CLI Reference
This page documents the command-line tools used to manage, monitor, and maintain a Sanctum instance.
Gateway Management
Section titled “Gateway Management”The OpenClaw gateway is the core agent runtime. Always use the openclaw CLI to manage it — never use raw launchctl commands for the gateway.
Start the Gateway
Section titled “Start the Gateway”openclaw gateway startLoads the gateway LaunchAgent and starts the agent runtime on the configured port (default 18789).
Stop the Gateway
Section titled “Stop the Gateway”openclaw gateway stopGracefully shuts down the gateway, cleans up state files and port locks, then unloads the LaunchAgent.
Restart Pattern
Section titled “Restart Pattern”# Macopenclaw gateway stopopenclaw gateway start
# VMsystemctl --user restart openclaw-gateway.serviceA convenience script is also available:
~/.sanctum/scripts/gateway-restart.shAgent Commands
Section titled “Agent Commands”Send a Message to an Agent
Section titled “Send a Message to an Agent”openclaw agent --agent <agent_name> --message "<message>"| Flag | Description |
|---|---|
--agent | Agent identifier: main (Yoda), windu, quigon, cilghal, mundi, or jocasta |
--message | The message to deliver to the agent |
# Send a message to the main agent (Yoda)openclaw agent --agent main --message "Run the evening briefing"
# Send a message to the security agentopenclaw agent --agent windu --message "Generate the weekly security report"Cross-Node Agent Messaging
Section titled “Cross-Node Agent Messaging”For sending messages between Mac and VM agents, use the council bridge SSH pattern:
ssh ubuntu@10.10.10.10 \ '/home/ubuntu/.npm-global/bin/openclaw agent --agent main --message "Hello from Jocasta"'ssh bert@10.10.10.1 \ 'PATH=/Users/bert/.local/share/fnm/node-versions/v22.22.0/installation/bin:/opt/homebrew/bin:$PATH \ openclaw agent --agent main --message "Hello from Yoda"'launchctl Patterns
Section titled “launchctl Patterns”macOS uses launchctl to manage LaunchAgents and LaunchDaemons. Sanctum uses the modern bootstrap/bootout subcommands.
Load a LaunchAgent
Section titled “Load a LaunchAgent”launchctl bootstrap gui/$(id -u) ~/Library/LaunchAgents/<label>.plist# Example: load the watchdoglaunchctl bootstrap gui/$(id -u) ~/Library/LaunchAgents/com.sanctum.watchdog.plistUnload a LaunchAgent
Section titled “Unload a LaunchAgent”launchctl bootout gui/$(id -u) ~/Library/LaunchAgents/<label>.plist# Example: unload the watchdoglaunchctl bootout gui/$(id -u) ~/Library/LaunchAgents/com.sanctum.watchdog.plistCheck Agent Status
Section titled “Check Agent Status”launchctl print gui/$(id -u)/<label># Example: check if the council MLX server is runninglaunchctl print gui/$(id -u)/com.sanctum.council-mlxLoad a LaunchDaemon
Section titled “Load a LaunchDaemon”LaunchDaemons require sudo and use the system domain:
sudo launchctl bootstrap system /Library/LaunchDaemons/<label>.plistsudo launchctl bootout system /Library/LaunchDaemons/<label>.plistgenerate-plists.sh
Section titled “generate-plists.sh”Renders LaunchAgent plist files from templates using values from instance.yaml and the macOS Keychain.
~/.sanctum/generate-plists.sh [--dry-run]| Flag | Description |
|---|---|
--dry-run | Show what would be generated without writing any files |
What It Does
Section titled “What It Does”- Reads templates from
~/.sanctum/templates/launchagents/ - Checks each template’s corresponding service
enabledflag ininstance.yaml - Skips disabled services
- Expands
{{PLACEHOLDER}}tokens with config values - Retrieves secrets from the macOS Keychain using the configured
keychain_account - Writes rendered plists to
~/Library/LaunchAgents/(or/Library/LaunchDaemons/)
# Preview changes~/.sanctum/generate-plists.sh --dry-run
# Generate and install~/.sanctum/generate-plists.shrun-all.sh (Test Suite)
Section titled “run-all.sh (Test Suite)”Runs the full Sanctum test suite to verify all services, connections, and configurations.
~/.sanctum/run-all.shThe test suite checks:
- All enabled LaunchAgents are loaded and running
- Gateway is responsive on the configured port
- VM is reachable via SSH
- Bridge interface has the correct IP
- All enabled services respond on their configured ports
- Firewalla bridge can authenticate
- Home Assistant is accessible
- Cloudflare tunnel is connected
- Tailscale is connected and peers are reachable
- Node connectivity (LAN and Tailscale)
Output uses color-coded pass/fail indicators. A summary count is printed at the end.
[PASS] Gateway responding on port 18789[PASS] VM reachable at 10.10.10.10[PASS] Home Assistant at port 8123[FAIL] Kiwix server not responding on port 8888---Results: 15/16 passedwatchdog.sh
Section titled “watchdog.sh”The watchdog script runs every 600 seconds via the com.sanctum.watchdog LaunchAgent. It monitors all enabled services and attempts auto-healing via service-doctor.
~/.sanctum/watchdog.shBehavior
Section titled “Behavior”- Iterates through all services with
enabled: trueininstance.yaml - Checks each service’s health (port check, process check, or custom probe)
- If a service is unhealthy, invokes
service-doctorto attempt recovery - Logs all results to
~/.sanctum/logs/watchdog.log - Sends a notification via
sanctum_notifyif any service required healing
Manual Run
Section titled “Manual Run”Run the watchdog manually to check current health:
~/.sanctum/watchdog.shsanctum-backup.sh
Section titled “sanctum-backup.sh”Creates a backup of the Sanctum configuration and critical state files.
~/.sanctum/sanctum-backup.sh [--destination <path>]| Flag | Description |
|---|---|
--destination | Override the default backup directory (from paths.backups in config) |
What Gets Backed Up
Section titled “What Gets Backed Up”| Item | Description |
|---|---|
instance.yaml | Central configuration |
templates/ | LaunchAgent plist templates |
lib/ | Shell and Python libraries |
| Agent configs | OpenClaw/DenchClaw configuration |
| HA config | Home Assistant configuration.yaml and automations |
| VM state | Key VM configuration files (via SSH) |
| Keychain exports | Metadata only (not the actual secrets) |
# Default backup to configured path~/.sanctum/sanctum-backup.sh
# Backup to a specific location~/.sanctum/sanctum-backup.sh --destination /Volumes/External/sanctum-backupBackups are timestamped and stored as compressed archives:
~/.sanctum/backups/sanctum-backup-2026-03-19T120000.tar.gzsanctum-restore.sh
Section titled “sanctum-restore.sh”Restore a Sanctum instance from a backup archive.
~/.sanctum/sanctum-restore.sh <backup_file>| Argument | Description |
|---|---|
backup_file | Path to a .tar.gz backup archive |
~/.sanctum/sanctum-restore.sh ~/.sanctum/backups/sanctum-backup-2026-03-19T120000.tar.gzRestore Process
Section titled “Restore Process”- Validates the backup archive integrity
- Extracts to a temporary directory for review
- Shows a diff of what would change
- Prompts for confirmation before overwriting
- Restores configuration files
- Re-runs
generate-plists.shto regenerate LaunchAgents - Optionally restarts affected services
Quick Reference
Section titled “Quick Reference”| Command | Purpose |
|---|---|
openclaw gateway start | Start the Mac gateway |
openclaw gateway stop | Stop the Mac gateway |
openclaw agent --agent main --message "..." | Send a message to an agent |
~/.sanctum/generate-plists.sh | Regenerate all LaunchAgent plists |
~/.sanctum/generate-plists.sh --dry-run | Preview plist generation |
~/.sanctum/run-all.sh | Run the full test suite |
~/.sanctum/watchdog.sh | Run the health watchdog manually |
~/.sanctum/sanctum-backup.sh | Create a configuration backup |
~/.sanctum/sanctum-restore.sh <file> | Restore from a backup |
launchctl bootstrap gui/$(id -u) <plist> | Load a LaunchAgent |
launchctl bootout gui/$(id -u) <plist> | Unload a LaunchAgent |
launchctl print gui/$(id -u)/<label> | Check agent status |
systemctl --user restart openclaw-gateway | Restart VM gateway |