@cotal-ai/cli 0.90.1 → 0.92.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chat/chat-view.d.ts +17 -0
- package/dist/chat/chat-view.d.ts.map +1 -0
- package/dist/chat/chat-view.js +179 -0
- package/dist/chat/chat-view.js.map +1 -0
- package/dist/chat/controller.d.ts +20 -0
- package/dist/chat/controller.d.ts.map +1 -0
- package/dist/chat/controller.js +132 -0
- package/dist/chat/controller.js.map +1 -0
- package/dist/chat/engine.d.ts +110 -0
- package/dist/chat/engine.d.ts.map +1 -0
- package/dist/chat/engine.js +224 -0
- package/dist/chat/engine.js.map +1 -0
- package/dist/chat/frontend.d.ts +35 -0
- package/dist/chat/frontend.d.ts.map +1 -0
- package/dist/chat/frontend.js +166 -0
- package/dist/chat/frontend.js.map +1 -0
- package/dist/chat/native-session.d.ts +93 -0
- package/dist/chat/native-session.d.ts.map +1 -0
- package/dist/chat/native-session.js +389 -0
- package/dist/chat/native-session.js.map +1 -0
- package/dist/chat/open-session.d.ts +8 -0
- package/dist/chat/open-session.d.ts.map +1 -0
- package/dist/chat/open-session.js +120 -0
- package/dist/chat/open-session.js.map +1 -0
- package/dist/chat/picker.d.ts +35 -0
- package/dist/chat/picker.d.ts.map +1 -0
- package/dist/chat/picker.js +99 -0
- package/dist/chat/picker.js.map +1 -0
- package/dist/chat/plain.d.ts +15 -0
- package/dist/chat/plain.d.ts.map +1 -0
- package/dist/chat/plain.js +249 -0
- package/dist/chat/plain.js.map +1 -0
- package/dist/chat/session.d.ts +222 -0
- package/dist/chat/session.d.ts.map +1 -0
- package/dist/chat/session.js +2 -0
- package/dist/chat/session.js.map +1 -0
- package/dist/chat/static-session.d.ts +61 -0
- package/dist/chat/static-session.d.ts.map +1 -0
- package/dist/chat/static-session.js +212 -0
- package/dist/chat/static-session.js.map +1 -0
- package/dist/chat/stdio-io.d.ts +35 -0
- package/dist/chat/stdio-io.d.ts.map +1 -0
- package/dist/chat/stdio-io.js +176 -0
- package/dist/chat/stdio-io.js.map +1 -0
- package/dist/chat/stdio.d.ts +173 -0
- package/dist/chat/stdio.d.ts.map +1 -0
- package/dist/chat/stdio.js +401 -0
- package/dist/chat/stdio.js.map +1 -0
- package/dist/chat/user-session.d.ts +21 -0
- package/dist/chat/user-session.d.ts.map +1 -0
- package/dist/chat/user-session.js +180 -0
- package/dist/chat/user-session.js.map +1 -0
- package/dist/chat/view.d.ts +217 -0
- package/dist/chat/view.d.ts.map +1 -0
- package/dist/chat/view.js +433 -0
- package/dist/chat/view.js.map +1 -0
- package/dist/command.d.ts +11 -3
- package/dist/command.d.ts.map +1 -1
- package/dist/command.js +395 -147
- package/dist/command.js.map +1 -1
- package/dist/commands/agents.d.ts +103 -11
- package/dist/commands/agents.d.ts.map +1 -1
- package/dist/commands/agents.js +506 -251
- package/dist/commands/agents.js.map +1 -1
- package/dist/commands/app-identity.d.ts.map +1 -1
- package/dist/commands/app-identity.js +10 -1
- package/dist/commands/app-identity.js.map +1 -1
- package/dist/commands/backup-maintenance.d.ts +4 -0
- package/dist/commands/backup-maintenance.d.ts.map +1 -0
- package/dist/commands/backup-maintenance.js +93 -0
- package/dist/commands/backup-maintenance.js.map +1 -0
- package/dist/commands/backup-read.d.ts +4 -0
- package/dist/commands/backup-read.d.ts.map +1 -0
- package/dist/commands/backup-read.js +30 -0
- package/dist/commands/backup-read.js.map +1 -0
- package/dist/commands/backup-restore.d.ts +7 -0
- package/dist/commands/backup-restore.d.ts.map +1 -0
- package/dist/commands/backup-restore.js +78 -0
- package/dist/commands/backup-restore.js.map +1 -0
- package/dist/commands/backup.d.ts +2 -1
- package/dist/commands/backup.d.ts.map +1 -1
- package/dist/commands/backup.js +123 -32
- package/dist/commands/backup.js.map +1 -1
- package/dist/commands/channel-members.d.ts +8 -0
- package/dist/commands/channel-members.d.ts.map +1 -0
- package/dist/commands/channel-members.js +144 -0
- package/dist/commands/channel-members.js.map +1 -0
- package/dist/commands/channels.d.ts +75 -22
- package/dist/commands/channels.d.ts.map +1 -1
- package/dist/commands/channels.js +181 -100
- package/dist/commands/channels.js.map +1 -1
- package/dist/commands/chat.d.ts +109 -0
- package/dist/commands/chat.d.ts.map +1 -0
- package/dist/commands/chat.js +227 -0
- package/dist/commands/chat.js.map +1 -0
- package/dist/commands/clean.d.ts +43 -1
- package/dist/commands/clean.d.ts.map +1 -1
- package/dist/commands/clean.js +90 -47
- package/dist/commands/clean.js.map +1 -1
- package/dist/commands/completion.d.ts +39 -1
- package/dist/commands/completion.d.ts.map +1 -1
- package/dist/commands/completion.js +211 -87
- package/dist/commands/completion.js.map +1 -1
- package/dist/commands/config.d.ts +33 -0
- package/dist/commands/config.d.ts.map +1 -0
- package/dist/commands/config.js +159 -0
- package/dist/commands/config.js.map +1 -0
- package/dist/commands/console.d.ts.map +1 -1
- package/dist/commands/console.js +25 -7
- package/dist/commands/console.js.map +1 -1
- package/dist/commands/describe.d.ts +63 -31
- package/dist/commands/describe.d.ts.map +1 -1
- package/dist/commands/describe.js +270 -136
- package/dist/commands/describe.js.map +1 -1
- package/dist/commands/doctor.d.ts +11 -6
- package/dist/commands/doctor.d.ts.map +1 -1
- package/dist/commands/doctor.js +195 -288
- package/dist/commands/doctor.js.map +1 -1
- package/dist/commands/down-services.d.ts +29 -0
- package/dist/commands/down-services.d.ts.map +1 -0
- package/dist/commands/down-services.js +129 -0
- package/dist/commands/down-services.js.map +1 -0
- package/dist/commands/down.d.ts +37 -11
- package/dist/commands/down.d.ts.map +1 -1
- package/dist/commands/down.js +384 -117
- package/dist/commands/down.js.map +1 -1
- package/dist/commands/endpoint-authoring.d.ts +6 -0
- package/dist/commands/endpoint-authoring.d.ts.map +1 -0
- package/dist/commands/endpoint-authoring.js +130 -0
- package/dist/commands/endpoint-authoring.js.map +1 -0
- package/dist/commands/endpoint-deregister.d.ts +5 -0
- package/dist/commands/endpoint-deregister.d.ts.map +1 -0
- package/dist/commands/endpoint-deregister.js +70 -0
- package/dist/commands/endpoint-deregister.js.map +1 -0
- package/dist/commands/endpoint.d.ts +118 -0
- package/dist/commands/endpoint.d.ts.map +1 -0
- package/dist/commands/endpoint.js +177 -0
- package/dist/commands/endpoint.js.map +1 -0
- package/dist/commands/endpoints.d.ts +27 -1
- package/dist/commands/endpoints.d.ts.map +1 -1
- package/dist/commands/endpoints.js +42 -30
- package/dist/commands/endpoints.js.map +1 -1
- package/dist/commands/ext.d.ts +38 -1
- package/dist/commands/ext.d.ts.map +1 -1
- package/dist/commands/ext.js +84 -49
- package/dist/commands/ext.js.map +1 -1
- package/dist/commands/feedback.d.ts +58 -1
- package/dist/commands/feedback.d.ts.map +1 -1
- package/dist/commands/feedback.js +119 -47
- package/dist/commands/feedback.js.map +1 -1
- package/dist/commands/help.d.ts +20 -0
- package/dist/commands/help.d.ts.map +1 -0
- package/dist/commands/help.js +52 -0
- package/dist/commands/help.js.map +1 -0
- package/dist/commands/history-clear.d.ts +14 -0
- package/dist/commands/history-clear.d.ts.map +1 -0
- package/dist/commands/history-clear.js +74 -0
- package/dist/commands/history-clear.js.map +1 -0
- package/dist/commands/history.d.ts +146 -4
- package/dist/commands/history.d.ts.map +1 -1
- package/dist/commands/history.js +437 -19
- package/dist/commands/history.js.map +1 -1
- package/dist/commands/join.d.ts.map +1 -1
- package/dist/commands/join.js +7 -3
- package/dist/commands/join.js.map +1 -1
- package/dist/commands/meshes-add.d.ts +3 -0
- package/dist/commands/meshes-add.d.ts.map +1 -1
- package/dist/commands/meshes-add.js +41 -34
- package/dist/commands/meshes-add.js.map +1 -1
- package/dist/commands/meshes-wizard.js +3 -3
- package/dist/commands/meshes-wizard.js.map +1 -1
- package/dist/commands/mint-endpoint-caller.d.ts +5 -0
- package/dist/commands/mint-endpoint-caller.d.ts.map +1 -0
- package/dist/commands/mint-endpoint-caller.js +130 -0
- package/dist/commands/mint-endpoint-caller.js.map +1 -0
- package/dist/commands/mint.d.ts +2 -37
- package/dist/commands/mint.d.ts.map +1 -1
- package/dist/commands/mint.js +142 -325
- package/dist/commands/mint.js.map +1 -1
- package/dist/commands/models.d.ts +30 -8
- package/dist/commands/models.d.ts.map +1 -1
- package/dist/commands/models.js +72 -41
- package/dist/commands/models.js.map +1 -1
- package/dist/commands/persona-remote.d.ts +5 -0
- package/dist/commands/persona-remote.d.ts.map +1 -0
- package/dist/commands/persona-remote.js +237 -0
- package/dist/commands/persona-remote.js.map +1 -0
- package/dist/commands/persona.d.ts +91 -0
- package/dist/commands/persona.d.ts.map +1 -0
- package/dist/commands/persona.js +200 -0
- package/dist/commands/persona.js.map +1 -0
- package/dist/commands/personas.d.ts.map +1 -1
- package/dist/commands/personas.js +16 -59
- package/dist/commands/personas.js.map +1 -1
- package/dist/commands/reset-space-apply.d.ts +5 -0
- package/dist/commands/reset-space-apply.d.ts.map +1 -0
- package/dist/commands/reset-space-apply.js +127 -0
- package/dist/commands/reset-space-apply.js.map +1 -0
- package/dist/commands/reset-store-apply.d.ts +35 -0
- package/dist/commands/reset-store-apply.d.ts.map +1 -0
- package/dist/commands/reset-store-apply.js +216 -0
- package/dist/commands/reset-store-apply.js.map +1 -0
- package/dist/commands/reset.d.ts +26 -0
- package/dist/commands/reset.d.ts.map +1 -0
- package/dist/commands/reset.js +155 -0
- package/dist/commands/reset.js.map +1 -0
- package/dist/commands/runtimes.d.ts +26 -1
- package/dist/commands/runtimes.d.ts.map +1 -1
- package/dist/commands/runtimes.js +68 -32
- package/dist/commands/runtimes.js.map +1 -1
- package/dist/commands/send.d.ts +91 -6
- package/dist/commands/send.d.ts.map +1 -1
- package/dist/commands/send.js +180 -106
- package/dist/commands/send.js.map +1 -1
- package/dist/commands/service-actions.d.ts +6 -0
- package/dist/commands/service-actions.d.ts.map +1 -0
- package/dist/commands/service-actions.js +413 -0
- package/dist/commands/service-actions.js.map +1 -0
- package/dist/commands/service-log-follow.d.ts +5 -0
- package/dist/commands/service-log-follow.d.ts.map +1 -0
- package/dist/commands/service-log-follow.js +107 -0
- package/dist/commands/service-log-follow.js.map +1 -0
- package/dist/commands/service-registry.d.ts +67 -0
- package/dist/commands/service-registry.d.ts.map +1 -0
- package/dist/commands/service-registry.js +275 -0
- package/dist/commands/service-registry.js.map +1 -0
- package/dist/commands/service-set-stop.d.ts +6 -0
- package/dist/commands/service-set-stop.d.ts.map +1 -0
- package/dist/commands/service-set-stop.js +164 -0
- package/dist/commands/service-set-stop.js.map +1 -0
- package/dist/commands/service-unit-entry.d.ts +5 -0
- package/dist/commands/service-unit-entry.d.ts.map +1 -0
- package/dist/commands/service-unit-entry.js +113 -0
- package/dist/commands/service-unit-entry.js.map +1 -0
- package/dist/commands/setup-start.d.ts +21 -0
- package/dist/commands/setup-start.d.ts.map +1 -0
- package/dist/commands/setup-start.js +95 -0
- package/dist/commands/setup-start.js.map +1 -0
- package/dist/commands/setup.d.ts +86 -100
- package/dist/commands/setup.d.ts.map +1 -1
- package/dist/commands/setup.js +766 -487
- package/dist/commands/setup.js.map +1 -1
- package/dist/commands/space-delete.d.ts +3 -0
- package/dist/commands/space-delete.d.ts.map +1 -0
- package/dist/commands/space-delete.js +386 -0
- package/dist/commands/space-delete.js.map +1 -0
- package/dist/commands/space-registration.d.ts +92 -0
- package/dist/commands/space-registration.d.ts.map +1 -0
- package/dist/commands/space-registration.js +394 -0
- package/dist/commands/space-registration.js.map +1 -0
- package/dist/commands/space.d.ts +128 -0
- package/dist/commands/space.d.ts.map +1 -0
- package/dist/commands/space.js +230 -0
- package/dist/commands/space.js.map +1 -0
- package/dist/commands/spawn-manifest.d.ts.map +1 -1
- package/dist/commands/spawn-manifest.js +2 -2
- package/dist/commands/spawn-manifest.js.map +1 -1
- package/dist/commands/spawn-preview.d.ts +9 -0
- package/dist/commands/spawn-preview.d.ts.map +1 -0
- package/dist/commands/spawn-preview.js +68 -0
- package/dist/commands/spawn-preview.js.map +1 -0
- package/dist/commands/spawn.d.ts +81 -21
- package/dist/commands/spawn.d.ts.map +1 -1
- package/dist/commands/spawn.js +254 -107
- package/dist/commands/spawn.js.map +1 -1
- package/dist/commands/stack-down.d.ts +20 -0
- package/dist/commands/stack-down.d.ts.map +1 -0
- package/dist/commands/stack-down.js +313 -0
- package/dist/commands/stack-down.js.map +1 -0
- package/dist/commands/stack-up.d.ts +154 -0
- package/dist/commands/stack-up.d.ts.map +1 -0
- package/dist/commands/stack-up.js +498 -0
- package/dist/commands/stack-up.js.map +1 -0
- package/dist/commands/stack-user-auth.d.ts +52 -0
- package/dist/commands/stack-user-auth.d.ts.map +1 -0
- package/dist/commands/stack-user-auth.js +128 -0
- package/dist/commands/stack-user-auth.js.map +1 -0
- package/dist/commands/status.d.ts +244 -5
- package/dist/commands/status.d.ts.map +1 -1
- package/dist/commands/status.js +1044 -407
- package/dist/commands/status.js.map +1 -1
- package/dist/commands/sync.d.ts +23 -0
- package/dist/commands/sync.d.ts.map +1 -1
- package/dist/commands/sync.js +69 -17
- package/dist/commands/sync.js.map +1 -1
- package/dist/commands/team-agent-apply.d.ts +5 -0
- package/dist/commands/team-agent-apply.d.ts.map +1 -0
- package/dist/commands/team-agent-apply.js +204 -0
- package/dist/commands/team-agent-apply.js.map +1 -0
- package/dist/commands/team-agent-remove.d.ts +87 -0
- package/dist/commands/team-agent-remove.d.ts.map +1 -0
- package/dist/commands/team-agent-remove.js +348 -0
- package/dist/commands/team-agent-remove.js.map +1 -0
- package/dist/commands/team-boot-controller.d.ts +11 -0
- package/dist/commands/team-boot-controller.d.ts.map +1 -0
- package/dist/commands/team-boot-controller.js +176 -0
- package/dist/commands/team-boot-controller.js.map +1 -0
- package/dist/commands/team-channel-remove.d.ts +167 -0
- package/dist/commands/team-channel-remove.d.ts.map +1 -0
- package/dist/commands/team-channel-remove.js +486 -0
- package/dist/commands/team-channel-remove.js.map +1 -0
- package/dist/commands/team-deploy-apply.d.ts +11 -0
- package/dist/commands/team-deploy-apply.d.ts.map +1 -0
- package/dist/commands/team-deploy-apply.js +320 -0
- package/dist/commands/team-deploy-apply.js.map +1 -0
- package/dist/commands/team-mixed-remove.d.ts +8 -0
- package/dist/commands/team-mixed-remove.d.ts.map +1 -0
- package/dist/commands/team-mixed-remove.js +207 -0
- package/dist/commands/team-mixed-remove.js.map +1 -0
- package/dist/commands/team.d.ts +51 -0
- package/dist/commands/team.d.ts.map +1 -0
- package/dist/commands/team.js +728 -0
- package/dist/commands/team.js.map +1 -0
- package/dist/commands/topology.d.ts +4 -0
- package/dist/commands/topology.d.ts.map +1 -1
- package/dist/commands/topology.js +8 -0
- package/dist/commands/topology.js.map +1 -1
- package/dist/commands/up.d.ts +146 -6
- package/dist/commands/up.d.ts.map +1 -1
- package/dist/commands/up.js +1123 -131
- package/dist/commands/up.js.map +1 -1
- package/dist/commands/update.d.ts +13 -0
- package/dist/commands/update.d.ts.map +1 -1
- package/dist/commands/update.js +90 -22
- package/dist/commands/update.js.map +1 -1
- package/dist/commands/use.d.ts +16 -3
- package/dist/commands/use.d.ts.map +1 -1
- package/dist/commands/use.js +45 -19
- package/dist/commands/use.js.map +1 -1
- package/dist/commands/watch.d.ts +37 -0
- package/dist/commands/watch.d.ts.map +1 -0
- package/dist/commands/watch.js +106 -0
- package/dist/commands/watch.js.map +1 -0
- package/dist/commands/who.d.ts +79 -0
- package/dist/commands/who.d.ts.map +1 -0
- package/dist/commands/who.js +193 -0
- package/dist/commands/who.js.map +1 -0
- package/dist/commands/whoami.d.ts +56 -0
- package/dist/commands/whoami.d.ts.map +1 -0
- package/dist/commands/whoami.js +106 -0
- package/dist/commands/whoami.js.map +1 -0
- package/dist/console/app.d.ts.map +1 -1
- package/dist/console/app.js +8 -4
- package/dist/console/app.js.map +1 -1
- package/dist/console/commands.d.ts.map +1 -1
- package/dist/console/commands.js +12 -6
- package/dist/console/commands.js.map +1 -1
- package/dist/exec-endpoint/definition.d.ts +15 -0
- package/dist/exec-endpoint/definition.d.ts.map +1 -0
- package/dist/exec-endpoint/definition.js +56 -0
- package/dist/exec-endpoint/definition.js.map +1 -0
- package/dist/exec-endpoint/handler.d.ts +13 -0
- package/dist/exec-endpoint/handler.d.ts.map +1 -0
- package/dist/exec-endpoint/handler.js +155 -0
- package/dist/exec-endpoint/handler.js.map +1 -0
- package/dist/exec-endpoint/registration.d.ts +34 -0
- package/dist/exec-endpoint/registration.d.ts.map +1 -0
- package/dist/exec-endpoint/registration.js +148 -0
- package/dist/exec-endpoint/registration.js.map +1 -0
- package/dist/exec-endpoint/serve.d.ts +8 -0
- package/dist/exec-endpoint/serve.d.ts.map +1 -0
- package/dist/exec-endpoint/serve.js +159 -0
- package/dist/exec-endpoint/serve.js.map +1 -0
- package/dist/exec-endpoint/service-adapter.d.ts +6 -0
- package/dist/exec-endpoint/service-adapter.d.ts.map +1 -0
- package/dist/exec-endpoint/service-adapter.js +110 -0
- package/dist/exec-endpoint/service-adapter.js.map +1 -0
- package/dist/ext-loader.d.ts +10 -0
- package/dist/ext-loader.d.ts.map +1 -1
- package/dist/ext-loader.js +61 -13
- package/dist/ext-loader.js.map +1 -1
- package/dist/help.d.ts +18 -0
- package/dist/help.d.ts.map +1 -0
- package/dist/help.js +256 -0
- package/dist/help.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +446 -119
- package/dist/index.js.map +1 -1
- package/dist/lib/assist.d.ts.map +1 -1
- package/dist/lib/assist.js +3 -2
- package/dist/lib/assist.js.map +1 -1
- package/dist/lib/attach-client.d.ts +7 -6
- package/dist/lib/attach-client.d.ts.map +1 -1
- package/dist/lib/attach-client.js +14 -15
- package/dist/lib/attach-client.js.map +1 -1
- package/dist/lib/auth-proc.d.ts +3 -3
- package/dist/lib/auth-proc.d.ts.map +1 -1
- package/dist/lib/auth-proc.js +8 -8
- package/dist/lib/auth-proc.js.map +1 -1
- package/dist/lib/backup-artifact.d.ts +41 -1
- package/dist/lib/backup-artifact.d.ts.map +1 -1
- package/dist/lib/backup-artifact.js +96 -22
- package/dist/lib/backup-artifact.js.map +1 -1
- package/dist/lib/broker-service.d.ts +19 -0
- package/dist/lib/broker-service.d.ts.map +1 -0
- package/dist/lib/broker-service.js +369 -0
- package/dist/lib/broker-service.js.map +1 -0
- package/dist/lib/cancel.js +1 -1
- package/dist/lib/cancel.js.map +1 -1
- package/dist/lib/choose-target.d.ts +10 -0
- package/dist/lib/choose-target.d.ts.map +1 -0
- package/dist/lib/choose-target.js +42 -0
- package/dist/lib/choose-target.js.map +1 -0
- package/dist/lib/command-path.d.ts +13 -0
- package/dist/lib/command-path.d.ts.map +1 -0
- package/dist/lib/command-path.js +40 -0
- package/dist/lib/command-path.js.map +1 -0
- package/dist/lib/completion-install.d.ts +29 -0
- package/dist/lib/completion-install.d.ts.map +1 -0
- package/dist/lib/completion-install.js +369 -0
- package/dist/lib/completion-install.js.map +1 -0
- package/dist/lib/completion-scripts.d.ts +4 -0
- package/dist/lib/completion-scripts.d.ts.map +1 -0
- package/dist/lib/completion-scripts.js +15 -0
- package/dist/lib/completion-scripts.js.map +1 -0
- package/dist/lib/completion.d.ts.map +1 -1
- package/dist/lib/completion.js +4 -1
- package/dist/lib/completion.js.map +1 -1
- package/dist/lib/confirmation-required.d.ts +13 -0
- package/dist/lib/confirmation-required.d.ts.map +1 -0
- package/dist/lib/confirmation-required.js +10 -0
- package/dist/lib/confirmation-required.js.map +1 -0
- package/dist/lib/control.d.ts +65 -6
- package/dist/lib/control.d.ts.map +1 -1
- package/dist/lib/control.js +121 -27
- package/dist/lib/control.js.map +1 -1
- package/dist/lib/controller-preserve.d.ts +12 -0
- package/dist/lib/controller-preserve.d.ts.map +1 -0
- package/dist/lib/controller-preserve.js +373 -0
- package/dist/lib/controller-preserve.js.map +1 -0
- package/dist/lib/controller-restore.d.ts +38 -0
- package/dist/lib/controller-restore.d.ts.map +1 -0
- package/dist/lib/controller-restore.js +205 -0
- package/dist/lib/controller-restore.js.map +1 -0
- package/dist/lib/controller-resume.d.ts +92 -0
- package/dist/lib/controller-resume.d.ts.map +1 -0
- package/dist/lib/controller-resume.js +300 -0
- package/dist/lib/controller-resume.js.map +1 -0
- package/dist/lib/credential-authority.d.ts +17 -0
- package/dist/lib/credential-authority.d.ts.map +1 -0
- package/dist/lib/credential-authority.js +29 -0
- package/dist/lib/credential-authority.js.map +1 -0
- package/dist/lib/default-persona.d.ts +38 -0
- package/dist/lib/default-persona.d.ts.map +1 -0
- package/dist/lib/default-persona.js +85 -0
- package/dist/lib/default-persona.js.map +1 -0
- package/dist/lib/delivery-proc.d.ts +9 -9
- package/dist/lib/delivery-proc.d.ts.map +1 -1
- package/dist/lib/delivery-proc.js +44 -23
- package/dist/lib/delivery-proc.js.map +1 -1
- package/dist/lib/endpoint-capability-gates.d.ts +10 -0
- package/dist/lib/endpoint-capability-gates.d.ts.map +1 -0
- package/dist/lib/endpoint-capability-gates.js +70 -0
- package/dist/lib/endpoint-capability-gates.js.map +1 -0
- package/dist/lib/endpoint-client.d.ts +23 -0
- package/dist/lib/endpoint-client.d.ts.map +1 -0
- package/dist/lib/endpoint-client.js +46 -0
- package/dist/lib/endpoint-client.js.map +1 -0
- package/dist/lib/endpoint-errors.d.ts +20 -0
- package/dist/lib/endpoint-errors.d.ts.map +1 -0
- package/dist/lib/endpoint-errors.js +46 -0
- package/dist/lib/endpoint-errors.js.map +1 -0
- package/dist/lib/endpoint-goal.d.ts +19 -0
- package/dist/lib/endpoint-goal.d.ts.map +1 -0
- package/dist/lib/endpoint-goal.js +31 -0
- package/dist/lib/endpoint-goal.js.map +1 -0
- package/dist/lib/endpoint-inventory.d.ts +30 -0
- package/dist/lib/endpoint-inventory.d.ts.map +1 -0
- package/dist/lib/endpoint-inventory.js +79 -0
- package/dist/lib/endpoint-inventory.js.map +1 -0
- package/dist/lib/endpoint-references.d.ts +22 -0
- package/dist/lib/endpoint-references.d.ts.map +1 -0
- package/dist/lib/endpoint-references.js +44 -0
- package/dist/lib/endpoint-references.js.map +1 -0
- package/dist/lib/endpoint-scatter.d.ts +57 -0
- package/dist/lib/endpoint-scatter.d.ts.map +1 -0
- package/dist/lib/endpoint-scatter.js +75 -0
- package/dist/lib/endpoint-scatter.js.map +1 -0
- package/dist/lib/endpoint-selection.d.ts +35 -0
- package/dist/lib/endpoint-selection.d.ts.map +1 -0
- package/dist/lib/endpoint-selection.js +80 -0
- package/dist/lib/endpoint-selection.js.map +1 -0
- package/dist/lib/install-umask.d.ts +6 -0
- package/dist/lib/install-umask.d.ts.map +1 -0
- package/dist/lib/install-umask.js +15 -0
- package/dist/lib/install-umask.js.map +1 -0
- package/dist/lib/isolated-broker.d.ts.map +1 -1
- package/dist/lib/isolated-broker.js +9 -5
- package/dist/lib/isolated-broker.js.map +1 -1
- package/dist/lib/local-process-stop.d.ts.map +1 -1
- package/dist/lib/local-process-stop.js +7 -1
- package/dist/lib/local-process-stop.js.map +1 -1
- package/dist/lib/manager-proc.d.ts +11 -5
- package/dist/lib/manager-proc.d.ts.map +1 -1
- package/dist/lib/manager-proc.js +12 -17
- package/dist/lib/manager-proc.js.map +1 -1
- package/dist/lib/manifest/apply.d.ts +4 -1
- package/dist/lib/manifest/apply.d.ts.map +1 -1
- package/dist/lib/manifest/apply.js +1 -1
- package/dist/lib/manifest/apply.js.map +1 -1
- package/dist/lib/manifest/ledger.d.ts +3 -1
- package/dist/lib/manifest/ledger.d.ts.map +1 -1
- package/dist/lib/manifest/ledger.js +16 -3
- package/dist/lib/manifest/ledger.js.map +1 -1
- package/dist/lib/manifest/schema.d.ts +1 -117
- package/dist/lib/manifest/schema.d.ts.map +1 -1
- package/dist/lib/manifest/schema.js +1 -95
- package/dist/lib/manifest/schema.js.map +1 -1
- package/dist/lib/offline-recipient.d.ts +5 -0
- package/dist/lib/offline-recipient.d.ts.map +1 -0
- package/dist/lib/offline-recipient.js +7 -0
- package/dist/lib/offline-recipient.js.map +1 -0
- package/dist/lib/onboard.js +3 -3
- package/dist/lib/onboard.js.map +1 -1
- package/dist/lib/persona-files.d.ts +29 -0
- package/dist/lib/persona-files.d.ts.map +1 -0
- package/dist/lib/persona-files.js +154 -0
- package/dist/lib/persona-files.js.map +1 -0
- package/dist/lib/personas.d.ts +3 -0
- package/dist/lib/personas.d.ts.map +1 -1
- package/dist/lib/personas.js +14 -2
- package/dist/lib/personas.js.map +1 -1
- package/dist/lib/prompts.d.ts +16 -0
- package/dist/lib/prompts.d.ts.map +1 -0
- package/dist/lib/prompts.js +35 -0
- package/dist/lib/prompts.js.map +1 -0
- package/dist/lib/protected-records.d.ts +2 -0
- package/dist/lib/protected-records.d.ts.map +1 -0
- package/dist/lib/protected-records.js +3 -0
- package/dist/lib/protected-records.js.map +1 -0
- package/dist/lib/registry-errors.d.ts +4 -0
- package/dist/lib/registry-errors.d.ts.map +1 -0
- package/dist/lib/registry-errors.js +6 -0
- package/dist/lib/registry-errors.js.map +1 -0
- package/dist/lib/reset-space-plan.d.ts +36 -0
- package/dist/lib/reset-space-plan.d.ts.map +1 -0
- package/dist/lib/reset-space-plan.js +202 -0
- package/dist/lib/reset-space-plan.js.map +1 -0
- package/dist/lib/restore.d.ts +13 -1
- package/dist/lib/restore.d.ts.map +1 -1
- package/dist/lib/restore.js +73 -11
- package/dist/lib/restore.js.map +1 -1
- package/dist/lib/seat-resume.d.ts +4 -1
- package/dist/lib/seat-resume.d.ts.map +1 -1
- package/dist/lib/seat-resume.js +7 -4
- package/dist/lib/seat-resume.js.map +1 -1
- package/dist/lib/service-adapters.d.ts +32 -0
- package/dist/lib/service-adapters.d.ts.map +1 -0
- package/dist/lib/service-adapters.js +55 -0
- package/dist/lib/service-adapters.js.map +1 -0
- package/dist/lib/service-census.d.ts +73 -0
- package/dist/lib/service-census.d.ts.map +1 -0
- package/dist/lib/service-census.js +42 -0
- package/dist/lib/service-census.js.map +1 -0
- package/dist/lib/service-definitions.d.ts +49 -0
- package/dist/lib/service-definitions.d.ts.map +1 -0
- package/dist/lib/service-definitions.js +61 -0
- package/dist/lib/service-definitions.js.map +1 -0
- package/dist/lib/service-install-intent.d.ts +48 -0
- package/dist/lib/service-install-intent.d.ts.map +1 -0
- package/dist/lib/service-install-intent.js +95 -0
- package/dist/lib/service-install-intent.js.map +1 -0
- package/dist/lib/service-instances.d.ts +143 -0
- package/dist/lib/service-instances.d.ts.map +1 -0
- package/dist/lib/service-instances.js +193 -0
- package/dist/lib/service-instances.js.map +1 -0
- package/dist/lib/service-journal.d.ts +38 -0
- package/dist/lib/service-journal.d.ts.map +1 -0
- package/dist/lib/service-journal.js +210 -0
- package/dist/lib/service-journal.js.map +1 -0
- package/dist/lib/service-launchd-plan.d.ts +21 -0
- package/dist/lib/service-launchd-plan.d.ts.map +1 -0
- package/dist/lib/service-launchd-plan.js +69 -0
- package/dist/lib/service-launchd-plan.js.map +1 -0
- package/dist/lib/service-launchd-unit.d.ts +20 -0
- package/dist/lib/service-launchd-unit.d.ts.map +1 -0
- package/dist/lib/service-launchd-unit.js +66 -0
- package/dist/lib/service-launchd-unit.js.map +1 -0
- package/dist/lib/service-presets.d.ts +17 -0
- package/dist/lib/service-presets.d.ts.map +1 -0
- package/dist/lib/service-presets.js +139 -0
- package/dist/lib/service-presets.js.map +1 -0
- package/dist/lib/service-private-seed.d.ts +7 -0
- package/dist/lib/service-private-seed.d.ts.map +1 -0
- package/dist/lib/service-private-seed.js +64 -0
- package/dist/lib/service-private-seed.js.map +1 -0
- package/dist/lib/service-private-tree.d.ts +6 -0
- package/dist/lib/service-private-tree.d.ts.map +1 -0
- package/dist/lib/service-private-tree.js +100 -0
- package/dist/lib/service-private-tree.js.map +1 -0
- package/dist/lib/service-process.d.ts +146 -0
- package/dist/lib/service-process.d.ts.map +1 -0
- package/dist/lib/service-process.js +862 -0
- package/dist/lib/service-process.js.map +1 -0
- package/dist/lib/service-stopped-allocation.d.ts +6 -0
- package/dist/lib/service-stopped-allocation.d.ts.map +1 -0
- package/dist/lib/service-stopped-allocation.js +42 -0
- package/dist/lib/service-stopped-allocation.js.map +1 -0
- package/dist/lib/service-supervision.d.ts +59 -0
- package/dist/lib/service-supervision.d.ts.map +1 -0
- package/dist/lib/service-supervision.js +71 -0
- package/dist/lib/service-supervision.js.map +1 -0
- package/dist/lib/service-systemd-attempt-read.d.ts +40 -0
- package/dist/lib/service-systemd-attempt-read.d.ts.map +1 -0
- package/dist/lib/service-systemd-attempt-read.js +80 -0
- package/dist/lib/service-systemd-attempt-read.js.map +1 -0
- package/dist/lib/service-systemd-control.d.ts +38 -0
- package/dist/lib/service-systemd-control.d.ts.map +1 -0
- package/dist/lib/service-systemd-control.js +141 -0
- package/dist/lib/service-systemd-control.js.map +1 -0
- package/dist/lib/service-systemd-files.d.ts +8 -0
- package/dist/lib/service-systemd-files.d.ts.map +1 -0
- package/dist/lib/service-systemd-files.js +63 -0
- package/dist/lib/service-systemd-files.js.map +1 -0
- package/dist/lib/service-systemd-install.d.ts +17 -0
- package/dist/lib/service-systemd-install.d.ts.map +1 -0
- package/dist/lib/service-systemd-install.js +146 -0
- package/dist/lib/service-systemd-install.js.map +1 -0
- package/dist/lib/service-systemd-plan.d.ts +28 -0
- package/dist/lib/service-systemd-plan.d.ts.map +1 -0
- package/dist/lib/service-systemd-plan.js +56 -0
- package/dist/lib/service-systemd-plan.js.map +1 -0
- package/dist/lib/service-systemd-reseed.d.ts +16 -0
- package/dist/lib/service-systemd-reseed.d.ts.map +1 -0
- package/dist/lib/service-systemd-reseed.js +106 -0
- package/dist/lib/service-systemd-reseed.js.map +1 -0
- package/dist/lib/service-systemd-uninstall-plan.d.ts +29 -0
- package/dist/lib/service-systemd-uninstall-plan.d.ts.map +1 -0
- package/dist/lib/service-systemd-uninstall-plan.js +56 -0
- package/dist/lib/service-systemd-uninstall-plan.js.map +1 -0
- package/dist/lib/service-systemd-uninstall.d.ts +17 -0
- package/dist/lib/service-systemd-uninstall.d.ts.map +1 -0
- package/dist/lib/service-systemd-uninstall.js +106 -0
- package/dist/lib/service-systemd-uninstall.js.map +1 -0
- package/dist/lib/service-systemd-unit.d.ts +28 -0
- package/dist/lib/service-systemd-unit.d.ts.map +1 -0
- package/dist/lib/service-systemd-unit.js +73 -0
- package/dist/lib/service-systemd-unit.js.map +1 -0
- package/dist/lib/service-systemd.d.ts +49 -0
- package/dist/lib/service-systemd.d.ts.map +1 -0
- package/dist/lib/service-systemd.js +134 -0
- package/dist/lib/service-systemd.js.map +1 -0
- package/dist/lib/service-uninstall-intent.d.ts +38 -0
- package/dist/lib/service-uninstall-intent.d.ts.map +1 -0
- package/dist/lib/service-uninstall-intent.js +74 -0
- package/dist/lib/service-uninstall-intent.js.map +1 -0
- package/dist/lib/service-unit-action.d.ts +24 -0
- package/dist/lib/service-unit-action.d.ts.map +1 -0
- package/dist/lib/service-unit-action.js +61 -0
- package/dist/lib/service-unit-action.js.map +1 -0
- package/dist/lib/setup-log.d.ts +5 -4
- package/dist/lib/setup-log.d.ts.map +1 -1
- package/dist/lib/setup-log.js +18 -9
- package/dist/lib/setup-log.js.map +1 -1
- package/dist/lib/shown-time.d.ts +5 -0
- package/dist/lib/shown-time.d.ts.map +1 -0
- package/dist/lib/shown-time.js +9 -0
- package/dist/lib/shown-time.js.map +1 -0
- package/dist/lib/space-schema-inspection.d.ts +73 -0
- package/dist/lib/space-schema-inspection.d.ts.map +1 -0
- package/dist/lib/space-schema-inspection.js +118 -0
- package/dist/lib/space-schema-inspection.js.map +1 -0
- package/dist/lib/space-schema-report.d.ts +82 -0
- package/dist/lib/space-schema-report.d.ts.map +1 -0
- package/dist/lib/space-schema-report.js +109 -0
- package/dist/lib/space-schema-report.js.map +1 -0
- package/dist/lib/spawn-defaults.d.ts +14 -0
- package/dist/lib/spawn-defaults.d.ts.map +1 -0
- package/dist/lib/spawn-defaults.js +20 -0
- package/dist/lib/spawn-defaults.js.map +1 -0
- package/dist/lib/stack-journal.d.ts +166 -0
- package/dist/lib/stack-journal.d.ts.map +1 -0
- package/dist/lib/stack-journal.js +421 -0
- package/dist/lib/stack-journal.js.map +1 -0
- package/dist/lib/stack-resume.d.ts +35 -0
- package/dist/lib/stack-resume.d.ts.map +1 -0
- package/dist/lib/stack-resume.js +123 -0
- package/dist/lib/stack-resume.js.map +1 -0
- package/dist/lib/status.d.ts +19 -20
- package/dist/lib/status.d.ts.map +1 -1
- package/dist/lib/status.js +41 -40
- package/dist/lib/status.js.map +1 -1
- package/dist/lib/stdout-owner.d.ts +17 -0
- package/dist/lib/stdout-owner.d.ts.map +1 -0
- package/dist/lib/stdout-owner.js +44 -0
- package/dist/lib/stdout-owner.js.map +1 -0
- package/dist/lib/steps.d.ts.map +1 -1
- package/dist/lib/steps.js +3 -2
- package/dist/lib/steps.js.map +1 -1
- package/dist/lib/systemd-supervision.d.ts +11 -4
- package/dist/lib/systemd-supervision.d.ts.map +1 -1
- package/dist/lib/systemd-supervision.js +19 -8
- package/dist/lib/systemd-supervision.js.map +1 -1
- package/dist/lib/team-additive-attempt.d.ts +286 -0
- package/dist/lib/team-additive-attempt.d.ts.map +1 -0
- package/dist/lib/team-additive-attempt.js +387 -0
- package/dist/lib/team-additive-attempt.js.map +1 -0
- package/dist/lib/team-additive-native.d.ts +17 -0
- package/dist/lib/team-additive-native.d.ts.map +1 -0
- package/dist/lib/team-additive-native.js +29 -0
- package/dist/lib/team-additive-native.js.map +1 -0
- package/dist/lib/team-agent-removal.d.ts +104 -0
- package/dist/lib/team-agent-removal.d.ts.map +1 -0
- package/dist/lib/team-agent-removal.js +121 -0
- package/dist/lib/team-agent-removal.js.map +1 -0
- package/dist/lib/team-channel-removal.d.ts +220 -0
- package/dist/lib/team-channel-removal.d.ts.map +1 -0
- package/dist/lib/team-channel-removal.js +258 -0
- package/dist/lib/team-channel-removal.js.map +1 -0
- package/dist/lib/team-deploy-inspection.d.ts +59 -0
- package/dist/lib/team-deploy-inspection.d.ts.map +1 -0
- package/dist/lib/team-deploy-inspection.js +177 -0
- package/dist/lib/team-deploy-inspection.js.map +1 -0
- package/dist/lib/team-fresh.d.ts +73 -0
- package/dist/lib/team-fresh.d.ts.map +1 -0
- package/dist/lib/team-fresh.js +207 -0
- package/dist/lib/team-fresh.js.map +1 -0
- package/dist/lib/team-removal-reconcile.d.ts +118 -0
- package/dist/lib/team-removal-reconcile.d.ts.map +1 -0
- package/dist/lib/team-removal-reconcile.js +90 -0
- package/dist/lib/team-removal-reconcile.js.map +1 -0
- package/dist/lib/team-removal-record.d.ts +7 -0
- package/dist/lib/team-removal-record.d.ts.map +1 -0
- package/dist/lib/team-removal-record.js +46 -0
- package/dist/lib/team-removal-record.js.map +1 -0
- package/dist/lib/team-retained.d.ts +33 -0
- package/dist/lib/team-retained.d.ts.map +1 -0
- package/dist/lib/team-retained.js +55 -0
- package/dist/lib/team-retained.js.map +1 -0
- package/dist/lib/theme.d.ts.map +1 -1
- package/dist/lib/theme.js +9 -8
- package/dist/lib/theme.js.map +1 -1
- package/dist/lib/transient.d.ts +14 -9
- package/dist/lib/transient.d.ts.map +1 -1
- package/dist/lib/transient.js +25 -18
- package/dist/lib/transient.js.map +1 -1
- package/dist/lib/up-report.d.ts +3 -0
- package/dist/lib/up-report.d.ts.map +1 -1
- package/dist/lib/up-report.js +4 -1
- package/dist/lib/up-report.js.map +1 -1
- package/dist/lib/version.d.ts +8 -2
- package/dist/lib/version.d.ts.map +1 -1
- package/dist/lib/version.js +16 -9
- package/dist/lib/version.js.map +1 -1
- package/dist/managed-handoff.d.ts +3 -0
- package/dist/managed-handoff.d.ts.map +1 -1
- package/dist/managed-handoff.js +5 -0
- package/dist/managed-handoff.js.map +1 -1
- package/dist/seed/paths.d.ts +1 -1
- package/dist/seed/paths.js +1 -1
- package/dist/seed/reconcile.d.ts.map +1 -1
- package/dist/seed/reconcile.js +19 -3
- package/dist/seed/reconcile.js.map +1 -1
- package/dist/ui.d.ts +10 -2
- package/dist/ui.d.ts.map +1 -1
- package/dist/ui.js +28 -6
- package/dist/ui.js.map +1 -1
- package/dist/watch-data.d.ts +15 -0
- package/dist/watch-data.d.ts.map +1 -0
- package/dist/watch-data.js +66 -0
- package/dist/watch-data.js.map +1 -0
- package/dist/watch-json.d.ts +5 -0
- package/dist/watch-json.d.ts.map +1 -0
- package/dist/watch-json.js +132 -0
- package/dist/watch-json.js.map +1 -0
- package/dist/watch-view.d.ts +8 -0
- package/dist/watch-view.d.ts.map +1 -0
- package/dist/watch-view.js +65 -0
- package/dist/watch-view.js.map +1 -0
- package/package.json +8 -5
- package/dist/commands/service.d.ts +0 -17
- package/dist/commands/service.d.ts.map +0 -1
- package/dist/commands/service.js +0 -589
- package/dist/commands/service.js.map +0 -1
package/dist/commands/down.js
CHANGED
|
@@ -1,15 +1,23 @@
|
|
|
1
|
-
import { readFileSync, rmSync, statSync } from "node:fs";
|
|
2
|
-
import {
|
|
1
|
+
import { existsSync, lstatSync, readdirSync, readFileSync, rmSync, statSync } from "node:fs";
|
|
2
|
+
import { homedir } from "node:os";
|
|
3
|
+
import { join, relative, resolve as resolvePath } from "node:path";
|
|
3
4
|
import {} from "@cotal-ai/core";
|
|
4
|
-
import { abortMaintenanceCut, acquireMaintenanceLock, assertSingleSpaceBroker, authDir, beginMaintenanceCut, clearPreservationCommitIntent, clearPreservationPrepareIntent, completeMaintenanceCut, loadMeshes, meshesForRoot, localProcessPath, localProcessPathCandidates, readMaintenanceJournal, readMaintenanceResumeDocument, readPreservationCommitIntent, readPreservationPrepareIntent, readStoreIdentity, recordPreservationManagerCommit, releaseMaintenanceLock, removeMeshesByRoot,
|
|
5
|
+
import { CommandFailure, localRecordName, presentationOf, abortMaintenanceCut, acquireMaintenanceLock, assertSingleSpaceBroker, authDir, beginMaintenanceCut, clearPreservationCommitIntent, clearPreservationPrepareIntent, completeMaintenanceCut, loadMeshes, meshesForRoot, localProcessPath, localProcessPathCandidates, canonicalRoot, brokerAddressForDisplay, findMesh, localMeshesForRoot, preparedSpaceAt, soleSpaceOf, writeResult, readMaintenanceJournal, readContainedRecord, readMaintenanceResumeDocument, readPreservationCommitIntent, readPreservationPrepareIntent, readStoreIdentity, recordPreservationManagerCommit, releaseMaintenanceLock, removeMeshesByRoot, sameStoreIdentity, writePreservationCommitIntent, writePreservationPrepareIntent, DELIVERY_PIDFILE, MANAGER_DELIVERY_AWARE_MARKER, MANAGER_PIDFILE, WEB_PIDFILE, MAINTENANCE_RESUME_DOCUMENT_VERSION, writeMaintenanceResumeDocument, loadSeatWriterGeneration, materializeFromManifest, seatCheckpointDir, } from "@cotal-ai/workspace";
|
|
5
6
|
import { jetstreamManager } from "@nats-io/jetstream";
|
|
6
|
-
import { DEV_OWNER, dialerFor, isReachable, LEASE_TTL_MS, MANAGER_LEASE_KEY, MANAGER_LEASE_TTL_MS, deliveryBucket, managerBucket, presenceBucket, parsePrincipalKey, principalKey, standaloneConnectOpts, } from "@cotal-ai/core";
|
|
7
|
-
import {
|
|
7
|
+
import { DEV_OWNER, dialerFor, isReachable, realDirNoSymlink, LEASE_TTL_MS, MANAGER_LEASE_KEY, MANAGER_LEASE_TTL_MS, deliveryBucket, managerBucket, presenceBucket, parsePrincipalKey, principalKey, standaloneConnectOpts, } from "@cotal-ai/core";
|
|
8
|
+
import { localProcessSurface } from "../ext-loader.js";
|
|
8
9
|
import { c } from "../ui.js";
|
|
9
10
|
import { cotalRoot } from "../lib/paths.js";
|
|
10
11
|
import { parsePid, probeLiveness, readPidfile } from "@cotal-ai/workspace";
|
|
11
12
|
import { resolveRuntimeSpace } from "../lib/status.js";
|
|
12
13
|
import { downManifest } from "./down-manifest.js";
|
|
14
|
+
import { listLedgerFiles } from "../lib/manifest/ledger.js";
|
|
15
|
+
import { freshTeamAttemptSettled, listFreshTeamAttempts, listFreshTeamSummaries } from "../lib/team-fresh.js";
|
|
16
|
+
import { additiveTeamRecordedState, listAdditiveTeamAttempts, retainedAdditiveTeamAttempts } from "../lib/team-additive-attempt.js";
|
|
17
|
+
import { service, serviceComplete, validateServiceArguments } from "./service-registry.js";
|
|
18
|
+
import { stopNamedServiceSet } from "./service-set-stop.js";
|
|
19
|
+
import { readLocalServiceCensus } from "../lib/service-census.js";
|
|
20
|
+
import { assertBareDownServicesVerified, bareDownServicesView, planBareDownServices, stopBareDownServices } from "./down-services.js";
|
|
13
21
|
import { askManager, resolveControlTarget } from "../lib/control.js";
|
|
14
22
|
import { connectOrExit, userViewAuthOrExit } from "../lib/connect.js";
|
|
15
23
|
import { waitForEndpointUnreachable } from "../lib/endpoint-cut.js";
|
|
@@ -17,124 +25,367 @@ import { captureSeatCheckpoint } from "../lib/seat-capture.js";
|
|
|
17
25
|
import { processRecorded, stopLocalProcess } from "../lib/local-process-stop.js";
|
|
18
26
|
import { stopManager } from "../lib/manager-proc.js";
|
|
19
27
|
import { removeDeliveryCredentials, stopDelivery } from "../lib/delivery-proc.js";
|
|
28
|
+
import { controllerStackRecorded, nothingRunning, stackDown, validateStackDownArguments } from "./stack-down.js";
|
|
29
|
+
import { recordedProcessLine } from "../lib/stack-journal.js";
|
|
20
30
|
/** Complete selective component names without importing installed packages. */
|
|
21
31
|
export function downComplete(argv) {
|
|
22
32
|
if (argv.some((word) => word === "-f" || word === "--file" || word === "--run"))
|
|
23
33
|
return { items: [], directive: "nofiles" };
|
|
24
34
|
if ((argv[argv.length - 1] ?? "").startsWith("-"))
|
|
25
35
|
return { items: [], directive: "nofiles" };
|
|
26
|
-
|
|
27
|
-
return {
|
|
28
|
-
items: extensionNames("local-process").filter((name) => !used.has(name)).map((value) => ({ value })),
|
|
29
|
-
directive: "nofiles",
|
|
30
|
-
};
|
|
36
|
+
return serviceComplete(["stop", ...(argv.length ? argv : [""])]);
|
|
31
37
|
}
|
|
32
|
-
|
|
33
|
-
|
|
38
|
+
function namedStopArguments(args) {
|
|
39
|
+
return { ...args, positionals: ["stop", args.positionals[0]] };
|
|
40
|
+
}
|
|
41
|
+
/** Named stops use only the owned-service controller. Multiple definitions require complete
|
|
42
|
+
* set selection, reservation and impact preflight. Legacy bare-stack integration stays separate. */
|
|
43
|
+
export function validateDownArguments(args) {
|
|
44
|
+
presentationOf(args.values);
|
|
45
|
+
if (args.positionals.length) {
|
|
46
|
+
for (const name of args.positionals)
|
|
47
|
+
localRecordName(name);
|
|
48
|
+
if (args.values["with-agents"] !== undefined)
|
|
49
|
+
throw new CommandFailure("refused", "USAGE_INVALID", "named down does not accept --with-agents; no flag was dropped", { remedy: "use cotal service stop <manager-name> --instance <full-id> --with-agents for the exact owned manager and its native impact review" });
|
|
50
|
+
if (args.values.instance !== undefined && args.positionals.length !== 1)
|
|
51
|
+
throw new CommandFailure("refused", "USAGE_INVALID", "--instance qualifies one service name, never a multi-service set");
|
|
52
|
+
const allowed = new Set(["space", "instance", "yes", "dry-run", "json", "plain"]);
|
|
53
|
+
if (Object.keys(args.values).some((name) => !allowed.has(name)))
|
|
54
|
+
throw new CommandFailure("refused", "USAGE_INVALID", "named down accepts only space, instance, confirmation, preview and presentation flags; no whole-stack or manifest option was ignored");
|
|
55
|
+
if (new Set(args.positionals).size !== args.positionals.length)
|
|
56
|
+
throw new CommandFailure("refused", "USAGE_INVALID", "name each service once; duplicate targets were not silently collapsed");
|
|
57
|
+
for (const name of args.positionals)
|
|
58
|
+
validateServiceArguments({ ...args, positionals: ["stop", name] });
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
if (args.values.instance !== undefined)
|
|
62
|
+
throw new CommandFailure("refused", "USAGE_INVALID", "--instance needs one explicit service definition name");
|
|
63
|
+
if (controllerStackRecorded(cotalRoot()))
|
|
64
|
+
return validateStackDownArguments(cotalRoot(), args.values);
|
|
65
|
+
if (args.values["dry-run"] === true && args.values.yes === true)
|
|
66
|
+
throw new CommandFailure("refused", "USAGE_INVALID", "--yes acknowledges a guarded apply, not a read-only stack preview");
|
|
67
|
+
if ((args.values.json !== undefined || args.values.plain !== undefined) && args.values["dry-run"] === true && args.values.file === undefined && args.values.run === undefined && args.values["preserve-state"] === undefined && args.values["store-dir"] === undefined && args.values["session-store"] === undefined)
|
|
68
|
+
return;
|
|
69
|
+
if (args.values.yes !== undefined)
|
|
70
|
+
throw new CommandFailure("refused", "UNSUPPORTED", "--yes applies only to a controller stack, and this root has none; a bare stop here needs no --yes, and nothing was stopped", { remedy: "run `cotal down` from this root without --yes" });
|
|
71
|
+
if ((args.values.json !== undefined || args.values.plain !== undefined) && !(bareStop(args.values) && stoppedLegacyStack()))
|
|
72
|
+
throw new CommandFailure("refused", "UNSUPPORTED", "--json and --plain apply only to a controller stack, a --dry-run preview or a stack that is already stopped; a bare stop here prints its own lines, and nothing was stopped", { remedy: "run `cotal down` from this root without --json or --plain; `cotal down --dry-run --json` reads this root's stack" });
|
|
73
|
+
}
|
|
74
|
+
/** The one route that stops the stack `up` starts from the machine home. */
|
|
75
|
+
const MACHINE_HOME_STOP = "stop the machine-home stack with cotal down --preserve-state, which keeps its state for the next cotal up";
|
|
76
|
+
/** A bare stack preview is a local record census, never an effect plan or stop authority. */
|
|
77
|
+
function previewWholeStack(args) {
|
|
78
|
+
const root = canonicalRoot(cotalRoot());
|
|
79
|
+
const selectedSpace = args.values.space;
|
|
80
|
+
const target = { root, ...(selectedSpace ? { space: selectedSpace } : {}) };
|
|
81
|
+
if (root === canonicalRoot(homedir()))
|
|
82
|
+
throw new CommandFailure("refused", "CONFLICT", "the machine home is not an isolated project root for a whole-stack preview", { target, remedy: MACHINE_HOME_STOP });
|
|
83
|
+
let mesh;
|
|
84
|
+
let maintenance;
|
|
85
|
+
let components;
|
|
86
|
+
let services, serviceStops;
|
|
87
|
+
let additiveRecords, additiveAttempts;
|
|
88
|
+
let bootAttempts, bootSummaries;
|
|
89
|
+
let otherBrokerRegistrations;
|
|
90
|
+
// A root with no control directory, or with no stack registered at it, holds no stack. That is a
|
|
91
|
+
// plain miss, not records that could not be read.
|
|
92
|
+
const noStack = () => new CommandFailure("refused", "TARGET_NOT_FOUND", "there is no stack at this folder's root, so there is nothing to preview", { target, remedy: "run `cotal down --dry-run` from the folder where `cotal up` started the stack" });
|
|
93
|
+
try {
|
|
94
|
+
try {
|
|
95
|
+
lstatSync(join(root, ".cotal"));
|
|
96
|
+
}
|
|
97
|
+
catch (error) {
|
|
98
|
+
if (error.code === "ENOENT")
|
|
99
|
+
throw noStack();
|
|
100
|
+
throw error;
|
|
101
|
+
}
|
|
102
|
+
if (!realDirNoSymlink(root, ".cotal"))
|
|
103
|
+
throw new Error("missing project control directory");
|
|
104
|
+
const local = localMeshesForRoot(root), sole = local[0];
|
|
105
|
+
if (!local.length)
|
|
106
|
+
throw noStack();
|
|
107
|
+
if (local.length !== 1 || sole?.origin !== "up")
|
|
108
|
+
throw new Error("no unique locally started stack at this root");
|
|
109
|
+
const candidate = selectedSpace ? findMesh(selectedSpace) : sole;
|
|
110
|
+
if (!candidate || candidate.origin !== "up" || candidate.space !== sole.space || canonicalRoot(candidate.root) !== root)
|
|
111
|
+
throw new Error("space does not belong to the selected root");
|
|
112
|
+
mesh = candidate;
|
|
113
|
+
assertSingleSpaceBroker(authDir(root), "down preview");
|
|
114
|
+
otherBrokerRegistrations = loadMeshes().filter((row) => row.space !== mesh.space && row.server === mesh.server)
|
|
115
|
+
.map((row) => ({ space: row.space, root: row.root, origin: row.origin ?? "not recorded" }));
|
|
116
|
+
maintenance = readMaintenanceJournal(root);
|
|
117
|
+
const context = { root, space: mesh.space };
|
|
118
|
+
components = localProcessSurface().map((component) => {
|
|
119
|
+
const pidfile = localProcessPath(component.pidFile, context);
|
|
120
|
+
const state = pidfileState(pidfile);
|
|
121
|
+
return { name: component.name, label: component.label, pidfile, recorded: processRecorded(component, context), liveness: state.liveness, pid: state.pid ?? null, note: state.note ?? null };
|
|
122
|
+
});
|
|
123
|
+
services = readLocalServiceCensus(mesh.space);
|
|
124
|
+
serviceStops = planBareDownServices(mesh.space);
|
|
125
|
+
additiveRecords = listLedgerFiles(root, { requireReadable: true });
|
|
126
|
+
additiveAttempts = listAdditiveTeamAttempts(root);
|
|
127
|
+
bootAttempts = listFreshTeamAttempts(root);
|
|
128
|
+
bootSummaries = listFreshTeamSummaries(root);
|
|
129
|
+
}
|
|
130
|
+
catch (error) {
|
|
131
|
+
if (error instanceof CommandFailure)
|
|
132
|
+
throw error;
|
|
133
|
+
throw new CommandFailure("refused", "CONFLICT", "the local stack, process or service records, or maintenance state could not be inspected consistently; no stop target was inferred", { target });
|
|
134
|
+
}
|
|
135
|
+
const byBootId = new Map(bootSummaries.valid.map((summary) => [summary.deploymentId, summary]));
|
|
136
|
+
const unsettledBootAttempts = bootAttempts.valid.filter((attempt) => !freshTeamAttemptSettled(attempt, byBootId.get(attempt.deploymentId)));
|
|
137
|
+
const result = { kind: "whole-stack-local-preview", space: mesh.space, root, recordedBroker: brokerAddressForDisplay(mesh.server) ?? null,
|
|
138
|
+
maintenance: maintenance?.state ?? "none-recorded", withAgentsRequested: args.values["with-agents"] === true,
|
|
139
|
+
components, ...services, serviceStops, otherBrokerRegistrations,
|
|
140
|
+
additiveLedgers: additiveRecords.valid.map(({ ledger }) => ({ deploymentId: ledger.runId, space: ledger.space, agents: ledger.created.agents.length, channels: ledger.created.channels.length })),
|
|
141
|
+
unreadableAdditiveLedgers: additiveRecords.refused.map(({ path }) => path),
|
|
142
|
+
retainedAdditiveAttempts: additiveAttempts.valid.map((attempt) => ({ deploymentId: attempt.deploymentId, space: attempt.space, server: brokerAddressForDisplay(attempt.server) ?? "not displayable", createdAt: attempt.createdAt, recordedState: additiveTeamRecordedState(attempt, additiveAttempts) })),
|
|
143
|
+
unreadableAdditiveAttempts: additiveAttempts.refused.map(({ path }) => path),
|
|
144
|
+
unsettledBootAttempts: unsettledBootAttempts.map((attempt) => ({ deploymentId: attempt.deploymentId, space: attempt.space, server: brokerAddressForDisplay(attempt.server) ?? "not displayable", createdAt: attempt.createdAt })),
|
|
145
|
+
unreadableBootRecords: [...bootAttempts.refused, ...bootSummaries.refused].map(({ path }) => path),
|
|
146
|
+
brokerSharing: "exact recorded address matches only; aliases and live tenants not checked", agentImpact: "not-established", serviceInstanceScope: "selected-space workstation records only; root ownership and live state not established",
|
|
147
|
+
dryRun: true, effectAttempted: false, reserved: false };
|
|
148
|
+
writeResult(presentationOf(args.values), { command: "down", target: { root, space: mesh.space }, result,
|
|
149
|
+
completeness: "partial", partial: { message: "Pidfiles, additive ledgers, service records, supervisor receipts and retained attempts are not a complete owned stack or native agent-impact plan. No process identity, service root ownership, broker sharing or stop authority was established." } }, (data) => ({ sections: [
|
|
150
|
+
{ title: "Whole-stack local inspection", blocks: [{ kind: "fields", rows: [["Space", data.space], ["Root", data.root], ["Maintenance", data.maintenance], ["Saved service definitions", String(data.serviceDefinitions.length)], ["Saved service instances", String(data.serviceRecords.length)], ["Supervisor receipts", String(data.supervisors.length)], ["Retained native attempts", String(data.nativeAttempts.length)], ["Other exact-address registrations", String(data.otherBrokerRegistrations.length)], ["Additive ledgers", String(data.additiveLedgers.length)], ["Unreadable additive ledgers", String(data.unreadableAdditiveLedgers.length)], ["Retained additive deployments", String(data.retainedAdditiveAttempts.length)], ["Unreadable additive attempts", String(data.unreadableAdditiveAttempts.length)], ["Unsettled fresh attempts", String(data.unsettledBootAttempts.length)], ["Unreadable fresh records", String(data.unreadableBootRecords.length)], ["Deprovision agents", data.withAgentsRequested ? "requested; impact unknown" : "not requested; process impact unknown"], ["Stop authority", "not established"]] }, { kind: "lines", lines: [{ text: "This is a read of local records, not a stop plan. Liveness does not prove identity, and service, broker-sharing and agent consequences are not checked. No process was signalled.", tone: "waiting" }] }] },
|
|
151
|
+
{ title: "Recorded broker address matches", blocks: [data.otherBrokerRegistrations.length ? { kind: "table", columns: [{ key: "space", label: "Other space" }, { key: "root", label: "Recorded root" }, { key: "origin", label: "Registration" }], rows: data.otherBrokerRegistrations.slice(0, 100) } : { kind: "lines", lines: ["No other registration uses this exact broker address in the local workstation registry."] }, { kind: "lines", lines: [...(data.otherBrokerRegistrations.length > 100 ? ["Additional exact-address matches are in JSON."] : []), "An exact-address match is a sharing warning. No match is not proof of an exclusive broker: aliases, remote tenants and live attachments were not checked."] }] },
|
|
152
|
+
{ title: "Recorded additive deployments", blocks: [data.additiveLedgers.length ? { kind: "table", columns: [{ key: "id", label: "Deployment" }, { key: "space", label: "Recorded space" }, { key: "agents", label: "Agent rows" }, { key: "channels", label: "Channel rows" }], rows: data.additiveLedgers.slice(0, 100).map((row) => ({ id: row.deploymentId, space: row.space, agents: String(row.agents), channels: String(row.channels) })) } : { kind: "lines", lines: ["No readable additive ledgers under this project root."] }, { kind: "lines", lines: [...(data.additiveLedgers.length > 100 ? ["Additional additive ledgers are in JSON."] : []), ...data.unreadableAdditiveLedgers.slice(0, 100).map((path) => `Unreadable ledger: ${path}`), ...(data.unreadableAdditiveLedgers.length > 100 ? ["Additional unreadable paths are in JSON."] : []), "An additive ledger is not whole-stack ownership. A recorded or unreadable one blocks the retained bare apply; this preview changes nothing."] }] },
|
|
153
|
+
{ title: "Retained additive deployments", blocks: [data.retainedAdditiveAttempts.length ? { kind: "table", columns: [{ key: "id", label: "Deployment" }, { key: "space", label: "Space" }, { key: "state", label: "Recorded state" }, { key: "time", label: "Intent recorded" }], rows: data.retainedAdditiveAttempts.slice(0, 100).map((attempt) => ({ id: attempt.deploymentId, space: attempt.space, state: attempt.recordedState, time: attempt.createdAt })) } : { kind: "lines", lines: ["No readable additive attempts under this root."] }, { kind: "lines", lines: [...data.unreadableAdditiveAttempts.slice(0, 100).map((path) => `Unreadable additive attempt: ${path}`), ...(data.retainedAdditiveAttempts.length > 100 || data.unreadableAdditiveAttempts.length > 100 ? ["Additional attempts or paths are in JSON."] : []), "Unsettled or unremoved additive deployments block the legacy bare stop. A full matched static agent-retirement receipt releases only its original deployment's blocker; all other ownership and process guards remain."] }] },
|
|
154
|
+
{ title: "Fresh boot attempts", blocks: [data.unsettledBootAttempts.length ? { kind: "table", columns: [{ key: "deploymentId", label: "Deployment" }, { key: "space", label: "Space" }, { key: "server", label: "Recorded broker" }, { key: "createdAt", label: "Intent recorded" }], rows: data.unsettledBootAttempts.slice(0, 100) } : { kind: "lines", lines: ["No unsettled readable fresh boot attempts under this root."] }, { kind: "lines", lines: [...data.unreadableBootRecords.slice(0, 100).map((path) => `Unreadable fresh record: ${path}`), ...(data.unsettledBootAttempts.length > 100 || data.unreadableBootRecords.length > 100 ? ["Additional attempts or unreadable paths are in JSON."] : []), "An unsettled fresh attempt or unreadable record blocks the retained bare apply; a missing summary does not prove the broker never started."] }] },
|
|
155
|
+
{ title: "Local process records", blocks: [data.components.length ? { kind: "table", columns: [{ key: "name", label: "Component" }, { key: "state", label: "Pidfile probe" }, { key: "record", label: "Recorded" }, { key: "pid", label: "PID" }], rows: data.components.map((row) => ({ name: row.label, state: row.liveness, record: row.recorded ? "yes" : "no", pid: row.pid === null ? "not pinned" : String(row.pid) })) } : { kind: "lines", lines: ["No local process descriptors were found."] }] },
|
|
156
|
+
{ title: "Selected-space service definitions", blocks: [data.serviceDefinitions.length ? { kind: "table", columns: [{ key: "name", label: "Definition" }, { key: "launch", label: "Launch type" }, { key: "instances", label: "Instance records" }], rows: data.serviceDefinitions.slice(0, 100).map((row) => ({ name: row.name, launch: row.launch, instances: String(row.instanceRecords) })) } : { kind: "lines", lines: ["No saved service definitions in this space's workstation store."] }, ...(data.serviceDefinitions.length > 100 ? [{ kind: "lines", lines: ["Additional definitions are in JSON."] }] : [])] },
|
|
157
|
+
{ title: "Selected-space service instances", blocks: [data.serviceRecords.length ? { kind: "table", columns: [{ key: "definition", label: "Definition" }, { key: "instance", label: "Full instance" }, { key: "state", label: "Recorded state" }, { key: "host", label: "Recorded host" }], rows: data.serviceRecords.slice(0, 100).map((row) => ({ definition: row.definition, instance: row.instanceId, state: row.recordedState, host: row.host })) } : { kind: "lines", lines: ["No saved service instances in this space's workstation store."] }, { kind: "lines", lines: [...(data.serviceRecords.length > 100 ? ["Additional service records are in JSON."] : []), "These records are scoped by space, not proven owned by this project root. Their recorded state is not live process or supervisor status; the next section observes each process on this host."] }] },
|
|
158
|
+
...(data.serviceStops.length ? bareDownServicesView(data.space, data.serviceStops).sections : [{ title: "Services bare down stops first", blocks: [{ kind: "lines", lines: ["No saved service instance in this space, so bare down stops no service first."] }] }]),
|
|
159
|
+
{ title: "Recorded native supervisors", blocks: [data.supervisors.length ? { kind: "table", columns: [{ key: "definition", label: "Definition" }, { key: "instance", label: "Full instance" }, { key: "mechanism", label: "Mechanism" }, { key: "unit", label: "Recorded unit" }], rows: data.supervisors.slice(0, 100).map((row) => ({ definition: row.definition, instance: row.instanceId, mechanism: row.mechanism, unit: row.unit })) } : { kind: "lines", lines: ["No supervisor receipts in this space's workstation store."] }, { kind: "lines", lines: [...(data.supervisors.length > 100 ? ["Additional supervisor receipts are in JSON."] : []), "A receipt is not a live unit observation or authority to stop it. No native service status request was made."] }] },
|
|
160
|
+
{ title: "Retained native attempts", blocks: [data.nativeAttempts.length ? { kind: "table", columns: [{ key: "kind", label: "Action" }, { key: "definition", label: "Definition" }, { key: "instance", label: "Full instance" }, { key: "step", label: "Step" }, { key: "position", label: "Position" }], rows: data.nativeAttempts.slice(0, 100).map((row) => ({ kind: row.kind, definition: row.definition, instance: row.instanceId, step: row.step, position: row.position })) } : { kind: "lines", lines: ["No retained install, uninstall or unit-action attempts in this space's workstation store."] }, { kind: "lines", lines: [...(data.nativeAttempts.length > 100 ? ["Additional attempts and their full IDs are in JSON."] : []), "A submitted or unknown step may already have changed native state. This preview neither reconciles nor retries it."] }] },
|
|
161
|
+
] }));
|
|
162
|
+
}
|
|
163
|
+
/** A bare stop, its preview included: no flag beyond --dry-run, --with-agents and the presentation
|
|
164
|
+
* flags. */
|
|
165
|
+
function bareStop(values) {
|
|
166
|
+
return Object.entries(values).every(([name, value]) => ["dry-run", "with-agents", "json", "plain"].includes(name) || value === undefined || Array.isArray(value) && value.length === 0);
|
|
167
|
+
}
|
|
168
|
+
/** Whether any process record (`*.pid`) remains in `<root>/.cotal`. */
|
|
169
|
+
const pidRecordsUnder = (root) => readdirSync(join(root, ".cotal")).some((name) => name.endsWith(".pid"));
|
|
170
|
+
/** A legacy root whose stack is not running, told apart from a folder that never had one. No
|
|
171
|
+
* registration names the root, because its own down removed the last one, and no `*.pid` record
|
|
172
|
+
* remains at the top of its `.cotal`. The root still holds the broker configuration a start rendered
|
|
173
|
+
* there (`server-open.conf`, or `auth/server.conf` in auth mode) or a space prepared there. When the
|
|
174
|
+
* root names its space, none of that space's saved services runs either. Undefined when any of that
|
|
175
|
+
* is missing, so bare down refuses rather than guess. `nothingRunning` reads every other record a
|
|
176
|
+
* local-process descriptor names under the root, for any space, before it answers. */
|
|
177
|
+
function stoppedLegacyStack() {
|
|
178
|
+
const root = canonicalRoot(cotalRoot());
|
|
179
|
+
if (root === canonicalRoot(homedir()) || !realDirNoSymlink(root, ".cotal") || meshesForRoot(root).length || pidRecordsUnder(root))
|
|
180
|
+
return undefined;
|
|
181
|
+
let space;
|
|
182
|
+
try {
|
|
183
|
+
space = soleSpaceOf(authDir(root));
|
|
184
|
+
}
|
|
185
|
+
catch {
|
|
186
|
+
return undefined;
|
|
187
|
+
}
|
|
188
|
+
const prepared = preparedSpaceAt(root);
|
|
189
|
+
if (!prepared && !existsSync(join(root, ".cotal", "server-open.conf")) && !existsSync(join(authDir(root), "server.conf")))
|
|
190
|
+
return undefined;
|
|
191
|
+
space ??= prepared?.space;
|
|
192
|
+
if (space !== undefined && planBareDownServices(space).some((row) => row.action !== "already-stopped"))
|
|
193
|
+
return undefined;
|
|
194
|
+
return { root, ...(space === undefined ? {} : { space }) };
|
|
195
|
+
}
|
|
196
|
+
/** Why bare down found no stack of its own at this root, with the one step that moves it on. */
|
|
197
|
+
function noOwnedStack(root) {
|
|
198
|
+
const target = { root };
|
|
199
|
+
const absent = new CommandFailure("refused", "TARGET_NOT_FOUND", "there is no stack at this folder's root, so there is nothing to stop", { target, remedy: "run `cotal down` from the folder where `cotal up` started the stack" });
|
|
200
|
+
const unclassified = new CommandFailure("refused", "CONFLICT", "the local root has no unique owned stack registration and real control directory; no whole-stack stop target was inferred", { target, remedy: "run `cotal status` here to see what this folder records" });
|
|
201
|
+
if (!existsSync(join(root, ".cotal")))
|
|
202
|
+
return absent;
|
|
203
|
+
if (!realDirNoSymlink(root, ".cotal"))
|
|
204
|
+
return unclassified;
|
|
205
|
+
let local, registered;
|
|
206
|
+
try {
|
|
207
|
+
local = localMeshesForRoot(root);
|
|
208
|
+
registered = meshesForRoot(root).length;
|
|
209
|
+
}
|
|
210
|
+
catch {
|
|
211
|
+
return unclassified;
|
|
212
|
+
}
|
|
213
|
+
if (local.length > 1)
|
|
214
|
+
return new CommandFailure("refused", "CONFLICT", `${local.length} registrations name this root (${local.map((mesh) => `"${mesh.space}"`).join(", ")}); bare down did not pick one to stop`, {
|
|
215
|
+
target: { root, spaces: local.map((mesh) => mesh.space) },
|
|
216
|
+
remedy: "remove the one that does not run here with `cotal space forget <name>`",
|
|
217
|
+
});
|
|
218
|
+
// A registration of any kind, or a process record no registration explains, is a stack this
|
|
219
|
+
// cannot classify.
|
|
220
|
+
if (registered || pidRecordsUnder(root))
|
|
221
|
+
return unclassified;
|
|
222
|
+
return absent;
|
|
223
|
+
}
|
|
224
|
+
/** Keep the retained pidfile sweep from crossing an exact recorded broker-sharing boundary, and
|
|
225
|
+
* return the space's service instances it stops first, each one verified. This is not a complete
|
|
226
|
+
* live ownership or agent-impact proof. */
|
|
227
|
+
function guardLegacyBareDown() {
|
|
228
|
+
const root = canonicalRoot(cotalRoot());
|
|
229
|
+
const target = { root };
|
|
230
|
+
if (root === canonicalRoot(homedir()))
|
|
231
|
+
throw new CommandFailure("refused", "CONFLICT", "the machine home is not an isolated whole-stack stop root; no process was signalled", { target, remedy: MACHINE_HOME_STOP });
|
|
232
|
+
let mesh;
|
|
233
|
+
try {
|
|
234
|
+
if (!realDirNoSymlink(root, ".cotal"))
|
|
235
|
+
throw new Error("missing project control directory");
|
|
236
|
+
// A root that hosts several spaces refuses before the registration lookup, naming them.
|
|
237
|
+
try {
|
|
238
|
+
assertSingleSpaceBroker(authDir(root), "bare down");
|
|
239
|
+
}
|
|
240
|
+
catch (error) {
|
|
241
|
+
throw new CommandFailure("refused", "CONFLICT", error.message, { target });
|
|
242
|
+
}
|
|
243
|
+
const local = localMeshesForRoot(root), sole = local[0];
|
|
244
|
+
if (local.length !== 1 || sole?.origin !== "up")
|
|
245
|
+
throw new Error("no unique locally started stack at this root");
|
|
246
|
+
mesh = sole;
|
|
247
|
+
}
|
|
248
|
+
catch (error) {
|
|
249
|
+
if (error instanceof CommandFailure)
|
|
250
|
+
throw error;
|
|
251
|
+
throw noOwnedStack(root);
|
|
252
|
+
}
|
|
253
|
+
const scoped = { root, space: mesh.space };
|
|
254
|
+
const maintenance = readMaintenanceJournal(root);
|
|
255
|
+
// A validated active restore is complete, so its retained journal does not fence ordinary stop.
|
|
256
|
+
// Pending transitions and a journal naming another space still cannot authorize this sweep.
|
|
257
|
+
if (maintenance && (maintenance.state !== "active" || maintenance.space !== mesh.space))
|
|
258
|
+
throw new CommandFailure("refused", "LIFECYCLE_BLOCKED", "this stack retains a maintenance transition; ordinary bare down did not bypass it", { target: { ...scoped, state: maintenance.state } });
|
|
259
|
+
let ledgers;
|
|
260
|
+
try {
|
|
261
|
+
ledgers = listLedgerFiles(root, { requireReadable: true });
|
|
262
|
+
}
|
|
263
|
+
catch {
|
|
264
|
+
throw new CommandFailure("refused", "TARGET_UNAVAILABLE", "the root's additive ledger directory could not be inspected; bare down did not infer that it owns every resource", { target: scoped });
|
|
265
|
+
}
|
|
266
|
+
if (ledgers.valid.length || ledgers.refused.length)
|
|
267
|
+
throw new CommandFailure("refused", "LIFECYCLE_BLOCKED", "additive ownership ledgers or unreadable ledger records remain under this root; bare down did not adopt or stop their resources", { target: { ...scoped, deploymentIds: ledgers.valid.map(({ ledger }) => ledger.runId), unreadable: ledgers.refused.map(({ path }) => path) }, remedy: "finish each additive deployment's own lifecycle before a guarded whole-stack stop" });
|
|
268
|
+
let additiveAttempts;
|
|
269
|
+
try {
|
|
270
|
+
additiveAttempts = listAdditiveTeamAttempts(root);
|
|
271
|
+
}
|
|
272
|
+
catch {
|
|
273
|
+
throw new CommandFailure("refused", "TARGET_UNAVAILABLE", "the additive attempt inventory could not be read; bare down did not infer an empty resource set", { target: scoped });
|
|
274
|
+
}
|
|
275
|
+
if (retainedAdditiveTeamAttempts(additiveAttempts).length || additiveAttempts.refused.length)
|
|
276
|
+
throw new CommandFailure("refused", "LIFECYCLE_BLOCKED", "an additive attempt or returned additive deployment remains under this root; legacy bare down did not adopt its resources", { target: { ...scoped, deploymentIds: retainedAdditiveTeamAttempts(additiveAttempts).map((attempt) => attempt.deploymentId), unreadable: additiveAttempts.refused.map(({ path }) => path) } });
|
|
277
|
+
let attempts, summaries;
|
|
278
|
+
try {
|
|
279
|
+
attempts = listFreshTeamAttempts(root);
|
|
280
|
+
summaries = listFreshTeamSummaries(root);
|
|
281
|
+
}
|
|
282
|
+
catch {
|
|
283
|
+
throw new CommandFailure("refused", "TARGET_UNAVAILABLE", "fresh boot attempt or summary records could not be read; bare down did not infer stop authority", { target: scoped });
|
|
284
|
+
}
|
|
285
|
+
const returned = new Map(summaries.valid.map((summary) => [summary.deploymentId, summary]));
|
|
286
|
+
const unsettled = attempts.valid.filter((attempt) => !freshTeamAttemptSettled(attempt, returned.get(attempt.deploymentId)));
|
|
287
|
+
if (unsettled.length || attempts.refused.length || summaries.refused.length)
|
|
288
|
+
throw new CommandFailure("refused", "LIFECYCLE_BLOCKED", "a fresh boot attempt is unsettled or a boot record unreadable; legacy bare down did not stop a process whose original launch outcome is unknown", { target: { ...scoped, unsettledIds: unsettled.map((row) => row.deploymentId), unreadable: [...attempts.refused, ...summaries.refused].map(({ path }) => path) }, remedy: "inspect the original boot and process custody before any stop; the pidfile sweep is not recovery" });
|
|
289
|
+
const other = loadMeshes().filter((row) => row.space !== mesh.space && row.server === mesh.server);
|
|
290
|
+
if (other.length)
|
|
291
|
+
throw new CommandFailure("refused", "LIFECYCLE_BLOCKED", "another registered space names this exact broker address; bare down did not stop its shared listener", { target: { ...scoped, otherSpaces: other.map((row) => row.space) }, remedy: "inspect both registrations and their native ownership; an exact-address match is a blocker, while no match does not prove exclusivity" });
|
|
292
|
+
const services = planBareDownServices(mesh.space);
|
|
293
|
+
assertBareDownServicesVerified(mesh.space, services);
|
|
294
|
+
return { space: mesh.space, services };
|
|
295
|
+
}
|
|
296
|
+
/** Bare down reads each process record it stops where the record lies, as the stopped-stack census
|
|
297
|
+
* does. A record that read leaves unread (a link on its path, a record that is not a regular file,
|
|
298
|
+
* is larger than a record, cannot be opened or changes while it is read) refuses before the first
|
|
299
|
+
* stop, naming where reading stopped: no process behind it is read, signalled or unrecorded. */
|
|
300
|
+
function refuseUncontainedRecords(components, context) {
|
|
301
|
+
const unread = new Map();
|
|
302
|
+
for (const component of components) {
|
|
303
|
+
const record = readContainedRecord(context.root, localProcessPath(component.pidFile, context));
|
|
304
|
+
if (record.state === "unread" && !unread.has(record.at))
|
|
305
|
+
unread.set(record.at, recordedProcessLine({ name: component.name, path: relative(context.root, record.at), note: record.why }));
|
|
306
|
+
}
|
|
307
|
+
if (!unread.size)
|
|
308
|
+
return;
|
|
309
|
+
const paths = [...unread.keys()].map((at) => relative(context.root, at));
|
|
310
|
+
throw new CommandFailure("refused", "LIFECYCLE_BLOCKED", `process records under this root cannot be read in place (${[...unread.values()].join("; ")}), so bare down stopped nothing; it does not read or signal through them`, {
|
|
311
|
+
target: { root: context.root, space: context.space, processes: [...unread.values()] },
|
|
312
|
+
remedy: `check ${paths.join(", ")}; stop each process where it was started, and replace a link with this stack's own record or remove it, then run \`cotal down\` again`,
|
|
313
|
+
});
|
|
314
|
+
}
|
|
315
|
+
/** One named service is a thin native-controller alias. The retained bare-stack and manifest
|
|
316
|
+
* paths below have not yet been replaced by the approved whole-stack controller. */
|
|
34
317
|
export async function down(args) {
|
|
318
|
+
validateDownArguments(args);
|
|
319
|
+
if (args.positionals.length > 1)
|
|
320
|
+
return stopNamedServiceSet(args);
|
|
321
|
+
if (args.positionals.length)
|
|
322
|
+
return service(namedStopArguments(args), "down");
|
|
323
|
+
// A root whose stack the service controller owns stops only through its recorded members.
|
|
324
|
+
if (controllerStackRecorded(cotalRoot()))
|
|
325
|
+
return stackDown(cotalRoot(), args.values);
|
|
35
326
|
const values = args.values;
|
|
36
|
-
|
|
327
|
+
// A legacy root whose stack is already stopped: a bare down and its preview stop nothing.
|
|
328
|
+
if (bareStop(args.values)) {
|
|
329
|
+
const stopped = stoppedLegacyStack();
|
|
330
|
+
if (stopped)
|
|
331
|
+
return nothingRunning(presentationOf(args.values), stopped, values["with-agents"] === true && values["dry-run"] !== true);
|
|
332
|
+
}
|
|
333
|
+
if (values["dry-run"] && !values.file && !values.run && !values["preserve-state"] && !values["store-dir"] && !values["session-store"]?.length)
|
|
334
|
+
return previewWholeStack(args);
|
|
37
335
|
if (values["preserve-state"] && values["with-agents"])
|
|
38
|
-
throw new
|
|
39
|
-
if (values["with-agents"] && (
|
|
40
|
-
throw new
|
|
336
|
+
throw new CommandFailure("refused", "USAGE_INVALID", "--preserve-state cannot be combined with --with-agents");
|
|
337
|
+
if (values["with-agents"] && (values.file || values.run || values.space))
|
|
338
|
+
throw new CommandFailure("refused", "USAGE_INVALID", "--with-agents is bare-whole-stack only and cannot be combined with components, --space, --file, or --run");
|
|
41
339
|
if (values["preserve-state"]) {
|
|
42
|
-
if (
|
|
43
|
-
throw new
|
|
340
|
+
if (values.file || values.run || values["dry-run"] || values.space)
|
|
341
|
+
throw new CommandFailure("refused", "USAGE_INVALID", "--preserve-state is bare-whole-stack only and cannot be combined with components, --space, --file, --run, or --dry-run");
|
|
44
342
|
assertSingleSpaceBroker(authDir(cotalRoot()), "cotal down");
|
|
45
343
|
await preserveStateDown(values["store-dir"], assertSessionStores(values["session-store"] ?? []));
|
|
46
344
|
return;
|
|
47
345
|
}
|
|
48
346
|
if (values["store-dir"])
|
|
49
|
-
throw new
|
|
347
|
+
throw new CommandFailure("refused", "USAGE_INVALID", "--store-dir is only valid with down --preserve-state");
|
|
50
348
|
if (values["session-store"]?.length)
|
|
51
|
-
throw new
|
|
52
|
-
if ((values.file || values.run) &&
|
|
53
|
-
throw new
|
|
349
|
+
throw new CommandFailure("refused", "USAGE_INVALID", "--session-store is only valid with down --preserve-state");
|
|
350
|
+
if ((values.file || values.run) && values.space) {
|
|
351
|
+
throw new CommandFailure("refused", "USAGE_INVALID", "component names and --space cannot be combined with --file or --run");
|
|
54
352
|
}
|
|
55
353
|
if (values.file || values.run) {
|
|
56
354
|
await downManifest(values.file ?? "<run>", { run: values.run, dryRun: Boolean(values["dry-run"]) });
|
|
57
355
|
return;
|
|
58
356
|
}
|
|
59
|
-
if (values.space
|
|
60
|
-
throw new
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
const selected = (requested.length ? requested.map((name) => all.find((part) => part.name === name)) : all)
|
|
357
|
+
if (values.space)
|
|
358
|
+
throw new CommandFailure("refused", "USAGE_INVALID", "a bare stop takes no --space: `cotal down` stops the stack recorded at this folder's root", {
|
|
359
|
+
target: { root: cotalRoot(), space: values.space },
|
|
360
|
+
remedy: "run `cotal down` without --space from the stack's root; to stop one saved service, run `cotal service stop <service-name> --space <space>`",
|
|
361
|
+
});
|
|
362
|
+
const guarded = guardLegacyBareDown();
|
|
363
|
+
const selected = localProcessSurface()
|
|
67
364
|
.sort((a, b) => Number(Boolean(a.stopLast)) - Number(Boolean(b.stopLast)) || (a.order ?? 50) - (b.order ?? 50));
|
|
68
|
-
// A component whose START is target-resolved (`rootedAt: "target"` — the web dashboard) records
|
|
69
|
-
// its pidfile under the TARGET mesh's root, so a selective stop resolves the SAME mesh the start
|
|
70
|
-
// side did (registry current mesh first, `--space` to name one) instead of assuming this folder.
|
|
71
|
-
// Bare `cotal down` stays a sweep of this folder's stack: its pidfiles live here, and reaching
|
|
72
|
-
// into another mesh's root mid-sweep would stop a process the folder's broker does not own.
|
|
73
|
-
const targetAddressed = (component) => requested.length > 0 && component.rootedAt === "target";
|
|
74
|
-
if (values.space) {
|
|
75
|
-
const folderRooted = selected.filter((component) => !targetAddressed(component));
|
|
76
|
-
if (folderRooted.length)
|
|
77
|
-
throw new Error(`--space only applies to target-addressed components - ${folderRooted.map((component) => component.name).join(", ")} always stop${folderRooted.length === 1 ? "s" : ""} under this folder's root`);
|
|
78
|
-
}
|
|
79
365
|
// A `down` that touches this folder's stack stops the shared broker and its per-space daemons;
|
|
80
366
|
// none of them can address one space, so a multi-space root is refused up front rather than at
|
|
81
|
-
// the space-blind pidfile lookup below.
|
|
82
|
-
|
|
83
|
-
if (selected.some((component) => !targetAddressed(component)))
|
|
84
|
-
assertSingleSpaceBroker(authDir(cotalRoot()), "cotal down");
|
|
85
|
-
// Both contexts resolve lazily: a purely target-addressed stop must not require a mesh root at
|
|
86
|
-
// the cwd, and a folder sweep must not require a resolvable mesh target.
|
|
367
|
+
// the space-blind pidfile lookup below.
|
|
368
|
+
assertSingleSpaceBroker(authDir(cotalRoot()), "cotal down");
|
|
87
369
|
let folderContext;
|
|
88
370
|
const folderCtx = () => (folderContext ??= { root: cotalRoot(), space: resolveRuntimeSpace(process.cwd()) });
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
if (!targetContext) {
|
|
94
|
-
const target = resolveMeshTarget(process.cwd(), values.space ? { space: values.space } : {});
|
|
95
|
-
targetContext = { root: target.root, space: target.space };
|
|
96
|
-
}
|
|
97
|
-
return targetContext;
|
|
98
|
-
};
|
|
99
|
-
if (selected.some((component) => component.stopLast)) {
|
|
100
|
-
const selectedNames = new Set(selected.map((component) => component.name));
|
|
101
|
-
// Fail CLOSED: an unselected dependant that MIGHT be running (including one behind an
|
|
102
|
-
// unattributable/unknown pidfile) blocks a stop-last shutdown - stopping the broker out from
|
|
103
|
-
// under a live dependant we could not confirm gone is exactly the signer-orphan the contract
|
|
104
|
-
// forbids. `mayBeRunning`, not `processAlive` (which reads uncertainty as "not running").
|
|
105
|
-
// Folder context: the question is what depends on THIS folder's broker, so a dependant is
|
|
106
|
-
// judged by the record under this root regardless of how it would be addressed selectively.
|
|
107
|
-
const dependants = all.filter((component) => !selectedNames.has(component.name) && mayBeRunning(component, folderCtx()));
|
|
108
|
-
if (dependants.length) {
|
|
109
|
-
throw new Error(`cannot stop ${selected.filter((component) => component.stopLast).map((component) => component.name).join(", ")} while ${dependants.map((component) => component.name).join(", ")} ${dependants.length === 1 ? "is" : "are"} still running (or its liveness cannot be confirmed) - name them too, or run bare \`cotal down\``);
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
if (values["dry-run"]) {
|
|
113
|
-
const recorded = selected.filter((component) => processRecorded(component, contextFor(component)));
|
|
114
|
-
for (const component of recorded)
|
|
115
|
-
console.log(c.dim(`would stop ${component.label}`));
|
|
116
|
-
if (!recorded.length) {
|
|
117
|
-
const target = requested.length ? requested.join(", ") : "the local stack";
|
|
118
|
-
console.error(c.red(`Nothing running for ${target} (no recorded pidfiles).`));
|
|
119
|
-
process.exit(1);
|
|
120
|
-
}
|
|
121
|
-
console.log(c.dim("Dry run - nothing was changed. Re-run without --dry-run to stop these components."));
|
|
122
|
-
return;
|
|
123
|
-
}
|
|
371
|
+
refuseUncontainedRecords(selected, folderCtx());
|
|
372
|
+
// Every dry run returned or was refused above, so from here on this is the whole-stack stop of
|
|
373
|
+
// this folder's root. Its services stop first, through the service controller.
|
|
374
|
+
await stopBareDownServices(guarded.space, guarded.services, { style: "rich", withAgents: values["with-agents"] === true });
|
|
124
375
|
let any = false;
|
|
125
376
|
let allStopped = true;
|
|
126
377
|
for (const component of selected) {
|
|
127
|
-
any = processRecorded(component,
|
|
378
|
+
any = processRecorded(component, folderCtx()) || any;
|
|
128
379
|
if (component.stopLast && !allStopped) {
|
|
129
380
|
console.error(c.red(`✗ not stopping ${component.label} because an earlier component did not stop`));
|
|
130
381
|
continue;
|
|
131
382
|
}
|
|
132
383
|
try {
|
|
133
|
-
const context =
|
|
384
|
+
const context = folderCtx();
|
|
134
385
|
if (component.name === "manager")
|
|
135
386
|
await stopManager(context.space, { withAgents: values["with-agents"] });
|
|
136
387
|
else if (component.name === "delivery")
|
|
137
|
-
await stopDelivery(context.space, { preserveCredentials:
|
|
388
|
+
await stopDelivery(context.space, { preserveCredentials: true });
|
|
138
389
|
else
|
|
139
390
|
await stopLocalProcess(component, context);
|
|
140
391
|
}
|
|
@@ -148,11 +399,11 @@ export async function down(args) {
|
|
|
148
399
|
process.exitCode = 1;
|
|
149
400
|
return;
|
|
150
401
|
}
|
|
151
|
-
if (
|
|
402
|
+
if (selected.some((component) => component.name === "delivery"))
|
|
152
403
|
await removeDeliveryCredentials(folderCtx().space);
|
|
153
404
|
for (const component of selected) {
|
|
154
405
|
for (const artifact of component.artifacts ?? [])
|
|
155
|
-
rmSync(localProcessPath(artifact,
|
|
406
|
+
rmSync(localProcessPath(artifact, folderCtx()), { force: true });
|
|
156
407
|
}
|
|
157
408
|
// Pidfiles are the only thing this stack owns. A registered broker that answers with no pidfile
|
|
158
409
|
// is a different situation: something is running that `down` did not start and must not stop.
|
|
@@ -161,27 +412,24 @@ export async function down(args) {
|
|
|
161
412
|
// Owned components (a detached web, a manager) do not change the question: stopping them is not
|
|
162
413
|
// the same as this stack owning the broker. The probe runs on every bare down that holds no
|
|
163
414
|
// nats pidfile, AFTER their owned artifacts cleared, so those components stop exactly as they
|
|
164
|
-
// do with no broker present.
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
for
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
`Stop that broker with the supervisor that started it, or remove the registration with \`cotal meshes rm ${broker.space}\`.`));
|
|
172
|
-
}
|
|
173
|
-
process.exit(1);
|
|
415
|
+
// do with no broker present.
|
|
416
|
+
const unowned = await liveUnownedBrokers(folderCtx());
|
|
417
|
+
if (unowned.length) {
|
|
418
|
+
for (const broker of unowned) {
|
|
419
|
+
console.error(c.red(`Broker for "${broker.space}" is running at ${broker.server}, but no pidfile records it. ` +
|
|
420
|
+
`cotal down will not stop a process it did not start. ` +
|
|
421
|
+
`Stop that broker with the supervisor that started it, or remove the registration with \`cotal meshes rm ${broker.space}\`.`));
|
|
174
422
|
}
|
|
423
|
+
process.exit(1);
|
|
175
424
|
}
|
|
176
|
-
// The broker owns the mesh registry entry and transient whole-mesh launch material
|
|
177
|
-
//
|
|
425
|
+
// The broker owns the mesh registry entry and transient whole-mesh launch material, so they go
|
|
426
|
+
// with it.
|
|
178
427
|
if (selected.some((component) => component.clearsMesh)) {
|
|
179
428
|
rmSync(join(folderCtx().root, ".cotal", "run"), { recursive: true, force: true });
|
|
180
429
|
removeMeshesByRoot(folderCtx().root);
|
|
181
430
|
}
|
|
182
431
|
if (!any) {
|
|
183
|
-
|
|
184
|
-
console.error(c.red(`Nothing running for ${target} (no recorded pidfiles).`));
|
|
432
|
+
console.error(c.red("Nothing running for the local stack (no recorded pidfiles)."));
|
|
185
433
|
process.exit(1);
|
|
186
434
|
}
|
|
187
435
|
}
|
|
@@ -212,14 +460,14 @@ export function processAlive(component, context) {
|
|
|
212
460
|
const pid = parsePid(raw);
|
|
213
461
|
return pid !== undefined && isAlive(pid);
|
|
214
462
|
}
|
|
215
|
-
/** Whether a component MIGHT still be running
|
|
216
|
-
*
|
|
217
|
-
*
|
|
218
|
-
*
|
|
219
|
-
*
|
|
220
|
-
* "not alive", which is fine for "is it worth
|
|
221
|
-
*
|
|
222
|
-
*
|
|
463
|
+
/** Whether a component MIGHT still be running. It fails CLOSED on uncertainty. A component with NO
|
|
464
|
+
* pidfile, an EMPTY husk, or a valid pid PROVEN dead (ESRCH) is not running. ANY other state - an
|
|
465
|
+
* unparsable/unattributable record, or a valid pid that is alive or whose liveness cannot be
|
|
466
|
+
* confirmed (`unknown`) - MIGHT be running. `down --preserve-state` asks it to fence an uncertain
|
|
467
|
+
* delivery daemon, to treat an uncertain manager as alive, and to refuse to call a cut complete.
|
|
468
|
+
* `processAlive` collapses unparsable and `unknown` to "not alive", which is fine for "is it worth
|
|
469
|
+
* stopping" but WRONG for those questions: it would count a live auth signer behind a torn pidfile
|
|
470
|
+
* as stopped. Only an ESRCH-confirmed death (or no record) clears a component. */
|
|
223
471
|
export function mayBeRunning(component, context) {
|
|
224
472
|
const raw = readPidfile(localProcessPath(component.pidFile, context));
|
|
225
473
|
if (!raw)
|
|
@@ -231,7 +479,7 @@ export function mayBeRunning(component, context) {
|
|
|
231
479
|
}
|
|
232
480
|
/** The principal keys of every retained agent in a preservation inventory — the dot-form ids that
|
|
233
481
|
* appear in the presence roster, so a caller can tell which retained agents are still live. */
|
|
234
|
-
function retainedPrincipalKeys(inventory) {
|
|
482
|
+
export function retainedPrincipalKeys(inventory) {
|
|
235
483
|
const agents = (inventory.agents ?? []);
|
|
236
484
|
return new Set(agents.map((agent) => {
|
|
237
485
|
if (agent.identity?.mode === "user" && agent.identity.owner && agent.identity.actor)
|
|
@@ -258,10 +506,10 @@ function assertSessionStores(paths) {
|
|
|
258
506
|
stat = statSync(resolved);
|
|
259
507
|
}
|
|
260
508
|
catch (error) {
|
|
261
|
-
throw new
|
|
509
|
+
throw new CommandFailure("refused", "USAGE_INVALID", `--session-store ${resolved} cannot be read (${error.code ?? error.message}); name the harness transcript store directory for this host`);
|
|
262
510
|
}
|
|
263
511
|
if (!stat.isDirectory())
|
|
264
|
-
throw new
|
|
512
|
+
throw new CommandFailure("refused", "USAGE_INVALID", `--session-store ${resolved} is not a directory; name the harness transcript store directory for this host`);
|
|
265
513
|
return resolved;
|
|
266
514
|
});
|
|
267
515
|
}
|
|
@@ -269,13 +517,16 @@ async function preserveStateDown(storeOverride, sessionStores = []) {
|
|
|
269
517
|
const root = cotalRoot();
|
|
270
518
|
const matching = loadMeshes().filter((mesh) => mesh.root === root);
|
|
271
519
|
if (matching.length !== 1)
|
|
272
|
-
throw new
|
|
520
|
+
throw new CommandFailure("refused", matching.length ? "TARGET_AMBIGUOUS" : "TARGET_NOT_FOUND", `down --preserve-state requires exactly one recorded mesh for this root; found ${matching.length}, and nothing was stopped`, { target: { root, spaces: matching.map((mesh) => mesh.space) } });
|
|
273
521
|
const mesh = matching[0];
|
|
274
522
|
const storeDir = storeOverride ? resolveStore(storeOverride) : join(root, ".cotal", "nats");
|
|
275
523
|
// The store cap the broker was started with travels with the store, so the resume re-renders it.
|
|
276
524
|
const cap = mesh.maxFileStore !== undefined ? { maxFileStore: mesh.maxFileStore } : {};
|
|
277
525
|
const lock = acquireMaintenanceLock(root);
|
|
278
526
|
try {
|
|
527
|
+
const additiveAttempts = listAdditiveTeamAttempts(root);
|
|
528
|
+
if (retainedAdditiveTeamAttempts(additiveAttempts).length || additiveAttempts.refused.length)
|
|
529
|
+
throw new CommandFailure("refused", "LIFECYCLE_BLOCKED", "an additive attempt or returned additive deployment remains; preserve-state down did not fold its resources into the retained stack", { target: { root, space: mesh.space, deploymentIds: retainedAdditiveTeamAttempts(additiveAttempts).map((attempt) => attempt.deploymentId), unreadable: additiveAttempts.refused.map(({ path }) => path) } });
|
|
279
530
|
const all = localProcessSurface();
|
|
280
531
|
const context = { root, space: mesh.space };
|
|
281
532
|
const existing = readMaintenanceJournal(root);
|
|
@@ -364,6 +615,14 @@ async function preserveStateDown(storeOverride, sessionStores = []) {
|
|
|
364
615
|
}
|
|
365
616
|
}
|
|
366
617
|
else {
|
|
618
|
+
// The cut takes its agent inventory from the manager that serves the space. A stack with no
|
|
619
|
+
// manager, such as one started with --no-manager, refuses here, before the prepare intent, the
|
|
620
|
+
// delivery stop or any other effect.
|
|
621
|
+
if ((await readPresenceAndLease(mesh.space, mesh.server)).managerId === undefined)
|
|
622
|
+
throw new CommandFailure("refused", "TARGET_UNAVAILABLE", "no manager serves this space, so --preserve-state cannot take the agent inventory it preserves; nothing was stopped", {
|
|
623
|
+
target: { root, space: mesh.space, server: mesh.server },
|
|
624
|
+
remedy: "start this stack's manager with `cotal up`, then run `cotal down --preserve-state` again",
|
|
625
|
+
});
|
|
367
626
|
// The attempt binding is durable BEFORE the manager is fenced: a crash between manager
|
|
368
627
|
// preparation and the cut-intent journal retries with the exact attempt the manager holds.
|
|
369
628
|
const intent = readPreservationPrepareIntent(root);
|
|
@@ -550,7 +809,7 @@ async function preserveStateDown(storeOverride, sessionStores = []) {
|
|
|
550
809
|
* source`, and a checkpoint inherits that refusal rather than writing something that will not
|
|
551
810
|
* reproduce the seat.
|
|
552
811
|
*/
|
|
553
|
-
function assertSeatsCheckpointable(inventory) {
|
|
812
|
+
export function assertSeatsCheckpointable(inventory) {
|
|
554
813
|
for (const entry of (inventory.agents ?? [])) {
|
|
555
814
|
const keys = entry.launch?.unresolvedLaunchOptionKeys ?? [];
|
|
556
815
|
if (keys.length)
|
|
@@ -560,7 +819,7 @@ function assertSeatsCheckpointable(inventory) {
|
|
|
560
819
|
}
|
|
561
820
|
}
|
|
562
821
|
/** Capture one checkpoint per retained seat, after the cut has proven the whole stack down. */
|
|
563
|
-
async function captureSeatCheckpoints(root, space, resume, destination, sessionStores) {
|
|
822
|
+
export async function captureSeatCheckpoints(root, space, resume, destination, sessionStores) {
|
|
564
823
|
const document = readMaintenanceResumeDocument(root, resume);
|
|
565
824
|
const inventory = document.inventory;
|
|
566
825
|
const agents = inventory?.agents ?? [];
|
|
@@ -631,7 +890,7 @@ async function directKvValue(nc, stream, subject, allowEmpty = false) {
|
|
|
631
890
|
* continuously, so the cut publishes `ready` only once BOTH lease buckets hold no live value —
|
|
632
891
|
* a dead daemon's lease expires by TTL, a pidless live one keeps renewing and is refused here.
|
|
633
892
|
* Pidfiles are hints; leases are proof. */
|
|
634
|
-
async function assertControlPlaneQuiesced(space, server) {
|
|
893
|
+
export async function assertControlPlaneQuiesced(space, server) {
|
|
635
894
|
const resolved = await connectOrExit({ space, server }, "deployer");
|
|
636
895
|
const user = resolved.bearer ? await userViewAuthOrExit(resolved, "deployer") : undefined;
|
|
637
896
|
const nc = await dialerFor(server)({
|
|
@@ -680,6 +939,14 @@ async function assertControlPlaneQuiesced(space, server) {
|
|
|
680
939
|
* THIS function, not a transcription of it: a copy carries its own `allowEmpty` parameter, so it
|
|
681
940
|
* stays green when the argument at the real call site is removed and proves nothing about the fix. */
|
|
682
941
|
export async function readPresenceWithoutConsumer(space, server) {
|
|
942
|
+
const { roster, managerId } = await readPresenceAndLease(space, server);
|
|
943
|
+
if (managerId === undefined)
|
|
944
|
+
throw new Error("manager lease has no authoritative holder principal");
|
|
945
|
+
return { roster, managerId };
|
|
946
|
+
}
|
|
947
|
+
/** The roster and the principal holding the space's manager lease, or no holder when no manager
|
|
948
|
+
* serves the space. */
|
|
949
|
+
async function readPresenceAndLease(space, server) {
|
|
683
950
|
const resolved = await connectOrExit({ space, server }, "deployer");
|
|
684
951
|
const user = resolved.bearer ? await userViewAuthOrExit(resolved, "deployer") : undefined;
|
|
685
952
|
const nc = await dialerFor(server)({
|
|
@@ -730,7 +997,7 @@ export async function readPresenceWithoutConsumer(space, server) {
|
|
|
730
997
|
}
|
|
731
998
|
}
|
|
732
999
|
if (!lease?.holder)
|
|
733
|
-
|
|
1000
|
+
return { roster };
|
|
734
1001
|
return { roster, managerId: parsePrincipalKey(lease.holder) ? lease.holder : principalKey(DEV_OWNER, lease.holder).key };
|
|
735
1002
|
}
|
|
736
1003
|
finally {
|