agent-messenger 2.0.0 → 2.2.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 (272) hide show
  1. package/.claude-plugin/marketplace.json +14 -1
  2. package/.claude-plugin/plugin.json +4 -2
  3. package/.env.template +35 -17
  4. package/README.md +37 -33
  5. package/bun.lock +6 -6
  6. package/dist/package.json +11 -3
  7. package/dist/src/cli.d.ts.map +1 -1
  8. package/dist/src/cli.js +3 -0
  9. package/dist/src/cli.js.map +1 -1
  10. package/dist/src/platforms/channeltalk/commands/auth.d.ts.map +1 -1
  11. package/dist/src/platforms/channeltalk/commands/auth.js +35 -28
  12. package/dist/src/platforms/channeltalk/commands/auth.js.map +1 -1
  13. package/dist/src/platforms/channeltalk/ensure-auth.js +6 -6
  14. package/dist/src/platforms/channeltalk/ensure-auth.js.map +1 -1
  15. package/dist/src/platforms/channeltalk/token-extractor.d.ts +23 -1
  16. package/dist/src/platforms/channeltalk/token-extractor.d.ts.map +1 -1
  17. package/dist/src/platforms/channeltalk/token-extractor.js +299 -29
  18. package/dist/src/platforms/channeltalk/token-extractor.js.map +1 -1
  19. package/dist/src/platforms/discord/commands/auth.d.ts.map +1 -1
  20. package/dist/src/platforms/discord/commands/auth.js +57 -49
  21. package/dist/src/platforms/discord/commands/auth.js.map +1 -1
  22. package/dist/src/platforms/discord/ensure-auth.js +3 -3
  23. package/dist/src/platforms/discord/ensure-auth.js.map +1 -1
  24. package/dist/src/platforms/discord/token-extractor.d.ts +6 -1
  25. package/dist/src/platforms/discord/token-extractor.d.ts.map +1 -1
  26. package/dist/src/platforms/discord/token-extractor.js +167 -14
  27. package/dist/src/platforms/discord/token-extractor.js.map +1 -1
  28. package/dist/src/platforms/instagram/client.d.ts +2 -0
  29. package/dist/src/platforms/instagram/client.d.ts.map +1 -1
  30. package/dist/src/platforms/instagram/client.js +2 -2
  31. package/dist/src/platforms/instagram/client.js.map +1 -1
  32. package/dist/src/platforms/instagram/commands/auth.d.ts.map +1 -1
  33. package/dist/src/platforms/instagram/commands/auth.js +107 -14
  34. package/dist/src/platforms/instagram/commands/auth.js.map +1 -1
  35. package/dist/src/platforms/instagram/ensure-auth.d.ts.map +1 -1
  36. package/dist/src/platforms/instagram/ensure-auth.js +57 -11
  37. package/dist/src/platforms/instagram/ensure-auth.js.map +1 -1
  38. package/dist/src/platforms/instagram/index.d.ts +1 -0
  39. package/dist/src/platforms/instagram/index.d.ts.map +1 -1
  40. package/dist/src/platforms/instagram/index.js +1 -0
  41. package/dist/src/platforms/instagram/index.js.map +1 -1
  42. package/dist/src/platforms/instagram/token-extractor.d.ts +44 -0
  43. package/dist/src/platforms/instagram/token-extractor.d.ts.map +1 -0
  44. package/dist/src/platforms/instagram/token-extractor.js +407 -0
  45. package/dist/src/platforms/instagram/token-extractor.js.map +1 -0
  46. package/dist/src/platforms/kakaotalk/client.d.ts.map +1 -1
  47. package/dist/src/platforms/kakaotalk/client.js +2 -1
  48. package/dist/src/platforms/kakaotalk/client.js.map +1 -1
  49. package/dist/src/platforms/kakaotalk/commands/auth.d.ts.map +1 -1
  50. package/dist/src/platforms/kakaotalk/commands/auth.js +14 -13
  51. package/dist/src/platforms/kakaotalk/commands/auth.js.map +1 -1
  52. package/dist/src/platforms/kakaotalk/protocol/connection.d.ts.map +1 -1
  53. package/dist/src/platforms/kakaotalk/protocol/connection.js +2 -1
  54. package/dist/src/platforms/kakaotalk/protocol/connection.js.map +1 -1
  55. package/dist/src/platforms/line/commands/auth.d.ts.map +1 -1
  56. package/dist/src/platforms/line/commands/auth.js +6 -5
  57. package/dist/src/platforms/line/commands/auth.js.map +1 -1
  58. package/dist/src/platforms/slack/commands/auth.d.ts.map +1 -1
  59. package/dist/src/platforms/slack/commands/auth.js +11 -10
  60. package/dist/src/platforms/slack/commands/auth.js.map +1 -1
  61. package/dist/src/platforms/slack/token-extractor.d.ts +9 -0
  62. package/dist/src/platforms/slack/token-extractor.d.ts.map +1 -1
  63. package/dist/src/platforms/slack/token-extractor.js +300 -23
  64. package/dist/src/platforms/slack/token-extractor.js.map +1 -1
  65. package/dist/src/platforms/teams/commands/auth.d.ts.map +1 -1
  66. package/dist/src/platforms/teams/commands/auth.js +9 -8
  67. package/dist/src/platforms/teams/commands/auth.js.map +1 -1
  68. package/dist/src/platforms/teams/ensure-auth.d.ts.map +1 -1
  69. package/dist/src/platforms/teams/ensure-auth.js +2 -1
  70. package/dist/src/platforms/teams/ensure-auth.js.map +1 -1
  71. package/dist/src/platforms/teams/token-extractor.d.ts +5 -0
  72. package/dist/src/platforms/teams/token-extractor.d.ts.map +1 -1
  73. package/dist/src/platforms/teams/token-extractor.js +161 -29
  74. package/dist/src/platforms/teams/token-extractor.js.map +1 -1
  75. package/dist/src/platforms/telegram/client.d.ts.map +1 -1
  76. package/dist/src/platforms/telegram/client.js +25 -7
  77. package/dist/src/platforms/telegram/client.js.map +1 -1
  78. package/dist/src/platforms/telegram/commands/auth.d.ts.map +1 -1
  79. package/dist/src/platforms/telegram/commands/auth.js +6 -5
  80. package/dist/src/platforms/telegram/commands/auth.js.map +1 -1
  81. package/dist/src/platforms/webex/app-config.d.ts +7 -0
  82. package/dist/src/platforms/webex/app-config.d.ts.map +1 -0
  83. package/dist/src/platforms/webex/app-config.js +20 -0
  84. package/dist/src/platforms/webex/app-config.js.map +1 -0
  85. package/dist/src/platforms/webex/cli.d.ts +5 -0
  86. package/dist/src/platforms/webex/cli.d.ts.map +1 -0
  87. package/dist/src/platforms/webex/cli.js +32 -0
  88. package/dist/src/platforms/webex/cli.js.map +1 -0
  89. package/dist/src/platforms/webex/client.d.ts +55 -0
  90. package/dist/src/platforms/webex/client.d.ts.map +1 -0
  91. package/dist/src/platforms/webex/client.js +299 -0
  92. package/dist/src/platforms/webex/client.js.map +1 -0
  93. package/dist/src/platforms/webex/commands/auth.d.ts +19 -0
  94. package/dist/src/platforms/webex/commands/auth.d.ts.map +1 -0
  95. package/dist/src/platforms/webex/commands/auth.js +166 -0
  96. package/dist/src/platforms/webex/commands/auth.js.map +1 -0
  97. package/dist/src/platforms/webex/commands/index.d.ts +6 -0
  98. package/dist/src/platforms/webex/commands/index.d.ts.map +1 -0
  99. package/dist/src/platforms/webex/commands/index.js +6 -0
  100. package/dist/src/platforms/webex/commands/index.js.map +1 -0
  101. package/dist/src/platforms/webex/commands/member.d.ts +7 -0
  102. package/dist/src/platforms/webex/commands/member.d.ts.map +1 -0
  103. package/dist/src/platforms/webex/commands/member.js +34 -0
  104. package/dist/src/platforms/webex/commands/member.js.map +1 -0
  105. package/dist/src/platforms/webex/commands/message.d.ts +26 -0
  106. package/dist/src/platforms/webex/commands/message.d.ts.map +1 -0
  107. package/dist/src/platforms/webex/commands/message.js +153 -0
  108. package/dist/src/platforms/webex/commands/message.js.map +1 -0
  109. package/dist/src/platforms/webex/commands/snapshot.d.ts +9 -0
  110. package/dist/src/platforms/webex/commands/snapshot.d.ts.map +1 -0
  111. package/dist/src/platforms/webex/commands/snapshot.js +72 -0
  112. package/dist/src/platforms/webex/commands/snapshot.js.map +1 -0
  113. package/dist/src/platforms/webex/commands/space.d.ts +11 -0
  114. package/dist/src/platforms/webex/commands/space.d.ts.map +1 -0
  115. package/dist/src/platforms/webex/commands/space.js +59 -0
  116. package/dist/src/platforms/webex/commands/space.js.map +1 -0
  117. package/dist/src/platforms/webex/credential-manager.d.ts +23 -0
  118. package/dist/src/platforms/webex/credential-manager.d.ts.map +1 -0
  119. package/dist/src/platforms/webex/credential-manager.js +148 -0
  120. package/dist/src/platforms/webex/credential-manager.js.map +1 -0
  121. package/dist/src/platforms/webex/ensure-auth.d.ts +2 -0
  122. package/dist/src/platforms/webex/ensure-auth.d.ts.map +1 -0
  123. package/dist/src/platforms/webex/ensure-auth.js +36 -0
  124. package/dist/src/platforms/webex/ensure-auth.js.map +1 -0
  125. package/dist/src/platforms/webex/index.d.ts +8 -0
  126. package/dist/src/platforms/webex/index.d.ts.map +1 -0
  127. package/dist/src/platforms/webex/index.js +6 -0
  128. package/dist/src/platforms/webex/index.js.map +1 -0
  129. package/dist/src/platforms/webex/token-extractor.d.ts +28 -0
  130. package/dist/src/platforms/webex/token-extractor.d.ts.map +1 -0
  131. package/dist/src/platforms/webex/token-extractor.js +344 -0
  132. package/dist/src/platforms/webex/token-extractor.js.map +1 -0
  133. package/dist/src/platforms/webex/types.d.ts +127 -0
  134. package/dist/src/platforms/webex/types.d.ts.map +1 -0
  135. package/dist/src/platforms/webex/types.js +64 -0
  136. package/dist/src/platforms/webex/types.js.map +1 -0
  137. package/dist/src/platforms/whatsapp/client.d.ts.map +1 -1
  138. package/dist/src/platforms/whatsapp/client.js +6 -2
  139. package/dist/src/platforms/whatsapp/client.js.map +1 -1
  140. package/dist/src/shared/utils/derived-key-cache.d.ts +1 -1
  141. package/dist/src/shared/utils/derived-key-cache.d.ts.map +1 -1
  142. package/dist/src/shared/utils/error-handler.d.ts +1 -1
  143. package/dist/src/shared/utils/error-handler.d.ts.map +1 -1
  144. package/dist/src/shared/utils/error-handler.js +3 -2
  145. package/dist/src/shared/utils/error-handler.js.map +1 -1
  146. package/dist/src/shared/utils/stderr.d.ts +5 -0
  147. package/dist/src/shared/utils/stderr.d.ts.map +1 -0
  148. package/dist/src/shared/utils/stderr.js +18 -0
  149. package/dist/src/shared/utils/stderr.js.map +1 -0
  150. package/dist/src/tui/adapters/webex-adapter.d.ts +14 -0
  151. package/dist/src/tui/adapters/webex-adapter.d.ts.map +1 -0
  152. package/dist/src/tui/adapters/webex-adapter.js +79 -0
  153. package/dist/src/tui/adapters/webex-adapter.js.map +1 -0
  154. package/dist/src/tui/app.d.ts.map +1 -1
  155. package/dist/src/tui/app.js +2 -0
  156. package/dist/src/tui/app.js.map +1 -1
  157. package/docs/content/docs/cli/channeltalk.mdx +7 -7
  158. package/docs/content/docs/cli/discord.mdx +3 -3
  159. package/docs/content/docs/cli/instagram.mdx +28 -6
  160. package/docs/content/docs/cli/meta.json +1 -0
  161. package/docs/content/docs/cli/slack.mdx +2 -2
  162. package/docs/content/docs/cli/teams.mdx +6 -4
  163. package/docs/content/docs/cli/webex.mdx +310 -0
  164. package/docs/content/docs/sdk/meta.json +1 -1
  165. package/docs/content/docs/sdk/webex.mdx +260 -0
  166. package/docs/content/docs/tui.mdx +4 -3
  167. package/docs/src/app/page.tsx +2 -2
  168. package/e2e/README.md +132 -8
  169. package/e2e/channeltalk.e2e.test.ts +2 -7
  170. package/e2e/channeltalkbot.e2e.test.ts +2 -6
  171. package/e2e/config.ts +172 -10
  172. package/e2e/helpers.ts +7 -0
  173. package/e2e/instagram.e2e.test.ts +97 -0
  174. package/e2e/kakaotalk.e2e.test.ts +74 -0
  175. package/e2e/line.e2e.test.ts +92 -0
  176. package/e2e/teams.e2e.test.ts +46 -1
  177. package/e2e/telegram.e2e.test.ts +84 -0
  178. package/e2e/webex.e2e.test.ts +190 -0
  179. package/e2e/whatsapp.e2e.test.ts +90 -0
  180. package/e2e/whatsappbot.e2e.test.ts +78 -0
  181. package/package.json +11 -3
  182. package/skills/agent-channeltalk/SKILL.md +9 -9
  183. package/skills/agent-channeltalk/references/authentication.md +21 -18
  184. package/skills/agent-channeltalkbot/SKILL.md +1 -1
  185. package/skills/agent-discord/SKILL.md +5 -5
  186. package/skills/agent-discord/references/authentication.md +8 -8
  187. package/skills/agent-discordbot/SKILL.md +1 -1
  188. package/skills/agent-instagram/SKILL.md +51 -9
  189. package/skills/agent-instagram/references/authentication.md +35 -3
  190. package/skills/agent-kakaotalk/SKILL.md +1 -1
  191. package/skills/agent-line/SKILL.md +1 -1
  192. package/skills/agent-slack/SKILL.md +5 -5
  193. package/skills/agent-slack/references/authentication.md +8 -8
  194. package/skills/agent-slackbot/SKILL.md +1 -1
  195. package/skills/agent-teams/SKILL.md +6 -6
  196. package/skills/agent-teams/references/authentication.md +8 -8
  197. package/skills/agent-telegram/SKILL.md +1 -1
  198. package/skills/agent-webex/SKILL.md +406 -0
  199. package/skills/agent-webex/references/authentication.md +371 -0
  200. package/skills/agent-webex/references/common-patterns.md +726 -0
  201. package/skills/agent-webex/templates/monitor-space.sh +165 -0
  202. package/skills/agent-webex/templates/post-message.sh +170 -0
  203. package/skills/agent-whatsapp/SKILL.md +1 -1
  204. package/skills/agent-whatsappbot/SKILL.md +1 -1
  205. package/src/cli.ts +4 -0
  206. package/src/platforms/channeltalk/commands/auth.test.ts +5 -5
  207. package/src/platforms/channeltalk/commands/auth.ts +38 -32
  208. package/src/platforms/channeltalk/ensure-auth.test.ts +6 -6
  209. package/src/platforms/channeltalk/ensure-auth.ts +6 -6
  210. package/src/platforms/channeltalk/token-extractor.test.ts +182 -15
  211. package/src/platforms/channeltalk/token-extractor.ts +344 -30
  212. package/src/platforms/discord/commands/auth.test.ts +3 -3
  213. package/src/platforms/discord/commands/auth.ts +58 -54
  214. package/src/platforms/discord/ensure-auth.test.ts +3 -3
  215. package/src/platforms/discord/ensure-auth.ts +3 -3
  216. package/src/platforms/discord/token-extractor.test.ts +199 -27
  217. package/src/platforms/discord/token-extractor.ts +190 -17
  218. package/src/platforms/instagram/client.ts +2 -2
  219. package/src/platforms/instagram/commands/auth.ts +133 -14
  220. package/src/platforms/instagram/ensure-auth.ts +63 -12
  221. package/src/platforms/instagram/index.ts +1 -0
  222. package/src/platforms/instagram/token-extractor.test.ts +424 -0
  223. package/src/platforms/instagram/token-extractor.ts +478 -0
  224. package/src/platforms/kakaotalk/client.ts +3 -1
  225. package/src/platforms/kakaotalk/commands/auth.ts +14 -13
  226. package/src/platforms/kakaotalk/protocol/connection.ts +3 -1
  227. package/src/platforms/line/commands/auth.ts +7 -6
  228. package/src/platforms/slack/cli.test.ts +6 -5
  229. package/src/platforms/slack/commands/auth.test.ts +11 -7
  230. package/src/platforms/slack/commands/auth.ts +11 -10
  231. package/src/platforms/slack/token-extractor.test.ts +98 -1
  232. package/src/platforms/slack/token-extractor.ts +338 -26
  233. package/src/platforms/teams/commands/auth.ts +9 -8
  234. package/src/platforms/teams/ensure-auth.ts +3 -1
  235. package/src/platforms/teams/token-extractor.test.ts +136 -17
  236. package/src/platforms/teams/token-extractor.ts +182 -31
  237. package/src/platforms/telegram/client.test.ts +134 -0
  238. package/src/platforms/telegram/client.ts +27 -6
  239. package/src/platforms/telegram/commands/auth.ts +6 -5
  240. package/src/platforms/webex/app-config.test.ts +98 -0
  241. package/src/platforms/webex/app-config.ts +31 -0
  242. package/src/platforms/webex/cli.test.ts +58 -0
  243. package/src/platforms/webex/cli.ts +39 -0
  244. package/src/platforms/webex/client.test.ts +743 -0
  245. package/src/platforms/webex/client.ts +405 -0
  246. package/src/platforms/webex/commands/auth.test.ts +222 -0
  247. package/src/platforms/webex/commands/auth.ts +243 -0
  248. package/src/platforms/webex/commands/index.ts +5 -0
  249. package/src/platforms/webex/commands/member.test.ts +112 -0
  250. package/src/platforms/webex/commands/member.ts +45 -0
  251. package/src/platforms/webex/commands/message.test.ts +235 -0
  252. package/src/platforms/webex/commands/message.ts +204 -0
  253. package/src/platforms/webex/commands/snapshot.test.ts +105 -0
  254. package/src/platforms/webex/commands/snapshot.ts +91 -0
  255. package/src/platforms/webex/commands/space.test.ts +216 -0
  256. package/src/platforms/webex/commands/space.ts +74 -0
  257. package/src/platforms/webex/credential-manager.test.ts +314 -0
  258. package/src/platforms/webex/credential-manager.ts +197 -0
  259. package/src/platforms/webex/ensure-auth.test.ts +89 -0
  260. package/src/platforms/webex/ensure-auth.ts +38 -0
  261. package/src/platforms/webex/index.test.ts +25 -0
  262. package/src/platforms/webex/index.ts +19 -0
  263. package/src/platforms/webex/token-extractor.test.ts +327 -0
  264. package/src/platforms/webex/token-extractor.ts +393 -0
  265. package/src/platforms/webex/types.test.ts +307 -0
  266. package/src/platforms/webex/types.ts +129 -0
  267. package/src/platforms/whatsapp/client.ts +11 -7
  268. package/src/shared/utils/derived-key-cache.ts +1 -1
  269. package/src/shared/utils/error-handler.ts +4 -2
  270. package/src/shared/utils/stderr.ts +22 -0
  271. package/src/tui/adapters/webex-adapter.ts +103 -0
  272. package/src/tui/app.ts +2 -0
@@ -0,0 +1,406 @@
1
+ ---
2
+ name: agent-webex
3
+ description: Interact with Cisco Webex - send messages, read spaces, manage memberships
4
+ version: 2.2.0
5
+ allowed-tools: Bash(agent-webex:*)
6
+ metadata:
7
+ openclaw:
8
+ requires:
9
+ bins:
10
+ - agent-webex
11
+ install:
12
+ - kind: node
13
+ package: agent-messenger
14
+ bins: [agent-webex]
15
+ ---
16
+
17
+ # Agent Webex
18
+
19
+ A TypeScript CLI tool that enables AI agents and humans to interact with Cisco Webex through a simple command interface. Supports browser token extraction (zero-config, sends as you) and OAuth Device Grant flow.
20
+
21
+ ## Quick Start
22
+
23
+ ```bash
24
+ # Extract token from browser (Chrome, Edge, Arc, Brave) — messages appear as you
25
+ agent-webex auth extract
26
+
27
+ # Or: Log in via OAuth Device Grant (opens browser, messages show "via agent-messenger")
28
+ agent-webex auth login
29
+
30
+ # Get workspace snapshot
31
+ agent-webex snapshot
32
+
33
+ # Send a message
34
+ agent-webex message send <space-id> "Hello from AI agent!"
35
+
36
+ # List spaces
37
+ agent-webex space list
38
+ ```
39
+
40
+ ## Authentication
41
+
42
+ Webex supports two authentication methods:
43
+
44
+ 1. **Browser token extraction** (recommended): Extracts your first-party token from a Chromium browser where you're logged into web.webex.com. Messages appear as you — no "via" label.
45
+ 2. **OAuth Device Grant**: Opens a browser for you to authorize. Messages show "via agent-messenger" label.
46
+
47
+ ### Browser Token Extraction (Recommended)
48
+
49
+ `agent-webex auth extract` reads your Webex session token from Chrome, Edge, Arc, or Brave. You must be logged into web.webex.com in one of these browsers. No configuration needed.
50
+
51
+ ```bash
52
+ # Extract token from browser — messages appear as you
53
+ agent-webex auth extract
54
+
55
+ # With debug output
56
+ agent-webex auth extract --debug
57
+ ```
58
+
59
+ **Supported browsers**: Chrome, Chrome Canary, Edge, Arc, Brave, Vivaldi, Chromium
60
+
61
+ **How it works**: The Webex web client stores its authentication token in the browser's localStorage. This CLI reads it directly from the browser's LevelDB files — no browser automation, no password prompts. The token is stored locally in `~/.config/agent-messenger/`.
62
+
63
+ **When to re-extract**: Browser tokens expire. When your token expires, re-run `agent-webex auth extract` or let auto-extraction handle it (the CLI attempts extraction automatically on each run).
64
+
65
+ ### OAuth Device Grant (Fallback)
66
+
67
+ `agent-webex auth login` starts the Device Grant flow: it displays a verification URL and user code, then opens the browser. You enter the code at the verification page and approve access. The CLI polls for the token automatically. Access and refresh tokens are stored locally, and the access token auto-refreshes via the refresh token.
68
+
69
+ Note: Messages sent via OAuth Device Grant show "via agent-messenger" because the token is associated with a third-party Webex Integration.
70
+
71
+ Optionally, pass `--token <bot-token>` for bot token auth. Or pass `--client-id <id> --client-secret <secret>` to use your own Webex Integration credentials instead of the built-in ones.
72
+
73
+ Env vars `AGENT_WEBEX_CLIENT_ID` / `AGENT_WEBEX_CLIENT_SECRET` can also override the built-in credentials.
74
+
75
+ ```bash
76
+ # Log in (Device Grant flow, opens browser)
77
+ agent-webex auth login
78
+
79
+ # Log in with custom Integration credentials
80
+ agent-webex auth login --client-id <id> --client-secret <secret>
81
+
82
+ # Log in with a bot token
83
+ agent-webex auth login --token <token>
84
+
85
+ # Check auth status
86
+ agent-webex auth status
87
+
88
+ # Log out
89
+ agent-webex auth logout
90
+ ```
91
+
92
+ ### Token Types
93
+
94
+ - **Extracted (browser)**: First-party token from web.webex.com. Messages appear as you. Requires re-extraction when expired.
95
+ - **OAuth Device Grant**: Zero-config login. Access token auto-refreshes. Messages show "via agent-messenger".
96
+ - **Bot Token**: Pass via `--token` flag. Never expires. Best for CI/CD.
97
+ - **Custom Integration**: Pass `--client-id` + `--client-secret` or set env vars for your own Webex Integration.
98
+
99
+ **IMPORTANT**: NEVER guide the user to open a web browser, use DevTools, or manually copy tokens from a browser's network inspector. Always use `agent-webex auth extract` or `agent-webex auth login` for authentication.
100
+
101
+ For detailed token management, see [references/authentication.md](references/authentication.md).
102
+
103
+ ## Memory
104
+
105
+ 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.
106
+
107
+ ### Reading Memory
108
+
109
+ At the **start of every task**, read `~/.config/agent-messenger/MEMORY.md` using the `Read` tool to load any previously discovered space IDs, member info, and preferences.
110
+
111
+ - If the file doesn't exist yet, that's fine. Proceed without it and create it when you first have useful information to store.
112
+ - If the file can't be read (permissions, missing directory), proceed without memory. Don't error out.
113
+
114
+ ### Writing Memory
115
+
116
+ After discovering useful information, update `~/.config/agent-messenger/MEMORY.md` using the `Write` tool. Write triggers include:
117
+
118
+ - After discovering space IDs and titles (from `space list`, `snapshot`, etc.)
119
+ - After discovering member IDs and names (from `member list`, `snapshot`, etc.)
120
+ - After the user gives you an alias or preference ("call this the standup space", "my main space is X")
121
+ - After discovering space structure (group vs direct spaces)
122
+
123
+ When writing, include the **complete file content**. The `Write` tool overwrites the entire file.
124
+
125
+ ### What to Store
126
+
127
+ - Space IDs with titles
128
+ - Member IDs with display names and space context
129
+ - User-given aliases ("standup space", "engineering space")
130
+ - Token type in use (PAT vs bot)
131
+ - Any user preference expressed during interaction
132
+
133
+ ### What NOT to Store
134
+
135
+ Never store tokens, credentials, or any sensitive data. Never store full message content (just IDs and space context).
136
+
137
+ ### Handling Stale Data
138
+
139
+ If a memorized ID returns an error (space not found, member not found), remove it from `MEMORY.md`. Don't blindly trust memorized data. Verify when something seems off. Prefer re-listing over using a memorized ID that might be stale.
140
+
141
+ ### Format / Example
142
+
143
+ ```markdown
144
+ # Agent Messenger Memory
145
+
146
+ ## Spaces
147
+
148
+ - `space-id-1` — Engineering (group)
149
+ - `space-id-2` — Alice / Bob (direct)
150
+ - `space-id-3` — Standups (group)
151
+
152
+ ## Members (Engineering)
153
+
154
+ - `person-id-1` — Alice Chen (engineering lead)
155
+ - `person-id-2` — Bob Park (backend)
156
+
157
+ ## Aliases
158
+
159
+ - "standup" -> `space-id-3` (Standups)
160
+ - "eng" -> `space-id-1` (Engineering)
161
+
162
+ ## Notes
163
+
164
+ - Using bot token (no expiry)
165
+ - Main space is "Engineering"
166
+ ```
167
+
168
+ > Memory lets you skip repeated `space list` and `member list` calls. When you already know an ID from a previous session, use it directly.
169
+
170
+ ## Commands
171
+
172
+ ### Auth Commands
173
+
174
+ ```bash
175
+ # Log in (Device Grant flow, opens browser)
176
+ agent-webex auth login
177
+
178
+ # Log in with custom Integration credentials
179
+ agent-webex auth login --client-id <id> --client-secret <secret>
180
+
181
+ # Log in with a bot token
182
+ agent-webex auth login --token <token>
183
+
184
+ # Check auth status
185
+ agent-webex auth status
186
+
187
+ # Log out
188
+ agent-webex auth logout
189
+ ```
190
+
191
+ ### Space Commands
192
+
193
+ ```bash
194
+ # List spaces
195
+ agent-webex space list
196
+ agent-webex space list --type group
197
+ agent-webex space list --type direct
198
+ agent-webex space list --limit 20
199
+
200
+ # Get space info
201
+ agent-webex space info <space-id>
202
+ ```
203
+
204
+ ### Message Commands
205
+
206
+ ```bash
207
+ # Send a message
208
+ agent-webex message send <space-id> <text>
209
+ agent-webex message send <space-id> "Hello world"
210
+
211
+ # Send a markdown message
212
+ agent-webex message send <space-id> "**Bold** and _italic_" --markdown
213
+
214
+ # List messages in a space
215
+ agent-webex message list <space-id>
216
+ agent-webex message list <space-id> --limit 50
217
+
218
+ # Get a single message by ID
219
+ agent-webex message get <message-id>
220
+
221
+ # Delete a message
222
+ agent-webex message delete <message-id>
223
+ agent-webex message delete <message-id> --force
224
+
225
+ # Edit a message
226
+ agent-webex message edit <message-id> <space-id> <text>
227
+ agent-webex message edit <message-id> <space-id> "Updated text" --markdown
228
+ ```
229
+
230
+ ### Member Commands
231
+
232
+ ```bash
233
+ # List members of a space
234
+ agent-webex member list <space-id>
235
+ agent-webex member list <space-id> --limit 100
236
+ ```
237
+
238
+ ### Snapshot Command
239
+
240
+ Get comprehensive workspace state for AI agents:
241
+
242
+ ```bash
243
+ # Full snapshot
244
+ agent-webex snapshot
245
+
246
+ # Filtered snapshots
247
+ agent-webex snapshot --spaces-only
248
+ agent-webex snapshot --members-only
249
+
250
+ # Limit messages per space
251
+ agent-webex snapshot --limit 10
252
+ ```
253
+
254
+ Returns JSON with:
255
+
256
+ - Spaces (id, title, type, created)
257
+ - Recent messages (id, text, personEmail, created)
258
+ - Members (id, personDisplayName, personEmail)
259
+
260
+ ## Output Format
261
+
262
+ ### JSON (Default)
263
+
264
+ All commands output JSON by default for AI consumption:
265
+
266
+ ```json
267
+ {
268
+ "id": "Y2lzY29zcGFyazovL...",
269
+ "text": "Hello world",
270
+ "personEmail": "alice@example.com",
271
+ "created": "2024-01-15T10:30:00.000Z"
272
+ }
273
+ ```
274
+
275
+ ### Pretty (Human-Readable)
276
+
277
+ Use `--pretty` flag for formatted output:
278
+
279
+ ```bash
280
+ agent-webex space list --pretty
281
+ ```
282
+
283
+ ## Error Handling
284
+
285
+ All commands return consistent error format:
286
+
287
+ ```json
288
+ {
289
+ "error": "Not authenticated. Run \"auth login\" first."
290
+ }
291
+ ```
292
+
293
+ Common errors:
294
+
295
+ - `Not authenticated`: No valid token. Run `auth login` first
296
+ - `Device authorization timed out`: User didn't complete verification in time. Run `auth login` again.
297
+ - `401 Unauthorized`: Token expired or invalid. Re-run `auth login`
298
+ - `429 Too Many Requests`: Rate limited. Wait and retry (Webex allows ~600 requests per minute)
299
+ - `404 Not Found`: Invalid space ID, message ID, or resource
300
+ - `Space not found`: Invalid space ID
301
+ - `Message not found`: Invalid message ID
302
+
303
+ ## Configuration
304
+
305
+ Credentials stored in `~/.config/agent-messenger/webex-credentials.json` (0600 permissions):
306
+
307
+ ```json
308
+ {
309
+ "accessToken": "...",
310
+ "refreshToken": "...",
311
+ "expiresAt": 1234567890,
312
+ "clientId": "...",
313
+ "clientSecret": "..."
314
+ }
315
+ ```
316
+
317
+ See [references/authentication.md](references/authentication.md) for format and security details.
318
+
319
+ ## SDK: Programmatic Usage
320
+
321
+ `WebexClient` is available as a TypeScript SDK for building scripts and automations.
322
+
323
+ ### Setup
324
+
325
+ ```typescript
326
+ import { WebexClient } from 'agent-messenger/webex'
327
+
328
+ const client = await new WebexClient().login()
329
+ ```
330
+
331
+ ### Example
332
+
333
+ ```typescript
334
+ // List spaces
335
+ const spaces = await client.listSpaces()
336
+
337
+ // List members in a space
338
+ const members = await client.listMembers(spaces[0].id)
339
+
340
+ // Send a message
341
+ const msg = await client.sendMessage(spaces[0].id, 'Hello from SDK!')
342
+
343
+ // Send markdown
344
+ await client.sendMessage(spaces[0].id, '**Status**: All systems go', { markdown: true })
345
+ ```
346
+
347
+ ### Full API Reference
348
+
349
+ See the [Webex SDK documentation](https://agent-messenger.dev/docs/sdk/webex) for complete method signatures, types, schemas, and examples.
350
+
351
+ ## Limitations
352
+
353
+ - No real-time events / WebSocket connection
354
+ - No file upload or download
355
+ - No reactions / emoji support
356
+ - No thread support
357
+ - No message search
358
+ - No voice/video or meeting support
359
+ - No space management (create/delete spaces, roles)
360
+
361
+ ## Troubleshooting
362
+
363
+ ### Token refresh failed
364
+
365
+ OAuth tokens auto-refresh, so expiration is handled automatically. If a refresh fails (revoked access, network issues), re-run:
366
+
367
+ ```bash
368
+ agent-webex auth login
369
+ ```
370
+
371
+ Bot tokens never expire and don't need refreshing.
372
+
373
+ ### `agent-webex: command not found`
374
+
375
+ **`agent-webex` is NOT the npm package name.** The npm package is `agent-messenger`.
376
+
377
+ If the package is installed globally, use `agent-webex` directly:
378
+
379
+ ```bash
380
+ agent-webex space list
381
+ ```
382
+
383
+ If the package is NOT installed, use `npx -y` by default. **Do NOT ask the user which package runner to use.** Just run it:
384
+
385
+ ```bash
386
+ npx -y agent-messenger webex space list
387
+ bunx agent-messenger webex space list
388
+ pnpm dlx agent-messenger webex space list
389
+ ```
390
+
391
+ > If you already know the user's preferred package runner (e.g., `bunx`, `pnpm dlx`), use that instead.
392
+
393
+ **NEVER run `npx agent-webex`, `bunx agent-webex`, or `pnpm dlx agent-webex`**. It will fail or install a wrong package since `agent-webex` is not the npm package name.
394
+
395
+ ### Rate limiting (429)
396
+
397
+ 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.
398
+
399
+ ### Other errors
400
+
401
+ For auth troubleshooting (token types, storage, permissions), see [references/authentication.md](references/authentication.md).
402
+
403
+ ## References
404
+
405
+ - [Authentication Guide](references/authentication.md)
406
+ - [Common Patterns](references/common-patterns.md)