Daemon Setup
Longshot connects to the cloud by default so you can control your agent from anywhere. Here's how it works and how to manage multiple machines.
How it works
When you run longshot, it connects to the Longshot proxy via a persistent WebSocket tunnel. No local web server is started — requests from your phone are routed directly through the tunnel to the CLI process.
Phone → https://app.longshothq.com → Proxy → WebSocket → Your CLI
Your code never leaves your machine. The proxy forwards requests between your browser and your CLI — it doesn't store, cache, or inspect your code.
Automatic setup
Every time you run longshot on a new machine, it authenticates and registers automatically:
- Opens a browser for you to log in (or create an account)
- Registers the CLI as a new daemon on your account
- Saves the auth token to
~/.longshot/auth.json - Connects to the proxy and shows the URL to open on your phone
That's it. No manual token copying, no dashboard setup. Just run longshot on any machine and it handles the rest.
Multiple machines
Run longshot on each machine. Each one goes through the same automatic auth flow and appears as a separate daemon on your Dashboard.
The daemon is named after the machine's hostname by default. Your dashboard shows all connected CLIs with online/offline status. Tap any one to access its mobile UI.
--token or set LONGSHOT_TOKEN if you need to automate setup (e.g. CI environments).
Local-only mode
If you don't need remote access, use the --local flag to skip the proxy:
longshot --local
This starts a local web server at http://localhost:3333. Access it from any device on the same network.
Auth configuration priority
The CLI reads auth credentials in this order (first found wins):
- CLI flags (
--token,--proxy-url) - Environment variables (
LONGSHOT_TOKEN,LONGSHOT_PROXY_URL) - Config file (
~/.longshot/auth.json)
Auto-reconnect
If the connection drops, the CLI automatically reconnects with exponential backoff (1s → 2s → 4s → ... → max 30s). You don't need to restart it.
CLI reference
longshot [options]
Options:
-d, --dir <path> Project root directory (default: cwd)
-l, --local Local-only mode — start a web server, skip proxy
-p, --port <number> Port for local web server (default: 3333, --local only)
--proxy-url <url> Proxy WebSocket URL (custom proxy)
--token <token> Auth token (overrides auth.json)
-h, --help Show help
-v, --version Show version