[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M71AHS442CZHM5T5ACNVJX4C":3,"skill-same:01M71AHS442CZHM5T5ACNVJX4C":71},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":38,"linkOnly":39,"markdownContent":40,"markdownBody":41,"frontMatter":42,"refName":51,"commitSha":52,"skillDirectory":53,"forksCount":14,"repositoryHtmlUrl":54,"repositoryHomepageUrl":6,"ownerHtmlUrl":55,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":56,"install":57,"resources":70},"01M71AHS442CZHM5T5ACNVJX4C","hermes-windows-wsl-gateway",null,"Troubleshoot and fix Hermes Gateway compatibility issues on Windows and WSL. Specifically addresses Windows process management errors and missing dependencies.","sapsapshen\u002Fai-memory-router","sapsapshen","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F20347959?v=4","01M6XDQEF1DP50DKF37H81J3J5","shenmian","01M6XDQEJPE41Y3DT2763X8ZJN",0,"MIT","https:\u002F\u002Fgithub.com\u002Fsapsapshen\u002Fai-memory-router\u002Fblob\u002Fmain\u002Fskills-store\u002Fhermes\u002Fhermes-windows-wsl-gateway\u002FSKILL.md",[],[19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37],"hermes windows wsl gateway","windows","gateway","hermes","fix","process management","addresses","errors","hermes-agent","missing","dependencies","compatibility","process","linux","management","hermes agent","troubleshooting","issues","troubleshoot","2026-11-10 10:12:30",false,"---\nname: hermes-windows-wsl-gateway\ndescription: Troubleshoot and fix Hermes Gateway compatibility issues on Windows and WSL. Specifically addresses Windows process management errors and missing dependencies.\nversion: 1.0.0\nauthor: Hermes Agent\nlicense: MIT\nmetadata:\n  hermes:\n    tags: [hermes, gateway, windows, wsl, troubleshooting, compatibility]\n    related_skills: [hermes-agent]\n    platforms: [windows, wsl, linux]\n---\n\n# Hermes Gateway Windows\u002FWSL Troubleshooting\n\nThis skill addresses common issues when running Hermes Gateway on Windows and WSL environments, particularly process management compatibility errors.\n\n## Common Error Patterns\n\n### Error 1: Windows Process Management Compatibility\n```\nTraceback (most recent call last):\n  File \"hermes_cli\u002Fgateway.py\", line 1305, in run_gateway\n    success = asyncio.run(start_gateway(replace=replace, verbosity=verbosity))\n  File \"asyncio\u002Frunners.py\", line 190, in run\n    return runner.run(main)\n  File \"asyncio\u002Frunners.py\", line 118, in run\n    return self._loop.run_until_complete(task)\n  File \"asyncio\u002Fbase_events.py\", line 654, in run_until_complete\n    return future.result()\n  File \"gateway\u002Frun.py\", line 7409, in start_gateway\n    existing_pid = get_running_pid()\n  File \"gateway\u002Fstatus.py\", line 370, in get_running_pid\n    os.kill(pid, 0)  # signal 0 = existence check, no actual signal sent\nOSError: [WinError 11] 试图加载格式不正确的程序\n```\n\n**Root Cause**: Hermes uses Unix-style process management (`os.kill(pid, 0)`) which has compatibility issues on native Windows. The `os.kill()` function with signal 0 (process existence check) fails on Windows with error 11.\n\n**Direct Solution**: Patch the `get_running_pid()` function in `gateway\u002Fstatus.py` to be Windows-compatible:\n\n```python\ndef get_running_pid():\n    \"\"\"\n    获取当前运行的 Hermes Gateway 进程 PID\n    Windows 兼容版本：跳过有问题的 os.kill 检查\n    \"\"\"\n    pid_file = _pid_file_path()\n    if not pid_file.exists():\n        return None\n    \n    try:\n        with open(pid_file, 'r', encoding='utf-8') as f:\n            data = json.load(f)\n        \n        pid = data.get('pid')\n        if not pid:\n            return None\n        \n        # Windows 兼容检查：只检查文件是否存在，不调用 os.kill\n        if sys.platform == 'win32':\n            # 在 Windows 上，我们只检查 PID 文件是否有效\n            # 不进行实际的进程检查，避免 \"试图加载格式不正确的程序\" 错误\n            try:\n                # 简单检查：如果 PID 文件最近被修改过，假设进程还在运行\n                mtime = pid_file.stat().st_mtime\n                if time.time() - mtime \u003C 300:  # 5分钟内修改过\n                    return pid\n                return None\n            except:\n                return None\n        else:\n            # Unix\u002FLinux: 正常检查\n            try:\n                os.kill(pid, 0)\n                return pid\n            except (OSError, ProcessLookupError):\n                return None\n                \n    except Exception:\n        return None\n```\n\n**Required imports** (add to top of `gateway\u002Fstatus.py` if missing):\n```python\nimport os\nimport sys\nimport json\nimport time\nfrom pathlib import Path\n```\n\n### Error 2: Corrupted Python Files\n```\nSyntaxError: invalid syntax\n  File \"\u002Fhome\u002Fsap\u002Fhermes-agent\u002Fgateway\u002Frun.py\", line 1063\n    \"GATEWAY_ALLOWED_USERS\")\n    ^^^^^^^^^^^^^^^^^^^^^^^\nSyntaxError: invalid syntax\n```\n\n**Root Cause**: Python files may contain corrupted `logout` strings inserted into code, breaking syntax. Common patterns:\n- `selflogout` instead of `self`\n- `faillogout` instead of `failed` \n- Broken strings across lines\n- Missing platform names like `Plogout\\nlatform.logout\\nSLACK:` instead of `Platform.SLACK:`\n- Standalone `logout` lines causing indentation errors\n\n### Error 3: Unicode Encoding Errors in Windows Console\n```\n--- Logging error ---\nTraceback (most recent call last):\n  File \"C:\\Python311\\Lib\\logging\\__init__.py\", line 1113, in emit\n    stream.write(msg + self.terminator)\nUnicodeEncodeError: 'gbk' codec can't encode character '\\u2713' in position 42: illegal multibyte sequence\nMessage: '✓ %s connected'\nArguments: ('webhook',)\n```\n\n**Root Cause**: Windows console uses GBK encoding by default, cannot handle Unicode characters like checkmarks (✓ U+2713, ✗ U+2717, 🧠 U+1F9E0) used in Hermes logging.\n\n### Error 4: Missing Function Import Errors\n```\nImportError: cannot import name 'remove_pid_file' from 'gateway.status'\n```\n\n**Root Cause**: Simplified or corrupted `gateway\u002Fstatus.py` missing required functions that `gateway\u002Frun.py` expects to import.\n\n### Error 3: Missing Dependencies in WSL\n```\nModuleNotFoundError: No module named 'httpx'\n```\n\n**Root Cause**: Python's externally-managed environment restrictions in WSL prevent system-wide package installation.\n\n## Solutions\n\n### Step 0: Fix All Common File Issues\n\n#### Fix Corrupted Python Files\nIf getting syntax errors, check and fix corrupted files:\n\n```bash\n# Search for corrupted 'logout' strings\ngrep -n \"logout\" \u002Fhome\u002Fsap\u002Fhermes-agent\u002Fgateway\u002Frun.py\n\n# Remove standalone logout lines (causes indentation errors)\nsed -i '\u002F^[[:space:]]*logout[[:space:]]*$\u002Fd' \u002Fhome\u002Fsap\u002Fhermes-agent\u002Fgateway\u002Frun.py\n\n# Or using Python:\npython3 -c \"\nwith open('\u002Fhome\u002Fsap\u002Fhermes-agent\u002Fgateway\u002Frun.py', 'r', encoding='utf-8') as f:\n    lines = [line for line in f if line.strip() != 'logout']\nwith open('\u002Fhome\u002Fsap\u002Fhermes-agent\u002Fgateway\u002Frun.py', 'w', encoding='utf-8') as f:\n    f.writelines(lines)\nprint('Removed standalone logout lines')\n\"\n\n# Common fixes using patch tool\n# Fix broken variable names\npatch(mode='replace', path='\u002Fhome\u002Fsap\u002Fhermes-agent\u002Fgateway\u002Frun.py',\n      old_string='selflogout', new_string='self', replace_all=True)\n\n# Fix broken strings\npatch(mode='replace', path='\u002Fhome\u002Fsap\u002Fhermes-agent\u002Fgateway\u002Frun.py',\n      old_string='logger.debug(\"Plugin command dispatch faillogout\\ned (non-fatal): %s\", e)',\n      new_string='logger.debug(\"Plugin command dispatch failed (non-fatal): %s\", e)')\n\n# Fix broken platform names  \npatch(mode='replace', path='\u002Fhome\u002Fsap\u002Fhermes-agent\u002Fgateway\u002Frun.py',\n      old_string='elif platform == Plogout\\nlatform.logout\\nSLACK:',\n      new_string='elif platform == Platform.SLACK:')\n```\n\n#### Fix Unicode Encoding Errors\nReplace Unicode characters that break Windows console:\n\n```bash\n# Replace problematic Unicode characters in gateway\u002Frun.py\nsed -i 's\u002F✓\u002F[OK]\u002Fg' \u002Fhome\u002Fsap\u002Fhermes-agent\u002Fgateway\u002Frun.py\nsed -i 's\u002F✗\u002F[FAIL]\u002Fg' \u002Fhome\u002Fsap\u002Fhermes-agent\u002Fgateway\u002Frun.py\nsed -i 's\u002F🧠\u002F[BRAIN]\u002Fg' \u002Fhome\u002Fsap\u002Fhermes-agent\u002Fgateway\u002Frun.py\n\n# Or using Python (more reliable):\npython3 -c \"\nwith open('\u002Fhome\u002Fsap\u002Fhermes-agent\u002Fgateway\u002Frun.py', 'r', encoding='utf-8') as f:\n    content = f.read()\ncontent = content.replace('✓', '[OK]').replace('✗', '[FAIL]').replace('🧠', '[BRAIN]')\nwith open('\u002Fhome\u002Fsap\u002Fhermes-agent\u002Fgateway\u002Frun.py', 'w', encoding='utf-8') as f:\n    f.write(content)\nprint('Fixed Unicode characters for Windows compatibility')\n\"\n```\n\n#### Fix Missing Functions in status.py\nEnsure `gateway\u002Fstatus.py` has all required functions. If missing, restore from backup or create complete version:\n\n```python\n# Check if status.py.backup exists and restore if needed\nif [ -f \"\u002Fhome\u002Fsap\u002Fhermes-agent\u002Fgateway\u002Fstatus.py.backup\" ]; then\n    cp \"\u002Fhome\u002Fsap\u002Fhermes-agent\u002Fgateway\u002Fstatus.py.backup\" \"\u002Fhome\u002Fsap\u002Fhermes-agent\u002Fgateway\u002Fstatus.py\"\n    echo \"Restored status.py from backup\"\nelse\n    # Create minimal Windows-compatible version with all required functions\n    cat > \u002Fhome\u002Fsap\u002Fhermes-agent\u002Fgateway\u002Fstatus.py \u003C\u003C 'EOF'\n\"\"\"\nGateway runtime status helpers - Windows 兼容版本\n\"\"\"\nimport os\nimport sys\nimport json\nimport time\nfrom pathlib import Path\nfrom hermes_constants import get_hermes_home\n\ndef _get_pid_path():\n    \"\"\"Return the path to the gateway PID file.\"\"\"\n    home = get_hermes_home()\n    return home \u002F \"gateway.pid\"\n\ndef get_running_pid():\n    \"\"\"Get running gateway PID - Windows compatible version.\"\"\"\n    pid_file = _get_pid_path()\n    if not pid_file.exists():\n        return None\n    \n    try:\n        with open(pid_file, 'r', encoding='utf-8') as f:\n            data = json.load(f)\n        \n        pid = data.get('pid')\n        if not pid:\n            return None\n        \n        # Windows compatible check\n        if sys.platform == 'win32':\n            try:\n                mtime = pid_file.stat().st_mtime\n                if time.time() - mtime \u003C 300:  # 5 minutes\n                    return pid\n                return None\n            except:\n                return None\n        else:\n            # Unix\u002FLinux normal check\n            try:\n                os.kill(pid, 0)\n                return pid\n            except (OSError, ProcessLookupError):\n                return None\n                \n    except Exception:\n        return None\n\ndef remove_pid_file():\n    \"\"\"Remove the gateway PID file if it exists.\"\"\"\n    try:\n        _get_pid_path().unlink(missing_ok=True)\n    except Exception:\n        pass\n\ndef write_pid_file():\n    \"\"\"Write current process PID to gateway PID file.\"\"\"\n    pid_file = _get_pid_path()\n    pid_file.parent.mkdir(parents=True, exist_ok=True)\n    \n    data = {\n        'pid': os.getpid(),\n        'argv': list(sys.argv),\n        'platform': sys.platform\n    }\n    \n    with open(pid_file, 'w', encoding='utf-8') as f:\n        json.dump(data, f)\n\n# Add other required functions as needed\ndef write_runtime_status(**kwargs):\n    \"\"\"Stub function - implement if needed.\"\"\"\n    pass\n\ndef read_runtime_status():\n    \"\"\"Stub function - implement if needed.\"\"\"\n    return None\n\nEOF\n    echo \"Created Windows-compatible status.py with all required functions\"\nfi\n```\n\n### Option 1: Run in WSL (Recommended)\n\n1. **Check current environment**:\n   ```bash\n   pwd  # Should show \u002Fmnt\u002Fc\u002FUsers\u002F... for Windows filesystem access\n   ```\n\n2. **Navigate to Hermes installation**:\n   ```bash\n   cd \u002Fmnt\u002Fc\u002FUsers\u002Fsap\u002Fhermes-agent\n   ```\n\n3. **Create and activate virtual environment**:\n   ```bash\n   python3 -m venv hermes_venv\n   source hermes_venv\u002Fbin\u002Factivate\n   ```\n\n4. **Install core dependencies**:\n   ```bash\n   pip install httpx openai python-dotenv fire rich tenacity prompt_toolkit pyyaml requests jinja2 pydantic PyJWT debugpy\n   ```\n\n5. **Check for existing Hermes processes**:\n   ```bash\n   pgrep -f hermes\n   # If any processes found, kill them:\n   kill \u003CPID>\n   ```\n\n6. **Run Hermes Gateway**:\n   ```bash\n   python hermes gateway\n   ```\n\n### Option 2: Fix Windows Native Installation\n\n1. **Ensure Python is properly installed**:\n   ```powershell\n   python --version\n   pip --version\n   ```\n\n2. **Install Hermes in Windows Python environment**:\n   ```powershell\n   cd C:\\Users\\sap\\hermes-agent\n   pip install -e .\n   ```\n\n3. **Check Windows PATH**:\n   ```powershell\n   where hermes\n   # If not found, add Python Scripts directory to PATH\n   ```\n\n4. **Create Windows startup scripts**:\n\n   **Simple batch file** (`GO.bat`):\n   ```batch\n   @echo off\n   chcp 65001 >nul\n   title Hermes Gateway\n   color 0A\n   \n   echo.\n   echo 启动 Hermes Gateway...\n   echo.\n   \n   cd \u002Fd \"C:\\Users\\sap\\hermes-agent\"\n   \n   set PYTHONIOENCODING=utf-8\n   set PYTHONUTF8=1\n   \n   python hermes gateway\n   \n   pause\n   ```\n\n   **Comprehensive cleanup script** (`CLEAN_START.bat`):\n   ```batch\n   @echo off\n   chcp 65001 >nul\n   title Hermes Gateway - 完全清理启动\n   color 0A\n   \n   echo ===============================================\n   echo    Hermes Gateway 完全清理启动\n   echo   解决所有已知问题\n   echo ===============================================\n   echo.\n   \n   cd \u002Fd \"C:\\Users\\sap\\hermes-agent\"\n   \n   :: 1. 清理所有 logout 字符串\n   echo [1\u002F4] 清理文件错误...\n   python -c \"\n   import re\n   \n   file_path = r'gateway\\\\run.py'\n   print('检查文件:', file_path)\n   \n   with open(file_path, 'r', encoding='utf-8') as f:\n       content = f.read()\n   \n   # 查找并修复所有 logout 字符串\n   logout_count = content.count('logout')\n   if logout_count > 0:\n       print(f'找到 {logout_count} 个 logout 字符串，正在修复...')\n       # 删除独立的 logout 行\n       lines = content.split('\\\\n')\n       cleaned_lines = []\n       for line in lines:\n           if line.strip() == 'logout':\n               continue\n           cleaned_lines.append(line)\n       \n       content = '\\\\n'.join(cleaned_lines)\n       \n       with open(file_path, 'w', encoding='utf-8') as f:\n           f.write(content)\n       \n       print('修复完成！')\n   else:\n       print('没有找到 logout 字符串')\n   \"\n   \n   :: 2. 修复 Unicode 字符\n   echo [2\u002F4] 修复 Unicode 字符...\n   python -c \"\n   import re\n   \n   file_path = r'gateway\\\\run.py'\n   print('修复 Unicode 字符...')\n   \n   with open(file_path, 'r', encoding='utf-8') as f:\n       content = f.read()\n   \n   # 简单替换所有问题字符\n   content = content.replace('✓', '[OK]')\n   content = content.replace('✗', '[FAIL]')\n   content = content.replace('🧠', '[BRAIN]')\n   \n   with open(file_path, 'w', encoding='utf-8') as f:\n       f.write(content)\n   \n   print('Unicode 字符已修复')\n   \"\n   \n   :: 3. 清理 PID 文件\n   echo [3\u002F4] 清理状态文件...\n   python -c \"\n   import os\n   import sys\n   \n   sys.path.insert(0, '.')\n   try:\n       from gateway.status import remove_pid_file, release_all_scoped_locks\n       remove_pid_file()\n       removed = release_all_scoped_locks()\n       print(f'已清理 PID 文件和锁文件')\n   except Exception as e:\n       print(f'状态清理: {e}')\n   \"\n   \n   :: 4. 设置环境并启动\n   echo [4\u002F4] 启动 Hermes Gateway...\n   echo.\n   echo ===============================================\n   echo   正在启动 Hermes Gateway...\n   echo   按 Ctrl+C 停止程序\n   echo ===============================================\n   echo.\n   \n   set PYTHONIOENCODING=utf-8\n   set PYTHONUTF8=1\n   \n   python hermes gateway\n   \n   echo.\n   echo ===============================================\n   echo   Hermes Gateway 已停止\n   echo ===============================================\n   pause\n   ```\n\n   **PowerShell script** (`Start-Hermes.ps1`):\n   ```powershell\n   $hermesPath = \"C:\\Users\\sap\\hermes-agent\"\n   Set-Location $hermesPath\n   \n   # Set environment variables for UTF-8 support\n   $env:PYTHONIOENCODING = \"utf-8\"\n   $env:PYTHONUTF8 = \"1\"\n   \n   # Set console to UTF-8\n   [Console]::OutputEncoding = [System.Text.Encoding]::UTF8\n   \n   # Start Hermes Gateway\n   python hermes gateway\n   ```\n\n5. **Try alternative startup**:\n   ```powershell\n   # Use the batch file\n   .\\START_HERMES.bat\n   \n   # Or run directly\n   python hermes gateway\n   ```\n\n### Option 3: Hybrid Approach (WSL with Windows Integration)\n\n1. **Create WSL startup script**:\n   ```bash\n   cat > ~\u002Fstart_hermes_gateway.sh \u003C\u003C 'EOF'\n   #!\u002Fbin\u002Fbash\n   cd \u002Fmnt\u002Fc\u002FUsers\u002Fsap\u002Fhermes-agent\n   source hermes_venv\u002Fbin\u002Factivate\n   python hermes gateway\n   EOF\n   \n   chmod +x ~\u002Fstart_hermes_gateway.sh\n   ```\n\n2. **Create Windows shortcut**:\n   ```powershell\n   # Create a PowerShell script\n   @\"\n   wsl bash -c \"~\u002Fstart_hermes_gateway.sh\"\n   \"@ | Out-File -FilePath \"$HOME\\Desktop\\Start Hermes Gateway.ps1\" -Encoding UTF8\n   ```\n\n## Verification Steps\n\n1. **Check gateway is running**:\n   ```bash\n   pgrep -f hermes\n   ```\n\n2. **Check logs for errors**:\n   ```bash\n   tail -f ~\u002F.hermes\u002Flogs\u002Fgateway.log\n   ```\n\n3. **Verify no platform errors** (warning about no platforms configured is normal):\n   ```\n   WARNING gateway.run: No adapter available for feishu\n   ERROR gateway.run: Gateway failed to connect any configured messaging platform\n   ```\n   \n   This is expected if you haven't configured Telegram, Discord, etc.\n\n## Platform Configuration\n\nIf you want to configure messaging platforms:\n\n1. **Run setup wizard**:\n   ```bash\n   hermes gateway setup\n   ```\n\n2. **Configure specific platform** (e.g., Telegram):\n   ```bash\n   # Set environment variable\n   export TELEGRAM_BOT_TOKEN=\"your_token_here\"\n   \n   # Or add to ~\u002F.hermes\u002F.env\n   echo \"TELEGRAM_BOT_TOKEN=your_token_here\" >> ~\u002F.hermes\u002F.env\n   ```\n\n## Troubleshooting Checklist\n\n### If gateway won't start:\n- [ ] Check for existing processes: `pgrep -f hermes`\n- [ ] Kill existing processes: `kill \u003CPID>`\n- [ ] Verify Python virtual environment is activated\n- [ ] Check dependencies: `pip list | grep -E \"httpx|openai|pydantic\"`\n- [ ] Look for permission issues in `~\u002F.hermes\u002Flogs\u002F`\n- [ ] Check for Unicode characters in logs: `grep -n \"[✓✗🧠]\" gateway\u002Frun.py`\n- [ ] Check for malformed strings: `grep -n \"logout\" gateway\u002Frun.py`\n- [ ] Verify status.py has all required functions: `python -c \"from gateway.status import get_running_pid, remove_pid_file\"`\n- [ ] Set Windows environment variables: `PYTHONIOENCODING=utf-8` and `PYTHONUTF8=1`\n\n### If getting \"externally-managed-environment\" error:\n- [ ] Always use virtual environment in WSL\n- [ ] Never use `--break-system-packages`\n- [ ] Use `python3 -m venv venv_name` to create isolated environment\n\n### If gateway starts but immediately exits:\n- [ ] Check `~\u002F.hermes\u002Flogs\u002Fgateway.log` for detailed errors\n- [ ] Verify no port conflicts (default port 8080)\n- [ ] Check disk space and permissions\n- [ ] Note: `hermes gateway` does NOT support `--replace` parameter - remove it if present in startup scripts\n\n## Background Running Options\n\n### Option A: Screen Session (Simplest & Most Reliable)\nCreate `~\u002Frun-hermes-background.sh`:\n```bash\n#!\u002Fbin\u002Fbash\nSESSION_NAME=\"hermes-gateway\"\nHERMES_DIR=\"\u002Fhome\u002Fsap\u002Fhermes-agent\"\n\nif screen -list | grep -q \"$SESSION_NAME\"; then\n    echo \"Hermes Gateway already running (screen -r $SESSION_NAME)\"\n    exit 0\nfi\n\ncd \"$HERMES_DIR\"\nscreen -dmS \"$SESSION_NAME\" bash -c \"source venv\u002Fbin\u002Factivate && python hermes gateway\"\n\necho \"Hermes Gateway started in screen session: $SESSION_NAME\"\necho \"Connect to view: screen -r $SESSION_NAME\"\necho \"Detach: Ctrl+A, D\"\necho \"Stop: Connect then Ctrl+C, then 'exit'\"\n```\n\nUsage:\n```bash\nchmod +x ~\u002Frun-hermes-background.sh\n~\u002Frun-hermes-background.sh\n```\n\n### Option B: Systemd User Service\nCreate `~\u002F.config\u002Fsystemd\u002Fuser\u002Fhermes-gateway.service`:\n```ini\n[Unit]\nDescription=Hermes Gateway\nAfter=network.target\n\n[Service]\nType=simple\nWorkingDirectory=\u002Fhome\u002Fsap\u002Fhermes-agent\nExecStart=\u002Fbin\u002Fbash -c 'source venv\u002Fbin\u002Factivate && python hermes gateway'\nRestart=always\nRestartSec=10\n\n[Install]\nWantedBy=default.target\n```\n\nEnable and start:\n```bash\nsystemctl --user daemon-reload\nsystemctl --user enable hermes-gateway\nsystemctl --user start hermes-gateway\n```\n\n### Option C: System-wide Systemd Service (WSL2)\n```bash\nsudo nano \u002Fetc\u002Fsystemd\u002Fsystem\u002Fhermes-gateway.service\n```\n\nAdd:\n```ini\n[Unit]\nDescription=Hermes Gateway\nAfter=network.target\n\n[Service]\nType=simple\nUser=sap\nWorkingDirectory=\u002Fhome\u002Fsap\u002Fhermes-agent\nExecStart=\u002Fhome\u002Fsap\u002Fhermes-agent\u002Fvenv\u002Fbin\u002Fpython hermes gateway\nRestart=on-failure\n\n[Install]\nWantedBy=multi-user.target\n```\n\nEnable:\n```bash\nsudo systemctl enable hermes-gateway\nsudo systemctl start hermes-gateway\n```\n\n## Quick Fix Commands\n\n```bash\n# One-liner to fix common issues\ncd \u002Fmnt\u002Fc\u002FUsers\u002Fsap\u002Fhermes-agent && \\\npython3 -c \"\nimport re, sys\nwith open('gateway\u002Frun.py','r',encoding='utf-8') as f: c=f.read()\nc=c.replace('✓','[OK]').replace('✗','[FAIL]').replace('🧠','[BRAIN]')\nc='\\\\n'.join([l for l in c.split('\\\\n') if l.strip()!='logout'])\nwith open('gateway\u002Frun.py','w',encoding='utf-8') as f: f.write(c)\nprint('Fixed Unicode and logout strings')\n\"\n\n# Verify fixes\npython3 -m py_compile gateway\u002Frun.py && echo \"Syntax OK\" || echo \"Syntax error\"\npython3 -c \"from gateway.status import get_running_pid, remove_pid_file\" && echo \"Imports OK\" || echo \"Import error\"\n```\n\n## Environment Setup for Windows\n\nAlways set these environment variables for Windows:\n```batch\nset PYTHONIOENCODING=utf-8\nset PYTHONUTF8=1\nchcp 65001  # Set console to UTF-8\n```\n\n## Related Resources\n\n- [Hermes Agent Documentation](https:\u002F\u002Fhermes-agent.nousresearch.com\u002Fdocs\u002F)\n- [Messaging Platforms Guide](https:\u002F\u002Fhermes-agent.nousresearch.com\u002Fdocs\u002Fuser-guide\u002Fmessaging\u002F)\n- [WSL Documentation](https:\u002F\u002Fdocs.microsoft.com\u002Fen-us\u002Fwindows\u002Fwsl\u002F)","# Hermes Gateway Windows\u002FWSL Troubleshooting\n\nThis skill addresses common issues when running Hermes Gateway on Windows and WSL environments, particularly process management compatibility errors.\n\n## Common Error Patterns\n\n### Error 1: Windows Process Management Compatibility\n```\nTraceback (most recent call last):\n  File \"hermes_cli\u002Fgateway.py\", line 1305, in run_gateway\n    success = asyncio.run(start_gateway(replace=replace, verbosity=verbosity))\n  File \"asyncio\u002Frunners.py\", line 190, in run\n    return runner.run(main)\n  File \"asyncio\u002Frunners.py\", line 118, in run\n    return self._loop.run_until_complete(task)\n  File \"asyncio\u002Fbase_events.py\", line 654, in run_until_complete\n    return future.result()\n  File \"gateway\u002Frun.py\", line 7409, in start_gateway\n    existing_pid = get_running_pid()\n  File \"gateway\u002Fstatus.py\", line 370, in get_running_pid\n    os.kill(pid, 0)  # signal 0 = existence check, no actual signal sent\nOSError: [WinError 11] 试图加载格式不正确的程序\n```\n\n**Root Cause**: Hermes uses Unix-style process management (`os.kill(pid, 0)`) which has compatibility issues on native Windows. The `os.kill()` function with signal 0 (process existence check) fails on Windows with error 11.\n\n**Direct Solution**: Patch the `get_running_pid()` function in `gateway\u002Fstatus.py` to be Windows-compatible:\n\n```python\ndef get_running_pid():\n    \"\"\"\n    获取当前运行的 Hermes Gateway 进程 PID\n    Windows 兼容版本：跳过有问题的 os.kill 检查\n    \"\"\"\n    pid_file = _pid_file_path()\n    if not pid_file.exists():\n        return None\n    \n    try:\n        with open(pid_file, 'r', encoding='utf-8') as f:\n            data = json.load(f)\n        \n        pid = data.get('pid')\n        if not pid:\n            return None\n        \n        # Windows 兼容检查：只检查文件是否存在，不调用 os.kill\n        if sys.platform == 'win32':\n            # 在 Windows 上，我们只检查 PID 文件是否有效\n            # 不进行实际的进程检查，避免 \"试图加载格式不正确的程序\" 错误\n            try:\n                # 简单检查：如果 PID 文件最近被修改过，假设进程还在运行\n                mtime = pid_file.stat().st_mtime\n                if time.time() - mtime \u003C 300:  # 5分钟内修改过\n                    return pid\n                return None\n            except:\n                return None\n        else:\n            # Unix\u002FLinux: 正常检查\n            try:\n                os.kill(pid, 0)\n                return pid\n            except (OSError, ProcessLookupError):\n                return None\n                \n    except Exception:\n        return None\n```\n\n**Required imports** (add to top of `gateway\u002Fstatus.py` if missing):\n```python\nimport os\nimport sys\nimport json\nimport time\nfrom pathlib import Path\n```\n\n### Error 2: Corrupted Python Files\n```\nSyntaxError: invalid syntax\n  File \"\u002Fhome\u002Fsap\u002Fhermes-agent\u002Fgateway\u002Frun.py\", line 1063\n    \"GATEWAY_ALLOWED_USERS\")\n    ^^^^^^^^^^^^^^^^^^^^^^^\nSyntaxError: invalid syntax\n```\n\n**Root Cause**: Python files may contain corrupted `logout` strings inserted into code, breaking syntax. Common patterns:\n- `selflogout` instead of `self`\n- `faillogout` instead of `failed` \n- Broken strings across lines\n- Missing platform names like `Plogout\\nlatform.logout\\nSLACK:` instead of `Platform.SLACK:`\n- Standalone `logout` lines causing indentation errors\n\n### Error 3: Unicode Encoding Errors in Windows Console\n```\n--- Logging error ---\nTraceback (most recent call last):\n  File \"C:\\Python311\\Lib\\logging\\__init__.py\", line 1113, in emit\n    stream.write(msg + self.terminator)\nUnicodeEncodeError: 'gbk' codec can't encode character '\\u2713' in position 42: illegal multibyte sequence\nMessage: '✓ %s connected'\nArguments: ('webhook',)\n```\n\n**Root Cause**: Windows console uses GBK encoding by default, cannot handle Unicode characters like checkmarks (✓ U+2713, ✗ U+2717, 🧠 U+1F9E0) used in Hermes logging.\n\n### Error 4: Missing Function Import Errors\n```\nImportError: cannot import name 'remove_pid_file' from 'gateway.status'\n```\n\n**Root Cause**: Simplified or corrupted `gateway\u002Fstatus.py` missing required functions that `gateway\u002Frun.py` expects to import.\n\n### Error 3: Missing Dependencies in WSL\n```\nModuleNotFoundError: No module named 'httpx'\n```\n\n**Root Cause**: Python's externally-managed environment restrictions in WSL prevent system-wide package installation.\n\n## Solutions\n\n### Step 0: Fix All Common File Issues\n\n#### Fix Corrupted Python Files\nIf getting syntax errors, check and fix corrupted files:\n\n```bash\n# Search for corrupted 'logout' strings\ngrep -n \"logout\" \u002Fhome\u002Fsap\u002Fhermes-agent\u002Fgateway\u002Frun.py\n\n# Remove standalone logout lines (causes indentation errors)\nsed -i '\u002F^[[:space:]]*logout[[:space:]]*$\u002Fd' \u002Fhome\u002Fsap\u002Fhermes-agent\u002Fgateway\u002Frun.py\n\n# Or using Python:\npython3 -c \"\nwith open('\u002Fhome\u002Fsap\u002Fhermes-agent\u002Fgateway\u002Frun.py', 'r', encoding='utf-8') as f:\n    lines = [line for line in f if line.strip() != 'logout']\nwith open('\u002Fhome\u002Fsap\u002Fhermes-agent\u002Fgateway\u002Frun.py', 'w', encoding='utf-8') as f:\n    f.writelines(lines)\nprint('Removed standalone logout lines')\n\"\n\n# Common fixes using patch tool\n# Fix broken variable names\npatch(mode='replace', path='\u002Fhome\u002Fsap\u002Fhermes-agent\u002Fgateway\u002Frun.py',\n      old_string='selflogout', new_string='self', replace_all=True)\n\n# Fix broken strings\npatch(mode='replace', path='\u002Fhome\u002Fsap\u002Fhermes-agent\u002Fgateway\u002Frun.py',\n      old_string='logger.debug(\"Plugin command dispatch faillogout\\ned (non-fatal): %s\", e)',\n      new_string='logger.debug(\"Plugin command dispatch failed (non-fatal): %s\", e)')\n\n# Fix broken platform names  \npatch(mode='replace', path='\u002Fhome\u002Fsap\u002Fhermes-agent\u002Fgateway\u002Frun.py',\n      old_string='elif platform == Plogout\\nlatform.logout\\nSLACK:',\n      new_string='elif platform == Platform.SLACK:')\n```\n\n#### Fix Unicode Encoding Errors\nReplace Unicode characters that break Windows console:\n\n```bash\n# Replace problematic Unicode characters in gateway\u002Frun.py\nsed -i 's\u002F✓\u002F[OK]\u002Fg' \u002Fhome\u002Fsap\u002Fhermes-agent\u002Fgateway\u002Frun.py\nsed -i 's\u002F✗\u002F[FAIL]\u002Fg' \u002Fhome\u002Fsap\u002Fhermes-agent\u002Fgateway\u002Frun.py\nsed -i 's\u002F🧠\u002F[BRAIN]\u002Fg' \u002Fhome\u002Fsap\u002Fhermes-agent\u002Fgateway\u002Frun.py\n\n# Or using Python (more reliable):\npython3 -c \"\nwith open('\u002Fhome\u002Fsap\u002Fhermes-agent\u002Fgateway\u002Frun.py', 'r', encoding='utf-8') as f:\n    content = f.read()\ncontent = content.replace('✓', '[OK]').replace('✗', '[FAIL]').replace('🧠', '[BRAIN]')\nwith open('\u002Fhome\u002Fsap\u002Fhermes-agent\u002Fgateway\u002Frun.py', 'w', encoding='utf-8') as f:\n    f.write(content)\nprint('Fixed Unicode characters for Windows compatibility')\n\"\n```\n\n#### Fix Missing Functions in status.py\nEnsure `gateway\u002Fstatus.py` has all required functions. If missing, restore from backup or create complete version:\n\n```python\n# Check if status.py.backup exists and restore if needed\nif [ -f \"\u002Fhome\u002Fsap\u002Fhermes-agent\u002Fgateway\u002Fstatus.py.backup\" ]; then\n    cp \"\u002Fhome\u002Fsap\u002Fhermes-agent\u002Fgateway\u002Fstatus.py.backup\" \"\u002Fhome\u002Fsap\u002Fhermes-agent\u002Fgateway\u002Fstatus.py\"\n    echo \"Restored status.py from backup\"\nelse\n    # Create minimal Windows-compatible version with all required functions\n    cat > \u002Fhome\u002Fsap\u002Fhermes-agent\u002Fgateway\u002Fstatus.py \u003C\u003C 'EOF'\n\"\"\"\nGateway runtime status helpers - Windows 兼容版本\n\"\"\"\nimport os\nimport sys\nimport json\nimport time\nfrom pathlib import Path\nfrom hermes_constants import get_hermes_home\n\ndef _get_pid_path():\n    \"\"\"Return the path to the gateway PID file.\"\"\"\n    home = get_hermes_home()\n    return home \u002F \"gateway.pid\"\n\ndef get_running_pid():\n    \"\"\"Get running gateway PID - Windows compatible version.\"\"\"\n    pid_file = _get_pid_path()\n    if not pid_file.exists():\n        return None\n    \n    try:\n        with open(pid_file, 'r', encoding='utf-8') as f:\n            data = json.load(f)\n        \n        pid = data.get('pid')\n        if not pid:\n            return None\n        \n        # Windows compatible check\n        if sys.platform == 'win32':\n            try:\n                mtime = pid_file.stat().st_mtime\n                if time.time() - mtime \u003C 300:  # 5 minutes\n                    return pid\n                return None\n            except:\n                return None\n        else:\n            # Unix\u002FLinux normal check\n            try:\n                os.kill(pid, 0)\n                return pid\n            except (OSError, ProcessLookupError):\n                return None\n                \n    except Exception:\n        return None\n\ndef remove_pid_file():\n    \"\"\"Remove the gateway PID file if it exists.\"\"\"\n    try:\n        _get_pid_path().unlink(missing_ok=True)\n    except Exception:\n        pass\n\ndef write_pid_file():\n    \"\"\"Write current process PID to gateway PID file.\"\"\"\n    pid_file = _get_pid_path()\n    pid_file.parent.mkdir(parents=True, exist_ok=True)\n    \n    data = {\n        'pid': os.getpid(),\n        'argv': list(sys.argv),\n        'platform': sys.platform\n    }\n    \n    with open(pid_file, 'w', encoding='utf-8') as f:\n        json.dump(data, f)\n\n# Add other required functions as needed\ndef write_runtime_status(**kwargs):\n    \"\"\"Stub function - implement if needed.\"\"\"\n    pass\n\ndef read_runtime_status():\n    \"\"\"Stub function - implement if needed.\"\"\"\n    return None\n\nEOF\n    echo \"Created Windows-compatible status.py with all required functions\"\nfi\n```\n\n### Option 1: Run in WSL (Recommended)\n\n1. **Check current environment**:\n   ```bash\n   pwd  # Should show \u002Fmnt\u002Fc\u002FUsers\u002F... for Windows filesystem access\n   ```\n\n2. **Navigate to Hermes installation**:\n   ```bash\n   cd \u002Fmnt\u002Fc\u002FUsers\u002Fsap\u002Fhermes-agent\n   ```\n\n3. **Create and activate virtual environment**:\n   ```bash\n   python3 -m venv hermes_venv\n   source hermes_venv\u002Fbin\u002Factivate\n   ```\n\n4. **Install core dependencies**:\n   ```bash\n   pip install httpx openai python-dotenv fire rich tenacity prompt_toolkit pyyaml requests jinja2 pydantic PyJWT debugpy\n   ```\n\n5. **Check for existing Hermes processes**:\n   ```bash\n   pgrep -f hermes\n   # If any processes found, kill them:\n   kill \u003CPID>\n   ```\n\n6. **Run Hermes Gateway**:\n   ```bash\n   python hermes gateway\n   ```\n\n### Option 2: Fix Windows Native Installation\n\n1. **Ensure Python is properly installed**:\n   ```powershell\n   python --version\n   pip --version\n   ```\n\n2. **Install Hermes in Windows Python environment**:\n   ```powershell\n   cd C:\\Users\\sap\\hermes-agent\n   pip install -e .\n   ```\n\n3. **Check Windows PATH**:\n   ```powershell\n   where hermes\n   # If not found, add Python Scripts directory to PATH\n   ```\n\n4. **Create Windows startup scripts**:\n\n   **Simple batch file** (`GO.bat`):\n   ```batch\n   @echo off\n   chcp 65001 >nul\n   title Hermes Gateway\n   color 0A\n   \n   echo.\n   echo 启动 Hermes Gateway...\n   echo.\n   \n   cd \u002Fd \"C:\\Users\\sap\\hermes-agent\"\n   \n   set PYTHONIOENCODING=utf-8\n   set PYTHONUTF8=1\n   \n   python hermes gateway\n   \n   pause\n   ```\n\n   **Comprehensive cleanup script** (`CLEAN_START.bat`):\n   ```batch\n   @echo off\n   chcp 65001 >nul\n   title Hermes Gateway - 完全清理启动\n   color 0A\n   \n   echo ===============================================\n   echo    Hermes Gateway 完全清理启动\n   echo   解决所有已知问题\n   echo ===============================================\n   echo.\n   \n   cd \u002Fd \"C:\\Users\\sap\\hermes-agent\"\n   \n   :: 1. 清理所有 logout 字符串\n   echo [1\u002F4] 清理文件错误...\n   python -c \"\n   import re\n   \n   file_path = r'gateway\\\\run.py'\n   print('检查文件:', file_path)\n   \n   with open(file_path, 'r', encoding='utf-8') as f:\n       content = f.read()\n   \n   # 查找并修复所有 logout 字符串\n   logout_count = content.count('logout')\n   if logout_count > 0:\n       print(f'找到 {logout_count} 个 logout 字符串，正在修复...')\n       # 删除独立的 logout 行\n       lines = content.split('\\\\n')\n       cleaned_lines = []\n       for line in lines:\n           if line.strip() == 'logout':\n               continue\n           cleaned_lines.append(line)\n       \n       content = '\\\\n'.join(cleaned_lines)\n       \n       with open(file_path, 'w', encoding='utf-8') as f:\n           f.write(content)\n       \n       print('修复完成！')\n   else:\n       print('没有找到 logout 字符串')\n   \"\n   \n   :: 2. 修复 Unicode 字符\n   echo [2\u002F4] 修复 Unicode 字符...\n   python -c \"\n   import re\n   \n   file_path = r'gateway\\\\run.py'\n   print('修复 Unicode 字符...')\n   \n   with open(file_path, 'r', encoding='utf-8') as f:\n       content = f.read()\n   \n   # 简单替换所有问题字符\n   content = content.replace('✓', '[OK]')\n   content = content.replace('✗', '[FAIL]')\n   content = content.replace('🧠', '[BRAIN]')\n   \n   with open(file_path, 'w', encoding='utf-8') as f:\n       f.write(content)\n   \n   print('Unicode 字符已修复')\n   \"\n   \n   :: 3. 清理 PID 文件\n   echo [3\u002F4] 清理状态文件...\n   python -c \"\n   import os\n   import sys\n   \n   sys.path.insert(0, '.')\n   try:\n       from gateway.status import remove_pid_file, release_all_scoped_locks\n       remove_pid_file()\n       removed = release_all_scoped_locks()\n       print(f'已清理 PID 文件和锁文件')\n   except Exception as e:\n       print(f'状态清理: {e}')\n   \"\n   \n   :: 4. 设置环境并启动\n   echo [4\u002F4] 启动 Hermes Gateway...\n   echo.\n   echo ===============================================\n   echo   正在启动 Hermes Gateway...\n   echo   按 Ctrl+C 停止程序\n   echo ===============================================\n   echo.\n   \n   set PYTHONIOENCODING=utf-8\n   set PYTHONUTF8=1\n   \n   python hermes gateway\n   \n   echo.\n   echo ===============================================\n   echo   Hermes Gateway 已停止\n   echo ===============================================\n   pause\n   ```\n\n   **PowerShell script** (`Start-Hermes.ps1`):\n   ```powershell\n   $hermesPath = \"C:\\Users\\sap\\hermes-agent\"\n   Set-Location $hermesPath\n   \n   # Set environment variables for UTF-8 support\n   $env:PYTHONIOENCODING = \"utf-8\"\n   $env:PYTHONUTF8 = \"1\"\n   \n   # Set console to UTF-8\n   [Console]::OutputEncoding = [System.Text.Encoding]::UTF8\n   \n   # Start Hermes Gateway\n   python hermes gateway\n   ```\n\n5. **Try alternative startup**:\n   ```powershell\n   # Use the batch file\n   .\\START_HERMES.bat\n   \n   # Or run directly\n   python hermes gateway\n   ```\n\n### Option 3: Hybrid Approach (WSL with Windows Integration)\n\n1. **Create WSL startup script**:\n   ```bash\n   cat > ~\u002Fstart_hermes_gateway.sh \u003C\u003C 'EOF'\n   #!\u002Fbin\u002Fbash\n   cd \u002Fmnt\u002Fc\u002FUsers\u002Fsap\u002Fhermes-agent\n   source hermes_venv\u002Fbin\u002Factivate\n   python hermes gateway\n   EOF\n   \n   chmod +x ~\u002Fstart_hermes_gateway.sh\n   ```\n\n2. **Create Windows shortcut**:\n   ```powershell\n   # Create a PowerShell script\n   @\"\n   wsl bash -c \"~\u002Fstart_hermes_gateway.sh\"\n   \"@ | Out-File -FilePath \"$HOME\\Desktop\\Start Hermes Gateway.ps1\" -Encoding UTF8\n   ```\n\n## Verification Steps\n\n1. **Check gateway is running**:\n   ```bash\n   pgrep -f hermes\n   ```\n\n2. **Check logs for errors**:\n   ```bash\n   tail -f ~\u002F.hermes\u002Flogs\u002Fgateway.log\n   ```\n\n3. **Verify no platform errors** (warning about no platforms configured is normal):\n   ```\n   WARNING gateway.run: No adapter available for feishu\n   ERROR gateway.run: Gateway failed to connect any configured messaging platform\n   ```\n   \n   This is expected if you haven't configured Telegram, Discord, etc.\n\n## Platform Configuration\n\nIf you want to configure messaging platforms:\n\n1. **Run setup wizard**:\n   ```bash\n   hermes gateway setup\n   ```\n\n2. **Configure specific platform** (e.g., Telegram):\n   ```bash\n   # Set environment variable\n   export TELEGRAM_BOT_TOKEN=\"your_token_here\"\n   \n   # Or add to ~\u002F.hermes\u002F.env\n   echo \"TELEGRAM_BOT_TOKEN=your_token_here\" >> ~\u002F.hermes\u002F.env\n   ```\n\n## Troubleshooting Checklist\n\n### If gateway won't start:\n- [ ] Check for existing processes: `pgrep -f hermes`\n- [ ] Kill existing processes: `kill \u003CPID>`\n- [ ] Verify Python virtual environment is activated\n- [ ] Check dependencies: `pip list | grep -E \"httpx|openai|pydantic\"`\n- [ ] Look for permission issues in `~\u002F.hermes\u002Flogs\u002F`\n- [ ] Check for Unicode characters in logs: `grep -n \"[✓✗🧠]\" gateway\u002Frun.py`\n- [ ] Check for malformed strings: `grep -n \"logout\" gateway\u002Frun.py`\n- [ ] Verify status.py has all required functions: `python -c \"from gateway.status import get_running_pid, remove_pid_file\"`\n- [ ] Set Windows environment variables: `PYTHONIOENCODING=utf-8` and `PYTHONUTF8=1`\n\n### If getting \"externally-managed-environment\" error:\n- [ ] Always use virtual environment in WSL\n- [ ] Never use `--break-system-packages`\n- [ ] Use `python3 -m venv venv_name` to create isolated environment\n\n### If gateway starts but immediately exits:\n- [ ] Check `~\u002F.hermes\u002Flogs\u002Fgateway.log` for detailed errors\n- [ ] Verify no port conflicts (default port 8080)\n- [ ] Check disk space and permissions\n- [ ] Note: `hermes gateway` does NOT support `--replace` parameter - remove it if present in startup scripts\n\n## Background Running Options\n\n### Option A: Screen Session (Simplest & Most Reliable)\nCreate `~\u002Frun-hermes-background.sh`:\n```bash\n#!\u002Fbin\u002Fbash\nSESSION_NAME=\"hermes-gateway\"\nHERMES_DIR=\"\u002Fhome\u002Fsap\u002Fhermes-agent\"\n\nif screen -list | grep -q \"$SESSION_NAME\"; then\n    echo \"Hermes Gateway already running (screen -r $SESSION_NAME)\"\n    exit 0\nfi\n\ncd \"$HERMES_DIR\"\nscreen -dmS \"$SESSION_NAME\" bash -c \"source venv\u002Fbin\u002Factivate && python hermes gateway\"\n\necho \"Hermes Gateway started in screen session: $SESSION_NAME\"\necho \"Connect to view: screen -r $SESSION_NAME\"\necho \"Detach: Ctrl+A, D\"\necho \"Stop: Connect then Ctrl+C, then 'exit'\"\n```\n\nUsage:\n```bash\nchmod +x ~\u002Frun-hermes-background.sh\n~\u002Frun-hermes-background.sh\n```\n\n### Option B: Systemd User Service\nCreate `~\u002F.config\u002Fsystemd\u002Fuser\u002Fhermes-gateway.service`:\n```ini\n[Unit]\nDescription=Hermes Gateway\nAfter=network.target\n\n[Service]\nType=simple\nWorkingDirectory=\u002Fhome\u002Fsap\u002Fhermes-agent\nExecStart=\u002Fbin\u002Fbash -c 'source venv\u002Fbin\u002Factivate && python hermes gateway'\nRestart=always\nRestartSec=10\n\n[Install]\nWantedBy=default.target\n```\n\nEnable and start:\n```bash\nsystemctl --user daemon-reload\nsystemctl --user enable hermes-gateway\nsystemctl --user start hermes-gateway\n```\n\n### Option C: System-wide Systemd Service (WSL2)\n```bash\nsudo nano \u002Fetc\u002Fsystemd\u002Fsystem\u002Fhermes-gateway.service\n```\n\nAdd:\n```ini\n[Unit]\nDescription=Hermes Gateway\nAfter=network.target\n\n[Service]\nType=simple\nUser=sap\nWorkingDirectory=\u002Fhome\u002Fsap\u002Fhermes-agent\nExecStart=\u002Fhome\u002Fsap\u002Fhermes-agent\u002Fvenv\u002Fbin\u002Fpython hermes gateway\nRestart=on-failure\n\n[Install]\nWantedBy=multi-user.target\n```\n\nEnable:\n```bash\nsudo systemctl enable hermes-gateway\nsudo systemctl start hermes-gateway\n```\n\n## Quick Fix Commands\n\n```bash\n# One-liner to fix common issues\ncd \u002Fmnt\u002Fc\u002FUsers\u002Fsap\u002Fhermes-agent && \\\npython3 -c \"\nimport re, sys\nwith open('gateway\u002Frun.py','r',encoding='utf-8') as f: c=f.read()\nc=c.replace('✓','[OK]').replace('✗','[FAIL]').replace('🧠','[BRAIN]')\nc='\\\\n'.join([l for l in c.split('\\\\n') if l.strip()!='logout'])\nwith open('gateway\u002Frun.py','w',encoding='utf-8') as f: f.write(c)\nprint('Fixed Unicode and logout strings')\n\"\n\n# Verify fixes\npython3 -m py_compile gateway\u002Frun.py && echo \"Syntax OK\" || echo \"Syntax error\"\npython3 -c \"from gateway.status import get_running_pid, remove_pid_file\" && echo \"Imports OK\" || echo \"Import error\"\n```\n\n## Environment Setup for Windows\n\nAlways set these environment variables for Windows:\n```batch\nset PYTHONIOENCODING=utf-8\nset PYTHONUTF8=1\nchcp 65001  # Set console to UTF-8\n```\n\n## Related Resources\n\n- [Hermes Agent Documentation](https:\u002F\u002Fhermes-agent.nousresearch.com\u002Fdocs\u002F)\n- [Messaging Platforms Guide](https:\u002F\u002Fhermes-agent.nousresearch.com\u002Fdocs\u002Fuser-guide\u002Fmessaging\u002F)\n- [WSL Documentation](https:\u002F\u002Fdocs.microsoft.com\u002Fen-us\u002Fwindows\u002Fwsl\u002F)",{"name":5,"author":43,"license":15,"version":44,"metadata":45,"description":7},"Hermes Agent","1.0.0",{"hermes":46},{"tags":47,"platforms":49,"related_skills":50},[22,21,20,48,35,30],"wsl",[20,48,32],[27],"main","7a38d8e7073e61c16eda85681cb32fb68a8657a5","skills-store\u002Fhermes\u002Fhermes-windows-wsl-gateway","https:\u002F\u002Fgithub.com\u002Fsapsapshen\u002Fai-memory-router","https:\u002F\u002Fgithub.com\u002Fsapsapshen","2026-04-14 21:12:12",{"source":8,"skillName":5,"commands":58,"prompt":68,"zipAvailable":69},[59,62,65],{"tool":60,"command":61},"npx","npx skills add sapsapshen\u002Fai-memory-router --skill hermes-windows-wsl-gateway",{"tool":63,"command":64},"bunx","bunx skills add sapsapshen\u002Fai-memory-router --skill hermes-windows-wsl-gateway",{"tool":66,"command":67},"pnpm","pnpm dlx skills add sapsapshen\u002Fai-memory-router --skill hermes-windows-wsl-gateway","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fsapsapshen\u002Fai-memory-router\u002Fblob\u002Fmain\u002Fskills-store\u002Fhermes\u002Fhermes-windows-wsl-gateway\u002FSKILL.md",true,[],[72,82,89,97,103,111],{"skillNo":73,"name":74,"nameZh":6,"description":75,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":76,"licenseFileUrl":77,"sourceHtmlUrl":78,"categories":79,"keywords":80,"publishedAt":81},"01M72R8PZX1ABFHJGTYPA4CAF1","webapp-testing","To test local web applications, write native Python Playwright scripts.","Apache-2.0","https:\u002F\u002Fgithub.com\u002Fsapsapshen\u002Fai-memory-router\u002Fblob\u002Fmain\u002Fskills-store\u002Fglobal\u002Fwebapp-testing\u002FLICENSE.txt","https:\u002F\u002Fgithub.com\u002Fsapsapshen\u002Fai-memory-router\u002Fblob\u002Fmain\u002Fskills-store\u002Fglobal\u002Fwebapp-testing\u002FSKILL.md",[],[],"2026-11-10 22:39:42",{"skillNo":83,"name":84,"nameZh":6,"description":85,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":86,"categories":87,"keywords":88,"publishedAt":81},"01M72QG37MMZNDY7X7GXPAK5W6","python-packaging","Comprehensive guide to creating, structuring, and distributing Python packages using modern packaging tools, pyproject.toml, and publishing to PyPI.","https:\u002F\u002Fgithub.com\u002Fsapsapshen\u002Fai-memory-router\u002Fblob\u002Fmain\u002Fskills-store\u002Fglobal\u002Fpython-packaging\u002FSKILL.md",[],[],{"skillNo":90,"name":91,"nameZh":6,"description":92,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":76,"licenseFileUrl":93,"sourceHtmlUrl":94,"categories":95,"keywords":96,"publishedAt":81},"01M72NXR0QMP9G46TW6A2DH59C","canvas-design","These are instructions for creating design philosophies - aesthetic movements that are then EXPRESSED VISUALLY. Output only .md files, .pdf files, and .png files.","https:\u002F\u002Fgithub.com\u002Fsapsapshen\u002Fai-memory-router\u002Fblob\u002Fmain\u002Fskills-store\u002Fglobal\u002Fcanvas-design\u002FLICENSE.txt","https:\u002F\u002Fgithub.com\u002Fsapsapshen\u002Fai-memory-router\u002Fblob\u002Fmain\u002Fskills-store\u002Fglobal\u002Fcanvas-design\u002FSKILL.md",[],[],{"skillNo":98,"name":74,"nameZh":6,"description":75,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":76,"licenseFileUrl":99,"sourceHtmlUrl":100,"categories":101,"keywords":102,"publishedAt":81},"01M72N55TK3EEQ4QK4AWDC2KZS","https:\u002F\u002Fgithub.com\u002Fsapsapshen\u002Fai-memory-router\u002Fblob\u002Fmain\u002Fskills-store\u002Fcursor\u002Fwebapp-testing\u002FLICENSE.txt","https:\u002F\u002Fgithub.com\u002Fsapsapshen\u002Fai-memory-router\u002Fblob\u002Fmain\u002Fskills-store\u002Fcursor\u002Fwebapp-testing\u002FSKILL.md",[],[],{"skillNo":104,"name":105,"nameZh":6,"description":106,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":76,"licenseFileUrl":107,"sourceHtmlUrl":108,"categories":109,"keywords":110,"publishedAt":81},"01M72MTWC150CFAP4Y5GSNKF80","slack-gif-creator","A toolkit providing utilities and knowledge for creating animated GIFs optimized for Slack.","https:\u002F\u002Fgithub.com\u002Fsapsapshen\u002Fai-memory-router\u002Fblob\u002Fmain\u002Fskills-store\u002Fcursor\u002Fslack-gif-creator\u002FLICENSE.txt","https:\u002F\u002Fgithub.com\u002Fsapsapshen\u002Fai-memory-router\u002Fblob\u002Fmain\u002Fskills-store\u002Fcursor\u002Fslack-gif-creator\u002FSKILL.md",[],[],{"skillNo":112,"name":113,"nameZh":6,"description":114,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":76,"licenseFileUrl":115,"sourceHtmlUrl":116,"categories":117,"keywords":118,"publishedAt":81},"01M72KPT3VVNSP88MNAY466TZT","frontend-design","You are a frontend designer-engineer, not a layout generator.","https:\u002F\u002Fgithub.com\u002Fsapsapshen\u002Fai-memory-router\u002Fblob\u002Fmain\u002Fskills-store\u002Fcursor\u002Ffrontend-design\u002FLICENSE.txt","https:\u002F\u002Fgithub.com\u002Fsapsapshen\u002Fai-memory-router\u002Fblob\u002Fmain\u002Fskills-store\u002Fcursor\u002Ffrontend-design\u002FSKILL.md",[],[]]