@agent-wechat/wechat 0.1.0 → 0.2.1

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 (2) hide show
  1. package/README.md +70 -58
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,47 +1,83 @@
1
- # OpenClaw WeChat Extension
1
+ # @agent-wechat/wechat
2
2
 
3
3
  OpenClaw channel plugin for WeChat. Polls the agent-wechat REST API for inbound messages and dispatches replies through OpenClaw's agent runtime.
4
4
 
5
5
  ## Prerequisites
6
6
 
7
- - A running agent-wechat container (provides the REST API on port 6174)
7
+ - [Docker](https://docs.docker.com/get-docker/) installed and running
8
8
  - OpenClaw installed and configured
9
9
 
10
- ## Development Setup
10
+ > **Note:** The agent-wechat container requires `SYS_PTRACE` and `seccomp=unconfined` (ptrace access to the WeChat desktop process). It cannot run in serverless or restricted container environments (AWS Fargate, Cloud Run, etc.) — use a VM or bare-metal Docker host.
11
11
 
12
- ### 1. Build
12
+ ## Setup
13
13
 
14
- From the repo root:
14
+ ### 1. Start the agent-wechat container
15
+
16
+ **Option A: CLI** (quickest for local use)
15
17
 
16
18
  ```bash
17
- pnpm install
18
- pnpm build
19
+ npm install -g @agent-wechat/cli
20
+ wx up
19
21
  ```
20
22
 
21
- This builds the shared package, CLI, and bundles the extension into `dist/index.js` via esbuild.
23
+ **Option B: Docker Compose** (production / networked)
24
+
25
+ ```yaml
26
+ services:
27
+ agent-wechat:
28
+ image: ghcr.io/thisnick/agent-wechat:latest
29
+ container_name: agent-wechat
30
+ security_opt:
31
+ - seccomp=unconfined
32
+ cap_add:
33
+ - SYS_PTRACE
34
+ ports:
35
+ - "6174:6174"
36
+ - "127.0.0.1:5900:5900"
37
+ volumes:
38
+ - agent-wechat-data:/data
39
+ - agent-wechat-home:/home/wechat
40
+ - ~/.config/agent-wechat/token:/data/auth-token:ro
41
+ restart: unless-stopped
42
+
43
+ volumes:
44
+ agent-wechat-data:
45
+ agent-wechat-home:
46
+ ```
22
47
 
23
- ### 2. Deploy to OpenClaw
48
+ Generate a token before starting:
24
49
 
25
50
  ```bash
26
- pnpm deploy:openclaw
51
+ mkdir -p ~/.config/agent-wechat
52
+ openssl rand -hex 32 > ~/.config/agent-wechat/token
53
+ chmod 600 ~/.config/agent-wechat/token
54
+ docker compose up -d
27
55
  ```
28
56
 
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:
57
+ If running alongside OpenClaw on the same Docker network, set `serverUrl` to `http://agent-wechat:6174` in the channel config below.
58
+
59
+ ### 2. Install the extension
30
60
 
31
61
  ```bash
32
- pnpm deploy:openclaw /path/to/openclaw/extensions/wechat
62
+ openclaw plugins install @agent-wechat/wechat
33
63
  ```
34
64
 
35
- ### 3. Enable the plugin
65
+ ### 3. Log in to WeChat
36
66
 
37
67
  ```bash
38
- openclaw plugins enable wechat
68
+ openclaw channels login --channel wechat
39
69
  ```
40
70
 
71
+ This displays a QR code in your terminal — scan it with WeChat on your phone. You only need to do this once (the session persists across container restarts).
72
+
73
+ If you installed the CLI, you can also use `wx auth login`.
74
+
41
75
  ### 4. Configure the channel
42
76
 
77
+ Run the setup wizard:
78
+
43
79
  ```bash
44
- openclaw channels add --channel wechat --url http://localhost:6174
80
+ openclaw channels setup wechat
45
81
  ```
46
82
 
47
83
  Or edit `~/.openclaw/openclaw.json` directly:
@@ -53,11 +89,6 @@ Or edit `~/.openclaw/openclaw.json` directly:
53
89
  "enabled": true,
54
90
  "serverUrl": "http://localhost:6174"
55
91
  }
56
- },
57
- "plugins": {
58
- "entries": {
59
- "wechat": { "enabled": true }
60
- }
61
92
  }
62
93
  }
63
94
  ```
@@ -68,44 +99,7 @@ Or edit `~/.openclaw/openclaw.json` directly:
68
99
  openclaw gateway run --verbose
69
100
  ```
70
101
 
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
- ```
102
+ The WeChat monitor starts polling the agent-wechat server for new messages. Make sure the agent-wechat container is running.
109
103
 
110
104
  ## Configuration Reference
111
105
 
@@ -123,6 +117,24 @@ All config lives under `channels.wechat` in OpenClaw's config file:
123
117
  | `pollIntervalMs` | integer | `1000` | Message polling interval |
124
118
  | `authPollIntervalMs` | integer | `30000` | Auth status check interval |
125
119
 
120
+ ## Development
121
+
122
+ ### Build from source
123
+
124
+ ```bash
125
+ git clone https://github.com/thisnick/agent-wechat.git
126
+ cd agent-wechat
127
+ pnpm install && pnpm build
128
+ ```
129
+
130
+ ### Link for local development
131
+
132
+ ```bash
133
+ openclaw plugins install -l ./packages/openclaw-extension
134
+ ```
135
+
136
+ This symlinks the extension so changes are picked up without reinstalling. Rebuild with `pnpm build` after making changes, then restart the gateway.
137
+
126
138
  ## Architecture
127
139
 
128
140
  ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agent-wechat/wechat",
3
- "version": "0.1.0",
3
+ "version": "0.2.1",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist",