Daemon & Portal Chat
Keep the agent always-on so your web portal can reach your servers in real time — no terminal open required.
What the daemon is
sudoji daemon opens a persistent WebSocket from your server to the Sudoji cloud hub (agent.sudoji.io). While it is running:
┌──────────────────────┐ ┌───────────────────────────┐
│ Your Browser │ │ Your Linux Server │
│ │ │ │
│ sudoji.io/sessions │ │ $ sudoji daemon │
│ (portal chat UI) │ │ │
└──────────┬───────────┘ └─────────────┬─────────────┘
│ POST /portal/threads │ WebSocket
│ Bearer: Supabase JWT │ /v1/daemon
▼ ▼
┌────────────────────────────────────────────────────────────┐
│ agent.sudoji.io │
│ │
│ • Verifies JWT / API key │
│ • Checks plan + credits │
│ • Routes portal message → daemon WS │
│ • Writes thread_messages to Supabase │
│ • Supabase Realtime notifies portal UI │
└────────────────────────────────────────────────────────────┘
Requirements
Starting the daemon
Foreground (testing)
Run directly to see the banner and connection logs. Press Ctrl-C to stop.
Running under PM2 (recommended — no second SSH session needed)
For production servers, run the daemon under PM2 so it survives reboots, auto-restarts on crash, and requires no open terminal session.
pm2 startup, copy and run the command it outputs (e.g. sudo env PATH=... pm2 startup systemd -u ubuntu --hp /home/ubuntu). That registers pm2 itself with systemd so it starts on boot and restores all saved processes — including the daemon.Running under systemd
SUDOJI_NO_KEYCHAIN=1 in the service environment when there is no interactive user session — systemd and pm2 service contexts have no D-Bus or GNOME Keyring session to attach to.Sending messages from the portal
Once the daemon is running, go to sudoji.io/dashboard/sessions and select a conversation thread. If the daemon is online for that server you will see ● daemon online in the thread header and the send bar becomes active.
Type a message and press Enter or click Send. The flow is:
sudoji daemon on the server to process messages." You can keep sending — messages queue in the thread and the daemon will process them once it reconnects.What the agent can do from the portal
The agent mode is set when a thread is created (from sudoji chat --mode <mode>) and controls what the agent is allowed to do when it handles your messages:
sudoji chat terminal session to execute it.Terminal chat: sudoji chat
sudoji chat is the terminal-side companion to the portal. It opens an interactive REPL where you type messages and receive streamed responses — but unlike sudoji ask the conversation history is preserved across turns, so the agent can refer back to what it read and found earlier.
Every session is automatically assigned a generated name (like Brave Falcon) and saved as a thread. The thread is immediately visible in the portal Sessions → Chat tab, and you can rename it from the portal by clicking the title. If the daemon is running, the same thread is also reachable from the portal for sending follow-up messages from the web.
Conversation threads
A thread is a stored multi-turn conversation. It records every message (user and assistant), tool calls made, and the cumulative token cost. Threads are associated with a specific server and visible in the portal.
Troubleshooting
Daemon won't connect
Run sudoji doctor to confirm your API key and network are working. Check that port 443 outbound to agent.sudoji.io is open. If behind a proxy, the proxy must support WebSocket upgrades (HTTP CONNECT tunnelling).
daemon.rejected: PLAN_INSUFFICIENT
Your account is on the Free plan. Upgrade to Engineer at sudoji.io/pricing to use the daemon.
daemon.rejected: SERVER_LIMIT
Engineer plan allows one connected daemon at a time. If you have the daemon running on multiple servers simultaneously, only the first one within the limit will be accepted. Enterprise plan removes this restriction.
Portal shows daemon offline after reconnect
The daemon updates the server's daemon_status column on connect and on disconnect. If a crash left the record stale, it will be corrected as soon as the daemon reconnects. Refresh the portal after reconnect to see the updated status.