agent-messenger 2.3.0 → 2.5.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 (438) hide show
  1. package/.claude-plugin/README.md +16 -16
  2. package/.claude-plugin/marketplace.json +29 -29
  3. package/.claude-plugin/plugin.json +5 -5
  4. package/.github/workflows/release.yml +0 -12
  5. package/CONTRIBUTING.md +1 -1
  6. package/README.md +11 -8
  7. package/bun.lock +70 -110
  8. package/bunfig.toml +3 -0
  9. package/dist/package.json +11 -3
  10. package/dist/src/platforms/channeltalk/cli.d.ts.map +1 -1
  11. package/dist/src/platforms/channeltalk/cli.js +2 -1
  12. package/dist/src/platforms/channeltalk/cli.js.map +1 -1
  13. package/dist/src/platforms/channeltalk/commands/index.d.ts +1 -0
  14. package/dist/src/platforms/channeltalk/commands/index.d.ts.map +1 -1
  15. package/dist/src/platforms/channeltalk/commands/index.js +1 -0
  16. package/dist/src/platforms/channeltalk/commands/index.js.map +1 -1
  17. package/dist/src/platforms/channeltalk/commands/whoami.d.ts +22 -0
  18. package/dist/src/platforms/channeltalk/commands/whoami.d.ts.map +1 -0
  19. package/dist/src/platforms/channeltalk/commands/whoami.js +40 -0
  20. package/dist/src/platforms/channeltalk/commands/whoami.js.map +1 -0
  21. package/dist/src/platforms/channeltalkbot/cli.d.ts.map +1 -1
  22. package/dist/src/platforms/channeltalkbot/cli.js +2 -1
  23. package/dist/src/platforms/channeltalkbot/cli.js.map +1 -1
  24. package/dist/src/platforms/channeltalkbot/commands/index.d.ts +1 -0
  25. package/dist/src/platforms/channeltalkbot/commands/index.d.ts.map +1 -1
  26. package/dist/src/platforms/channeltalkbot/commands/index.js +1 -0
  27. package/dist/src/platforms/channeltalkbot/commands/index.js.map +1 -1
  28. package/dist/src/platforms/channeltalkbot/commands/whoami.d.ts +13 -0
  29. package/dist/src/platforms/channeltalkbot/commands/whoami.d.ts.map +1 -0
  30. package/dist/src/platforms/channeltalkbot/commands/whoami.js +31 -0
  31. package/dist/src/platforms/channeltalkbot/commands/whoami.js.map +1 -0
  32. package/dist/src/platforms/discord/cli.d.ts.map +1 -1
  33. package/dist/src/platforms/discord/cli.js +2 -1
  34. package/dist/src/platforms/discord/cli.js.map +1 -1
  35. package/dist/src/platforms/discord/commands/index.d.ts +1 -0
  36. package/dist/src/platforms/discord/commands/index.d.ts.map +1 -1
  37. package/dist/src/platforms/discord/commands/index.js +1 -0
  38. package/dist/src/platforms/discord/commands/index.js.map +1 -1
  39. package/dist/src/platforms/discord/commands/whoami.d.ts +6 -0
  40. package/dist/src/platforms/discord/commands/whoami.d.ts.map +1 -0
  41. package/dist/src/platforms/discord/commands/whoami.js +33 -0
  42. package/dist/src/platforms/discord/commands/whoami.js.map +1 -0
  43. package/dist/src/platforms/discordbot/cli.d.ts.map +1 -1
  44. package/dist/src/platforms/discordbot/cli.js +2 -1
  45. package/dist/src/platforms/discordbot/cli.js.map +1 -1
  46. package/dist/src/platforms/discordbot/client.js +2 -2
  47. package/dist/src/platforms/discordbot/client.js.map +1 -1
  48. package/dist/src/platforms/discordbot/commands/index.d.ts +1 -0
  49. package/dist/src/platforms/discordbot/commands/index.d.ts.map +1 -1
  50. package/dist/src/platforms/discordbot/commands/index.js +1 -0
  51. package/dist/src/platforms/discordbot/commands/index.js.map +1 -1
  52. package/dist/src/platforms/discordbot/commands/whoami.d.ts +14 -0
  53. package/dist/src/platforms/discordbot/commands/whoami.d.ts.map +1 -0
  54. package/dist/src/platforms/discordbot/commands/whoami.js +32 -0
  55. package/dist/src/platforms/discordbot/commands/whoami.js.map +1 -0
  56. package/dist/src/platforms/instagram/cli.d.ts.map +1 -1
  57. package/dist/src/platforms/instagram/cli.js +2 -1
  58. package/dist/src/platforms/instagram/cli.js.map +1 -1
  59. package/dist/src/platforms/instagram/client.d.ts +6 -0
  60. package/dist/src/platforms/instagram/client.d.ts.map +1 -1
  61. package/dist/src/platforms/instagram/client.js +12 -0
  62. package/dist/src/platforms/instagram/client.js.map +1 -1
  63. package/dist/src/platforms/instagram/commands/index.d.ts +1 -0
  64. package/dist/src/platforms/instagram/commands/index.d.ts.map +1 -1
  65. package/dist/src/platforms/instagram/commands/index.js +1 -0
  66. package/dist/src/platforms/instagram/commands/index.js.map +1 -1
  67. package/dist/src/platforms/instagram/commands/whoami.d.ts +7 -0
  68. package/dist/src/platforms/instagram/commands/whoami.d.ts.map +1 -0
  69. package/dist/src/platforms/instagram/commands/whoami.js +19 -0
  70. package/dist/src/platforms/instagram/commands/whoami.js.map +1 -0
  71. package/dist/src/platforms/kakaotalk/cli.d.ts.map +1 -1
  72. package/dist/src/platforms/kakaotalk/cli.js +2 -1
  73. package/dist/src/platforms/kakaotalk/cli.js.map +1 -1
  74. package/dist/src/platforms/kakaotalk/client.d.ts +2 -1
  75. package/dist/src/platforms/kakaotalk/client.d.ts.map +1 -1
  76. package/dist/src/platforms/kakaotalk/client.js +225 -23
  77. package/dist/src/platforms/kakaotalk/client.js.map +1 -1
  78. package/dist/src/platforms/kakaotalk/commands/index.d.ts +1 -0
  79. package/dist/src/platforms/kakaotalk/commands/index.d.ts.map +1 -1
  80. package/dist/src/platforms/kakaotalk/commands/index.js +1 -0
  81. package/dist/src/platforms/kakaotalk/commands/index.js.map +1 -1
  82. package/dist/src/platforms/kakaotalk/commands/whoami.d.ts +3 -0
  83. package/dist/src/platforms/kakaotalk/commands/whoami.d.ts.map +1 -0
  84. package/dist/src/platforms/kakaotalk/commands/whoami.js +19 -0
  85. package/dist/src/platforms/kakaotalk/commands/whoami.js.map +1 -0
  86. package/dist/src/platforms/kakaotalk/index.d.ts +2 -2
  87. package/dist/src/platforms/kakaotalk/index.d.ts.map +1 -1
  88. package/dist/src/platforms/kakaotalk/index.js +1 -1
  89. package/dist/src/platforms/kakaotalk/index.js.map +1 -1
  90. package/dist/src/platforms/kakaotalk/protocol/session.d.ts +4 -2
  91. package/dist/src/platforms/kakaotalk/protocol/session.d.ts.map +1 -1
  92. package/dist/src/platforms/kakaotalk/protocol/session.js +27 -7
  93. package/dist/src/platforms/kakaotalk/protocol/session.js.map +1 -1
  94. package/dist/src/platforms/kakaotalk/protocol/types.d.ts +17 -0
  95. package/dist/src/platforms/kakaotalk/protocol/types.d.ts.map +1 -1
  96. package/dist/src/platforms/kakaotalk/protocol/types.js.map +1 -1
  97. package/dist/src/platforms/kakaotalk/types.d.ts +28 -0
  98. package/dist/src/platforms/kakaotalk/types.d.ts.map +1 -1
  99. package/dist/src/platforms/kakaotalk/types.js +14 -0
  100. package/dist/src/platforms/kakaotalk/types.js.map +1 -1
  101. package/dist/src/platforms/line/cli.js +2 -2
  102. package/dist/src/platforms/line/cli.js.map +1 -1
  103. package/dist/src/platforms/line/client.d.ts.map +1 -1
  104. package/dist/src/platforms/line/client.js +9 -36
  105. package/dist/src/platforms/line/client.js.map +1 -1
  106. package/dist/src/platforms/line/commands/auth.d.ts.map +1 -1
  107. package/dist/src/platforms/line/commands/auth.js +9 -47
  108. package/dist/src/platforms/line/commands/auth.js.map +1 -1
  109. package/dist/src/platforms/line/commands/index.d.ts +1 -1
  110. package/dist/src/platforms/line/commands/index.d.ts.map +1 -1
  111. package/dist/src/platforms/line/commands/index.js +1 -1
  112. package/dist/src/platforms/line/commands/index.js.map +1 -1
  113. package/dist/src/platforms/line/commands/whoami.d.ts +3 -0
  114. package/dist/src/platforms/line/commands/whoami.d.ts.map +1 -0
  115. package/dist/src/platforms/line/commands/{profile.js → whoami.js} +5 -5
  116. package/dist/src/platforms/line/commands/whoami.js.map +1 -0
  117. package/dist/src/platforms/slack/cli.d.ts.map +1 -1
  118. package/dist/src/platforms/slack/cli.js +2 -1
  119. package/dist/src/platforms/slack/cli.js.map +1 -1
  120. package/dist/src/platforms/slack/commands/index.d.ts +1 -0
  121. package/dist/src/platforms/slack/commands/index.d.ts.map +1 -1
  122. package/dist/src/platforms/slack/commands/index.js +1 -0
  123. package/dist/src/platforms/slack/commands/index.js.map +1 -1
  124. package/dist/src/platforms/slack/commands/whoami.d.ts +6 -0
  125. package/dist/src/platforms/slack/commands/whoami.d.ts.map +1 -0
  126. package/dist/src/platforms/slack/commands/whoami.js +39 -0
  127. package/dist/src/platforms/slack/commands/whoami.js.map +1 -0
  128. package/dist/src/platforms/slackbot/cli.d.ts.map +1 -1
  129. package/dist/src/platforms/slackbot/cli.js +2 -1
  130. package/dist/src/platforms/slackbot/cli.js.map +1 -1
  131. package/dist/src/platforms/slackbot/commands/index.d.ts +1 -0
  132. package/dist/src/platforms/slackbot/commands/index.d.ts.map +1 -1
  133. package/dist/src/platforms/slackbot/commands/index.js +1 -0
  134. package/dist/src/platforms/slackbot/commands/index.js.map +1 -1
  135. package/dist/src/platforms/slackbot/commands/whoami.d.ts +14 -0
  136. package/dist/src/platforms/slackbot/commands/whoami.d.ts.map +1 -0
  137. package/dist/src/platforms/slackbot/commands/whoami.js +32 -0
  138. package/dist/src/platforms/slackbot/commands/whoami.js.map +1 -0
  139. package/dist/src/platforms/teams/cli.d.ts.map +1 -1
  140. package/dist/src/platforms/teams/cli.js +2 -1
  141. package/dist/src/platforms/teams/cli.js.map +1 -1
  142. package/dist/src/platforms/teams/commands/index.d.ts +1 -0
  143. package/dist/src/platforms/teams/commands/index.d.ts.map +1 -1
  144. package/dist/src/platforms/teams/commands/index.js +1 -0
  145. package/dist/src/platforms/teams/commands/index.js.map +1 -1
  146. package/dist/src/platforms/teams/commands/reaction.d.ts.map +1 -1
  147. package/dist/src/platforms/teams/commands/reaction.js +2 -0
  148. package/dist/src/platforms/teams/commands/reaction.js.map +1 -1
  149. package/dist/src/platforms/teams/commands/whoami.d.ts +6 -0
  150. package/dist/src/platforms/teams/commands/whoami.d.ts.map +1 -0
  151. package/dist/src/platforms/teams/commands/whoami.js +30 -0
  152. package/dist/src/platforms/teams/commands/whoami.js.map +1 -0
  153. package/dist/src/platforms/telegram/cli.d.ts.map +1 -1
  154. package/dist/src/platforms/telegram/cli.js +2 -1
  155. package/dist/src/platforms/telegram/cli.js.map +1 -1
  156. package/dist/src/platforms/telegram/commands/index.d.ts +1 -0
  157. package/dist/src/platforms/telegram/commands/index.d.ts.map +1 -1
  158. package/dist/src/platforms/telegram/commands/index.js +1 -0
  159. package/dist/src/platforms/telegram/commands/index.js.map +1 -1
  160. package/dist/src/platforms/telegram/commands/whoami.d.ts +7 -0
  161. package/dist/src/platforms/telegram/commands/whoami.d.ts.map +1 -0
  162. package/dist/src/platforms/telegram/commands/whoami.js +27 -0
  163. package/dist/src/platforms/telegram/commands/whoami.js.map +1 -0
  164. package/dist/src/platforms/webex/cli.d.ts.map +1 -1
  165. package/dist/src/platforms/webex/cli.js +2 -1
  166. package/dist/src/platforms/webex/cli.js.map +1 -1
  167. package/dist/src/platforms/webex/commands/index.d.ts +1 -0
  168. package/dist/src/platforms/webex/commands/index.d.ts.map +1 -1
  169. package/dist/src/platforms/webex/commands/index.js +1 -0
  170. package/dist/src/platforms/webex/commands/index.js.map +1 -1
  171. package/dist/src/platforms/webex/commands/message.js +1 -1
  172. package/dist/src/platforms/webex/commands/message.js.map +1 -1
  173. package/dist/src/platforms/webex/commands/whoami.d.ts +6 -0
  174. package/dist/src/platforms/webex/commands/whoami.d.ts.map +1 -0
  175. package/dist/src/platforms/webex/commands/whoami.js +30 -0
  176. package/dist/src/platforms/webex/commands/whoami.js.map +1 -0
  177. package/dist/src/platforms/wechatbot/cli.d.ts +5 -0
  178. package/dist/src/platforms/wechatbot/cli.d.ts.map +1 -0
  179. package/dist/src/platforms/wechatbot/cli.js +19 -0
  180. package/dist/src/platforms/wechatbot/cli.js.map +1 -0
  181. package/dist/src/platforms/wechatbot/client.d.ts +36 -0
  182. package/dist/src/platforms/wechatbot/client.d.ts.map +1 -0
  183. package/dist/src/platforms/wechatbot/client.js +208 -0
  184. package/dist/src/platforms/wechatbot/client.js.map +1 -0
  185. package/dist/src/platforms/wechatbot/commands/auth.d.ts +28 -0
  186. package/dist/src/platforms/wechatbot/commands/auth.d.ts.map +1 -0
  187. package/dist/src/platforms/wechatbot/commands/auth.js +164 -0
  188. package/dist/src/platforms/wechatbot/commands/auth.js.map +1 -0
  189. package/dist/src/platforms/wechatbot/commands/index.d.ts +6 -0
  190. package/dist/src/platforms/wechatbot/commands/index.d.ts.map +1 -0
  191. package/dist/src/platforms/wechatbot/commands/index.js +6 -0
  192. package/dist/src/platforms/wechatbot/commands/index.js.map +1 -0
  193. package/dist/src/platforms/wechatbot/commands/message.d.ts +18 -0
  194. package/dist/src/platforms/wechatbot/commands/message.d.ts.map +1 -0
  195. package/dist/src/platforms/wechatbot/commands/message.js +80 -0
  196. package/dist/src/platforms/wechatbot/commands/message.js.map +1 -0
  197. package/dist/src/platforms/wechatbot/commands/shared.d.ts +9 -0
  198. package/dist/src/platforms/wechatbot/commands/shared.d.ts.map +1 -0
  199. package/dist/src/platforms/wechatbot/commands/shared.js +13 -0
  200. package/dist/src/platforms/wechatbot/commands/shared.js.map +1 -0
  201. package/dist/src/platforms/wechatbot/commands/template.d.ts +19 -0
  202. package/dist/src/platforms/wechatbot/commands/template.d.ts.map +1 -0
  203. package/dist/src/platforms/wechatbot/commands/template.js +76 -0
  204. package/dist/src/platforms/wechatbot/commands/template.js.map +1 -0
  205. package/dist/src/platforms/wechatbot/commands/user.d.ts +20 -0
  206. package/dist/src/platforms/wechatbot/commands/user.d.ts.map +1 -0
  207. package/dist/src/platforms/wechatbot/commands/user.js +53 -0
  208. package/dist/src/platforms/wechatbot/commands/user.js.map +1 -0
  209. package/dist/src/platforms/wechatbot/commands/whoami.d.ts +12 -0
  210. package/dist/src/platforms/wechatbot/commands/whoami.d.ts.map +1 -0
  211. package/dist/src/platforms/wechatbot/commands/whoami.js +33 -0
  212. package/dist/src/platforms/wechatbot/commands/whoami.js.map +1 -0
  213. package/dist/src/platforms/wechatbot/credential-manager.d.ts +17 -0
  214. package/dist/src/platforms/wechatbot/credential-manager.d.ts.map +1 -0
  215. package/dist/src/platforms/wechatbot/credential-manager.js +121 -0
  216. package/dist/src/platforms/wechatbot/credential-manager.js.map +1 -0
  217. package/dist/src/platforms/wechatbot/index.d.ts +5 -0
  218. package/dist/src/platforms/wechatbot/index.d.ts.map +1 -0
  219. package/dist/src/platforms/wechatbot/index.js +4 -0
  220. package/dist/src/platforms/wechatbot/index.js.map +1 -0
  221. package/dist/src/platforms/wechatbot/types.d.ts +94 -0
  222. package/dist/src/platforms/wechatbot/types.d.ts.map +1 -0
  223. package/dist/src/platforms/wechatbot/types.js +54 -0
  224. package/dist/src/platforms/wechatbot/types.js.map +1 -0
  225. package/dist/src/platforms/whatsapp/cli.d.ts.map +1 -1
  226. package/dist/src/platforms/whatsapp/cli.js +2 -1
  227. package/dist/src/platforms/whatsapp/cli.js.map +1 -1
  228. package/dist/src/platforms/whatsapp/client.d.ts +9 -0
  229. package/dist/src/platforms/whatsapp/client.d.ts.map +1 -1
  230. package/dist/src/platforms/whatsapp/client.js +143 -21
  231. package/dist/src/platforms/whatsapp/client.js.map +1 -1
  232. package/dist/src/platforms/whatsapp/commands/auth.d.ts.map +1 -1
  233. package/dist/src/platforms/whatsapp/commands/auth.js +133 -60
  234. package/dist/src/platforms/whatsapp/commands/auth.js.map +1 -1
  235. package/dist/src/platforms/whatsapp/commands/index.d.ts +1 -0
  236. package/dist/src/platforms/whatsapp/commands/index.d.ts.map +1 -1
  237. package/dist/src/platforms/whatsapp/commands/index.js +1 -0
  238. package/dist/src/platforms/whatsapp/commands/index.js.map +1 -1
  239. package/dist/src/platforms/whatsapp/commands/shared.js +2 -2
  240. package/dist/src/platforms/whatsapp/commands/shared.js.map +1 -1
  241. package/dist/src/platforms/whatsapp/commands/whoami.d.ts +7 -0
  242. package/dist/src/platforms/whatsapp/commands/whoami.d.ts.map +1 -0
  243. package/dist/src/platforms/whatsapp/commands/whoami.js +19 -0
  244. package/dist/src/platforms/whatsapp/commands/whoami.js.map +1 -0
  245. package/dist/src/platforms/whatsapp/credential-manager.d.ts.map +1 -1
  246. package/dist/src/platforms/whatsapp/credential-manager.js +14 -8
  247. package/dist/src/platforms/whatsapp/credential-manager.js.map +1 -1
  248. package/dist/src/platforms/whatsapp/ensure-auth.js +2 -2
  249. package/dist/src/platforms/whatsapp/ensure-auth.js.map +1 -1
  250. package/dist/src/platforms/whatsappbot/cli.d.ts.map +1 -1
  251. package/dist/src/platforms/whatsappbot/cli.js +2 -1
  252. package/dist/src/platforms/whatsappbot/cli.js.map +1 -1
  253. package/dist/src/platforms/whatsappbot/commands/index.d.ts +1 -0
  254. package/dist/src/platforms/whatsappbot/commands/index.d.ts.map +1 -1
  255. package/dist/src/platforms/whatsappbot/commands/index.js +1 -0
  256. package/dist/src/platforms/whatsappbot/commands/index.js.map +1 -1
  257. package/dist/src/platforms/whatsappbot/commands/whoami.d.ts +17 -0
  258. package/dist/src/platforms/whatsappbot/commands/whoami.d.ts.map +1 -0
  259. package/dist/src/platforms/whatsappbot/commands/whoami.js +39 -0
  260. package/dist/src/platforms/whatsappbot/commands/whoami.js.map +1 -0
  261. package/dist/src/shared/utils/qr.d.ts +15 -0
  262. package/dist/src/shared/utils/qr.d.ts.map +1 -0
  263. package/dist/src/shared/utils/qr.js +74 -0
  264. package/dist/src/shared/utils/qr.js.map +1 -0
  265. package/dist/src/tui/adapters/whatsapp-adapter.d.ts.map +1 -1
  266. package/dist/src/tui/adapters/whatsapp-adapter.js +20 -15
  267. package/dist/src/tui/adapters/whatsapp-adapter.js.map +1 -1
  268. package/docs/content/docs/agent-skills.mdx +4 -4
  269. package/docs/content/docs/cli/channeltalk.mdx +12 -1
  270. package/docs/content/docs/cli/channeltalkbot.mdx +10 -1
  271. package/docs/content/docs/cli/discord.mdx +11 -1
  272. package/docs/content/docs/cli/discordbot.mdx +10 -1
  273. package/docs/content/docs/cli/instagram.mdx +12 -1
  274. package/docs/content/docs/cli/kakaotalk.mdx +25 -1
  275. package/docs/content/docs/cli/line.mdx +5 -5
  276. package/docs/content/docs/cli/meta.json +1 -0
  277. package/docs/content/docs/cli/slack.mdx +11 -1
  278. package/docs/content/docs/cli/slackbot.mdx +10 -1
  279. package/docs/content/docs/cli/teams.mdx +11 -1
  280. package/docs/content/docs/cli/telegram.mdx +11 -0
  281. package/docs/content/docs/cli/webex.mdx +11 -1
  282. package/docs/content/docs/cli/wechatbot.mdx +188 -0
  283. package/docs/content/docs/cli/whatsapp.mdx +37 -8
  284. package/docs/content/docs/cli/whatsappbot.mdx +10 -1
  285. package/docs/content/docs/sdk/meta.json +1 -1
  286. package/docs/content/docs/sdk/wechatbot.mdx +282 -0
  287. package/docs/content/docs/tui.mdx +1 -1
  288. package/docs/src/app/page.tsx +5 -5
  289. package/package.json +11 -3
  290. package/skills/agent-channeltalk/SKILL.md +12 -1
  291. package/skills/agent-channeltalkbot/SKILL.md +10 -1
  292. package/skills/agent-discord/SKILL.md +11 -1
  293. package/skills/agent-discordbot/SKILL.md +10 -1
  294. package/skills/agent-instagram/SKILL.md +12 -1
  295. package/skills/agent-kakaotalk/SKILL.md +30 -1
  296. package/skills/agent-kakaotalk/references/common-patterns.md +1 -1
  297. package/skills/agent-line/SKILL.md +11 -15
  298. package/skills/agent-line/references/authentication.md +13 -4
  299. package/skills/agent-slack/SKILL.md +11 -1
  300. package/skills/agent-slackbot/SKILL.md +10 -1
  301. package/skills/agent-teams/SKILL.md +11 -1
  302. package/skills/agent-telegram/SKILL.md +6 -1
  303. package/skills/agent-webex/SKILL.md +11 -1
  304. package/skills/agent-wechatbot/SKILL.md +394 -0
  305. package/skills/agent-whatsapp/SKILL.md +63 -15
  306. package/skills/agent-whatsapp/references/authentication.md +36 -6
  307. package/skills/agent-whatsappbot/SKILL.md +10 -1
  308. package/src/platforms/channeltalk/cli.ts +2 -0
  309. package/src/platforms/channeltalk/commands/index.ts +1 -0
  310. package/src/platforms/channeltalk/commands/whoami.test.ts +64 -0
  311. package/src/platforms/channeltalk/commands/whoami.ts +62 -0
  312. package/src/platforms/channeltalkbot/cli.ts +2 -0
  313. package/src/platforms/channeltalkbot/commands/index.ts +1 -0
  314. package/src/platforms/channeltalkbot/commands/whoami.test.ts +104 -0
  315. package/src/platforms/channeltalkbot/commands/whoami.ts +42 -0
  316. package/src/platforms/discord/cli.ts +2 -0
  317. package/src/platforms/discord/commands/index.ts +1 -0
  318. package/src/platforms/discord/commands/whoami.test.ts +91 -0
  319. package/src/platforms/discord/commands/whoami.ts +36 -0
  320. package/src/platforms/discord/credential-manager.test.ts +18 -1
  321. package/src/platforms/discordbot/cli.ts +2 -0
  322. package/src/platforms/discordbot/client.ts +2 -2
  323. package/src/platforms/discordbot/commands/index.ts +1 -0
  324. package/src/platforms/discordbot/commands/whoami.test.ts +96 -0
  325. package/src/platforms/discordbot/commands/whoami.ts +44 -0
  326. package/src/platforms/instagram/cli.ts +2 -1
  327. package/src/platforms/instagram/client.ts +13 -0
  328. package/src/platforms/instagram/commands/auth.test.ts +216 -0
  329. package/src/platforms/instagram/commands/chat.test.ts +123 -0
  330. package/src/platforms/instagram/commands/index.ts +1 -0
  331. package/src/platforms/instagram/commands/message.test.ts +174 -0
  332. package/src/platforms/instagram/commands/whoami.test.ts +60 -0
  333. package/src/platforms/instagram/commands/whoami.ts +21 -0
  334. package/src/platforms/kakaotalk/cli.ts +2 -1
  335. package/src/platforms/kakaotalk/client.test.ts +182 -14
  336. package/src/platforms/kakaotalk/client.ts +261 -27
  337. package/src/platforms/kakaotalk/commands/auth.test.ts +299 -0
  338. package/src/platforms/kakaotalk/commands/chat.test.ts +97 -0
  339. package/src/platforms/kakaotalk/commands/index.ts +1 -0
  340. package/src/platforms/kakaotalk/commands/message.test.ts +113 -0
  341. package/src/platforms/kakaotalk/commands/whoami.test.ts +116 -0
  342. package/src/platforms/kakaotalk/commands/whoami.ts +21 -0
  343. package/src/platforms/kakaotalk/index.test.ts +5 -0
  344. package/src/platforms/kakaotalk/index.ts +2 -0
  345. package/src/platforms/kakaotalk/protocol/session.ts +29 -7
  346. package/src/platforms/kakaotalk/protocol/types.ts +9 -0
  347. package/src/platforms/kakaotalk/types.ts +30 -0
  348. package/src/platforms/line/cli.ts +2 -2
  349. package/src/platforms/line/client.ts +14 -39
  350. package/src/platforms/line/commands/auth.test.ts +141 -0
  351. package/src/platforms/line/commands/auth.ts +37 -61
  352. package/src/platforms/line/commands/chat.test.ts +110 -0
  353. package/src/platforms/line/commands/friend.test.ts +98 -0
  354. package/src/platforms/line/commands/index.ts +1 -1
  355. package/src/platforms/line/commands/message.test.ts +119 -0
  356. package/src/platforms/line/commands/whoami.test.ts +85 -0
  357. package/src/platforms/line/commands/{profile.ts → whoami.ts} +4 -4
  358. package/src/platforms/slack/cli.ts +2 -0
  359. package/src/platforms/slack/commands/index.ts +1 -0
  360. package/src/platforms/slack/commands/whoami.test.ts +126 -0
  361. package/src/platforms/slack/commands/whoami.ts +40 -0
  362. package/src/platforms/slackbot/cli.ts +2 -1
  363. package/src/platforms/slackbot/commands/channel.test.ts +139 -0
  364. package/src/platforms/slackbot/commands/index.ts +1 -0
  365. package/src/platforms/slackbot/commands/message.test.ts +226 -0
  366. package/src/platforms/slackbot/commands/reaction.test.ts +90 -0
  367. package/src/platforms/slackbot/commands/user.test.ts +143 -0
  368. package/src/platforms/slackbot/commands/whoami.test.ts +102 -0
  369. package/src/platforms/slackbot/commands/whoami.ts +44 -0
  370. package/src/platforms/teams/cli.ts +2 -0
  371. package/src/platforms/teams/commands/index.ts +1 -0
  372. package/src/platforms/teams/commands/reaction.test.ts +45 -61
  373. package/src/platforms/teams/commands/reaction.ts +2 -0
  374. package/src/platforms/teams/commands/whoami.test.ts +83 -0
  375. package/src/platforms/teams/commands/whoami.ts +33 -0
  376. package/src/platforms/telegram/cli.ts +2 -1
  377. package/src/platforms/telegram/commands/chat.test.ts +125 -0
  378. package/src/platforms/telegram/commands/index.ts +1 -0
  379. package/src/platforms/telegram/commands/message.test.ts +92 -0
  380. package/src/platforms/telegram/commands/whoami.test.ts +75 -0
  381. package/src/platforms/telegram/commands/whoami.ts +29 -0
  382. package/src/platforms/webex/cli.ts +2 -1
  383. package/src/platforms/webex/commands/auth.test.ts +58 -46
  384. package/src/platforms/webex/commands/index.ts +1 -0
  385. package/src/platforms/webex/commands/member.test.ts +60 -57
  386. package/src/platforms/webex/commands/message.test.ts +74 -121
  387. package/src/platforms/webex/commands/message.ts +1 -1
  388. package/src/platforms/webex/commands/snapshot.test.ts +54 -45
  389. package/src/platforms/webex/commands/space.test.ts +46 -49
  390. package/src/platforms/webex/commands/whoami.test.ts +113 -0
  391. package/src/platforms/webex/commands/whoami.ts +31 -0
  392. package/src/platforms/webex/credential-manager.test.ts +0 -1
  393. package/src/platforms/wechatbot/cli.ts +25 -0
  394. package/src/platforms/wechatbot/client.test.ts +497 -0
  395. package/src/platforms/wechatbot/client.ts +268 -0
  396. package/src/platforms/wechatbot/commands/auth.test.ts +211 -0
  397. package/src/platforms/wechatbot/commands/auth.ts +203 -0
  398. package/src/platforms/wechatbot/commands/index.ts +5 -0
  399. package/src/platforms/wechatbot/commands/message.test.ts +155 -0
  400. package/src/platforms/wechatbot/commands/message.ts +104 -0
  401. package/src/platforms/wechatbot/commands/shared.ts +22 -0
  402. package/src/platforms/wechatbot/commands/template.test.ts +199 -0
  403. package/src/platforms/wechatbot/commands/template.ts +102 -0
  404. package/src/platforms/wechatbot/commands/user.test.ts +165 -0
  405. package/src/platforms/wechatbot/commands/user.ts +75 -0
  406. package/src/platforms/wechatbot/commands/whoami.test.ts +109 -0
  407. package/src/platforms/wechatbot/commands/whoami.ts +43 -0
  408. package/src/platforms/wechatbot/credential-manager.test.ts +255 -0
  409. package/src/platforms/wechatbot/credential-manager.ts +148 -0
  410. package/src/platforms/wechatbot/index.test.ts +49 -0
  411. package/src/platforms/wechatbot/index.ts +19 -0
  412. package/src/platforms/wechatbot/types.test.ts +223 -0
  413. package/src/platforms/wechatbot/types.ts +107 -0
  414. package/src/platforms/whatsapp/cli.ts +2 -1
  415. package/src/platforms/whatsapp/client.ts +180 -37
  416. package/src/platforms/whatsapp/commands/auth.test.ts +311 -0
  417. package/src/platforms/whatsapp/commands/auth.ts +194 -84
  418. package/src/platforms/whatsapp/commands/chat.test.ts +198 -0
  419. package/src/platforms/whatsapp/commands/index.ts +1 -0
  420. package/src/platforms/whatsapp/commands/message.test.ts +231 -0
  421. package/src/platforms/whatsapp/commands/shared.ts +2 -2
  422. package/src/platforms/whatsapp/commands/whoami.test.ts +59 -0
  423. package/src/platforms/whatsapp/commands/whoami.ts +21 -0
  424. package/src/platforms/whatsapp/credential-manager.test.ts +20 -0
  425. package/src/platforms/whatsapp/credential-manager.ts +17 -8
  426. package/src/platforms/whatsapp/ensure-auth.ts +2 -2
  427. package/src/platforms/whatsappbot/cli.ts +2 -1
  428. package/src/platforms/whatsappbot/commands/auth.test.ts +217 -0
  429. package/src/platforms/whatsappbot/commands/index.ts +1 -0
  430. package/src/platforms/whatsappbot/commands/message.test.ts +198 -0
  431. package/src/platforms/whatsappbot/commands/template.test.ts +112 -0
  432. package/src/platforms/whatsappbot/commands/whoami.test.ts +100 -0
  433. package/src/platforms/whatsappbot/commands/whoami.ts +57 -0
  434. package/src/shared/utils/qr.ts +92 -0
  435. package/src/tui/adapters/whatsapp-adapter.ts +19 -16
  436. package/dist/src/platforms/line/commands/profile.d.ts +0 -3
  437. package/dist/src/platforms/line/commands/profile.d.ts.map +0 -1
  438. package/dist/src/platforms/line/commands/profile.js.map +0 -1
@@ -1,89 +1,73 @@
1
- import { afterEach, beforeEach, expect, mock, spyOn, test } from 'bun:test'
1
+ import { afterEach, beforeEach, expect, spyOn, test } from 'bun:test'
2
2
 
3
3
  import { TeamsClient } from '../client'
4
4
  import { TeamsCredentialManager } from '../credential-manager'
5
5
  import { addAction, removeAction } from './reaction'
6
6
 
7
- let clientAddReactionSpy: ReturnType<typeof spyOn>
8
- let clientRemoveReactionSpy: ReturnType<typeof spyOn>
9
- let credManagerLoadConfigSpy: ReturnType<typeof spyOn>
7
+ let addReactionSpy: ReturnType<typeof spyOn>
8
+ let removeReactionSpy: ReturnType<typeof spyOn>
9
+ let getTokenWithExpirySpy: ReturnType<typeof spyOn>
10
+ let consoleLogSpy: ReturnType<typeof spyOn>
11
+ let processExitSpy: ReturnType<typeof spyOn>
10
12
 
11
13
  beforeEach(() => {
12
- clientAddReactionSpy = spyOn(TeamsClient.prototype, 'addReaction').mockResolvedValue(undefined)
13
- clientRemoveReactionSpy = spyOn(TeamsClient.prototype, 'removeReaction').mockResolvedValue(undefined)
14
- credManagerLoadConfigSpy = spyOn(TeamsCredentialManager.prototype, 'loadConfig').mockResolvedValue({
15
- current_account: 'work',
16
- accounts: {
17
- work: {
18
- token: 'test-token',
19
- account_type: 'work' as const,
20
- current_team: null,
21
- teams: {},
22
- },
23
- },
14
+ addReactionSpy = spyOn(TeamsClient.prototype, 'addReaction').mockResolvedValue(undefined)
15
+ removeReactionSpy = spyOn(TeamsClient.prototype, 'removeReaction').mockResolvedValue(undefined)
16
+ getTokenWithExpirySpy = spyOn(TeamsCredentialManager.prototype, 'getTokenWithExpiry').mockImplementation(() =>
17
+ Promise.resolve({ token: 'test-token', tokenExpiresAt: undefined }),
18
+ )
19
+
20
+ consoleLogSpy = spyOn(console, 'log').mockImplementation(() => {})
21
+ processExitSpy = spyOn(process, 'exit').mockImplementation((_code?: number) => {
22
+ throw new Error(`process.exit(${_code})`)
24
23
  })
25
24
  })
26
25
 
27
26
  afterEach(() => {
28
- clientAddReactionSpy?.mockRestore()
29
- clientRemoveReactionSpy?.mockRestore()
30
- credManagerLoadConfigSpy?.mockRestore()
27
+ addReactionSpy.mockRestore()
28
+ removeReactionSpy.mockRestore()
29
+ getTokenWithExpirySpy.mockRestore()
30
+ consoleLogSpy.mockRestore()
31
+ processExitSpy.mockRestore()
31
32
  })
32
33
 
33
34
  test('add: sends correct POST request with emoji', async () => {
34
- const consoleSpy = mock((_msg: string) => {})
35
- const originalLog = console.log
36
- console.log = consoleSpy
37
-
38
35
  try {
39
36
  await addAction('team123', 'ch123', 'msg123', 'like', { pretty: false })
40
- expect(consoleSpy).toHaveBeenCalled()
41
- const output = JSON.parse(consoleSpy.mock.calls[0][0])
42
- expect(output.success).toBe(true)
43
- expect(output.team_id).toBe('team123')
44
- expect(output.channel_id).toBe('ch123')
45
- expect(output.message_id).toBe('msg123')
46
- expect(output.emoji).toBe('like')
47
- } finally {
48
- console.log = originalLog
49
- }
37
+ } catch {}
38
+
39
+ expect(consoleLogSpy).toHaveBeenCalled()
40
+ const output = JSON.parse(consoleLogSpy.mock.calls[0][0])
41
+ expect(output.success).toBe(true)
42
+ expect(output.team_id).toBe('team123')
43
+ expect(output.channel_id).toBe('ch123')
44
+ expect(output.message_id).toBe('msg123')
45
+ expect(output.emoji).toBe('like')
50
46
  })
51
47
 
52
48
  test('remove: sends correct DELETE request with emoji', async () => {
53
- const consoleSpy = mock((_msg: string) => {})
54
- const originalLog = console.log
55
- console.log = consoleSpy
56
-
57
49
  try {
58
50
  await removeAction('team123', 'ch123', 'msg123', 'like', { pretty: false })
59
- expect(consoleSpy).toHaveBeenCalled()
60
- const output = JSON.parse(consoleSpy.mock.calls[0][0])
61
- expect(output.success).toBe(true)
62
- expect(output.team_id).toBe('team123')
63
- expect(output.channel_id).toBe('ch123')
64
- expect(output.message_id).toBe('msg123')
65
- expect(output.emoji).toBe('like')
66
- } finally {
67
- console.log = originalLog
68
- }
51
+ } catch {}
52
+
53
+ expect(consoleLogSpy).toHaveBeenCalled()
54
+ const output = JSON.parse(consoleLogSpy.mock.calls[0][0])
55
+ expect(output.success).toBe(true)
56
+ expect(output.team_id).toBe('team123')
57
+ expect(output.channel_id).toBe('ch123')
58
+ expect(output.message_id).toBe('msg123')
59
+ expect(output.emoji).toBe('like')
69
60
  })
70
61
 
71
62
  test('add: handles missing token gracefully', async () => {
72
- credManagerLoadConfigSpy?.mockResolvedValue(null)
73
-
74
- const consoleSpy = mock((_msg: string) => {})
75
- const originalLog = console.log
76
- const originalExit = process.exit
77
- process.exit = mock(() => {}) as any
78
- console.log = consoleSpy
63
+ getTokenWithExpirySpy.mockImplementation(() => Promise.resolve(null))
79
64
 
80
65
  try {
81
66
  await addAction('team123', 'ch123', 'msg123', 'like', { pretty: false })
82
- expect(consoleSpy).toHaveBeenCalled()
83
- const output = JSON.parse(consoleSpy.mock.calls[0][0])
84
- expect(output.error).toBeDefined()
85
- } finally {
86
- console.log = originalLog
87
- process.exit = originalExit
88
- }
67
+ } catch {}
68
+
69
+ expect(consoleLogSpy).toHaveBeenCalled()
70
+ const output = JSON.parse(consoleLogSpy.mock.calls[0][0])
71
+ expect(output.error).toBeDefined()
72
+ expect(processExitSpy).toHaveBeenCalledWith(1)
89
73
  })
@@ -20,6 +20,7 @@ export async function addAction(
20
20
  if (!cred) {
21
21
  console.log(formatOutput({ error: 'Not authenticated. Run "auth extract" first.' }, options.pretty))
22
22
  process.exit(1)
23
+ return
23
24
  }
24
25
 
25
26
  const client = await new TeamsClient().login({ token: cred.token, tokenExpiresAt: cred.tokenExpiresAt })
@@ -56,6 +57,7 @@ export async function removeAction(
56
57
  if (!cred) {
57
58
  console.log(formatOutput({ error: 'Not authenticated. Run "auth extract" first.' }, options.pretty))
58
59
  process.exit(1)
60
+ return
59
61
  }
60
62
 
61
63
  const client = await new TeamsClient().login({ token: cred.token, tokenExpiresAt: cred.tokenExpiresAt })
@@ -0,0 +1,83 @@
1
+ import { afterEach, beforeEach, expect, spyOn, test } from 'bun:test'
2
+
3
+ import { TeamsClient } from '@/platforms/teams/client'
4
+ import { TeamsCredentialManager } from '@/platforms/teams/credential-manager'
5
+ import { whoamiAction, whoamiCommand } from '@/platforms/teams/commands/whoami'
6
+
7
+ let credManagerSpy: ReturnType<typeof spyOn>
8
+ let clientTestAuthSpy: ReturnType<typeof spyOn>
9
+ let consoleLogSpy: ReturnType<typeof spyOn>
10
+ let processExitSpy: ReturnType<typeof spyOn>
11
+
12
+ const mockCred = {
13
+ token: 'test-teams-token',
14
+ tokenExpiresAt: '2099-01-01T00:00:00.000Z',
15
+ }
16
+
17
+ const mockUser = {
18
+ id: 'ME',
19
+ displayName: 'Test User',
20
+ }
21
+
22
+ beforeEach(() => {
23
+ credManagerSpy = spyOn(TeamsCredentialManager.prototype, 'getTokenWithExpiry').mockResolvedValue(mockCred)
24
+ clientTestAuthSpy = spyOn(TeamsClient.prototype, 'testAuth').mockResolvedValue(mockUser)
25
+ consoleLogSpy = spyOn(console, 'log').mockImplementation(() => {})
26
+ processExitSpy = spyOn(process, 'exit').mockImplementation((_code?: number) => undefined as never)
27
+ })
28
+
29
+ afterEach(() => {
30
+ credManagerSpy?.mockRestore()
31
+ clientTestAuthSpy?.mockRestore()
32
+ consoleLogSpy?.mockRestore()
33
+ processExitSpy?.mockRestore()
34
+ })
35
+
36
+ test('whoami command is defined with correct name and description', () => {
37
+ expect(whoamiCommand).toBeDefined()
38
+ expect(whoamiCommand.name()).toBe('whoami')
39
+ expect(whoamiCommand.description()).toBe('Show current authenticated user')
40
+ })
41
+
42
+ test('whoami command has --pretty option', () => {
43
+ const options = whoamiCommand.options
44
+ const hasPretty = options.some((opt: { long?: string }) => opt.long === '--pretty')
45
+ expect(hasPretty).toBe(true)
46
+ })
47
+
48
+ test('whoami outputs id and displayName', async () => {
49
+ await whoamiAction({})
50
+
51
+ expect(consoleLogSpy).toHaveBeenCalledWith(
52
+ JSON.stringify({
53
+ id: 'ME',
54
+ displayName: 'Test User',
55
+ }),
56
+ )
57
+ })
58
+
59
+ test('whoami outputs pretty-printed JSON when pretty is true', async () => {
60
+ await whoamiAction({ pretty: true })
61
+
62
+ expect(consoleLogSpy).toHaveBeenCalledWith(
63
+ JSON.stringify(
64
+ {
65
+ id: 'ME',
66
+ displayName: 'Test User',
67
+ },
68
+ null,
69
+ 2,
70
+ ),
71
+ )
72
+ })
73
+
74
+ test('whoami exits with error when not authenticated', async () => {
75
+ credManagerSpy.mockResolvedValue(null)
76
+
77
+ await whoamiAction({})
78
+
79
+ expect(consoleLogSpy).toHaveBeenCalledWith(
80
+ JSON.stringify({ error: 'Not authenticated. Run "auth extract" first.' }),
81
+ )
82
+ expect(processExitSpy).toHaveBeenCalledWith(1)
83
+ })
@@ -0,0 +1,33 @@
1
+ import { Command } from 'commander'
2
+ import { handleError } from '@/shared/utils/error-handler'
3
+ import { formatOutput } from '@/shared/utils/output'
4
+ import { TeamsClient } from '../client'
5
+ import { TeamsCredentialManager } from '../credential-manager'
6
+
7
+ export async function whoamiAction(options: { pretty?: boolean }): Promise<void> {
8
+ try {
9
+ const credManager = new TeamsCredentialManager()
10
+ const cred = await credManager.getTokenWithExpiry()
11
+
12
+ if (!cred) {
13
+ console.log(formatOutput({ error: 'Not authenticated. Run "auth extract" first.' }, options.pretty))
14
+ return process.exit(1)
15
+ }
16
+
17
+ const client = await new TeamsClient().login({ token: cred.token, tokenExpiresAt: cred.tokenExpiresAt })
18
+ const user = await client.testAuth()
19
+
20
+ const output = {
21
+ id: user.id,
22
+ displayName: user.displayName,
23
+ }
24
+ console.log(formatOutput(output, options.pretty))
25
+ } catch (error) {
26
+ handleError(error as Error)
27
+ }
28
+ }
29
+
30
+ export const whoamiCommand = new Command('whoami')
31
+ .description('Show current authenticated user')
32
+ .option('--pretty', 'Pretty print JSON output')
33
+ .action(whoamiAction)
@@ -2,7 +2,7 @@
2
2
 
3
3
  import { Command } from 'commander'
4
4
  import pkg from '../../../package.json' with { type: 'json' }
5
- import { authCommand, chatCommand, messageCommand } from './commands'
5
+ import { authCommand, chatCommand, messageCommand, whoamiCommand } from './commands'
6
6
 
7
7
  const program = new Command()
8
8
 
@@ -14,6 +14,7 @@ program
14
14
  program.addCommand(authCommand)
15
15
  program.addCommand(chatCommand)
16
16
  program.addCommand(messageCommand)
17
+ program.addCommand(whoamiCommand)
17
18
 
18
19
  await program.parseAsync(process.argv)
19
20
 
@@ -0,0 +1,125 @@
1
+ import { afterEach, beforeEach, describe, expect, mock, spyOn, test } from 'bun:test'
2
+
3
+ const mockListChats = mock(() =>
4
+ Promise.resolve([
5
+ { id: 'chat-1', title: 'General', type: 'supergroup', unread_count: 0 },
6
+ { id: 'chat-2', title: 'Random', type: 'group', unread_count: 5 },
7
+ ]),
8
+ )
9
+
10
+ const mockSearchChats = mock(() =>
11
+ Promise.resolve([{ id: 'chat-1', title: 'General', type: 'supergroup', unread_count: 0 }]),
12
+ )
13
+
14
+ const mockGetChat = mock(() =>
15
+ Promise.resolve({ id: 'chat-1', title: 'General', type: 'supergroup', unread_count: 0 }),
16
+ )
17
+
18
+ const mockClient = {
19
+ listChats: mockListChats,
20
+ searchChats: mockSearchChats,
21
+ getChat: mockGetChat,
22
+ }
23
+
24
+ mock.module('./shared', () => ({
25
+ withTelegramClient: async (_opts: unknown, fn: (client: typeof mockClient) => Promise<unknown>) =>
26
+ fn(mockClient),
27
+ }))
28
+
29
+ import { chatCommand } from './chat'
30
+
31
+ describe('chat commands', () => {
32
+ let consoleSpy: ReturnType<typeof spyOn>
33
+ let processExitSpy: ReturnType<typeof spyOn>
34
+
35
+ beforeEach(() => {
36
+ mockListChats.mockReset()
37
+ mockListChats.mockImplementation(() =>
38
+ Promise.resolve([
39
+ { id: 'chat-1', title: 'General', type: 'supergroup', unread_count: 0 },
40
+ { id: 'chat-2', title: 'Random', type: 'group', unread_count: 5 },
41
+ ]),
42
+ )
43
+ mockSearchChats.mockReset()
44
+ mockSearchChats.mockImplementation(() =>
45
+ Promise.resolve([{ id: 'chat-1', title: 'General', type: 'supergroup', unread_count: 0 }]),
46
+ )
47
+ mockGetChat.mockReset()
48
+ mockGetChat.mockImplementation(() =>
49
+ Promise.resolve({ id: 'chat-1', title: 'General', type: 'supergroup', unread_count: 0 }),
50
+ )
51
+ consoleSpy = spyOn(console, 'log').mockImplementation(() => {})
52
+ processExitSpy = spyOn(process, 'exit').mockImplementation((() => {}) as (code?: number) => never)
53
+ })
54
+
55
+ afterEach(() => {
56
+ consoleSpy.mockRestore()
57
+ processExitSpy.mockRestore()
58
+ })
59
+
60
+ describe('list subcommand', () => {
61
+ test('calls listChats with default limit', async () => {
62
+ await chatCommand.parseAsync(['list'], { from: 'user' })
63
+
64
+ expect(mockListChats).toHaveBeenCalledWith(20)
65
+ })
66
+
67
+ test('calls listChats with custom limit', async () => {
68
+ await chatCommand.parseAsync(['list', '--limit', '5'], { from: 'user' })
69
+
70
+ expect(mockListChats).toHaveBeenCalledWith(5)
71
+ })
72
+
73
+ test('outputs JSON array to console', async () => {
74
+ await chatCommand.parseAsync(['list'], { from: 'user' })
75
+
76
+ expect(consoleSpy).toHaveBeenCalled()
77
+ const output = consoleSpy.mock.calls[0][0] as string
78
+ const parsed = JSON.parse(output)
79
+ expect(parsed).toBeArray()
80
+ expect(parsed).toHaveLength(2)
81
+ })
82
+ })
83
+
84
+ describe('search subcommand', () => {
85
+ test('calls searchChats with query and default limit', async () => {
86
+ await chatCommand.parseAsync(['search', 'General'], { from: 'user' })
87
+
88
+ expect(mockSearchChats).toHaveBeenCalledWith('General', 20)
89
+ })
90
+
91
+ test('calls searchChats with query and custom limit', async () => {
92
+ await chatCommand.parseAsync(['search', 'General', '--limit', '3'], { from: 'user' })
93
+
94
+ expect(mockSearchChats).toHaveBeenCalledWith('General', 3)
95
+ })
96
+
97
+ test('outputs JSON array to console', async () => {
98
+ await chatCommand.parseAsync(['search', 'General'], { from: 'user' })
99
+
100
+ expect(consoleSpy).toHaveBeenCalled()
101
+ const output = consoleSpy.mock.calls[0][0] as string
102
+ const parsed = JSON.parse(output)
103
+ expect(parsed).toBeArray()
104
+ expect(parsed).toHaveLength(1)
105
+ })
106
+ })
107
+
108
+ describe('get subcommand', () => {
109
+ test('calls getChat with chat reference', async () => {
110
+ await chatCommand.parseAsync(['get', 'chat-1'], { from: 'user' })
111
+
112
+ expect(mockGetChat).toHaveBeenCalledWith('chat-1')
113
+ })
114
+
115
+ test('outputs JSON object to console', async () => {
116
+ await chatCommand.parseAsync(['get', 'chat-1'], { from: 'user' })
117
+
118
+ expect(consoleSpy).toHaveBeenCalled()
119
+ const output = consoleSpy.mock.calls[0][0] as string
120
+ const parsed = JSON.parse(output)
121
+ expect(parsed).toBeObject()
122
+ expect(parsed.id).toBe('chat-1')
123
+ })
124
+ })
125
+ })
@@ -1,3 +1,4 @@
1
1
  export { authCommand } from './auth'
2
2
  export { chatCommand } from './chat'
3
3
  export { messageCommand } from './message'
4
+ export { whoamiCommand } from './whoami'
@@ -0,0 +1,92 @@
1
+ import { afterEach, beforeEach, describe, expect, mock, spyOn, test } from 'bun:test'
2
+
3
+ const mockListMessages = mock(() =>
4
+ Promise.resolve([
5
+ { id: 1, text: 'Hello', sender_id: 'user-1', date: 1000 },
6
+ { id: 2, text: 'World', sender_id: 'user-2', date: 2000 },
7
+ ]),
8
+ )
9
+
10
+ const mockSendMessage = mock(() =>
11
+ Promise.resolve({ id: 3, text: 'Sent message', sender_id: 'user-1', date: 3000 }),
12
+ )
13
+
14
+ const mockClient = {
15
+ listMessages: mockListMessages,
16
+ sendMessage: mockSendMessage,
17
+ }
18
+
19
+ mock.module('./shared', () => ({
20
+ withTelegramClient: async (_opts: unknown, fn: (client: typeof mockClient) => Promise<unknown>) =>
21
+ fn(mockClient),
22
+ }))
23
+
24
+ import { messageCommand } from './message'
25
+
26
+ describe('message commands', () => {
27
+ let consoleSpy: ReturnType<typeof spyOn>
28
+ let processExitSpy: ReturnType<typeof spyOn>
29
+
30
+ beforeEach(() => {
31
+ mockListMessages.mockReset()
32
+ mockListMessages.mockImplementation(() =>
33
+ Promise.resolve([
34
+ { id: 1, text: 'Hello', sender_id: 'user-1', date: 1000 },
35
+ { id: 2, text: 'World', sender_id: 'user-2', date: 2000 },
36
+ ]),
37
+ )
38
+ mockSendMessage.mockReset()
39
+ mockSendMessage.mockImplementation(() =>
40
+ Promise.resolve({ id: 3, text: 'Sent message', sender_id: 'user-1', date: 3000 }),
41
+ )
42
+ consoleSpy = spyOn(console, 'log').mockImplementation(() => {})
43
+ processExitSpy = spyOn(process, 'exit').mockImplementation((() => {}) as (code?: number) => never)
44
+ })
45
+
46
+ afterEach(() => {
47
+ consoleSpy.mockRestore()
48
+ processExitSpy.mockRestore()
49
+ })
50
+
51
+ describe('list subcommand', () => {
52
+ test('calls listMessages with chat reference and default limit', async () => {
53
+ await messageCommand.parseAsync(['list', 'chat-123'], { from: 'user' })
54
+
55
+ expect(mockListMessages).toHaveBeenCalledWith('chat-123', 20)
56
+ })
57
+
58
+ test('calls listMessages with custom limit', async () => {
59
+ await messageCommand.parseAsync(['list', 'chat-123', '--limit', '10'], { from: 'user' })
60
+
61
+ expect(mockListMessages).toHaveBeenCalledWith('chat-123', 10)
62
+ })
63
+
64
+ test('outputs JSON to console', async () => {
65
+ await messageCommand.parseAsync(['list', 'chat-123'], { from: 'user' })
66
+
67
+ expect(consoleSpy).toHaveBeenCalled()
68
+ const output = consoleSpy.mock.calls[0][0] as string
69
+ const parsed = JSON.parse(output)
70
+ expect(parsed).toBeArray()
71
+ expect(parsed).toHaveLength(2)
72
+ })
73
+ })
74
+
75
+ describe('send subcommand', () => {
76
+ test('calls sendMessage with chat reference and text', async () => {
77
+ await messageCommand.parseAsync(['send', 'chat-123', 'Hello there'], { from: 'user' })
78
+
79
+ expect(mockSendMessage).toHaveBeenCalledWith('chat-123', 'Hello there')
80
+ })
81
+
82
+ test('outputs JSON to console', async () => {
83
+ await messageCommand.parseAsync(['send', 'chat-123', 'Hello there'], { from: 'user' })
84
+
85
+ expect(consoleSpy).toHaveBeenCalled()
86
+ const output = consoleSpy.mock.calls[0][0] as string
87
+ const parsed = JSON.parse(output)
88
+ expect(parsed).toBeObject()
89
+ expect(parsed.id).toBe(3)
90
+ })
91
+ })
92
+ })
@@ -0,0 +1,75 @@
1
+ import { afterEach, beforeEach, describe, expect, spyOn, test } from 'bun:test'
2
+
3
+ import { TelegramTdlibClient } from '../client'
4
+ import type { TelegramAccount } from '../types'
5
+ import { TelegramCredentialManager } from '../credential-manager'
6
+ import * as sharedModule from './shared'
7
+ import { whoamiAction } from './whoami'
8
+
9
+ const mockAuthStatus = {
10
+ account_id: 'plus-12025551234',
11
+ phone_number: '+12025551234',
12
+ authorization_state: 'authorizationStateReady',
13
+ authenticated: true,
14
+ user: {
15
+ id: 123456,
16
+ first_name: 'Test',
17
+ last_name: 'User',
18
+ username: 'testuser',
19
+ phone_number: '12025551234',
20
+ type: 'user' as const,
21
+ },
22
+ }
23
+
24
+ let withTelegramClientSpy: ReturnType<typeof spyOn>
25
+ let getAuthStatusSpy: ReturnType<typeof spyOn>
26
+ let consoleLogSpy: ReturnType<typeof spyOn>
27
+
28
+ describe('whoami command', () => {
29
+ beforeEach(() => {
30
+ getAuthStatusSpy = spyOn(TelegramTdlibClient.prototype, 'getAuthStatus').mockResolvedValue(mockAuthStatus)
31
+ withTelegramClientSpy = spyOn(sharedModule, 'withTelegramClient').mockImplementation(
32
+ async (_opts, fn) => {
33
+ const fakeClient = Object.create(TelegramTdlibClient.prototype) as TelegramTdlibClient
34
+ return fn(fakeClient, {} as TelegramAccount, new TelegramCredentialManager())
35
+ },
36
+ )
37
+ consoleLogSpy = spyOn(console, 'log').mockImplementation(() => {})
38
+ })
39
+
40
+ afterEach(() => {
41
+ getAuthStatusSpy?.mockRestore()
42
+ withTelegramClientSpy?.mockRestore()
43
+ consoleLogSpy?.mockRestore()
44
+ })
45
+
46
+ test('outputs account info with user when authenticated', async () => {
47
+ await whoamiAction({})
48
+
49
+ expect(consoleLogSpy).toHaveBeenCalledTimes(1)
50
+ const output = JSON.parse(consoleLogSpy.mock.calls[0][0] as string)
51
+ expect(output.account_id).toBe('plus-12025551234')
52
+ expect(output.phone_number).toBe('+12025551234')
53
+ expect(output.authenticated).toBe(true)
54
+ expect(output.user).toBeDefined()
55
+ expect(output.user.id).toBe(123456)
56
+ expect(output.user.username).toBe('testuser')
57
+ })
58
+
59
+ test('omits user field when not present', async () => {
60
+ getAuthStatusSpy.mockResolvedValue({
61
+ account_id: 'plus-12025551234',
62
+ phone_number: '+12025551234',
63
+ authorization_state: 'authorizationStateWaitCode',
64
+ authenticated: false,
65
+ })
66
+
67
+ await whoamiAction({})
68
+
69
+ expect(consoleLogSpy).toHaveBeenCalledTimes(1)
70
+ const output = JSON.parse(consoleLogSpy.mock.calls[0][0] as string)
71
+ expect(output.account_id).toBe('plus-12025551234')
72
+ expect(output.authenticated).toBe(false)
73
+ expect(output.user).toBeUndefined()
74
+ })
75
+ })
@@ -0,0 +1,29 @@
1
+ import { Command } from 'commander'
2
+
3
+ import { handleError } from '@/shared/utils/error-handler'
4
+ import { formatOutput } from '@/shared/utils/output'
5
+
6
+ import { withTelegramClient } from './shared'
7
+
8
+ export async function whoamiAction(options: { account?: string; pretty?: boolean }): Promise<void> {
9
+ try {
10
+ await withTelegramClient(options, async (client) => {
11
+ const status = await client.getAuthStatus()
12
+ const output = {
13
+ account_id: status.account_id,
14
+ phone_number: status.phone_number,
15
+ authenticated: status.authenticated,
16
+ ...status.user && { user: status.user },
17
+ }
18
+ console.log(formatOutput(output, options.pretty))
19
+ })
20
+ } catch (error) {
21
+ handleError(error as Error)
22
+ }
23
+ }
24
+
25
+ export const whoamiCommand = new Command('whoami')
26
+ .description('Show current authenticated user')
27
+ .option('--account <id>', 'Use a specific Telegram account')
28
+ .option('--pretty', 'Pretty print JSON output')
29
+ .action(whoamiAction)
@@ -4,7 +4,7 @@ import type { Command as CommandType } from 'commander'
4
4
  import { Command } from 'commander'
5
5
 
6
6
  import pkg from '../../../package.json' with { type: 'json' }
7
- import { authCommand, memberCommand, messageCommand, snapshotCommand, spaceCommand } from './commands'
7
+ import { authCommand, memberCommand, messageCommand, snapshotCommand, spaceCommand, whoamiCommand } from './commands'
8
8
  import { ensureWebexAuth } from './ensure-auth'
9
9
 
10
10
  function isAuthCommand(command: CommandType): boolean {
@@ -33,6 +33,7 @@ program.addCommand(memberCommand)
33
33
  program.addCommand(messageCommand)
34
34
  program.addCommand(snapshotCommand)
35
35
  program.addCommand(spaceCommand)
36
+ program.addCommand(whoamiCommand)
36
37
 
37
38
  program.parse(process.argv)
38
39