@agent-wechat/wechaty-puppet 0.8.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,88 @@
1
+ # @agent-wechat/wechaty-puppet
2
+
3
+ Wechaty Puppet for [agent-wechat](https://github.com/thisnick/agent-wechat). Bridges any Wechaty bot to WeChat via the agent-wechat REST/WebSocket server.
4
+
5
+ ## Prerequisites
6
+
7
+ - **An agent-wechat server** running (Docker container or via `wx up`)
8
+ - **Node.js >= 22**
9
+
10
+ ## Install
11
+
12
+ ```bash
13
+ npm install @agent-wechat/wechaty-puppet wechaty wechaty-puppet
14
+ ```
15
+
16
+ ## Usage
17
+
18
+ ```ts
19
+ import { WechatyBuilder } from 'wechaty'
20
+ import PuppetAgentWeChat from '@agent-wechat/wechaty-puppet'
21
+
22
+ const bot = WechatyBuilder.build({
23
+ puppet: new PuppetAgentWeChat({
24
+ serverUrl: 'http://localhost:6174', // optional, this is the default
25
+ token: 'your-token', // optional, reads from ~/.config/agent-wechat/token
26
+ })
27
+ })
28
+
29
+ bot.on('scan', (qrcode, status) => {
30
+ console.log(`Scan QR code: status=${status}`)
31
+ // Use qrcode-terminal or similar to display the QR
32
+ })
33
+
34
+ bot.on('login', user => console.log(`Logged in: ${user}`))
35
+
36
+ bot.on('message', async msg => {
37
+ if (msg.text() === 'ding') {
38
+ await msg.say('dong')
39
+ }
40
+ })
41
+
42
+ await bot.start()
43
+ ```
44
+
45
+ ## Configuration
46
+
47
+ | Option | Type | Default | Description |
48
+ |--------|------|---------|-------------|
49
+ | `serverUrl` | string | `http://localhost:6174` | agent-wechat server URL |
50
+ | `token` | string | auto | Auth token. Falls back to `AGENT_WECHAT_TOKEN` env var, then `~/.config/agent-wechat/token` |
51
+ | `pollIntervalMs` | number | `2000` | Message polling interval in milliseconds |
52
+
53
+ ## Supported Features
54
+
55
+ | Feature | Status | Notes |
56
+ |---------|--------|-------|
57
+ | QR Login | Yes | Via WebSocket `/api/ws/login` |
58
+ | Logout | Yes | |
59
+ | Receive Text | Yes | Polling-based |
60
+ | Receive Image | Yes | Via media endpoint |
61
+ | Receive Voice | Yes | Via media endpoint |
62
+ | Receive Video | Yes | Via media endpoint |
63
+ | Receive Emoticon | Yes | |
64
+ | Send Text | Yes | |
65
+ | Send Image | Yes | |
66
+ | Send File | Yes | |
67
+ | Contact List | Yes | Full address book via `/api/contacts` |
68
+ | Contact Alias | Read | From remark field |
69
+ | Room List | Partial | Recent group chats only |
70
+ | Room Topic | Read | From group name |
71
+ | Forward Text | Yes | |
72
+ | Send URL | Partial | Sent as plain text |
73
+ | Message Recall | No | |
74
+ | Room Create | No | |
75
+ | Room Add/Remove | No | |
76
+ | Friendship | No | |
77
+ | Tags | No | |
78
+ | Moments/Posts | No | |
79
+
80
+ ## How It Works
81
+
82
+ The puppet connects to the agent-wechat REST API (Rust server running inside a Docker container alongside WeChat desktop). It does not interact with WeChat directly.
83
+
84
+ - **Login**: WebSocket subscription to `/api/ws/login` drives QR scan events
85
+ - **Messages**: Polls `GET /api/chats` for unreads, then `GET /api/messages/{chatId}` for new messages
86
+ - **Sending**: `POST /api/messages/send` with text, image, or file payloads
87
+ - **Media**: `GET /api/messages/{chatId}/media/{localId}` for image/voice/video downloads
88
+ - **Contacts/Rooms**: Derived from `GET /api/chats` (contacts = non-group chats, rooms = group chats)
package/dist/mod.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ export { PuppetAgentWeChat, PuppetAgentWeChat as default } from './puppet-agent-wechat.js';
2
+ export type { PuppetAgentWeChatOptions } from './puppet-agent-wechat.js';
3
+ //# sourceMappingURL=mod.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../src/mod.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,IAAI,OAAO,EAAE,MAAM,0BAA0B,CAAA;AAC1F,YAAY,EAAE,wBAAwB,EAAE,MAAM,0BAA0B,CAAA"}