agent-messenger 2.20.5 → 2.22.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.
Files changed (137) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/README.md +8 -5
  3. package/dist/package.json +9 -1
  4. package/dist/src/cli.d.ts.map +1 -1
  5. package/dist/src/cli.js +3 -0
  6. package/dist/src/cli.js.map +1 -1
  7. package/dist/src/platforms/webex/client.d.ts +19 -0
  8. package/dist/src/platforms/webex/client.d.ts.map +1 -1
  9. package/dist/src/platforms/webex/client.js +81 -1
  10. package/dist/src/platforms/webex/client.js.map +1 -1
  11. package/dist/src/platforms/webexbot/cli.d.ts +5 -0
  12. package/dist/src/platforms/webexbot/cli.d.ts.map +1 -0
  13. package/dist/src/platforms/webexbot/cli.js +33 -0
  14. package/dist/src/platforms/webexbot/cli.js.map +1 -0
  15. package/dist/src/platforms/webexbot/client.d.ts +61 -0
  16. package/dist/src/platforms/webexbot/client.d.ts.map +1 -0
  17. package/dist/src/platforms/webexbot/client.js +80 -0
  18. package/dist/src/platforms/webexbot/client.js.map +1 -0
  19. package/dist/src/platforms/webexbot/commands/auth.d.ts +28 -0
  20. package/dist/src/platforms/webexbot/commands/auth.d.ts.map +1 -0
  21. package/dist/src/platforms/webexbot/commands/auth.js +166 -0
  22. package/dist/src/platforms/webexbot/commands/auth.js.map +1 -0
  23. package/dist/src/platforms/webexbot/commands/file.d.ts +22 -0
  24. package/dist/src/platforms/webexbot/commands/file.d.ts.map +1 -0
  25. package/dist/src/platforms/webexbot/commands/file.js +64 -0
  26. package/dist/src/platforms/webexbot/commands/file.js.map +1 -0
  27. package/dist/src/platforms/webexbot/commands/index.d.ts +10 -0
  28. package/dist/src/platforms/webexbot/commands/index.d.ts.map +1 -0
  29. package/dist/src/platforms/webexbot/commands/index.js +10 -0
  30. package/dist/src/platforms/webexbot/commands/index.js.map +1 -0
  31. package/dist/src/platforms/webexbot/commands/listen.d.ts +12 -0
  32. package/dist/src/platforms/webexbot/commands/listen.d.ts.map +1 -0
  33. package/dist/src/platforms/webexbot/commands/listen.js +85 -0
  34. package/dist/src/platforms/webexbot/commands/listen.js.map +1 -0
  35. package/dist/src/platforms/webexbot/commands/member.d.ts +19 -0
  36. package/dist/src/platforms/webexbot/commands/member.d.ts.map +1 -0
  37. package/dist/src/platforms/webexbot/commands/member.js +33 -0
  38. package/dist/src/platforms/webexbot/commands/member.js.map +1 -0
  39. package/dist/src/platforms/webexbot/commands/message.d.ts +44 -0
  40. package/dist/src/platforms/webexbot/commands/message.d.ts.map +1 -0
  41. package/dist/src/platforms/webexbot/commands/message.js +193 -0
  42. package/dist/src/platforms/webexbot/commands/message.js.map +1 -0
  43. package/dist/src/platforms/webexbot/commands/shared.d.ts +9 -0
  44. package/dist/src/platforms/webexbot/commands/shared.d.ts.map +1 -0
  45. package/dist/src/platforms/webexbot/commands/shared.js +13 -0
  46. package/dist/src/platforms/webexbot/commands/shared.js.map +1 -0
  47. package/dist/src/platforms/webexbot/commands/snapshot.d.ts +24 -0
  48. package/dist/src/platforms/webexbot/commands/snapshot.d.ts.map +1 -0
  49. package/dist/src/platforms/webexbot/commands/snapshot.js +37 -0
  50. package/dist/src/platforms/webexbot/commands/snapshot.js.map +1 -0
  51. package/dist/src/platforms/webexbot/commands/space.d.ts +28 -0
  52. package/dist/src/platforms/webexbot/commands/space.d.ts.map +1 -0
  53. package/dist/src/platforms/webexbot/commands/space.js +61 -0
  54. package/dist/src/platforms/webexbot/commands/space.js.map +1 -0
  55. package/dist/src/platforms/webexbot/commands/user.d.ts +30 -0
  56. package/dist/src/platforms/webexbot/commands/user.d.ts.map +1 -0
  57. package/dist/src/platforms/webexbot/commands/user.js +66 -0
  58. package/dist/src/platforms/webexbot/commands/user.js.map +1 -0
  59. package/dist/src/platforms/webexbot/commands/whoami.d.ts +16 -0
  60. package/dist/src/platforms/webexbot/commands/whoami.d.ts.map +1 -0
  61. package/dist/src/platforms/webexbot/commands/whoami.js +29 -0
  62. package/dist/src/platforms/webexbot/commands/whoami.js.map +1 -0
  63. package/dist/src/platforms/webexbot/credential-manager.d.ts +17 -0
  64. package/dist/src/platforms/webexbot/credential-manager.d.ts.map +1 -0
  65. package/dist/src/platforms/webexbot/credential-manager.js +120 -0
  66. package/dist/src/platforms/webexbot/credential-manager.js.map +1 -0
  67. package/dist/src/platforms/webexbot/index.d.ts +9 -0
  68. package/dist/src/platforms/webexbot/index.d.ts.map +1 -0
  69. package/dist/src/platforms/webexbot/index.js +6 -0
  70. package/dist/src/platforms/webexbot/index.js.map +1 -0
  71. package/dist/src/platforms/webexbot/listener.d.ts +44 -0
  72. package/dist/src/platforms/webexbot/listener.d.ts.map +1 -0
  73. package/dist/src/platforms/webexbot/listener.js +214 -0
  74. package/dist/src/platforms/webexbot/listener.js.map +1 -0
  75. package/dist/src/platforms/webexbot/types.d.ts +60 -0
  76. package/dist/src/platforms/webexbot/types.d.ts.map +1 -0
  77. package/dist/src/platforms/webexbot/types.js +28 -0
  78. package/dist/src/platforms/webexbot/types.js.map +1 -0
  79. package/dist/src/platforms/webexbot/wdm-discovery.d.ts +4 -0
  80. package/dist/src/platforms/webexbot/wdm-discovery.d.ts.map +1 -0
  81. package/dist/src/platforms/webexbot/wdm-discovery.js +36 -0
  82. package/dist/src/platforms/webexbot/wdm-discovery.js.map +1 -0
  83. package/docs/content/docs/cli/meta.json +1 -0
  84. package/docs/content/docs/cli/webexbot.mdx +292 -0
  85. package/docs/content/docs/sdk/meta.json +1 -0
  86. package/docs/content/docs/sdk/webexbot.mdx +342 -0
  87. package/docs/src/app/page.tsx +115 -19
  88. package/package.json +9 -1
  89. package/skills/agent-channeltalk/SKILL.md +1 -1
  90. package/skills/agent-channeltalkbot/SKILL.md +1 -1
  91. package/skills/agent-discord/SKILL.md +1 -1
  92. package/skills/agent-discordbot/SKILL.md +1 -1
  93. package/skills/agent-instagram/SKILL.md +1 -1
  94. package/skills/agent-kakaotalk/SKILL.md +1 -1
  95. package/skills/agent-line/SKILL.md +1 -1
  96. package/skills/agent-slack/SKILL.md +1 -1
  97. package/skills/agent-slackbot/SKILL.md +1 -1
  98. package/skills/agent-teams/SKILL.md +1 -1
  99. package/skills/agent-telegram/SKILL.md +1 -1
  100. package/skills/agent-telegrambot/SKILL.md +1 -1
  101. package/skills/agent-webex/SKILL.md +1 -1
  102. package/skills/agent-webexbot/SKILL.md +414 -0
  103. package/skills/agent-webexbot/references/authentication.md +225 -0
  104. package/skills/agent-webexbot/references/common-patterns.md +708 -0
  105. package/skills/agent-wechatbot/SKILL.md +1 -1
  106. package/skills/agent-whatsapp/SKILL.md +1 -1
  107. package/skills/agent-whatsappbot/SKILL.md +1 -1
  108. package/src/cli.ts +4 -0
  109. package/src/platforms/webex/client.test.ts +10 -0
  110. package/src/platforms/webex/client.ts +97 -3
  111. package/src/platforms/webex/typings/webex-message-handler.d.ts +360 -29
  112. package/src/platforms/webexbot/cli.ts +48 -0
  113. package/src/platforms/webexbot/client.test.ts +198 -0
  114. package/src/platforms/webexbot/client.ts +113 -0
  115. package/src/platforms/webexbot/commands/auth.test.ts +185 -0
  116. package/src/platforms/webexbot/commands/auth.ts +210 -0
  117. package/src/platforms/webexbot/commands/file.ts +104 -0
  118. package/src/platforms/webexbot/commands/index.ts +9 -0
  119. package/src/platforms/webexbot/commands/listen.test.ts +20 -0
  120. package/src/platforms/webexbot/commands/listen.ts +104 -0
  121. package/src/platforms/webexbot/commands/member.ts +51 -0
  122. package/src/platforms/webexbot/commands/message.ts +263 -0
  123. package/src/platforms/webexbot/commands/shared.ts +22 -0
  124. package/src/platforms/webexbot/commands/snapshot.ts +60 -0
  125. package/src/platforms/webexbot/commands/space.ts +88 -0
  126. package/src/platforms/webexbot/commands/user.test.ts +77 -0
  127. package/src/platforms/webexbot/commands/user.ts +98 -0
  128. package/src/platforms/webexbot/commands/whoami.ts +43 -0
  129. package/src/platforms/webexbot/credential-manager.test.ts +182 -0
  130. package/src/platforms/webexbot/credential-manager.ts +149 -0
  131. package/src/platforms/webexbot/index.ts +8 -0
  132. package/src/platforms/webexbot/listener.test.ts +234 -0
  133. package/src/platforms/webexbot/listener.ts +255 -0
  134. package/src/platforms/webexbot/types.test.ts +87 -0
  135. package/src/platforms/webexbot/types.ts +72 -0
  136. package/src/platforms/webexbot/wdm-discovery.test.ts +97 -0
  137. package/src/platforms/webexbot/wdm-discovery.ts +43 -0
@@ -0,0 +1,414 @@
1
+ ---
2
+ name: agent-webexbot
3
+ description: Interact with Cisco Webex using bot tokens - send messages, reply in threads, upload and download files, look up people, read spaces, manage memberships, stream real-time events
4
+ version: 2.22.0
5
+ allowed-tools: Bash(agent-webexbot:*)
6
+ metadata:
7
+ openclaw:
8
+ requires:
9
+ bins:
10
+ - agent-webexbot
11
+ install:
12
+ - kind: node
13
+ package: agent-messenger
14
+ bins: [agent-webexbot]
15
+ ---
16
+
17
+ # Agent WebexBot
18
+
19
+ A TypeScript CLI tool that enables AI agents and humans to interact with Cisco Webex using **bot tokens** (created at [developer.webex.com](https://developer.webex.com/my-apps/new/bot)). Unlike `agent-webex` which authenticates as a real user account via browser extraction or OAuth, `agent-webexbot` uses the Webex REST API with a permanent bot identity — designed for server-side and CI/CD integrations.
20
+
21
+ ## Key Concepts
22
+
23
+ Before diving in, a few things about Webex Bot integration:
24
+
25
+ - **Bot tokens** — Created at developer.webex.com → My Webex Apps → Create a Bot. The token is shown once at creation time. Bot tokens never expire.
26
+ - **Bot ≠ User** — Messages appear from the bot's identity, not yours. The bot can only interact with spaces it has been added to.
27
+ - **Space IDs** — Webex uses opaque Base64-encoded IDs. You can't guess them. Always get IDs from `space list` first.
28
+ - **Real-time events** — Available via the `listen` command and the SDK's `WebexBotListener`. Uses the Mercury WebSocket protocol — no public URL required, works behind firewalls.
29
+ - **Loop prevention** — The listener filters the bot's own messages by default (`ignoreSelfMessages` is `true`), preventing echo loops.
30
+
31
+ ## Quick Start
32
+
33
+ ```bash
34
+ # Set your bot token (validates against Webex)
35
+ agent-webexbot auth set YOUR_BOT_TOKEN
36
+
37
+ # Verify authentication
38
+ agent-webexbot whoami
39
+
40
+ # Send a message
41
+ agent-webexbot message send <space-id> "Hello from the bot!"
42
+
43
+ # Stream real-time events
44
+ agent-webexbot listen
45
+ ```
46
+
47
+ ## Authentication
48
+
49
+ ### Bot Token Setup
50
+
51
+ `agent-webexbot` uses bot tokens which you create at [developer.webex.com](https://developer.webex.com/my-apps/new/bot):
52
+
53
+ ```bash
54
+ # Set bot token (validates against Webex API before saving)
55
+ agent-webexbot auth set YOUR_BOT_TOKEN
56
+
57
+ # Set with a custom bot identifier
58
+ agent-webexbot auth set YOUR_BOT_TOKEN --bot deploy
59
+
60
+ # Check auth status
61
+ agent-webexbot auth status
62
+
63
+ # Clear all credentials
64
+ agent-webexbot auth clear
65
+ ```
66
+
67
+ ### Multi-Bot Support
68
+
69
+ ```bash
70
+ # List all configured bots
71
+ agent-webexbot auth list
72
+
73
+ # Switch active bot
74
+ agent-webexbot auth use <bot-id>
75
+
76
+ # Remove a bot
77
+ agent-webexbot auth remove <bot-id>
78
+
79
+ # Use a specific bot for a single command
80
+ agent-webexbot --bot deploy message send <space-id> "Deploy succeeded"
81
+ ```
82
+
83
+ ## Memory
84
+
85
+ The agent maintains a `~/.config/agent-messenger/MEMORY.md` file as persistent memory across sessions. This is agent-managed — the CLI does not read or write this file. Use the `Read` and `Write` tools to manage your memory file.
86
+
87
+ ### What to Store
88
+
89
+ - Space IDs with titles (e.g. `Y2lzY29zcGFyazovL...` → "Engineering")
90
+ - Bot identifiers and their purposes
91
+ - User-given aliases ("the alerts bot", "the team space")
92
+
93
+ ### What NOT to Store
94
+
95
+ Never store bot tokens, credentials, or any sensitive data. Never store full message content (just IDs and space context).
96
+
97
+ ### Format / Example
98
+
99
+ ```markdown
100
+ # Agent Messenger Memory
101
+
102
+ ## Webex Bots
103
+
104
+ - `deploy` — Deploy Bot (active)
105
+ - `alert` — Alert Bot
106
+
107
+ ## Spaces (Deploy Bot)
108
+
109
+ - `Y2lzY29zcGFyazovL...` — Engineering (group)
110
+ - `Y2lzY29zcGFyazovL...` — #ci-alerts (group)
111
+
112
+ ## Aliases
113
+
114
+ - "engineering" → `Y2lzY29zcGFyazovL...`
115
+ - "alerts" → `Y2lzY29zcGFyazovL...`
116
+ ```
117
+
118
+ ## Commands
119
+
120
+ ### Auth Commands
121
+
122
+ ```bash
123
+ # Set bot token
124
+ agent-webexbot auth set <token>
125
+ agent-webexbot auth set <token> --bot deploy
126
+
127
+ # Check auth status
128
+ agent-webexbot auth status
129
+ agent-webexbot auth status --bot deploy
130
+
131
+ # Clear all credentials
132
+ agent-webexbot auth clear
133
+
134
+ # List stored bots
135
+ agent-webexbot auth list
136
+
137
+ # Switch active bot
138
+ agent-webexbot auth use <bot-id>
139
+
140
+ # Remove a stored bot
141
+ agent-webexbot auth remove <bot-id>
142
+ ```
143
+
144
+ ### Whoami Command
145
+
146
+ ```bash
147
+ # Show current authenticated bot
148
+ agent-webexbot whoami
149
+ agent-webexbot whoami --pretty
150
+ ```
151
+
152
+ ### Space Commands
153
+
154
+ ```bash
155
+ # List spaces the bot is a member of
156
+ agent-webexbot space list
157
+ agent-webexbot space list --type group
158
+ agent-webexbot space list --type direct
159
+ agent-webexbot space list --max 20
160
+
161
+ # Get space details
162
+ agent-webexbot space info <space-id>
163
+ ```
164
+
165
+ ### Message Commands
166
+
167
+ ```bash
168
+ # Send a message to a space
169
+ agent-webexbot message send <space-id> <text>
170
+ agent-webexbot message send <space-id> "Hello world"
171
+
172
+ # Send a markdown message
173
+ agent-webexbot message send <space-id> "**Bold** and _italic_" --markdown
174
+
175
+ # Reply within a thread (parent message ID)
176
+ agent-webexbot message send <space-id> "Threaded reply" --parent <message-id>
177
+ agent-webexbot message reply <space-id> <parent-message-id> "Threaded reply"
178
+
179
+ # List replies in a thread
180
+ agent-webexbot message replies <space-id> <parent-message-id>
181
+ agent-webexbot message replies <space-id> <parent-message-id> --max 20
182
+
183
+ # Send a direct message by email
184
+ agent-webexbot message dm alice@example.com "Hey, quick question"
185
+ agent-webexbot message dm alice@example.com "**Build failed**" --markdown
186
+
187
+ # List messages in a space
188
+ # In group spaces, Webex only returns messages that mention the bot.
189
+ # Direct-space history is returned normally.
190
+ agent-webexbot message list <space-id>
191
+ agent-webexbot message list <space-id> --max 50
192
+
193
+ # Get a specific message
194
+ agent-webexbot message get <message-id>
195
+
196
+ # Edit a message (bot's own messages only)
197
+ agent-webexbot message edit <message-id> <space-id> "Updated text"
198
+ agent-webexbot message edit <message-id> <space-id> "**Updated**" --markdown
199
+
200
+ # Delete a message
201
+ agent-webexbot message delete <message-id>
202
+ ```
203
+
204
+ ### Member Commands
205
+
206
+ ```bash
207
+ # List members of a space
208
+ agent-webexbot member list <space-id>
209
+ agent-webexbot member list <space-id> --max 100
210
+ ```
211
+
212
+ ### User Commands
213
+
214
+ Search the Webex people directory and look up person details.
215
+
216
+ ```bash
217
+ # Search people by email (exact) or display name (prefix)
218
+ agent-webexbot user list --email alice@example.com
219
+ agent-webexbot user list --display-name "Alice"
220
+ agent-webexbot user list --display-name "Al" --max 20
221
+
222
+ # Get details for a specific person
223
+ agent-webexbot user info <person-id>
224
+ ```
225
+
226
+ ### File Commands
227
+
228
+ Upload local files to a space and download attachments. Max file size is 100 MB; one file per message.
229
+
230
+ ```bash
231
+ # Upload a local file
232
+ agent-webexbot file upload <space-id> ./report.pdf
233
+ agent-webexbot file upload <space-id> ./report.pdf --text "Latest report"
234
+ agent-webexbot file upload <space-id> ./report.pdf --text "**Done**" --markdown
235
+
236
+ # Upload a file as a threaded reply
237
+ agent-webexbot file upload <space-id> ./report.pdf --parent <message-id>
238
+
239
+ # Download an attachment (content URL comes from a message's "files" array)
240
+ agent-webexbot file download <content-url-or-id>
241
+ agent-webexbot file download <content-url-or-id> ./downloaded-report.pdf
242
+ ```
243
+
244
+ ### Snapshot Command
245
+
246
+ Get a workspace overview for AI agents.
247
+
248
+ ```bash
249
+ # Brief snapshot (bot identity + space IDs/titles)
250
+ agent-webexbot snapshot
251
+
252
+ # Full snapshot (includes space type and last activity)
253
+ agent-webexbot snapshot --full
254
+ agent-webexbot snapshot --full --max 50
255
+ ```
256
+
257
+ ### Listen Command
258
+
259
+ Stream real-time Webex events over the Mercury WebSocket. No public URL required.
260
+
261
+ ```bash
262
+ # Listen for all default events (NDJSON output)
263
+ agent-webexbot listen
264
+
265
+ # Filter to specific events
266
+ agent-webexbot listen --events message_created,membership_created
267
+
268
+ # Pretty-print each event
269
+ agent-webexbot listen --pretty
270
+
271
+ # Use a specific bot
272
+ agent-webexbot listen --bot deploy
273
+ ```
274
+
275
+ Supported events: `message_created`, `message_updated`, `message_deleted`, `membership_created`, `attachment_action`, `room_created`, `room_updated`, `webex_event`, `connected`, `reconnecting`, `disconnected`, `error`.
276
+
277
+ Output is NDJSON — one JSON object per line:
278
+
279
+ ```json
280
+ {"type":"connected","payload":{"connected":true,"status":"connected"}}
281
+ {"type":"message_created","payload":{"id":"Y2lz...","text":"Hello bot!","personEmail":"alice@example.com","roomId":"Y2lz..."}}
282
+ ```
283
+
284
+ ## Output Format
285
+
286
+ ### JSON (Default)
287
+
288
+ All commands output JSON by default for AI consumption:
289
+
290
+ ```json
291
+ {
292
+ "id": "Y2lzY29zcGFyazovL...",
293
+ "text": "Hello world",
294
+ "personEmail": "bot@webex.bot",
295
+ "created": "2024-01-15T10:30:00.000Z"
296
+ }
297
+ ```
298
+
299
+ ### Pretty (Human-Readable)
300
+
301
+ Use `--pretty` flag for formatted output:
302
+
303
+ ```bash
304
+ agent-webexbot space list --pretty
305
+ ```
306
+
307
+ ## Global Options
308
+
309
+ | Option | Description |
310
+ | ------------ | -------------------------------------- |
311
+ | `--pretty` | Human-readable output instead of JSON |
312
+ | `--bot <id>` | Use a specific bot for this command |
313
+
314
+ ## Real-Time Events
315
+
316
+ Real-time events are available via both the CLI (`listen` command) and the SDK (`WebexBotListener`). The listener uses the Mercury WebSocket protocol — the same transport Webex clients use internally. No public HTTPS endpoint is required.
317
+
318
+ ```typescript
319
+ import { WebexBotClient, WebexBotListener } from 'agent-messenger/webexbot'
320
+
321
+ const client = await new WebexBotClient().login({ token: 'YOUR_BOT_TOKEN' })
322
+ const listener = new WebexBotListener(client)
323
+
324
+ listener.on('message_created', (event) => {
325
+ console.log(`From ${event.personEmail} in ${event.roomId}: ${event.text}`)
326
+ })
327
+
328
+ await listener.start()
329
+ ```
330
+
331
+ The Mercury WebSocket means the bot opens a persistent connection to Webex's infrastructure. No public endpoint is required — perfect for CI/CD and behind-NAT environments.
332
+
333
+ ## Error Handling
334
+
335
+ All commands return consistent error format:
336
+
337
+ ```json
338
+ {
339
+ "error": "No credentials configured. Run \"auth set <token>\" first."
340
+ }
341
+ ```
342
+
343
+ Common errors:
344
+
345
+ - `No credentials configured` — No bot token stored. Run `auth set <token>` first.
346
+ - `Token is not a bot token` — The token belongs to a user account. Use `agent-webex` for user tokens.
347
+ - `401 Unauthorized` — Token is invalid or the bot was deleted. Re-run `auth set <token>`.
348
+ - `429 Too Many Requests` — Rate limited. Webex allows ~600 requests per minute. Wait and retry.
349
+ - `404 Not Found` — Invalid space ID, message ID, or resource. The bot may not be a member of that space.
350
+
351
+ ## Configuration
352
+
353
+ Credentials stored in `~/.config/agent-messenger/webexbot-credentials.json` (0600 permissions). The location can be overridden with `AGENT_MESSENGER_CONFIG_DIR`.
354
+
355
+ ## Key Differences from agent-webex
356
+
357
+ | Feature | agent-webex (user) | agent-webexbot (bot) |
358
+ | -------------------- | ----------------------------------- | ----------------------------------- |
359
+ | Token type | Browser session / OAuth / PAT | Bot token (developer.webex.com) |
360
+ | Auth method | Browser extraction or Device Grant | `auth set <token>` (manual) |
361
+ | Token lifetime | Session-based or 14-day OAuth | Never expires |
362
+ | Messages appear as | You (your name) | Bot identity |
363
+ | Real-time events | No | Yes (Mercury WebSocket) |
364
+ | CI/CD friendly | Possible (bot token via `--token`) | Yes (designed for it) |
365
+
366
+ ## Limitations
367
+
368
+ - Bot can only interact with spaces it has been added to
369
+ - Bot can only edit/delete its own messages
370
+ - No reactions / emoji support — the Webex public REST API does not expose a reactions endpoint, and reaction events are not delivered to bot webhooks
371
+ - No message search
372
+ - No voice/video or meeting support
373
+ - No space management (create/delete spaces, roles)
374
+
375
+ ## Troubleshooting
376
+
377
+ ### `agent-webexbot: command not found`
378
+
379
+ **`agent-webexbot` is NOT the npm package name.** The npm package is `agent-messenger`.
380
+
381
+ If the package is installed globally, use `agent-webexbot` directly:
382
+
383
+ ```bash
384
+ agent-webexbot space list
385
+ ```
386
+
387
+ If the package is NOT installed, use `npx -y` by default:
388
+
389
+ ```bash
390
+ npx -y agent-messenger webexbot space list
391
+ bunx agent-messenger webexbot space list
392
+ pnpm dlx agent-messenger webexbot space list
393
+ ```
394
+
395
+ > If you already know the user's preferred package runner (e.g., `bunx`, `pnpm dlx`), use that instead.
396
+
397
+ **NEVER run `npx agent-webexbot`, `bunx agent-webexbot`, or `pnpm dlx agent-webexbot`** — it will fail or install a wrong package since `agent-webexbot` is not the npm package name.
398
+
399
+ ### "Token is not a bot token"
400
+
401
+ The token you provided belongs to a user account. Create a bot at [developer.webex.com](https://developer.webex.com/my-apps/new/bot) to get a proper bot token, or use `agent-webex` for user-level access.
402
+
403
+ ### "Bot not found in space"
404
+
405
+ The bot must be added to each space it needs to interact with. Invite the bot from the Webex app, then retry.
406
+
407
+ ### Rate limiting (429)
408
+
409
+ Webex allows roughly 600 API calls per minute. If you hit a 429, wait a few seconds and retry. For bulk operations, add a `sleep 1` between requests.
410
+
411
+ ## References
412
+
413
+ - [Authentication Guide](references/authentication.md)
414
+ - [Common Patterns](references/common-patterns.md)
@@ -0,0 +1,225 @@
1
+ # Authentication Guide
2
+
3
+ ## Overview
4
+
5
+ `agent-webexbot` uses **bot tokens** issued at [developer.webex.com](https://developer.webex.com/my-apps/new/bot). Unlike `agent-webex` which supports browser extraction and OAuth Device Grant, `agent-webexbot` uses a single, simple auth model: set a token once, and it works forever.
6
+
7
+ Bot tokens never expire. They're the right choice for CI/CD pipelines, long-running automations, and any server-side integration.
8
+
9
+ ## Creating a Bot Token
10
+
11
+ 1. Go to [developer.webex.com](https://developer.webex.com/my-apps/new/bot)
12
+ 2. Sign in with your Webex account
13
+ 3. Click **Create a New App** → **Create a Bot**
14
+ 4. Fill in the bot name, username, and icon
15
+ 5. Click **Add Bot**
16
+ 6. Copy the **Bot Access Token** shown on the confirmation page
17
+
18
+ The token is shown only once. Save it immediately. If you lose it, you can regenerate it from the bot's settings page — but the old token will be invalidated.
19
+
20
+ ## Setting Up Credentials
21
+
22
+ ```bash
23
+ # Set bot token (validates against Webex API before saving)
24
+ agent-webexbot auth set YOUR_BOT_TOKEN
25
+
26
+ # Set with a custom bot identifier for multi-bot setups
27
+ agent-webexbot auth set YOUR_BOT_TOKEN --bot deploy
28
+
29
+ # Check auth status
30
+ agent-webexbot auth status
31
+
32
+ # Clear all stored credentials
33
+ agent-webexbot auth clear
34
+ ```
35
+
36
+ When you run `auth set`, the CLI validates the token against the Webex API and confirms it's a bot token (not a user token). If validation fails, the token won't be stored.
37
+
38
+ ## Multi-Bot Support
39
+
40
+ You can store multiple bot tokens and switch between them:
41
+
42
+ ```bash
43
+ # Store multiple bots
44
+ agent-webexbot auth set TOKEN_A --bot deploy
45
+ agent-webexbot auth set TOKEN_B --bot alerts
46
+
47
+ # List all configured bots
48
+ agent-webexbot auth list
49
+
50
+ # Switch active bot
51
+ agent-webexbot auth use deploy
52
+
53
+ # Use a specific bot for a single command (without switching)
54
+ agent-webexbot --bot alerts message send <space-id> "Alert!"
55
+
56
+ # Remove a bot
57
+ agent-webexbot auth remove alerts
58
+ ```
59
+
60
+ The `--bot <id>` flag on any command overrides the active bot for that invocation only.
61
+
62
+ ## Checking Status
63
+
64
+ ```bash
65
+ agent-webexbot auth status
66
+ ```
67
+
68
+ Output when authenticated:
69
+
70
+ ```json
71
+ {
72
+ "valid": true,
73
+ "bot_id": "Y2lz...",
74
+ "bot_name": "Deploy Bot"
75
+ }
76
+ ```
77
+
78
+ Output when not authenticated:
79
+
80
+ ```json
81
+ {
82
+ "valid": false,
83
+ "error": "No credentials configured. Run \"auth set <token>\" first."
84
+ }
85
+ ```
86
+
87
+ ## Credential Storage
88
+
89
+ ### Location
90
+
91
+ ```
92
+ ~/.config/agent-messenger/webexbot-credentials.json
93
+ ```
94
+
95
+ Override with the `AGENT_MESSENGER_CONFIG_DIR` environment variable.
96
+
97
+ ### Format
98
+
99
+ ```json
100
+ {
101
+ "current": { "bot_id": "deploy" },
102
+ "bots": {
103
+ "deploy": {
104
+ "bot_id": "deploy",
105
+ "bot_name": "Deploy Bot",
106
+ "token": "YOUR_BOT_TOKEN"
107
+ }
108
+ }
109
+ }
110
+ ```
111
+
112
+ `bots` is keyed by `bot_id`, and the active bot is tracked by the top-level `current` field. `current` is `null` when no bot is selected.
113
+
114
+ ### Security
115
+
116
+ - File permissions: `0600` (owner read/write only)
117
+ - Credentials are stored in plaintext (same approach as other agent-messenger platforms)
118
+ - Keep this file secure. It grants full access to your bot's Webex spaces
119
+ - Bot tokens never expire — treat them like passwords
120
+ - If a token is compromised, regenerate it at [developer.webex.com/my-apps](https://developer.webex.com/my-apps)
121
+
122
+ ## Token Lifecycle
123
+
124
+ ```
125
+ Create bot at developer.webex.com → Bot token issued → Valid forever
126
+ |
127
+ Only invalidated if:
128
+ - You regenerate the token
129
+ - The bot is deleted
130
+ ```
131
+
132
+ Bot tokens are ideal for automation. No refresh logic needed, no expiry to track.
133
+
134
+ ## Troubleshooting
135
+
136
+ ### "No credentials configured"
137
+
138
+ No bot token stored. Set one first:
139
+
140
+ ```bash
141
+ agent-webexbot auth set YOUR_BOT_TOKEN
142
+ ```
143
+
144
+ ### "Token is not a bot token"
145
+
146
+ The token you provided belongs to a user account, not a bot. Use `agent-webex` for user tokens, or create a bot at [developer.webex.com](https://developer.webex.com/my-apps/new/bot) to get a proper bot token.
147
+
148
+ ### "401 Unauthorized"
149
+
150
+ Bot tokens don't expire, so a 401 usually means:
151
+
152
+ - The token was copied incorrectly (missing characters, extra whitespace)
153
+ - The bot was deleted or the token was regenerated
154
+
155
+ Double-check the full token, then re-run:
156
+
157
+ ```bash
158
+ agent-webexbot auth set YOUR_BOT_TOKEN
159
+ ```
160
+
161
+ ### "Bot not found" when using `--bot <id>`
162
+
163
+ The bot identifier doesn't match any stored bot. List available bots:
164
+
165
+ ```bash
166
+ agent-webexbot auth list
167
+ ```
168
+
169
+ ### Permission errors on credentials file
170
+
171
+ ```bash
172
+ chmod 600 ~/.config/agent-messenger/webexbot-credentials.json
173
+ ```
174
+
175
+ ## Security Considerations
176
+
177
+ ### What agent-webexbot Can Access
178
+
179
+ With a valid bot token, `agent-webexbot` can:
180
+
181
+ - Read and send messages in any space the bot has been added to
182
+ - List members of spaces the bot is in
183
+ - Send direct messages to any Webex user by email
184
+
185
+ ### What agent-webexbot Cannot Do
186
+
187
+ - Access spaces the bot hasn't been added to
188
+ - Perform admin operations
189
+ - Read messages from before the bot was added to a space
190
+ - Create or delete spaces
191
+
192
+ ### Best Practices
193
+
194
+ 1. **Use separate bots for separate purposes** — one for CI/CD alerts, one for interactive commands
195
+ 2. **Protect credentials.json** — never commit to version control
196
+ 3. **Revoke compromised tokens** — regenerate at [developer.webex.com/my-apps](https://developer.webex.com/my-apps) if a token is exposed
197
+ 4. **Use `AGENT_MESSENGER_CONFIG_DIR`** for CI/CD sandboxes to isolate credentials per environment
198
+
199
+ ## Manual Credential Setup (Advanced)
200
+
201
+ If you need to create the credentials file manually:
202
+
203
+ ```bash
204
+ # Create config directory
205
+ mkdir -p ~/.config/agent-messenger
206
+
207
+ # Write credentials
208
+ cat > ~/.config/agent-messenger/webexbot-credentials.json << 'EOF'
209
+ {
210
+ "current": { "bot_id": "default" },
211
+ "bots": {
212
+ "default": {
213
+ "bot_id": "default",
214
+ "bot_name": "My Bot",
215
+ "token": "YOUR_BOT_TOKEN"
216
+ }
217
+ }
218
+ }
219
+ EOF
220
+
221
+ # Set secure permissions
222
+ chmod 600 ~/.config/agent-messenger/webexbot-credentials.json
223
+ ```
224
+
225
+ Always prefer `agent-webexbot auth set` over manual file creation. The `auth set` command validates the token and handles the file format correctly.