agent-messenger 2.10.2 → 2.11.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 (330) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/.env.template +4 -1
  3. package/README.md +77 -27
  4. package/bun.lock +26 -0
  5. package/dist/package.json +14 -1
  6. package/dist/src/platforms/channeltalk/commands/auth.d.ts +2 -1
  7. package/dist/src/platforms/channeltalk/commands/auth.d.ts.map +1 -1
  8. package/dist/src/platforms/channeltalk/commands/auth.js +5 -3
  9. package/dist/src/platforms/channeltalk/commands/auth.js.map +1 -1
  10. package/dist/src/platforms/channeltalk/token-extractor.d.ts +2 -1
  11. package/dist/src/platforms/channeltalk/token-extractor.d.ts.map +1 -1
  12. package/dist/src/platforms/channeltalk/token-extractor.js +22 -6
  13. package/dist/src/platforms/channeltalk/token-extractor.js.map +1 -1
  14. package/dist/src/platforms/channeltalkbot/cli.d.ts.map +1 -1
  15. package/dist/src/platforms/channeltalkbot/cli.js +11 -1
  16. package/dist/src/platforms/channeltalkbot/cli.js.map +1 -1
  17. package/dist/src/platforms/channeltalkbot/commands/auth.d.ts.map +1 -1
  18. package/dist/src/platforms/channeltalkbot/commands/auth.js +1 -5
  19. package/dist/src/platforms/channeltalkbot/commands/auth.js.map +1 -1
  20. package/dist/src/platforms/channeltalkbot/commands/bot.d.ts.map +1 -1
  21. package/dist/src/platforms/channeltalkbot/commands/bot.js +1 -6
  22. package/dist/src/platforms/channeltalkbot/commands/bot.js.map +1 -1
  23. package/dist/src/platforms/channeltalkbot/commands/chat.d.ts.map +1 -1
  24. package/dist/src/platforms/channeltalkbot/commands/chat.js +1 -6
  25. package/dist/src/platforms/channeltalkbot/commands/chat.js.map +1 -1
  26. package/dist/src/platforms/channeltalkbot/commands/group.d.ts.map +1 -1
  27. package/dist/src/platforms/channeltalkbot/commands/group.js +1 -6
  28. package/dist/src/platforms/channeltalkbot/commands/group.js.map +1 -1
  29. package/dist/src/platforms/channeltalkbot/commands/manager.d.ts.map +1 -1
  30. package/dist/src/platforms/channeltalkbot/commands/manager.js +1 -6
  31. package/dist/src/platforms/channeltalkbot/commands/manager.js.map +1 -1
  32. package/dist/src/platforms/channeltalkbot/commands/message.d.ts.map +1 -1
  33. package/dist/src/platforms/channeltalkbot/commands/message.js +1 -6
  34. package/dist/src/platforms/channeltalkbot/commands/message.js.map +1 -1
  35. package/dist/src/platforms/channeltalkbot/commands/whoami.d.ts.map +1 -1
  36. package/dist/src/platforms/channeltalkbot/commands/whoami.js +1 -6
  37. package/dist/src/platforms/channeltalkbot/commands/whoami.js.map +1 -1
  38. package/dist/src/platforms/channeltalkbot/credential-manager.d.ts +5 -0
  39. package/dist/src/platforms/channeltalkbot/credential-manager.d.ts.map +1 -1
  40. package/dist/src/platforms/channeltalkbot/credential-manager.js +34 -4
  41. package/dist/src/platforms/channeltalkbot/credential-manager.js.map +1 -1
  42. package/dist/src/platforms/discord/commands/auth.d.ts +1 -0
  43. package/dist/src/platforms/discord/commands/auth.d.ts.map +1 -1
  44. package/dist/src/platforms/discord/commands/auth.js +3 -1
  45. package/dist/src/platforms/discord/commands/auth.js.map +1 -1
  46. package/dist/src/platforms/discord/listener.d.ts +2 -0
  47. package/dist/src/platforms/discord/listener.d.ts.map +1 -1
  48. package/dist/src/platforms/discord/listener.js +51 -21
  49. package/dist/src/platforms/discord/listener.js.map +1 -1
  50. package/dist/src/platforms/discord/token-extractor.d.ts +2 -1
  51. package/dist/src/platforms/discord/token-extractor.d.ts.map +1 -1
  52. package/dist/src/platforms/discord/token-extractor.js +21 -6
  53. package/dist/src/platforms/discord/token-extractor.js.map +1 -1
  54. package/dist/src/platforms/discordbot/cli.d.ts.map +1 -1
  55. package/dist/src/platforms/discordbot/cli.js +12 -1
  56. package/dist/src/platforms/discordbot/cli.js.map +1 -1
  57. package/dist/src/platforms/discordbot/client.d.ts +3 -0
  58. package/dist/src/platforms/discordbot/client.d.ts.map +1 -1
  59. package/dist/src/platforms/discordbot/client.js +3 -0
  60. package/dist/src/platforms/discordbot/client.js.map +1 -1
  61. package/dist/src/platforms/discordbot/commands/auth.d.ts.map +1 -1
  62. package/dist/src/platforms/discordbot/commands/auth.js +1 -5
  63. package/dist/src/platforms/discordbot/commands/auth.js.map +1 -1
  64. package/dist/src/platforms/discordbot/commands/message.d.ts.map +1 -1
  65. package/dist/src/platforms/discordbot/commands/message.js +1 -6
  66. package/dist/src/platforms/discordbot/commands/message.js.map +1 -1
  67. package/dist/src/platforms/discordbot/commands/server.d.ts.map +1 -1
  68. package/dist/src/platforms/discordbot/commands/server.js +1 -4
  69. package/dist/src/platforms/discordbot/commands/server.js.map +1 -1
  70. package/dist/src/platforms/discordbot/commands/whoami.d.ts.map +1 -1
  71. package/dist/src/platforms/discordbot/commands/whoami.js +1 -6
  72. package/dist/src/platforms/discordbot/commands/whoami.js.map +1 -1
  73. package/dist/src/platforms/discordbot/index.d.ts +3 -1
  74. package/dist/src/platforms/discordbot/index.d.ts.map +1 -1
  75. package/dist/src/platforms/discordbot/index.js +2 -1
  76. package/dist/src/platforms/discordbot/index.js.map +1 -1
  77. package/dist/src/platforms/discordbot/listener.d.ts +43 -0
  78. package/dist/src/platforms/discordbot/listener.d.ts.map +1 -0
  79. package/dist/src/platforms/discordbot/listener.js +292 -0
  80. package/dist/src/platforms/discordbot/listener.js.map +1 -0
  81. package/dist/src/platforms/discordbot/types.d.ts +161 -0
  82. package/dist/src/platforms/discordbot/types.d.ts.map +1 -1
  83. package/dist/src/platforms/discordbot/types.js +34 -0
  84. package/dist/src/platforms/discordbot/types.js.map +1 -1
  85. package/dist/src/platforms/instagram/commands/auth.d.ts.map +1 -1
  86. package/dist/src/platforms/instagram/commands/auth.js +3 -1
  87. package/dist/src/platforms/instagram/commands/auth.js.map +1 -1
  88. package/dist/src/platforms/instagram/token-extractor.d.ts +2 -1
  89. package/dist/src/platforms/instagram/token-extractor.d.ts.map +1 -1
  90. package/dist/src/platforms/instagram/token-extractor.js +11 -2
  91. package/dist/src/platforms/instagram/token-extractor.js.map +1 -1
  92. package/dist/src/platforms/slack/commands/auth.d.ts.map +1 -1
  93. package/dist/src/platforms/slack/commands/auth.js +4 -2
  94. package/dist/src/platforms/slack/commands/auth.js.map +1 -1
  95. package/dist/src/platforms/slack/token-extractor.d.ts +4 -1
  96. package/dist/src/platforms/slack/token-extractor.d.ts.map +1 -1
  97. package/dist/src/platforms/slack/token-extractor.js +64 -15
  98. package/dist/src/platforms/slack/token-extractor.js.map +1 -1
  99. package/dist/src/platforms/slackbot/cli.d.ts.map +1 -1
  100. package/dist/src/platforms/slackbot/cli.js +15 -3
  101. package/dist/src/platforms/slackbot/cli.js.map +1 -1
  102. package/dist/src/platforms/slackbot/client.d.ts +22 -1
  103. package/dist/src/platforms/slackbot/client.d.ts.map +1 -1
  104. package/dist/src/platforms/slackbot/client.js +104 -1
  105. package/dist/src/platforms/slackbot/client.js.map +1 -1
  106. package/dist/src/platforms/slackbot/commands/auth.d.ts.map +1 -1
  107. package/dist/src/platforms/slackbot/commands/auth.js +1 -5
  108. package/dist/src/platforms/slackbot/commands/auth.js.map +1 -1
  109. package/dist/src/platforms/slackbot/commands/file.d.ts +3 -0
  110. package/dist/src/platforms/slackbot/commands/file.d.ts.map +1 -0
  111. package/dist/src/platforms/slackbot/commands/file.js +164 -0
  112. package/dist/src/platforms/slackbot/commands/file.js.map +1 -0
  113. package/dist/src/platforms/slackbot/commands/index.d.ts +1 -0
  114. package/dist/src/platforms/slackbot/commands/index.d.ts.map +1 -1
  115. package/dist/src/platforms/slackbot/commands/index.js +1 -0
  116. package/dist/src/platforms/slackbot/commands/index.js.map +1 -1
  117. package/dist/src/platforms/slackbot/commands/message.d.ts.map +1 -1
  118. package/dist/src/platforms/slackbot/commands/message.js +19 -0
  119. package/dist/src/platforms/slackbot/commands/message.js.map +1 -1
  120. package/dist/src/platforms/slackbot/commands/whoami.d.ts.map +1 -1
  121. package/dist/src/platforms/slackbot/commands/whoami.js +1 -6
  122. package/dist/src/platforms/slackbot/commands/whoami.js.map +1 -1
  123. package/dist/src/platforms/slackbot/credential-manager.d.ts +1 -0
  124. package/dist/src/platforms/slackbot/credential-manager.d.ts.map +1 -1
  125. package/dist/src/platforms/slackbot/credential-manager.js +30 -2
  126. package/dist/src/platforms/slackbot/credential-manager.js.map +1 -1
  127. package/dist/src/platforms/slackbot/index.d.ts +4 -1
  128. package/dist/src/platforms/slackbot/index.d.ts.map +1 -1
  129. package/dist/src/platforms/slackbot/index.js +1 -0
  130. package/dist/src/platforms/slackbot/index.js.map +1 -1
  131. package/dist/src/platforms/slackbot/listener.d.ts +44 -0
  132. package/dist/src/platforms/slackbot/listener.d.ts.map +1 -0
  133. package/dist/src/platforms/slackbot/listener.js +313 -0
  134. package/dist/src/platforms/slackbot/listener.js.map +1 -0
  135. package/dist/src/platforms/slackbot/types.d.ts +196 -1
  136. package/dist/src/platforms/slackbot/types.d.ts.map +1 -1
  137. package/dist/src/platforms/slackbot/types.js +4 -1
  138. package/dist/src/platforms/slackbot/types.js.map +1 -1
  139. package/dist/src/platforms/teams/commands/auth.d.ts +1 -0
  140. package/dist/src/platforms/teams/commands/auth.d.ts.map +1 -1
  141. package/dist/src/platforms/teams/commands/auth.js +37 -6
  142. package/dist/src/platforms/teams/commands/auth.js.map +1 -1
  143. package/dist/src/platforms/teams/ensure-auth.js +31 -9
  144. package/dist/src/platforms/teams/ensure-auth.js.map +1 -1
  145. package/dist/src/platforms/teams/token-extractor.d.ts +4 -1
  146. package/dist/src/platforms/teams/token-extractor.d.ts.map +1 -1
  147. package/dist/src/platforms/teams/token-extractor.js +71 -29
  148. package/dist/src/platforms/teams/token-extractor.js.map +1 -1
  149. package/dist/src/platforms/webex/commands/auth.d.ts +1 -0
  150. package/dist/src/platforms/webex/commands/auth.d.ts.map +1 -1
  151. package/dist/src/platforms/webex/commands/auth.js +3 -1
  152. package/dist/src/platforms/webex/commands/auth.js.map +1 -1
  153. package/dist/src/platforms/webex/token-extractor.d.ts +3 -1
  154. package/dist/src/platforms/webex/token-extractor.d.ts.map +1 -1
  155. package/dist/src/platforms/webex/token-extractor.js +16 -2
  156. package/dist/src/platforms/webex/token-extractor.js.map +1 -1
  157. package/dist/src/platforms/wechatbot/cli.d.ts.map +1 -1
  158. package/dist/src/platforms/wechatbot/cli.js +11 -1
  159. package/dist/src/platforms/wechatbot/cli.js.map +1 -1
  160. package/dist/src/platforms/wechatbot/commands/auth.d.ts.map +1 -1
  161. package/dist/src/platforms/wechatbot/commands/auth.js +1 -5
  162. package/dist/src/platforms/wechatbot/commands/auth.js.map +1 -1
  163. package/dist/src/platforms/wechatbot/commands/message.d.ts.map +1 -1
  164. package/dist/src/platforms/wechatbot/commands/message.js +1 -6
  165. package/dist/src/platforms/wechatbot/commands/message.js.map +1 -1
  166. package/dist/src/platforms/wechatbot/commands/template.d.ts.map +1 -1
  167. package/dist/src/platforms/wechatbot/commands/template.js +1 -6
  168. package/dist/src/platforms/wechatbot/commands/template.js.map +1 -1
  169. package/dist/src/platforms/wechatbot/commands/user.d.ts.map +1 -1
  170. package/dist/src/platforms/wechatbot/commands/user.js +1 -6
  171. package/dist/src/platforms/wechatbot/commands/user.js.map +1 -1
  172. package/dist/src/platforms/wechatbot/commands/whoami.d.ts.map +1 -1
  173. package/dist/src/platforms/wechatbot/commands/whoami.js +1 -6
  174. package/dist/src/platforms/wechatbot/commands/whoami.js.map +1 -1
  175. package/dist/src/platforms/whatsappbot/cli.d.ts.map +1 -1
  176. package/dist/src/platforms/whatsappbot/cli.js +11 -1
  177. package/dist/src/platforms/whatsappbot/cli.js.map +1 -1
  178. package/dist/src/platforms/whatsappbot/commands/auth.d.ts.map +1 -1
  179. package/dist/src/platforms/whatsappbot/commands/auth.js +1 -5
  180. package/dist/src/platforms/whatsappbot/commands/auth.js.map +1 -1
  181. package/dist/src/platforms/whatsappbot/commands/message.d.ts.map +1 -1
  182. package/dist/src/platforms/whatsappbot/commands/message.js +1 -6
  183. package/dist/src/platforms/whatsappbot/commands/message.js.map +1 -1
  184. package/dist/src/platforms/whatsappbot/commands/template.d.ts.map +1 -1
  185. package/dist/src/platforms/whatsappbot/commands/template.js +1 -6
  186. package/dist/src/platforms/whatsappbot/commands/template.js.map +1 -1
  187. package/dist/src/platforms/whatsappbot/commands/whoami.d.ts.map +1 -1
  188. package/dist/src/platforms/whatsappbot/commands/whoami.js +1 -6
  189. package/dist/src/platforms/whatsappbot/commands/whoami.js.map +1 -1
  190. package/dist/src/shared/chromium/browsers.d.ts +8 -0
  191. package/dist/src/shared/chromium/browsers.d.ts.map +1 -1
  192. package/dist/src/shared/chromium/browsers.js +58 -3
  193. package/dist/src/shared/chromium/browsers.js.map +1 -1
  194. package/dist/src/shared/chromium/cli-options.d.ts +5 -0
  195. package/dist/src/shared/chromium/cli-options.d.ts.map +1 -0
  196. package/dist/src/shared/chromium/cli-options.js +8 -0
  197. package/dist/src/shared/chromium/cli-options.js.map +1 -0
  198. package/dist/src/shared/chromium/index.d.ts +3 -1
  199. package/dist/src/shared/chromium/index.d.ts.map +1 -1
  200. package/dist/src/shared/chromium/index.js +2 -1
  201. package/dist/src/shared/chromium/index.js.map +1 -1
  202. package/dist/src/shared/utils/cli-output.d.ts +7 -0
  203. package/dist/src/shared/utils/cli-output.d.ts.map +1 -0
  204. package/dist/src/shared/utils/cli-output.js +7 -0
  205. package/dist/src/shared/utils/cli-output.js.map +1 -0
  206. package/dist/src/tui/app.d.ts.map +1 -1
  207. package/dist/src/tui/app.js +73 -20
  208. package/dist/src/tui/app.js.map +1 -1
  209. package/docs/content/docs/cli/channeltalk.mdx +4 -0
  210. package/docs/content/docs/cli/discord.mdx +5 -0
  211. package/docs/content/docs/cli/instagram.mdx +3 -0
  212. package/docs/content/docs/cli/slack.mdx +5 -0
  213. package/docs/content/docs/cli/slackbot.mdx +60 -22
  214. package/docs/content/docs/cli/teams.mdx +5 -0
  215. package/docs/content/docs/cli/webex.mdx +3 -0
  216. package/docs/content/docs/sdk/channeltalkbot.mdx +38 -1
  217. package/docs/content/docs/sdk/discordbot.mdx +501 -0
  218. package/docs/content/docs/sdk/meta.json +2 -0
  219. package/docs/content/docs/sdk/slackbot.mdx +576 -0
  220. package/e2e/README.md +1 -1
  221. package/e2e/config.ts +9 -4
  222. package/examples/discordbot-listen.ts +65 -0
  223. package/examples/slackbot-listen.ts +65 -0
  224. package/package.json +14 -1
  225. package/skills/agent-channeltalk/SKILL.md +5 -1
  226. package/skills/agent-channeltalk/references/authentication.md +5 -1
  227. package/skills/agent-channeltalkbot/SKILL.md +17 -3
  228. package/skills/agent-channeltalkbot/references/authentication.md +7 -5
  229. package/skills/agent-discord/SKILL.md +5 -1
  230. package/skills/agent-discord/references/authentication.md +7 -1
  231. package/skills/agent-discordbot/SKILL.md +13 -2
  232. package/skills/agent-discordbot/references/common-patterns.md +1 -1
  233. package/skills/agent-instagram/SKILL.md +7 -1
  234. package/skills/agent-instagram/references/authentication.md +6 -0
  235. package/skills/agent-kakaotalk/SKILL.md +1 -1
  236. package/skills/agent-line/SKILL.md +1 -1
  237. package/skills/agent-slack/SKILL.md +5 -1
  238. package/skills/agent-slack/references/authentication.md +7 -1
  239. package/skills/agent-slackbot/SKILL.md +56 -4
  240. package/skills/agent-slackbot/references/authentication.md +4 -0
  241. package/skills/agent-teams/SKILL.md +5 -1
  242. package/skills/agent-teams/references/authentication.md +7 -1
  243. package/skills/agent-telegram/SKILL.md +1 -1
  244. package/skills/agent-webex/SKILL.md +7 -1
  245. package/skills/agent-webex/references/authentication.md +6 -0
  246. package/skills/agent-wechatbot/SKILL.md +16 -1
  247. package/skills/agent-wechatbot/references/authentication.md +219 -0
  248. package/skills/agent-wechatbot/references/common-patterns.md +358 -0
  249. package/skills/agent-wechatbot/templates/account-summary.sh +122 -0
  250. package/skills/agent-wechatbot/templates/post-message.sh +122 -0
  251. package/skills/agent-wechatbot/templates/send-template.sh +152 -0
  252. package/skills/agent-whatsapp/SKILL.md +1 -1
  253. package/skills/agent-whatsappbot/SKILL.md +30 -1
  254. package/src/platforms/channeltalk/commands/auth.test.ts +15 -3
  255. package/src/platforms/channeltalk/commands/auth.ts +15 -5
  256. package/src/platforms/channeltalk/token-extractor.ts +24 -5
  257. package/src/platforms/channeltalkbot/cli.ts +9 -0
  258. package/src/platforms/channeltalkbot/commands/auth.ts +1 -5
  259. package/src/platforms/channeltalkbot/commands/bot.ts +1 -6
  260. package/src/platforms/channeltalkbot/commands/chat.ts +1 -6
  261. package/src/platforms/channeltalkbot/commands/group.ts +1 -6
  262. package/src/platforms/channeltalkbot/commands/manager.ts +1 -6
  263. package/src/platforms/channeltalkbot/commands/message.ts +1 -6
  264. package/src/platforms/channeltalkbot/commands/whoami.test.ts +2 -0
  265. package/src/platforms/channeltalkbot/commands/whoami.ts +1 -6
  266. package/src/platforms/channeltalkbot/credential-manager.test.ts +96 -2
  267. package/src/platforms/channeltalkbot/credential-manager.ts +37 -4
  268. package/src/platforms/discord/commands/auth.ts +13 -2
  269. package/src/platforms/discord/listener.test.ts +59 -1
  270. package/src/platforms/discord/listener.ts +43 -19
  271. package/src/platforms/discord/token-extractor.ts +30 -6
  272. package/src/platforms/discordbot/cli.ts +10 -0
  273. package/src/platforms/discordbot/client.ts +4 -0
  274. package/src/platforms/discordbot/commands/auth.ts +1 -5
  275. package/src/platforms/discordbot/commands/message.ts +1 -6
  276. package/src/platforms/discordbot/commands/server.ts +1 -5
  277. package/src/platforms/discordbot/commands/whoami.ts +1 -6
  278. package/src/platforms/discordbot/index.test.ts +82 -0
  279. package/src/platforms/discordbot/index.ts +27 -9
  280. package/src/platforms/discordbot/listener.test.ts +1002 -0
  281. package/src/platforms/discordbot/listener.ts +321 -0
  282. package/src/platforms/discordbot/types.ts +163 -0
  283. package/src/platforms/instagram/commands/auth.ts +9 -1
  284. package/src/platforms/instagram/token-extractor.ts +13 -1
  285. package/src/platforms/slack/commands/auth.ts +11 -2
  286. package/src/platforms/slack/token-extractor.test.ts +96 -0
  287. package/src/platforms/slack/token-extractor.ts +76 -13
  288. package/src/platforms/slackbot/cli.ts +13 -1
  289. package/src/platforms/slackbot/client.test.ts +274 -0
  290. package/src/platforms/slackbot/client.ts +130 -2
  291. package/src/platforms/slackbot/commands/auth.ts +1 -5
  292. package/src/platforms/slackbot/commands/file.test.ts +201 -0
  293. package/src/platforms/slackbot/commands/file.ts +212 -0
  294. package/src/platforms/slackbot/commands/index.ts +1 -0
  295. package/src/platforms/slackbot/commands/message.ts +22 -0
  296. package/src/platforms/slackbot/commands/whoami.ts +1 -6
  297. package/src/platforms/slackbot/credential-manager.test.ts +62 -2
  298. package/src/platforms/slackbot/credential-manager.ts +32 -2
  299. package/src/platforms/slackbot/index.test.ts +59 -0
  300. package/src/platforms/slackbot/index.ts +31 -7
  301. package/src/platforms/slackbot/listener.test.ts +1012 -0
  302. package/src/platforms/slackbot/listener.ts +362 -0
  303. package/src/platforms/slackbot/types.ts +224 -1
  304. package/src/platforms/teams/commands/auth.test.ts +1 -1
  305. package/src/platforms/teams/commands/auth.ts +66 -7
  306. package/src/platforms/teams/ensure-auth.test.ts +56 -5
  307. package/src/platforms/teams/ensure-auth.ts +39 -11
  308. package/src/platforms/teams/token-extractor.test.ts +146 -24
  309. package/src/platforms/teams/token-extractor.ts +87 -29
  310. package/src/platforms/webex/commands/auth.ts +13 -2
  311. package/src/platforms/webex/token-extractor.ts +25 -3
  312. package/src/platforms/wechatbot/cli.ts +9 -0
  313. package/src/platforms/wechatbot/commands/auth.ts +1 -5
  314. package/src/platforms/wechatbot/commands/message.ts +1 -6
  315. package/src/platforms/wechatbot/commands/template.ts +1 -6
  316. package/src/platforms/wechatbot/commands/user.ts +1 -6
  317. package/src/platforms/wechatbot/commands/whoami.ts +1 -6
  318. package/src/platforms/whatsappbot/cli.ts +9 -0
  319. package/src/platforms/whatsappbot/commands/auth.ts +1 -5
  320. package/src/platforms/whatsappbot/commands/message.ts +1 -6
  321. package/src/platforms/whatsappbot/commands/template.ts +1 -6
  322. package/src/platforms/whatsappbot/commands/whoami.ts +1 -6
  323. package/src/shared/chromium/browsers.test.ts +80 -0
  324. package/src/shared/chromium/browsers.ts +72 -3
  325. package/src/shared/chromium/cli-options.test.ts +22 -0
  326. package/src/shared/chromium/cli-options.ts +12 -0
  327. package/src/shared/chromium/index.ts +3 -0
  328. package/src/shared/utils/cli-output.test.ts +57 -0
  329. package/src/shared/utils/cli-output.ts +8 -0
  330. package/src/tui/app.ts +129 -20
@@ -0,0 +1,501 @@
1
+ ---
2
+ title: Discord Bot
3
+ description: TypeScript SDK reference for Discord Bot — client, real-time Gateway listener, credential management, and types.
4
+ ---
5
+
6
+ ## Installation
7
+
8
+ ```bash
9
+ npm install agent-messenger
10
+ ```
11
+
12
+ ```typescript
13
+ import {
14
+ DiscordBotClient,
15
+ DiscordBotCredentialManager,
16
+ DiscordBotError,
17
+ DiscordBotListener,
18
+ } from 'agent-messenger/discordbot'
19
+ ```
20
+
21
+ ## DiscordBotClient
22
+
23
+ The main client for interacting with Discord's REST API using a bot token. All methods include automatic rate-limit handling with per-bucket and global rate-limit tracking.
24
+
25
+ ```typescript
26
+ import { DiscordBotClient } from 'agent-messenger/discordbot'
27
+
28
+ const client = await new DiscordBotClient().login({ token: 'YOUR_BOT_TOKEN' })
29
+ ```
30
+
31
+ Or use stored credentials — credentials are read from `~/.config/agent-messenger/discordbot-credentials.json` (managed by `agent-discordbot auth set`):
32
+
33
+ ```typescript
34
+ const client = await new DiscordBotClient().login()
35
+ ```
36
+
37
+ ### Authentication
38
+
39
+ ```typescript
40
+ // Verify bot credentials and get the bot's identity
41
+ const me = await client.testAuth()
42
+ // → DiscordUser { id, username, global_name?, avatar?, bot? }
43
+ ```
44
+
45
+ ### Servers (Guilds)
46
+
47
+ ```typescript
48
+ // List all servers the bot has been added to
49
+ const guilds = await client.listGuilds()
50
+ // → DiscordGuild[]
51
+
52
+ // Get a specific server by ID
53
+ const guild = await client.getGuild(guildId)
54
+ // → DiscordGuild { id, name, icon?, owner? }
55
+ ```
56
+
57
+ ### Channels
58
+
59
+ ```typescript
60
+ // List all channels in a server
61
+ const channels = await client.listChannels(guildId)
62
+ // → DiscordChannel[]
63
+
64
+ // Get a specific channel by ID
65
+ const channel = await client.getChannel(channelId)
66
+ // → DiscordChannel { id, guild_id, name, type, topic?, position?, parent_id?, thread_metadata? }
67
+
68
+ // Resolve a channel by name or ID — returns the channel ID
69
+ const channelId = await client.resolveChannel(guildId, '#general')
70
+ const sameId = await client.resolveChannel(guildId, '1234567890123456789')
71
+ ```
72
+
73
+ ### Messages
74
+
75
+ ```typescript
76
+ // Send a message to a channel
77
+ const msg = await client.sendMessage(channelId, 'Hello world')
78
+
79
+ // Send a message in a thread
80
+ const reply = await client.sendMessage(channelId, 'Reply', { thread_id: threadId })
81
+ // → DiscordMessage { id, channel_id, author, content, timestamp }
82
+
83
+ // Get recent messages from a channel (default limit: 50)
84
+ const messages = await client.getMessages(channelId)
85
+ const limited = await client.getMessages(channelId, 25)
86
+ // → DiscordMessage[]
87
+
88
+ // Get a single message by ID
89
+ const message = await client.getMessage(channelId, messageId)
90
+ // → DiscordMessage
91
+
92
+ // Edit a message (bot can only edit its own messages)
93
+ const edited = await client.editMessage(channelId, messageId, 'Updated content')
94
+ // → DiscordMessage
95
+
96
+ // Delete a message (bot can delete its own messages or any with Manage Messages permission)
97
+ await client.deleteMessage(channelId, messageId)
98
+ ```
99
+
100
+ ### Reactions
101
+
102
+ ```typescript
103
+ // Add a reaction (use a standard emoji or `name:id` for custom emojis)
104
+ await client.addReaction(channelId, messageId, '👍')
105
+ await client.addReaction(channelId, messageId, 'custom_emoji_name:123456789')
106
+
107
+ // Remove the bot's own reaction
108
+ await client.removeReaction(channelId, messageId, '👍')
109
+ ```
110
+
111
+ ### Users
112
+
113
+ ```typescript
114
+ // List members in a server (up to 1000 at a time)
115
+ const users = await client.listUsers(guildId)
116
+ // → DiscordUser[]
117
+
118
+ // Get a user by ID
119
+ const user = await client.getUser(userId)
120
+ // → DiscordUser { id, username, global_name?, avatar?, bot? }
121
+ ```
122
+
123
+ ### Files
124
+
125
+ ```typescript
126
+ // Upload a file to a channel (by file path)
127
+ const file = await client.uploadFile(channelId, '/path/to/report.pdf')
128
+ // → DiscordFile { id, filename, size, url, content_type?, height?, width? }
129
+
130
+ // List file attachments from recent messages in a channel
131
+ const files = await client.listFiles(channelId)
132
+ // → DiscordFile[]
133
+ ```
134
+
135
+ ### Threads
136
+
137
+ ```typescript
138
+ // Create a thread in a channel
139
+ const thread = await client.createThread(channelId, 'Bug Report: Login Issue')
140
+ const configured = await client.createThread(channelId, 'Design Review', {
141
+ auto_archive_duration: 1440, // minutes: 60, 1440, 4320, or 10080
142
+ rate_limit_per_user: 5, // seconds between messages (slow mode)
143
+ })
144
+ // → DiscordChannel (with thread_metadata)
145
+
146
+ // Archive (or unarchive) a thread
147
+ await client.archiveThread(threadId)
148
+ await client.archiveThread(threadId, false) // unarchive
149
+ // → DiscordChannel
150
+ ```
151
+
152
+ ## Real-Time Events
153
+
154
+ `DiscordBotListener` connects to Discord's [Gateway WebSocket](https://discord.com/developers/docs/topics/gateway) for instant event streaming — messages, reactions, slash command interactions, member changes, and more. No webhook server required.
155
+
156
+ ```typescript
157
+ import { DiscordBotClient, DiscordBotListener } from 'agent-messenger/discordbot'
158
+
159
+ const client = await new DiscordBotClient().login({ token })
160
+ const listener = new DiscordBotListener(client)
161
+
162
+ listener.on('connected', (info) => {
163
+ console.log(`Connected as ${info.user.username} (session ${info.sessionId})`)
164
+ })
165
+
166
+ listener.on('message_create', (event) => {
167
+ if (event.author.bot) return
168
+ console.log(`#${event.channel_id} <${event.author.username}>: ${event.content}`)
169
+ })
170
+
171
+ listener.on('interaction_create', (event) => {
172
+ console.log(`Slash command: ${(event.data as { name?: string } | undefined)?.name}`)
173
+ })
174
+
175
+ listener.on('error', (err) => console.error(err))
176
+
177
+ await listener.start() // connects via Gateway WebSocket
178
+ // listener.stop() // clean shutdown
179
+ ```
180
+
181
+ ### Intents
182
+
183
+ Discord Gateway requires [intents](https://discord.com/developers/docs/topics/gateway#gateway-intents) — a bitfield that opts the bot into specific event categories. The default set includes safe, non-privileged intents for messages, reactions, and typing in guilds and DMs.
184
+
185
+ To customize intents, pass `DiscordIntent` flags:
186
+
187
+ ```typescript
188
+ import { DiscordIntent } from 'agent-messenger/discordbot'
189
+
190
+ const listener = new DiscordBotListener(client, {
191
+ intents:
192
+ DiscordIntent.Guilds |
193
+ DiscordIntent.GuildMessages |
194
+ DiscordIntent.GuildMessageReactions |
195
+ DiscordIntent.DirectMessages |
196
+ DiscordIntent.MessageContent, // privileged — must enable in Developer Portal
197
+ })
198
+ ```
199
+
200
+ > **Privileged intents** (`MessageContent`, `GuildMembers`, `GuildPresences`) must be explicitly enabled in the [Discord Developer Portal](https://discord.com/developers/applications) under your bot's settings before they can be requested. Connecting with a privileged intent that is not enabled will close the Gateway with code `4014`.
201
+ >
202
+ > Without `MessageContent`, the `content` field on `message_create` events will be empty for messages that don't mention the bot or arrive in DMs.
203
+
204
+ ### Available Events
205
+
206
+ | Event | Description |
207
+ | ------------------------------------------------------ | --------------------------------------------------- |
208
+ | `message_create` | New message in a guild channel or DM |
209
+ | `message_update` | Message content edited |
210
+ | `message_delete` | Message deleted |
211
+ | `message_reaction_add` / `message_reaction_remove` | Reaction added or removed |
212
+ | `guild_member_add` / `guild_member_remove` | Member joins or leaves a server |
213
+ | `presence_update` | User status changed (requires `GuildPresences`) |
214
+ | `typing_start` | Typing indicator |
215
+ | `channel_create` / `channel_update` / `channel_delete` | Channel lifecycle |
216
+ | `guild_create` / `guild_update` / `guild_delete` | Bot added to / updated in / removed from a server |
217
+ | `interaction_create` | Slash command, button, modal, or context menu fired |
218
+ | `discord_event` | Catch-all — fires for every Gateway dispatch |
219
+ | `connected` / `disconnected` | Connection lifecycle |
220
+ | `error` | Connection or protocol error |
221
+
222
+ ### Lifecycle Features
223
+
224
+ - **Auto-reconnect** with exponential backoff (1s → 30s, capped) and jitter on heartbeats.
225
+ - **Session resume** — reconnects use Discord's `resume_gateway_url` to replay missed events without re-identifying.
226
+ - **Heartbeat keepalive** with zombie connection detection — if Discord doesn't acknowledge a heartbeat, the connection is closed and re-established.
227
+ - **Non-recoverable close detection** — connections close cleanly on close codes `4004` (invalid token), `4010`–`4014` (sharding/intents misconfiguration). The listener emits `error` and stops.
228
+ - **Session reset** on close codes `4007` (invalid sequence) and `4009` (session timed out) — clears local session state and reconnects fresh.
229
+ - **Stale-socket safety** — every async callback is generation-guarded so a stop+start cycle cannot leave the new connection in a broken state.
230
+
231
+ ## DiscordBotCredentialManager
232
+
233
+ Manages bot credentials stored at `~/.config/agent-messenger/discordbot-credentials.json` with `0o600` permissions. Supports multiple bot identities (e.g., a deploy bot and an alerts bot in the same config). The environment variables `E2E_DISCORDBOT_TOKEN`, `E2E_DISCORDBOT_SERVER_ID`, and `E2E_DISCORDBOT_SERVER_NAME` take precedence over file-based credentials.
234
+
235
+ ```typescript
236
+ import { DiscordBotCredentialManager } from 'agent-messenger/discordbot'
237
+
238
+ const manager = new DiscordBotCredentialManager()
239
+ // Custom path: new DiscordBotCredentialManager('/custom/config/dir')
240
+ ```
241
+
242
+ ```typescript
243
+ // Load full config from disk (returns defaults if file doesn't exist)
244
+ const config = await manager.load()
245
+ // → DiscordBotConfig { current, bots, current_server, servers }
246
+
247
+ // Save full config to disk
248
+ await manager.save(config)
249
+
250
+ // Get the credentials for the current bot (or a specific bot ID)
251
+ const creds = await manager.getCredentials()
252
+ const specific = await manager.getCredentials('deploy')
253
+ // → DiscordBotCredentials | null
254
+
255
+ // Store credentials for a bot (also marks it as current)
256
+ await manager.setCredentials({
257
+ token: 'YOUR_BOT_TOKEN',
258
+ bot_id: 'deploy',
259
+ bot_name: 'Deploy Bot',
260
+ })
261
+
262
+ // Switch the active bot
263
+ await manager.setCurrent('alerts')
264
+
265
+ // List all stored bots with current marker
266
+ const bots = await manager.listAll()
267
+ // → Array<DiscordBotCredentials & { is_current: boolean }>
268
+
269
+ // Remove a stored bot
270
+ await manager.removeBot('alerts')
271
+
272
+ // Clear all stored credentials
273
+ await manager.clearCredentials()
274
+
275
+ // Server preference helpers
276
+ const serverId = await manager.getCurrentServer()
277
+ await manager.setCurrentServer('1234567890123456789', 'My Server')
278
+ ```
279
+
280
+ ## Types
281
+
282
+ ```typescript
283
+ import type {
284
+ DiscordBotConfig,
285
+ DiscordBotCredentials,
286
+ DiscordBotEntry,
287
+ DiscordBotListenerEventMap,
288
+ DiscordChannel,
289
+ DiscordFile,
290
+ DiscordGatewayChannelEvent,
291
+ DiscordGatewayEvent,
292
+ DiscordGatewayGenericEvent,
293
+ DiscordGatewayGuildEvent,
294
+ DiscordGatewayInteractionEvent,
295
+ DiscordGatewayMemberEvent,
296
+ DiscordGatewayMessageCreateEvent,
297
+ DiscordGatewayMessageDeleteEvent,
298
+ DiscordGatewayMessageUpdateEvent,
299
+ DiscordGatewayPresenceEvent,
300
+ DiscordGatewayReactionEvent,
301
+ DiscordGatewayTypingEvent,
302
+ DiscordGuild,
303
+ DiscordMessage,
304
+ DiscordReaction,
305
+ DiscordUser,
306
+ } from 'agent-messenger/discordbot'
307
+ ```
308
+
309
+ ### Zod Schemas
310
+
311
+ Runtime-validated schemas for parsing API responses:
312
+
313
+ ```typescript
314
+ import {
315
+ DiscordBotConfigSchema,
316
+ DiscordBotCredentialsSchema,
317
+ DiscordBotEntrySchema,
318
+ DiscordChannelSchema,
319
+ DiscordFileSchema,
320
+ DiscordGuildSchema,
321
+ DiscordMessageSchema,
322
+ DiscordReactionSchema,
323
+ DiscordUserSchema,
324
+ } from 'agent-messenger/discordbot'
325
+ ```
326
+
327
+ ### Constants
328
+
329
+ ```typescript
330
+ import { DiscordGatewayOpcode, DiscordIntent } from 'agent-messenger/discordbot'
331
+
332
+ DiscordGatewayOpcode.Identify // 2
333
+ DiscordGatewayOpcode.Hello // 10
334
+
335
+ DiscordIntent.Guilds // 1
336
+ DiscordIntent.GuildMessages // 1 << 9
337
+ DiscordIntent.MessageContent // 1 << 15 (privileged)
338
+ ```
339
+
340
+ ## DiscordBotError
341
+
342
+ All client methods throw `DiscordBotError` on failure. The error includes a `code` field describing the failure category — useful for retry logic and structured error reporting.
343
+
344
+ ```typescript
345
+ import { DiscordBotClient, DiscordBotError } from 'agent-messenger/discordbot'
346
+
347
+ const client = await new DiscordBotClient().login({ token: 'YOUR_BOT_TOKEN' })
348
+
349
+ try {
350
+ await client.sendMessage('1234567890123456789', 'Hello!')
351
+ } catch (err) {
352
+ if (err instanceof DiscordBotError) {
353
+ console.error(`[${err.code}] ${err.message}`)
354
+
355
+ if (err.code === 'rate_limited') {
356
+ // Discord returned 429 — back off and retry
357
+ } else if (err.code === 'missing_token' || err.code === 'no_credentials') {
358
+ // Token is missing — re-run auth set
359
+ }
360
+ } else {
361
+ throw err
362
+ }
363
+ }
364
+ ```
365
+
366
+ Error codes thrown by the client:
367
+
368
+ - `missing_token` — `login()` called with an empty token
369
+ - `no_credentials` — `login()` called without args and no stored bot token was found
370
+ - `not_authenticated` — Method called before `login()` resolved
371
+ - `rate_limited` — Discord 429 response; the client retries automatically with `Retry-After`, then surfaces this if retries are exhausted
372
+ - `network_error` — Fetch failed (DNS, connection refused, timeout)
373
+ - `channel_not_found` — `resolveChannel()` could not find the named channel in the current guild
374
+ - `no_attachments` — File upload returned 200 but the response had no attachments
375
+ - `http_<status>` — Discord returned an unexpected status (e.g., `http_500`) without a structured `code` in the error body
376
+ - Discord API error codes (numeric, as strings) — When Discord's response body includes a `code` field (e.g., `"50001"` for "Missing Access"), it is propagated as-is. See the [Discord JSON Error Codes reference](https://discord.com/developers/docs/topics/opcodes-and-status-codes#json-json-error-codes).
377
+
378
+ ## Examples
379
+
380
+ ### Auto-Reply Bot
381
+
382
+ Listen for messages mentioning the bot and reply with a help message.
383
+
384
+ ```typescript
385
+ import { DiscordBotClient, DiscordBotListener, DiscordIntent } from 'agent-messenger/discordbot'
386
+
387
+ const client = await new DiscordBotClient().login({ token })
388
+ const me = await client.testAuth()
389
+
390
+ const listener = new DiscordBotListener(client, {
391
+ intents:
392
+ DiscordIntent.Guilds | DiscordIntent.GuildMessages | DiscordIntent.DirectMessages | DiscordIntent.MessageContent,
393
+ })
394
+
395
+ listener.on('message_create', async (event) => {
396
+ if (event.author.bot) return
397
+
398
+ const mentioned = event.content.includes(`<@${me.id}>`)
399
+ if (!mentioned) return
400
+
401
+ await client.sendMessage(event.channel_id, `👋 Hey <@${event.author.id}>! Try \`/help\` for a list of commands.`)
402
+ })
403
+
404
+ await listener.start()
405
+ ```
406
+
407
+ ### Reaction-Driven Approval Workflow
408
+
409
+ Post a request, then watch for ✅ or ❌ reactions to advance state.
410
+
411
+ ```typescript
412
+ import { DiscordBotClient, DiscordBotListener } from 'agent-messenger/discordbot'
413
+
414
+ const client = await new DiscordBotClient().login({ token })
415
+ const listener = new DiscordBotListener(client)
416
+
417
+ const post = await client.sendMessage(channelId, '🚀 Deploy v2.1.0 to production?')
418
+ await client.addReaction(channelId, post.id, '✅')
419
+ await client.addReaction(channelId, post.id, '❌')
420
+
421
+ listener.on('message_reaction_add', async (event) => {
422
+ if (event.message_id !== post.id) return
423
+ if (event.user_id === me.id) return
424
+
425
+ if (event.emoji.name === '✅') {
426
+ await client.editMessage(channelId, post.id, '🚀 Deploy v2.1.0 — **approved**')
427
+ } else if (event.emoji.name === '❌') {
428
+ await client.editMessage(channelId, post.id, '🚀 Deploy v2.1.0 — **rejected**')
429
+ }
430
+ })
431
+
432
+ await listener.start()
433
+ ```
434
+
435
+ ### Slash Command Handler
436
+
437
+ React to slash command interactions in real time. (The bot must register slash commands separately via Discord's REST API.)
438
+
439
+ ```typescript
440
+ import { DiscordBotClient, DiscordBotListener } from 'agent-messenger/discordbot'
441
+
442
+ const client = await new DiscordBotClient().login({ token })
443
+ const listener = new DiscordBotListener(client)
444
+
445
+ listener.on('interaction_create', async (event) => {
446
+ const name = (event.data as { name?: string } | undefined)?.name
447
+ if (name !== 'ping') return
448
+
449
+ if (event.channel_id) {
450
+ await client.sendMessage(event.channel_id, '🏓 Pong!')
451
+ }
452
+ })
453
+
454
+ await listener.start()
455
+ ```
456
+
457
+ ### CI Status Notifier
458
+
459
+ Post a status message at the start and finish of a CI job, with a reaction to indicate state.
460
+
461
+ ```typescript
462
+ import { DiscordBotClient } from 'agent-messenger/discordbot'
463
+
464
+ const client = await new DiscordBotClient().login({ token })
465
+
466
+ const start = await client.sendMessage(channelId, `🛠️ Build #${runId} started`)
467
+ await client.addReaction(channelId, start.id, '⏳')
468
+
469
+ try {
470
+ await runBuild()
471
+ await client.removeReaction(channelId, start.id, '⏳')
472
+ await client.addReaction(channelId, start.id, '✅')
473
+ await client.sendMessage(channelId, `✅ Build #${runId} succeeded`)
474
+ } catch (err) {
475
+ await client.removeReaction(channelId, start.id, '⏳')
476
+ await client.addReaction(channelId, start.id, '❌')
477
+ await client.sendMessage(channelId, `❌ Build #${runId} failed: ${(err as Error).message}`)
478
+ throw err
479
+ }
480
+ ```
481
+
482
+ ### Multi-Bot Configuration
483
+
484
+ Use `DiscordBotCredentialManager` to switch between multiple bots stored in the same config (e.g., separate deploy and alerts bots).
485
+
486
+ ```typescript
487
+ import { DiscordBotClient, DiscordBotCredentialManager } from 'agent-messenger/discordbot'
488
+
489
+ const manager = new DiscordBotCredentialManager()
490
+
491
+ // Store credentials for two bots
492
+ await manager.setCredentials({ token: 'TOKEN_A', bot_id: 'deploy', bot_name: 'Deploy Bot' })
493
+ await manager.setCredentials({ token: 'TOKEN_B', bot_id: 'alerts', bot_name: 'Alerts Bot' })
494
+
495
+ // Switch to the alerts bot and use it
496
+ await manager.setCurrent('alerts')
497
+ const creds = await manager.getCredentials()
498
+ const client = await new DiscordBotClient().login({ token: creds!.token })
499
+
500
+ await client.sendMessage(channelId, '🚨 Error rate above threshold')
501
+ ```
@@ -2,7 +2,9 @@
2
2
  "title": "TypeScript SDK",
3
3
  "pages": [
4
4
  "slack",
5
+ "slackbot",
5
6
  "discord",
7
+ "discordbot",
6
8
  "teams",
7
9
  "webex",
8
10
  "whatsapp",