Guida - AI & Automazione

Come eseguire l'agente AI OpenClaw 24/7 su un Mac Mini

OpenClaw è un agente AI open source che automatizza attività via WhatsApp, Telegram, Discord e altro, basato su Claude o GPT. Un Mac Mini M4 è l'host always-on ideale: elaborazione locale su Apple Silicon, zero sovrapprezzi GPU e un costo fisso di 85 $/mese.

25 min di lettura Aggiornato il 28 settembre 2026

1. Perché eseguire OpenClaw su un Mac Mini?

I provider di VPS cloud fatturano in base al tempo di calcolo e aggiungono sovrapprezzi GPU per l'inferenza AI. Un Mac Mini M4 ti offre Apple Silicon dedicato a un costo fisso di 85 $/mese, nessuna sorpresa a consumo, accesso SSH completo e la possibilità di eseguire LLM locali insieme a OpenClaw con un costo di inferenza quasi nullo.

Caratteristica VPS cloud (tier AI) Mac Mini M4 (MyRemoteMac)
Costo mensile Prezzo tier GPU (variabile) 85 $/mese (tariffa fissa)
Supporto LLM locale Costo extra / limitato Nativo (Ollama, llama.cpp)
Disponibilità always-on Sì Sì (SLA 99,9%)
Integrazioni Apple Nessuna iMessage, Shortcuts, Automator
Complessità di configurazione Media Bassa (accesso SSH incluso)
Privacy Datacenter condiviso Hardware dedicato

Vantaggio chiave: A differenza di un VPS cloud, il tuo Mac Mini M4 esegue Ollama o llama.cpp nativamente su Apple Silicon. Puoi indirizzare OpenClaw a un LLM locale per attività sensibili, poi ripiegare su Claude per query complesse, il tutto senza pagare per token.

2. Prerequisiti

Prima di iniziare, assicurati di avere quanto segue:

  • Un server Mac Mini M4 (da 85 $/mese) o un Mac mini M6 (da 149 $/mese) di MyRemoteMac
  • Accesso SSH al tuo Mac Mini (incluso nel tuo abbonamento MyRemoteMac)
  • Una chiave API Anthropic (per Claude), ottienila su console.anthropic.com
  • Un account di messaggistica su Telegram, Discord o WhatsApp per collegare il tuo agente
  • Familiarità di base con i comandi da terminale e con la modifica di un file di configurazione JSON5 (~/.openclaw/openclaw.json)

3. Passo 1: Connettiti al tuo Mac Mini e installa Node.js

Per prima cosa, connettiti al tuo Mac Mini M4 via SSH. Hai ricevuto le tue credenziali quando hai configurato il tuo server MyRemoteMac.

Connettiti via SSH

# Connect to your Mac Mini M4
ssh admin@your-server-ip

# Verify you're on Apple Silicon
uname -m
# Expected output: arm64

# Check macOS version (official Node.js 24/26 macOS binaries need macOS 13.5+)
sw_vers
# ProductName:    macOS
# ProductVersion: 15.4

Installa Node.js con Homebrew

# Install Node.js 26 with Homebrew (documented method on macOS)
# Homebrew missing? /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
brew install node

# Must print v26.x (or v24.16+). Node 22, 23 and 25 are unsupported.
node --version
# v26.x.x
npm --version

Installa una versione supportata di Node.js (26.1+ o 24.16+)

OpenClaw richiede Node.js 26.1+ (consigliato) o 24.16+, Node 22, 23 e 25 non sono supportati dalla release 2026.9.3. Homebrew è il metodo documentato su macOS. Se preferisci nvm, installa Node 26 (mai --lts) e assicurati che nvm sia inizializzato in ~/.zshrc, altrimenti openclaw non sarà nel tuo PATH:

# Prefer nvm? Target Node 26: never --lts
nvm install 26
nvm alias default 26

# nvm must be initialised in ~/.zshrc, otherwise `openclaw` is not on PATH in new sessions
echo 'export NVM_DIR="$HOME/.nvm"; [ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"' >> ~/.zshrc

Verifica l'installazione

# Confirm Node.js is running on Apple Silicon
node -e "console.log(process.platform, process.arch)"
# darwin arm64

4. Passo 2: Installa OpenClaw e configura la chiave API Claude

Con Node.js pronto, installa la CLI di OpenClaw globalmente, non esiste un'installazione locale al progetto. OpenClaw viene distribuito come pacchetto npm openclaw; è disponibile anche un installer in una riga (openclaw.ai/install.sh) che installa Node 26 al posto tuo se manca.

Installa OpenClaw

# Option A: one-line installer (provisions Node 26 if missing, then launches the wizard)
curl -fsSL https://openclaw.ai/install.sh | bash
# (append `-s -- --no-onboard` to skip the wizard)

# Option B: global npm install (you manage Node)
npm install -g openclaw@latest --allow-scripts=openclaw
# omit --allow-scripts on npm <= 11.15

openclaw --version
# 2026.9.6

Esegui la procedura guidata di onboarding

OpenClaw legge le sue impostazioni da ~/.openclaw/openclaw.json (JSON5). Non scriverlo a mano: la procedura guidata di onboarding lo crea, chiede la tua chiave API Anthropic, verifica l'accesso ai modelli e registra il servizio launchd in un unico passaggio:

# Onboarding wizard + launchd service in one go
openclaw onboard --install-daemon

# Non-interactive over SSH (key from console.anthropic.com):
export ANTHROPIC_API_KEY="sk-ant-YOUR_API_KEY_HERE"
openclaw onboard --anthropic-api-key "$ANTHROPIC_API_KEY" --install-daemon

# Choose the default Claude model (provider/model format)
openclaw models set anthropic/claude-sonnet-5
# cheaper: openclaw models set anthropic/claude-haiku-4-5
openclaw models status

# Settings now live in ~/.openclaw/openclaw.json (JSON5). After any hand edit:
openclaw doctor --fix

Incolla la tua chiave da console.anthropic.com quando la procedura guidata la richiede (oppure passala con --anthropic-api-key). Gli id dei modelli richiedono il prefisso del provider: usa anthropic/claude-sonnet-5 per attività complesse o anthropic/claude-haiku-4-5 per risposte più veloci ed economiche, il valore predefinito di OpenClaw su una nuova installazione è anthropic/claude-opus-5-5.

Verifica il Gateway e invia un primo messaggio

# Check the Gateway service installed by --install-daemon
openclaw gateway status
# Runtime: running
# Connectivity probe: ok

# Send a first message through the running Gateway
openclaw agent --agent main --message "Hello, are you alive?"

# Control UI from your laptop, the Gateway stays loopback-only on 127.0.0.1:18789
ssh -N -L 18789:127.0.0.1:18789 admin@your-server-ip
# then open http://127.0.0.1:18789 (or run `openclaw dashboard` over VNC)

5. Passo 3: Collega i canali di messaggistica

OpenClaw supporta Telegram, Discord, WhatsApp, iMessage, Slack, Signal, Microsoft Teams, Google Chat e oltre 20 altri canali. Telegram è incluso di serie ed è il più rapido da far funzionare, crea un bot tramite @BotFather, aggiungi il token, poi approva il tuo primo DM con il codice di pairing che il bot ti rimanda:

# Step 1: Open Telegram and search for @BotFather
# Step 2: Send /newbot and follow the prompts
# Step 3: Copy the token (format: 1234567890:AAF...)

# Test your bot token is valid:
curl -s "https://api.telegram.org/botYOUR_TOKEN/getMe"
# {"ok":true,"result":{"id":...,"first_name":"My Agent","username":"myagent_bot",...}}

# Add the channel (Telegram is bundled: nothing to install)
openclaw channels add --channel telegram --token YOUR_TELEGRAM_BOT_TOKEN
openclaw channels status --probe

# DM your bot once: it answers with a pairing code. Approve it:
openclaw pairing approve telegram <CODE>

# Groups: disable Privacy Mode via BotFather (/setprivacy) or make the bot a group admin

Collega Discord

Per collegare un bot Discord, crea un'applicazione nel Discord Developer Portal, abilita il Message Content Intent (obbligatorio) e invitalo con gli scope bot + applications.commands. Installa il plugin ufficiale, fai riferimento al token tramite la variabile d'ambiente DISCORD_BOT_TOKEN e approva il tuo primo DM:

# In Discord Developer Portal (https://discord.com/developers/applications):
# 1. Create a New Application and give it a name
# 2. Open the Bot page, click Reset Token and copy the token (despite the name, it creates your first token)
# 3. Enable "Message Content Intent" (required) and "Server Members Intent" (recommended)
# 4. Under OAuth2 > URL Generator select scopes bot + applications.commands,
#    permissions View Channels, Send Messages, Read Message History, Embed Links, Attach Files
# 5. Use the generated URL to invite the bot to your server

# Install the official plugin and reference the token from an env var
openclaw plugins install @openclaw/discord
cat > ./discord.patch.json5 << 'EOF'
{ env: { vars: { DISCORD_BOT_TOKEN: "YOUR_DISCORD_BOT_TOKEN" } },
  channels: { discord: { enabled: true, token: { source: "env", provider: "default", id: "DISCORD_BOT_TOKEN" } } } }
EOF
openclaw config patch --file ./discord.patch.json5
rm ./discord.patch.json5   # the token now lives in ~/.openclaw/openclaw.json: do not leave a copy behind

# Approve your first DM
openclaw pairing approve discord <CODE>

# WhatsApp (optional, QR login, do it over VNC, use a separate number):
# openclaw plugins install @openclaw/whatsapp && openclaw channels login --channel whatsapp

6. Passo 4: Esegui come servizio launchd persistente

Per il funzionamento 24/7, il Gateway di OpenClaw deve avviarsi automaticamente all'avvio del sistema e riavviarsi in caso di errore. OpenClaw se ne occupa da solo: openclaw gateway install (o il flag --install-daemon del Passo 2) registra un LaunchAgent launchd supervisionato chiamato ai.openclaw.gateway in ~/Library/LaunchAgents/, non scrivere mai il plist a mano.

Installa il servizio Gateway

Se hai saltato --install-daemon nel Passo 2, registra il servizio adesso. Poi disattiva lo sleep di macOS in modo che il Gateway sopravviva alle cadute di rete causate dallo sleep di manutenzione (raccomandazione ufficiale):

# Register the supervised LaunchAgent ai.openclaw.gateway
# (skip if you already ran `openclaw onboard --install-daemon`)
openclaw gateway install

# The plist lives at ~/Library/LaunchAgents/ai.openclaw.gateway.plist: do not edit it by hand

# Keep the Mac awake: avoids maintenance-sleep network flaps (official recommendation)
sudo pmset -a sleep 0 disksleep 0 standby 0 powernap 0

Gestisci il servizio

openclaw gateway status --deep   # CLI vs service version, port, runtime
openclaw gateway restart         # never chain `stop` + `start` as a restart
openclaw gateway stop            # add --disable to keep it off across reboots
openclaw gateway install --runtime node --force   # retarget the service after a Node.js change

Verifica che il servizio sia in esecuzione

openclaw gateway status
# Runtime: running
# Connectivity probe: ok
openclaw gateway health

# Live logs
openclaw logs --follow
# Files: /tmp/openclaw/openclaw-YYYY-MM-DD.log and ~/Library/Logs/openclaw/gateway.log

# Raw launchd view (troubleshooting only)
launchctl print gui/$UID/ai.openclaw.gateway

Aggiorna OpenClaw

# Back up your state first (automatic config copies are not a full backup)
cp -R ~/.openclaw ~/openclaw-backup-$(date +%F)

# Update: stages the package, validates config, runs doctor, restarts the Gateway
openclaw update
openclaw doctor
openclaw gateway restart
openclaw health

# Prefer the LTS-equivalent line (currently 2026.7.35):
# openclaw update --channel extended-stable

7. Risoluzione dei problemi comuni

Il Gateway rifiuta di avviarsi o segnala una versione non corrispondente

Un ~/.openclaw/openclaw.json non valido (basta una sola chiave sconosciuta) fa sì che il Gateway rifiuti di avviarsi, e un cambio di Node.js può lasciare la CLI e il servizio su versioni diverse. Esegui la diagnostica integrata e ripara il servizio:

# Validate and auto-repair the config
openclaw doctor --fix

# CLI vs service version skew
openclaw gateway status --deep
openclaw logs --follow

# Re-register the service on the new Node.js after a runtime change
openclaw gateway install --runtime node --force

L'API Claude restituisce 401 Unauthorized

La tua chiave API manca, è errata o il tuo account Anthropic non ha crediti residui. Controlla prima lo stato del provider da OpenClaw, poi se necessario testa la chiave direttamente:

# Check provider auth from OpenClaw
openclaw models status
openclaw doctor

# Optional: test the key directly
curl https://api.anthropic.com/v1/messages \
  -H "x-api-key: YOUR_API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -H "content-type: application/json" \
  -d '{"model":"claude-haiku-4-5","max_tokens":10,"messages":[{"role":"user","content":"Hi"}]}'

# Expected: {"id":"msg_...","type":"message",...}
# If you get 401: check your key at console.anthropic.com

Il bot Telegram smette di rispondere

Il token del bot potrebbe essere stato revocato, il tuo DM potrebbe essere ancora in attesa dell'approvazione del pairing, oppure il Gateway si è fermato. Verifica il canale, approva i pairing in sospeso e riavvia:

# Verify the bot token is still valid
curl -s "https://api.telegram.org/botYOUR_TOKEN/getMe"

# Probe the channel and approve any pending pairing
openclaw channels status --probe
openclaw pairing approve telegram <CODE>

# Restart the Gateway
openclaw gateway restart

# If the token was revoked, generate a new one via @BotFather (/mybots > API Token)

Il bot smette di rispondere dopo qualche ora su macOS

Lo sleep di manutenzione di macOS può far cadere la rete (ENETDOWN) e mettere a tacere i canali finché non tocchi il Mac. Disattiva lo sleep, controlla i log di stabilità, tieni d'occhio gli avvisi di pressione sulla memoria e aggiungi il watchdog launchd ufficiale:

# Disable macOS maintenance sleep (ENETDOWN network flaps)
sudo pmset -a sleep 0 disksleep 0 standby 0 powernap 0

# Stability logs and memory-pressure warnings
ls ~/.openclaw/logs/stability/
grep -i "memory pressure" /tmp/openclaw/openclaw-$(date +%F).log

# Official liveness watchdog: re-arm launchd's respawn gate
launchctl kickstart -k gui/$UID/ai.openclaw.gateway

8. Analisi dei costi vs. VPS cloud

Ecco un confronto realistico dei costi per eseguire un agente AI 24/7 a diversi livelli di utilizzo:

Caso d'uso Chiamate AI/mese Costo VPS cloud Costo MyRemoteMac Risparmio mensile
Assistente personale ~500 chiamate 120 $/mese (VPS GPU base) 85 $/mese 45 $/mese
Bot per piccolo team ~5.000 chiamate 200 $/mese 85 $/mese 125 $/mese
LLM locale + agente Illimitate (locale) 350+ $/mese (VPS GPU) 85 $/mese 275+ $/mese
Sistema multi-agente 10.000+ chiamate 600+ $/mese 229 $/mese (M4 Pro) 371+ $/mese

In sintesi: Eseguire OpenClaw su un Mac Mini M4 è notevolmente più economico di un VPS cloud GPU. Ottieni anche Apple Silicon nativo per LLM locali tramite Ollama, indirizza le attività non sensibili a un modello locale (openclaw models set ollama/gemma4) e punta l'heartbeat integrato da 30 minuti su anthropic/claude-haiku-4-5 per mantenere bassa la bolletta API a riposo.

Fonti (documentazione ufficiale di OpenClaw)

Guide correlate

Pronto a eseguire il tuo agente AI 24/7?

Distribuisci un Mac Mini M4 dedicato come tuo host OpenClaw. A partire da 85 $/mese.

Cerchi maggiori dettagli?

Consulta la documentazione completa per guide passo passo, riferimenti di configurazione e risoluzione dei problemi.

Apri la documentazione →