@cotal-ai/cli 0.90.0 → 0.91.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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 +19 -0
- package/dist/chat/controller.d.ts.map +1 -0
- package/dist/chat/controller.js +116 -0
- package/dist/chat/controller.js.map +1 -0
- package/dist/chat/engine.d.ts +108 -0
- package/dist/chat/engine.d.ts.map +1 -0
- package/dist/chat/engine.js +226 -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 +151 -0
- package/dist/chat/frontend.js.map +1 -0
- package/dist/chat/native-session.d.ts +71 -0
- package/dist/chat/native-session.d.ts.map +1 -0
- package/dist/chat/native-session.js +348 -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 +34 -0
- package/dist/chat/picker.d.ts.map +1 -0
- package/dist/chat/picker.js +97 -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 +242 -0
- package/dist/chat/plain.js.map +1 -0
- package/dist/chat/session.d.ts +217 -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 +34 -0
- package/dist/chat/stdio-io.d.ts.map +1 -0
- package/dist/chat/stdio-io.js +175 -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 +400 -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 +186 -0
- package/dist/chat/view.d.ts.map +1 -0
- package/dist/chat/view.js +386 -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 +392 -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 +501 -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 +92 -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 +27 -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 +81 -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 +102 -24
- 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 +264 -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 +276 -115
- package/dist/commands/down.js.map +1 -1
- package/dist/commands/endpoint-authoring.d.ts +4 -0
- package/dist/commands/endpoint-authoring.d.ts.map +1 -0
- package/dist/commands/endpoint-authoring.js +125 -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 +73 -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 +443 -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 +140 -0
- package/dist/commands/reset-space-apply.js.map +1 -0
- package/dist/commands/reset-store-apply.d.ts +11 -0
- package/dist/commands/reset-store-apply.d.ts.map +1 -0
- package/dist/commands/reset-store-apply.js +154 -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 +143 -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 +405 -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 +106 -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 +161 -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 +341 -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 +388 -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 +78 -18
- package/dist/commands/spawn.d.ts.map +1 -1
- package/dist/commands/spawn.js +236 -96
- package/dist/commands/spawn.js.map +1 -1
- package/dist/commands/stack-down.d.ts +6 -0
- package/dist/commands/stack-down.d.ts.map +1 -0
- package/dist/commands/stack-down.js +206 -0
- package/dist/commands/stack-down.js.map +1 -0
- package/dist/commands/stack-up.d.ts +149 -0
- package/dist/commands/stack-up.d.ts.map +1 -0
- package/dist/commands/stack-up.js +459 -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 +232 -5
- package/dist/commands/status.d.ts.map +1 -1
- package/dist/commands/status.js +989 -406
- 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 +727 -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 +144 -5
- package/dist/commands/up.d.ts.map +1 -1
- package/dist/commands/up.js +1015 -124
- package/dist/commands/up.js.map +1 -1
- package/dist/commands/update.d.ts +11 -0
- package/dist/commands/update.d.ts.map +1 -1
- package/dist/commands/update.js +72 -15
- 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 +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +444 -118
- 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 +34 -1
- package/dist/lib/backup-artifact.d.ts.map +1 -1
- package/dist/lib/backup-artifact.js +67 -17
- package/dist/lib/backup-artifact.js.map +1 -1
- package/dist/lib/broker-service.d.ts +10 -0
- package/dist/lib/broker-service.d.ts.map +1 -0
- package/dist/lib/broker-service.js +329 -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/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 +28 -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 +9 -19
- 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 +20 -0
- package/dist/lib/endpoint-client.d.ts.map +1 -0
- package/dist/lib/endpoint-client.js +42 -0
- package/dist/lib/endpoint-client.js.map +1 -0
- package/dist/lib/endpoint-errors.d.ts +11 -0
- package/dist/lib/endpoint-errors.d.ts.map +1 -0
- package/dist/lib/endpoint-errors.js +30 -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 +181 -0
- package/dist/lib/reset-space-plan.js.map +1 -0
- package/dist/lib/restore.d.ts +3 -1
- package/dist/lib/restore.d.ts.map +1 -1
- package/dist/lib/restore.js +38 -10
- 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 +138 -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 +121 -0
- package/dist/lib/service-process.d.ts.map +1 -0
- package/dist/lib/service-process.js +742 -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/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 +92 -0
- package/dist/lib/stack-journal.d.ts.map +1 -0
- package/dist/lib/stack-journal.js +199 -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/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 +1 -0
- package/dist/lib/up-report.d.ts.map +1 -1
- package/dist/lib/up-report.js +2 -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/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 +6 -0
- package/dist/ui.d.ts.map +1 -1
- package/dist/ui.js +12 -1
- 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 +131 -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
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { type BrokerTransport, type ParsedArgs } from "@cotal-ai/core";
|
|
2
|
+
import { presentationOf, type Report, type UserAuthInfo } from "@cotal-ai/workspace";
|
|
3
|
+
import { type StackJournal, type StackMode } from "../lib/stack-journal.js";
|
|
4
|
+
import { type StackUserPrepared } from "./stack-user-auth.js";
|
|
5
|
+
/** Callbacks into the native broker preparation that `up.ts` owns. They hold private authority
|
|
6
|
+
* material and are passed in, so this module never re-derives trust or a transport decision. */
|
|
7
|
+
export interface StackUpNative {
|
|
8
|
+
/** `userAuth` asks the native `authSetup` user arm (`prepareServer`) and must return its private
|
|
9
|
+
* `user` material; any other mode must return none. */
|
|
10
|
+
prepareBroker(opts: {
|
|
11
|
+
transport: BrokerTransport;
|
|
12
|
+
server: string;
|
|
13
|
+
space: string;
|
|
14
|
+
open: boolean;
|
|
15
|
+
userAuth?: {
|
|
16
|
+
idpUrl?: string;
|
|
17
|
+
};
|
|
18
|
+
host?: string;
|
|
19
|
+
storeDir?: string;
|
|
20
|
+
existingStore?: ExistingStorePin;
|
|
21
|
+
maxFileStore?: number;
|
|
22
|
+
channels?: string;
|
|
23
|
+
seed?: unknown;
|
|
24
|
+
}): Promise<{
|
|
25
|
+
root: string;
|
|
26
|
+
server: string;
|
|
27
|
+
space: string;
|
|
28
|
+
storeDir: string;
|
|
29
|
+
transport: BrokerTransport;
|
|
30
|
+
setup?: {
|
|
31
|
+
creds: string;
|
|
32
|
+
wsPort: number;
|
|
33
|
+
};
|
|
34
|
+
user?: StackUserPrepared;
|
|
35
|
+
confPath: string;
|
|
36
|
+
bin: string;
|
|
37
|
+
seedFile?: unknown;
|
|
38
|
+
}>;
|
|
39
|
+
initializeStreams(server: string, space: string, setup: {
|
|
40
|
+
creds: string;
|
|
41
|
+
} | undefined, seedFile: unknown): Promise<void>;
|
|
42
|
+
recordMesh(entry: {
|
|
43
|
+
space: string;
|
|
44
|
+
server: string;
|
|
45
|
+
root: string;
|
|
46
|
+
mode: StackMode;
|
|
47
|
+
tlsRequired: boolean;
|
|
48
|
+
storeDir: string;
|
|
49
|
+
userAuth?: UserAuthInfo;
|
|
50
|
+
maxSessions?: number;
|
|
51
|
+
attachHost?: string;
|
|
52
|
+
maxFileStore?: number;
|
|
53
|
+
}): void;
|
|
54
|
+
commitTransport(root: string, transport: BrokerTransport): void;
|
|
55
|
+
}
|
|
56
|
+
/** The identity of an existing broker store that a start must reuse and never create. */
|
|
57
|
+
export interface ExistingStorePin {
|
|
58
|
+
named: string;
|
|
59
|
+
path: string;
|
|
60
|
+
dev: string;
|
|
61
|
+
ino: string;
|
|
62
|
+
birthtimeNs: string;
|
|
63
|
+
}
|
|
64
|
+
/** Pin a named store that must already exist as a real directory, refusing a missing path, a
|
|
65
|
+
* non-directory and a symlink. The pin and its rechecks narrow the window in which another local
|
|
66
|
+
* process can replace the path. They cannot close it: neither Node nor nats-server opens a
|
|
67
|
+
* directory by identity, and the last recheck still precedes the broker's own open. */
|
|
68
|
+
export declare function pinExistingStore(named: string, target: Record<string, unknown>): ExistingStorePin;
|
|
69
|
+
/** Check a pinned store again: the named path must still resolve to the pinned directory. A missing,
|
|
70
|
+
* replaced or relinked store refuses. */
|
|
71
|
+
export declare function recheckExistingStore(pin: ExistingStorePin, target: Record<string, unknown>): void;
|
|
72
|
+
export interface StackUpRequest {
|
|
73
|
+
root: string;
|
|
74
|
+
space: string;
|
|
75
|
+
server: string;
|
|
76
|
+
transport: BrokerTransport;
|
|
77
|
+
runtime: string;
|
|
78
|
+
noManager: boolean;
|
|
79
|
+
/** An explicitly requested mode. Omitted keeps the journal's pinned mode, or static auth. */
|
|
80
|
+
mode?: StackMode;
|
|
81
|
+
/** The IdP a first user-auth enable pins (`--idp`); refused outside user mode. */
|
|
82
|
+
idp?: string;
|
|
83
|
+
host?: string;
|
|
84
|
+
storeDir?: string;
|
|
85
|
+
maxFileStore?: number;
|
|
86
|
+
maxSessions?: number;
|
|
87
|
+
channels?: string;
|
|
88
|
+
foreground: boolean;
|
|
89
|
+
presentation: ReturnType<typeof presentationOf>;
|
|
90
|
+
/** A fresh team boot's frozen manifest inputs. `seed` replaces `channels` for the broker's native
|
|
91
|
+
* channel registry seed. `launchSpec` runs once, after broker (and user auth-service)
|
|
92
|
+
* preparation and immediately before the manager member is defined, and returns the private
|
|
93
|
+
* native launch spec the manager service pins by digest. It is never called for a reused manager. */
|
|
94
|
+
manifest?: {
|
|
95
|
+
/** The boot's own retained fresh intent, which is unsettled by design until its summary. Only
|
|
96
|
+
* this exact ID is exempt from the unsettled-attempt refusal; every other one still refuses. */
|
|
97
|
+
deploymentId: string;
|
|
98
|
+
seed: unknown;
|
|
99
|
+
launchSpec(context: {
|
|
100
|
+
root: string;
|
|
101
|
+
space: string;
|
|
102
|
+
server: string;
|
|
103
|
+
mode: StackMode;
|
|
104
|
+
user?: StackUserPrepared;
|
|
105
|
+
}): Promise<{
|
|
106
|
+
path: string;
|
|
107
|
+
sha256: string;
|
|
108
|
+
}>;
|
|
109
|
+
};
|
|
110
|
+
/** Compare-and-swap binding for a team boot that resumes an exact stopped stack: the journal bytes
|
|
111
|
+
* read by its eligibility gate under the same maintenance lock. Any change before this call's
|
|
112
|
+
* own read refuses; nothing is re-planned from different records. */
|
|
113
|
+
expectPriorDown?: {
|
|
114
|
+
journalSha256: string;
|
|
115
|
+
operationId: string;
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
/** The domain outcome of a successful whole-stack start, for a caller that renders its own receipt.
|
|
119
|
+
* Every refusal, partial or unknown outcome is still thrown as a classified failure. */
|
|
120
|
+
export interface StackUpResult {
|
|
121
|
+
journal: StackJournal;
|
|
122
|
+
changed: unknown[];
|
|
123
|
+
allReused: boolean;
|
|
124
|
+
/** The manager's pinned launch spec, when this call defined one. */
|
|
125
|
+
launch?: {
|
|
126
|
+
path: string;
|
|
127
|
+
sha256: string;
|
|
128
|
+
};
|
|
129
|
+
/** A settled active restore of this stack that its retained journal did not fence. */
|
|
130
|
+
admittedRestore?: string;
|
|
131
|
+
}
|
|
132
|
+
/** The mode an invocation explicitly asks for, or none for a bare `up`. */
|
|
133
|
+
export declare function requestedStackMode(values: ParsedArgs["values"]): StackMode | undefined;
|
|
134
|
+
/** A root takes the controller route when it already has a stack journal, or when it is a fresh,
|
|
135
|
+
* prepared root with nothing legacy, maintenance or team-owned retained under it and the
|
|
136
|
+
* invocation names only controller-supported inputs. A static-auth request needs an `up`
|
|
137
|
+
* registration in auth mode or none. An `--open` request needs an open registration or none, and
|
|
138
|
+
* a root that holds no broker account. A prepared user-auth root uses the same controller with
|
|
139
|
+
* its native auth service. Anything else keeps the retained path. */
|
|
140
|
+
export declare function controllerStackApplies(root: string, space: string, values: ParsedArgs["values"]): boolean;
|
|
141
|
+
/** `cotal up`'s controller route: start, seed the default persona into the root, then write its
|
|
142
|
+
* own receipt. The stack is up by then, so a persona that cannot be written is a warning. */
|
|
143
|
+
export declare function stackUp(request: StackUpRequest, native: StackUpNative): Promise<void>;
|
|
144
|
+
/** Start the recorded stack and return its domain result without writing any receipt. */
|
|
145
|
+
export declare function startControllerStack(request: StackUpRequest, native: StackUpNative): Promise<StackUpResult>;
|
|
146
|
+
/** The member table and evidence text a caller embeds in its own receipt. */
|
|
147
|
+
export declare function stackMembersView(journal: StackJournal, title: string): Report;
|
|
148
|
+
export declare function stackUpForegroundNotice(presentation: ReturnType<typeof presentationOf>, space: string): void;
|
|
149
|
+
//# sourceMappingURL=stack-up.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stack-up.d.ts","sourceRoot":"","sources":["../../src/commands/stack-up.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,459 @@
|
|
|
1
|
+
/** Controller-owned whole-stack startup: broker first, then native stream setup, the auth service
|
|
2
|
+
* for a user stack, the delivery credential and delivery, then the manager. An open stack has no
|
|
3
|
+
* delivery member and mints no credential: its broker serves the prepared open configuration and
|
|
4
|
+
* its manager reports through the child's own local receipt. A user stack's manager needs the
|
|
5
|
+
* invoking user's existing login and grant; without it the manager is not attempted and the result
|
|
6
|
+
* is a known `AUTH_REQUIRED` partial. Every member is a saved root-bound definition and an
|
|
7
|
+
* exact service-controller instance. Trust and the broker configuration are prepared explicitly
|
|
8
|
+
* here, outside any adapter plan. A failure after the first effect is reported as partial or
|
|
9
|
+
* unknown with the members it changed; nothing already started is rolled back. */
|
|
10
|
+
import { existsSync, lstatSync, realpathSync } from "node:fs";
|
|
11
|
+
import { homedir } from "node:os";
|
|
12
|
+
import { join, resolve } from "node:path";
|
|
13
|
+
import { JetStreamApiError } from "@nats-io/jetstream";
|
|
14
|
+
import { isReachable, mintCreds, newIdentity } from "@cotal-ai/core";
|
|
15
|
+
import { CommandFailure, accountInventory, authDir, canonicalRoot, deliveryCredsKey, findMesh, findPreparedSpace, getSpaceAuth, hasUserAuthState, isCommandFailure, localMeshesForRoot, presentationOf, readMaintenanceJournal, renderReport, resolveOnPath, terminalWidth, workspaceSecretStore, writeResult, } from "@cotal-ai/workspace";
|
|
16
|
+
import { liveMeshProcesses } from "./clean.js";
|
|
17
|
+
import { seedDefaultPersona } from "../lib/default-persona.js";
|
|
18
|
+
import { serviceDefinitionStore, validateServiceDefinition } from "../lib/service-definitions.js";
|
|
19
|
+
import { instanceProjection, observeServiceProcess, serviceInstances } from "../lib/service-instances.js";
|
|
20
|
+
import { prepareProcessService, removeStoppedInstanceRecords, startProcessService } from "../lib/service-process.js";
|
|
21
|
+
import { listLedgerFiles } from "../lib/manifest/ledger.js";
|
|
22
|
+
import { listAdditiveTeamAttempts, retainedAdditiveTeamAttempts } from "../lib/team-additive-attempt.js";
|
|
23
|
+
import { freshTeamAttemptSettled, listFreshTeamAttempts, listFreshTeamSummaries } from "../lib/team-fresh.js";
|
|
24
|
+
import { foreignLocalProcesses, newStackOperation, readStackJournal, stackMaintenanceFence, STACK_ADAPTER, STACK_DEFINITION, STACK_ROLES, stackRoleApplies, writeStackJournal } from "../lib/stack-journal.js";
|
|
25
|
+
import { assertUserStackTransport, confirmUserAuthEndpoints, preflightUserStack, provisionalUserAuth, userLoginRequired, userLoginState, userRegistrationIncomplete } from "./stack-user-auth.js";
|
|
26
|
+
/** Pin a named store that must already exist as a real directory, refusing a missing path, a
|
|
27
|
+
* non-directory and a symlink. The pin and its rechecks narrow the window in which another local
|
|
28
|
+
* process can replace the path. They cannot close it: neither Node nor nats-server opens a
|
|
29
|
+
* directory by identity, and the last recheck still precedes the broker's own open. */
|
|
30
|
+
export function pinExistingStore(named, target) {
|
|
31
|
+
let pin;
|
|
32
|
+
try {
|
|
33
|
+
const link = lstatSync(named, { bigint: true });
|
|
34
|
+
if (link.isDirectory() && !link.isSymbolicLink()) {
|
|
35
|
+
const path = realpathSync.native(named), stat = lstatSync(path, { bigint: true });
|
|
36
|
+
if (stat.isDirectory() && !stat.isSymbolicLink() && stat.dev === link.dev && stat.ino === link.ino)
|
|
37
|
+
pin = { named, path, dev: stat.dev.toString(), ino: stat.ino.toString(), birthtimeNs: stat.birthtimeNs.toString() };
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
catch {
|
|
41
|
+
pin = undefined;
|
|
42
|
+
}
|
|
43
|
+
if (!pin)
|
|
44
|
+
throw new CommandFailure("refused", "TARGET_UNAVAILABLE", "the named broker store is not an existing real directory; no store was created and nothing was prepared", { target: { ...target, storeDir: named } });
|
|
45
|
+
return pin;
|
|
46
|
+
}
|
|
47
|
+
/** Check a pinned store again: the named path must still resolve to the pinned directory. A missing,
|
|
48
|
+
* replaced or relinked store refuses. */
|
|
49
|
+
export function recheckExistingStore(pin, target) {
|
|
50
|
+
let stat;
|
|
51
|
+
try {
|
|
52
|
+
const link = lstatSync(pin.named, { bigint: true });
|
|
53
|
+
stat = link.isDirectory() && !link.isSymbolicLink() && realpathSync.native(pin.named) === pin.path ? lstatSync(pin.path, { bigint: true }) : undefined;
|
|
54
|
+
}
|
|
55
|
+
catch {
|
|
56
|
+
stat = undefined;
|
|
57
|
+
}
|
|
58
|
+
if (!stat || !stat.isDirectory() || stat.isSymbolicLink() || stat.dev.toString() !== pin.dev || stat.ino.toString() !== pin.ino || stat.birthtimeNs.toString() !== pin.birthtimeNs)
|
|
59
|
+
throw new CommandFailure("refused", "TARGET_UNAVAILABLE", "the named broker store disappeared, was replaced or became a link after it was checked; no store was created and the broker was not started", { target: { ...target, storeDir: pin.named } });
|
|
60
|
+
}
|
|
61
|
+
/** Inputs that name a legacy-only startup refuse on the controller route. They are not dropped. */
|
|
62
|
+
const CONTROLLER_UNSUPPORTED = ["file", "dry-run", "restore", "restore-only", "accept-missing-source", "accept-stale-checkpoint", "rotate-sys", "exchange-public-port", "exchange-public-url", "exchange-trusted-proxy", "advertised-server", "agent-provisioning-url", "tls-cert", "tls-key"];
|
|
63
|
+
/** Any account record, readable or not, means the root carries static trust an open stack would bypass. */
|
|
64
|
+
function holdsBrokerAccount(root) {
|
|
65
|
+
const inventory = accountInventory(authDir(root));
|
|
66
|
+
return inventory.spaces.length > 0 || inventory.corrupt.length > 0;
|
|
67
|
+
}
|
|
68
|
+
/** The mode an invocation explicitly asks for, or none for a bare `up`. */
|
|
69
|
+
export function requestedStackMode(values) {
|
|
70
|
+
return values["user-auth"] === true ? "user" : values.open === true ? "open" : undefined;
|
|
71
|
+
}
|
|
72
|
+
/** A root takes the controller route when it already has a stack journal, or when it is a fresh,
|
|
73
|
+
* prepared root with nothing legacy, maintenance or team-owned retained under it and the
|
|
74
|
+
* invocation names only controller-supported inputs. A static-auth request needs an `up`
|
|
75
|
+
* registration in auth mode or none. An `--open` request needs an open registration or none, and
|
|
76
|
+
* a root that holds no broker account. A prepared user-auth root uses the same controller with
|
|
77
|
+
* its native auth service. Anything else keeps the retained path. */
|
|
78
|
+
export function controllerStackApplies(root, space, values) {
|
|
79
|
+
const canonical = canonicalRoot(root);
|
|
80
|
+
const recorded = readStackJournal(canonical);
|
|
81
|
+
const requested = requestedStackMode(values);
|
|
82
|
+
const unsupportedNow = (name) => values[name] !== undefined && values[name] !== false && CONTROLLER_UNSUPPORTED.includes(name);
|
|
83
|
+
if (recorded) {
|
|
84
|
+
const unsupported = CONTROLLER_UNSUPPORTED.filter(unsupportedNow);
|
|
85
|
+
if (unsupported.length)
|
|
86
|
+
throw new CommandFailure("refused", "UNSUPPORTED", "this root's stack is owned by the service controller; the requested startup option has no controller-owned route and was not applied through the legacy launcher", { target: { root: canonical, options: unsupported } });
|
|
87
|
+
if (requested !== undefined && requested !== recorded.journal.mode)
|
|
88
|
+
throw new CommandFailure("refused", "CONFLICT", `this root's controller stack is pinned to ${recorded.journal.mode === "open" ? "open" : recorded.journal.mode === "user" ? "user auth" : "static auth"}; the requested mode does not convert it`, { target: { root: canonical, recorded: recorded.journal.mode, requested }, remedy: "run bare cotal up to keep the recorded mode" });
|
|
89
|
+
if (values.idp !== undefined && recorded.journal.mode !== "user")
|
|
90
|
+
throw new CommandFailure("refused", "USAGE_INVALID", "--idp belongs to a user-auth stack", { target: { root: canonical } });
|
|
91
|
+
return true;
|
|
92
|
+
}
|
|
93
|
+
if (CONTROLLER_UNSUPPORTED.some(unsupportedNow))
|
|
94
|
+
return false;
|
|
95
|
+
const wanted = requested ?? "auth";
|
|
96
|
+
if (canonical === canonicalRoot(homedir()) || wanted !== "user" && hasUserAuthState(canonical, space, { readOnly: true }))
|
|
97
|
+
return false;
|
|
98
|
+
if (wanted === "open" && holdsBrokerAccount(canonical))
|
|
99
|
+
return false;
|
|
100
|
+
const registered = findMesh(space);
|
|
101
|
+
if (registered && (registered.origin !== "up" || canonicalRoot(registered.root) !== canonical || registered.mode !== wanted))
|
|
102
|
+
return false;
|
|
103
|
+
// Only a space prepared at this very root qualifies. An absent prepared record is not a root: an
|
|
104
|
+
// empty path would canonicalize to the working directory and admit an unprepared legacy folder.
|
|
105
|
+
const prepared = findPreparedSpace(space);
|
|
106
|
+
if (!registered && (!prepared || canonicalRoot(prepared.root) !== canonical))
|
|
107
|
+
return false;
|
|
108
|
+
if (readMaintenanceJournal(canonical))
|
|
109
|
+
return false;
|
|
110
|
+
if (existsSync(join(canonical, ".cotal", "nats.pid")) || liveMeshProcesses(canonical, space).length)
|
|
111
|
+
return false;
|
|
112
|
+
return true;
|
|
113
|
+
}
|
|
114
|
+
/** Returns a settled active restore of the recorded stack that was admitted, for the result to name. */
|
|
115
|
+
function stackPreflight(root, space, recorded, ownAttempt) {
|
|
116
|
+
const maintenance = recorded ? stackMaintenanceFence(root, recorded) : { fenced: readMaintenanceJournal(root) !== undefined };
|
|
117
|
+
if (maintenance.fenced)
|
|
118
|
+
throw new CommandFailure("refused", "LIFECYCLE_BLOCKED", "this root retains a maintenance or recovery attempt; the controller stack did not substitute an ordinary startup", { target: { root, space } });
|
|
119
|
+
const legacy = foreignLocalProcesses(root, space);
|
|
120
|
+
if (legacy.length || existsSync(join(root, ".cotal", "nats.pid")))
|
|
121
|
+
throw new CommandFailure("refused", "LIFECYCLE_BLOCKED", "legacy pidfile-owned processes or records remain under this root; the controller stack neither adopts nor replaces them", { target: { root, space, processes: legacy } });
|
|
122
|
+
if (localMeshesForRoot(root).some((mesh) => mesh.space !== space))
|
|
123
|
+
throw new CommandFailure("refused", "CONFLICT", "another locally started space uses this root; a single-space controller stack cannot share its broker", { target: { root, space } });
|
|
124
|
+
let ledgers, additive, boots, summaries;
|
|
125
|
+
try {
|
|
126
|
+
ledgers = listLedgerFiles(root, { requireReadable: true });
|
|
127
|
+
additive = listAdditiveTeamAttempts(root);
|
|
128
|
+
boots = listFreshTeamAttempts(root);
|
|
129
|
+
summaries = listFreshTeamSummaries(root);
|
|
130
|
+
}
|
|
131
|
+
catch {
|
|
132
|
+
throw new CommandFailure("refused", "TARGET_UNAVAILABLE", "team records under this root could not be read; no empty team state was inferred", { target: { root, space } });
|
|
133
|
+
}
|
|
134
|
+
const settled = new Map(summaries.valid.map((summary) => [summary.deploymentId, summary]));
|
|
135
|
+
if (ledgers.valid.length || ledgers.refused.length || retainedAdditiveTeamAttempts(additive).length || additive.refused.length || boots.refused.length || summaries.refused.length || boots.valid.some((attempt) => attempt.deploymentId !== ownAttempt && !freshTeamAttemptSettled(attempt, settled.get(attempt.deploymentId))))
|
|
136
|
+
throw new CommandFailure("refused", "LIFECYCLE_BLOCKED", "team deployments or unsettled boot records remain under this root; the controller stack did not adopt their resources", { target: { root, space } });
|
|
137
|
+
return maintenance.admittedRestore;
|
|
138
|
+
}
|
|
139
|
+
/** The broker binary that preparation already selected, canonicalized to its file. A bare PATH name
|
|
140
|
+
* is resolved under the same environment; no second selection or fallback is made. */
|
|
141
|
+
function canonicalBinary(bin) {
|
|
142
|
+
const found = bin.includes("/") ? bin : resolveOnPath(bin);
|
|
143
|
+
if (!found)
|
|
144
|
+
throw new CommandFailure("refused", "DEPENDENCY_UNAVAILABLE", "the selected nats-server could not be resolved to a file; no other binary was selected");
|
|
145
|
+
return realpathSync.native(found);
|
|
146
|
+
}
|
|
147
|
+
/** Save a stack definition, or verify an existing one is this root's stack definition. A saved
|
|
148
|
+
* definition naming another adapter or root refuses. One whose volatile launch options differ (the
|
|
149
|
+
* broker's freshly allocated websocket port, a different selected binary) is redefined only when
|
|
150
|
+
* every recorded instance of it is stopped with its terminal receipt; those stopped records are
|
|
151
|
+
* removed with the definition under its writer lock, exactly as `service remove` requires. */
|
|
152
|
+
function ensureDefinition(space, role, input, root) {
|
|
153
|
+
const store = serviceDefinitionStore(space), name = STACK_DEFINITION[role];
|
|
154
|
+
const existing = store.read(name);
|
|
155
|
+
const wanted = input.launch;
|
|
156
|
+
if (existing) {
|
|
157
|
+
const launch = existing.record.value.launch;
|
|
158
|
+
if (launch.type !== "adapter" || wanted.type !== "adapter" || launch.adapter !== STACK_ADAPTER[role] || launch.options.root !== root)
|
|
159
|
+
throw new CommandFailure("refused", "CONFLICT", "a saved definition under a stack name belongs to another adapter or root; it was not replaced", { target: { space, definition: name }, remedy: `inspect cotal service show ${name} --space ${space}` });
|
|
160
|
+
if (JSON.stringify(launch.options) === JSON.stringify(wanted.options))
|
|
161
|
+
return existing;
|
|
162
|
+
// A running member keeps the definition it was launched from; it is reused, never redefined.
|
|
163
|
+
if (serviceInstances(space, name).some((row) => observeServiceProcess(row.record.value) === "running"))
|
|
164
|
+
return existing;
|
|
165
|
+
store.commit(name, existing, undefined, () => removeStoppedInstanceRecords(space, name));
|
|
166
|
+
}
|
|
167
|
+
store.commit(name, undefined, validateServiceDefinition(input, space));
|
|
168
|
+
return store.read(name);
|
|
169
|
+
}
|
|
170
|
+
function adapterDefinition(space, adapter, options, timeoutMs) {
|
|
171
|
+
return { schemaVersion: 1, space, launch: { type: "adapter", adapter, options }, readiness: { type: "adapter", timeoutMs } };
|
|
172
|
+
}
|
|
173
|
+
function membersView(journal, title) {
|
|
174
|
+
return { sections: [{ title, blocks: [
|
|
175
|
+
{ kind: "fields", rows: [["Space", journal.space], ["Root", journal.root], ["Broker", journal.server], ["Mode", journal.mode === "open" ? "open, no authentication" : journal.mode === "user" ? "user auth" : "static auth"], ["Operation", `${journal.operation.kind} ${journal.operation.phase}`], ...(journal.mode === "user" ? [["Registration", userRegistrationIncomplete(journal.space) ? "incomplete: no confirmed auth-service endpoint" : "auth-service endpoint confirmed by its provider"]] : [])] },
|
|
176
|
+
{ kind: "table", columns: [{ key: "role", label: "Member" }, { key: "definition", label: "Definition" }, { key: "instance", label: "Full instance" }, { key: "state", label: "Result" }], rows: journal.members.map((member) => ({ role: member.role, definition: member.definition, instance: member.instanceId ?? "not allocated", state: { text: member.state.replaceAll("-", " "), tone: ["started", "reused", "stopped", "already-stopped"].includes(member.state) ? "ok" : ["refused", "failed"].includes(member.state) ? "failed" : "waiting" } })) },
|
|
177
|
+
{ kind: "lines", lines: [journal.mode === "open"
|
|
178
|
+
? "Open stack: no authentication, no delivery member and no delivery credential. Each member is one exact service-controller instance. Broker readiness means its own process reported its listener; manager readiness is the child's own local receipt, not an attributed endpoint response. This is not agent or task readiness, and a partial start is not rolled back."
|
|
179
|
+
: journal.mode === "user"
|
|
180
|
+
? "User-auth stack: each member is one exact service-controller instance. Auth-service readiness is its startup receipt plus the provider's readiness for that exact process; delivery readiness is its startup receipt; manager readiness is its endpoint read as your signed-in, granted login. This is not agent or task readiness, and a partial start is not rolled back."
|
|
181
|
+
: "Each member is one exact service-controller instance. Broker readiness means its own process reported its listener; delivery readiness is its process startup receipt; manager readiness is its attributed native endpoint. This is not agent or task readiness, and a partial start is not rolled back."] },
|
|
182
|
+
] }] };
|
|
183
|
+
}
|
|
184
|
+
/** `cotal up`'s controller route: start, seed the default persona into the root, then write its
|
|
185
|
+
* own receipt. The stack is up by then, so a persona that cannot be written is a warning. */
|
|
186
|
+
export async function stackUp(request, native) {
|
|
187
|
+
const { journal, changed, allReused, admittedRestore } = await startControllerStack(request, native);
|
|
188
|
+
const { root, space, server, mode } = journal;
|
|
189
|
+
const written = [];
|
|
190
|
+
const warnings = [];
|
|
191
|
+
try {
|
|
192
|
+
const persona = seedDefaultPersona(root);
|
|
193
|
+
if (persona)
|
|
194
|
+
written.push(persona);
|
|
195
|
+
}
|
|
196
|
+
catch (error) {
|
|
197
|
+
warnings.push({ code: "PERSONA_NOT_WRITTEN", target: { root, space }, message: `the default persona was not written in ${root}: ${error.message}` });
|
|
198
|
+
}
|
|
199
|
+
writeResult(request.presentation, { command: "up", target: { root, space, server }, result: { kind: "controller-stack-up", root, space, server, mode, operation: journal.operation, members: journal.members, changed, foreground: request.foreground, admittedRestore: admittedRestore ?? null, written }, warnings, ...(allReused && written.length === 0 ? { noOp: true } : {}) }, (result) => {
|
|
200
|
+
const members = membersView({ ...journal, members: result.members }, allReused ? "Controller stack already running" : "Controller stack started");
|
|
201
|
+
const view = result.written.length ? { ...members, sections: [...members.sections, { blocks: [{ kind: "fields", rows: result.written.map((w) => ["wrote", `${w.what}: ${w.path}`]) }] }] } : members;
|
|
202
|
+
return admittedRestore ? { ...view, sections: [...view.sections, { title: "Retained restore journal", blocks: [{ kind: "lines", lines: [`Active restore ${admittedRestore} stays in this root's maintenance journal. It was read and not changed.`] }] }] } : view;
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
/** Start the recorded stack and return its domain result without writing any receipt. */
|
|
206
|
+
export async function startControllerStack(request, native) {
|
|
207
|
+
const root = canonicalRoot(request.root), space = request.space;
|
|
208
|
+
if (request.transport.kind !== "plaintext" && request.transport.kind !== "tls-required")
|
|
209
|
+
throw new CommandFailure("refused", "UNSUPPORTED", "unknown broker transport");
|
|
210
|
+
const previous = readStackJournal(root);
|
|
211
|
+
if (request.expectPriorDown && (!previous || previous.sha256 !== request.expectPriorDown.journalSha256 || previous.journal.operation.id !== request.expectPriorDown.operationId))
|
|
212
|
+
throw new CommandFailure("refused", "CONFLICT", "the stopped stack changed after the team boot checked it; nothing was started", { target: { root, space, expected: request.expectPriorDown.operationId } });
|
|
213
|
+
// A stopped stack's broker is prepared again from its own recorded inputs. An explicit request for
|
|
214
|
+
// a different store, cap or bind host refuses; none is replaced by a default.
|
|
215
|
+
const recordedBroker = previous?.journal.broker;
|
|
216
|
+
if (recordedBroker && (request.storeDir !== undefined && resolve(request.storeDir) !== recordedBroker.storeDir || request.maxFileStore !== undefined && request.maxFileStore !== recordedBroker.maxFileStore || request.host !== undefined && request.host !== recordedBroker.host))
|
|
217
|
+
throw new CommandFailure("refused", "CONFLICT", "the requested broker store, cap or bind host differs from this stack's recorded broker inputs; nothing was prepared", { target: { root, space, recorded: recordedBroker } });
|
|
218
|
+
// A journal written before broker inputs were recorded cannot tell which store, cap or bind host
|
|
219
|
+
// its stopped broker used: `cotal down` removed the registration that held them, and broker
|
|
220
|
+
// preparation would otherwise fall back to the default `.cotal/nats` store with no cap. Such a
|
|
221
|
+
// restart is refused before any effect unless the caller names the store explicitly; the cap and
|
|
222
|
+
// host are then taken exactly as given and recorded, never inferred from a default.
|
|
223
|
+
const brokerRows0 = previous && !recordedBroker ? serviceInstances(space, STACK_DEFINITION.broker) : [];
|
|
224
|
+
const legacyStopped = previous !== undefined && !recordedBroker && !(brokerRows0.length === 1 && observeServiceProcess(brokerRows0[0].record.value) === "running");
|
|
225
|
+
if (legacyStopped && request.storeDir === undefined)
|
|
226
|
+
throw new CommandFailure("refused", "LIFECYCLE_BLOCKED", "this stopped stack was recorded before its broker store, cap and bind host were kept; the broker is not prepared from a default store", { target: { root, space, operation: previous.journal.operation.id }, remedy: `name the stack's original store explicitly: cotal up --store-dir <original store dir> [--max-file-store <bytes>] [--host <host>] --space ${space}; omit --max-file-store and --host only if the original start set neither` });
|
|
227
|
+
// The named store must already exist as a real directory: preparation would otherwise create
|
|
228
|
+
// an empty store at a mistyped path and start the stack on it. Its identity is pinned here and
|
|
229
|
+
// checked again by preparation, which never creates a pinned store, and just before the broker starts.
|
|
230
|
+
const storePin = legacyStopped ? pinExistingStore(resolve(request.storeDir), { root, space }) : undefined;
|
|
231
|
+
const brokerStore = recordedBroker?.storeDir ?? request.storeDir;
|
|
232
|
+
const brokerCap = recordedBroker ? recordedBroker.maxFileStore : request.maxFileStore;
|
|
233
|
+
const brokerHost = recordedBroker ? recordedBroker.host : request.host;
|
|
234
|
+
// The mode is pinned by the first whole-stack up. A conflicting explicit request refuses here,
|
|
235
|
+
// before any preflight write, preparation or launch.
|
|
236
|
+
if (previous && request.mode !== undefined && request.mode !== previous.journal.mode)
|
|
237
|
+
throw new CommandFailure("refused", "CONFLICT", "this root's controller stack is pinned to another auth mode; a running or stopped stack is not converted", { target: { root, space, recorded: previous.journal.mode, requested: request.mode }, remedy: "run bare cotal up to keep the recorded mode" });
|
|
238
|
+
const mode = previous?.journal.mode ?? request.mode ?? "auth";
|
|
239
|
+
if (mode === "open" && holdsBrokerAccount(root))
|
|
240
|
+
throw new CommandFailure("refused", "CONFLICT", "this root holds a broker account; an open stack does not bypass its recorded authorization", { target: { root, space } });
|
|
241
|
+
if (mode === "user")
|
|
242
|
+
assertUserStackTransport(previous?.journal.server ?? request.server, request.transport.kind === "tls-required");
|
|
243
|
+
else if (request.idp !== undefined)
|
|
244
|
+
throw new CommandFailure("refused", "USAGE_INVALID", "--idp belongs to a user-auth stack; nothing was prepared", { target: { root, space } });
|
|
245
|
+
const admittedRestore = stackPreflight(root, space, previous?.journal, request.manifest?.deploymentId);
|
|
246
|
+
if (previous && (previous.journal.space !== space || previous.journal.server !== request.server))
|
|
247
|
+
throw new CommandFailure("refused", "CONFLICT", "this root's stack journal names another space or broker address; it was not rebound", { target: { root, space, recorded: { space: previous.journal.space, server: previous.journal.server } } });
|
|
248
|
+
// The broker service launches only for a space registered or prepared at this root. That is
|
|
249
|
+
// checked here, before trust, configuration, definitions, instances or the journal are written,
|
|
250
|
+
// so the refusal leaves the folder as it was.
|
|
251
|
+
const registration = findMesh(space), preparedSpace = findPreparedSpace(space);
|
|
252
|
+
if (registration && (registration.origin !== "up" || canonicalRoot(registration.root) !== root || registration.server !== (previous?.journal.server ?? request.server)))
|
|
253
|
+
throw new CommandFailure("refused", "CONFLICT", "the space is registered to another root, broker address or external origin; nothing was prepared or started", { target: { root, space }, remedy: `inspect it with cotal space show ${space}` });
|
|
254
|
+
if (!registration && (!preparedSpace || canonicalRoot(preparedSpace.root) !== root))
|
|
255
|
+
throw new CommandFailure("refused", "TARGET_UNAVAILABLE", "the space has no prepared or locally started registration at this root; nothing was prepared or started", { target: { root, space }, remedy: `prepare it with cotal space create ${space} --root ${root}, then run cotal up` });
|
|
256
|
+
if (previous && ["planned", "applying", "unknown"].includes(previous.journal.operation.phase))
|
|
257
|
+
throw new CommandFailure("unknown", "OPERATION_UNKNOWN", "an earlier whole-stack operation on this root has no settled outcome; it was not retried", { target: { root, space, operation: previous.journal.operation }, remedy: `inspect the stack's members with cotal service --space ${space} before another whole-stack operation` });
|
|
258
|
+
const server = previous?.journal.server ?? request.server;
|
|
259
|
+
if (request.noManager) {
|
|
260
|
+
const running = serviceInstances(space, STACK_DEFINITION.manager).filter((row) => observeServiceProcess(row.record.value) === "running");
|
|
261
|
+
if (running.length)
|
|
262
|
+
throw new CommandFailure("refused", "LIFECYCLE_BLOCKED", "--no-manager cannot keep an already-running controller manager; no member was started or stopped", { target: { root, space, instances: running.map((row) => row.name) }, remedy: `stop the recorded manager with cotal service stop ${STACK_DEFINITION.manager} --space ${space} --yes before requesting --no-manager` });
|
|
263
|
+
}
|
|
264
|
+
// Check provider inputs before preparation or a journal write. A supplied IdP is always checked,
|
|
265
|
+
// including a live refresh; only an unpinned first enable probes JWKS. Preparation checks again.
|
|
266
|
+
if (mode === "user") {
|
|
267
|
+
const brokerRows = serviceInstances(space, STACK_DEFINITION.broker);
|
|
268
|
+
if (request.idp !== undefined || !(brokerRows.length === 1 && observeServiceProcess(brokerRows[0].record.value) === "running"))
|
|
269
|
+
await preflightUserStack(root, space, request.idp);
|
|
270
|
+
}
|
|
271
|
+
const roles = STACK_ROLES.filter((role) => stackRoleApplies(mode, role) && !(role === "manager" && request.noManager));
|
|
272
|
+
const members = STACK_ROLES.map((role) => ({ role, definition: STACK_DEFINITION[role], instanceId: previous?.journal.members.find((row) => row.role === role)?.instanceId ?? null, state: roles.includes(role) ? "planned" : "not-attempted" }));
|
|
273
|
+
let journal = { schemaVersion: 1, kind: "cotal-stack-controller", root, space, server, mode, ...(recordedBroker ? { broker: recordedBroker } : {}), members, operation: newStackOperation("up"), updatedAt: new Date().toISOString() };
|
|
274
|
+
// The whole scoped plan is durable before the first effect. A crash after this reads as unsettled.
|
|
275
|
+
let snapshot = writeStackJournal(root, previous, journal);
|
|
276
|
+
const changed = [];
|
|
277
|
+
const settle = (phase) => {
|
|
278
|
+
journal = { ...journal, operation: { ...journal.operation, phase }, updatedAt: new Date().toISOString() };
|
|
279
|
+
snapshot = writeStackJournal(root, snapshot, journal);
|
|
280
|
+
};
|
|
281
|
+
const mark = (role, change) => {
|
|
282
|
+
journal = { ...journal, members: journal.members.map((row) => row.role === role ? { ...row, ...change } : row), updatedAt: new Date().toISOString() };
|
|
283
|
+
snapshot = writeStackJournal(root, snapshot, journal);
|
|
284
|
+
};
|
|
285
|
+
const start = async (role, definition) => {
|
|
286
|
+
prepareProcessService(definition);
|
|
287
|
+
const current = serviceInstances(space, definition.name);
|
|
288
|
+
if (current.length > 1)
|
|
289
|
+
throw new CommandFailure("refused", "TARGET_AMBIGUOUS", "a stack definition has several instance records; no instance was chosen", { target: { space, definition: definition.name, candidates: current.map((row) => row.name) } });
|
|
290
|
+
const recorded = journal.members.find((row) => row.role === role).instanceId;
|
|
291
|
+
if (current[0] && recorded && current[0].name !== recorded)
|
|
292
|
+
throw new CommandFailure("refused", "CONFLICT", "the stack journal and the definition's instance record name different instances; neither was adopted", { target: { space, definition: definition.name } });
|
|
293
|
+
const started = await startProcessService(definition, current[0] ? { instance: current[0].name } : {});
|
|
294
|
+
mark(role, { instanceId: started.instance.name, state: started.noOp ? "reused" : "started" });
|
|
295
|
+
if (!started.noOp)
|
|
296
|
+
changed.push(instanceProjection(started.instance));
|
|
297
|
+
return started.instance;
|
|
298
|
+
};
|
|
299
|
+
settle("applying");
|
|
300
|
+
// Set only when a user stack's manager is withheld for want of an existing login and grant. That
|
|
301
|
+
// is a known pre-effect refusal of one member, never a launch and never an unknown outcome.
|
|
302
|
+
let loginBlock;
|
|
303
|
+
// A failure in a step that belongs to an already-started member is attributed to that member,
|
|
304
|
+
// never to the next planned one.
|
|
305
|
+
let failedRole;
|
|
306
|
+
let failedStage;
|
|
307
|
+
let launch;
|
|
308
|
+
try {
|
|
309
|
+
// Broker. Trust and configuration are prepared only when this broker is not already serving
|
|
310
|
+
// under its own recorded instance, never as an adapter planning step.
|
|
311
|
+
const brokerRows = serviceInstances(space, STACK_DEFINITION.broker);
|
|
312
|
+
const brokerRunning = brokerRows.length === 1 && observeServiceProcess(brokerRows[0].record.value) === "running";
|
|
313
|
+
if (!brokerRunning && await isReachable(server, { timeoutMs: 1500 }))
|
|
314
|
+
throw new CommandFailure("refused", "CONFLICT", "something already answers at the stack's broker address without this stack's broker instance; it was not adopted or stopped", { target: { root, space, server } });
|
|
315
|
+
let prepared;
|
|
316
|
+
if (!brokerRunning) {
|
|
317
|
+
prepared = await native.prepareBroker({ transport: request.transport, server, space, open: mode === "open", ...(mode === "user" ? { userAuth: request.idp !== undefined ? { idpUrl: request.idp } : {} } : {}), ...(brokerHost ? { host: brokerHost } : {}), ...(brokerStore ? { storeDir: brokerStore } : {}), ...(storePin ? { existingStore: storePin } : {}), ...(brokerCap !== undefined ? { maxFileStore: brokerCap } : {}), ...(request.manifest ? { seed: request.manifest.seed } : request.channels ? { channels: request.channels } : {}) });
|
|
318
|
+
if (canonicalRoot(prepared.root) !== root || prepared.space !== space || prepared.server !== server || (prepared.setup === undefined) !== (mode === "open") || (prepared.user === undefined) !== (mode !== "user"))
|
|
319
|
+
throw new CommandFailure("refused", "CONFLICT", "the prepared broker configuration names another root, space, address or auth mode; the stack did not continue");
|
|
320
|
+
if (mode === "user")
|
|
321
|
+
assertUserStackTransport(server, prepared.transport.kind === "tls-required");
|
|
322
|
+
// The validated transport decision is recorded before the broker child starts, so its
|
|
323
|
+
// listener-report check compares against the transport this configuration actually serves.
|
|
324
|
+
native.commitTransport(root, prepared.transport);
|
|
325
|
+
journal = { ...journal, broker: { storeDir: resolve(prepared.storeDir), ...(brokerCap !== undefined ? { maxFileStore: brokerCap } : {}), ...(brokerHost ? { host: brokerHost } : {}) }, updatedAt: new Date().toISOString() };
|
|
326
|
+
snapshot = writeStackJournal(root, snapshot, journal);
|
|
327
|
+
}
|
|
328
|
+
// A running stack broker keeps its saved definition; a fresh one is defined from this preparation.
|
|
329
|
+
const savedBroker = serviceDefinitionStore(space).read(STACK_DEFINITION.broker);
|
|
330
|
+
const savedOptions = savedBroker?.record.value.launch.type === "adapter" ? savedBroker.record.value.launch.options : undefined;
|
|
331
|
+
if (!prepared && !savedOptions)
|
|
332
|
+
throw new CommandFailure("refused", "CONFLICT", "a broker instance runs without its saved stack definition; it was not adopted", { target: { space, definition: STACK_DEFINITION.broker } });
|
|
333
|
+
const brokerOptions = prepared ? { root, config: prepared.confPath, binary: canonicalBinary(prepared.bin), server } : { ...savedOptions };
|
|
334
|
+
const broker = ensureDefinition(space, "broker", adapterDefinition(space, STACK_ADAPTER.broker, brokerOptions, 30000), root);
|
|
335
|
+
if (storePin)
|
|
336
|
+
recheckExistingStore(storePin, { root, space });
|
|
337
|
+
await start("broker", broker);
|
|
338
|
+
if (prepared) {
|
|
339
|
+
// The broker's own stream and registry setup, on the native space path, after it serves.
|
|
340
|
+
failedRole = "broker";
|
|
341
|
+
failedStage = "broker-streams";
|
|
342
|
+
await native.initializeStreams(server, space, prepared.setup, prepared.seedFile);
|
|
343
|
+
failedStage = "broker-registration";
|
|
344
|
+
// A user registration is recorded here, before its auth service exists, because the native
|
|
345
|
+
// auth-service child resolves a registered user target. It carries only the prepared trust
|
|
346
|
+
// pins and stays incomplete until that child's own readiness is confirmed below.
|
|
347
|
+
native.recordMesh({ space, server, root, mode, tlsRequired: prepared.transport.kind === "tls-required", storeDir: prepared.storeDir, ...(prepared.user ? { userAuth: provisionalUserAuth(prepared.user) } : {}), ...(request.maxSessions !== undefined ? { maxSessions: request.maxSessions } : {}), ...(brokerHost ? { attachHost: brokerHost } : {}), ...(brokerCap !== undefined ? { maxFileStore: brokerCap } : {}) });
|
|
348
|
+
failedStage = undefined;
|
|
349
|
+
failedRole = undefined;
|
|
350
|
+
}
|
|
351
|
+
// Auth service, user stacks only. Its native preparation came from this broker preparation, so
|
|
352
|
+
// a stopped auth service under an already-running broker is not started from guessed material.
|
|
353
|
+
if (mode === "user") {
|
|
354
|
+
const authRows = serviceInstances(space, STACK_DEFINITION.auth);
|
|
355
|
+
const authRunning = authRows.length === 1 && observeServiceProcess(authRows[0].record.value) === "running";
|
|
356
|
+
if (!prepared?.user && !authRunning)
|
|
357
|
+
throw new CommandFailure("refused", "LIFECYCLE_BLOCKED", "the user stack's auth service is stopped while its broker still runs; its native preparation runs only with a broker start, so it was not started from other material", { target: { root, space }, remedy: "stop the stack with bare cotal down, then run bare cotal up" });
|
|
358
|
+
const authService = ensureDefinition(space, "auth", adapterDefinition(space, STACK_ADAPTER.auth, { root, server }, 60000), root);
|
|
359
|
+
const instance = await start("auth", authService);
|
|
360
|
+
if (prepared?.user) {
|
|
361
|
+
failedRole = "auth";
|
|
362
|
+
const confirmed = await confirmUserAuthEndpoints(prepared.user, space, instance);
|
|
363
|
+
native.recordMesh({ space, server, root, mode, tlsRequired: prepared.transport.kind === "tls-required", storeDir: prepared.storeDir, userAuth: confirmed, ...(request.maxSessions !== undefined ? { maxSessions: request.maxSessions } : {}), ...(brokerHost ? { attachHost: brokerHost } : {}), ...(brokerCap !== undefined ? { maxFileStore: brokerCap } : {}) });
|
|
364
|
+
failedRole = undefined;
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
// Delivery. Its scoped native credential is minted into the root's own store key, the same
|
|
368
|
+
// material the native daemon reads; the adapter is handed only that protected path. A user
|
|
369
|
+
// stack uses the same hosting-root space signer as native `ensureDelivery` does on a user root.
|
|
370
|
+
// An open stack has no delivery member, so no trust is read and no credential is minted.
|
|
371
|
+
if (mode !== "open") {
|
|
372
|
+
const store = workspaceSecretStore(root), auth = await getSpaceAuth(store, space);
|
|
373
|
+
if (!auth)
|
|
374
|
+
throw new CommandFailure("refused", "TARGET_UNAVAILABLE", "the static space trust is missing; no delivery credential was minted from another signer", { target: { root, space } });
|
|
375
|
+
const credsKey = deliveryCredsKey(space, { injected: false, root });
|
|
376
|
+
const credsPath = join(root, ".cotal", credsKey);
|
|
377
|
+
const deliveryRows = serviceInstances(space, STACK_DEFINITION.delivery);
|
|
378
|
+
if (!(deliveryRows.length === 1 && observeServiceProcess(deliveryRows[0].record.value) === "running"))
|
|
379
|
+
await store.put(credsKey, await mintCreds(auth, newIdentity(), "delivery"));
|
|
380
|
+
const delivery = ensureDefinition(space, "delivery", adapterDefinition(space, STACK_ADAPTER.delivery, { root, creds: credsPath, server }, 40000), root);
|
|
381
|
+
await start("delivery", delivery);
|
|
382
|
+
}
|
|
383
|
+
// A user stack's manager is read and stopped as the invoking user's existing login. Without a
|
|
384
|
+
// signed-in, granted login it is not attempted; nothing is launched for it.
|
|
385
|
+
if (!request.noManager && mode === "user") {
|
|
386
|
+
const login = await userLoginState(root, space);
|
|
387
|
+
if (login.state !== "ready")
|
|
388
|
+
loginBlock = userLoginRequired(space, login);
|
|
389
|
+
}
|
|
390
|
+
if (!request.noManager && !loginBlock) {
|
|
391
|
+
const options = { root, runtime: request.runtime, server };
|
|
392
|
+
if (prepared?.setup?.wsPort !== undefined)
|
|
393
|
+
options["ws-port"] = prepared.setup.wsPort;
|
|
394
|
+
if (request.maxSessions !== undefined)
|
|
395
|
+
options["max-sessions"] = request.maxSessions;
|
|
396
|
+
if (brokerHost)
|
|
397
|
+
options["console-host"] = brokerHost;
|
|
398
|
+
if (request.manifest) {
|
|
399
|
+
// The manager carries the manifest launch only when this call starts it. A running manager
|
|
400
|
+
// keeps the launch it was started with; nothing is re-launched or re-pinned under it.
|
|
401
|
+
const managerRows = serviceInstances(space, STACK_DEFINITION.manager);
|
|
402
|
+
if (managerRows.some((row) => observeServiceProcess(row.record.value) === "running"))
|
|
403
|
+
throw new CommandFailure("refused", "LIFECYCLE_BLOCKED", "a controller manager already runs for this space; a fresh manifest launch was not attached to it", { target: { root, space, instances: managerRows.map((row) => row.name) } });
|
|
404
|
+
failedRole = "manager";
|
|
405
|
+
launch = await request.manifest.launchSpec({ root, space, server, mode, ...(prepared?.user ? { user: prepared.user } : {}) });
|
|
406
|
+
failedRole = undefined;
|
|
407
|
+
options.launch = launch.path;
|
|
408
|
+
options["launch-sha256"] = launch.sha256;
|
|
409
|
+
}
|
|
410
|
+
const manager = ensureDefinition(space, "manager", adapterDefinition(space, STACK_ADAPTER.manager, options, 60000), root);
|
|
411
|
+
await start("manager", manager);
|
|
412
|
+
}
|
|
413
|
+
if (!loginBlock)
|
|
414
|
+
settle("completed");
|
|
415
|
+
}
|
|
416
|
+
catch (error) {
|
|
417
|
+
const failure = isCommandFailure(error) ? error : undefined;
|
|
418
|
+
const uncertain = failure === undefined || failure.outcome === "unknown";
|
|
419
|
+
const pending = failedRole ? journal.members.find((row) => row.role === failedRole) : journal.members.find((row) => row.state === "planned");
|
|
420
|
+
if (pending)
|
|
421
|
+
mark(pending.role, { state: uncertain ? "unknown" : failure?.outcome === "refused" ? "refused" : "failed", code: failure?.code ?? "OPERATION_UNKNOWN" });
|
|
422
|
+
for (const row of journal.members.filter((member) => member.state === "planned"))
|
|
423
|
+
mark(row.role, { state: "not-attempted" });
|
|
424
|
+
settle(uncertain ? "unknown" : changed.length ? "partial" : failure?.outcome === "failed" ? "failed" : "refused");
|
|
425
|
+
const outcome = uncertain ? "unknown" : changed.length ? "partial" : failure.outcome;
|
|
426
|
+
// Keep typed broker codes, never the server's arbitrary description or the raw error object.
|
|
427
|
+
const nativeCause = failure ? { code: failure.code, outcome: failure.outcome, detail: failure.message }
|
|
428
|
+
: error instanceof JetStreamApiError && Number.isSafeInteger(error.code) && error.code >= 10000 && error.code < 20000
|
|
429
|
+
? { code: String(error.code), ...(Number.isSafeInteger(error.status) && error.status >= 400 && error.status < 600 ? { detail: { status: error.status } } : {}) }
|
|
430
|
+
: undefined;
|
|
431
|
+
throw new CommandFailure(outcome, uncertain ? "OPERATION_UNKNOWN" : changed.length ? "OPERATION_PARTIAL" : failure.code, "the controller stack did not start every planned member; started members were kept and nothing was retried", { target: { root, space, operation: journal.operation.id, members: journal.members, ...(failedStage ? { stage: failedStage } : {}) }, changed, ...(nativeCause ? { native: nativeCause } : {}), remedy: `inspect the stack's members with cotal service --space ${space} before another cotal up; a later bare cotal down stops only the recorded members` });
|
|
432
|
+
}
|
|
433
|
+
if (loginBlock) {
|
|
434
|
+
mark("manager", { state: "not-attempted", code: "AUTH_REQUIRED" });
|
|
435
|
+
// Other members that this call started or found already running under their own recorded
|
|
436
|
+
// instances are known live state, so the outcome is partial even when nothing new launched.
|
|
437
|
+
// `changed` stays exactly what this call launched; reused members are not reported as launches.
|
|
438
|
+
const live = journal.members.filter((row) => row.role !== "manager" && (row.state === "started" || row.state === "reused"));
|
|
439
|
+
settle(live.length ? "partial" : "refused");
|
|
440
|
+
const detail = { root, space, operation: journal.operation.id, members: journal.members, registration: userRegistrationIncomplete(space) ? "incomplete" : "confirmed" };
|
|
441
|
+
if (!live.length)
|
|
442
|
+
throw new CommandFailure("refused", "AUTH_REQUIRED", loginBlock.message, { target: detail, ...(loginBlock.remedy ? { remedy: loginBlock.remedy } : {}) });
|
|
443
|
+
throw new CommandFailure("partial", "OPERATION_PARTIAL", changed.length
|
|
444
|
+
? "the user stack started its other members; the manager was not attempted because no signed-in, granted login exists. This is not whole-stack readiness"
|
|
445
|
+
: "the user stack's other members were already running and were reused; the manager was not attempted because no signed-in, granted login exists. This is not whole-stack readiness", { target: detail, changed, native: { code: "AUTH_REQUIRED", outcome: "refused", detail: loginBlock.message }, ...(loginBlock.remedy ? { remedy: loginBlock.remedy } : {}) });
|
|
446
|
+
}
|
|
447
|
+
const allReused = journal.members.every((row) => row.state === "reused" || row.state === "not-attempted");
|
|
448
|
+
return { journal, changed, allReused, ...(launch ? { launch } : {}), ...(admittedRestore ? { admittedRestore } : {}) };
|
|
449
|
+
}
|
|
450
|
+
/** The member table and evidence text a caller embeds in its own receipt. */
|
|
451
|
+
export function stackMembersView(journal, title) {
|
|
452
|
+
return membersView(journal, title);
|
|
453
|
+
}
|
|
454
|
+
export function stackUpForegroundNotice(presentation, space) {
|
|
455
|
+
if (presentation === "json")
|
|
456
|
+
return;
|
|
457
|
+
console.log(renderReport({ space, sections: [{ title: "Foreground stack lifetime", blocks: [{ kind: "lines", lines: ["This terminal holds the stack's lifetime. Ctrl-C or SIGTERM runs the same guarded whole-stack stop as bare cotal down, including its manager impact review. Terminal loss or an external kill is not a confirmed stop."] }] }] }, presentation, terminalWidth(process.stdout)));
|
|
458
|
+
}
|
|
459
|
+
//# sourceMappingURL=stack-up.js.map
|