> **Canonical comprehensive report (merged):**
> `/Users/khaledahmedmohamed/designs-content/vip/setting/SESSION_SUMMARY_2026-07-14_to_15_Catalog_Hub_Hybrid47_OpenClaw_ZeroClaw.md`
>
> This file is a satellite summary kept for history. Prefer the comprehensive file for dual-server OpenClaw/ZeroClaw + full session index.

# OpenClaw Session Summary & Future Learnings

## 1. Session Goals & Action Report
This document summarizes the troubleshooting, configuration, and optimization actions performed on the local and remote environments during this session.

### Goal A: Analyze OpenClaw Alternatives
*   **Required Action**: Investigate alternatives to OpenClaw that offer better security, lower resource usage, and simpler workflows.
*   **How it was made**: Performed web queries and compared OpenClaw against major open-source agent frameworks.
*   **Result**: 
    *   Identified **NanoClaw** (containerized sandboxing for security), **Nanobot** (lightweight Python + MCP support), **n8n/Activepieces** (robust visual workflows for messaging/integrations), and **Dify** (enterprise-grade UI model orchestrator) as superior alternatives.

### Goal B: Resolve Crashing and Connect Remote Server
*   **Required Action**: Connect via SSH to the remote server `149.102.150.185` and fix the non-functional `zeroclaw` gateway app.
*   **How it was made**:
    *   Inspected running ports, Docker containers, and PM2 processes.
    *   Checked system logs (`/root/.pm2/logs/zeroclaw-gateway-error.log` and `journalctl`).
    *   Identified a startup validation crash caused by invalid schema keys (`autoApprove` and `autoRemoveFiles`) in `/root/.openclaw/openclaw.json`.
    *   Identified port conflicts on `18789` between PM2 daemon and a systemd unit.
*   **Result**:
    *   Deleted the invalid config keys on the server to pass validation.
    *   Cleaned and disabled the conflicting PM2 service since the server is running a dedicated system-wide systemd service.

### Goal C: Configure OpenRouter & Gemini
*   **Required Action**: Update model providers with OpenRouter free keys and the `doctorhealthy111` Gemini API key.
*   **How it was made**:
    *   Extracted the Gemini key from the local path `/Users/khaledahmedmohamed/designs-content/vip/setting/api-new.md`.
    *   Extracted the OpenRouter free-tier key from `/Users/khaledahmedmohamed/designs-content/vip/setting/openrouter-configurations/qwen-open-router-config.md`.
    *   Modified the remote `/root/zeroclaw/openclaw.json` configuration file.
    *   Removed the unused Minimax API key and non-functional CORS origins (`https://zero.master1.vip` and `https://auto.master1.vip`) from the configurations.
*   **Result**:
    *   Set the primary agent model to `openrouter/qwen/qwen3-coder:free`.
    *   Set the fallback models to `google/gemini-2.5-flash` and `openrouter/nvidia/nemotron-nano-9b-v2:free`.
    *   Added the corresponding API keys securely to `models.providers`.
    *   Unused providers (Minimax) and origins are cleared.

---

## 2. Final Results & Architecture Details
The application is now 100% active, stable, and running on [https://zeroclaw.addict.best](https://zeroclaw.addict.best).

*   **Runtime Engine**: Managed by `systemd` (`zeroclaw-gateway.service`). 
*   **Authentication Mode**: Configured to `"none"` with `"allowInsecureAuth": true` and `"dangerouslyDisableDeviceAuth": true` to prevent any WebSocket connection rejections when accessing the dashboard via the public reverse proxy.
*   **Watchdog Recovery**: The watchdog timer `zeroclaw-healthcheck.timer` executes the status checker script `/usr/local/sbin/zeroclaw-healthcheck.sh` every 2 minutes. If the port dies, it restarts the service automatically.

---

## 3. Session Files Log (Local and Remote)

| File Name & Description | Location | Purpose |
| :--- | :--- | :--- |
| **api-new.md** | `/Users/khaledahmedmohamed/designs-content/vip/setting/api-new.md` | Extracted the `doctorhealthy111` Gemini API key. |
| **qwen-open-router-config.md** | `/Users/khaledahmedmohamed/designs-content/vip/setting/openrouter-configurations/qwen-open-router-config.md` | Extracted the OpenRouter API key. |
| **openclaw-session-summary.md** | `/Users/khaledahmedmohamed/designs-content/vip/setting/openclaw-session-summary.md` | This summary log for future learning and diagnostics. |
| **openclaw.json** (Remote) | `/root/zeroclaw/openclaw.json` | Updated gateway authentication settings, added OpenRouter/Gemini keys, and set default models. |
| **openclaw.json** (Remote) | `/root/.openclaw/openclaw.json` | Cleaned up root schema properties to resolve the validator crash. |
| **zeroclaw-gateway.service** (Remote) | `/etc/systemd/system/zeroclaw-gateway.service` | Verified to ensure clean node environment configurations and pre-start port cleaning. |
| **ZEROCLAW_PERMANENT.md** (Remote) | `/root/ZEROCLAW_PERMANENT.md` | Read to understand the permanent deployment script specifications. |
| **openrouter-image/SKILL.md** (Remote) | `/root/zeroclaw/skills/openrouter-image/SKILL.md` | Created custom skill for Flux Schnell image generation via OpenRouter API. |
| **openrouter-video/SKILL.md** (Remote) | `/root/zeroclaw/skills/openrouter-video/SKILL.md` | Created custom skill for Alibaba Happy Horse video generation via OpenRouter API. |
| **minimax-image & minimax-video** (Remote) | Deleted from `/root/zeroclaw/skills/` | Cleaned up obsolete minimax-based image and video generation custom skills. |

---

## 4. Future Enhancements & Error Avoidance Tips

### Rule: Building on, Not Replacing
When merging and maintaining configurations or low-review score content (e.g. system keys, configuration instructions, automation templates):
*   **Preserve Legacy Configs**: Do not overwrite the file. Use `jq` or programmatic schema checkers to append/patch blocks (like `openclaw config patch` or `jq '.models.providers += ...'`).
*   **Fallback Anchors**: When updating primary models, always retain the previous working model as the first item in the `"fallbacks"` array so the system never defaults to an empty state.
*   **Port Lockouts**: Never start two process managers (e.g. PM2 and systemd) on the same daemon. If a service is managed by systemd, disable the app in PM2 (`pm2 delete <name>`) and save the configuration (`pm2 save`).

### Key Recommendations
1.  **Strict Schema Checking**: Before starting any local or remote AI agent gateway, run:
    ```bash
    npx openclaw config validate
    ```
    This catches invalid keys (like the stray `autoApprove` keys) before they take down the daemon.
2.  **Verify WebSockets via Gateway URL**: If you receive a `closed before connect` error in the client, always append `&token=YOUR_TOKEN` to the URL query string if auth mode is set to `"token"`. If running behind Caddy reverse proxy, set `auth.mode` to `"none"` only if firewall rules restrict incoming traffic to port 18789.
