pub const CONNECT: &str = "# zag connect\n\nConnect to a remote zag server.\n\n## Synopsis\n\n zag connect <url> [flags]\n\n## Description\n\nConnects to a remote zag server and saves the connection configuration. Once connected, all subsequent zag commands transparently proxy through the remote server until `zag disconnect` is called.\n\nIf the URL does not include a scheme, `https://` is automatically prepended.\n\nThe connection state is stored in `~/.zag/connect.json`. While connected, commands like `zag spawn`, `zag status`, `zag listen`, `zag session list`, and others are forwarded to the remote server\'s REST/WebSocket API.\n\nzag supports two authentication modes against a remote server:\n\n- **Bearer token** \u{2014} a shared token configured with `zag serve --generate-token` (or the `ZAG_SERVE_TOKEN` env var). The client passes it with `--token` or the `ZAG_CONNECT_TOKEN` env var. All commands run with the server\'s default filesystem root.\n- **User account** \u{2014} per-user credentials managed by `zag user add` on the server. The client passes `--username` / `--password`, and the server jails all commands to the user\'s configured home directory.\n\n`--token` and `--username` are mutually exclusive.\n\n## Arguments\n\n url Server URL (e.g., home.local:2100 or https://home.local:2100)\n\n## Flags\n\n --token <TOKEN> Authentication token (or set ZAG_CONNECT_TOKEN env var)\n -u, --username <NAME> Username for user-account authentication\n --password <PASSWORD> Password for user-account authentication\n (prompted interactively if omitted)\n\n## Health Check\n\nBefore proxying each command, zag pings the remote server\'s health endpoint to verify it is reachable. If the server is unreachable, zag automatically disconnects and runs the command locally, printing a warning to stderr. The health check result is cached for 30 seconds to avoid adding latency on every invocation.\n\nTo disable this behavior, use the `--no-health-check` global flag or set the `ZAG_NO_HEALTH_CHECK=1` environment variable:\n\n zag --no-health-check status <session-id>\n\n## Commands That Work Remotely\n\n zag spawn Spawn a session on the remote machine\n zag status Check session status\n zag events Query session events\n zag listen Stream session events in real-time (via WebSocket)\n zag subscribe Subscribe to all session events\n zag cancel Cancel a session\n zag collect Collect results\n zag wait Wait for sessions to complete\n zag output Get session output\n zag session list List sessions\n zag session show Show session details\n zag ps List processes\n zag input Send a message to a session\n\n## Commands That Always Run Locally\n\n zag serve Start a local server\n zag connect Connect to a server\n zag disconnect Disconnect from a server\n zag run Interactive sessions (local only)\n zag exec Non-interactive execution (local only)\n zag config Local configuration\n\n## Examples\n\n # Connect with a bearer token (https:// auto-prepended)\n zag connect home.local:2100 --token mysecrettoken\n\n # Connect with explicit scheme\n zag connect https://home.local:2100 --token mysecrettoken\n\n # Connect as a user account (password prompted)\n zag connect home.local:2100 -u alice\n\n # Connect as a user account with inline password\n zag connect home.local:2100 -u alice --password hunter2\n\n # Now all commands proxy through the remote server\n zag spawn \"write tests for auth module\"\n zag listen --latest\n zag session list\n\n # Spawn an interactive session on the remote machine\n sid=$(zag spawn --interactive --name worker -p claude)\n zag input --name worker \"analyze the auth module\"\n zag listen --name worker\n\n # Disconnect when done\n zag disconnect\n\n## See Also\n\n zag man serve Start the zag HTTPS/WebSocket server\n zag man user Manage user accounts on the server\n";