wechatbridge-cli 1.10.0__tar.gz → 1.12.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. wechatbridge_cli-1.12.0/PKG-INFO +325 -0
  2. wechatbridge_cli-1.12.0/README.md +293 -0
  3. {wechatbridge_cli-1.10.0 → wechatbridge_cli-1.12.0}/tests/test_codex.py +100 -106
  4. {wechatbridge_cli-1.10.0 → wechatbridge_cli-1.12.0}/tests/test_codex_auth.py +4 -10
  5. {wechatbridge_cli-1.10.0 → wechatbridge_cli-1.12.0}/tests/test_dsh.py +128 -165
  6. {wechatbridge_cli-1.10.0 → wechatbridge_cli-1.12.0}/tests/test_grok_auth.py +3 -5
  7. {wechatbridge_cli-1.10.0 → wechatbridge_cli-1.12.0}/tests/test_hardening.py +1349 -629
  8. {wechatbridge_cli-1.10.0 → wechatbridge_cli-1.12.0}/tests/test_pig.py +61 -65
  9. {wechatbridge_cli-1.10.0 → wechatbridge_cli-1.12.0}/wechatbridge/__init__.py +1 -1
  10. {wechatbridge_cli-1.10.0 → wechatbridge_cli-1.12.0}/wechatbridge/agy.py +66 -79
  11. {wechatbridge_cli-1.10.0 → wechatbridge_cli-1.12.0}/wechatbridge/codex.py +63 -68
  12. {wechatbridge_cli-1.10.0 → wechatbridge_cli-1.12.0}/wechatbridge/config.py +25 -21
  13. {wechatbridge_cli-1.10.0 → wechatbridge_cli-1.12.0}/wechatbridge/dsh.py +75 -85
  14. {wechatbridge_cli-1.10.0 → wechatbridge_cli-1.12.0}/wechatbridge/grok.py +57 -61
  15. {wechatbridge_cli-1.10.0 → wechatbridge_cli-1.12.0}/wechatbridge/ilink.py +83 -24
  16. {wechatbridge_cli-1.10.0 → wechatbridge_cli-1.12.0}/wechatbridge/main.py +1166 -508
  17. {wechatbridge_cli-1.10.0 → wechatbridge_cli-1.12.0}/wechatbridge/pig.py +44 -47
  18. {wechatbridge_cli-1.10.0 → wechatbridge_cli-1.12.0}/wechatbridge/runner_common.py +212 -120
  19. {wechatbridge_cli-1.10.0 → wechatbridge_cli-1.12.0}/wechatbridge/update_check.py +8 -10
  20. wechatbridge_cli-1.12.0/wechatbridge_cli.egg-info/PKG-INFO +325 -0
  21. wechatbridge_cli-1.10.0/PKG-INFO +0 -421
  22. wechatbridge_cli-1.10.0/README.md +0 -389
  23. wechatbridge_cli-1.10.0/wechatbridge_cli.egg-info/PKG-INFO +0 -421
  24. {wechatbridge_cli-1.10.0 → wechatbridge_cli-1.12.0}/LICENSE +0 -0
  25. {wechatbridge_cli-1.10.0 → wechatbridge_cli-1.12.0}/pyproject.toml +0 -0
  26. {wechatbridge_cli-1.10.0 → wechatbridge_cli-1.12.0}/setup.cfg +0 -0
  27. {wechatbridge_cli-1.10.0 → wechatbridge_cli-1.12.0}/tests/test_price.py +0 -0
  28. {wechatbridge_cli-1.10.0 → wechatbridge_cli-1.12.0}/wechatbridge/__main__.py +0 -0
  29. {wechatbridge_cli-1.10.0 → wechatbridge_cli-1.12.0}/wechatbridge/price.py +0 -0
  30. {wechatbridge_cli-1.10.0 → wechatbridge_cli-1.12.0}/wechatbridge_cli.egg-info/SOURCES.txt +0 -0
  31. {wechatbridge_cli-1.10.0 → wechatbridge_cli-1.12.0}/wechatbridge_cli.egg-info/dependency_links.txt +0 -0
  32. {wechatbridge_cli-1.10.0 → wechatbridge_cli-1.12.0}/wechatbridge_cli.egg-info/entry_points.txt +0 -0
  33. {wechatbridge_cli-1.10.0 → wechatbridge_cli-1.12.0}/wechatbridge_cli.egg-info/requires.txt +0 -0
  34. {wechatbridge_cli-1.10.0 → wechatbridge_cli-1.12.0}/wechatbridge_cli.egg-info/top_level.txt +0 -0
@@ -0,0 +1,325 @@
1
+ Metadata-Version: 2.4
2
+ Name: wechatbridge-cli
3
+ Version: 1.12.0
4
+ Summary: Bridge WeChat messages to agy, Grok Build, Codex, dsh, or pig CLIs — text/image/file/voice in, CLI replies and generated files back.
5
+ Author: WeChatBridge contributors
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/dorokuma/wechatbridge
8
+ Project-URL: Repository, https://github.com/dorokuma/wechatbridge
9
+ Project-URL: Issues, https://github.com/dorokuma/wechatbridge/issues
10
+ Project-URL: Changelog, https://github.com/dorokuma/wechatbridge/blob/main/CHANGELOG.md
11
+ Keywords: wechat,bot,bridge,agy,grok,codex,pig
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Environment :: Console
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: License :: OSI Approved :: MIT License
16
+ Classifier: Natural Language :: Chinese (Simplified)
17
+ Classifier: Operating System :: POSIX :: Linux
18
+ Classifier: Programming Language :: Python :: 3
19
+ Classifier: Programming Language :: Python :: 3.10
20
+ Classifier: Programming Language :: Python :: 3.11
21
+ Classifier: Programming Language :: Python :: 3.12
22
+ Classifier: Topic :: Communications :: Chat
23
+ Requires-Python: >=3.10
24
+ Description-Content-Type: text/markdown
25
+ License-File: LICENSE
26
+ Requires-Dist: httpx
27
+ Requires-Dist: qrcode
28
+ Requires-Dist: Pillow
29
+ Requires-Dist: cryptography
30
+ Requires-Dist: PyYAML
31
+ Dynamic: license-file
32
+
33
+ <div align="center">
34
+
35
+ <picture>
36
+ <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/dorokuma/wechatbridge/main/assets/logo-dark.svg">
37
+ <source media="(prefers-color-scheme: light)" srcset="https://raw.githubusercontent.com/dorokuma/wechatbridge/main/assets/logo-light.svg">
38
+ <img src="https://raw.githubusercontent.com/dorokuma/wechatbridge/main/assets/logo-dark.svg" alt="WeChatBridge logo" width="64" height="64">
39
+ </picture>
40
+
41
+ # WeChatBridge
42
+
43
+ **Talk to your terminal coding agent right from personal WeChat — scan a QR code, zero public IP, zero enterprise account needed.**
44
+
45
+ [![PyPI](https://img.shields.io/pypi/v/wechatbridge-cli?style=flat-square&labelColor=18181b)](https://pypi.org/project/wechatbridge-cli/)
46
+ [![Python 3.10+](https://img.shields.io/badge/python-3.10%2B-3776ab?style=flat-square&labelColor=18181b&logo=python&logoColor=white)](https://www.python.org/)
47
+ [![CI](https://github.com/dorokuma/wechatbridge/actions/workflows/tests.yml/badge.svg)](https://github.com/dorokuma/wechatbridge/actions/workflows/tests.yml)
48
+ [![License: MIT](https://img.shields.io/badge/license-MIT-green?style=flat-square&labelColor=18181b)](https://github.com/dorokuma/wechatbridge/blob/main/LICENSE)
49
+
50
+ [Quick Start](#quick-start) · [Highlights](#highlights) · [Commands](#chat-commands) · [Configuration](#more-details) · [简体中文](https://github.com/dorokuma/wechatbridge/blob/main/README.zh-CN.md)
51
+
52
+ </div>
53
+
54
+ WeChatBridge runs in the background and keeps long-polling WeChat for new messages through Tencent's official iLink channel. When a message needs the AI, it starts your CLI once, waits for the answer, then closes it again. Most slash commands like `/help`, `/backend`, or `/persona` are answered by the bridge itself; a few like `/model` or `/agents` may query the CLI, and `/agent` runs a real task.
55
+
56
+ ```mermaid
57
+ flowchart LR
58
+ A["📱 Personal WeChat<br/>text / voice / image / file"] <--> B["WeChat iLink<br/>long-poll, no public IP"]
59
+ B <--> C["🌉 WeChatBridge"]
60
+ C <--> D["🤖 CLI Agents<br/>agy / codex / grok / dsh / pig"]
61
+ D --> E["📦 Generated files<br/>≤100MB via CDN"]
62
+ E -.-> A
63
+ ```
64
+
65
+ <a id="highlights"></a>
66
+
67
+ ## Highlights
68
+
69
+ | | |
70
+ |---|---|
71
+ | 📱 **Scan & connect in seconds** | Official iLink long-poll on your personal WeChat — free, no public IP, no enterprise WeChat account |
72
+ | 🔀 **5 backends, hot-swap** | `/backend` switches `agy` / `codex` / `grok` / `dsh` / `pig` at runtime — no restart, per-user workspace & history |
73
+ | 🎤 **Full duplex media** | Voice auto-transcribed; images/files fed straight to the agent; generated files come back over encrypted CDN (100MB cap) |
74
+ | 🛡️ **Danger gate** | Your *prompt* is keyword-checked (`rm -rf /`, `mkfs`…) and needs a confirm token before it runs — it does not gate the agent's own tool calls afterward, so trusted users only |
75
+ | ⚡ **Concurrent & RAM-friendly** | Per-user serial queue, global concurrency cap, built-in systemd cgroup memory-limit template |
76
+ | 🐍 **One `pip` away** | Plain Python — `pipx` / `uv` or run from source; expired QR codes auto-refresh without exiting |
77
+
78
+ ## Quick Start
79
+
80
+ About 30 seconds of commands — then scan a QR code and you're chatting.
81
+
82
+ **1. Install** (Python 3.10+, [pipx](https://pypa.github.io/pipx/) recommended):
83
+
84
+ ```bash
85
+ pipx install wechatbridge-cli
86
+ wechatbridge --version
87
+ ```
88
+
89
+ **2. Configure `.env`** — pick at least one backend CLI and sign into it (`grok login`, `codex login`, `dsh login`, or `MAGPIE_API_KEY` for pig; `agy` is the default and needs no config):
90
+
91
+ ```bash
92
+ mkdir -p ~/.config/wechatbridge
93
+ curl -o ~/.config/wechatbridge/.env https://raw.githubusercontent.com/dorokuma/wechatbridge/main/deploy/wechatbridge.env.example
94
+ # if your backend isn't agy:
95
+ echo 'WECHATBRIDGE_BACKEND=grok' >> ~/.config/wechatbridge/.env # or codex / dsh / pig
96
+ ```
97
+
98
+ > [!TIP]
99
+ > The whitelist is on by default: with both `WECHATBRIDGE_ALLOWED_SENDERS` and `WECHATBRIDGE_ADMINS` empty, everyone is denied. For your first run set `WECHATBRIDGE_ALLOWED_SENDERS=*`, send the bot a message, grab your sender ID (`from=<id>`) from the log, then replace `*` with your own wxid and restart.
100
+
101
+ **3. Run & scan** — the QR code prints right in your terminal; scan it with WeChat and start chatting. If the code expires, the bridge fetches a fresh one automatically and keeps waiting:
102
+
103
+ ```bash
104
+ wechatbridge
105
+ ```
106
+
107
+ <a id="chat-commands"></a>
108
+
109
+ ## Chat Commands
110
+
111
+ Send these in WeChat; most are answered by the bridge itself — `/model`, `/models`, `/agents` may query the CLI, and `/agent` runs a real task.
112
+
113
+ | Command | What it does |
114
+ |---|---|
115
+ | `/help` | List commands supported by your current backend |
116
+ | `/backend agy\|codex\|grok\|dsh\|pig` | Switch agent (no arg = show current); a real switch starts a fresh session |
117
+ | `/model <name>` | Change model — validated against the CLI's live list (`/models` to browse); pig: `gemini-web/gemini-4-neon` + `:low/:medium/:high` |
118
+ | `/new` or `/clear` | Start a fresh conversation |
119
+ | `/fast`, `/planning` | Toggle low-effort / planning mode (`on`/`off`, bare repeats flip it) |
120
+ | `/persona <text>` | Set your agent persona (`show` / `clear` / `reset`) |
121
+ | `/add-dir <path>` | Grant the agent extra working directories (agy/codex/pig) |
122
+ | `/agents` | List available agents — agy/grok query the CLI; codex/pig return a note; not supported on dsh |
123
+ | `/version` | Show version, instance and backend + upgrade hint |
124
+ | `/price <link/keyword>` | Optional JD/Taobao coupon & price lookup (needs `JDUNION_*` or `DATAOKE_*` keys) |
125
+ | `/mcp`, `/agent <name> <task>` | Extension-tool usage hint / rewrite your request into a subagent prompt |
126
+
127
+ Unsupported or TUI-only commands either get a polite refusal or are passed through to the CLI.
128
+
129
+ <a id="more-details"></a>
130
+
131
+ ## More Details
132
+
133
+ Everything else you might need, tucked away.
134
+
135
+ <a id="backend-setup"></a>
136
+
137
+ <details>
138
+ <summary><b>Backend Setup (agy / codex / grok / dsh / pig)</b></summary>
139
+
140
+ Install at least one backend CLI and sign in once on the host. `agy` is the default; switch anytime per user with `/backend`, or set the global default with `WECHATBRIDGE_BACKEND`.
141
+
142
+ | Backend | CLI | Auth | Notes |
143
+ |---|---|---|---|
144
+ | **agy** (default) | [Antigravity CLI](https://antigravity.google/docs/cli) | `agy` login on host | Author's daily driver |
145
+ | **pig** | pig CLI | `WECHATBRIDGE_MAGPIE_API_KEY` or `MAGPIE_API_KEY` | Magpie-backed, single model `gemini-web/gemini-4-neon`; no interactive login; author's daily driver |
146
+ | **codex** | [Codex CLI](https://developers.openai.com/codex/cli) | `codex login` (or `CODEX_API_KEY`) | Implemented & tested; verify in your own setup |
147
+ | **grok** | [Grok Build](https://docs.x.ai/build/overview) | `grok login` (or `XAI_API_KEY`) | Implemented & tested; verify in your own setup |
148
+ | **dsh** | [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness/blob/master/apps/cli/README.md) | `dsh login` | Contributed by [@KOP-XIAO](https://github.com/dorokuma/wechatbridge/pull/3) & verified on real hardware; needs `PyYAML`; windowed memory by default or true persistent sessions via `WECHATBRIDGE_DSH_RESUME=true` + the `dsh-bridge-runner` plugin in your own headless profile (not shipped) |
149
+
150
+ Key env knobs: `AGY_BIN_PATH` / `GROK_BIN_PATH` / `CODEX_BIN_PATH` / `DSH_BIN_PATH` / `PIG_BIN_PATH` (binary paths), `AGY_TIMEOUT` / `DSH_TIMEOUT` / `PIG_TIMEOUT` (run timeouts), `WECHATBRIDGE_MAGPIE_BASE_URL` (pig upstream, `https://` or loopback only), `WECHATBRIDGE_DSH_HOME` / `WECHATBRIDGE_HOST_HOME` (credential & profile home resolution for service-user deployments).
151
+
152
+ Each WeChat user runs with `HOME` pointed at their own session directory — model, effort, mode and persona are remembered per backend; auth files like `~/.codex/auth.json` are symlinked in from the host and atomically copied back when the CLI refreshes them, so renewed tokens are never clobbered.
153
+
154
+ </details>
155
+
156
+ <a id="env-vars"></a>
157
+
158
+ <details>
159
+ <summary><b>Full Environment Variables</b></summary>
160
+
161
+ Config file load order: `$WECHATBRIDGE_ENV_FILE` → `$XDG_CONFIG_HOME/wechatbridge/<instance>.env` → `$XDG_CONFIG_HOME/wechatbridge/.env` → repo-root `.env` (deprecated). Full annotated list: [`deploy/wechatbridge.env.example`](https://github.com/dorokuma/wechatbridge/blob/main/deploy/wechatbridge.env.example).
162
+
163
+ | Variable | Default | Purpose |
164
+ |---|---|---|
165
+ | `AGY_BIN_PATH` | `agy` | path to the agy binary |
166
+ | `GROK_BIN_PATH` | `grok` | path to the grok binary |
167
+ | `CODEX_BIN_PATH` | `codex` | path to the codex binary |
168
+ | `DSH_BIN_PATH` | `dsh` | path to the dsh binary |
169
+ | `PIG_BIN_PATH` | `pig` | path to the pig binary |
170
+ | `PIG_TIMEOUT` | `570` | pig CLI run timeout in seconds (aligned with the Magpie upstream stream deadline) |
171
+ | `WECHATBRIDGE_MAGPIE_BASE_URL` | _built-in_ | Magpie OpenAI-compatible base URL for pig; unset falls back to the built-in upstream (only `https://` or loopback `http://` allowed) |
172
+ | `WECHATBRIDGE_MAGPIE_API_KEY` | _empty_ | Magpie API key for pig (also read from `MAGPIE_API_KEY`; injected into the pig child, never persisted) |
173
+ | `DSH_PROFILE` | `headless` | dsh profile booted for one-shot tasks |
174
+ | `DSH_TIMEOUT` | `600` | dsh CLI run timeout in seconds |
175
+ | `WECHATBRIDGE_DSH_MEMORY_TURNS` | `10` | dsh backend: recent user+assistant turns injected as context |
176
+ | `WECHATBRIDGE_DSH_MEMORY_CHARS` | `6000` | dsh backend: max chars of injected memory context |
177
+ | `WECHATBRIDGE_DSH_RESUME` | `false` | dsh backend: true persistent-session mode (one resumed session per user); requires the dsh-bridge-runner plugin in the headless profile; skips windowed memory |
178
+ | `WECHATBRIDGE_DSH_HOME` | _empty_ | explicit `DSH_HOME` for the dsh child; set = dedicated home + auto session cleanup, unset = fall back to `WECHATBRIDGE_HOST_HOME/.dsh` or `~/.dsh` |
179
+ | `WECHATBRIDGE_HOST_HOME` | _empty_ | host home override for service-user deployments; fallback base for `~/.grok`, `~/.codex`, `~/.dsh` |
180
+ | `WECHATBRIDGE_DSH_STATE_DIR` | _derived_ | bridge-private dsh state dir (memory JSONL + persistent session IDs; default `~/.local/share/wechatbridge/<instance>/dsh_state`) |
181
+ | `WECHATBRIDGE_BACKEND` | `agy` | global default backend (`agy` / `grok` / `codex` / `dsh` / `pig`; `/backend` overrides per user) |
182
+ | `WECHATBRIDGE_INSTANCE` | `default` | instance name; state / session / QR paths derive from it |
183
+ | `WECHATBRIDGE_ALLOWED_SENDERS` | _empty_ | comma-separated WeChat IDs; `*` = allow all; empty = only `WECHATBRIDGE_ADMINS` users (deny all if that is empty too) |
184
+ | `AGY_TIMEOUT` | `600` | CLI run timeout in seconds (agy / grok / codex) |
185
+ | `WECHATBRIDGE_MAX_OUTBOUND_BYTES` | `104857600` | max file size sent back to WeChat (100 MB) |
186
+ | `WECHATBRIDGE_MAX_INBOUND_BYTES` | `20971520` | max inbound image/file after download (20 MB) |
187
+ | `WECHATBRIDGE_PROGRESS_NOTICE` | `true` | one-shot "still working" notice after `WECHATBRIDGE_PROGRESS_NOTICE_DELAY` |
188
+ | `WECHATBRIDGE_PROGRESS_NOTICE_DELAY` | `30` | seconds before the progress notice fires |
189
+ | `WECHATBRIDGE_CONFIRM_TOKEN` | `y` | reply this token to approve a gated dangerous prompt |
190
+ | `WECHATBRIDGE_ENABLE_MCP` | `true` | enable the `/mcp` help-text command |
191
+ | `WECHATBRIDGE_ENABLE_SUBAGENT` | `true` | enable the `/agent` prompt-rewrite command |
192
+ | `WECHATBRIDGE_ADMINS` | _empty_ | comma-separated wxid list; admins get a WeChat ping when a new version is detected |
193
+ | `WECHATBRIDGE_UPDATE_CHECK` | `true` | check PyPI for new versions on startup and every 24h; failures are silent |
194
+ | `WECHATBRIDGE_UPDATE_CHECK_INTERVAL` | `86400` | update check interval in seconds |
195
+
196
+ </details>
197
+
198
+ <a id="deployment"></a>
199
+
200
+ <details>
201
+ <summary><b>Production Deployment (systemd & Memory Limits)</b></summary>
202
+
203
+ **Upgrade an existing install:**
204
+
205
+ ```bash
206
+ pipx upgrade wechatbridge-cli
207
+ sudo systemctl restart wechatbridge
208
+ # or via the deploy script — it upgrades and restarts for you:
209
+ curl -fsSL https://raw.githubusercontent.com/dorokuma/wechatbridge/main/deploy/update.sh | sudo bash
210
+ ```
211
+
212
+ Your data (`~/.local/share/wechatbridge/<instance>/`: sessions, SQLite history, QR codes, login state) is never touched by upgrades. Before a **major** or **minor** bump, check [`CHANGELOG.md`](https://github.com/dorokuma/wechatbridge/blob/main/CHANGELOG.md) for breaking changes.
213
+
214
+ **Linux (systemd):**
215
+
216
+ Fetch the unit files first — either clone the repo or download them straight into place:
217
+
218
+ ```bash
219
+ # option A: clone the repo
220
+ git clone https://github.com/dorokuma/wechatbridge.git && cd wechatbridge
221
+
222
+ # option B: download just the unit files
223
+ sudo curl -fsSL -o /etc/systemd/system/wechatbridge.service \
224
+ https://raw.githubusercontent.com/dorokuma/wechatbridge/main/deploy/wechatbridge.service
225
+ sudo curl -fsSL -o /etc/systemd/system/wechatbridge@.service \
226
+ https://raw.githubusercontent.com/dorokuma/wechatbridge/main/deploy/wechatbridge@.service
227
+ ```
228
+
229
+ ```bash
230
+ sudo -u wechatbridge pipx install wechatbridge-cli
231
+ sudo cp deploy/wechatbridge.service /etc/systemd/system/ # option A only
232
+ sudo systemctl enable --now wechatbridge
233
+ ```
234
+
235
+ **Multi-instance** — one process per WeChat binding, each with its own config & data dir:
236
+
237
+ ```bash
238
+ sudo cp deploy/wechatbridge@.service /etc/systemd/system/ # option A; option B already placed it
239
+ sudo systemctl enable --now wechatbridge@bot2 # reads ~/.config/wechatbridge/bot2.env
240
+ ```
241
+
242
+ Drop each instance's `<name>.env` into the **service user's** config dir (`~/.config/wechatbridge/` for the account the unit runs as).
243
+
244
+ The bundled units ship cgroup memory limits tuned for small hosts:
245
+
246
+ ```ini
247
+ MemoryAccounting=yes
248
+ MemoryHigh=450M
249
+ MemoryMax=512M
250
+ ```
251
+
252
+ - **Why these numbers:** a backend child like `agy` can peak at ~276 MB+ RSS per turn; on a ~1 GB host a hard 300 MB cap causes swap thrashing and breaks streaming. `450M` reclaims gently, `512M` is the OOM-safe ceiling. Budget N × `MemoryMax` across all running instances.
253
+ - **Override per instance** with a drop-in (no template edits):
254
+
255
+ ```bash
256
+ sudo mkdir -p /etc/systemd/system/wechatbridge@bot2.service.d/
257
+ cat << 'EOF' | sudo tee /etc/systemd/system/wechatbridge@bot2.service.d/memory.conf
258
+ [Service]
259
+ # hosts with >= 2 GB RAM
260
+ MemoryHigh=600M
261
+ MemoryMax=768M
262
+ EOF
263
+ sudo systemctl daemon-reload && sudo systemctl restart wechatbridge@bot2
264
+ systemctl show wechatbridge@bot2 -p MemoryHigh,MemoryMax
265
+ ```
266
+ - **Interplay:** a single heavy turn still multiplies child memory — on small hosts lower `WECHATBRIDGE_MAX_INBOUND_BYTES` and rely on `WECHATBRIDGE_PROGRESS_NOTICE` instead of running several turns at once. Don't tighten `MemorySwapMax`; swap headroom degrades gracefully instead of OOM-killing. Single-instance deployments use the same built-in limits via `/etc/systemd/system/wechatbridge.service.d/`. cgroup caps exist only on Linux — macOS launchd and Windows Task Scheduler have no equivalent.
267
+
268
+ **macOS (launchd):**
269
+
270
+ ```bash
271
+ # A. From a repo clone:
272
+ mkdir -p ~/Library/LaunchAgents && cp deploy/wechatbridge.plist ~/Library/LaunchAgents/com.wechatbridge.plist
273
+ # B. No clone (e.g. pipx install) — fetch the plist instead:
274
+ mkdir -p ~/Library/LaunchAgents && curl -fsSL -o ~/Library/LaunchAgents/com.wechatbridge.plist https://raw.githubusercontent.com/dorokuma/wechatbridge/main/deploy/wechatbridge.plist
275
+ # edit WorkingDirectory and ProgramArguments
276
+ launchctl load ~/Library/LaunchAgents/com.wechatbridge.plist
277
+ ```
278
+
279
+ **Windows:** see [`deploy/wechatbridge-windows.md`](https://github.com/dorokuma/wechatbridge/blob/main/deploy/wechatbridge-windows.md).
280
+
281
+ </details>
282
+
283
+ <a id="security-notes"></a>
284
+
285
+ <details>
286
+ <summary><b>Security & Architecture Notes</b></summary>
287
+
288
+ What the bridge actually enforces — read this before exposing it to anyone:
289
+
290
+ - **Whitelist first.** Empty `WECHATBRIDGE_ALLOWED_SENDERS` + empty `WECHATBRIDGE_ADMINS` = nobody gets in. `*` is first-run debugging only.
291
+ - **Auto-approve CLIs.** agy runs with `--dangerously-skip-permissions`, grok with `--always-approve` (unless planning mode), dsh tools have no host path restrictions. Only give this bot to people you trust — it is not a multi-tenant sandbox.
292
+ - **The danger gate matches keywords**, not intent. Defaults catch `rm -rf /`, pipe-to-shell, `mkfs`, `format c:` and a few heavy Chinese phrases — a bare "delete" is *not* gated. Customize via `WECHATBRIDGE_CONFIRM_KEYWORDS`; confirm with `WECHATBRIDGE_CONFIRM_TOKEN` (default `y`) within `WECHATBRIDGE_PENDING_TTL`.
293
+ - **Inbound media:** size-capped (default 20 MB), streamed, CDN hosts allowlisted, AES-128-ECB decrypt; a missing `aes_key` returns a clear error.
294
+ - **Outbound artifacts:** only from the allowed per-user tree, `realpath`-checked, capped at `WECHATBRIDGE_MAX_OUTBOUND_BYTES`. The credential scanner also blocks files containing host OAuth tokens or `MAGPIE_API_KEY` material.
295
+ - **Concurrency:** strictly serial — the bridge serves one user, so messages are handled one at a time (a queued message waits for the running one; no "busy" reply).
296
+ - **Isolation:** each user's child runs with `HOME` (and `USERPROFILE` on Windows) pointed at their session dir; common secret-style env vars are stripped before spawning.
297
+ - **Retention:** session temps and dialogue history use separate TTLs (`WECHATBRIDGE_SESSION_RETENTION_DAYS`, `WECHATBRIDGE_HISTORY_RETENTION_DAYS`); prefs and auth survive. Runtime dirs prefer `0700`, token/QR files `0600` (Unix; Windows relies on NTFS ACLs).
298
+ - **Long replies** are chunked (`WECHATBRIDGE_MESSAGE_CHUNK`, default 2000 chars).
299
+ - **dsh-specific:** private state (`dsh_memory.jsonl`, session IDs) lives outside the child session tree so one-level `../` can't reach it — but two-level traversal still can, and that is accepted on purpose. Same trust model: trusted users only.
300
+
301
+ **Known limitations:** not a standalone agent (you need at least one backend CLI); voice is WeChat-side transcription only; no video, no native voice-bubble replies; one WeChat binding per process (multi-account = multi-instance); artifact send-back is best-effort within allowed paths; `/mcp`/`/agent` are guidance, not an in-bridge MCP host; dsh's `/model`/`/fast`/`/planning`/`/persona`/`/add-dir` are not wired yet.
302
+
303
+ </details>
304
+
305
+ ## Platform Support
306
+
307
+ | Platform | Status | Notes |
308
+ |---|---|---|
309
+ | Linux | Primary | systemd units + cgroup memory limits included |
310
+ | macOS | Supported | launchd plist included |
311
+ | Windows | Supported | Task Scheduler guide included |
312
+
313
+ Default data paths expand from `~` (e.g. `~/.local/share/wechatbridge/<instance>/`).
314
+
315
+ ## Contributors
316
+
317
+ - [@KOP-XIAO](https://github.com/KOP-XIAO) — the dsh backend ([#3](https://github.com/dorokuma/wechatbridge/pull/3)) and its long-term memory plus resume support ([#4](https://github.com/dorokuma/wechatbridge/pull/4)), verified on real hardware.
318
+
319
+ ## Contributing
320
+
321
+ See [`CONTRIBUTING.md`](https://github.com/dorokuma/wechatbridge/blob/main/CONTRIBUTING.md). Versions follow SemVer; changes go into [`CHANGELOG.md`](https://github.com/dorokuma/wechatbridge/blob/main/CHANGELOG.md).
322
+
323
+ ## License
324
+
325
+ [MIT](https://github.com/dorokuma/wechatbridge/blob/main/LICENSE)
@@ -0,0 +1,293 @@
1
+ <div align="center">
2
+
3
+ <picture>
4
+ <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/dorokuma/wechatbridge/main/assets/logo-dark.svg">
5
+ <source media="(prefers-color-scheme: light)" srcset="https://raw.githubusercontent.com/dorokuma/wechatbridge/main/assets/logo-light.svg">
6
+ <img src="https://raw.githubusercontent.com/dorokuma/wechatbridge/main/assets/logo-dark.svg" alt="WeChatBridge logo" width="64" height="64">
7
+ </picture>
8
+
9
+ # WeChatBridge
10
+
11
+ **Talk to your terminal coding agent right from personal WeChat — scan a QR code, zero public IP, zero enterprise account needed.**
12
+
13
+ [![PyPI](https://img.shields.io/pypi/v/wechatbridge-cli?style=flat-square&labelColor=18181b)](https://pypi.org/project/wechatbridge-cli/)
14
+ [![Python 3.10+](https://img.shields.io/badge/python-3.10%2B-3776ab?style=flat-square&labelColor=18181b&logo=python&logoColor=white)](https://www.python.org/)
15
+ [![CI](https://github.com/dorokuma/wechatbridge/actions/workflows/tests.yml/badge.svg)](https://github.com/dorokuma/wechatbridge/actions/workflows/tests.yml)
16
+ [![License: MIT](https://img.shields.io/badge/license-MIT-green?style=flat-square&labelColor=18181b)](https://github.com/dorokuma/wechatbridge/blob/main/LICENSE)
17
+
18
+ [Quick Start](#quick-start) · [Highlights](#highlights) · [Commands](#chat-commands) · [Configuration](#more-details) · [简体中文](https://github.com/dorokuma/wechatbridge/blob/main/README.zh-CN.md)
19
+
20
+ </div>
21
+
22
+ WeChatBridge runs in the background and keeps long-polling WeChat for new messages through Tencent's official iLink channel. When a message needs the AI, it starts your CLI once, waits for the answer, then closes it again. Most slash commands like `/help`, `/backend`, or `/persona` are answered by the bridge itself; a few like `/model` or `/agents` may query the CLI, and `/agent` runs a real task.
23
+
24
+ ```mermaid
25
+ flowchart LR
26
+ A["📱 Personal WeChat<br/>text / voice / image / file"] <--> B["WeChat iLink<br/>long-poll, no public IP"]
27
+ B <--> C["🌉 WeChatBridge"]
28
+ C <--> D["🤖 CLI Agents<br/>agy / codex / grok / dsh / pig"]
29
+ D --> E["📦 Generated files<br/>≤100MB via CDN"]
30
+ E -.-> A
31
+ ```
32
+
33
+ <a id="highlights"></a>
34
+
35
+ ## Highlights
36
+
37
+ | | |
38
+ |---|---|
39
+ | 📱 **Scan & connect in seconds** | Official iLink long-poll on your personal WeChat — free, no public IP, no enterprise WeChat account |
40
+ | 🔀 **5 backends, hot-swap** | `/backend` switches `agy` / `codex` / `grok` / `dsh` / `pig` at runtime — no restart, per-user workspace & history |
41
+ | 🎤 **Full duplex media** | Voice auto-transcribed; images/files fed straight to the agent; generated files come back over encrypted CDN (100MB cap) |
42
+ | 🛡️ **Danger gate** | Your *prompt* is keyword-checked (`rm -rf /`, `mkfs`…) and needs a confirm token before it runs — it does not gate the agent's own tool calls afterward, so trusted users only |
43
+ | ⚡ **Concurrent & RAM-friendly** | Per-user serial queue, global concurrency cap, built-in systemd cgroup memory-limit template |
44
+ | 🐍 **One `pip` away** | Plain Python — `pipx` / `uv` or run from source; expired QR codes auto-refresh without exiting |
45
+
46
+ ## Quick Start
47
+
48
+ About 30 seconds of commands — then scan a QR code and you're chatting.
49
+
50
+ **1. Install** (Python 3.10+, [pipx](https://pypa.github.io/pipx/) recommended):
51
+
52
+ ```bash
53
+ pipx install wechatbridge-cli
54
+ wechatbridge --version
55
+ ```
56
+
57
+ **2. Configure `.env`** — pick at least one backend CLI and sign into it (`grok login`, `codex login`, `dsh login`, or `MAGPIE_API_KEY` for pig; `agy` is the default and needs no config):
58
+
59
+ ```bash
60
+ mkdir -p ~/.config/wechatbridge
61
+ curl -o ~/.config/wechatbridge/.env https://raw.githubusercontent.com/dorokuma/wechatbridge/main/deploy/wechatbridge.env.example
62
+ # if your backend isn't agy:
63
+ echo 'WECHATBRIDGE_BACKEND=grok' >> ~/.config/wechatbridge/.env # or codex / dsh / pig
64
+ ```
65
+
66
+ > [!TIP]
67
+ > The whitelist is on by default: with both `WECHATBRIDGE_ALLOWED_SENDERS` and `WECHATBRIDGE_ADMINS` empty, everyone is denied. For your first run set `WECHATBRIDGE_ALLOWED_SENDERS=*`, send the bot a message, grab your sender ID (`from=<id>`) from the log, then replace `*` with your own wxid and restart.
68
+
69
+ **3. Run & scan** — the QR code prints right in your terminal; scan it with WeChat and start chatting. If the code expires, the bridge fetches a fresh one automatically and keeps waiting:
70
+
71
+ ```bash
72
+ wechatbridge
73
+ ```
74
+
75
+ <a id="chat-commands"></a>
76
+
77
+ ## Chat Commands
78
+
79
+ Send these in WeChat; most are answered by the bridge itself — `/model`, `/models`, `/agents` may query the CLI, and `/agent` runs a real task.
80
+
81
+ | Command | What it does |
82
+ |---|---|
83
+ | `/help` | List commands supported by your current backend |
84
+ | `/backend agy\|codex\|grok\|dsh\|pig` | Switch agent (no arg = show current); a real switch starts a fresh session |
85
+ | `/model <name>` | Change model — validated against the CLI's live list (`/models` to browse); pig: `gemini-web/gemini-4-neon` + `:low/:medium/:high` |
86
+ | `/new` or `/clear` | Start a fresh conversation |
87
+ | `/fast`, `/planning` | Toggle low-effort / planning mode (`on`/`off`, bare repeats flip it) |
88
+ | `/persona <text>` | Set your agent persona (`show` / `clear` / `reset`) |
89
+ | `/add-dir <path>` | Grant the agent extra working directories (agy/codex/pig) |
90
+ | `/agents` | List available agents — agy/grok query the CLI; codex/pig return a note; not supported on dsh |
91
+ | `/version` | Show version, instance and backend + upgrade hint |
92
+ | `/price <link/keyword>` | Optional JD/Taobao coupon & price lookup (needs `JDUNION_*` or `DATAOKE_*` keys) |
93
+ | `/mcp`, `/agent <name> <task>` | Extension-tool usage hint / rewrite your request into a subagent prompt |
94
+
95
+ Unsupported or TUI-only commands either get a polite refusal or are passed through to the CLI.
96
+
97
+ <a id="more-details"></a>
98
+
99
+ ## More Details
100
+
101
+ Everything else you might need, tucked away.
102
+
103
+ <a id="backend-setup"></a>
104
+
105
+ <details>
106
+ <summary><b>Backend Setup (agy / codex / grok / dsh / pig)</b></summary>
107
+
108
+ Install at least one backend CLI and sign in once on the host. `agy` is the default; switch anytime per user with `/backend`, or set the global default with `WECHATBRIDGE_BACKEND`.
109
+
110
+ | Backend | CLI | Auth | Notes |
111
+ |---|---|---|---|
112
+ | **agy** (default) | [Antigravity CLI](https://antigravity.google/docs/cli) | `agy` login on host | Author's daily driver |
113
+ | **pig** | pig CLI | `WECHATBRIDGE_MAGPIE_API_KEY` or `MAGPIE_API_KEY` | Magpie-backed, single model `gemini-web/gemini-4-neon`; no interactive login; author's daily driver |
114
+ | **codex** | [Codex CLI](https://developers.openai.com/codex/cli) | `codex login` (or `CODEX_API_KEY`) | Implemented & tested; verify in your own setup |
115
+ | **grok** | [Grok Build](https://docs.x.ai/build/overview) | `grok login` (or `XAI_API_KEY`) | Implemented & tested; verify in your own setup |
116
+ | **dsh** | [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness/blob/master/apps/cli/README.md) | `dsh login` | Contributed by [@KOP-XIAO](https://github.com/dorokuma/wechatbridge/pull/3) & verified on real hardware; needs `PyYAML`; windowed memory by default or true persistent sessions via `WECHATBRIDGE_DSH_RESUME=true` + the `dsh-bridge-runner` plugin in your own headless profile (not shipped) |
117
+
118
+ Key env knobs: `AGY_BIN_PATH` / `GROK_BIN_PATH` / `CODEX_BIN_PATH` / `DSH_BIN_PATH` / `PIG_BIN_PATH` (binary paths), `AGY_TIMEOUT` / `DSH_TIMEOUT` / `PIG_TIMEOUT` (run timeouts), `WECHATBRIDGE_MAGPIE_BASE_URL` (pig upstream, `https://` or loopback only), `WECHATBRIDGE_DSH_HOME` / `WECHATBRIDGE_HOST_HOME` (credential & profile home resolution for service-user deployments).
119
+
120
+ Each WeChat user runs with `HOME` pointed at their own session directory — model, effort, mode and persona are remembered per backend; auth files like `~/.codex/auth.json` are symlinked in from the host and atomically copied back when the CLI refreshes them, so renewed tokens are never clobbered.
121
+
122
+ </details>
123
+
124
+ <a id="env-vars"></a>
125
+
126
+ <details>
127
+ <summary><b>Full Environment Variables</b></summary>
128
+
129
+ Config file load order: `$WECHATBRIDGE_ENV_FILE` → `$XDG_CONFIG_HOME/wechatbridge/<instance>.env` → `$XDG_CONFIG_HOME/wechatbridge/.env` → repo-root `.env` (deprecated). Full annotated list: [`deploy/wechatbridge.env.example`](https://github.com/dorokuma/wechatbridge/blob/main/deploy/wechatbridge.env.example).
130
+
131
+ | Variable | Default | Purpose |
132
+ |---|---|---|
133
+ | `AGY_BIN_PATH` | `agy` | path to the agy binary |
134
+ | `GROK_BIN_PATH` | `grok` | path to the grok binary |
135
+ | `CODEX_BIN_PATH` | `codex` | path to the codex binary |
136
+ | `DSH_BIN_PATH` | `dsh` | path to the dsh binary |
137
+ | `PIG_BIN_PATH` | `pig` | path to the pig binary |
138
+ | `PIG_TIMEOUT` | `570` | pig CLI run timeout in seconds (aligned with the Magpie upstream stream deadline) |
139
+ | `WECHATBRIDGE_MAGPIE_BASE_URL` | _built-in_ | Magpie OpenAI-compatible base URL for pig; unset falls back to the built-in upstream (only `https://` or loopback `http://` allowed) |
140
+ | `WECHATBRIDGE_MAGPIE_API_KEY` | _empty_ | Magpie API key for pig (also read from `MAGPIE_API_KEY`; injected into the pig child, never persisted) |
141
+ | `DSH_PROFILE` | `headless` | dsh profile booted for one-shot tasks |
142
+ | `DSH_TIMEOUT` | `600` | dsh CLI run timeout in seconds |
143
+ | `WECHATBRIDGE_DSH_MEMORY_TURNS` | `10` | dsh backend: recent user+assistant turns injected as context |
144
+ | `WECHATBRIDGE_DSH_MEMORY_CHARS` | `6000` | dsh backend: max chars of injected memory context |
145
+ | `WECHATBRIDGE_DSH_RESUME` | `false` | dsh backend: true persistent-session mode (one resumed session per user); requires the dsh-bridge-runner plugin in the headless profile; skips windowed memory |
146
+ | `WECHATBRIDGE_DSH_HOME` | _empty_ | explicit `DSH_HOME` for the dsh child; set = dedicated home + auto session cleanup, unset = fall back to `WECHATBRIDGE_HOST_HOME/.dsh` or `~/.dsh` |
147
+ | `WECHATBRIDGE_HOST_HOME` | _empty_ | host home override for service-user deployments; fallback base for `~/.grok`, `~/.codex`, `~/.dsh` |
148
+ | `WECHATBRIDGE_DSH_STATE_DIR` | _derived_ | bridge-private dsh state dir (memory JSONL + persistent session IDs; default `~/.local/share/wechatbridge/<instance>/dsh_state`) |
149
+ | `WECHATBRIDGE_BACKEND` | `agy` | global default backend (`agy` / `grok` / `codex` / `dsh` / `pig`; `/backend` overrides per user) |
150
+ | `WECHATBRIDGE_INSTANCE` | `default` | instance name; state / session / QR paths derive from it |
151
+ | `WECHATBRIDGE_ALLOWED_SENDERS` | _empty_ | comma-separated WeChat IDs; `*` = allow all; empty = only `WECHATBRIDGE_ADMINS` users (deny all if that is empty too) |
152
+ | `AGY_TIMEOUT` | `600` | CLI run timeout in seconds (agy / grok / codex) |
153
+ | `WECHATBRIDGE_MAX_OUTBOUND_BYTES` | `104857600` | max file size sent back to WeChat (100 MB) |
154
+ | `WECHATBRIDGE_MAX_INBOUND_BYTES` | `20971520` | max inbound image/file after download (20 MB) |
155
+ | `WECHATBRIDGE_PROGRESS_NOTICE` | `true` | one-shot "still working" notice after `WECHATBRIDGE_PROGRESS_NOTICE_DELAY` |
156
+ | `WECHATBRIDGE_PROGRESS_NOTICE_DELAY` | `30` | seconds before the progress notice fires |
157
+ | `WECHATBRIDGE_CONFIRM_TOKEN` | `y` | reply this token to approve a gated dangerous prompt |
158
+ | `WECHATBRIDGE_ENABLE_MCP` | `true` | enable the `/mcp` help-text command |
159
+ | `WECHATBRIDGE_ENABLE_SUBAGENT` | `true` | enable the `/agent` prompt-rewrite command |
160
+ | `WECHATBRIDGE_ADMINS` | _empty_ | comma-separated wxid list; admins get a WeChat ping when a new version is detected |
161
+ | `WECHATBRIDGE_UPDATE_CHECK` | `true` | check PyPI for new versions on startup and every 24h; failures are silent |
162
+ | `WECHATBRIDGE_UPDATE_CHECK_INTERVAL` | `86400` | update check interval in seconds |
163
+
164
+ </details>
165
+
166
+ <a id="deployment"></a>
167
+
168
+ <details>
169
+ <summary><b>Production Deployment (systemd & Memory Limits)</b></summary>
170
+
171
+ **Upgrade an existing install:**
172
+
173
+ ```bash
174
+ pipx upgrade wechatbridge-cli
175
+ sudo systemctl restart wechatbridge
176
+ # or via the deploy script — it upgrades and restarts for you:
177
+ curl -fsSL https://raw.githubusercontent.com/dorokuma/wechatbridge/main/deploy/update.sh | sudo bash
178
+ ```
179
+
180
+ Your data (`~/.local/share/wechatbridge/<instance>/`: sessions, SQLite history, QR codes, login state) is never touched by upgrades. Before a **major** or **minor** bump, check [`CHANGELOG.md`](https://github.com/dorokuma/wechatbridge/blob/main/CHANGELOG.md) for breaking changes.
181
+
182
+ **Linux (systemd):**
183
+
184
+ Fetch the unit files first — either clone the repo or download them straight into place:
185
+
186
+ ```bash
187
+ # option A: clone the repo
188
+ git clone https://github.com/dorokuma/wechatbridge.git && cd wechatbridge
189
+
190
+ # option B: download just the unit files
191
+ sudo curl -fsSL -o /etc/systemd/system/wechatbridge.service \
192
+ https://raw.githubusercontent.com/dorokuma/wechatbridge/main/deploy/wechatbridge.service
193
+ sudo curl -fsSL -o /etc/systemd/system/wechatbridge@.service \
194
+ https://raw.githubusercontent.com/dorokuma/wechatbridge/main/deploy/wechatbridge@.service
195
+ ```
196
+
197
+ ```bash
198
+ sudo -u wechatbridge pipx install wechatbridge-cli
199
+ sudo cp deploy/wechatbridge.service /etc/systemd/system/ # option A only
200
+ sudo systemctl enable --now wechatbridge
201
+ ```
202
+
203
+ **Multi-instance** — one process per WeChat binding, each with its own config & data dir:
204
+
205
+ ```bash
206
+ sudo cp deploy/wechatbridge@.service /etc/systemd/system/ # option A; option B already placed it
207
+ sudo systemctl enable --now wechatbridge@bot2 # reads ~/.config/wechatbridge/bot2.env
208
+ ```
209
+
210
+ Drop each instance's `<name>.env` into the **service user's** config dir (`~/.config/wechatbridge/` for the account the unit runs as).
211
+
212
+ The bundled units ship cgroup memory limits tuned for small hosts:
213
+
214
+ ```ini
215
+ MemoryAccounting=yes
216
+ MemoryHigh=450M
217
+ MemoryMax=512M
218
+ ```
219
+
220
+ - **Why these numbers:** a backend child like `agy` can peak at ~276 MB+ RSS per turn; on a ~1 GB host a hard 300 MB cap causes swap thrashing and breaks streaming. `450M` reclaims gently, `512M` is the OOM-safe ceiling. Budget N × `MemoryMax` across all running instances.
221
+ - **Override per instance** with a drop-in (no template edits):
222
+
223
+ ```bash
224
+ sudo mkdir -p /etc/systemd/system/wechatbridge@bot2.service.d/
225
+ cat << 'EOF' | sudo tee /etc/systemd/system/wechatbridge@bot2.service.d/memory.conf
226
+ [Service]
227
+ # hosts with >= 2 GB RAM
228
+ MemoryHigh=600M
229
+ MemoryMax=768M
230
+ EOF
231
+ sudo systemctl daemon-reload && sudo systemctl restart wechatbridge@bot2
232
+ systemctl show wechatbridge@bot2 -p MemoryHigh,MemoryMax
233
+ ```
234
+ - **Interplay:** a single heavy turn still multiplies child memory — on small hosts lower `WECHATBRIDGE_MAX_INBOUND_BYTES` and rely on `WECHATBRIDGE_PROGRESS_NOTICE` instead of running several turns at once. Don't tighten `MemorySwapMax`; swap headroom degrades gracefully instead of OOM-killing. Single-instance deployments use the same built-in limits via `/etc/systemd/system/wechatbridge.service.d/`. cgroup caps exist only on Linux — macOS launchd and Windows Task Scheduler have no equivalent.
235
+
236
+ **macOS (launchd):**
237
+
238
+ ```bash
239
+ # A. From a repo clone:
240
+ mkdir -p ~/Library/LaunchAgents && cp deploy/wechatbridge.plist ~/Library/LaunchAgents/com.wechatbridge.plist
241
+ # B. No clone (e.g. pipx install) — fetch the plist instead:
242
+ mkdir -p ~/Library/LaunchAgents && curl -fsSL -o ~/Library/LaunchAgents/com.wechatbridge.plist https://raw.githubusercontent.com/dorokuma/wechatbridge/main/deploy/wechatbridge.plist
243
+ # edit WorkingDirectory and ProgramArguments
244
+ launchctl load ~/Library/LaunchAgents/com.wechatbridge.plist
245
+ ```
246
+
247
+ **Windows:** see [`deploy/wechatbridge-windows.md`](https://github.com/dorokuma/wechatbridge/blob/main/deploy/wechatbridge-windows.md).
248
+
249
+ </details>
250
+
251
+ <a id="security-notes"></a>
252
+
253
+ <details>
254
+ <summary><b>Security & Architecture Notes</b></summary>
255
+
256
+ What the bridge actually enforces — read this before exposing it to anyone:
257
+
258
+ - **Whitelist first.** Empty `WECHATBRIDGE_ALLOWED_SENDERS` + empty `WECHATBRIDGE_ADMINS` = nobody gets in. `*` is first-run debugging only.
259
+ - **Auto-approve CLIs.** agy runs with `--dangerously-skip-permissions`, grok with `--always-approve` (unless planning mode), dsh tools have no host path restrictions. Only give this bot to people you trust — it is not a multi-tenant sandbox.
260
+ - **The danger gate matches keywords**, not intent. Defaults catch `rm -rf /`, pipe-to-shell, `mkfs`, `format c:` and a few heavy Chinese phrases — a bare "delete" is *not* gated. Customize via `WECHATBRIDGE_CONFIRM_KEYWORDS`; confirm with `WECHATBRIDGE_CONFIRM_TOKEN` (default `y`) within `WECHATBRIDGE_PENDING_TTL`.
261
+ - **Inbound media:** size-capped (default 20 MB), streamed, CDN hosts allowlisted, AES-128-ECB decrypt; a missing `aes_key` returns a clear error.
262
+ - **Outbound artifacts:** only from the allowed per-user tree, `realpath`-checked, capped at `WECHATBRIDGE_MAX_OUTBOUND_BYTES`. The credential scanner also blocks files containing host OAuth tokens or `MAGPIE_API_KEY` material.
263
+ - **Concurrency:** strictly serial — the bridge serves one user, so messages are handled one at a time (a queued message waits for the running one; no "busy" reply).
264
+ - **Isolation:** each user's child runs with `HOME` (and `USERPROFILE` on Windows) pointed at their session dir; common secret-style env vars are stripped before spawning.
265
+ - **Retention:** session temps and dialogue history use separate TTLs (`WECHATBRIDGE_SESSION_RETENTION_DAYS`, `WECHATBRIDGE_HISTORY_RETENTION_DAYS`); prefs and auth survive. Runtime dirs prefer `0700`, token/QR files `0600` (Unix; Windows relies on NTFS ACLs).
266
+ - **Long replies** are chunked (`WECHATBRIDGE_MESSAGE_CHUNK`, default 2000 chars).
267
+ - **dsh-specific:** private state (`dsh_memory.jsonl`, session IDs) lives outside the child session tree so one-level `../` can't reach it — but two-level traversal still can, and that is accepted on purpose. Same trust model: trusted users only.
268
+
269
+ **Known limitations:** not a standalone agent (you need at least one backend CLI); voice is WeChat-side transcription only; no video, no native voice-bubble replies; one WeChat binding per process (multi-account = multi-instance); artifact send-back is best-effort within allowed paths; `/mcp`/`/agent` are guidance, not an in-bridge MCP host; dsh's `/model`/`/fast`/`/planning`/`/persona`/`/add-dir` are not wired yet.
270
+
271
+ </details>
272
+
273
+ ## Platform Support
274
+
275
+ | Platform | Status | Notes |
276
+ |---|---|---|
277
+ | Linux | Primary | systemd units + cgroup memory limits included |
278
+ | macOS | Supported | launchd plist included |
279
+ | Windows | Supported | Task Scheduler guide included |
280
+
281
+ Default data paths expand from `~` (e.g. `~/.local/share/wechatbridge/<instance>/`).
282
+
283
+ ## Contributors
284
+
285
+ - [@KOP-XIAO](https://github.com/KOP-XIAO) — the dsh backend ([#3](https://github.com/dorokuma/wechatbridge/pull/3)) and its long-term memory plus resume support ([#4](https://github.com/dorokuma/wechatbridge/pull/4)), verified on real hardware.
286
+
287
+ ## Contributing
288
+
289
+ See [`CONTRIBUTING.md`](https://github.com/dorokuma/wechatbridge/blob/main/CONTRIBUTING.md). Versions follow SemVer; changes go into [`CHANGELOG.md`](https://github.com/dorokuma/wechatbridge/blob/main/CHANGELOG.md).
290
+
291
+ ## License
292
+
293
+ [MIT](https://github.com/dorokuma/wechatbridge/blob/main/LICENSE)