@cotal-ai/cli 0.90.1 → 0.91.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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,227 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `cotal chat [channel]`: one live session under its own admitted identity, in the terminal view,
|
|
3
|
+
* `--plain` lines, or the `--stdio` NDJSON protocol. The mesh is resolved once, and the session is
|
|
4
|
+
* admitted by that target's recorded auth mode only. Leaving ends the session; nothing outlives it.
|
|
5
|
+
*/
|
|
6
|
+
import { randomBytes } from "node:crypto";
|
|
7
|
+
import { hostname, userInfo } from "node:os";
|
|
8
|
+
import { assertValidChannel, isConcreteChannel, oneLine, readChannelRegistry, } from "@cotal-ai/core";
|
|
9
|
+
import { CommandFailure, connectTargetOrThrow, credsFlag, isConnectRefusal, loadMeshes, plainFlag, preflightOrThrow, resolveTargetOrThrow, serverFlag, spaceFlag, } from "@cotal-ai/workspace";
|
|
10
|
+
import { completingFlagValue, positionalsForCompletion } from "../lib/completion.js";
|
|
11
|
+
import { listDeclaredChannels } from "../lib/personas.js";
|
|
12
|
+
import { declaredFrom } from "./send.js";
|
|
13
|
+
import { loadChatFrontEnd, selectFrontEnd } from "../chat/frontend.js";
|
|
14
|
+
import { openRoutingChatSession } from "../chat/open-session.js";
|
|
15
|
+
import { openStaticChatSession } from "../chat/static-session.js";
|
|
16
|
+
import { openUserChatSession } from "../chat/user-session.js";
|
|
17
|
+
import { closeSummary } from "../chat/view.js";
|
|
18
|
+
export const chatFlags = [
|
|
19
|
+
spaceFlag, serverFlag, { ...credsFlag, description: "an explicit credential file (not available for chat yet)" }, plainFlag,
|
|
20
|
+
{ name: "stdio", type: "boolean", description: "exchange the NDJSON participant protocol on stdin and stdout instead of the terminal view" },
|
|
21
|
+
{ name: "name", type: "string", value: "<n>", description: "the session's display label (default: <login>@<host> and a short suffix)" },
|
|
22
|
+
{ name: "role", type: "string", value: "<r>", description: "a presence role (not available for chat yet)" },
|
|
23
|
+
{ name: "kind", type: "string", value: "<k>", description: "the session's presence kind; only endpoint, the default, is accepted" },
|
|
24
|
+
{ name: "link", type: "string", value: "<url>", description: "the space and auth from a join link (not available for chat yet)" },
|
|
25
|
+
{ name: "token", type: "string", value: "<t>", description: "the space and auth from a join token (not available for chat yet)" },
|
|
26
|
+
{ name: "lifecycle-uid", type: "string", value: "<uid>", description: "the lifecycle UID paired with --creds (not available for chat yet)" },
|
|
27
|
+
];
|
|
28
|
+
/** Declared flags no admission supports yet, each with the reason it refuses. */
|
|
29
|
+
const NOT_YET = [
|
|
30
|
+
["role", "a role puts the session on that role's work queue, the chat view cannot yet answer a task's sender, and the static and user-mode admissions take no role"],
|
|
31
|
+
["link", "no admission opens a chat session from a join link; select the space with --space or cotal use"],
|
|
32
|
+
["token", "no admission opens a chat session from a join token; select the space with --space or cotal use"],
|
|
33
|
+
["creds", "a chat session gets its own identity from the space, and no admission accepts an explicit credential"],
|
|
34
|
+
["lifecycle-uid", "it pairs with --creds, which no chat admission accepts"],
|
|
35
|
+
];
|
|
36
|
+
/** A user-mode session asks for the auth service's whole lifetime cap, 8 hours, which it never
|
|
37
|
+
* extends. Each bearer within it still lasts at most 15 minutes. */
|
|
38
|
+
export const USER_CHAT_TTL_SEC = 8 * 60 * 60;
|
|
39
|
+
/** Check the grammar and choose the front end, before any target, connector or connection. */
|
|
40
|
+
export function chatArguments(args) {
|
|
41
|
+
const values = args.values;
|
|
42
|
+
if (args.positionals.length > 1)
|
|
43
|
+
throw new CommandFailure("refused", "USAGE_INVALID", "chat takes at most one channel", { remedy: "run cotal chat [<channel>]" });
|
|
44
|
+
const raw = args.positionals[0];
|
|
45
|
+
const channel = raw?.replace(/^#/, "");
|
|
46
|
+
if (channel !== undefined) {
|
|
47
|
+
try {
|
|
48
|
+
assertValidChannel(channel);
|
|
49
|
+
if (!isConcreteChannel(channel))
|
|
50
|
+
throw new Error("wildcard");
|
|
51
|
+
}
|
|
52
|
+
catch {
|
|
53
|
+
throw new CommandFailure("refused", "USAGE_INVALID", "name one concrete channel, without wildcards");
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
if (values.name !== undefined && (!values.name.trim() || values.name.length > 128 || /[\u0000-\u001f\u007f]/u.test(values.name)))
|
|
57
|
+
throw new CommandFailure("refused", "USAGE_INVALID", "--name takes a label of 1 to 128 characters without control characters");
|
|
58
|
+
// Every admission presents the session as an endpoint, so `--kind endpoint` changes nothing.
|
|
59
|
+
if (values.kind !== undefined && values.kind !== "endpoint")
|
|
60
|
+
throw new CommandFailure("refused", "USAGE_INVALID", values.kind === "agent" ? "--kind agent is refused because a chat session never presents as an agent" : "--kind accepts only endpoint", { remedy: "run cotal chat without --kind" });
|
|
61
|
+
for (const [flag, reason] of NOT_YET)
|
|
62
|
+
if (values[flag] !== undefined)
|
|
63
|
+
throw new CommandFailure("refused", "UNSUPPORTED", `--${flag} is not available for chat yet: ${reason}`, { remedy: `run cotal chat without --${flag}` });
|
|
64
|
+
const picked = selectFrontEnd({ stdio: values.stdio, plain: values.plain });
|
|
65
|
+
if (!picked.ok)
|
|
66
|
+
throw new CommandFailure("refused", "USAGE_INVALID", picked.message);
|
|
67
|
+
return { ...(channel === undefined ? {} : { channel }), ...(values.name === undefined ? {} : { label: values.name }), frontEnd: picked.frontEnd };
|
|
68
|
+
}
|
|
69
|
+
export function chatAdmission(mode, label, channel) {
|
|
70
|
+
const channels = channel === undefined ? [] : [channel];
|
|
71
|
+
if (mode === "open")
|
|
72
|
+
return { mode, label, channels };
|
|
73
|
+
if (mode === "auth")
|
|
74
|
+
return { mode, label, subscribe: channels, allowPublish: channels };
|
|
75
|
+
if (mode === "user")
|
|
76
|
+
return { mode, label, channels, read: channels, post: channels, ttlSec: USER_CHAT_TTL_SEC };
|
|
77
|
+
throw new CommandFailure("refused", "UNSUPPORTED", `chat has no admission for a mesh recorded in "${String(mode)}" mode; no other mode was tried`);
|
|
78
|
+
}
|
|
79
|
+
/** Admit through the one adapter the mode names. Each adapter refuses a target of another mode. */
|
|
80
|
+
function admit(target, admission) {
|
|
81
|
+
switch (admission.mode) {
|
|
82
|
+
case "open": return openRoutingChatSession(target, admission);
|
|
83
|
+
case "auth": return openStaticChatSession(target, admission);
|
|
84
|
+
case "user": return openUserChatSession(target, admission);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
/** The exit code of a session that ended by leaving, end of input or expiry. Only a confirmed
|
|
88
|
+
* close is 0. Retirement asked for and not confirmed is 4. An unknown outcome, an unconfirmed
|
|
89
|
+
* connection close, or no close report is 3. */
|
|
90
|
+
export function closeExitCode(close) {
|
|
91
|
+
if (!close || close.retirement === "unknown" || close.connectionClosed !== "confirmed")
|
|
92
|
+
return 3;
|
|
93
|
+
return close.retirement === "requested" ? 4 : 0;
|
|
94
|
+
}
|
|
95
|
+
/** `<login>@<host>-<4 hex>`: readable, and distinct between two windows on one machine. A label is
|
|
96
|
+
* display only; the admitted principal is the session's authority. */
|
|
97
|
+
function defaultLabel() {
|
|
98
|
+
let login = "";
|
|
99
|
+
let host = "";
|
|
100
|
+
try {
|
|
101
|
+
login = userInfo().username.trim();
|
|
102
|
+
host = hostname().trim();
|
|
103
|
+
}
|
|
104
|
+
catch { /* refused below */ }
|
|
105
|
+
const label = `${login}@${host}-${randomBytes(2).toString("hex")}`;
|
|
106
|
+
if (!login || !host || label.length > 128 || /[/\\\u0000-\u001f\u007f]/u.test(label))
|
|
107
|
+
throw new CommandFailure("refused", "USAGE_INVALID", "chat cannot derive a label from the OS login and host", { remedy: "pass --name <n>" });
|
|
108
|
+
return label;
|
|
109
|
+
}
|
|
110
|
+
/** The exit status each terminating signal sets. */
|
|
111
|
+
const SIGNAL_EXIT = { SIGINT: 130, SIGTERM: 143, SIGHUP: 129 };
|
|
112
|
+
/** Hold SIGINT, SIGTERM and SIGHUP until a front end has installed its own handling, so no signal
|
|
113
|
+
* kills the process while a session is being admitted or is admitted. The first signal is kept and
|
|
114
|
+
* later ones are absorbed. */
|
|
115
|
+
export function holdSignals() {
|
|
116
|
+
let caught;
|
|
117
|
+
const held = Object.keys(SIGNAL_EXIT).map((sig) => {
|
|
118
|
+
const handler = () => { caught ??= SIGNAL_EXIT[sig]; };
|
|
119
|
+
process.on(sig, handler);
|
|
120
|
+
return () => { process.off(sig, handler); };
|
|
121
|
+
});
|
|
122
|
+
return { caught: () => caught, release: () => { for (const off of held)
|
|
123
|
+
off(); } };
|
|
124
|
+
}
|
|
125
|
+
/** The line that discloses a named channel before admission. `registered` is undefined when the
|
|
126
|
+
* registry could not be read. */
|
|
127
|
+
export function channelDisclosure(channel, registered) {
|
|
128
|
+
if (registered === undefined)
|
|
129
|
+
return `the registration of #${channel} could not be read; only the space's native policy decides whether a send is accepted`;
|
|
130
|
+
return registered ? `#${channel} is a registered channel` : `Unregistered channel #${channel}: sends follow the space's native policy, and nothing creates its registration`;
|
|
131
|
+
}
|
|
132
|
+
/** Read whether `channel` is registered, on the resolved target, through the one-shot `operator`
|
|
133
|
+
* connection and the registry read `cotal send` uses. The connection is also the reachability
|
|
134
|
+
* check. Nothing is written, and a read the broker refuses is disclosed as not read. */
|
|
135
|
+
async function discloseChannel(target, channel) {
|
|
136
|
+
const connection = await connectTargetOrThrow(target, "operator");
|
|
137
|
+
try {
|
|
138
|
+
const registry = await readChannelRegistry({ servers: connection.server, space: target.space, ...(connection.bearer ? { bearer: connection.bearer, sentinelCreds: connection.sentinelCreds } : { creds: connection.creds }) });
|
|
139
|
+
return channelDisclosure(channel, Object.hasOwn(registry.channels ?? {}, channel));
|
|
140
|
+
}
|
|
141
|
+
catch {
|
|
142
|
+
return channelDisclosure(channel, undefined);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
/** Resolve the recorded mesh `--space`/`--server` select, once. Disclose the named channel, or
|
|
146
|
+
* check the target reachable when none is named. */
|
|
147
|
+
async function prepareChat(values, channel) {
|
|
148
|
+
try {
|
|
149
|
+
const target = await resolveTargetOrThrow({ space: values.space, server: values.server });
|
|
150
|
+
if (channel !== undefined)
|
|
151
|
+
return { target, notice: await discloseChannel(target, channel) };
|
|
152
|
+
await preflightOrThrow(target);
|
|
153
|
+
return { target };
|
|
154
|
+
}
|
|
155
|
+
catch (e) {
|
|
156
|
+
if (isConnectRefusal(e))
|
|
157
|
+
throw e.failure();
|
|
158
|
+
throw e;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
export async function chat(args) {
|
|
162
|
+
const input = chatArguments(args);
|
|
163
|
+
const start = await loadChatFrontEnd(input.frontEnd);
|
|
164
|
+
const signals = holdSignals();
|
|
165
|
+
let target;
|
|
166
|
+
let notice;
|
|
167
|
+
let session;
|
|
168
|
+
try {
|
|
169
|
+
({ target, notice } = await prepareChat(args.values, input.channel));
|
|
170
|
+
if (notice)
|
|
171
|
+
process.stderr.write(`cotal chat: ${notice}\n`);
|
|
172
|
+
const before = signals.caught();
|
|
173
|
+
if (before !== undefined) {
|
|
174
|
+
signals.release();
|
|
175
|
+
process.stderr.write("cotal chat: interrupted before admission; no session was opened\n");
|
|
176
|
+
process.exitCode = before;
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
session = await admit(target, chatAdmission(target.mode, input.label ?? defaultLabel(), input.channel));
|
|
180
|
+
}
|
|
181
|
+
catch (e) {
|
|
182
|
+
signals.release();
|
|
183
|
+
throw e;
|
|
184
|
+
}
|
|
185
|
+
const during = signals.caught();
|
|
186
|
+
if (during !== undefined) {
|
|
187
|
+
// Interrupted while admitting: close what was admitted before a front end starts.
|
|
188
|
+
const ended = await session.close().catch(() => undefined);
|
|
189
|
+
signals.release();
|
|
190
|
+
process.stderr.write(`cotal chat: interrupted during admission; ${ended ? oneLine(closeSummary(session.identity(), ended)) : "the session's close was not observed"}\n`);
|
|
191
|
+
process.exitCode = during;
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
const initialRecipient = input.channel === undefined ? undefined : { kind: "channel", channel: input.channel };
|
|
195
|
+
let close;
|
|
196
|
+
try {
|
|
197
|
+
// The front end installs its signal handling before it first yields, so releasing here leaves no gap.
|
|
198
|
+
const running = start({ session, initialRecipient, notice });
|
|
199
|
+
signals.release();
|
|
200
|
+
close = await running;
|
|
201
|
+
}
|
|
202
|
+
catch (e) {
|
|
203
|
+
// A front end that threw still ends the session it was given. Closing is idempotent.
|
|
204
|
+
const held = holdSignals();
|
|
205
|
+
signals.release();
|
|
206
|
+
const ended = await session.close().catch(() => undefined);
|
|
207
|
+
held.release();
|
|
208
|
+
const confirmed = closeExitCode(ended) === 0;
|
|
209
|
+
throw new CommandFailure(confirmed ? "failed" : "unknown", confirmed ? "OPERATION_FAILED" : "OPERATION_UNKNOWN", `the chat front end stopped with an error (${e instanceof Error ? e.message : String(e)}); ${ended ? ended.message : "the session's close was not observed"}`, { target: { space: target.space, principal: session.identity().principal }, native: { detail: { close: ended ?? null } } });
|
|
210
|
+
}
|
|
211
|
+
// The terminal view leaves its screen with nothing on it; `--plain` and `--stdio` report their own end.
|
|
212
|
+
if (input.frontEnd === "tui" && close)
|
|
213
|
+
console.log(oneLine(closeSummary(session.identity(), close)));
|
|
214
|
+
// A signal the front end handled already set 129, 130 or 143.
|
|
215
|
+
process.exitCode ??= closeExitCode(close);
|
|
216
|
+
}
|
|
217
|
+
/** Complete `--space` from the registry and the channel from the target mesh's persona catalog,
|
|
218
|
+
* offline. Other values have nothing to offer. */
|
|
219
|
+
export function chatComplete(argv) {
|
|
220
|
+
const flag = completingFlagValue(argv, chatFlags);
|
|
221
|
+
if (flag?.name === "space")
|
|
222
|
+
return { items: loadMeshes().map((mesh) => ({ value: mesh.space })), directive: "nofiles" };
|
|
223
|
+
if (!flag && positionalsForCompletion(argv, chatFlags).length === 1)
|
|
224
|
+
return { items: declaredFrom(argv, listDeclaredChannels).map((value) => ({ value })), directive: "nofiles" };
|
|
225
|
+
return { items: [], directive: "nofiles" };
|
|
226
|
+
}
|
|
227
|
+
//# sourceMappingURL=chat.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chat.js","sourceRoot":"","sources":["../../src/commands/chat.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC7C,OAAO,EACL,kBAAkB,EAAE,iBAAiB,EAAE,OAAO,EAAE,mBAAmB,GACpE,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,cAAc,EAAE,oBAAoB,EAAE,SAAS,EAAE,gBAAgB,EAAE,UAAU,EAAE,SAAS,E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,KAAK,EAAE,KAAK,IAAI,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC;IAChI,CAAC;IACD,wGAAwG;IACxG,IAAI,KAAK,CAAC,QAAQ,KAAK,KAAK,IAAI,KAAK;QAAE,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,YAAY,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC;IACrG,8DAA8D;IAC9D,OAAO,CAAC,QAAQ,KAAK,aAAa,CAAC,KAAK,CAAC,CAAC;AAC5C,CAAC;AAED;mDACmD;AACnD,MAAM,UAAU,YAAY,CAAC,IAAc;IACzC,MAAM,IAAI,GAAG,mBAAmB,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;IAClD,IAAI,IAAI,EAAE,IAAI,KAAK,OAAO;QAAE,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC;IACxH,IAAI,CAAC,IAAI,IAAI,wBAAwB,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC,MAAM,KAAK,CAAC;QACjE,OAAO,EAAE,KAAK,EAAE,YAAY,CAAC,IAAI,EAAE,oBAAoB,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC;IAC/G,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC;AAC7C,CAAC"}
|
package/dist/commands/clean.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type CompletionResult, type ParsedArgs } from "@cotal-ai/core";
|
|
1
|
+
import { type AuthProvider, type CompletionResult, type ParsedArgs, type SecretStore } from "@cotal-ai/core";
|
|
2
2
|
/** `cotal clean <history|store|all>` - one configurable cleanup verb.
|
|
3
3
|
* - `history`: purge the retained message backlog on the RUNNING broker (CHAT, plus DMs with
|
|
4
4
|
* `--dms`) via the least-privilege purger cred. `cotal history clear` is a thin alias.
|
|
@@ -37,6 +37,11 @@ export declare function liveMeshProcess(root: string, space?: string): string |
|
|
|
37
37
|
* keeps "this mesh is running here, use `cotal down`" a true statement: found live against a real
|
|
38
38
|
* registry, where a dashboard watching the remote optiplex mesh made `meshes rm` refuse and point
|
|
39
39
|
* at a `cotal down` that would not have stopped that mesh at all.
|
|
40
|
+
*
|
|
41
|
+
* The controller stack this root recorded for the same space makes it the home too. `cotal up`
|
|
42
|
+
* starts that stack's members as service instances with no pidfile, and `cotal down` stops them
|
|
43
|
+
* together and drops the record. A member counts here while its process may still run. One proven
|
|
44
|
+
* gone without its stop receipt does not, and {@link unsettledStackMembers} names it.
|
|
40
45
|
*/
|
|
41
46
|
export declare function liveMeshOwner(root: string, space?: string): string | undefined;
|
|
42
47
|
/** `space` names the tenant whose pidfiles to look at. Pass it whenever the caller already knows
|
|
@@ -44,6 +49,25 @@ export declare function liveMeshOwner(root: string, space?: string): string | un
|
|
|
44
49
|
* DIFFERENT tenant on a multi-space root, and the derivation throws outright on an unreadable or
|
|
45
50
|
* ambiguous one — a caller asking a yes/no liveness question should not inherit that failure. */
|
|
46
51
|
export declare function liveMeshProcesses(root: string, space?: string): string[];
|
|
52
|
+
/** The members of the controller stack recorded at this root for `space` whose process is proven
|
|
53
|
+
* gone with no stop receipt: they can no longer run, but nothing stopped them cleanly. */
|
|
54
|
+
export declare function unsettledStackMembers(root: string, space: string): string[];
|
|
55
|
+
/** Fixed filesystem targets shared by native identity cleanup and its read-only impact plan. */
|
|
56
|
+
export declare function localIdentityCleanupTargets(root: string, space: string): {
|
|
57
|
+
material: string;
|
|
58
|
+
renewal: string;
|
|
59
|
+
legacy: string[];
|
|
60
|
+
runtime: string[];
|
|
61
|
+
run: string;
|
|
62
|
+
auth: string;
|
|
63
|
+
};
|
|
64
|
+
export interface ReviewedIdentityCleanup {
|
|
65
|
+
store: SecretStore;
|
|
66
|
+
provider: AuthProvider | null;
|
|
67
|
+
agentKeys: readonly string[];
|
|
68
|
+
beforeRemove(path: string): void;
|
|
69
|
+
afterRemove(path: string): void;
|
|
70
|
+
}
|
|
47
71
|
/** Delete the stopped mesh's local state and return what was removed (paths relative to the root).
|
|
48
72
|
* `store`: the JetStream store directory. `all` adds the space identity (`.cotal/auth`), the
|
|
49
73
|
* locally persisted creds/markers tied to it - all invalid once the identity regenerates, and
|
|
@@ -61,6 +85,24 @@ export declare function liveMeshProcesses(root: string, space?: string): string[
|
|
|
61
85
|
export declare function removeLocalState(root: string, opts: {
|
|
62
86
|
includeAuth: boolean;
|
|
63
87
|
storeDir?: string;
|
|
88
|
+
space?: string;
|
|
89
|
+
expectedStore?: {
|
|
90
|
+
path: string;
|
|
91
|
+
identity?: {
|
|
92
|
+
dev: bigint;
|
|
93
|
+
ino: bigint;
|
|
94
|
+
};
|
|
95
|
+
};
|
|
96
|
+
onRemoved?: (label: string) => void;
|
|
97
|
+
identity?: ReviewedIdentityCleanup;
|
|
64
98
|
}): Promise<string[]>;
|
|
99
|
+
/** Inspect the same pinned local store path that the existing guarded cleanup deletes. */
|
|
100
|
+
export declare function safeStoreCleanupPath(root: string, override: string | undefined): {
|
|
101
|
+
path: string;
|
|
102
|
+
identity?: {
|
|
103
|
+
dev: bigint;
|
|
104
|
+
ino: bigint;
|
|
105
|
+
};
|
|
106
|
+
};
|
|
65
107
|
export declare function cleanComplete(argv: string[]): CompletionResult;
|
|
66
108
|
//# sourceMappingURL=clean.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clean.d.ts","sourceRoot":"","sources":["../../src/commands/clean.ts"],"names":[],"mappings":"AAGA,OAAO,
|
|
1
|
+
{"version":3,"file":"clean.d.ts","sourceRoot":"","sources":["../../src/commands/clean.ts"],"names":[],"mappings":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,GAAG,IAAI,CAAC;IACjC,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;CACjC;AAED;;;;;;;;;;;;;oDAaoD;AACpD,wBAAsB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE;IAAE,WAAW,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,aAAa,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE;YAAE,GAAG,EAAE,MAAM,CAAC;YAAC,GAAG,EAAE,MAAM,CAAA;SAAE,CAAA;KAAE,CAAC;IAAC,SAAS,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAAC,QAAQ,CAAC,EAAE,uBAAuB,CAAA;CAAE,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CA4I7R;AAQD,0FAA0F;AAC1F,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,SAAS,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE,CAAA;CAAE,CAsB1I;AAaD,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,gBAAgB,CAG9D"}
|
package/dist/commands/clean.js
CHANGED
|
@@ -2,12 +2,15 @@ import { randomUUID } from "node:crypto";
|
|
|
2
2
|
import { existsSync, lstatSync, readdirSync, realpathSync, renameSync, rmSync } from "node:fs";
|
|
3
3
|
import { dirname, isAbsolute, join, parse, relative, resolve } from "node:path";
|
|
4
4
|
import { clearSpaceHistory, isReachable, registry, resolveAuthProvider } from "@cotal-ai/core";
|
|
5
|
-
import { DELIVERY_CREDS_KIND, MEMBERSHIP_CONFIG_KIND, MEMBERSHIP_RW_CREDS_KIND, segmentedKey, spaceMaterialDir, spaceSegment, acquireMaintenanceLock, agentSecretKeysUnder, assertSingleSpaceBroker, authDir, cleanupRestoreFallback, deleteSpaceAuth, localProcessPath, localMeshesForRoot, readMaintenanceJournal, releaseMaintenanceLock, renewalRecordPath, removeMeshesByRoot, resolveRuntimeSpace, resolveSpace,
|
|
5
|
+
import { CommandFailure, DELIVERY_CREDS_KIND, MEMBERSHIP_CONFIG_KIND, MEMBERSHIP_RW_CREDS_KIND, segmentedKey, spaceMaterialDir, spaceSegment, acquireMaintenanceLock, agentSecretKeysUnder, assertSingleSpaceBroker, authDir, cleanupRestoreFallback, deleteSpaceAuth, localProcessPath, localMeshesForRoot, readMaintenanceJournal, releaseMaintenanceLock, renewalRecordPath, removeMeshesByRoot, resolveRuntimeSpace, resolveSpace, SYSTEM_CREDS_FILES, workspaceSecretStore, } from "@cotal-ai/workspace";
|
|
6
6
|
import { connectOrExit, userViewAuthOrExit } from "../lib/connect.js";
|
|
7
7
|
import { c } from "../ui.js";
|
|
8
8
|
import { cotalRoot } from "../lib/paths.js";
|
|
9
9
|
import { pidfileState, pidfileTargets } from "./down.js";
|
|
10
10
|
import { localProcessSurface } from "../ext-loader.js";
|
|
11
|
+
import { readStackJournal, STACK_DEFINITION } from "../lib/stack-journal.js";
|
|
12
|
+
import { rollbackRestoreWithBroker } from "../lib/controller-restore.js";
|
|
13
|
+
import { observeServiceProcess, serviceInstances } from "../lib/service-instances.js";
|
|
11
14
|
const TARGETS = ["history", "store", "all", "restore-fallback", "restore-attempt"];
|
|
12
15
|
/** `cotal clean <history|store|all>` - one configurable cleanup verb.
|
|
13
16
|
* - `history`: purge the retained message backlog on the RUNNING broker (CHAT, plus DMs with
|
|
@@ -24,12 +27,9 @@ export async function clean(args) {
|
|
|
24
27
|
const target = args.positionals[0];
|
|
25
28
|
const values = args.values;
|
|
26
29
|
if (!target || !TARGETS.includes(target))
|
|
27
|
-
|
|
28
|
-
if (!values.force)
|
|
29
|
-
|
|
30
|
-
console.error(c.dim(`usage: ${USAGE}`));
|
|
31
|
-
process.exit(1);
|
|
32
|
-
}
|
|
30
|
+
throw new CommandFailure("refused", "USAGE_INVALID", target ? `clean has no target "${target}"; it takes ${TARGETS.join(", ")}` : `clean needs a target: ${TARGETS.join(", ")}`);
|
|
31
|
+
if (!values.force)
|
|
32
|
+
throw new CommandFailure("refused", "USAGE_INVALID", `clean ${target} deletes without prompting, so it requires --force`, { remedy: `cotal clean ${target} --force` });
|
|
33
33
|
if (target === "history")
|
|
34
34
|
return purgeHistory(values);
|
|
35
35
|
// Everything below acts on the SHARED broker, never one space: `store`/`all` delete the single
|
|
@@ -50,7 +50,7 @@ export async function clean(args) {
|
|
|
50
50
|
const journal = readMaintenanceJournal(root);
|
|
51
51
|
if (!journal || journal.state !== "restore-ready" || journal.restore.attemptId !== values.attempt)
|
|
52
52
|
throw new Error(`no pre-commit restore attempt ${values.attempt} is recorded${journal ? ` (maintenance state is ${journal.state}${"restore" in journal ? ` for attempt ${journal.restore.attemptId}` : ""})` : ""}`);
|
|
53
|
-
|
|
53
|
+
rollbackRestoreWithBroker(lock);
|
|
54
54
|
console.log(c.green(`✓ rolled back stale restore attempt ${values.attempt}`));
|
|
55
55
|
console.log(c.dim(" the preserved source is back at ready; resume with `cotal up` or retry `cotal up --restore`"));
|
|
56
56
|
}
|
|
@@ -145,6 +145,11 @@ export function liveMeshProcess(root, space) {
|
|
|
145
145
|
* keeps "this mesh is running here, use `cotal down`" a true statement: found live against a real
|
|
146
146
|
* registry, where a dashboard watching the remote optiplex mesh made `meshes rm` refuse and point
|
|
147
147
|
* at a `cotal down` that would not have stopped that mesh at all.
|
|
148
|
+
*
|
|
149
|
+
* The controller stack this root recorded for the same space makes it the home too. `cotal up`
|
|
150
|
+
* starts that stack's members as service instances with no pidfile, and `cotal down` stops them
|
|
151
|
+
* together and drops the record. A member counts here while its process may still run. One proven
|
|
152
|
+
* gone without its stop receipt does not, and {@link unsettledStackMembers} names it.
|
|
148
153
|
*/
|
|
149
154
|
export function liveMeshOwner(root, space) {
|
|
150
155
|
const context = { root, space: space ?? resolveRuntimeSpace(root) };
|
|
@@ -155,7 +160,7 @@ export function liveMeshOwner(root, space) {
|
|
|
155
160
|
if (running)
|
|
156
161
|
return running;
|
|
157
162
|
}
|
|
158
|
-
return
|
|
163
|
+
return liveStackMembers(root, context.space, false)[0];
|
|
159
164
|
}
|
|
160
165
|
/** `space` names the tenant whose pidfiles to look at. Pass it whenever the caller already knows
|
|
161
166
|
* which mesh it means (a registry entry does): re-deriving it from the root can resolve a
|
|
@@ -169,7 +174,36 @@ export function liveMeshProcesses(root, space) {
|
|
|
169
174
|
if (record)
|
|
170
175
|
running.push(record);
|
|
171
176
|
}
|
|
172
|
-
return running;
|
|
177
|
+
return [...running, ...liveStackMembers(root)];
|
|
178
|
+
}
|
|
179
|
+
/** The members of the controller stack recorded at this root that may still run. A member counts as
|
|
180
|
+
* live unless its process is gone and its record carries the stop receipt its role requires.
|
|
181
|
+
* Backup, reset store and reset space share this rule. With `unreceipted` false, a member whose
|
|
182
|
+
* process is proven gone does not count even without its receipt, as `space forget` asks. */
|
|
183
|
+
function liveStackMembers(root, space, unreceipted = true) {
|
|
184
|
+
return stackMembers(root, space).filter((row) => !row.gone || unreceipted && !row.receipted).map((row) => `${row.label}${row.gone ? ", no stop receipt" : ""}`);
|
|
185
|
+
}
|
|
186
|
+
/** The members of the controller stack recorded at this root for `space` whose process is proven
|
|
187
|
+
* gone with no stop receipt: they can no longer run, but nothing stopped them cleanly. */
|
|
188
|
+
export function unsettledStackMembers(root, space) {
|
|
189
|
+
return stackMembers(root, space).filter((row) => row.gone && !row.receipted).map((row) => row.label);
|
|
190
|
+
}
|
|
191
|
+
/** Each instance record of the controller stack recorded at this root. The members live under the
|
|
192
|
+
* stack's own recorded space. A space derived from the root's pidfiles or accounts can name another
|
|
193
|
+
* tenant, or the default, once the stack is stopped. `space` limits the answer to that space's
|
|
194
|
+
* stack. */
|
|
195
|
+
function stackMembers(root, space) {
|
|
196
|
+
const stack = readStackJournal(root);
|
|
197
|
+
if (!stack || space !== undefined && stack.journal.space !== space)
|
|
198
|
+
return [];
|
|
199
|
+
return Object.values(STACK_DEFINITION).flatMap((definition) => serviceInstances(stack.journal.space, definition).map((row) => {
|
|
200
|
+
const value = row.record.value;
|
|
201
|
+
return {
|
|
202
|
+
label: `${definition}, instance ${row.name}`,
|
|
203
|
+
gone: ["gone", "previous-boot"].includes(observeServiceProcess(value)),
|
|
204
|
+
receipted: value.state === "stopped" && Boolean(value.nativeStop ?? value.kernelStop ?? value.processStop),
|
|
205
|
+
};
|
|
206
|
+
}));
|
|
173
207
|
}
|
|
174
208
|
/** "label, pid N" for a record that may still front a process, with the probe's note when it is not
|
|
175
209
|
* proven alive; undefined only for no record, an empty husk or a pid proven dead. Every caller
|
|
@@ -181,6 +215,16 @@ function possiblyRunning(component, context) {
|
|
|
181
215
|
return undefined;
|
|
182
216
|
return `${component.label}, ${[state.pid && `pid ${state.pid}`, state.note].filter(Boolean).join(", ")}`;
|
|
183
217
|
}
|
|
218
|
+
/** Fixed filesystem targets shared by native identity cleanup and its read-only impact plan. */
|
|
219
|
+
export function localIdentityCleanupTargets(root, space) {
|
|
220
|
+
const control = join(root, ".cotal");
|
|
221
|
+
return {
|
|
222
|
+
material: spaceMaterialDir(root, space), renewal: renewalRecordPath(root, space),
|
|
223
|
+
legacy: [...SYSTEM_CREDS_FILES, MEMBERSHIP_CONFIG_KIND, "renewal.json"].map((name) => join(control, name)),
|
|
224
|
+
runtime: pidfileTargets(space, root).flatMap(([path]) => [path, `${path}.identity`]),
|
|
225
|
+
run: join(control, "run"), auth: authDir(root),
|
|
226
|
+
};
|
|
227
|
+
}
|
|
184
228
|
/** Delete the stopped mesh's local state and return what was removed (paths relative to the root).
|
|
185
229
|
* `store`: the JetStream store directory. `all` adds the space identity (`.cotal/auth`), the
|
|
186
230
|
* locally persisted creds/markers tied to it - all invalid once the identity regenerates, and
|
|
@@ -197,23 +241,31 @@ function possiblyRunning(component, context) {
|
|
|
197
241
|
* provider hook, never a KMS mode on this CLI). */
|
|
198
242
|
export async function removeLocalState(root, opts) {
|
|
199
243
|
const removed = [];
|
|
244
|
+
const recordRemoved = (label) => { removed.push(label); opts.onRemoved?.(label); };
|
|
200
245
|
const rm = (path, label) => {
|
|
246
|
+
opts.identity?.beforeRemove(path);
|
|
201
247
|
if (!existsSync(path))
|
|
202
248
|
return;
|
|
203
249
|
rmSync(path, { recursive: true, force: true });
|
|
204
|
-
|
|
250
|
+
opts.identity?.afterRemove(path);
|
|
251
|
+
recordRemoved(label);
|
|
205
252
|
};
|
|
206
|
-
//
|
|
207
|
-
//
|
|
208
|
-
|
|
253
|
+
// Trust removal always derives its space from the root's local authority. A named
|
|
254
|
+
// store-only reset may supply the recorded open space, which has no auth record.
|
|
255
|
+
if (opts.includeAuth && opts.space !== undefined)
|
|
256
|
+
throw new Error("identity cleanup cannot take a caller-selected space");
|
|
257
|
+
const space = opts.space ?? resolveSpace(root);
|
|
209
258
|
const store = safeStoreCleanupPath(root, opts.storeDir);
|
|
259
|
+
if (opts.expectedStore && (store.path !== opts.expectedStore.path || Boolean(store.identity) !== Boolean(opts.expectedStore.identity) || store.identity && (store.identity.dev !== opts.expectedStore.identity?.dev || store.identity.ino !== opts.expectedStore.identity?.ino)))
|
|
260
|
+
throw new Error("store path or pinned filesystem identity changed before cleanup; no directory was removed");
|
|
210
261
|
if (store.identity) {
|
|
211
262
|
removePinnedStoreDirectory(store.path, store.identity);
|
|
212
|
-
|
|
263
|
+
recordRemoved(opts.storeDir ? store.path : ".cotal/nats (JetStream store)");
|
|
213
264
|
}
|
|
214
265
|
if (opts.includeAuth) {
|
|
266
|
+
const targets = localIdentityCleanupTargets(root, space);
|
|
215
267
|
// ---- the seam deletes, before ANY raw identity removal (see the doc above) ----
|
|
216
|
-
const secrets = workspaceSecretStore(root);
|
|
268
|
+
const secrets = opts.identity?.store ?? workspaceSecretStore(root);
|
|
217
269
|
const failures = [];
|
|
218
270
|
// Both kinds are PER-SPACE as of P7 (§3.1's `(space) => key` shape), and both are swept at BOTH
|
|
219
271
|
// spellings: the segmented key this space writes today, and the flat pre-P7 key, which a root
|
|
@@ -229,7 +281,7 @@ export async function removeLocalState(root, opts) {
|
|
|
229
281
|
try {
|
|
230
282
|
if ((await secrets.get(key)) !== undefined) {
|
|
231
283
|
await secrets.delete(key);
|
|
232
|
-
|
|
284
|
+
recordRemoved(`.cotal/${key}`);
|
|
233
285
|
}
|
|
234
286
|
}
|
|
235
287
|
catch (e) {
|
|
@@ -249,10 +301,10 @@ export async function removeLocalState(root, opts) {
|
|
|
249
301
|
// sweep above is (never move material into the path you are about to delete), which is why it
|
|
250
302
|
// reports both the segmented keys and the flat pre-P1 level rather than resolving through
|
|
251
303
|
// `agentCredsDir`.
|
|
252
|
-
for (const key of agentSecretKeysUnder(root)) {
|
|
304
|
+
for (const key of opts.identity?.agentKeys ?? agentSecretKeysUnder(root)) {
|
|
253
305
|
try {
|
|
254
306
|
await secrets.delete(key);
|
|
255
|
-
|
|
307
|
+
recordRemoved(`.cotal/${key}`);
|
|
256
308
|
}
|
|
257
309
|
catch (e) {
|
|
258
310
|
failures.push(`${key}: ${e instanceof Error ? e.message : String(e)}`);
|
|
@@ -261,9 +313,10 @@ export async function removeLocalState(root, opts) {
|
|
|
261
313
|
// Gate on registration: an open-mode composition may not register an auth provider, and a
|
|
262
314
|
// reset there must not start failing. With one registered, its deprovision must SUCCEED
|
|
263
315
|
// (absent keys are idempotent no-ops) before the identity goes.
|
|
264
|
-
|
|
316
|
+
const provider = opts.identity ? opts.identity.provider : registry.all("auth-provider").length ? resolveAuthProvider() : null;
|
|
317
|
+
if (provider) {
|
|
265
318
|
try {
|
|
266
|
-
await
|
|
319
|
+
await provider.deprovisionSecrets({ store: secrets, space });
|
|
267
320
|
}
|
|
268
321
|
catch (e) {
|
|
269
322
|
failures.push(e instanceof Error ? e.message : String(e));
|
|
@@ -286,30 +339,26 @@ export async function removeLocalState(root, opts) {
|
|
|
286
339
|
// went through the store above; the seam deletes are authoritative and their failure already
|
|
287
340
|
// threw, so by here the dir holds only what a raw rm owns. On a multi-space root this removes
|
|
288
341
|
// ONLY this space's segment — the other tenants' material is not this reset's to touch.
|
|
289
|
-
rm(
|
|
342
|
+
rm(targets.material, `.cotal/${spaceSegment(space)} (this space's material)`);
|
|
290
343
|
// This space's renewal record is per-space (#1850), removed with the rest of its material. The
|
|
291
344
|
// LEGACY root-scoped `renewal.json` below stays in the list too: a pre-per-space build's copy
|
|
292
345
|
// must not survive a full local reset either.
|
|
293
|
-
rm(
|
|
294
|
-
for (const
|
|
346
|
+
rm(targets.renewal, `${relative(root, targets.renewal)} (renewal record)`);
|
|
347
|
+
for (const path of targets.legacy) {
|
|
295
348
|
// The LEGACY FLAT copies of the raw P7 kinds: still present on a root no post-P7 `up` has
|
|
296
349
|
// touched, and this surface must not leave old-operator $SYS material behind because the
|
|
297
350
|
// migration had not run yet. The $SYS pair comes from its ONE named source, shared with the
|
|
298
351
|
// rotation writer, so a file added to that class can never be minted-but-not-swept.
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
"renewal.json",
|
|
302
|
-
])
|
|
303
|
-
rm(join(root, ".cotal", f), `.cotal/${f}`);
|
|
352
|
+
rm(path, relative(root, path));
|
|
353
|
+
}
|
|
304
354
|
// Crash residue: after a clean `down` none of this exists; after a crash the dead pidfiles and
|
|
305
355
|
// transient launch artifacts are exactly the leftovers a "full local reset" must not keep.
|
|
306
356
|
// Absolute paths, every spelling: the runtime records are `{space}` templates now, and the
|
|
307
357
|
// delivery-aware marker rides along with them (it was a literal in the list above).
|
|
308
|
-
for (const
|
|
309
|
-
rm(path, `${relative(root, path)} (stale runtime record)`);
|
|
310
|
-
rm(`${path}.identity`, `${relative(root, path)}.identity (stale identity pin)`); // #969 sibling of the record
|
|
358
|
+
for (const path of targets.runtime) {
|
|
359
|
+
rm(path, `${relative(root, path)} (${path.endsWith(".identity") ? "stale identity pin" : "stale runtime record"})`);
|
|
311
360
|
}
|
|
312
|
-
rm(
|
|
361
|
+
rm(targets.run, ".cotal/run (launch artifacts)");
|
|
313
362
|
// The auth dir's NON-namer contents (callout, creds, server.conf, the user-auth state dir, any
|
|
314
363
|
// stray) are removed BEFORE the trust records — a locked/immutable stray UNDER `.cotal/auth`
|
|
315
364
|
// throws HERE, while the namer is still present, so a re-run still resolves THIS space. Removing
|
|
@@ -317,7 +366,7 @@ export async function removeLocalState(root, opts) {
|
|
|
317
366
|
// a stray survived after the namer had already gone. The protected set is exactly what
|
|
318
367
|
// `deleteSpaceAuth` owns: the account record (the space NAMER `resolveSpace` reads), the broker
|
|
319
368
|
// record, and the legacy monolith.
|
|
320
|
-
const authDirPath =
|
|
369
|
+
const authDirPath = targets.auth;
|
|
321
370
|
const trustRecord = (entry) => entry === "auth.json" || entry === "broker.json" || (entry.startsWith("account.") && entry.endsWith(".json"));
|
|
322
371
|
if (existsSync(authDirPath))
|
|
323
372
|
for (const entry of readdirSync(authDirPath))
|
|
@@ -326,12 +375,13 @@ export async function removeLocalState(root, opts) {
|
|
|
326
375
|
// The trust records — the space-NAMER last among them — die ABSOLUTELY LAST, as a single
|
|
327
376
|
// authoritative op: the store delete is real for a non-FS store, and on the FS composition it
|
|
328
377
|
// removes the same files.
|
|
329
|
-
|
|
330
|
-
for (const entry of readdirSync(authDirPath))
|
|
331
|
-
if (trustRecord(entry))
|
|
332
|
-
removed.push(`.cotal/auth/${entry} (space trust)`);
|
|
378
|
+
const trustPaths = existsSync(authDirPath) ? readdirSync(authDirPath).filter(trustRecord) : [];
|
|
333
379
|
await deleteSpaceAuth(secrets, space);
|
|
380
|
+
for (const entry of trustPaths)
|
|
381
|
+
recordRemoved(`.cotal/auth/${entry} (space trust)`);
|
|
382
|
+
opts.identity?.beforeRemove(authDirPath);
|
|
334
383
|
rmSync(authDirPath, { recursive: true, force: true }); // drop the now-empty auth dir (nothing lockable left)
|
|
384
|
+
opts.identity?.afterRemove(authDirPath);
|
|
335
385
|
}
|
|
336
386
|
return removed;
|
|
337
387
|
}
|
|
@@ -340,7 +390,8 @@ function pathContains(parent, child) {
|
|
|
340
390
|
const separator = process.platform === "win32" ? "\\" : "/";
|
|
341
391
|
return path === "" || (path !== ".." && !path.startsWith(`..${separator}`) && !isAbsolute(path));
|
|
342
392
|
}
|
|
343
|
-
|
|
393
|
+
/** Inspect the same pinned local store path that the existing guarded cleanup deletes. */
|
|
394
|
+
export function safeStoreCleanupPath(root, override) {
|
|
344
395
|
const requested = resolve(override ?? join(root, ".cotal", "nats"));
|
|
345
396
|
if (!existsSync(requested))
|
|
346
397
|
return { path: requested };
|
|
@@ -376,14 +427,6 @@ function removePinnedStoreDirectory(path, identity) {
|
|
|
376
427
|
}
|
|
377
428
|
rmSync(tomb, { recursive: true });
|
|
378
429
|
}
|
|
379
|
-
const USAGE = "cotal clean <history|store|all> --force [--dms] [--space <s>] [--server <url>] [--creds <path>] [--store-dir <dir>] | cotal clean <restore-attempt|restore-fallback> --attempt <id> --force";
|
|
380
|
-
function usage() {
|
|
381
|
-
console.error(c.red(`usage: ${USAGE}`));
|
|
382
|
-
console.error(c.dim(" history purge the message backlog on the running broker (--dms to include DMs)"));
|
|
383
|
-
console.error(c.dim(" store delete the stopped mesh's JetStream store (.cotal/nats)"));
|
|
384
|
-
console.error(c.dim(" all store + the space identity (.cotal/auth) - full local reset"));
|
|
385
|
-
process.exit(1);
|
|
386
|
-
}
|
|
387
430
|
export function cleanComplete(argv) {
|
|
388
431
|
if (argv.length <= 1)
|
|
389
432
|
return { items: TARGETS.map((value) => ({ value })), directive: "nofiles" };
|