wechatbridge-cli 1.3.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.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 WeChatBridge contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,29 @@
1
+ Metadata-Version: 2.4
2
+ Name: wechatbridge-cli
3
+ Version: 1.3.0
4
+ Summary: Bridge WeChat messages to agy or Grok Build 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
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
+ License-File: LICENSE
25
+ Requires-Dist: httpx
26
+ Requires-Dist: qrcode
27
+ Requires-Dist: Pillow
28
+ Requires-Dist: cryptography
29
+ Dynamic: license-file
@@ -0,0 +1,256 @@
1
+ # WeChatBridge
2
+
3
+ [English](README.md) | [简体中文](README.zh-CN.md)
4
+
5
+ ![license](https://img.shields.io/badge/license-MIT-blue.svg)
6
+ ![python](https://img.shields.io/badge/python-3.10+-blue.svg)
7
+
8
+ WeChatBridge connects a WeChat bot to agentic coding CLIs (Google's agy / Antigravity, or xAI's Grok Build). From WeChat you can send text, images, files, and voice-as-text to the active CLI, get replies back, and receive certain generated files over the WeChat CDN. Switch backends per user with `/backend` — no restart.
9
+
10
+ ```
11
+ WeChat (phone) ⇄ iLink bot API ⇄ WeChatBridge ⇄ agy / grok CLI
12
+ (this project) (runs tools)
13
+ ```
14
+
15
+ The bridge process stays up and long-polls iLink. For prompts that go to a CLI, it spawns one `agy` or `grok` child (`-p` single-turn) and exits that child when done — the child does not stay resident. Many slash commands (`/help`, `/backend`, `/persona`, …) are handled inside the bridge and never start a CLI. Only artifacts the bridge can detect under the user's allowed session paths are pushed back via CDN.
16
+
17
+ ## Features
18
+
19
+ - Text, image, file, and voice (WeChat server-side transcription only) go to the **active** backend (`agy` or `grok`)
20
+ - Detected CLI artifacts under the per-user allowed tree can be sent back (size-capped); not every file the CLI touches
21
+ - Each WeChat user gets an isolated workspace; model / effort / mode are remembered **per backend**
22
+ - Runtime backend switch: `/backend agy` or `/backend grok` (clears the “continue session” flag so the next CLI turn starts without `-c` / `--continue`; does not immediately wipe history files on disk)
23
+ - Slash commands for model, session reset, persona, and more (see below)
24
+ - Dangerous-prompt gate: a **keyword list** of concrete destructive patterns asks for confirmation before run
25
+ - Sender whitelist (`WECHATBRIDGE_ALLOWED_SENDERS`; empty = allow all)
26
+ - `/mcp` returns short usage text; `/agent` rewrites into a natural-language subagent prompt for the CLI (not a native MCP bridge)
27
+ - Media over WeChat CDN with AES-128-ECB encrypt/decrypt
28
+ - Multi-instance: one codebase, set `WECHATBRIDGE_INSTANCE` per process (state / session / QR paths derive from it)
29
+ - Deploy templates: systemd (Linux), launchd (macOS), Task Scheduler notes (Windows)
30
+
31
+ ## Platform Support
32
+
33
+ - **Linux** — primary (systemd unit included)
34
+ - **macOS** — supported (launchd plist included)
35
+ - **Windows** — supported (Task Scheduler guide included)
36
+
37
+ Default data paths expand from `~` (e.g. `~/.local/share/wechatbridge/<instance>/`).
38
+
39
+ ## CLI Backends
40
+
41
+ - **agy** (default) — Google Antigravity CLI
42
+ - **grok** — xAI Grok Build CLI
43
+
44
+ Per-user switch: `/backend agy` or `/backend grok`. Each backend keeps its own model / effort / mode memory and persona file layout. Global default is `WECHATBRIDGE_BACKEND`.
45
+
46
+ ## Prerequisites
47
+
48
+ - At least one CLI installed and signed in:
49
+ - **agy** on `PATH`, or set `AGY_BIN_PATH`
50
+ - **and/or grok** on `PATH`, or set `GROK_BIN_PATH`
51
+ - Antigravity is Google's terminal agentic coding CLI (successor to Gemini CLI). Grok Build is xAI's counterpart.
52
+ - A WeChat account with a [ClawBot / iLink](https://ilinkai.weixin.qq.com) bot (QR bind on first run)
53
+ - Python 3.10+
54
+
55
+ ## Install
56
+
57
+ The recommended way is with [pipx](https://pypa.github.io/pipx/) (Python >= 3.10 required):
58
+
59
+ ```bash
60
+ pipx install wechatbridge-cli
61
+ ```
62
+
63
+ After installation, verify:
64
+
65
+ ```bash
66
+ wechatbridge --version
67
+ ```
68
+
69
+ ### Install pipx
70
+
71
+ **Debian / Ubuntu:**
72
+
73
+ ```bash
74
+ sudo apt install pipx
75
+ ```
76
+
77
+ **Other systems (or to get the latest version):**
78
+
79
+ ```bash
80
+ python3 -m pip install --user pipx && python3 -m pipx ensurepath
81
+ ```
82
+
83
+ Then start a new shell or re-source your shell config so `pipx` is on `PATH`.
84
+
85
+ ### Developers
86
+
87
+ If you want to hack on the source:
88
+
89
+ ```bash
90
+ git clone https://github.com/dorokuma/wechatbridge.git
91
+ cd wechatbridge
92
+ pip install -e .
93
+ ```
94
+
95
+ ## Configure
96
+
97
+ Configuration is loaded from the first location found:
98
+
99
+ 1. `$WECHATBRIDGE_ENV_FILE` — explicit path
100
+ 2. `$XDG_CONFIG_HOME/wechatbridge/<instance>.env` (defaults to `~/.config/wechatbridge/<instance>.env`)
101
+ 3. `$XDG_CONFIG_HOME/wechatbridge/.env` (defaults to `~/.config/wechatbridge/.env`)
102
+ 4. `.env` in the repository root — **deprecated** (prints a warning on startup)
103
+
104
+ The instance name defaults to `default`; override with `WECHATBRIDGE_INSTANCE`.
105
+
106
+ Get the example config:
107
+
108
+ ```bash
109
+ mkdir -p ~/.config/wechatbridge
110
+ curl -o ~/.config/wechatbridge/.env https://raw.githubusercontent.com/dorokuma/wechatbridge/main/deploy/wechatbridge.env.example
111
+ ```
112
+
113
+ Then edit `~/.config/wechatbridge/.env` with your settings.
114
+
115
+ Key variables (all have defaults):
116
+
117
+ | Variable | Default | Purpose |
118
+ |---|---|---|
119
+ | `AGY_BIN_PATH` | `agy` | path to the agy binary |
120
+ | `GROK_BIN_PATH` | `grok` | path to the grok binary |
121
+ | `WECHATBRIDGE_BACKEND` | `agy` | global default backend (`agy` / `grok`; overridable per user via `/backend`) |
122
+ | `WECHATBRIDGE_INSTANCE` | `default` | instance name; state / session / QR paths derive from it |
123
+ | `WECHATBRIDGE_ALLOWED_SENDERS` | _empty_ | comma-separated WeChat IDs (empty = allow all) |
124
+ | `AGY_TIMEOUT` | `600` | CLI run timeout in seconds (both backends) |
125
+ | `WECHATBRIDGE_MAX_OUTBOUND_BYTES` | `104857600` | max file size sent back to WeChat (100 MB) |
126
+ | `WECHATBRIDGE_MAX_INBOUND_BYTES` | `20971520` | max inbound image/file after download (20 MB) |
127
+ | `WECHATBRIDGE_MAX_CONCURRENT` | `4` | global concurrent handlers; extras get a busy reply |
128
+ | `WECHATBRIDGE_CONFIRM_TOKEN` | `y` | reply this token to approve a gated dangerous prompt |
129
+ | `WECHATBRIDGE_ENABLE_MCP` | `true` | enable the `/mcp` help text command |
130
+ | `WECHATBRIDGE_ENABLE_SUBAGENT` | `true` | enable the `/agent` prompt-rewrite command |
131
+ | `WECHATBRIDGE_ADMINS` | _empty_ | comma-separated wxid list; admins receive WeChat notification when a new version is detected |
132
+ | `WECHATBRIDGE_UPDATE_CHECK` | `true` | check PyPI for new versions on startup and every 24h; failures are silent |
133
+ | `WECHATBRIDGE_UPDATE_CHECK_INTERVAL` | `86400` | update check interval in seconds |
134
+
135
+ Full list: [`deploy/wechatbridge.env.example`](deploy/wechatbridge.env.example).
136
+
137
+ > **Why the new config location?** With pipx the package is installed globally, so a `.env` next to the source no longer makes sense. The XDG base directory layout keeps your config separate and instance-aware.
138
+
139
+ ## Run
140
+
141
+ ```bash
142
+ wechatbridge
143
+ ```
144
+
145
+ On first run the bridge prints a QR code (and saves PNG under the instance data dir). Scan with WeChat to bind, then it long-polls for messages.
146
+
147
+ ## Upgrading
148
+
149
+ ```bash
150
+ pipx upgrade wechatbridge-cli
151
+ sudo systemctl restart wechatbridge
152
+ ```
153
+
154
+ Or run the upgrade script (no clone needed — fetch it with curl):
155
+
156
+ ```bash
157
+ curl -fsSL https://raw.githubusercontent.com/dorokuma/wechatbridge/main/deploy/update.sh | sudo bash
158
+ ```
159
+
160
+ The script upgrades the pipx installation and restarts the service. If the service runs as a dedicated system user (e.g. `wechatbridge`), running as root automatically runs pipx as that user (override with `WECHATBRIDGE_USER=<user>`).
161
+
162
+ Data lives under `~/.local/share/wechatbridge/<instance>/` (sessions, SQLite history, QR codes, login state) and is **not** touched during upgrade — your bots stay logged in and conversations are preserved.
163
+
164
+ Before upgrading a **major** or **minor** version (e.g. 1.2 → 1.3), check the corresponding section in [`CHANGELOG.md`](CHANGELOG.md) for breaking changes and migration steps.
165
+
166
+ ## Deploy
167
+
168
+ ### Linux (systemd)
169
+
170
+ First, install the bridge under the `wechatbridge` system user:
171
+
172
+ ```bash
173
+ sudo -u wechatbridge pipx install wechatbridge-cli
174
+ ```
175
+
176
+ Then deploy the service unit:
177
+
178
+ ```bash
179
+ sudo cp deploy/wechatbridge.service /etc/systemd/system/
180
+ sudo systemctl enable --now wechatbridge
181
+ ```
182
+
183
+ **Multi-instance:** copy the template `deploy/wechatbridge@.service` and enable instances:
184
+
185
+ ```bash
186
+ sudo cp deploy/wechatbridge@.service /etc/systemd/system/
187
+ sudo systemctl enable --now wechatbridge@bot2
188
+ sudo systemctl enable --now wechatbridge@bot3
189
+ ```
190
+
191
+ Each instance reads its own config file (`~/.config/wechatbridge/bot2.env`) and keeps state under its own data directory (`~/.local/share/wechatbridge/bot2/`).
192
+
193
+ ### macOS (launchd)
194
+
195
+ ```bash
196
+ cp deploy/wechatbridge.plist ~/Library/LaunchAgents/com.wechatbridge.plist
197
+ # edit WorkingDirectory and ProgramArguments in the plist
198
+ launchctl load ~/Library/LaunchAgents/com.wechatbridge.plist
199
+ ```
200
+
201
+ ### Windows (Task Scheduler)
202
+
203
+ See [`deploy/wechatbridge-windows.md`](deploy/wechatbridge-windows.md).
204
+
205
+ ## Slash commands
206
+
207
+ | Command | Action |
208
+ |---|---|
209
+ | `/help` | list supported commands for the active backend |
210
+ | `/backend <agy\|grok>` | switch CLI backend for this WeChat user (on real change: drop continue flag; history files may remain until retention cleanup) |
211
+ | `/clear` or `/new` | drop continue flag so the next CLI turn is a new conversation (does not instantly delete history files) |
212
+ | `/model <name>` | set model (validated against the backend's model list; see `/models`) |
213
+ | `/models` | list models from the active CLI |
214
+ | `/fast` | set low reasoning effort (**on only** — not a toggle; no “off” command) |
215
+ | `/planning` | set planning mode (**on only** — not a toggle) |
216
+ | `/add-dir <path>` | **agy:** pass `--add-dir` on later runs if path is allowed. **grok:** recorded only; not passed to the CLI yet |
217
+ | `/agents` | list agents via the active CLI |
218
+ | `/persona <text>` | set persona (`show` / `clear` / `reset` subcommands) |
219
+ | `/version` | show current version, instance name, and backend; if a newer version is available, show upgrade hint |
220
+ | `/mcp` | short MCP **usage hint** text (can disable with `WECHATBRIDGE_ENABLE_MCP`) |
221
+ | `/agent <name> <task>` | craft a "invoke subagent …" prompt and run the CLI (can disable with `WECHATBRIDGE_ENABLE_SUBAGENT`) |
222
+
223
+ Other `/…` commands are either rejected (e.g. `/exit`), reported as unsupported on WeChat (TUI-only panels), or passed through to the active CLI.
224
+
225
+ `/add-dir` only accepts paths under the user's session directory or roots listed in `WECHATBRIDGE_ADD_DIR_ROOTS`.
226
+
227
+ ## Ops & security (what the bridge actually enforces)
228
+
229
+ - **Whitelist first.** Empty `WECHATBRIDGE_ALLOWED_SENDERS` means anyone who can message the bot can use it.
230
+ - **Auto-approve CLIs.** agy runs with `--dangerously-skip-permissions`; grok with `--always-approve` (unless planning mode). Treat this as trusted-user tooling, not a multi-tenant sandbox.
231
+ - **Danger gate is keyword-based**, not full intent understanding. Defaults target concrete patterns (`rm -rf /`, pipe-to-shell, `mkfs`, `format c:`, a few heavy Chinese phrases, …). Everyday wording like bare “delete” is **not** gated. Override list via `WECHATBRIDGE_CONFIRM_KEYWORDS`; approve with `WECHATBRIDGE_CONFIRM_TOKEN` (default `y`), TTL `WECHATBRIDGE_PENDING_TTL`.
232
+ - **Inbound media** is size-capped (default 20 MB), streamed, and CDN hosts are allowlisted. Missing `aes_key` returns a clear error.
233
+ - **Outbound artifacts** only leave the allowed per-user tree (agy: session scratch; grok: under session dir), after `realpath` checks, and only if under `WECHATBRIDGE_MAX_OUTBOUND_BYTES`.
234
+ - **Concurrency:** global cap (`WECHATBRIDGE_MAX_CONCURRENT`, default 4); same user is serialized, different users can run in parallel.
235
+ - **Long replies** are split into chunks (`WECHATBRIDGE_MESSAGE_CHUNK`, default 2000 characters).
236
+ - **Data layout:** instance data under `~/.local/share/wechatbridge/<instance>/` (override with env). Runtime dirs prefer `0700`; token/QR files prefer `0600` (Unix; Windows relies on NTFS ACLs).
237
+ - **Retention:** session temps vs dialogue history use separate TTLs (`WECHATBRIDGE_SESSION_RETENTION_DAYS`, `WECHATBRIDGE_HISTORY_RETENTION_DAYS`). Prefs/auth are kept.
238
+ - **Child env** is sanitized (strips common secret-style variable names) and points `HOME` (and `USERPROFILE` on Windows) at the per-user session dir.
239
+
240
+ ## Limitations
241
+
242
+ - Not a standalone agent — requires agy and/or grok.
243
+ - Voice is WeChat speech-to-text only; no local ASR; empty transcript → “type instead”.
244
+ - No video send/receive; no native WeChat voice-bubble replies (no silk encode).
245
+ - One WeChat binding per process; multiple accounts need multiple instances (`WECHATBRIDGE_INSTANCE`).
246
+ - Artifact send-back is best-effort detection under allowed paths, not “every file the CLI created anywhere”.
247
+ - `/mcp` / `/agent` do not implement MCP protocol or spawn process supervisors inside the bridge — they only guide or rephrase for the CLI.
248
+ - Deploy only for trusted users behind a whitelist when possible.
249
+
250
+ ## Contributing
251
+
252
+ See [`CONTRIBUTING.md`](CONTRIBUTING.md). Semantic Versioning from 1.0.0; record changes in [`CHANGELOG.md`](CHANGELOG.md).
253
+
254
+ ## License
255
+
256
+ MIT. See [`LICENSE`](LICENSE).
@@ -0,0 +1,43 @@
1
+ [project]
2
+ name = "wechatbridge-cli"
3
+ dynamic = ["version"]
4
+ description = "Bridge WeChat messages to agy or Grok Build CLIs — text/image/file/voice in, CLI replies and generated files back."
5
+ requires-python = ">=3.10"
6
+ license = { text = "MIT" }
7
+ urls = { Homepage = "https://github.com/dorokuma/wechatbridge", Repository = "https://github.com/dorokuma/wechatbridge", Issues = "https://github.com/dorokuma/wechatbridge/issues", Changelog = "https://github.com/dorokuma/wechatbridge/blob/main/CHANGELOG.md" }
8
+ authors = [
9
+ { name = "WeChatBridge contributors" },
10
+ ]
11
+ keywords = ["wechat", "bot", "bridge", "agy", "grok"]
12
+ classifiers = [
13
+ "Development Status :: 4 - Beta",
14
+ "Environment :: Console",
15
+ "Intended Audience :: Developers",
16
+ "License :: OSI Approved :: MIT License",
17
+ "Natural Language :: Chinese (Simplified)",
18
+ "Operating System :: POSIX :: Linux",
19
+ "Programming Language :: Python :: 3",
20
+ "Programming Language :: Python :: 3.10",
21
+ "Programming Language :: Python :: 3.11",
22
+ "Programming Language :: Python :: 3.12",
23
+ "Topic :: Communications :: Chat",
24
+ ]
25
+ dependencies = [
26
+ "httpx",
27
+ "qrcode",
28
+ "Pillow",
29
+ "cryptography",
30
+ ]
31
+
32
+ [project.scripts]
33
+ wechatbridge = "wechatbridge.main:main"
34
+
35
+ [build-system]
36
+ requires = ["setuptools>=68"]
37
+ build-backend = "setuptools.build_meta"
38
+
39
+ [tool.setuptools]
40
+ packages = ["wechatbridge"]
41
+
42
+ [tool.setuptools.dynamic]
43
+ version = { attr = "wechatbridge.__version__" }
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,2 @@
1
+ """WeChatBridge — bridge WeChat messages to agy or Grok Build CLIs."""
2
+ __version__ = "1.3.0"
@@ -0,0 +1,4 @@
1
+ from wechatbridge.main import main
2
+
3
+ if __name__ == "__main__":
4
+ main()