Run a Locally Hosted LLM to Automate Your Computer: Setup to Remote Control
This guide walks through building a local AI agent that uses a locally hosted large language model to control a computer. It covers the three-layer architecture (model inference, scheduling and execution, interaction and feedback), the recommended Node.js runtime, and permission differences across Linux, macOS, and Windows. You will also find steps for installing and initializing the clawdbot CLI, verifying that the agent actually executes commands through observability logs, connecting Telegram for remote tasks, and applying security boundaries such as sandboxing, command whitelists, auditing, and confirmation for high-risk actions. A troubleshooting table for common issues is included.
1. Core Architecture: Making a Locally Hosted LLM Take Action
Traditional LLMs typically operate in an “input text, output text” loop. A local AI agent connects the model to a system call layer: the model understands the task and breaks it into steps, while the execution layer calls the shell, reads and writes files, drives a browser, or simulates keyboard and mouse input for GUI interaction.
A three-layer architecture is recommended:
| Layer | Responsibility | Common Components |
|---|---|---|
| Model inference | Understand natural language, generate tool calls | Local Ollama, Qwen, Llama, GLM, etc. |
| Scheduling and execution | Parse actions, run commands, return results | Daemon, task queue, Function Calling |
| Interaction and feedback | Receive instructions, display results | TUI, Web Console, Telegram, mobile |
An agent is essentially “model + tool calling + permission control.” For example, when a user says “check disk space,” the model does not fabricate an answer. It generates a df -h action, the execution layer runs the command, and the standard output is returned to the model to produce the final response.
2. Runtime Environment: Node.js Version, Permissions, and Command Differences
2.1 Recommended Node.js Version
Node.js 22+ is a reasonable runtime choice, but whether version 22 is mandatory depends on the framework and dependencies. If the documentation requires 22, pin that version explicitly; if the project runs on 18 or 20, lock the dependency versions instead.
On Linux and macOS, use nvm to pin the version:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bashsource ~/.bashrcnvm install 22nvm use 22node -v
The output should show v22.x.x or higher. On Windows, install the LTS release from the official website, then verify with node -v and npm -v.
2.2 Permissions and OS Differences
By default, the agent should run as a least-privilege user. Running as root, administrator, or a privileged daemon for extended periods is not recommended.
- Linux: if a command such as
apt updateis genuinely required, configure asudo -nallowlist for that single command rather than opening a full root shell. - macOS: to read protected directories, grant the terminal “Full Disk Access” in system settings, but only for the account the agent actually runs under.
- Windows: prefer WSL2 to reduce issues from mixing PowerShell and Bash commands.
- Browser launch commands differ:
openon macOS,xdg-openon Linux, andstarton Windows.
3. Installing the clawdbot CLI and Initializing
Using the clawdbot CLI as an example, the install command is:
# Linux / macOScurl -fsSL https://molt.bot/install.sh | bash
Confirm the download source is trusted before installing. For production, review the script first, pin a version, or use an offline package.
On Windows, the official script can be run in an elevated PowerShell session, but reviewing the script before installing is still recommended.
Initialize:
clawdbot onboardclawdbot onboard --install-daemon
If your version does not support --install-daemon, register the daemon manually:
- Linux: use systemd, run the service as a regular user, and set
Restart=on-failure. - macOS: use launchd, and avoid writing plaintext tokens in the Plist.
- Windows: use a Windows Service or Task Scheduler with least privilege.
The onboarding wizard lets you choose a model provider. If the device must operate offline or sits on an internal network, prefer a local model. If you use a cloud model, make sure it is reachable and store the API key in a protected .env file or the system keychain.
4. Interaction Test: Verifying the Agent Really Executes
In the TUI or Web Console, enter:
Check the remaining disk space
The expected flow is:
- The model identifies the intent;
- It generates
df -hor an equivalent command; - The scheduling layer executes the command;
- stdout, stderr, exit code, and duration are returned;
- The model produces a natural-language summary.
To confirm the answer is not fabricated, enable minimal observability logging that records at least:
tool=execcommand=df -hexit_code=0duration_ms=86output_hash=...
The command, exit code, duration, and result summary together show whether the agent actually invoked the system.
5. Telegram Remote Control: Meeting Reachability Conditions First
Connecting the agent to Telegram lets you send tasks from your phone. Create a bot:
- Search for
@BotFatherin Telegram; - Send
/newbot; - Set the bot name and username;
- Save the HTTP API token.
Note that a Telegram bot is not an intranet penetration solution. The device running the agent must be able to reach the Telegram API.
- For testing on the same LAN, connect directly to the local console;
- For cross-network remote access, use a secure channel such as a reverse tunnel, Tailscale, or FRP;
- Do not expose port 3000 directly to the public internet;
- Never write the token in plaintext into logs, screenshots, or a Git repository.
Add a Telegram channel in the Web Console, enter the token, and send a test command. High-risk commands should still require confirmation.
6. Security Boundaries: Sandboxing, Allowlists, Auditing, and Confirmation
Because the agent can execute commands, treat it as a high-privilege automation system.
Recommended baseline controls:
| Risk | Control |
|---|---|
| Accidental file deletion | Restrict the working directory to /sandbox; block commands like rm -rf / and disk formatting |
| Privilege abuse | Isolate the agent with a regular user, container, or chroot |
| Runaway commands | Configure a command allowlist permitting only necessary commands such as df, ls, curl, and open |
| Key leakage | Put API keys in .env, set chmod 600, and never commit to Git |
| No audit trail | Log the command, arguments, user, time, exit code, and result summary |
| Model hallucination | Add a second confirmation for high-risk actions such as deletion, transfers, deployment, and restarts |
A container example:
services:agent:user: "1000:1000"read_only: truenetwork_mode: nonevolumes:- ./sandbox:/sandbox
If network access is required, open only the necessary domains or a proxy instead of granting full network access by default. Logs should define access permissions, retention, and redaction rules — for example, admin-only read access, 7 to 30 days retention, and no plaintext tokens.
7. Troubleshooting
| Problem | Likely Cause | How to Check |
|---|---|---|
command not found: clawdbot |
PATH not loaded | source ~/.zshrc, then which clawdbot |
| Node version mismatch | nvm did not switch versions | node -v, nvm use 22 |
| Model timeout | External network unreachable or proxy error | curl -I https://api.example.com, check HTTPS_PROXY |
| Daemon not running | systemd/launchd not registered | systemctl status, launchctl list |
| Telegram unresponsive | Wrong token or missing channel permission | Check the bot token, channel permissions, and persisted config |
| Console port conflict | Port 3000 in use | lsof -i:3000, change the configured port |
| Auth failure | API key expired or insufficient permissions | Regenerate the key, check billing/project permissions |
Conclusion
Running a locally hosted LLM to automate a computer is about more than making AI “chat.” It is about completing real tasks in a controlled environment. A practical setup needs three things: a model that understands, tools that can execute, and permissions that can be audited. For developers, the path is to get the minimal loop working first, then add remote channels, sandbox isolation, command allowlists, and log auditing step by step to balance efficiency and safety.
