@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
package/dist/commands/agents.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import { dialerFor, mintCreds, newIdentity, openSessionRail, peerLabel, standaloneConnectOpts } from "@cotal-ai/core";
|
|
2
|
-
import { ConnectRefusal, divergentCwdAnchor, isWorkspaceTargetError, loadMeshes, renderWorkspaceError, targetFlags, userSessionAuth } from "@cotal-ai/workspace";
|
|
1
|
+
import { DEV_OWNER, assertLifecycleToken, dialerFor, mintCreds, newIdentity, openSessionRail, peerLabel, standaloneConnectOpts } from "@cotal-ai/core";
|
|
2
|
+
import { CommandFailure, ConnectRefusal, divergentCwdAnchor, isWorkspaceTargetError, jsonFlag, loadMeshes, oneLine, renderReport, terminalWidth, plainFlag, presentationOf, resolveSeatControlTarget, renderWorkspaceError, targetFlags, userSessionAuth, writeResult, recordOperationSpace, } from "@cotal-ai/workspace";
|
|
3
|
+
import * as prompts from "../lib/prompts.js";
|
|
4
|
+
import { canPrompt } from "./meshes-wizard.js";
|
|
3
5
|
import {} from "@nats-io/transport-node";
|
|
4
|
-
import { c,
|
|
5
|
-
import { askManager, scatterManager, failIfNotOk, resolveControlTarget, onInstanceOrExit, onFlag } from "../lib/control.js";
|
|
6
|
+
import { c, presenceFacts } from "../ui.js";
|
|
7
|
+
import { askManager, scatterManager, failIfNotOk, managerFailure, readFailure, resolveControlTarget, onInstance, onInstanceOrExit, onFlag } from "../lib/control.js";
|
|
6
8
|
import { attachClient, detachKey, holdTerminal, isDetachPress, isTransportEnd, meshSessionTransport } from "../lib/attach-client.js";
|
|
7
9
|
import { completingFlagValue } from "../lib/completion.js";
|
|
8
10
|
/**
|
|
@@ -16,15 +18,17 @@ const nameFlag = (what) => ({ name: "name", type: "string", value: "<n>", descri
|
|
|
16
18
|
// seat); `--json` is the machine form (one JSON object per line, exactly the row the manager
|
|
17
19
|
// sent). Mutually exclusive because they are two answers to "how should I read this".
|
|
18
20
|
const wideFlag = { name: "wide", type: "boolean", description: "also print the per-seat facts the manager already records: cwd, pid, spawner, lifecycle uid, host/instance" };
|
|
19
|
-
const
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
const slotsFlag = { name: "slots", type: "boolean", description: "list the durable static slots instead of live seats; not with --wide" };
|
|
22
|
+
export const stopFlags = [...targetFlags, nameFlag("agent name; you can name it positionally"),
|
|
23
|
+
{ name: "self", type: "boolean", description: "stop only the verified managed seat running this command" },
|
|
24
|
+
{ name: "force", type: "boolean", description: "request native hard despawn (graceful:false); does not bypass authority" },
|
|
25
|
+
onFlag, jsonFlag, plainFlag];
|
|
26
|
+
export const psFlags = [...targetFlags, onFlag, wideFlag, jsonFlag, plainFlag, slotsFlag];
|
|
23
27
|
/** `--no-reconnect`: one session, exit when it ends, whatever ended it. The default reconnects,
|
|
24
28
|
* which is right for a person at a terminal and wrong for a script that wants a single run with a
|
|
25
29
|
* single exit code. */
|
|
26
30
|
const noReconnectFlag = { name: "no-reconnect", type: "boolean", description: "exit when the session ends instead of re-establishing it" };
|
|
27
|
-
export const attachFlags = [...targetFlags, nameFlag("
|
|
31
|
+
export const attachFlags = [...targetFlags, nameFlag("agent name; you can name it positionally"), onFlag, noReconnectFlag];
|
|
28
32
|
/** `cotal input`: type into a seat without holding a terminal open. `--text` is a VALUE flag, so
|
|
29
33
|
* its argument is taken verbatim and may begin with `/` or `-` (`--text "/compact"`) - which is
|
|
30
34
|
* the point: a harness command is exactly the payload that would be eaten by a positional
|
|
@@ -36,7 +40,7 @@ export const inputFlags = [
|
|
|
36
40
|
nameFlag("managed agent to type into (required)"),
|
|
37
41
|
{ name: "text", type: "string", value: "<text>", description: "the text to type, verbatim (required); quote it when it starts with / or -" },
|
|
38
42
|
{ name: "no-enter", type: "boolean", description: "type the text without pressing Enter after it" },
|
|
39
|
-
onFlag,
|
|
43
|
+
onFlag, jsonFlag, plainFlag,
|
|
40
44
|
];
|
|
41
45
|
export function managedAgentComplete(argv) {
|
|
42
46
|
const flag = completingFlagValue(argv, attachFlags);
|
|
@@ -50,30 +54,114 @@ export function managedAgentComplete(argv) {
|
|
|
50
54
|
return { items: attachFlags.map((f) => ({ value: `--${f.name}`, description: f.description })), directive: "nofiles" };
|
|
51
55
|
return { items: [], directive: "nofiles" };
|
|
52
56
|
}
|
|
57
|
+
/** The named target grammar, checked before any command preparation. */
|
|
58
|
+
export function managedTarget(args, operation, allowPicker = false) {
|
|
59
|
+
const named = typeof args.values.name === "string" ? args.values.name : undefined;
|
|
60
|
+
if (args.positionals.length > 1 || (args.positionals.length && named !== undefined))
|
|
61
|
+
throw new CommandFailure("refused", "USAGE_INVALID", `choose one agent: cotal ${operation} <name>`);
|
|
62
|
+
const name = args.positionals[0] ?? named;
|
|
63
|
+
if (typeof args.values.on === "string")
|
|
64
|
+
onInstance(args.values.on, `cotal ${operation}`);
|
|
65
|
+
if (name === undefined && operation === "attach" && allowPicker) {
|
|
66
|
+
if (!canPrompt())
|
|
67
|
+
throw new CommandFailure("refused", "USAGE_INVALID", "name the agent to attach without an interactive terminal", { remedy: "run cotal ps, then cotal attach <name>" });
|
|
68
|
+
return undefined;
|
|
69
|
+
}
|
|
70
|
+
if (name !== undefined && /[\u0000-\u001f\u007f]/u.test(name))
|
|
71
|
+
throw new CommandFailure("refused", "USAGE_INVALID", "the agent name contains terminal control characters");
|
|
72
|
+
if (!name?.trim())
|
|
73
|
+
throw new CommandFailure("refused", "USAGE_INVALID", `name the agent to ${operation}`, { remedy: "run cotal ps, then cotal " + operation + " <name>" });
|
|
74
|
+
return name;
|
|
75
|
+
}
|
|
76
|
+
export function validateStopArguments(args) {
|
|
77
|
+
presentationOf(args.values);
|
|
78
|
+
if (args.values.self) {
|
|
79
|
+
if (args.positionals.length || args.values.name !== undefined || args.values.creds !== undefined)
|
|
80
|
+
throw new CommandFailure("refused", "USAGE_INVALID", "stop --self takes no other agent or caller credential");
|
|
81
|
+
if (args.values.on !== undefined) {
|
|
82
|
+
const pin = onInstance(String(args.values.on), "cotal stop --self");
|
|
83
|
+
if (pin !== process.env.COTAL_MANAGER_INSTANCE)
|
|
84
|
+
throw new CommandFailure("refused", "CONFLICT", "stop --self cannot select a different manager than the seat's launcher");
|
|
85
|
+
}
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
managedTarget(args, "stop");
|
|
89
|
+
}
|
|
53
90
|
export async function stop(args) {
|
|
91
|
+
validateStopArguments(args);
|
|
54
92
|
const v = args.values;
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
93
|
+
let on;
|
|
94
|
+
let t;
|
|
95
|
+
let name;
|
|
96
|
+
if (v.self) {
|
|
97
|
+
const space = v.space ?? process.env.COTAL_SPACE;
|
|
98
|
+
const manager = process.env.COTAL_MANAGER_INSTANCE;
|
|
99
|
+
if (!space || !manager)
|
|
100
|
+
throw new CommandFailure("refused", "UNSUPPORTED", "stop --self requires a managed seat's own shell, space and launcher attribution");
|
|
101
|
+
on = onInstance(manager, "cotal stop --self");
|
|
102
|
+
let seat;
|
|
103
|
+
try {
|
|
104
|
+
seat = await resolveSeatControlTarget({ space, server: v.server }, on);
|
|
105
|
+
}
|
|
106
|
+
catch {
|
|
107
|
+
throw new CommandFailure("refused", "AUTH_REQUIRED", "the seat's own caller could not be verified; no operator identity was substituted");
|
|
108
|
+
}
|
|
109
|
+
if (!seat)
|
|
110
|
+
throw new CommandFailure("refused", "UNSUPPORTED", "this caller cannot stop itself through the CLI; missing or mismatched seat context and user-auth self impersonation never fall back to the operator");
|
|
111
|
+
t = seat;
|
|
58
112
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
const
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
113
|
+
else {
|
|
114
|
+
name = managedTarget(args, "stop");
|
|
115
|
+
on = await pinForTarget({ ...v, name }, "cotal stop");
|
|
116
|
+
t = await resolveControlTarget(v, "control-caller-admin", on);
|
|
117
|
+
}
|
|
118
|
+
recordOperationSpace(t.space);
|
|
119
|
+
const reply = await askManager(t.space, t.server, v.self ? "stopSelf" : "stop", { ...(name ? { name } : {}), graceful: v.force !== true }, t.auth, t.auth.bearer ? "owner" : "any", undefined, { instanceId: on });
|
|
120
|
+
const target = { space: t.space, managerInstanceId: reply.managerInstanceId ?? on ?? null, selection: v.self ? "verified-self" : "named", ...(name ? { agent: name } : {}) };
|
|
121
|
+
if (!reply.ok)
|
|
122
|
+
throw managerFailure(reply, "agent stop", target);
|
|
123
|
+
const data = reply.data;
|
|
124
|
+
if (!data || typeof data.name !== "string" || typeof data.stopped !== "boolean" || typeof data.graceful !== "boolean")
|
|
125
|
+
throw new CommandFailure("unknown", "OPERATION_UNKNOWN", "the manager answered, but the stop receipt could not be read; the request was not repeated", { target, ...(reply.request ? { native: { detail: { request: reply.request } } } : {}) });
|
|
126
|
+
if (!data.stopped)
|
|
127
|
+
throw new CommandFailure("failed", "OPERATION_FAILED", "the manager reported that it did not stop the selected agent", { target });
|
|
128
|
+
const result = { kind: "agent-stop", name: data.name, stopped: data.stopped, graceful: data.graceful, request: reply.request ?? null, grantRevocation: t.auth.bearer ? "native user-mode stop policy" : "not asserted" };
|
|
129
|
+
writeResult(presentationOf(v), { command: "stop", target, result }, (row) => ({ sections: [
|
|
130
|
+
{ title: "Agent stop acknowledged", blocks: [{ kind: "fields", rows: [["Agent", row.name], ["Space", t.space], ["Manager", reply.managerInstanceId ?? "not attributed"], ["Native mode", row.graceful ? "graceful" : "hard despawn"], ["Selection", v.self ? "this verified seat only" : "named agent's resolved incarnation"]] }, { kind: "lines", lines: [{ text: "This is the manager's stop result, not an independent process-exit measurement. No other agent was selected and no replacement was launched.", tone: "hint" }] }] },
|
|
131
|
+
] }));
|
|
132
|
+
}
|
|
133
|
+
/** The named status contract separates process, presence and work observations. A missing
|
|
134
|
+
* manager field is null, never inferred from a process handle or an old heartbeat. */
|
|
135
|
+
function agentStatusProjection(row, managerInstanceId) {
|
|
136
|
+
const principal = row.id.split(".");
|
|
137
|
+
const owner = principal.length === 1 ? DEV_OWNER : principal.length === 2 && principal[0] ? principal[0] : null;
|
|
138
|
+
const actor = principal.length === 1 ? principal[0] || null : principal.length === 2 && principal[1] ? principal[1] : null;
|
|
139
|
+
const viewCurrent = row.meshView === undefined || row.meshView === "current";
|
|
140
|
+
const exactPresence = viewCurrent && row.presenceIdentityVerified === true;
|
|
141
|
+
const reportedAt = typeof row.activeAt === "number" && Number.isFinite(row.activeAt) && Math.abs(row.activeAt) <= 8.64e15
|
|
142
|
+
? new Date(row.activeAt).toISOString() : null;
|
|
143
|
+
const observedAt = exactPresence && typeof row.presenceObservedAt === "number" && Number.isSafeInteger(row.presenceObservedAt) && row.presenceObservedAt >= 0 && row.presenceObservedAt <= 8.64e15
|
|
144
|
+
? new Date(row.presenceObservedAt).toISOString() : null;
|
|
145
|
+
const since = row.condition?.since;
|
|
146
|
+
const conditionSince = typeof since === "number" && Number.isSafeInteger(since) && since >= 0 && since <= 8.64e15
|
|
147
|
+
? new Date(since).toISOString() : null;
|
|
148
|
+
return {
|
|
149
|
+
identity: { name: row.name, owner, actor, lifecycleUid: row.lifecycleUid || null, source: "manager-ps" },
|
|
150
|
+
execution: { managerInstanceId, host: row.host ?? null, harness: row.agent, model: row.model ?? null,
|
|
151
|
+
runtime: row.mode, pid: typeof row.pid === "number" && Number.isSafeInteger(row.pid) && row.pid > 0 ? row.pid : null, processState: row.status, source: "manager-ps" },
|
|
152
|
+
mesh: { presenceState: exactPresence ? row.mesh : null, observedAt, nameMatchedState: !exactPresence && viewCurrent && row.mesh !== "absent" ? row.mesh : null,
|
|
153
|
+
source: exactPresence ? "manager-ps-exact-principal-lifecycle-current-view" : "manager-ps-name-match-not-incarnation-verified" },
|
|
154
|
+
activity: { state: exactPresence && ["idle", "working", "waiting"].includes(row.mesh) ? row.mesh : null,
|
|
155
|
+
text: null, reportedAt: exactPresence ? reportedAt : null, nameMatchedWorkEventAt: exactPresence ? null : reportedAt,
|
|
156
|
+
condition: exactPresence ? row.condition ?? null : null, conditionSince: exactPresence ? conditionSince : null,
|
|
157
|
+
nameMatchedCondition: exactPresence ? null : row.condition ?? null,
|
|
158
|
+
source: exactPresence ? "manager-ps-exact-principal-lifecycle-current-view" : "manager-ps-name-match-not-incarnation-verified" },
|
|
159
|
+
details: { role: row.role ?? null, variant: row.variant ?? null, provider: row.provider ?? null,
|
|
160
|
+
providerSource: row.provider ? exactPresence ? "exact-principal-lifecycle" : "name-match-unverified" : null, cwd: row.cwd ?? null,
|
|
161
|
+
uptimeMs: row.uptimeMs, spawner: row.spawner ?? null, presenceView: row.meshView ?? null, presenceIdentityVerified: row.presenceIdentityVerified ?? null,
|
|
162
|
+
presenceObservedAt: row.presenceObservedAt ?? null, offlineSince: row.offlineSince ?? null,
|
|
163
|
+
authHealth: row.authHealth ?? null, authReason: row.authReason ?? null, resume: row.resume ?? null },
|
|
164
|
+
};
|
|
77
165
|
}
|
|
78
166
|
/** A seat's compact runtime identity. Model is provenance, not a debugging detail, so it belongs
|
|
79
167
|
* beside the connector in the default row. `variant` is the requested override the manager
|
|
@@ -211,17 +299,18 @@ export function seatMissRefusal(name, verb, loc) {
|
|
|
211
299
|
* - `not-probed` / `probe-refused`: this command could not ask. That is a fact about the command,
|
|
212
300
|
* not the instance, and saying so is what keeps a local gap from reading as a remote fault.
|
|
213
301
|
*/
|
|
214
|
-
function
|
|
302
|
+
function silentManager(liveness, instanceId) {
|
|
215
303
|
if (liveness === "gone")
|
|
216
|
-
return
|
|
217
|
-
|
|
218
|
-
|
|
304
|
+
return {
|
|
305
|
+
state: { text: "registration is stale (the broker reports nothing subscribed on its rail; its host is gone and never deregistered)", tone: "failed" },
|
|
306
|
+
remedy: `remove the record: cotal deregister-instance --instance ${instanceId}`,
|
|
307
|
+
};
|
|
219
308
|
const why = liveness === "probe-refused"
|
|
220
309
|
? " (its liveness could not be probed: the broker refused this command's probe, named above)"
|
|
221
310
|
: liveness === "not-probed"
|
|
222
311
|
? " (its liveness was not probed: this command holds no probe grant for it)"
|
|
223
312
|
: " (either the host is alive and slow, or it died and its registration was never removed)";
|
|
224
|
-
return
|
|
313
|
+
return { state: { text: `registered, no answer within the deadline${why}`, tone: "failed" } };
|
|
225
314
|
}
|
|
226
315
|
/** The mesh column of one `ps` row. A verdict needs a fresh observer: when the manager reports its
|
|
227
316
|
* own presence view as `stale` (its watch went silent past TTL) or `unpopulated` (its watch has not
|
|
@@ -230,233 +319,346 @@ function silentManagerRow(liveness, instanceId) {
|
|
|
230
319
|
* on. A row from a manager that predates `meshView` carries no field and renders as before.
|
|
231
320
|
* An offline verdict says how long it has stood when the row carries `offlineSince` (#1208), so a
|
|
232
321
|
* seat that dropped a minute ago reads differently from one that dropped two days ago. */
|
|
233
|
-
export function
|
|
322
|
+
export function meshCell(r, now = Date.now()) {
|
|
234
323
|
if (r.meshView === "stale")
|
|
235
|
-
return
|
|
324
|
+
return { text: "mesh unknown (manager's presence view is stale)", tone: "waiting" };
|
|
236
325
|
if (r.meshView === "unpopulated")
|
|
237
|
-
return
|
|
326
|
+
return { text: "mesh unknown (manager's presence view not yet populated)", tone: "waiting" };
|
|
238
327
|
// The harness-reported condition and the last work progress ride beside the status, as the roster
|
|
239
328
|
// renders them (#618): a turn that died upstream 40m ago reads `waiting (rate_limit for 40m) ·
|
|
240
329
|
// active 40m ago`, not a bare `waiting`, and a turn that stopped advancing shows the age of its
|
|
241
330
|
// last event.
|
|
242
|
-
const condition =
|
|
243
|
-
const
|
|
244
|
-
|
|
245
|
-
:
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
return mesh
|
|
331
|
+
const { condition, ages } = presenceFacts(r, now);
|
|
332
|
+
const detail = condition + ages;
|
|
333
|
+
if (r.mesh === "absent")
|
|
334
|
+
return { text: `not in roster${detail}`, tone: "waiting" };
|
|
335
|
+
if (r.mesh === "offline")
|
|
336
|
+
return { text: `${r.offlineSince === undefined ? "mesh offline" : `mesh offline for ${fmtUptime(now - r.offlineSince)}`}${detail}`, tone: "hint" };
|
|
337
|
+
if (r.mesh === "working")
|
|
338
|
+
return { text: `working · progress unknown${detail}`, tone: "ok" };
|
|
339
|
+
if (r.mesh === "waiting")
|
|
340
|
+
return { text: `waiting${detail}`, tone: "waiting" };
|
|
341
|
+
return { text: `${r.mesh}${detail}` };
|
|
253
342
|
}
|
|
254
|
-
/**
|
|
255
|
-
* the per-manager grouping a class scatter prints.
|
|
343
|
+
/** The process column of one `ps` row, beside the mesh column and never folded into it.
|
|
256
344
|
*
|
|
257
|
-
* Two facts,
|
|
258
|
-
*
|
|
259
|
-
*
|
|
260
|
-
*
|
|
261
|
-
*
|
|
262
|
-
*
|
|
263
|
-
*
|
|
264
|
-
function
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
const mesh = meshColumn(r);
|
|
271
|
-
// Confirmed failure is red; ambiguity/warning states (unknown/stale) are yellow — the operator
|
|
272
|
-
// triages "definitely broken" before "might be".
|
|
273
|
-
const authColor = r.authHealth === "auth-renewal-failed" ? c.red : c.yellow;
|
|
274
|
-
console.log(`${indent}${c.bold(peerLabel(r))} ${c.dim(agentIdentity(r))} ${proc} ${mesh}${r.authHealth ? " " + authColor(r.authHealth) : ""}`);
|
|
275
|
-
// The detached agent's ONLY operator window into a failing bearer refresh: the provider command's
|
|
276
|
-
// operator-exact sentence, verbatim (it already names the repair).
|
|
277
|
-
if (r.authHealth && r.authReason)
|
|
278
|
-
console.log(authColor(`${indent} ${r.authReason}`));
|
|
345
|
+
* Two facts, shown as two facts. The manager reports the PROCESS (`status` from the runtime handle,
|
|
346
|
+
* `uptimeMs` from its start) and the MESH presence separately, and they disagree in the common
|
|
347
|
+
* failure: a seat that is `running` for two days but `offline` on the mesh. Folding them into one
|
|
348
|
+
* word rendered ten live processes as "offline" and a 57h-old process with no roster entry as
|
|
349
|
+
* "starting…", both false. `mesh: absent` means exactly "not in the presence roster", so it prints
|
|
350
|
+
* as that; the process age next to it tells the reader whether it is a fresh start or a seat that
|
|
351
|
+
* never joined. */
|
|
352
|
+
function processCell(r) {
|
|
353
|
+
if (r.status === "running")
|
|
354
|
+
return { text: `running ${fmtUptime(r.uptimeMs)}`, tone: "ok" };
|
|
355
|
+
if (r.status === "exited")
|
|
356
|
+
return { text: `exited after ${fmtUptime(r.uptimeMs)}`, tone: "failed" };
|
|
357
|
+
return { text: `${r.status} ${fmtUptime(r.uptimeMs)}`, tone: "waiting" };
|
|
279
358
|
}
|
|
280
|
-
/**
|
|
281
|
-
*
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
359
|
+
/** Confirmed failure is red; ambiguity/warning states (unknown/stale) are amber, so the operator
|
|
360
|
+
* triages "definitely broken" before "might be". */
|
|
361
|
+
const authTone = (r) => (r.authHealth === "auth-renewal-failed" ? "failed" : "waiting");
|
|
362
|
+
/** Extra operational facts for `--wide`, as label and value. Model and requested variant are already
|
|
363
|
+
* in the compact identity, so repeating them here would make wide output noisier without adding
|
|
364
|
+
* provenance. Only fields the manager actually recorded appear; lifecycle uid is required on every
|
|
365
|
+
* row. */
|
|
366
|
+
function wideFields(r) {
|
|
367
|
+
const fields = [];
|
|
285
368
|
if (r.provider)
|
|
286
|
-
|
|
369
|
+
fields.push(["provider", r.provider]);
|
|
287
370
|
if (r.cwd)
|
|
288
|
-
|
|
371
|
+
fields.push(["cwd", r.cwd]);
|
|
289
372
|
if (r.pid !== undefined)
|
|
290
|
-
|
|
373
|
+
fields.push(["pid", String(r.pid)]);
|
|
291
374
|
if (r.spawner)
|
|
292
|
-
|
|
293
|
-
|
|
375
|
+
fields.push(["spawner", r.spawner]);
|
|
376
|
+
fields.push(["uid", r.lifecycleUid]);
|
|
294
377
|
if (r.instanceId)
|
|
295
|
-
|
|
378
|
+
fields.push(["instance", r.instanceId]);
|
|
296
379
|
if (r.host)
|
|
297
|
-
|
|
380
|
+
fields.push(["host", r.host]);
|
|
298
381
|
if (r.resume) {
|
|
299
382
|
const { source, title, transcriptSha256, host, transferredAt } = r.resume;
|
|
300
|
-
|
|
383
|
+
fields.push(["forked from", `${host ? `${host}:` : ""}${source}${title ? ` ${JSON.stringify(title)}` : ""}${transcriptSha256 ? ` sha256:${transcriptSha256}` : ""}${transferredAt ? ` carried ${transferredAt}` : ""}`]);
|
|
301
384
|
}
|
|
302
|
-
return
|
|
385
|
+
return fields;
|
|
303
386
|
}
|
|
304
|
-
|
|
305
|
-
|
|
387
|
+
/** {@link wideFields} as one line of facts. */
|
|
388
|
+
export function agentWideFacts(r) {
|
|
389
|
+
return wideFields(r).map(([label, value]) => `${label} ${value}`);
|
|
306
390
|
}
|
|
307
|
-
/**
|
|
308
|
-
*
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
391
|
+
/** The seats one manager answered with: a table, or with `--wide` one labeled record per seat. A
|
|
392
|
+
* failing bearer refresh is a detached seat's only window to the operator, so the provider's own
|
|
393
|
+
* sentence follows, verbatim (it already names the repair). A record's labels read as its facts'
|
|
394
|
+
* do, and a field the seat leaves empty is left out. */
|
|
395
|
+
function seatBlocks(rows, wide) {
|
|
396
|
+
const auth = rows.some((r) => r.authHealth);
|
|
397
|
+
const cells = (r) => [
|
|
398
|
+
["NAME", peerLabel(r)],
|
|
399
|
+
["AGENT", { text: agentIdentity(r), tone: "hint" }],
|
|
400
|
+
["PROCESS", processCell(r)],
|
|
401
|
+
["MESH", meshCell(r)],
|
|
402
|
+
...(auth ? [["AUTH", r.authHealth ? { text: r.authHealth, tone: authTone(r) } : ""]] : []),
|
|
403
|
+
];
|
|
404
|
+
const blocks = wide
|
|
405
|
+
? rows.flatMap((r, i) => [...(i ? [{ kind: "lines", lines: [""] }] : []), { kind: "fields", rows: [...cells(r).filter(([, value]) => value !== "").map(([label, value]) => [label.toLowerCase(), value]), ...wideFields(r)] }])
|
|
406
|
+
: [{
|
|
407
|
+
kind: "table",
|
|
408
|
+
columns: cells(rows[0]).map(([label]) => ({ key: label, label })),
|
|
409
|
+
rows: rows.map((r) => Object.fromEntries(cells(r))),
|
|
410
|
+
}];
|
|
411
|
+
const reasons = rows.filter((r) => r.authHealth && r.authReason).map((r) => ({ text: `${peerLabel(r)}: ${r.authReason}`, tone: authTone(r) }));
|
|
412
|
+
if (reasons.length)
|
|
413
|
+
blocks.push({ kind: "lines", lines: reasons });
|
|
414
|
+
return blocks;
|
|
317
415
|
}
|
|
318
|
-
/** `--slots
|
|
319
|
-
*
|
|
320
|
-
function
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
416
|
+
/** `--slots`: one row per slot naming phase, slot uid, cleanup, head and liveness. The read order
|
|
417
|
+
* and its consistency are the same on every row, so they are stated once. */
|
|
418
|
+
function slotBlocks(rows) {
|
|
419
|
+
return [
|
|
420
|
+
{
|
|
421
|
+
kind: "table",
|
|
422
|
+
columns: [
|
|
423
|
+
{ key: "name", label: "NAME" },
|
|
424
|
+
{ key: "phase", label: "PHASE" },
|
|
425
|
+
{ key: "slot", label: "SLOT" },
|
|
426
|
+
{ key: "cleanup", label: "CLEANUP COMPLETE" },
|
|
427
|
+
{ key: "head", label: "HEAD" },
|
|
428
|
+
{ key: "live", label: "LIVE" },
|
|
429
|
+
],
|
|
430
|
+
rows: rows.map((r) => ({
|
|
431
|
+
name: r.name,
|
|
432
|
+
phase: r.slotPhase,
|
|
433
|
+
slot: r.slotLifecycleUid,
|
|
434
|
+
cleanup: r.cleanupComplete === undefined ? "unknown" : String(r.cleanupComplete),
|
|
435
|
+
head: r.headState === undefined ? "absent" : `${r.headState}${r.headOp ? ` op ${r.headOp.kind}:${r.headOp.opId}` : ""}`,
|
|
436
|
+
live: String(r.live),
|
|
437
|
+
})),
|
|
438
|
+
},
|
|
439
|
+
{ kind: "lines", lines: [{ text: `read order slot,head; consistency ${rows[0].consistency}`, tone: "hint" }] },
|
|
440
|
+
];
|
|
441
|
+
}
|
|
442
|
+
/** `rowsOf` is each answered instance's rows as the census received them, so a row that names no
|
|
443
|
+
* instance of its own is still listed under the manager that returned it. */
|
|
444
|
+
function psView(result, wide, rowsOf = new Map()) {
|
|
445
|
+
const empty = result.kind === "slots" ? "No active static slots." : "No managed agents.";
|
|
446
|
+
const blocksFor = (rows) => !rows.length ? [{ kind: "lines", lines: [{ text: empty, tone: "hint" }] }]
|
|
447
|
+
: result.kind === "slots" ? slotBlocks(rows)
|
|
448
|
+
: seatBlocks(rows, wide);
|
|
449
|
+
// A single manager that answered is the common case: a flat list, no per-manager grouping noise.
|
|
450
|
+
if (result.managers.length <= 1 && result.managers.every((m) => m.state === "answered"))
|
|
451
|
+
return { sections: [
|
|
452
|
+
{ title: result.kind === "slots" ? "Static slots" : "Agents", blocks: blocksFor(result.items) },
|
|
453
|
+
{ title: "Next", blocks: [{ kind: "commands", items: result.items.length ? [
|
|
454
|
+
{ command: "cotal attach <name>", description: "Return to an agent's terminal" },
|
|
455
|
+
{ command: "cotal stop <name>", description: "Stop one agent" },
|
|
456
|
+
] : [{ command: "cotal spawn", description: "Launch your default agent" }] }] },
|
|
457
|
+
] };
|
|
458
|
+
// Several managers: one section each, named by the FULL instance id, since `--on` takes nothing
|
|
459
|
+
// shorter and this is precisely where it becomes the one way to address a manager. Silent and
|
|
460
|
+
// refused instances are shown, never dropped.
|
|
461
|
+
return {
|
|
462
|
+
sections: result.managers.map((m) => {
|
|
463
|
+
const title = `manager ${m.instanceId}`;
|
|
464
|
+
if (m.state === "silent") {
|
|
465
|
+
const silent = silentManager(m.liveness, m.instanceId);
|
|
466
|
+
return { title, blocks: [{ kind: "lines", lines: [silent.state, ...(silent.remedy ? [{ text: `↳ ${silent.remedy}`, tone: "hint" }] : [])] }] };
|
|
467
|
+
}
|
|
468
|
+
if (m.state === "contract-mismatch")
|
|
469
|
+
return { title, blocks: [{ kind: "lines", lines: [{ text: "contract mismatch; seats not listed", tone: "failed" }] }] };
|
|
470
|
+
if (m.state === "refused")
|
|
471
|
+
return { title, blocks: [{ kind: "lines", lines: [{ text: `list refused: ${m.error}`, tone: "failed" }] }] };
|
|
472
|
+
const rows = rowsOf.get(m.instanceId) ?? [];
|
|
473
|
+
const count = rows.length ? `${rows.length} ${result.kind === "slots" ? "slot" : "agent"}${rows.length === 1 ? "" : "s"}` : `no ${result.kind === "slots" ? "slots" : "agents"}`;
|
|
474
|
+
return { title, blocks: [{ kind: "lines", lines: [{ text: count, tone: "hint" }] }, ...(rows.length ? blocksFor(rows) : [])] };
|
|
475
|
+
}),
|
|
476
|
+
};
|
|
328
477
|
}
|
|
329
478
|
export async function ps(args) {
|
|
330
479
|
const v = args.values;
|
|
331
|
-
// #651 presentations:
|
|
332
|
-
//
|
|
333
|
-
//
|
|
334
|
-
const
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
if (
|
|
340
|
-
|
|
341
|
-
|
|
480
|
+
// #651 presentations: --wide is a human layout and --json the document that already carries every
|
|
481
|
+
// field, so the pair asks one question two ways; inventing a precedence would be a silent
|
|
482
|
+
// fallback, so refuse instead.
|
|
483
|
+
const presentation = presentationOf(v);
|
|
484
|
+
const wide = v.wide === true;
|
|
485
|
+
const slots = v.slots === true;
|
|
486
|
+
if (wide && presentation === "json")
|
|
487
|
+
throw new CommandFailure("refused", "USAGE_INVALID", "--wide and --json are mutually exclusive: --wide is the human layout, --json the document with every field", { remedy: "drop --wide; --json already carries every field the manager recorded" });
|
|
488
|
+
if (slots && wide)
|
|
489
|
+
throw new CommandFailure("refused", "USAGE_INVALID", "--slots and --wide are mutually exclusive: --slots lists durable static slot rows, --wide the live seat facts", { remedy: "pass one of them" });
|
|
490
|
+
const command = slots ? "slots" : "ps";
|
|
491
|
+
const kind = slots ? "slots" : "seats";
|
|
492
|
+
const census = await readSeats(v, command, onInstance(v.on, "cotal ps"));
|
|
493
|
+
const view = (result) => psView(result, wide, census.rowsOf);
|
|
494
|
+
writeResult(presentation, {
|
|
495
|
+
command: "ps",
|
|
496
|
+
target: census.target,
|
|
497
|
+
result: { kind, items: census.items, managers: census.managers },
|
|
498
|
+
completeness: census.partial ? "partial" : "complete",
|
|
499
|
+
warnings: census.warnings,
|
|
500
|
+
...(census.partial ? { partial: census.partial } : {}),
|
|
501
|
+
}, view);
|
|
502
|
+
}
|
|
503
|
+
/** A named-agent detail uses the same authorized census as ps, never an invented process view. */
|
|
504
|
+
export async function agentStatus(args) {
|
|
505
|
+
const name = args.positionals[0];
|
|
506
|
+
const values = args.values;
|
|
507
|
+
const census = await readSeats(values, "ps", onInstance(values.on, "cotal status"));
|
|
508
|
+
const rows = census.items.map((value) => {
|
|
509
|
+
if (!value || typeof value !== "object")
|
|
510
|
+
throw new CommandFailure("failed", "OPERATION_FAILED", "a manager returned an invalid agent record", { target: census.target });
|
|
511
|
+
const row = value;
|
|
512
|
+
if (typeof row.name !== "string" || typeof row.id !== "string" || typeof row.agent !== "string" || typeof row.mode !== "string" || typeof row.status !== "string" || typeof row.mesh !== "string" || typeof row.uptimeMs !== "number" || !Number.isFinite(row.uptimeMs))
|
|
513
|
+
throw new CommandFailure("failed", "OPERATION_FAILED", "a manager returned an incomplete agent record", { target: census.target });
|
|
514
|
+
return value;
|
|
515
|
+
});
|
|
516
|
+
const matches = rows.filter((row) => row.name === name || row.id === name);
|
|
517
|
+
if (matches.length > 1)
|
|
518
|
+
throw new CommandFailure("refused", "TARGET_AMBIGUOUS", "more than one manager reports this agent; select a manager with --on", { target: { ...census.target, name, candidates: matches.map((row) => ({ name: row.name, id: row.id, instanceId: row.instanceId ?? null })) } });
|
|
519
|
+
if (!matches.length && !census.partial)
|
|
520
|
+
throw new CommandFailure("refused", "TARGET_NOT_FOUND", "the answering managers report no agent with that name or identity", { target: { ...census.target, name } });
|
|
521
|
+
const item = matches[0] ?? null;
|
|
522
|
+
const managerInstanceId = item ? [...census.rowsOf].find(([, rows]) => rows.includes(item))?.[0] ?? census.target.managerInstanceId ?? item.instanceId ?? null : null;
|
|
523
|
+
let managerHint = "";
|
|
524
|
+
if (managerInstanceId) {
|
|
525
|
+
try {
|
|
526
|
+
managerHint = ` --on ${assertLifecycleToken(managerInstanceId, "instanceId")}`;
|
|
527
|
+
}
|
|
528
|
+
catch {
|
|
529
|
+
managerHint = " --on <manager-instance>";
|
|
530
|
+
}
|
|
342
531
|
}
|
|
343
|
-
const
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
:
|
|
348
|
-
|
|
532
|
+
const projected = item ? agentStatusProjection(item, managerInstanceId) : { identity: null, execution: null, mesh: null, activity: null, details: null };
|
|
533
|
+
writeResult(presentationOf(values), {
|
|
534
|
+
command: "status",
|
|
535
|
+
target: { ...census.target, name },
|
|
536
|
+
result: { kind: "agent", ...projected, managers: census.managers },
|
|
537
|
+
completeness: census.partial ? "partial" : "complete",
|
|
538
|
+
warnings: census.warnings,
|
|
539
|
+
...(census.partial ? { partial: census.partial } : {}),
|
|
540
|
+
}, (result) => {
|
|
541
|
+
const row = item;
|
|
542
|
+
if (!row || !result.identity || !result.execution || !result.mesh || !result.activity || !result.details)
|
|
543
|
+
return { sections: [
|
|
544
|
+
{ title: "Agent could not be located", blocks: [{ kind: "lines", lines: [{ text: "Some managers did not answer. This does not establish that the agent is gone.", tone: "waiting" }] }] },
|
|
545
|
+
{ title: "Next", blocks: [{ kind: "commands", items: [{ command: "cotal ps", description: "See the responding and unavailable managers" }, { command: "cotal status <agent> --on <manager-instance>", description: "Address a known manager directly" }] }] },
|
|
546
|
+
] };
|
|
547
|
+
const identity = result.identity, execution = result.execution, mesh = result.mesh, activity = result.activity;
|
|
548
|
+
const credential = row.authHealth ? [["Credential", { text: row.authHealth, tone: authTone(row) }]] : [];
|
|
549
|
+
return { sections: [
|
|
550
|
+
{ title: "Identity", blocks: [
|
|
551
|
+
...(census.partial ? [{ kind: "lines", lines: [{ text: "Other managers did not answer. This is one known match, not a complete uniqueness check.", tone: "waiting" }] }] : []),
|
|
552
|
+
{ kind: "fields", rows: [["Agent", identity.name], ["Space", census.target.space], ["Principal", row.id], ["Owner", identity.owner ?? "not established"], ["Actor", identity.actor ?? "not established"], ["Lifecycle", identity.lifecycleUid ?? "not reported"], ["Role", result.details.role ?? "not reported"]] },
|
|
553
|
+
] },
|
|
554
|
+
{ title: "Execution", blocks: [
|
|
555
|
+
{ kind: "fields", rows: [["Process", processCell(row)], ["Application", execution.harness], ["Model", execution.model ? `${execution.model} · requested, not provider-confirmed` : "not reported"], ["Variant", result.details.variant ?? "not reported"], ["Reported provider", result.details.providerSource === "exact-principal-lifecycle" ? result.details.provider ?? "not reported" : "not established"], ["Name-matched provider", result.details.providerSource === "name-match-unverified" ? result.details.provider ?? "not reported" : "none"], ["Runtime", execution.runtime], ["PID", execution.pid === null ? "not reported" : String(execution.pid)], ["Host", execution.host ?? "not reported"], ["Folder", result.details.cwd ?? "not reported"], ["Manager", execution.managerInstanceId ?? "not reported"], ...credential] },
|
|
556
|
+
...(row.authReason ? [{ kind: "lines", lines: [{ text: row.authReason, tone: authTone(row) }] }] : []),
|
|
557
|
+
] },
|
|
558
|
+
{ title: "Mesh", blocks: [
|
|
559
|
+
{ kind: "fields", rows: [["Exact presence", mesh.presenceState ?? "not established"], ["Connection", mesh.presenceState === null ? "not attributable to this lifecycle" : meshCell(row)], ["Name-matched roster", mesh.nameMatchedState === null ? "none separate" : meshCell(row)], ["Observed at", mesh.observedAt ?? "not reported"], ["Presence view", result.details.presenceView ?? "not reported"]] },
|
|
560
|
+
...(mesh.presenceState === null ? [{ kind: "lines", lines: [{ text: "This manager has not established a current roster record for the agent's exact principal and lifecycle UID. A matching name alone is not proof.", tone: "waiting" }] }] : []),
|
|
561
|
+
] },
|
|
562
|
+
{ title: "Last reported activity", blocks: [
|
|
563
|
+
{ kind: "fields", rows: [["State", activity.state ?? "not established"], ["Text", "not reported"], ["Condition", activity.condition?.code ?? "not established"], ["Condition since", activity.conditionSince ?? "not reported"], ["Work event", activity.reportedAt ?? "not reported"], ["Unverified name-match condition", activity.nameMatchedCondition?.code ?? "none"], ["Unverified name-match event", activity.nameMatchedWorkEventAt ?? "none"]] },
|
|
564
|
+
{ kind: "lines", lines: [{ text: "A work event is not task completion or a measured blocked duration. A name-match without the manager's exact-identity proof is not this agent's activity.", tone: "hint" }] },
|
|
565
|
+
] },
|
|
566
|
+
{ title: "Next", blocks: [{ kind: "commands", items: [{ command: `cotal attach <agent>${managerHint}`, description: managerHint ? "Return to its terminal through this manager" : "Return to its terminal" }, { command: `cotal stop <agent>${managerHint}`, description: managerHint ? "Stop the named agent through this manager" : "Stop the named agent" }] }] },
|
|
567
|
+
] };
|
|
568
|
+
});
|
|
569
|
+
}
|
|
570
|
+
/** Read the managed seats the way `ps` lists them: from one manager when `on` pins it or the caller
|
|
571
|
+
* holds a user bearer, otherwise from every registered instance. Throws the classified failure when
|
|
572
|
+
* the target cannot be resolved or no manager can be asked. */
|
|
573
|
+
export async function readSeats(v, command, on) {
|
|
349
574
|
// `--on` must reach the MINT, not just the invoke: the one-shot instrument is issued during
|
|
350
575
|
// this resolve, and a credential cannot gain an instance rail after it is minted.
|
|
351
|
-
const t = await resolveControlTarget(v, "control-caller-privileged", on);
|
|
352
|
-
|
|
353
|
-
//
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
// A JSON stream with zero rows is zero lines on stdout, not a prose line that would
|
|
360
|
-
// corrupt a consumer reading JSONL.
|
|
361
|
-
if (!opts.json)
|
|
362
|
-
console.log(c.dim(emptyLine));
|
|
363
|
-
return;
|
|
364
|
-
}
|
|
365
|
-
for (const r of rows)
|
|
366
|
-
print(r);
|
|
367
|
-
return;
|
|
368
|
-
}
|
|
576
|
+
const t = await resolveControlTarget(v, "control-caller-privileged", on, { onRefusal: "throw" });
|
|
577
|
+
recordOperationSpace(t.space);
|
|
578
|
+
// One manager instance: `--on <instance>` pins ps to its `inst` route on a multi-manager mesh,
|
|
579
|
+
// and in USER MODE (bearer present) the borrowed manager view pins one authorized instance and
|
|
580
|
+
// keeps the actor's existing command scopes. That view has no registry freeze rows and never
|
|
581
|
+
// scatters; the manager answers from its in-memory roster with an owner filter, which is not a
|
|
582
|
+
// complete multi-manager inventory (see docs/cli.md), and the target says so.
|
|
583
|
+
//
|
|
369
584
|
// Mode chosen UP FRONT from the connection shape. Never try-scatter-catch-degrade: a silent
|
|
370
585
|
// downgrade is the bug this branch fixes, and reintroducing it in the fix would be the whole
|
|
371
586
|
// night in miniature.
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
return;
|
|
587
|
+
if (on !== undefined || t.auth.bearer) {
|
|
588
|
+
const instanceId = on ?? t.auth.managerInstanceId;
|
|
589
|
+
const target = { space: t.space, scope: "manager", managerInstanceId: instanceId ?? null };
|
|
590
|
+
const reply = await askManager(t.space, t.server, command, undefined, t.auth, "owner", undefined, on !== undefined ? { instanceId: on } : {});
|
|
591
|
+
if (!reply.ok) {
|
|
592
|
+
const failure = readFailure(reply, target);
|
|
593
|
+
// A user-mode manager view that the broker refused before any responder saw the call. The
|
|
594
|
+
// broker does not say which row was missing, so this names the documented requirement for
|
|
595
|
+
// these reads instead of asserting a cause, and keeps the native refusal as it was. A refusal
|
|
596
|
+
// the manager answered, such as a retiring caller's, already states its own reason.
|
|
597
|
+
if (t.auth.bearer && failure.code === "PERMISSION_DENIED" && reply.nativeOutcome === "not-executed" && !reply.answered)
|
|
598
|
+
throw new CommandFailure(failure.outcome, failure.code, failure.message, {
|
|
599
|
+
target,
|
|
600
|
+
remedy: `on a user-auth mesh, the manager's \`${command}\` read is documented to need the \`admin\` scope on your actor grant; \`spawn\` alone does not carry it. Check what your row holds with \`cotal auth grants\``,
|
|
601
|
+
...(failure.native ? { native: failure.native } : {}),
|
|
602
|
+
});
|
|
603
|
+
throw failure;
|
|
390
604
|
}
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
return;
|
|
605
|
+
const items = reply.data ?? [];
|
|
606
|
+
return { target, items, managers: instanceId ? [{ instanceId, state: "answered" }] : [], warnings: [], rowsOf: new Map() };
|
|
394
607
|
}
|
|
608
|
+
// STATIC/OPEN (no bearer): class scatter. The operator instrument (or bare open connect) holds the
|
|
609
|
+
// freeze rows; every registered instance is attributed, and a non-answering one is labeled with
|
|
610
|
+
// what this command established about it (pin 3).
|
|
611
|
+
const target = { space: t.space, scope: "all-managers" };
|
|
395
612
|
const scatter = await scatterManager(t.space, t.server, command, t.auth, t.spaceAuth);
|
|
396
|
-
if (!scatter.ok)
|
|
397
|
-
|
|
398
|
-
process.exit(1);
|
|
399
|
-
}
|
|
613
|
+
if (!scatter.ok)
|
|
614
|
+
throw readFailure(scatter, target);
|
|
400
615
|
// Stable ordering: reachable instances first, then by instance id.
|
|
401
616
|
const instances = [...scatter.instances].sort((a, b) => Number(b.reachable) - Number(a.reachable) || a.instanceId.localeCompare(b.instanceId));
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
if (!rows.length) {
|
|
406
|
-
if (!opts.json)
|
|
407
|
-
console.log(c.dim(emptyLine));
|
|
408
|
-
return;
|
|
409
|
-
}
|
|
410
|
-
for (const r of rows)
|
|
411
|
-
print(r);
|
|
412
|
-
return;
|
|
413
|
-
}
|
|
414
|
-
// Multi-manager: group under a per-instance header; unreachable instances are shown, never dropped.
|
|
415
|
-
//
|
|
416
|
-
// The header prints the FULL instance id, not a prefix. This block runs only in a multi-manager
|
|
417
|
-
// space (precisely when the split makes `--on <instance>` the one way to address a manager) and
|
|
418
|
-
// `--on` takes nothing but the whole 26-32 char lifecycle token (`assertLifecycleToken`). An
|
|
419
|
-
// abbreviated header therefore showed the operator an id that the very next command refuses
|
|
420
|
-
// (`"4ik6rb0e" is not a valid lifecycle token`), with the full value printed nowhere: the remedy
|
|
421
|
-
// was named and then withheld. Width costs one line here; the prefix cost the flag entirely.
|
|
422
|
-
let incomplete = false;
|
|
617
|
+
const items = [];
|
|
618
|
+
const managers = [];
|
|
619
|
+
const warnings = [];
|
|
423
620
|
const mismatches = [];
|
|
621
|
+
const rowsOf = new Map();
|
|
424
622
|
for (const inst of instances) {
|
|
425
|
-
const
|
|
426
|
-
// Under --json the instance headers are STRUCTURE, not data: they go to stderr so stdout is
|
|
427
|
-
// pure rows (each row carries its own instanceId/host, so nothing is lost).
|
|
428
|
-
const header = (line) => { (opts.json ? console.error : console.log)(line); };
|
|
623
|
+
const at = { space: t.space, managerInstanceId: inst.instanceId };
|
|
429
624
|
if (!inst.reachable) {
|
|
430
|
-
incomplete = true;
|
|
431
625
|
// Not "unreachable": the client holds no network verdict. What it knows is which question it
|
|
432
626
|
// asked about this instance and what came back, which is narrower and more useful. The four
|
|
433
|
-
// cases and their wording are `
|
|
434
|
-
|
|
627
|
+
// cases and their wording are `silentManager`.
|
|
628
|
+
managers.push({ instanceId: inst.instanceId, state: "silent", ...(inst.liveness ? { liveness: inst.liveness } : {}) });
|
|
629
|
+
warnings.push({ code: "MANAGER_SILENT", target: at, message: `manager ${inst.instanceId}: ${silentManager(inst.liveness, inst.instanceId).state.text}` });
|
|
435
630
|
continue;
|
|
436
631
|
}
|
|
437
632
|
if (inst.error) {
|
|
438
|
-
incomplete = true;
|
|
439
633
|
const mismatch = /^pinned digests (sha256:[a-f0-9]{64})\/(sha256:[a-f0-9]{64}) do not match the served contract (sha256:[a-f0-9]{64})\/(sha256:[a-f0-9]{64});/.exec(inst.error);
|
|
634
|
+
const code = inst.code === undefined ? {} : { code: inst.code };
|
|
440
635
|
if (mismatch) {
|
|
441
|
-
|
|
636
|
+
managers.push({ instanceId: inst.instanceId, state: "contract-mismatch", error: inst.error, ...code });
|
|
442
637
|
mismatches.push(`manager ${inst.instanceId}: requested input/output ${mismatch[1]} / ${mismatch[2]}; served input/output ${mismatch[3]} / ${mismatch[4]}`);
|
|
638
|
+
warnings.push({ code: "MANAGER_CONTRACT_MISMATCH", target: at, message: `manager ${inst.instanceId} serves a different ps contract; its seats were not listed` });
|
|
443
639
|
}
|
|
444
640
|
else {
|
|
445
|
-
|
|
641
|
+
managers.push({ instanceId: inst.instanceId, state: "refused", error: inst.error, ...code });
|
|
642
|
+
warnings.push({ code: "MANAGER_REFUSED", target: at, message: `manager ${inst.instanceId} refused the list: ${inst.error}` });
|
|
446
643
|
}
|
|
447
644
|
continue;
|
|
448
645
|
}
|
|
449
646
|
const rows = inst.data ?? [];
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
}
|
|
454
|
-
if (mismatches.length)
|
|
455
|
-
console.error(c.red(`✗ Managers in this space serve different ps contracts. ${mismatches.join("; ")}. Align the manager versions and retry.`));
|
|
456
|
-
if (incomplete) {
|
|
457
|
-
console.error(c.red("✗ Incomplete manager census: some instances did not return seats. Rows above are partial, not a complete list."));
|
|
458
|
-
process.exitCode = 1;
|
|
647
|
+
managers.push({ instanceId: inst.instanceId, state: "answered" });
|
|
648
|
+
rowsOf.set(inst.instanceId, rows);
|
|
649
|
+
items.push(...rows);
|
|
459
650
|
}
|
|
651
|
+
const unread = managers.filter((m) => m.state !== "answered").length;
|
|
652
|
+
const kind = command === "slots" ? "slots" : "seats";
|
|
653
|
+
const partial = unread
|
|
654
|
+
? {
|
|
655
|
+
message: `Incomplete manager census: ${unread} of ${managers.length} instances did not return ${kind}. Rows above are partial, not a complete list.`,
|
|
656
|
+
remedy: mismatches.length
|
|
657
|
+
? `Managers in this space serve different ps contracts. ${mismatches.join("; ")}. Align the manager versions and retry.`
|
|
658
|
+
: "retry, or read one manager with `cotal ps --on <instance>`",
|
|
659
|
+
}
|
|
660
|
+
: undefined;
|
|
661
|
+
return { target, items, managers, warnings, rowsOf, ...(partial ? { partial } : {}) };
|
|
460
662
|
}
|
|
461
663
|
/** Re-establishment backoff, in order; the last value is the cap and repeats forever. A seat that
|
|
462
664
|
* exists is worth waiting for — the operator asked to be attached to it, and the alternative is
|
|
@@ -531,7 +733,12 @@ export function attachRefusal(code, details) {
|
|
|
531
733
|
* helper can wrap it, and it only rethrows the codes that are not "no mesh found", so that is fatal
|
|
532
734
|
* too. Anything else, including a broker that is not reachable yet, is transient.
|
|
533
735
|
*/
|
|
736
|
+
class SeatAttachCallerUnavailable extends Error {
|
|
737
|
+
constructor() { super("the launching seat could not re-establish its own caller; no operator identity was substituted"); }
|
|
738
|
+
}
|
|
534
739
|
function thrownEstablishment(e) {
|
|
740
|
+
if (e instanceof SeatAttachCallerUnavailable)
|
|
741
|
+
return { ok: false, kind: "fatal", message: e.message };
|
|
535
742
|
if (e instanceof ConnectRefusal && e.kind === "permanent")
|
|
536
743
|
return { ok: false, kind: "fatal", message: [e.rendered.replace(/^✗ /, ""), e.hint].filter(Boolean).join("\n") };
|
|
537
744
|
if (isWorkspaceTargetError(e))
|
|
@@ -604,11 +811,20 @@ async function establishAttachSession(v, on, reconnect, firstAttempt) {
|
|
|
604
811
|
// mid-session, and the refusal becomes a status-line notice instead. So "first" here means the
|
|
605
812
|
// first attempt of a command that wants the exit.
|
|
606
813
|
const first = firstAttempt && (v.onRefusal ?? "exit") === "exit";
|
|
607
|
-
const
|
|
814
|
+
const seat = v.asSeat ? await resolveSeatControlTarget(v, on) : undefined;
|
|
815
|
+
if (v.asSeat && !seat)
|
|
816
|
+
throw new SeatAttachCallerUnavailable();
|
|
817
|
+
const t = seat ?? await resolveControlTarget(v, "control-caller-admin", on, first ? {} : { onRefusal: "throw" });
|
|
818
|
+
recordOperationSpace(t.space);
|
|
608
819
|
const reach = t.auth.bearer ? "owner" : "any";
|
|
609
|
-
|
|
610
|
-
|
|
820
|
+
if (first)
|
|
821
|
+
console.error(renderReport({ space: t.space, sections: [{ title: "Attach", blocks: [{ kind: "fields", rows: [["Agent", v.name], ["Manager", on ?? t.auth.managerInstanceId ?? "native selection"]] }] }] }, "rich", terminalWidth(process.stderr)));
|
|
822
|
+
const reply = await askManager(t.space, t.server, "attach", { name: v.name }, t.auth, reach, undefined, { instanceId: on, expectedTarget: v.expectedTarget });
|
|
823
|
+
if (!reply.ok) {
|
|
824
|
+
if (first && (reply.preSubmitRefusal || reply.nativeOutcome === "not-executed"))
|
|
825
|
+
throw managerFailure(reply, "terminal attach", { space: t.space, agent: v.name, managerInstanceId: reply.managerInstanceId ?? on ?? null });
|
|
611
826
|
return { ok: false, kind: attachRefusal(reply.code, reply.details), message: reply.error ?? "error", fromManager: true };
|
|
827
|
+
}
|
|
612
828
|
// P2 item 6: the reply is the holder-bound §13.6 session GRANT (no ws:// URL). Redeem it over the
|
|
613
829
|
// mesh. A static-auth mesh mints a per-session, rails-only caller cred from the resolved root's
|
|
614
830
|
// seed. A registered open mesh has no seed: the same bare connection `askManagerEp` already used
|
|
@@ -962,7 +1178,7 @@ async function runAttachLoop(vv, pin, reconnect, key, hold) {
|
|
|
962
1178
|
const detached = watch ? await Promise.race([waited, watch.pressed.then(() => true)]) : await waited;
|
|
963
1179
|
clearTimeout(timer);
|
|
964
1180
|
if (detached)
|
|
965
|
-
return await done({ kind: "ended" });
|
|
1181
|
+
return await done({ kind: "ended", reason: "detached" });
|
|
966
1182
|
attempt++;
|
|
967
1183
|
}
|
|
968
1184
|
// Give the manager its slots back BEFORE claiming another one. The order is load-bearing at the
|
|
@@ -999,7 +1215,7 @@ async function runAttachLoop(vv, pin, reconnect, key, hold) {
|
|
|
999
1215
|
// abandoned backoff timer, one layer down.
|
|
1000
1216
|
await closeLink(late.nc);
|
|
1001
1217
|
}
|
|
1002
|
-
return await done({ kind: "ended" });
|
|
1218
|
+
return await done({ kind: "ended", reason: "detached" });
|
|
1003
1219
|
}
|
|
1004
1220
|
}
|
|
1005
1221
|
try {
|
|
@@ -1085,7 +1301,7 @@ async function runAttachLoop(vv, pin, reconnect, key, hold) {
|
|
|
1085
1301
|
// One-shot: a faulted session still throws, so `--no-reconnect` exits the way it does today.
|
|
1086
1302
|
if (outcome.error)
|
|
1087
1303
|
throw outcome.error;
|
|
1088
|
-
return await done({ kind: "ended" });
|
|
1304
|
+
return await done({ kind: "ended", reason: outcome.reason });
|
|
1089
1305
|
}
|
|
1090
1306
|
if (!isTransportEnd(outcome.reason)) {
|
|
1091
1307
|
// A faulted end this classification does not recognise is NOT a detach. Printing
|
|
@@ -1094,7 +1310,7 @@ async function runAttachLoop(vv, pin, reconnect, key, hold) {
|
|
|
1094
1310
|
// this is a guard against a future one that forgets, not a live path.
|
|
1095
1311
|
if (outcome.error)
|
|
1096
1312
|
return await done({ kind: "failed", message: outcome.error.message });
|
|
1097
|
-
return await done({ kind: "ended" });
|
|
1313
|
+
return await done({ kind: "ended", reason: outcome.reason });
|
|
1098
1314
|
}
|
|
1099
1315
|
console.error(c.dim("[cotal: connection lost, reconnecting]"));
|
|
1100
1316
|
// Raw from here on, whether or not the session that just ended reached ready. A first session
|
|
@@ -1143,28 +1359,49 @@ export async function attachSeat(v, opts) {
|
|
|
1143
1359
|
hold.restore();
|
|
1144
1360
|
}
|
|
1145
1361
|
}
|
|
1362
|
+
async function pickAttach(values) {
|
|
1363
|
+
const census = await readSeats(values, "ps", onInstance(values.on, "cotal attach"));
|
|
1364
|
+
const choices = census.items.map((value) => {
|
|
1365
|
+
const row = value;
|
|
1366
|
+
if (!row || typeof row.name !== "string" || typeof row.id !== "string" || typeof row.lifecycleUid !== "string")
|
|
1367
|
+
throw new CommandFailure("refused", "UNSUPPORTED", "a manager did not report the identity needed for a safe attach selection", { remedy: "align the manager versions before using the picker", target: census.target });
|
|
1368
|
+
const on = [...census.rowsOf].find(([, rows]) => rows.includes(value))?.[0] ?? census.target.managerInstanceId;
|
|
1369
|
+
if (!on)
|
|
1370
|
+
throw new CommandFailure("refused", "TARGET_UNAVAILABLE", "the agent's manager instance was not established", { target: census.target });
|
|
1371
|
+
return { name: row.name, on, expectedTarget: { id: row.id, lifecycleUid: row.lifecycleUid }, status: typeof row.status === "string" ? row.status : "not reported" };
|
|
1372
|
+
});
|
|
1373
|
+
if (census.partial)
|
|
1374
|
+
console.error(renderReport({ space: census.target.space, sections: [{ title: "Agent list is partial", blocks: [{ kind: "lines", lines: [{ text: census.partial.message, tone: "waiting" }] }] }] }, "rich", terminalWidth(process.stderr)));
|
|
1375
|
+
if (!choices.length)
|
|
1376
|
+
throw new CommandFailure("refused", census.partial ? "TARGET_UNAVAILABLE" : "TARGET_NOT_FOUND", census.partial ? "no attachable agent was returned; some managers did not answer" : "the answering managers report no agents to attach", { target: census.target, remedy: "run cotal ps, or launch an agent with cotal spawn" });
|
|
1377
|
+
const choice = await prompts.select({
|
|
1378
|
+
message: `Return to an agent in ${oneLine(census.target.space)}`,
|
|
1379
|
+
options: choices.map((item, index) => ({ value: index, label: oneLine(`${item.name} · ${item.status}`), hint: oneLine(`${item.expectedTarget.id} · manager ${item.on}`) })),
|
|
1380
|
+
});
|
|
1381
|
+
if (prompts.isCancel(choice))
|
|
1382
|
+
return undefined;
|
|
1383
|
+
const selected = choices[choice];
|
|
1384
|
+
console.error(renderReport({ space: census.target.space, sections: [{ title: "Attaching", blocks: [{ kind: "fields", rows: [["Agent", selected.name], ["Identity", selected.expectedTarget.id], ["Manager", selected.on], ["Detach", `${detachKey().label} leaves the agent running`]] }] }] }, "rich", terminalWidth(process.stderr)));
|
|
1385
|
+
return selected;
|
|
1386
|
+
}
|
|
1146
1387
|
export async function attach(args) {
|
|
1147
|
-
const
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1388
|
+
const name = managedTarget(args, "attach", true);
|
|
1389
|
+
const selection = name === undefined ? await pickAttach(args.values) : undefined;
|
|
1390
|
+
if (name === undefined && selection === undefined) {
|
|
1391
|
+
console.error("Attach cancelled. No agent was stopped.");
|
|
1392
|
+
return;
|
|
1151
1393
|
}
|
|
1394
|
+
const v = { ...args.values, name: name ?? selection.name, ...(selection ? { on: selection.on } : {}) };
|
|
1152
1395
|
const reconnecting = v["no-reconnect"] !== true;
|
|
1153
|
-
// Seat-locality first, exactly as `stop` does it: attaching to a seat means reaching the process,
|
|
1154
|
-
// which only its host manager has. Resolved ONCE — the seat does not move between reconnects, and
|
|
1155
|
-
// a manager that stops answering is a transient the loop already retries through. An explicit
|
|
1156
|
-
// `--on` skips the lookup (the empty-value refusal lives in `pinForTarget`).
|
|
1157
1396
|
const on = v.on !== undefined ? await pinForTarget(v, "cotal attach") : undefined;
|
|
1158
|
-
const verdict = await attachSeat({ space: v.space, server: v.server, creds: v.creds, name: v.name }, { reconnect: reconnecting, onRefusal: "exit", on });
|
|
1159
|
-
if (verdict.kind === "failed")
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
}
|
|
1167
|
-
console.error(c.dim(`\ndetached from ${v.name}`));
|
|
1397
|
+
const verdict = await attachSeat({ space: v.space, server: v.server, creds: v.creds, name: v.name, ...(selection ? { expectedTarget: selection.expectedTarget } : {}) }, { reconnect: reconnecting, onRefusal: "exit", on });
|
|
1398
|
+
if (verdict.kind === "failed")
|
|
1399
|
+
throw new CommandFailure("failed", "OPERATION_FAILED", verdict.message);
|
|
1400
|
+
const detached = verdict.kind === "ended" && verdict.reason === "detached";
|
|
1401
|
+
console.error(renderReport({ sections: [{ title: verdict.kind === "gone" ? "Attach target no longer available" : detached ? "Detached" : "Attach session ended", blocks: [
|
|
1402
|
+
{ kind: "fields", rows: [["Agent", v.name]] },
|
|
1403
|
+
{ kind: "lines", lines: [{ text: verdict.kind === "gone" ? "The selected agent or incarnation was not available to this attach request." : detached ? "Detaching did not send a stop request." : "The terminal session ended. This view sent no agent stop request; run cotal ps to check the agent's current state.", tone: "hint" }] },
|
|
1404
|
+
] }] }, "rich", terminalWidth(process.stderr)));
|
|
1168
1405
|
}
|
|
1169
1406
|
/**
|
|
1170
1407
|
* `cotal input --name <seat> --text <text> [--no-enter]`: deliver one line of text into a running
|
|
@@ -1177,26 +1414,39 @@ export async function attach(args) {
|
|
|
1177
1414
|
* reads the resulting turns from the event plane or the transcript, so this prints only what was
|
|
1178
1415
|
* delivered.
|
|
1179
1416
|
*/
|
|
1417
|
+
export function inputArguments(args) {
|
|
1418
|
+
presentationOf(args.values);
|
|
1419
|
+
const [positionalName, positionalText, ...extra] = args.positionals;
|
|
1420
|
+
const values = args.values;
|
|
1421
|
+
if (extra.length || (positionalName !== undefined && values.name !== undefined) || (positionalText !== undefined && values.text !== undefined))
|
|
1422
|
+
throw new CommandFailure("refused", "USAGE_INVALID", "choose one agent and one text source: cotal input <agent> <text>, or --name and --text");
|
|
1423
|
+
const name = positionalName ?? values.name;
|
|
1424
|
+
const text = positionalText ?? values.text;
|
|
1425
|
+
if (!name?.trim() || /[\u0000-\u001f\u007f]/u.test(name))
|
|
1426
|
+
throw new CommandFailure("refused", "USAGE_INVALID", "input needs one concrete agent name without terminal control characters");
|
|
1427
|
+
if (!text)
|
|
1428
|
+
throw new CommandFailure("refused", "USAGE_INVALID", "input needs nonempty text; use --text for a value beginning with a dash");
|
|
1429
|
+
if (values.on !== undefined)
|
|
1430
|
+
onInstance(values.on, "cotal input");
|
|
1431
|
+
return { name, text };
|
|
1432
|
+
}
|
|
1180
1433
|
export async function input(args) {
|
|
1181
|
-
const
|
|
1182
|
-
|
|
1183
|
-
console.error(c.red("--name is required"));
|
|
1184
|
-
process.exit(1);
|
|
1185
|
-
}
|
|
1186
|
-
// An EMPTY --text is refused here rather than sent: the op's contract requires a non-empty
|
|
1187
|
-
// string, so sending it would spend a round trip to be told the same thing in a contract error
|
|
1188
|
-
// that names a schema instead of the flag the operator got wrong. `v.text === undefined` (flag
|
|
1189
|
-
// omitted) and `""` (flag given, empty) are the same mistake to the caller, so one message.
|
|
1190
|
-
if (!v.text) {
|
|
1191
|
-
console.error(c.red("--text is required and must not be empty"));
|
|
1192
|
-
process.exit(1);
|
|
1193
|
-
}
|
|
1434
|
+
const parsed = inputArguments(args);
|
|
1435
|
+
const v = { ...args.values, ...parsed };
|
|
1194
1436
|
const on = await pinForTarget(v, "cotal input");
|
|
1195
1437
|
const t = await resolveControlTarget(v, "control-caller-admin", on);
|
|
1438
|
+
recordOperationSpace(t.space);
|
|
1196
1439
|
const reach = t.auth.bearer ? "owner" : "any";
|
|
1197
1440
|
const reply = await askManager(t.space, t.server, "input", { name: v.name, text: v.text, enter: v["no-enter"] !== true }, t.auth, reach, undefined, { instanceId: on });
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1441
|
+
const target = { space: t.space, managerInstanceId: reply.managerInstanceId ?? on ?? null, agent: v.name };
|
|
1442
|
+
if (!reply.ok)
|
|
1443
|
+
throw managerFailure(reply, "terminal input", target);
|
|
1444
|
+
const data = reply.data;
|
|
1445
|
+
if (!data || typeof data.name !== "string" || typeof data.bytes !== "number" || !Number.isSafeInteger(data.bytes) || data.bytes < 0)
|
|
1446
|
+
throw new CommandFailure("unknown", "OPERATION_UNKNOWN", "the manager answered, but the terminal-input receipt was unreadable; the text was not sent again", { target, ...(reply.request ? { native: { detail: { request: reply.request } } } : {}) });
|
|
1447
|
+
const result = { kind: "terminal-input", name: data.name, bytes: Number(data.bytes), enterRequested: v["no-enter"] !== true, request: reply.request ?? null };
|
|
1448
|
+
writeResult(presentationOf(v), { command: "input", target, result }, (row) => ({ sections: [
|
|
1449
|
+
{ title: "Terminal input written", blocks: [{ kind: "fields", rows: [["Agent", row.name], ["Space", t.space], ["Manager", reply.managerInstanceId ?? "not attributed"], ["Bytes reported", String(row.bytes)], ["Enter requested", row.enterRequested ? "yes" : "no"]] }, { kind: "lines", lines: [{ text: "The native manager acknowledged writing to the terminal. This does not prove the application read it or completed a task. The input text is not echoed.", tone: "hint" }] }] },
|
|
1450
|
+
] }));
|
|
1201
1451
|
}
|
|
1202
1452
|
//# sourceMappingURL=agents.js.map
|