agent-messenger 2.2.0 → 2.4.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/.claude-plugin/README.md +16 -16
- package/.claude-plugin/marketplace.json +29 -29
- package/.claude-plugin/plugin.json +5 -5
- package/CONTRIBUTING.md +1 -1
- package/README.md +9 -6
- package/bun.lock +89 -105
- package/bunfig.toml +3 -0
- package/dist/package.json +13 -3
- package/dist/src/platforms/discordbot/client.js +2 -2
- package/dist/src/platforms/discordbot/client.js.map +1 -1
- package/dist/src/platforms/kakaotalk/cli.d.ts.map +1 -1
- package/dist/src/platforms/kakaotalk/cli.js +2 -1
- package/dist/src/platforms/kakaotalk/cli.js.map +1 -1
- package/dist/src/platforms/kakaotalk/client.d.ts +2 -1
- package/dist/src/platforms/kakaotalk/client.d.ts.map +1 -1
- package/dist/src/platforms/kakaotalk/client.js +52 -2
- package/dist/src/platforms/kakaotalk/client.js.map +1 -1
- package/dist/src/platforms/kakaotalk/commands/index.d.ts +1 -0
- package/dist/src/platforms/kakaotalk/commands/index.d.ts.map +1 -1
- package/dist/src/platforms/kakaotalk/commands/index.js +1 -0
- package/dist/src/platforms/kakaotalk/commands/index.js.map +1 -1
- package/dist/src/platforms/kakaotalk/commands/profile.d.ts +3 -0
- package/dist/src/platforms/kakaotalk/commands/profile.d.ts.map +1 -0
- package/dist/src/platforms/kakaotalk/commands/profile.js +19 -0
- package/dist/src/platforms/kakaotalk/commands/profile.js.map +1 -0
- package/dist/src/platforms/kakaotalk/index.d.ts +2 -2
- package/dist/src/platforms/kakaotalk/index.d.ts.map +1 -1
- package/dist/src/platforms/kakaotalk/index.js +1 -1
- package/dist/src/platforms/kakaotalk/index.js.map +1 -1
- package/dist/src/platforms/kakaotalk/protocol/session.d.ts.map +1 -1
- package/dist/src/platforms/kakaotalk/protocol/session.js +2 -1
- package/dist/src/platforms/kakaotalk/protocol/session.js.map +1 -1
- package/dist/src/platforms/kakaotalk/types.d.ts +16 -0
- package/dist/src/platforms/kakaotalk/types.d.ts.map +1 -1
- package/dist/src/platforms/kakaotalk/types.js +8 -0
- package/dist/src/platforms/kakaotalk/types.js.map +1 -1
- package/dist/src/platforms/line/commands/auth.d.ts.map +1 -1
- package/dist/src/platforms/line/commands/auth.js +32 -20
- package/dist/src/platforms/line/commands/auth.js.map +1 -1
- package/dist/src/platforms/teams/commands/reaction.d.ts.map +1 -1
- package/dist/src/platforms/teams/commands/reaction.js +2 -0
- package/dist/src/platforms/teams/commands/reaction.js.map +1 -1
- package/dist/src/platforms/webex/client.d.ts +2 -0
- package/dist/src/platforms/webex/client.d.ts.map +1 -1
- package/dist/src/platforms/webex/client.js +66 -23
- package/dist/src/platforms/webex/client.js.map +1 -1
- package/dist/src/platforms/webex/commands/auth.d.ts.map +1 -1
- package/dist/src/platforms/webex/commands/auth.js +4 -0
- package/dist/src/platforms/webex/commands/auth.js.map +1 -1
- package/dist/src/platforms/webex/encryption.d.ts +10 -0
- package/dist/src/platforms/webex/encryption.d.ts.map +1 -0
- package/dist/src/platforms/webex/encryption.js +49 -0
- package/dist/src/platforms/webex/encryption.js.map +1 -0
- package/dist/src/platforms/webex/ensure-auth.d.ts.map +1 -1
- package/dist/src/platforms/webex/ensure-auth.js +4 -0
- package/dist/src/platforms/webex/ensure-auth.js.map +1 -1
- package/dist/src/platforms/webex/token-extractor.d.ts +6 -5
- package/dist/src/platforms/webex/token-extractor.d.ts.map +1 -1
- package/dist/src/platforms/webex/token-extractor.js +92 -43
- package/dist/src/platforms/webex/token-extractor.js.map +1 -1
- package/dist/src/platforms/webex/types.d.ts +4 -0
- package/dist/src/platforms/webex/types.d.ts.map +1 -1
- package/dist/src/platforms/webex/types.js +2 -0
- package/dist/src/platforms/webex/types.js.map +1 -1
- package/dist/src/platforms/wechatbot/cli.d.ts +5 -0
- package/dist/src/platforms/wechatbot/cli.d.ts.map +1 -0
- package/dist/src/platforms/wechatbot/cli.js +18 -0
- package/dist/src/platforms/wechatbot/cli.js.map +1 -0
- package/dist/src/platforms/wechatbot/client.d.ts +36 -0
- package/dist/src/platforms/wechatbot/client.d.ts.map +1 -0
- package/dist/src/platforms/wechatbot/client.js +208 -0
- package/dist/src/platforms/wechatbot/client.js.map +1 -0
- package/dist/src/platforms/wechatbot/commands/auth.d.ts +28 -0
- package/dist/src/platforms/wechatbot/commands/auth.d.ts.map +1 -0
- package/dist/src/platforms/wechatbot/commands/auth.js +164 -0
- package/dist/src/platforms/wechatbot/commands/auth.js.map +1 -0
- package/dist/src/platforms/wechatbot/commands/index.d.ts +5 -0
- package/dist/src/platforms/wechatbot/commands/index.d.ts.map +1 -0
- package/dist/src/platforms/wechatbot/commands/index.js +5 -0
- package/dist/src/platforms/wechatbot/commands/index.js.map +1 -0
- package/dist/src/platforms/wechatbot/commands/message.d.ts +18 -0
- package/dist/src/platforms/wechatbot/commands/message.d.ts.map +1 -0
- package/dist/src/platforms/wechatbot/commands/message.js +80 -0
- package/dist/src/platforms/wechatbot/commands/message.js.map +1 -0
- package/dist/src/platforms/wechatbot/commands/shared.d.ts +9 -0
- package/dist/src/platforms/wechatbot/commands/shared.d.ts.map +1 -0
- package/dist/src/platforms/wechatbot/commands/shared.js +13 -0
- package/dist/src/platforms/wechatbot/commands/shared.js.map +1 -0
- package/dist/src/platforms/wechatbot/commands/template.d.ts +19 -0
- package/dist/src/platforms/wechatbot/commands/template.d.ts.map +1 -0
- package/dist/src/platforms/wechatbot/commands/template.js +76 -0
- package/dist/src/platforms/wechatbot/commands/template.js.map +1 -0
- package/dist/src/platforms/wechatbot/commands/user.d.ts +20 -0
- package/dist/src/platforms/wechatbot/commands/user.d.ts.map +1 -0
- package/dist/src/platforms/wechatbot/commands/user.js +53 -0
- package/dist/src/platforms/wechatbot/commands/user.js.map +1 -0
- package/dist/src/platforms/wechatbot/credential-manager.d.ts +17 -0
- package/dist/src/platforms/wechatbot/credential-manager.d.ts.map +1 -0
- package/dist/src/platforms/wechatbot/credential-manager.js +121 -0
- package/dist/src/platforms/wechatbot/credential-manager.js.map +1 -0
- package/dist/src/platforms/wechatbot/index.d.ts +5 -0
- package/dist/src/platforms/wechatbot/index.d.ts.map +1 -0
- package/dist/src/platforms/wechatbot/index.js +4 -0
- package/dist/src/platforms/wechatbot/index.js.map +1 -0
- package/dist/src/platforms/wechatbot/types.d.ts +94 -0
- package/dist/src/platforms/wechatbot/types.d.ts.map +1 -0
- package/dist/src/platforms/wechatbot/types.js +54 -0
- package/dist/src/platforms/wechatbot/types.js.map +1 -0
- package/dist/src/platforms/whatsapp/client.d.ts +1 -0
- package/dist/src/platforms/whatsapp/client.d.ts.map +1 -1
- package/dist/src/platforms/whatsapp/client.js +27 -13
- package/dist/src/platforms/whatsapp/client.js.map +1 -1
- package/dist/src/platforms/whatsapp/commands/auth.d.ts.map +1 -1
- package/dist/src/platforms/whatsapp/commands/auth.js +21 -18
- package/dist/src/platforms/whatsapp/commands/auth.js.map +1 -1
- package/dist/src/platforms/whatsapp/credential-manager.d.ts.map +1 -1
- package/dist/src/platforms/whatsapp/credential-manager.js +14 -8
- package/dist/src/platforms/whatsapp/credential-manager.js.map +1 -1
- package/docs/content/docs/agent-skills.mdx +4 -4
- package/docs/content/docs/cli/channeltalk.mdx +1 -1
- package/docs/content/docs/cli/channeltalkbot.mdx +1 -1
- package/docs/content/docs/cli/discord.mdx +1 -1
- package/docs/content/docs/cli/discordbot.mdx +1 -1
- package/docs/content/docs/cli/instagram.mdx +1 -1
- package/docs/content/docs/cli/kakaotalk.mdx +1 -1
- package/docs/content/docs/cli/line.mdx +1 -1
- package/docs/content/docs/cli/meta.json +1 -0
- package/docs/content/docs/cli/slack.mdx +1 -1
- package/docs/content/docs/cli/slackbot.mdx +1 -1
- package/docs/content/docs/cli/teams.mdx +1 -1
- package/docs/content/docs/cli/webex.mdx +5 -3
- package/docs/content/docs/cli/wechatbot.mdx +179 -0
- package/docs/content/docs/cli/whatsapp.mdx +1 -1
- package/docs/content/docs/cli/whatsappbot.mdx +1 -1
- package/docs/content/docs/sdk/meta.json +1 -1
- package/docs/content/docs/sdk/wechatbot.mdx +282 -0
- package/docs/content/docs/tui.mdx +1 -1
- package/docs/src/app/page.tsx +5 -5
- package/package.json +13 -3
- package/skills/agent-channeltalk/SKILL.md +1 -1
- package/skills/agent-channeltalkbot/SKILL.md +1 -1
- package/skills/agent-discord/SKILL.md +1 -1
- package/skills/agent-discordbot/SKILL.md +1 -1
- package/skills/agent-instagram/SKILL.md +1 -1
- package/skills/agent-kakaotalk/SKILL.md +24 -1
- package/skills/agent-line/SKILL.md +7 -11
- package/skills/agent-line/references/authentication.md +13 -4
- package/skills/agent-slack/SKILL.md +1 -1
- package/skills/agent-slackbot/SKILL.md +1 -1
- package/skills/agent-teams/SKILL.md +1 -1
- package/skills/agent-telegram/SKILL.md +1 -1
- package/skills/agent-webex/SKILL.md +1 -1
- package/skills/agent-webex/references/authentication.md +4 -3
- package/skills/agent-webex/references/common-patterns.md +1 -1
- package/skills/agent-wechatbot/SKILL.md +385 -0
- package/skills/agent-whatsapp/SKILL.md +12 -1
- package/skills/agent-whatsappbot/SKILL.md +1 -1
- package/src/platforms/discord/credential-manager.test.ts +18 -1
- package/src/platforms/discordbot/client.ts +2 -2
- package/src/platforms/instagram/commands/auth.test.ts +216 -0
- package/src/platforms/instagram/commands/chat.test.ts +127 -0
- package/src/platforms/instagram/commands/message.test.ts +178 -0
- package/src/platforms/kakaotalk/cli.ts +2 -1
- package/src/platforms/kakaotalk/client.test.ts +157 -0
- package/src/platforms/kakaotalk/client.ts +57 -3
- package/src/platforms/kakaotalk/commands/auth.test.ts +299 -0
- package/src/platforms/kakaotalk/commands/chat.test.ts +97 -0
- package/src/platforms/kakaotalk/commands/index.ts +1 -0
- package/src/platforms/kakaotalk/commands/message.test.ts +113 -0
- package/src/platforms/kakaotalk/commands/profile.test.ts +84 -0
- package/src/platforms/kakaotalk/commands/profile.ts +21 -0
- package/src/platforms/kakaotalk/index.test.ts +5 -0
- package/src/platforms/kakaotalk/index.ts +2 -0
- package/src/platforms/kakaotalk/protocol/session.ts +2 -0
- package/src/platforms/kakaotalk/types.ts +18 -0
- package/src/platforms/line/commands/auth.test.ts +141 -0
- package/src/platforms/line/commands/auth.ts +28 -19
- package/src/platforms/line/commands/chat.test.ts +110 -0
- package/src/platforms/line/commands/friend.test.ts +98 -0
- package/src/platforms/line/commands/message.test.ts +119 -0
- package/src/platforms/line/commands/profile.test.ts +85 -0
- package/src/platforms/slackbot/commands/channel.test.ts +139 -0
- package/src/platforms/slackbot/commands/message.test.ts +226 -0
- package/src/platforms/slackbot/commands/reaction.test.ts +90 -0
- package/src/platforms/slackbot/commands/user.test.ts +143 -0
- package/src/platforms/teams/commands/reaction.test.ts +45 -61
- package/src/platforms/teams/commands/reaction.ts +2 -0
- package/src/platforms/telegram/commands/chat.test.ts +125 -0
- package/src/platforms/telegram/commands/message.test.ts +92 -0
- package/src/platforms/webex/client.ts +98 -26
- package/src/platforms/webex/commands/auth.ts +4 -0
- package/src/platforms/webex/commands/member.test.ts +65 -58
- package/src/platforms/webex/commands/message.test.ts +78 -121
- package/src/platforms/webex/commands/snapshot.test.ts +59 -46
- package/src/platforms/webex/commands/space.test.ts +49 -48
- package/src/platforms/webex/encryption.ts +53 -0
- package/src/platforms/webex/ensure-auth.ts +4 -0
- package/src/platforms/webex/token-extractor.ts +107 -40
- package/src/platforms/webex/types.ts +4 -0
- package/src/platforms/webex/typings/node-jose.d.ts +27 -0
- package/src/platforms/wechatbot/cli.ts +24 -0
- package/src/platforms/wechatbot/client.test.ts +497 -0
- package/src/platforms/wechatbot/client.ts +268 -0
- package/src/platforms/wechatbot/commands/auth.test.ts +211 -0
- package/src/platforms/wechatbot/commands/auth.ts +203 -0
- package/src/platforms/wechatbot/commands/index.ts +4 -0
- package/src/platforms/wechatbot/commands/message.test.ts +155 -0
- package/src/platforms/wechatbot/commands/message.ts +104 -0
- package/src/platforms/wechatbot/commands/shared.ts +22 -0
- package/src/platforms/wechatbot/commands/template.test.ts +199 -0
- package/src/platforms/wechatbot/commands/template.ts +102 -0
- package/src/platforms/wechatbot/commands/user.test.ts +165 -0
- package/src/platforms/wechatbot/commands/user.ts +75 -0
- package/src/platforms/wechatbot/credential-manager.test.ts +255 -0
- package/src/platforms/wechatbot/credential-manager.ts +148 -0
- package/src/platforms/wechatbot/index.test.ts +49 -0
- package/src/platforms/wechatbot/index.ts +19 -0
- package/src/platforms/wechatbot/types.test.ts +223 -0
- package/src/platforms/wechatbot/types.ts +107 -0
- package/src/platforms/whatsapp/client.ts +24 -13
- package/src/platforms/whatsapp/commands/auth.test.ts +311 -0
- package/src/platforms/whatsapp/commands/auth.ts +21 -17
- package/src/platforms/whatsapp/commands/chat.test.ts +198 -0
- package/src/platforms/whatsapp/commands/message.test.ts +231 -0
- package/src/platforms/whatsapp/credential-manager.test.ts +20 -0
- package/src/platforms/whatsapp/credential-manager.ts +17 -8
- package/src/platforms/whatsappbot/commands/auth.test.ts +217 -0
- package/src/platforms/whatsappbot/commands/message.test.ts +198 -0
- package/src/platforms/whatsappbot/commands/template.test.ts +112 -0
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: WeChat Bot
|
|
3
|
+
description: TypeScript SDK reference for WeChat Bot — Official Account API client, credential management, and types.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
## Installation
|
|
7
|
+
|
|
8
|
+
```bash
|
|
9
|
+
npm install agent-messenger
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
```typescript
|
|
13
|
+
import {
|
|
14
|
+
WeChatBotClient,
|
|
15
|
+
WeChatBotCredentialManager,
|
|
16
|
+
WeChatBotError,
|
|
17
|
+
} from 'agent-messenger/wechatbot'
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## WeChatBotClient
|
|
21
|
+
|
|
22
|
+
The main client for interacting with the WeChat Official Account API programmatically. Handles access token lifecycle (caching, auto-refresh on expiry), errcode-aware response parsing, and automatic retries on transient errors. All API calls use query-parameter token injection per WeChat convention.
|
|
23
|
+
|
|
24
|
+
```typescript
|
|
25
|
+
import { WeChatBotClient } from 'agent-messenger/wechatbot'
|
|
26
|
+
|
|
27
|
+
const client = await new WeChatBotClient().login({ appId, appSecret })
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Or use automatic credential extraction, where credentials are read from stored config:
|
|
31
|
+
|
|
32
|
+
```typescript
|
|
33
|
+
import { WeChatBotClient } from 'agent-messenger/wechatbot'
|
|
34
|
+
|
|
35
|
+
const client = await new WeChatBotClient().login()
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### Verification
|
|
39
|
+
|
|
40
|
+
```typescript
|
|
41
|
+
// Verify credentials by attempting to obtain an access token
|
|
42
|
+
const valid = await client.verifyCredentials()
|
|
43
|
+
// → boolean
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### Customer Service Messages
|
|
47
|
+
|
|
48
|
+
Customer service messages can be sent to users who have interacted with your Official Account within the last 48 hours.
|
|
49
|
+
|
|
50
|
+
```typescript
|
|
51
|
+
// Send a text message
|
|
52
|
+
await client.sendTextMessage('oABCD1234', 'Hello from the bot!')
|
|
53
|
+
|
|
54
|
+
// Send an image message (requires a media ID from WeChat's media upload API)
|
|
55
|
+
await client.sendImageMessage('oABCD1234', 'MEDIA_ID_HERE')
|
|
56
|
+
|
|
57
|
+
// Send a news/article message
|
|
58
|
+
await client.sendNewsMessage('oABCD1234', [
|
|
59
|
+
{
|
|
60
|
+
title: 'Your Order Update',
|
|
61
|
+
description: 'Your order #12345 has been shipped',
|
|
62
|
+
url: 'https://example.com/orders/12345',
|
|
63
|
+
picurl: 'https://example.com/images/shipping.jpg',
|
|
64
|
+
},
|
|
65
|
+
])
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### Template Messages
|
|
69
|
+
|
|
70
|
+
Template messages can be sent at any time, regardless of the 48-hour interaction window.
|
|
71
|
+
|
|
72
|
+
```typescript
|
|
73
|
+
// Send a template message
|
|
74
|
+
const result = await client.sendTemplateMessage(
|
|
75
|
+
'oABCD1234',
|
|
76
|
+
'TM00001',
|
|
77
|
+
{ order_id: { value: 'ORD-9876' }, customer_name: { value: 'Alice' } },
|
|
78
|
+
'https://example.com/order/9876', // optional click URL
|
|
79
|
+
)
|
|
80
|
+
console.log(`Message ID: ${result.msgid}`)
|
|
81
|
+
// → { msgid: number }
|
|
82
|
+
|
|
83
|
+
// List all private templates
|
|
84
|
+
const templates = await client.listTemplates()
|
|
85
|
+
// → WeChatBotTemplate[]
|
|
86
|
+
|
|
87
|
+
// Delete a template
|
|
88
|
+
await client.deleteTemplate('TM00001')
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### Users
|
|
92
|
+
|
|
93
|
+
```typescript
|
|
94
|
+
// List followers (paginated)
|
|
95
|
+
const followers = await client.getFollowers()
|
|
96
|
+
console.log(`Total: ${followers.total}, This page: ${followers.count}`)
|
|
97
|
+
// → { total: number, count: number, openids: string[], next_openid: string }
|
|
98
|
+
|
|
99
|
+
// Get next page
|
|
100
|
+
const nextPage = await client.getFollowers(followers.next_openid)
|
|
101
|
+
|
|
102
|
+
// Get user info
|
|
103
|
+
const user = await client.getUserInfo('oABCD1234', 'en')
|
|
104
|
+
// → WeChatBotUserInfo
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
## WeChatBotCredentialManager
|
|
108
|
+
|
|
109
|
+
Manages WeChat Bot credentials stored at `~/.config/agent-messenger/wechatbot-credentials.json`. Files are written with `0o600` permissions. The environment variables `E2E_WECHATBOT_APP_ID` and `E2E_WECHATBOT_APP_SECRET` take precedence when calling `getCredentials()` without an `accountId`.
|
|
110
|
+
|
|
111
|
+
```typescript
|
|
112
|
+
import { WeChatBotCredentialManager } from 'agent-messenger/wechatbot'
|
|
113
|
+
|
|
114
|
+
const manager = new WeChatBotCredentialManager()
|
|
115
|
+
// Custom path: new WeChatBotCredentialManager('/custom/config/dir')
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
```typescript
|
|
119
|
+
// Load full config from disk (returns defaults if file doesn't exist)
|
|
120
|
+
const config = await manager.load()
|
|
121
|
+
// → WeChatBotConfig
|
|
122
|
+
|
|
123
|
+
// Save full config to disk
|
|
124
|
+
await manager.save(config)
|
|
125
|
+
|
|
126
|
+
// Get credentials for an account (env vars take precedence)
|
|
127
|
+
const creds = await manager.getCredentials()
|
|
128
|
+
const specific = await manager.getCredentials(accountId)
|
|
129
|
+
// → WeChatBotCredentials | null
|
|
130
|
+
|
|
131
|
+
// Store credentials for an account
|
|
132
|
+
await manager.setCredentials({
|
|
133
|
+
app_id: 'wx1234567890',
|
|
134
|
+
app_secret: '...',
|
|
135
|
+
account_name: 'wx1234567890',
|
|
136
|
+
})
|
|
137
|
+
|
|
138
|
+
// Remove an account's credentials
|
|
139
|
+
const removed = await manager.removeAccount('wx1234567890')
|
|
140
|
+
// → boolean
|
|
141
|
+
|
|
142
|
+
// Set the current default account
|
|
143
|
+
const ok = await manager.setCurrent('wx1234567890')
|
|
144
|
+
// → boolean
|
|
145
|
+
|
|
146
|
+
// List all saved accounts with current marker
|
|
147
|
+
const all = await manager.listAll()
|
|
148
|
+
// → Array<WeChatBotAccountEntry & { is_current: boolean }>
|
|
149
|
+
|
|
150
|
+
// Clear all stored credentials
|
|
151
|
+
await manager.clearCredentials()
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
## Types
|
|
155
|
+
|
|
156
|
+
```typescript
|
|
157
|
+
import type {
|
|
158
|
+
WeChatBotAccountEntry,
|
|
159
|
+
WeChatBotConfig,
|
|
160
|
+
WeChatBotCredentials,
|
|
161
|
+
WeChatBotNewsArticle,
|
|
162
|
+
WeChatBotTemplate,
|
|
163
|
+
WeChatBotUserInfo,
|
|
164
|
+
} from 'agent-messenger/wechatbot'
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
## WeChatBotError
|
|
168
|
+
|
|
169
|
+
Thrown on authentication failures, network errors, rate limits, and API errors. Includes a `code` string for programmatic handling.
|
|
170
|
+
|
|
171
|
+
```typescript
|
|
172
|
+
import { WeChatBotError } from 'agent-messenger/wechatbot'
|
|
173
|
+
|
|
174
|
+
try {
|
|
175
|
+
await client.sendTextMessage('oABCD1234', 'Hello')
|
|
176
|
+
} catch (error) {
|
|
177
|
+
if (error instanceof WeChatBotError) {
|
|
178
|
+
console.error(`${error.code}: ${error.message}`)
|
|
179
|
+
// e.g. "40001: Invalid credential"
|
|
180
|
+
// e.g. "45009: Reach max API daily quota limit"
|
|
181
|
+
// e.g. "40164: Invalid ip, not in whitelist"
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
### Zod Schemas
|
|
187
|
+
|
|
188
|
+
Runtime-validated schemas are also exported for parsing API responses:
|
|
189
|
+
|
|
190
|
+
```typescript
|
|
191
|
+
import {
|
|
192
|
+
WeChatBotAccountEntrySchema,
|
|
193
|
+
WeChatBotConfigSchema,
|
|
194
|
+
WeChatBotCredentialsSchema,
|
|
195
|
+
WeChatBotNewsArticleSchema,
|
|
196
|
+
WeChatBotTemplateSchema,
|
|
197
|
+
WeChatBotUserInfoSchema,
|
|
198
|
+
} from 'agent-messenger/wechatbot'
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
## Examples
|
|
202
|
+
|
|
203
|
+
### Send Template Notification
|
|
204
|
+
|
|
205
|
+
Send a template message with dynamic data to a follower.
|
|
206
|
+
|
|
207
|
+
```typescript
|
|
208
|
+
import { WeChatBotClient } from 'agent-messenger/wechatbot'
|
|
209
|
+
|
|
210
|
+
const client = await new WeChatBotClient().login({ appId, appSecret })
|
|
211
|
+
|
|
212
|
+
const result = await client.sendTemplateMessage(
|
|
213
|
+
'oABCD1234',
|
|
214
|
+
'order_confirmation',
|
|
215
|
+
{
|
|
216
|
+
order_id: { value: 'ORD-5678' },
|
|
217
|
+
status: { value: 'Shipped' },
|
|
218
|
+
date: { value: 'March 30, 2026' },
|
|
219
|
+
},
|
|
220
|
+
'https://example.com/orders/5678',
|
|
221
|
+
)
|
|
222
|
+
console.log(`Sent template, msgid: ${result.msgid}`)
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
### Broadcast to All Followers
|
|
226
|
+
|
|
227
|
+
Iterate through paginated follower list and send template messages.
|
|
228
|
+
|
|
229
|
+
```typescript
|
|
230
|
+
import { WeChatBotClient } from 'agent-messenger/wechatbot'
|
|
231
|
+
|
|
232
|
+
const client = await new WeChatBotClient().login({ appId, appSecret })
|
|
233
|
+
|
|
234
|
+
let nextOpenId: string | undefined
|
|
235
|
+
do {
|
|
236
|
+
const page = await client.getFollowers(nextOpenId)
|
|
237
|
+
for (const openId of page.openids) {
|
|
238
|
+
await client.sendTemplateMessage(openId, 'weekly_update', {
|
|
239
|
+
content: { value: 'New features released this week!' },
|
|
240
|
+
})
|
|
241
|
+
}
|
|
242
|
+
nextOpenId = page.next_openid || undefined
|
|
243
|
+
} while (nextOpenId)
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
### Multi-Account Management
|
|
247
|
+
|
|
248
|
+
Set up and switch between multiple Official Account credentials.
|
|
249
|
+
|
|
250
|
+
```typescript
|
|
251
|
+
import { WeChatBotCredentialManager, WeChatBotClient } from 'agent-messenger/wechatbot'
|
|
252
|
+
|
|
253
|
+
const manager = new WeChatBotCredentialManager()
|
|
254
|
+
|
|
255
|
+
// Store credentials for two accounts
|
|
256
|
+
await manager.setCredentials({
|
|
257
|
+
app_id: 'wx1111111111',
|
|
258
|
+
app_secret: 'secret1...',
|
|
259
|
+
account_name: 'wx1111111111',
|
|
260
|
+
})
|
|
261
|
+
|
|
262
|
+
await manager.setCredentials({
|
|
263
|
+
app_id: 'wx2222222222',
|
|
264
|
+
app_secret: 'secret2...',
|
|
265
|
+
account_name: 'wx2222222222',
|
|
266
|
+
})
|
|
267
|
+
|
|
268
|
+
// List all accounts
|
|
269
|
+
const accounts = await manager.listAll()
|
|
270
|
+
for (const acct of accounts) {
|
|
271
|
+
const marker = acct.is_current ? '(current)' : ''
|
|
272
|
+
console.log(`${acct.account_name} [${acct.app_id}] ${marker}`)
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
// Switch to a specific account
|
|
276
|
+
await manager.setCurrent('wx1111111111')
|
|
277
|
+
|
|
278
|
+
// Login picks up the current account automatically
|
|
279
|
+
const client = await new WeChatBotClient().login()
|
|
280
|
+
const valid = await client.verifyCredentials()
|
|
281
|
+
console.log(`Credentials valid: ${valid}`)
|
|
282
|
+
```
|
|
@@ -113,7 +113,7 @@ This means adding a new platform to the TUI is just implementing one adapter —
|
|
|
113
113
|
|
|
114
114
|
## Source
|
|
115
115
|
|
|
116
|
-
The TUI source lives in [`src/tui/`](https://github.com/
|
|
116
|
+
The TUI source lives in [`src/tui/`](https://github.com/agent-messenger/agent-messenger/tree/main/src/tui):
|
|
117
117
|
|
|
118
118
|
```
|
|
119
119
|
src/tui/
|
package/docs/src/app/page.tsx
CHANGED
|
@@ -543,7 +543,7 @@ const HOW_IT_WORKS = [
|
|
|
543
543
|
{
|
|
544
544
|
step: 3,
|
|
545
545
|
title: 'Teach Your Agent',
|
|
546
|
-
code: 'npx skills add
|
|
546
|
+
code: 'npx skills add agent-messenger/agent-messenger',
|
|
547
547
|
description: 'Install Agent Skills via Skills CLI, Claude Code, OpenCode, or SkillPad — your agent learns every command and starts messaging on its own.',
|
|
548
548
|
},
|
|
549
549
|
]
|
|
@@ -617,7 +617,7 @@ export default function Home() {
|
|
|
617
617
|
docs
|
|
618
618
|
</Link>
|
|
619
619
|
<a
|
|
620
|
-
href="https://github.com/
|
|
620
|
+
href="https://github.com/agent-messenger/agent-messenger"
|
|
621
621
|
target="_blank"
|
|
622
622
|
rel="noopener noreferrer"
|
|
623
623
|
className="rounded-lg px-3 py-2 font-mono text-xs text-zinc-500 transition-colors hover:text-zinc-900 dark:text-zinc-400 dark:hover:text-zinc-100"
|
|
@@ -661,7 +661,7 @@ export default function Home() {
|
|
|
661
661
|
Get Started
|
|
662
662
|
</Link>
|
|
663
663
|
<a
|
|
664
|
-
href="https://github.com/
|
|
664
|
+
href="https://github.com/agent-messenger/agent-messenger"
|
|
665
665
|
target="_blank"
|
|
666
666
|
rel="noopener noreferrer"
|
|
667
667
|
className="inline-flex items-center justify-center rounded-xl border border-zinc-300 px-6 py-3 text-sm font-medium text-zinc-700 transition-all duration-300 hover:bg-zinc-50 dark:border-white/[0.06] dark:text-zinc-300 dark:hover:border-white/15 dark:hover:bg-white/[0.05]"
|
|
@@ -1002,7 +1002,7 @@ export default function Home() {
|
|
|
1002
1002
|
Read the Docs
|
|
1003
1003
|
</Link>
|
|
1004
1004
|
<a
|
|
1005
|
-
href="https://github.com/
|
|
1005
|
+
href="https://github.com/agent-messenger/agent-messenger"
|
|
1006
1006
|
target="_blank"
|
|
1007
1007
|
rel="noopener noreferrer"
|
|
1008
1008
|
className="inline-flex items-center justify-center rounded-xl border border-zinc-300 px-6 py-3 text-sm font-medium text-zinc-700 transition-all duration-300 hover:bg-white dark:border-white/[0.06] dark:text-zinc-300 dark:hover:border-white/15 dark:hover:bg-white/[0.05]"
|
|
@@ -1024,7 +1024,7 @@ export default function Home() {
|
|
|
1024
1024
|
docs
|
|
1025
1025
|
</Link>
|
|
1026
1026
|
<a
|
|
1027
|
-
href="https://github.com/
|
|
1027
|
+
href="https://github.com/agent-messenger/agent-messenger"
|
|
1028
1028
|
target="_blank"
|
|
1029
1029
|
rel="noopener noreferrer"
|
|
1030
1030
|
className="transition-colors duration-300 hover:text-zinc-700 dark:hover:text-zinc-300"
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agent-messenger",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.4.0",
|
|
4
4
|
"description": "Multi-platform messaging CLI for AI agents (Slack, Discord, Teams, Webex, Telegram, WhatsApp, LINE, Instagram, KakaoTalk, Channel Talk)",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
|
-
"url": "https://github.com/
|
|
7
|
+
"url": "https://github.com/agent-messenger/agent-messenger"
|
|
8
8
|
},
|
|
9
9
|
"bin": {
|
|
10
10
|
"agent-messenger": "dist/src/cli.js",
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
"agent-whatsapp": "dist/src/platforms/whatsapp/cli.js",
|
|
20
20
|
"agent-whatsappbot": "dist/src/platforms/whatsappbot/cli.js",
|
|
21
21
|
"agent-line": "dist/src/platforms/line/cli.js",
|
|
22
|
+
"agent-wechatbot": "dist/src/platforms/wechatbot/cli.js",
|
|
22
23
|
"agent-instagram": "dist/src/platforms/instagram/cli.js",
|
|
23
24
|
"agent-kakaotalk": "dist/src/platforms/kakaotalk/cli.js",
|
|
24
25
|
"agent-channeltalk": "dist/src/platforms/channeltalk/cli.js",
|
|
@@ -58,6 +59,10 @@
|
|
|
58
59
|
"types": "./dist/src/platforms/line/index.d.ts",
|
|
59
60
|
"default": "./dist/src/platforms/line/index.js"
|
|
60
61
|
},
|
|
62
|
+
"./wechatbot": {
|
|
63
|
+
"types": "./dist/src/platforms/wechatbot/index.d.ts",
|
|
64
|
+
"default": "./dist/src/platforms/wechatbot/index.js"
|
|
65
|
+
},
|
|
61
66
|
"./instagram": {
|
|
62
67
|
"types": "./dist/src/platforms/instagram/index.d.ts",
|
|
63
68
|
"default": "./dist/src/platforms/instagram/index.js"
|
|
@@ -101,6 +106,9 @@
|
|
|
101
106
|
"line": [
|
|
102
107
|
"./dist/src/platforms/line/index.d.ts"
|
|
103
108
|
],
|
|
109
|
+
"wechatbot": [
|
|
110
|
+
"./dist/src/platforms/wechatbot/index.d.ts"
|
|
111
|
+
],
|
|
104
112
|
"instagram": [
|
|
105
113
|
"./dist/src/platforms/instagram/index.d.ts"
|
|
106
114
|
],
|
|
@@ -129,7 +137,7 @@
|
|
|
129
137
|
"postpublish": "git checkout package.json"
|
|
130
138
|
},
|
|
131
139
|
"dependencies": {
|
|
132
|
-
"@evex/linejs": "npm
|
|
140
|
+
"@evex/linejs": "https://npm.jsr.io/~/11/@jsr/evex__linejs/2.3.7.tgz",
|
|
133
141
|
"@hapi/boom": "^10.0.1",
|
|
134
142
|
"@slack/web-api": "^6.9.0",
|
|
135
143
|
"@whiskeysockets/baileys": "^7.0.0-rc.9",
|
|
@@ -138,6 +146,7 @@
|
|
|
138
146
|
"bson": "^7.2.0",
|
|
139
147
|
"classic-level": "^3.0.0",
|
|
140
148
|
"commander": "^11.1.0",
|
|
149
|
+
"node-jose": "^2.2.0",
|
|
141
150
|
"pino": "^10.3.1",
|
|
142
151
|
"qrcode": "^1.5.4",
|
|
143
152
|
"ws": "^8.19.0",
|
|
@@ -153,6 +162,7 @@
|
|
|
153
162
|
"@types/bun": "latest",
|
|
154
163
|
"@types/hapi__boom": "^9.0.1",
|
|
155
164
|
"@types/node": "^20.10.6",
|
|
165
|
+
"@types/node-jose": "^1.1.13",
|
|
156
166
|
"@types/qrcode": "^1.5.6",
|
|
157
167
|
"@types/ws": "^8.18.1",
|
|
158
168
|
"oxfmt": "^0.36.0",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: agent-channeltalk
|
|
3
3
|
description: Interact with Channel Talk using extracted desktop app or browser credentials - read chats, send messages, search messages, manage groups
|
|
4
|
-
version: 2.
|
|
4
|
+
version: 2.4.0
|
|
5
5
|
allowed-tools: Bash(agent-channeltalk:*)
|
|
6
6
|
metadata:
|
|
7
7
|
openclaw:
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: agent-kakaotalk
|
|
3
3
|
description: Interact with KakaoTalk - send messages, read chats, manage conversations
|
|
4
|
-
version: 2.
|
|
4
|
+
version: 2.4.0
|
|
5
5
|
allowed-tools: Bash(agent-kakaotalk:*)
|
|
6
6
|
metadata:
|
|
7
7
|
openclaw:
|
|
@@ -46,6 +46,9 @@ agent-kakaotalk message send <chat-id> "Hello from AI agent!"
|
|
|
46
46
|
|
|
47
47
|
# List messages in a chat
|
|
48
48
|
agent-kakaotalk message list <chat-id>
|
|
49
|
+
|
|
50
|
+
# Show your profile
|
|
51
|
+
agent-kakaotalk profile
|
|
49
52
|
```
|
|
50
53
|
|
|
51
54
|
## Authentication
|
|
@@ -285,6 +288,23 @@ agent-kakaotalk auth status --account <account-id>
|
|
|
285
288
|
agent-kakaotalk auth logout --account <account-id>
|
|
286
289
|
```
|
|
287
290
|
|
|
291
|
+
### Profile Command
|
|
292
|
+
|
|
293
|
+
```bash
|
|
294
|
+
# Show your KakaoTalk profile
|
|
295
|
+
agent-kakaotalk profile
|
|
296
|
+
agent-kakaotalk profile --pretty
|
|
297
|
+
agent-kakaotalk profile --account <account-id>
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
Output includes:
|
|
301
|
+
- `user_id` — your KakaoTalk user ID
|
|
302
|
+
- `nickname` — your display name
|
|
303
|
+
- `profile_image_url` — profile image thumbnail URL
|
|
304
|
+
- `original_profile_image_url` — original profile image URL
|
|
305
|
+
- `status_message` — your status message
|
|
306
|
+
- `account_display_id` — your KakaoTalk ID (may be null if not set)
|
|
307
|
+
|
|
288
308
|
### Chat Commands
|
|
289
309
|
|
|
290
310
|
```bash
|
|
@@ -468,6 +488,9 @@ const client = await new KakaoTalkClient().login({ oauthToken: account.oauth_tok
|
|
|
468
488
|
|
|
469
489
|
```typescript
|
|
470
490
|
try {
|
|
491
|
+
// Get your profile
|
|
492
|
+
const profile = await client.getProfile()
|
|
493
|
+
|
|
471
494
|
// List chats
|
|
472
495
|
const chats = await client.getChats()
|
|
473
496
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: agent-line
|
|
3
3
|
description: Interact with LINE - send messages, read chats, manage conversations
|
|
4
|
-
version: 2.
|
|
4
|
+
version: 2.4.0
|
|
5
5
|
allowed-tools: Bash(agent-line:*)
|
|
6
6
|
metadata:
|
|
7
7
|
openclaw:
|
|
@@ -117,18 +117,14 @@ agent-line auth login
|
|
|
117
117
|
|
|
118
118
|
Possible responses:
|
|
119
119
|
|
|
120
|
-
- `{"authenticated": true, ...}`
|
|
121
|
-
- `{"next_action": "
|
|
122
|
-
- `{"error": "not_connected", ...}`
|
|
123
|
-
- `{"error": "not_authenticated", ...}`
|
|
120
|
+
- `{"authenticated": true, ...}` → Success. Retry original command.
|
|
121
|
+
- `{"next_action": "scan_qr", "qr_url": "...", "qr_html_path": "/tmp/line-qr-xxx.html", ...}` → QR code has been generated. The CLI attempts to open it in the user's browser automatically. If it didn't open, run `open <qr_html_path>` (macOS) to show the QR code. Tell the user to scan the QR code with the LINE mobile app. The command blocks until the user scans — once scanned, it outputs `{"authenticated": true, ...}`.
|
|
122
|
+
- `{"error": "not_connected", ...}` → Network issue. Check connectivity and retry.
|
|
123
|
+
- `{"error": "not_authenticated", ...}` → Credentials expired. Re-run `auth login`.
|
|
124
124
|
|
|
125
|
-
**Important**: QR login
|
|
125
|
+
**Important**: QR login works in both interactive and non-interactive (agent) sessions. The CLI generates an HTML page with the QR code and opens it in the user's default browser. No TTY is required.
|
|
126
126
|
|
|
127
|
-
**Step 3:
|
|
128
|
-
|
|
129
|
-
Tell the user: "Please run `agent-line auth login` in your terminal and scan the QR code with your LINE app." Then periodically check `agent-line auth status` until credentials appear.
|
|
130
|
-
|
|
131
|
-
**Step 4: Retry the original command**
|
|
127
|
+
**Step 3: Retry the original command**
|
|
132
128
|
|
|
133
129
|
After successful auth, immediately execute whatever the user originally asked for.
|
|
134
130
|
|
|
@@ -33,16 +33,25 @@ The CLI opens the QR code in your default browser and prints an ASCII version in
|
|
|
33
33
|
|
|
34
34
|
### Non-Interactive Mode (AI Agents)
|
|
35
35
|
|
|
36
|
-
QR code login
|
|
36
|
+
QR code login works in both interactive and non-interactive sessions. In non-interactive mode (e.g., AI agent), the CLI:
|
|
37
|
+
|
|
38
|
+
1. Generates an HTML page with the QR code
|
|
39
|
+
2. Attempts to open it in the user's default browser
|
|
40
|
+
3. Outputs the QR URL and HTML file path to stdout:
|
|
37
41
|
|
|
38
42
|
```json
|
|
39
43
|
{
|
|
40
|
-
"next_action": "
|
|
41
|
-
"
|
|
44
|
+
"next_action": "scan_qr",
|
|
45
|
+
"qr_url": "https://line.me/R/au/q/...",
|
|
46
|
+
"qr_html_path": "/tmp/line-qr-1234567890.html",
|
|
47
|
+
"message": "QR code opened in browser. Scan with LINE mobile app to complete login."
|
|
42
48
|
}
|
|
43
49
|
```
|
|
44
50
|
|
|
45
|
-
|
|
51
|
+
4. Blocks until the user scans the QR code with the LINE mobile app
|
|
52
|
+
5. Outputs the final authentication result
|
|
53
|
+
|
|
54
|
+
If the browser did not open automatically, the agent can open the HTML file manually (e.g., `open <qr_html_path>` on macOS).
|
|
46
55
|
|
|
47
56
|
## Method 2: Email/Password Login
|
|
48
57
|
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
agent-webex supports four authentication methods against the Webex REST API (`https://webexapis.com/v1`):
|
|
6
6
|
|
|
7
|
-
1. **Browser Token Extraction**: Extracts your first-party token from a Chromium browser where you're logged into web.webex.com.
|
|
7
|
+
1. **Browser Token Extraction**: Extracts your first-party token and cached encryption keys from a Chromium browser where you're logged into web.webex.com. Supports all operations including encrypted messaging via the internal API. Zero-config.
|
|
8
8
|
2. **OAuth Device Grant** (recommended for messaging): Zero-config. Run `auth login`, approve in browser, done. Tokens refresh automatically. Supports all operations including sending messages (shows "via agent-messenger").
|
|
9
9
|
3. **Bot Token**: Pass via `auth login --token`. Never expires. Best for CI/CD.
|
|
10
10
|
4. **Personal Access Token (PAT)**: Pass via `auth login --token`. Expires in 12 hours. For quick testing.
|
|
@@ -13,12 +13,13 @@ agent-webex supports four authentication methods against the Webex REST API (`ht
|
|
|
13
13
|
|
|
14
14
|
### Browser Token Extraction
|
|
15
15
|
|
|
16
|
-
Extracts your first-party Webex session token from a Chromium-based browser where you're logged into web.webex.com.
|
|
16
|
+
Extracts your first-party Webex session token from a Chromium-based browser where you're logged into web.webex.com. Supports full messaging with end-to-end encryption. The extracted token uses Webex's internal conversation API for sending messages. Encryption keys are also extracted from the browser's cached KMS key store, enabling client-side JWE encryption so messages appear as encrypted in the Webex client.
|
|
17
17
|
|
|
18
|
-
- **How it works**: Run `agent-webex auth extract`. The CLI scans Chromium browser profiles for Webex localStorage data (LevelDB files). It finds the `webex-storage` key containing `Credentials.@.supertoken` and extracts the access token. No browser automation, no password prompts.
|
|
18
|
+
- **How it works**: Run `agent-webex auth extract`. The CLI scans Chromium browser profiles for Webex localStorage data (LevelDB files). It finds the `webex-storage` key containing `Credentials.@.supertoken` and extracts the access token. It also extracts `userId` from the Device namespace and cached KMS encryption keys from the unbounded storage — these keys enable end-to-end encrypted messaging via the internal API. No browser automation, no password prompts.
|
|
19
19
|
- **Supported browsers**: Chrome, Chrome Canary, Edge, Arc, Brave, Vivaldi, Chromium
|
|
20
20
|
- **Token lifetime**: Depends on Webex session policy (typically hours to days). Re-extract when expired.
|
|
21
21
|
- **Auto-extraction**: The CLI attempts browser extraction automatically when no valid token is stored, so you often don't need to run `auth extract` manually.
|
|
22
|
+
- **End-to-end encryption**: When encryption keys are found in the browser's cache, messages are encrypted client-side (JWE with AES-256-GCM) before sending via the internal conversation API. This ensures messages appear as encrypted in the Webex client. If no keys are found (e.g., the conversation hasn't been opened in the browser), messages fall back to plaintext.
|
|
22
23
|
- **Best for**: Interactive use, sending messages as yourself without the "via" label
|
|
23
24
|
|
|
24
25
|
```bash
|
|
@@ -28,7 +28,7 @@ agent-webex auth login --token "YOUR_BOT_TOKEN_HERE"
|
|
|
28
28
|
agent-webex auth login --token "YOUR_PAT_HERE"
|
|
29
29
|
```
|
|
30
30
|
|
|
31
|
-
**When to use**: Before any other command, if not already authenticated. Browser extraction is preferred — it auto-runs when no valid token is stored.
|
|
31
|
+
**When to use**: Before any other command, if not already authenticated. Browser extraction is preferred — it auto-runs when no valid token is stored. It also extracts cached KMS encryption keys from the browser, enabling end-to-end encrypted messaging via the internal API.
|
|
32
32
|
|
|
33
33
|
### Pattern 2: Check Auth Status
|
|
34
34
|
|