@agent-wechat/wechat 0.1.0

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.
package/README.md ADDED
@@ -0,0 +1,145 @@
1
+ # OpenClaw WeChat Extension
2
+
3
+ OpenClaw channel plugin for WeChat. Polls the agent-wechat REST API for inbound messages and dispatches replies through OpenClaw's agent runtime.
4
+
5
+ ## Prerequisites
6
+
7
+ - A running agent-wechat container (provides the REST API on port 6174)
8
+ - OpenClaw installed and configured
9
+
10
+ ## Development Setup
11
+
12
+ ### 1. Build
13
+
14
+ From the repo root:
15
+
16
+ ```bash
17
+ pnpm install
18
+ pnpm build
19
+ ```
20
+
21
+ This builds the shared package, CLI, and bundles the extension into `dist/index.js` via esbuild.
22
+
23
+ ### 2. Deploy to OpenClaw
24
+
25
+ ```bash
26
+ pnpm deploy:openclaw
27
+ ```
28
+
29
+ This copies `dist/index.js`, `package.json`, and `openclaw.plugin.json` into `../openclaw/extensions/wechat/` (sibling to the agent-wechat repo). To deploy to a different location:
30
+
31
+ ```bash
32
+ pnpm deploy:openclaw /path/to/openclaw/extensions/wechat
33
+ ```
34
+
35
+ ### 3. Enable the plugin
36
+
37
+ ```bash
38
+ openclaw plugins enable wechat
39
+ ```
40
+
41
+ ### 4. Configure the channel
42
+
43
+ ```bash
44
+ openclaw channels add --channel wechat --url http://localhost:6174
45
+ ```
46
+
47
+ Or edit `~/.openclaw/openclaw.json` directly:
48
+
49
+ ```json
50
+ {
51
+ "channels": {
52
+ "wechat": {
53
+ "enabled": true,
54
+ "serverUrl": "http://localhost:6174"
55
+ }
56
+ },
57
+ "plugins": {
58
+ "entries": {
59
+ "wechat": { "enabled": true }
60
+ }
61
+ }
62
+ }
63
+ ```
64
+
65
+ ### 5. Run the gateway
66
+
67
+ ```bash
68
+ openclaw gateway run --verbose
69
+ ```
70
+
71
+ The WeChat monitor starts polling the agent-wechat server for new messages. Make sure the agent-wechat container is running (`pnpm cli up` / `pnpm cli status`).
72
+
73
+ ### Iterating
74
+
75
+ After making changes to the extension source:
76
+
77
+ ```bash
78
+ pnpm deploy:openclaw # rebuilds + copies
79
+ # restart the gateway
80
+ ```
81
+
82
+ ## Docker Setup
83
+
84
+ The extension is bundled into a single `dist/index.js` with no runtime dependency on the shared package. Mount just the three required files:
85
+
86
+ ```bash
87
+ mkdir -p /host/openclaw-ext/wechat/dist
88
+ cp packages/openclaw-extension/dist/index.js /host/openclaw-ext/wechat/dist/index.js
89
+ cp packages/openclaw-extension/package.json /host/openclaw-ext/wechat/package.json
90
+ cp packages/openclaw-extension/openclaw.plugin.json /host/openclaw-ext/wechat/openclaw.plugin.json
91
+
92
+ docker run \
93
+ -v /host/openclaw-ext/wechat:/app/extensions/wechat \
94
+ openclaw-image
95
+ ```
96
+
97
+ Inside the container, configure `channels.wechat.serverUrl` to point at the agent-wechat server. If both containers are on the same Docker network:
98
+
99
+ ```json
100
+ {
101
+ "channels": {
102
+ "wechat": {
103
+ "enabled": true,
104
+ "serverUrl": "http://agent-wechat:6174"
105
+ }
106
+ }
107
+ }
108
+ ```
109
+
110
+ ## Configuration Reference
111
+
112
+ All config lives under `channels.wechat` in OpenClaw's config file:
113
+
114
+ | Key | Type | Default | Description |
115
+ |-----|------|---------|-------------|
116
+ | `enabled` | boolean | `false` | Enable the WeChat channel |
117
+ | `serverUrl` | string | — | agent-wechat REST API URL |
118
+ | `dmPolicy` | `"open" \| "allowlist" \| "disabled"` | `"disabled"` | Who can DM the bot |
119
+ | `allowFrom` | string[] | `[]` | wxid allowlist for DMs (when policy is `allowlist`) |
120
+ | `groupPolicy` | `"open" \| "allowlist" \| "disabled"` | `"disabled"` | Group message policy |
121
+ | `groupAllowFrom` | string[] | `[]` | wxid allowlist for group senders |
122
+ | `groups` | object | `{}` | Per-group overrides (e.g. `{ "id@chatroom": { "requireMention": false } }`) |
123
+ | `pollIntervalMs` | integer | `1000` | Message polling interval |
124
+ | `authPollIntervalMs` | integer | `30000` | Auth status check interval |
125
+
126
+ ## Architecture
127
+
128
+ ```
129
+ OpenClaw Gateway
130
+ └── WeChat Monitor (polling loop)
131
+
132
+ │ GET /api/chats (list chats with unreads)
133
+ │ POST /api/chats/{id}/open (open chat, clear unreads)
134
+ │ GET /api/messages/{id} (fetch new messages)
135
+ │ GET /api/messages/{id}/media/{localId} (download media)
136
+ │ POST /api/messages/send (send reply)
137
+
138
+
139
+ agent-wechat container (port 6174)
140
+
141
+
142
+ WeChat Desktop (in Xvfb)
143
+ ```
144
+
145
+ The monitor polls for chats with unread messages, fetches new messages, resolves routing/session via OpenClaw's runtime, and dispatches replies back through the agent-wechat API.