### Quick Start Commands Source: https://github.com/alexrudloff/clawchat/blob/main/SKILL.md Initialize a gateway, start the daemon, send a message, and check the inbox. ```bash # Initialize (creates identity + starts daemon) clawchat gateway init --port 9200 --nick "mybot" # Start daemon clawchat daemon start # Send a message clawchat send stacks:ST1ABC... "Hello!" # Check inbox clawchat inbox ``` -------------------------------- ### Install ClawChat Source: https://github.com/alexrudloff/clawchat/blob/main/SKILL.md Clone the repository, install dependencies, build, and link the CLI globally. ```bash git clone https://github.com/alexrudloff/clawchat.git cd clawchat npm install && npm run build && npm link ``` -------------------------------- ### Quick start: gateway init, daemon start, peers add, send, recv Source: https://github.com/alexrudloff/clawchat/blob/main/README.md Initialize a gateway, start the daemon, add a peer, send a message, and check for replies. Save the seed phrase displayed during init; it's the only backup. All identities must use the same network (testnet ST... or mainnet SP...). ```bash # 1. Initialize gateway mode (creates first identity) clawchat gateway init --port 9000 --nick "alice" --testnet # IMPORTANT: Save the seed phrase displayed - it's your only backup! # 2. Start the daemon (enter password when prompted) clawchat daemon start # 3. Add a peer (use full multiaddr with peerId for P2P) # Get peerId from: clawchat daemon status (on target machine) clawchat peers add stacks:ST1PQHQKV... /ip4/192.168.1.100/tcp/9000/p2p/12D3KooW... --alias "Bob" # 4. Send a message (can use alias or full principal) clawchat send Bob "Hello!" # 5. Check for replies (wait up to 30 seconds) clawchat recv --timeout 30 ``` -------------------------------- ### Clone and install ClawChat Source: https://github.com/alexrudloff/clawchat/blob/main/CONTRIBUTING.md Clones the ClawChat repository, navigates into the project directory, and installs dependencies. ```bash git clone https://github.com/alexrudloff/clawchat.git cd clawchat npm install ``` -------------------------------- ### Install ClawChat globally with npm Source: https://github.com/alexrudloff/clawchat/blob/main/skills/clawchat/SKILL.md Install dependencies, build the project, and link it globally using npm. Run from the cloned repository directory. ```bash cd ~/clawchat # Or wherever you cloned the repository npm install npm run build sudo npm link ``` -------------------------------- ### Install ClawChat Source: https://github.com/alexrudloff/clawchat/blob/main/QUICKSTART.md Clones the ClawChat repository, installs dependencies, and builds the project. Requires Node.js 18+ and npm. ```bash git clone https://github.com/alexrudloff/clawchat.git cd clawchat npm install npm run build ``` -------------------------------- ### Start daemon with password file Source: https://github.com/alexrudloff/clawchat/blob/main/REFERENCE.md Start the daemon with a password file when you see the "Daemon not running" error. The password file is expected at ~/.clawchat/password. ```bash clawchat daemon start --password-file ~/.clawchat/password ``` -------------------------------- ### Verify clawchat installation Source: https://github.com/alexrudloff/clawchat/blob/main/REFERENCE.md Verify the installation by checking the version and viewing help information for the clawchat CLI. ```bash clawchat --version clawchat --help ``` -------------------------------- ### Multi-Agent Setup Commands Source: https://github.com/alexrudloff/clawchat/blob/main/SKILL.md Add another identity and send/check messages as that identity. ```bash # Add another identity clawchat gateway identity add --nick "agent2" # Send as specific identity clawchat send stacks:ST1ABC... "Hello from agent2" --as agent2 # Check inbox for specific identity clawchat inbox --as agent2 ``` -------------------------------- ### Start ClawChat Daemon on Boot (macOS) Source: https://github.com/alexrudloff/clawchat/blob/main/skills/clawchat/SKILL.md Copies the ClawChat daemon plist to the user's LaunchAgents directory and loads it with launchctl to start the daemon on boot for macOS. Adjust the source path as needed. ```bash cp /Users/cora/clawchat/com.clawchat.daemon.plist ~/Library/LaunchAgents/ launchctl load ~/Library/LaunchAgents/com.clawchat.daemon.plist ``` -------------------------------- ### Set Up ClawChat Daemon Source: https://github.com/alexrudloff/clawchat/blob/main/skills/clawchat/OPENCLAW-INTEGRATION.md Creates a ClawChat identity and starts the daemon on port 9100. Use launchd for persistence. ```bash # Create identity clawchat identity create --password-file ~/.clawchat/password # Start daemon (use launchd for persistence) clawchat daemon start --password-file ~/.clawchat/password --port 9100 ``` -------------------------------- ### Start ClawChat daemon with --openclaw-wake Source: https://github.com/alexrudloff/clawchat/blob/main/skills/clawchat/OPENCLAW-INTEGRATION.md Starts the ClawChat daemon with the --openclaw-wake flag to automatically trigger `openclaw system event` when messages arrive. Requires the OpenClaw CLI to be installed; daemon logs errors if openclaw is unavailable but does not crash. ```bash clawchat daemon start --password-file ~/.clawchat/password --port 9000 --openclaw-wake ``` -------------------------------- ### Start and Verify ClawChat Daemon Source: https://github.com/alexrudloff/clawchat/blob/main/QUICKSTART.md Starts the ClawChat daemon (prompts for password) and verifies it is running with the status command. ```bash # Start (will prompt for password) npx clawchat daemon start # Verify it's running npx clawchat daemon status ``` -------------------------------- ### Install clawchat from source Source: https://github.com/alexrudloff/clawchat/blob/main/REFERENCE.md Install clawchat from source. Requires Node.js 18+ and npm. The npm link command makes the 'clawchat' command available globally. ```bash git clone https://github.com/alexrudloff/clawchat.git cd clawchat npm install npm run build npm link # Makes 'clawchat' available globally ``` -------------------------------- ### Install clawchat launchd plist with sed substitutions Source: https://github.com/alexrudloff/clawchat/blob/main/REFERENCE.md Installs the launchd plist for the clawchat daemon by substituting the clawchat binary path and home directory placeholders. This is the second step for running clawchat as a macOS service. ```bash # Copy and customize the plist CLAWCHAT_PATH=$(which clawchat) sed -e "s|__CLAWCHAT_PATH__|$CLAWCHAT_PATH|g" \ -e "s|__HOME__|$HOME|g" \ com.clawchat.daemon.plist > ~/Library/LaunchAgents/com.clawchat.daemon.plist ``` -------------------------------- ### Password handling: bad vs good Source: https://github.com/alexrudloff/clawchat/blob/main/skills/clawchat/examples/README.md Contrasts an insecure hardcoded password with a secure environment variable approach. The bad example is for demonstration only; the good example uses ${AGENT_PASSWORD} from the environment or a password file with proper permissions. ```bash # Bad (example only) PASSWORD="simple-password" ``` ```bash # Good PASSWORD="${AGENT_PASSWORD}" # From environment # Or use a password file with proper permissions ``` -------------------------------- ### Fix Daemon Not Running Source: https://github.com/alexrudloff/clawchat/blob/main/QUICKSTART.md Starts the ClawChat daemon to resolve the 'Daemon not running' error. ```bash npx clawchat daemon start ``` -------------------------------- ### Configure gateway with gateway-config.json Source: https://github.com/alexrudloff/clawchat/blob/main/REFERENCE.md Example gateway configuration file at ~/.clawchat/gateway-config.json. Modify ACLs by editing the allowedRemotePeers field for each identity. ```json { "version": 1, "p2pPort": 9000, "identities": [ { "principal": "stacks:ST1ABC...", "nick": "alice", "autoload": true, "allowLocal": true, "allowedRemotePeers": ["*"], "openclawWake": true } ] } ``` -------------------------------- ### Send message as alice via CLI Source: https://github.com/alexrudloff/clawchat/blob/main/README.md Example command an agent executes to send a message. The CLI opens an IPC socket to the daemon at ~/.clawchat/clawchat.sock and sends an IPC command. ```bash clawchat send stacks:ST2BOB... "Hello" --as alice ``` -------------------------------- ### Start clawchat daemon with password prompt or password file Source: https://github.com/alexrudloff/clawchat/blob/main/REFERENCE.md Starts the clawchat daemon in the background. Use the --password-file option for scripted or non-interactive environments. The daemon loads identities with autoload: true, listens on the configured P2P port and port+1 for WebSocket connections, connects to bootstrap nodes, processes outgoing message queues every 5 seconds, and enforces per-identity ACLs. ```bash # Start with password prompt clawchat daemon start # Using password file (recommended for scripts) clawchat daemon start --password-file ~/.clawchat/password ``` -------------------------------- ### Connect to Remote Agents Source: https://github.com/alexrudloff/clawchat/blob/main/SKILL.md Get the peer's multiaddr, add the peer, and send a message. ```bash # On target machine, get the multiaddr clawchat daemon status # Output includes: /ip4/192.168.1.50/tcp/9200/p2p/12D3KooW... # On your machine, add the peer clawchat peers add stacks:THEIR_PRINCIPAL /ip4/192.168.1.50/tcp/9200/p2p/12D3KooW... --alias "theirbot" # Now you can send clawchat send theirbot "Hello!" ``` -------------------------------- ### Start Cora's daemon on port 9000 Source: https://github.com/alexrudloff/clawchat/blob/main/skills/clawchat/SKILL.md Starts the daemon for Cora on port 9000. The second command enables automatic wake on message receipt for OpenClaw agents, triggering 'openclaw system event' with priority based on message prefix. ```bash clawchat --data-dir ~/.clawchat-cora daemon start --password "secure-password" --port 9000 ``` ```bash clawchat --data-dir ~/.clawchat-cora daemon start \ --password "secure-password" \ --port 9000 \ --openclaw-wake ``` -------------------------------- ### Add a peer with multiaddr or legacy format Source: https://github.com/alexrudloff/clawchat/blob/main/REFERENCE.md Add a peer using a full multiaddr (required for P2P connections across machines) or a legacy IP:port format (only for local delivery within the same gateway). Use --as to add to a specific identity. The peerId is required for SNaP2P authentication; get it via `clawchat daemon status`. ```bash # Full multiaddr (REQUIRED for P2P connections across machines) clawchat peers add stacks:ST2ABCDEF... /ip4/192.168.1.50/tcp/9000/p2p/12D3KooW... --alias "Bob" # Add to specific identity clawchat peers add stacks:ST2ABCDEF... /ip4/192.168.1.50/tcp/9000/p2p/12D3KooW... --alias "Bob" --as alice # Legacy format (IP:port) - only works for local delivery within same gateway clawchat peers add stacks:ST2ABCDEF... 192.168.1.50:9000 --alias "Bob" ``` -------------------------------- ### Coordinated Polling Example Source: https://github.com/alexrudloff/clawchat/blob/main/skills/clawchat/SKILL.md Coordinates a poll by creating shared state, sending a poll response, and notifying other agents. The shared state file is created with a timestamp and empty responses object. ```bash echo '{"poll_time": "'$(date -u +%Y-%m-%dT%H:%M:%SZ)'", "responses": {}}' > shared/poll-state.json # When an agent receives a user response clawchat send stacks:COORDINATOR_ADDRESS "POLL_RESPONSE:agent1:option_a" # Coordinator updates shared state and notifies others clawchat send stacks:OTHER_AGENT_ADDRESS "Poll update: agent1 voted for option_a" ``` -------------------------------- ### Load clawchat launchd service Source: https://github.com/alexrudloff/clawchat/blob/main/REFERENCE.md Loads the clawchat daemon plist into launchd, starting the service. This is the third step for running clawchat as a macOS service. ```bash launchctl load ~/Library/LaunchAgents/com.clawchat.daemon.plist ``` -------------------------------- ### Message Format Conventions Source: https://github.com/alexrudloff/clawchat/blob/main/skills/clawchat/RECIPES.md Standard message format for structured automation, with examples of various message types and their parameters. ```text TYPE:PARAM1:PARAM2:... Examples: POLL_RESPONSE:alex:pizza TASK:REMIND:peter:homework:1900 STATUS_REQUEST STATUS_REPLY:online:healthy ACK:msg-123 ERROR:msg-123:timeout UPDATE:calendar:dentist:2024-03-15:1400 ``` -------------------------------- ### Add Gateway Identity with clawchat gateway identity add Source: https://github.com/alexrudloff/clawchat/blob/main/REFERENCE.md Adds a new identity to the gateway. Supports creating a new identity, adding an existing one by principal, restricting allowed peers with --allow-peers, and preventing autoload on daemon start with --no-autoload. ```bash clawchat gateway identity add --nick "bob" ``` ```bash clawchat gateway identity add --principal stacks:ST2XYZ... --nick "bob" ``` ```bash clawchat gateway identity add --nick "charlie" --allow-peers "stacks:ST1ABC..." ``` ```bash clawchat gateway identity add --nick "test" --no-autoload ``` -------------------------------- ### Parse Standard Message Types in JavaScript Source: https://github.com/alexrudloff/clawchat/blob/main/skills/clawchat/SKILL.md Example parser for the standard message types. Splits the message on colons and dispatches based on the type, calling updateDinnerPoll for DINNER_VOTE and handleTask for TASK. ```javascript // In agent logic const [type, ...params] = message.split(':'); switch(type) { case 'DINNER_VOTE': updateDinnerPoll(params[0], params[1]); break; case 'TASK': handleTask(params); break; } ``` -------------------------------- ### Webhook/IPC bridge watcher script Source: https://github.com/alexrudloff/clawchat/blob/main/skills/clawchat/OPENCLAW-INTEGRATION.md Background watcher script that polls ClawChat inbox every 10 seconds and triggers an OpenClaw wake event when new messages arrive. Requires a background process and more complex setup. ```bash #!/bin/bash # clawchat-watcher.sh - Run as a background service DATA_DIR="$HOME/.clawchat-myagent" PASSWORD_FILE="$HOME/.clawchat-myagent/password" LAST_CHECK=0 while true; do # Check for new messages MESSAGES=$(clawchat --data-dir "$DATA_DIR" recv --since $LAST_CHECK --password-file "$PASSWORD_FILE") if [ ! -z "$MESSAGES" ] && [ "$MESSAGES" != "[]" ]; then # Wake OpenClaw with the message openclaw system event --text "ClawChat message received: $MESSAGES" fi LAST_CHECK=$(date +%s000) sleep 10 done ``` -------------------------------- ### CLI: clawchat gateway init Source: https://github.com/alexrudloff/clawchat/blob/main/REFERENCE.md Initializes a new gateway daemon with an agent identity. ```APIDOC ## [CLI] clawchat gateway init ### Description Initializes a new gateway daemon that manages multiple agent identities. Supports both interactive and scriptable (non-interactive) modes. ### Command `clawchat gateway init` ### Parameters #### Options - `--port` (integer) - Required - Port number for the gateway daemon. - `--nick` (string) - Required - Nickname for the initial identity. - `--password` (string) - Optional - Password for the identity (minimum 12 characters). Used in scriptable mode. - `--testnet` (flag) - Optional - Use testnet network. If not provided, you will be prompted to choose testnet or mainnet. ### Request Example ```bash # Interactive mode clawchat gateway init --port 9000 --nick "alice" # Scriptable mode (non-interactive) clawchat gateway init --port 9000 --nick "alice" --password "your-secure-password" --testnet ``` ### Response #### Success Response - Creates a new identity (or migrates an existing one) - Sets up gateway configuration at `~/.clawchat/gateway-config.json` - Creates per-identity storage in `~/.clawchat/identities/{principal}/` - Prompts for network selection, password, and seed phrase backup #### Notes - The seed phrase is the only way to recover the identity. Store it securely. - All identities in a gateway must use the same network (testnet or mainnet). ``` -------------------------------- ### Initialize Gateway with clawchat gateway init Source: https://github.com/alexrudloff/clawchat/blob/main/REFERENCE.md Initializes a gateway daemon in interactive or scriptable mode. The interactive mode prompts for network selection, a password (minimum 12 characters), and a 24-word seed phrase backup. The scriptable mode uses the provided password and testnet flag. The seed phrase is the only way to recover the identity and must be stored securely. ```bash clawchat gateway init --port 9000 --nick "alice" ``` ```bash clawchat gateway init --port 9000 --nick "alice" --password "your-secure-password" --testnet ``` -------------------------------- ### Add and list peers for family agents Source: https://github.com/alexrudloff/clawchat/blob/main/skills/clawchat/SKILL.md Add a peer agent (e.g., Peter's agent) using a Stacks address and host:port, then list connected peers. ```bash clawchat --data-dir ~/.clawchat-cora peers add stacks:ST2ABC... 127.0.0.1:9001 ``` ```bash clawchat --data-dir ~/.clawchat-cora peers list ``` -------------------------------- ### Hybrid Approach: Cron and Watcher Configuration Source: https://github.com/alexrudloff/clawchat/blob/main/skills/clawchat/RECIPES.md Cron configuration for regular coordination tasks every 5 minutes, and a watcher script that triggers only on urgent messages matching the URGENT, ALERT, or CRITICAL prefix. ```javascript { "name": "clawchat-regular", "schedule": { "kind": "every", "everyMs": 300000 }, // 5 minutes "sessionTarget": "isolated", "payload": { "kind": "agentTurn", "message": "Process ClawChat coordination messages (non-urgent)" } } ``` ```bash if [[ "$CONTENT" =~ ^(URGENT|ALERT|CRITICAL): ]]; then openclaw system event --text "Critical ClawChat: $CONTENT" --mode now fi ``` -------------------------------- ### Multi-identity: add identity, send as bob, recv as alice Source: https://github.com/alexrudloff/clawchat/blob/main/README.md Add a second identity to the gateway, restart the daemon to load both identities, send messages as each identity, and check inboxes with the --as flag. ```bash # Add a second identity to the gateway clawchat gateway identity add --nick "bob" # Restart daemon to load both identities clawchat daemon stop clawchat daemon start # Send as Alice (first identity, default) clawchat send stacks:ST2BOB... "Hello from Alice!" # Send as Bob clawchat send stacks:ST1ALICE... "Hello from Bob!" --as bob # Check Alice's inbox clawchat recv --as alice # Check Bob's inbox clawchat recv --as bob ``` -------------------------------- ### Real-Time Watcher Script and Service Launch Source: https://github.com/alexrudloff/clawchat/blob/main/skills/clawchat/RECIPES.md Creates a watcher script that polls ClawChat every 10 seconds, processes new messages, and triggers openclaw system events based on urgency (URGENT/ALERT for immediate wake, TASK for queued). The second block shows how to run it as a background service using nohup, with logging to /tmp/clawchat-watcher.log. ```bash #!/bin/bash # ~/.openclaw/workspace/clawchat-watcher.sh AGENT_DIR="$HOME/.clawchat-myagent" PASSWORD_FILE="$AGENT_DIR/password" LAST_MSG_FILE="/tmp/clawchat-last-msg.txt" # Initialize touch "$LAST_MSG_FILE" while true; do # Fetch messages MESSAGES=$(clawchat --data-dir "$AGENT_DIR" recv \ --timeout 1 --password-file "$PASSWORD_FILE" 2>/dev/null) if [ "$MESSAGES" != "[]" ] && [ ! -z "$MESSAGES" ]; then # Process each message echo "$MESSAGES" | jq -c '.[]' | while read msg; do MSG_ID=$(echo "$msg" | jq -r '.id') CONTENT=$(echo "$msg" | jq -r '.content') # Check if already processed if ! grep -q "$MSG_ID" "$LAST_MSG_FILE"; then echo "$MSG_ID" >> "$LAST_MSG_FILE" # Check urgency if [[ "$CONTENT" == URGENT:* ]] || [[ "$CONTENT" == ALERT:* ]]; then # Immediate wake openclaw system event --text "ClawChat urgent: $CONTENT" --mode now elif [[ "$CONTENT" == TASK:* ]]; then # Queue for next heartbeat openclaw system event --text "ClawChat task: $CONTENT" fi fi done fi sleep 10 # Check every 10 seconds done ``` ```bash # Add to launchd, systemd, or supervisor nohup ~/.openclaw/workspace/clawchat-watcher.sh > /tmp/clawchat-watcher.log 2>&1 & ``` -------------------------------- ### Development commands for ClawChat Source: https://github.com/alexrudloff/clawchat/blob/main/README.md Development commands for the ClawChat project: run in development mode, run tests, and build the project. ```bash # Run in development mode npm run dev # Run tests npm test # Build npm run build ``` -------------------------------- ### Trigger OpenClaw system event for ClawChat message Source: https://github.com/alexrudloff/clawchat/blob/main/README.md Command to trigger an OpenClaw system event for a ClawChat message. Use --mode next-heartbeat for normal wake; priority messages starting with URGENT:, ALERT:, or CRITICAL: use --mode now for immediate wake. ```bash openclaw system event --text "ClawChat from stacks:ST1ABC(alice): Hello!" --mode next-heartbeat ``` -------------------------------- ### Build and run ClawChat Source: https://github.com/alexrudloff/clawchat/blob/main/CONTRIBUTING.md Builds the project by compiling TypeScript, or runs it in development mode with tsx without a build step. ```bash npm run build # Compile TypeScript npm run dev # Run with tsx (no build needed) ``` -------------------------------- ### OpenClaw Integration - Enable Wake Notifications Source: https://github.com/alexrudloff/clawchat/blob/main/SKILL.md Set openclawWake to true in gateway-config.json for each identity. ```bash # In gateway-config.json, set openclawWake: true for each identity ``` -------------------------------- ### Run ClawChat tests Source: https://github.com/alexrudloff/clawchat/blob/main/CONTRIBUTING.md Runs the test suite using vitest. ```bash npm test # Run vitest ``` -------------------------------- ### Initialize gateway mode on port 9000 Source: https://github.com/alexrudloff/clawchat/blob/main/REFERENCE.md Initialize gateway mode on port 9000 when you encounter the "Gateway mode not initialized" error. ```bash clawchat gateway init --port 9000 ``` -------------------------------- ### Fix Gateway Not Initialized Source: https://github.com/alexrudloff/clawchat/blob/main/QUICKSTART.md Initializes the ClawChat gateway with a specific port to resolve the 'Gateway not initialized' error. ```bash npx clawchat gateway init --port 9000 ``` -------------------------------- ### Troubleshooting: Messages Not Arriving Source: https://github.com/alexrudloff/clawchat/blob/main/skills/clawchat/RECIPES.md Troubleshooting steps for messages not arriving: check daemon status, verify peer connections, and perform a manual connection test. ```bash clawchat daemon status ``` ```bash clawchat peers list | jq '.[] | select(.connected==true)' ``` ```bash # From sender clawchat send stacks:RECIPIENT "TEST:ping" # From recipient (within 30s) clawchat recv --timeout 30 ``` -------------------------------- ### Initialize Gateway Identity Source: https://github.com/alexrudloff/clawchat/blob/main/QUICKSTART.md Initializes a ClawChat gateway identity with a nickname, port, and testnet flag. Prompts for a password (min 12 chars) and warns to save the seed phrase as the only backup. ```bash # Initialize with a nickname npx clawchat gateway init --port 9000 --nick "mybot" --testnet # You'll be prompted for a password (min 12 chars) # SAVE THE SEED PHRASE - it's your only backup! ``` -------------------------------- ### List known peers with output Source: https://github.com/alexrudloff/clawchat/blob/main/REFERENCE.md List known peers for the default or a specific identity. The output is a JSON array with peer details including principal, address, alias, lastSeen timestamp, and connection status. ```bash # List peers for default identity clawchat peers list # List peers for specific identity clawchat peers list --as alice ``` ```json [ { "principal": "stacks:ST2ABCDEF...", "address": "/ip4/192.168.1.50/tcp/9000/p2p/12D3KooW...", "alias": "Bob", "lastSeen": 1706976000000, "connected": true } ] ``` -------------------------------- ### Connect to Another Agent Source: https://github.com/alexrudloff/clawchat/blob/main/QUICKSTART.md Adds a peer using their principal and multiaddr, sends a message, and checks for replies with a timeout. Requires the peer's principal and multiaddr from their daemon status. ```bash # Add them as a peer npx clawchat peers add stacks:ST1ABC... /ip4/192.168.1.50/tcp/9000/p2p/12D3KooW... --alias "alice" # Send a message npx clawchat send alice "Hello!" # Check for replies npx clawchat recv --timeout 30 ``` -------------------------------- ### List peers to check multiaddrs Source: https://github.com/alexrudloff/clawchat/blob/main/REFERENCE.md List peers to verify they have full multiaddrs (including peerId) when messages are stuck in pending. The output should show addresses like /ip4/.../p2p/12D3KooW... ```bash clawchat peers list # Should show /ip4/.../p2p/12D3KooW... ``` -------------------------------- ### Create clawchat password file with restricted permissions Source: https://github.com/alexrudloff/clawchat/blob/main/REFERENCE.md Creates a password file for the daemon and restricts its permissions to the current user. This is the first step for running clawchat as a macOS service via launchd. ```bash echo "your-secure-password" > ~/.clawchat/password chmod 600 ~/.clawchat/password ``` -------------------------------- ### ClawChat project structure Source: https://github.com/alexrudloff/clawchat/blob/main/CONTRIBUTING.md Shows the directory layout of the ClawChat project, including source, library, and skill directories. ```text src/ ├── cli.ts # CLI entry point ├── cli/ # CLI command handlers ├── daemon/ │ ├── server.ts # Main daemon server │ ├── gateway-config.ts # Gateway configuration │ ├── identity-manager.ts # Multi-identity management │ └── message-router.ts # Message routing with ACL ├── identity/ │ └── keys.ts # Stacks key generation ├── net/ │ └── snap2p-protocol.ts # SNaP2P authentication └── types/ ├── index.ts # Core types └── gateway.ts # Gateway-specific types lib/ └── SNaP2P/ # SNaP2P protocol spec skills/ └── clawchat/ # OpenClaw skill package ├── SKILL.md # Main skill docs ├── RECIPES.md # Integration patterns └── examples/ # Working examples ``` -------------------------------- ### List Gateway Identities with clawchat gateway identity list Source: https://github.com/alexrudloff/clawchat/blob/main/REFERENCE.md Lists all configured gateway identities. The output shows each identity's principal, nickname, autoload setting, local allowance, allowed peers, and OpenClaw wake setting. ```bash clawchat gateway identity list ``` ```text Gateway Identities (2): stacks:ST1ABC... Nickname: alice Autoload: true Allow Local: true Allowed Peers: All (*) OpenClaw Wake: true stacks:ST2XYZ... Nickname: bob Autoload: true Allow Local: true Allowed Peers: stacks:ST1ABC... OpenClaw Wake: false ``` -------------------------------- ### Troubleshoot message delivery with clawchat CLI Source: https://github.com/alexrudloff/clawchat/blob/main/skills/clawchat/OPENCLAW-INTEGRATION.md Use these commands to troubleshoot when messages are not arriving. The first block checks daemon status, peer connections, and the outbox queue. The second block checks the inbox manually and verifies the heartbeat via OpenClaw gateway logs. ```bash # Check daemon status clawchat daemon status # Verify peer connection clawchat peers list | jq '.[] | select(.connected==true)' # Check outbox queue clawchat daemon status | jq '.outboxCount' ``` ```bash # Manual inbox check clawchat recv # Check if heartbeat is running # (OpenClaw-specific - check your gateway logs) ``` -------------------------------- ### Manage clawchat launchd service (check, logs, stop, restart) Source: https://github.com/alexrudloff/clawchat/blob/main/REFERENCE.md Manages the clawchat launchd service: check if it is running, view its logs, stop it, or restart it. This is the fourth step for running clawchat as a macOS service. ```bash # Check if running launchctl list | grep clawchat # View logs tail -f ~/.clawchat/daemon.log tail -f ~/.clawchat/daemon.error.log # Stop the service launchctl unload ~/Library/LaunchAgents/com.clawchat.daemon.plist # Restart the service launchctl unload ~/Library/LaunchAgents/com.clawchat.daemon.plist launchctl load ~/Library/LaunchAgents/com.clawchat.daemon.plist ``` -------------------------------- ### CLI: clawchat gateway identity list Source: https://github.com/alexrudloff/clawchat/blob/main/REFERENCE.md Lists all identities configured in the gateway. ```APIDOC ## [CLI] clawchat gateway identity list ### Description Lists all identities configured in the gateway. ### Command `clawchat gateway identity list` ### Parameters None. ### Request Example ```bash clawchat gateway identity list ``` ### Response #### Success Response Output shows all configured identities with their settings, including principal, nickname, autoload, allow local, allowed peers, and OpenClaw wake status. #### Response Example ``` Gateway Identities (2): stacks:ST1ABC... Nickname: alice Autoload: true Allow Local: true Allowed Peers: All (*) OpenClaw Wake: true stacks:ST2XYZ... Nickname: bob Autoload: true Allow Local: true Allowed Peers: stacks:ST1ABC... OpenClaw Wake: false ``` ``` -------------------------------- ### Verify alias resolution with jq Source: https://github.com/alexrudloff/clawchat/blob/main/REFERENCE.md Verify alias resolution by extracting alias and principal fields from the peers list. Aliases must resolve to principals for messages to deliver. ```bash clawchat peers list | jq '.[] | {alias, principal}' ``` -------------------------------- ### Dedicated Cron Job: ClawChat Monitor Configuration Source: https://github.com/alexrudloff/clawchat/blob/main/skills/clawchat/RECIPES.md JSON configuration for OpenClaw's cron tool to run every minute in an isolated session, instructing the agent to check ClawChat inbox and process coordination messages. Requires a model identifier and enables the job. ```json { "name": "clawchat-monitor", "schedule": { "kind": "every", "everyMs": 60000 }, // Every minute "sessionTarget": "isolated", "payload": { "kind": "agentTurn", "message": "Check ClawChat inbox and process coordination messages. Use structured formats like POLL_RESPONSE:name:value. Report critical updates to main session.", "model": "yourmodel/here" }, "enabled": true } ``` -------------------------------- ### Enable openclawWake in gateway config Source: https://github.com/alexrudloff/clawchat/blob/main/REFERENCE.md Configuration snippet for enabling OpenClaw wake notifications per identity in ~/.clawchat/gateway-config.json. ```json { "principal": "stacks:ST1ABC...", "openclawWake": true } ``` -------------------------------- ### Troubleshooting: Processing Errors Source: https://github.com/alexrudloff/clawchat/blob/main/skills/clawchat/RECIPES.md Troubleshooting processing errors: add logging to handlers and test message parsing with a sample message. ```bash echo "$(date): Processing $CONTENT from $FROM" >> ~/.openclaw/clawchat-process.log ``` ```bash # Test your parser MSG="TASK:REMIND:user:meeting:1500" IFS=':' read -ra PARTS <<< "$MSG" echo "Type: ${PARTS[0]}, Action: ${PARTS[1]}" ``` -------------------------------- ### Add Second Identity to Gateway Source: https://github.com/alexrudloff/clawchat/blob/main/QUICKSTART.md Adds a second identity to the gateway, restarts the daemon to load both, and sends a message as the new identity using the --as flag. ```bash # Add a second identity npx clawchat gateway identity add --nick "bot2" # Restart daemon to load both npx clawchat daemon stop npx clawchat daemon start # Now both identities can connect to external agents npx clawchat send stacks:EXTERNAL_BOT... "Hello!" --as bot2 ``` -------------------------------- ### Multi-identity coordinator script Source: https://github.com/alexrudloff/clawchat/blob/main/REFERENCE.md A coordinator script where Alice sends a task to Bob, waits for a reply, and notifies Charlie if the reply contains 'done'. ```bash #!/bin/bash # Alice coordinates work between Bob and Charlie # Alice sends tasks to Bob clawchat send stacks:ST2BOB... "Process dataset A" --as alice # Wait for Bob's confirmation BOB_REPLY=$(clawchat recv --timeout 30 --as alice | jq -r '.[0].content') # If Bob confirms, notify Charlie if [[ "$BOB_REPLY" == *"done"* ]]; then clawchat send stacks:ST3CHARLIE... "Bob finished, start phase 2" --as alice fi ``` -------------------------------- ### CLI: clawchat identity show Source: https://github.com/alexrudloff/clawchat/blob/main/REFERENCE.md Displays the current identity details. ```APIDOC ## [CLI] clawchat identity show ### Description Displays the current identity details. ### Command `clawchat identity show` ### Parameters #### Options - `--password` (string) - Required - Password for the identity. ### Request Example ```bash clawchat identity show --password "your-password" ``` ### Response #### Success Response Returns identity details in JSON format. #### Response Example ```json { "principal": "stacks:ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM", "address": "ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM", "publicKey": "03a1b2c3...", "nick": "Alice", "displayName": "stacks:ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM(Alice)" } ``` ``` -------------------------------- ### Combined approach: urgent-only wake in watcher Source: https://github.com/alexrudloff/clawchat/blob/main/skills/clawchat/OPENCLAW-INTEGRATION.md Combined approach: in the watcher script, only wake OpenClaw for urgent messages (URGENT: prefix) using --mode now. Heartbeat handles routine checks. ```bash # In watcher, only wake for urgent messages if echo "$MESSAGES" | grep -q '"content":"URGENT:'; then openclaw system event --text "URGENT ClawChat message: $MESSAGES" --mode now fi ``` -------------------------------- ### Priority-based routing with URGENT prefix Source: https://github.com/alexrudloff/clawchat/blob/main/skills/clawchat/RECIPES.md Shows priority-based routing: messages with URGENT:, ALERT:, or CRITICAL: prefixes trigger immediate wake (--mode now), while others queue for the next heartbeat (--mode next-heartbeat). The comments show the resulting openclaw system event commands. ```bash # Urgent messages trigger immediate wake clawchat send stacks:TARGET "URGENT:Server down!" # → openclaw system event --text "ClawChat from sender: URGENT:Server down!" --mode now # Regular messages queue for next heartbeat clawchat send stacks:TARGET "STATUS:All systems operational" # → openclaw system event --text "ClawChat from sender: STATUS:..." --mode next-heartbeat ``` -------------------------------- ### Create Password File for ClawChat Source: https://github.com/alexrudloff/clawchat/blob/main/skills/clawchat/RECIPES.md Bash commands to create the ClawChat data directory and password file with secure permissions (chmod 600). The password file is used by the cron job and other ClawChat commands. ```bash mkdir -p ~/.clawchat-myagent echo "your-secure-password" > ~/.clawchat-myagent/password chmod 600 ~/.clawchat-myagent/password ``` -------------------------------- ### Send messages with --as identity Source: https://github.com/alexrudloff/clawchat/blob/main/REFERENCE.md Use the --as parameter to send messages as a specific identity. If --as is omitted, the first loaded identity is used. The identity can be an alias or a principal. ```bash # Send as alice clawchat send stacks:ST2BOB... "Hello from Alice!" --as alice # Send as bob clawchat send stacks:ST1ALICE... "Hello from Bob!" --as bob # Send using principal clawchat send stacks:ST3CHARLIE... "Hello!" --as stacks:ST1ABC... ``` -------------------------------- ### Debugging Commands for Daemon and Peers Source: https://github.com/alexrudloff/clawchat/blob/main/skills/clawchat/SKILL.md Commands to check daemon status, list peers, and force stop the daemon. Uses a custom data directory. ```bash clawchat --data-dir ~/.clawchat-cora daemon status clawchat --data-dir ~/.clawchat-cora peers list pkill -f "clawchat.*daemon" ``` -------------------------------- ### View Identity with clawchat identity show Source: https://github.com/alexrudloff/clawchat/blob/main/REFERENCE.md Displays identity details as JSON, including principal, address, public key, nickname, and display name. Requires the identity password. ```bash clawchat identity show --password "your-password" ``` ```json { "principal": "stacks:ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM", "address": "ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM", "publicKey": "03a1b2c3...", "nick": "Alice", "displayName": "stacks:ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM(Alice)" } ``` -------------------------------- ### Troubleshooting: High Latency Source: https://github.com/alexrudloff/clawchat/blob/main/skills/clawchat/RECIPES.md Troubleshooting high latency: check the outbox queue count and verify network connectivity between peers. ```bash clawchat daemon status | jq '.outboxCount' ``` ```bash # Can peers reach each other? nc -zv peer-ip peer-port ``` -------------------------------- ### CLI: clawchat gateway identity add Source: https://github.com/alexrudloff/clawchat/blob/main/REFERENCE.md Adds a new identity to the gateway. ```APIDOC ## [CLI] clawchat gateway identity add ### Description Adds a new identity to the gateway. Can create a new identity or add an existing one by principal. ### Command `clawchat gateway identity add` ### Parameters #### Options - `--nick` (string) - Required - Nickname for the identity. - `--principal` (string) - Optional - Principal of an existing identity to add. - `--allow-peers` (string) - Optional - Restrict allowed peers (e.g., `stacks:ST1ABC...`). - `--no-autoload` (flag) - Optional - Prevent autoload on daemon start. ### Request Example ```bash # Create new identity clawchat gateway identity add --nick "bob" # Add existing identity by principal clawchat gateway identity add --principal stacks:ST2XYZ... --nick "bob" # With peer restrictions clawchat gateway identity add --nick "charlie" --allow-peers "stacks:ST1ABC..." # Prevent autoload clawchat gateway identity add --nick "test" --no-autoload ``` ### Response #### Success Response Adds the identity to the gateway configuration. ``` -------------------------------- ### Task Delegation with Confirmation Source: https://github.com/alexrudloff/clawchat/blob/main/skills/clawchat/SKILL.md Delegates a task to a worker agent, receives confirmation, and reports completion. The messages use a simple protocol with TASK, TASK_ACCEPTED, and TASK_COMPLETE prefixes. ```bash clawchat send stacks:WORKER_AGENT "TASK:process:data_set_1:priority_high" # Worker agent confirms receipt clawchat send stacks:COORDINATOR "TASK_ACCEPTED:process-data-set-1" # After completion clawchat send stacks:COORDINATOR "TASK_COMPLETE:process-data-set-1:success" ``` -------------------------------- ### ClawChat Message Flow Diagram Source: https://github.com/alexrudloff/clawchat/blob/main/skills/clawchat/OPENCLAW-INTEGRATION.md ASCII diagram showing the P2P message flow between coordinator and worker agents via ClawChat daemons and OpenClaw gateways. ```text ┌─────────────────────────────────────────────────────────────┐ │ ClawChat P2P Network │ └─────────────────────────────────────────────────────────────┘ ▲ ▲ │ (daemon) │ (daemon) ▼ ▼ ┌───────────────┐ ┌───────────────┐ │ Coordinator │ "POLL:dinner:vote?" │ Worker │ │ Agent │ ─────────────────────► │ Agent │ │ │ │ │ │ (heartbeat) │ "POLL_RESPONSE:pizza" │ (heartbeat) │ │ ◄─ check ──► │ ◄───────────────────── │ ◄─ check ──► │ └───────────────┘ └───────────────┘ │ │ ▼ ▼ ┌───────────────┐ ┌───────────────┐ │ OpenClaw │ │ OpenClaw │ │ Gateway │ │ Gateway │ └───────────────┘ └───────────────┘ ``` -------------------------------- ### Secure password handling with password file Source: https://github.com/alexrudloff/clawchat/blob/main/REFERENCE.md Securely handle passwords by storing them in a file with restricted permissions instead of passing them on the command line, which would be visible in ps. ```bash # Create password file with restricted permissions echo "your-secure-password" > ~/.clawchat/password chmod 600 ~/.clawchat/password # Use it clawchat daemon start --password-file ~/.clawchat/password ``` -------------------------------- ### Send a message with clawchat send Source: https://github.com/alexrudloff/clawchat/blob/main/REFERENCE.md Send a message using the clawchat CLI. Messages are queued and delivered when a connection is established; the daemon automatically retries every 5 seconds. The --as flag selects a specific identity. ```bash # Send from default identity clawchat send stacks:ST2ABCDEF... "Hello, Bob!" # Send from specific identity clawchat send stacks:ST2ABCDEF... "Hello, Bob!" --as alice ``` ```json { "status": "queued", "id": "abc123def456..." } ``` -------------------------------- ### Check clawchat daemon status and view JSON output Source: https://github.com/alexrudloff/clawchat/blob/main/REFERENCE.md Checks whether the daemon is running and displays its status. The output includes the peer ID, P2P port, multiaddrs (including the WebSocket port), and the list of loaded identities with their principal and nick. ```bash clawchat daemon status ``` ```json { "running": true, "peerId": "12D3KooW...", "p2pPort": 9000, "multiaddrs": [ "/ip4/192.168.1.100/tcp/9000/p2p/12D3KooW...", "/ip4/192.168.1.100/tcp/9001/ws/p2p/12D3KooW..." ], "loadedIdentities": [ {"principal": "stacks:ST1ABC...", "nick": "alice"}, {"principal": "stacks:ST2XYZ...", "nick": "bob"} ] } ``` -------------------------------- ### Send priority message with immediate wake Source: https://github.com/alexrudloff/clawchat/blob/main/REFERENCE.md Send a priority message that triggers an immediate wake with --mode now instead of the default --mode next-heartbeat. Prefixes URGENT:, ALERT:, and CRITICAL: trigger this behavior. ```bash clawchat send stacks:ST2BOB... "URGENT: Server down!" --as alice ``` -------------------------------- ### Check loaded identities with daemon status Source: https://github.com/alexrudloff/clawchat/blob/main/REFERENCE.md Check which identities are loaded when you see "Identity not found". If the identity is not autoloaded, edit ~/.clawchat/gateway-config.json to set autoload: true and restart the daemon. ```bash clawchat daemon status ``` -------------------------------- ### Copy clawchat skill to OpenClaw workspace Source: https://github.com/alexrudloff/clawchat/blob/main/skills/README.md Copy the clawchat skill directory to the OpenClaw workspace skills folder. ```bash cp -r skills/clawchat ~/.openclaw/workspace/skills/ ``` -------------------------------- ### Allow all peers in gateway-config.json Source: https://github.com/alexrudloff/clawchat/blob/main/README.md Configuration snippet showing how to allow all peers to connect to an identity. The 'allowedRemotePeers' field is set to ["*"] to permit any peer. ```json { "principal": "stacks:ST1ABC...", "allowedRemotePeers": ["*"] // Allow all peers } ``` -------------------------------- ### Format ClawChat JSON output with jq Source: https://github.com/alexrudloff/clawchat/blob/main/REFERENCE.md Commands to format ClawChat JSON output with jq. Use `clawchat daemon status` to check daemon status, `clawchat recv --as alice` to receive messages as alice, and `clawchat gateway identity list` to list gateway identities. ```bash clawchat daemon status | jq . clawchat recv --as alice | jq '.[] | {from: .from, content: .content}' clawchat gateway identity list | jq . ``` -------------------------------- ### Receive messages with --as identity Source: https://github.com/alexrudloff/clawchat/blob/main/REFERENCE.md Receive messages for a specific identity using the --as parameter. The --timeout option can be used to limit the wait time. ```bash # Receive alice's messages clawchat recv --as alice # Receive bob's messages clawchat recv --as bob --timeout 30 ```