agent-messenger 2.4.0 → 2.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/plugin.json +1 -1
- package/.github/workflows/ci.yml +35 -0
- package/.github/workflows/release.yml +0 -12
- package/README.md +3 -3
- package/bun.lock +10 -2
- package/dist/package.json +3 -1
- package/dist/src/platforms/channeltalk/cli.d.ts.map +1 -1
- package/dist/src/platforms/channeltalk/cli.js +2 -1
- package/dist/src/platforms/channeltalk/cli.js.map +1 -1
- package/dist/src/platforms/channeltalk/commands/index.d.ts +1 -0
- package/dist/src/platforms/channeltalk/commands/index.d.ts.map +1 -1
- package/dist/src/platforms/channeltalk/commands/index.js +1 -0
- package/dist/src/platforms/channeltalk/commands/index.js.map +1 -1
- package/dist/src/platforms/channeltalk/commands/whoami.d.ts +22 -0
- package/dist/src/platforms/channeltalk/commands/whoami.d.ts.map +1 -0
- package/dist/src/platforms/channeltalk/commands/whoami.js +40 -0
- package/dist/src/platforms/channeltalk/commands/whoami.js.map +1 -0
- package/dist/src/platforms/channeltalkbot/cli.d.ts.map +1 -1
- package/dist/src/platforms/channeltalkbot/cli.js +2 -1
- package/dist/src/platforms/channeltalkbot/cli.js.map +1 -1
- package/dist/src/platforms/channeltalkbot/commands/index.d.ts +1 -0
- package/dist/src/platforms/channeltalkbot/commands/index.d.ts.map +1 -1
- package/dist/src/platforms/channeltalkbot/commands/index.js +1 -0
- package/dist/src/platforms/channeltalkbot/commands/index.js.map +1 -1
- package/dist/src/platforms/channeltalkbot/commands/whoami.d.ts +13 -0
- package/dist/src/platforms/channeltalkbot/commands/whoami.d.ts.map +1 -0
- package/dist/src/platforms/channeltalkbot/commands/whoami.js +31 -0
- package/dist/src/platforms/channeltalkbot/commands/whoami.js.map +1 -0
- package/dist/src/platforms/discord/cli.d.ts.map +1 -1
- package/dist/src/platforms/discord/cli.js +2 -1
- package/dist/src/platforms/discord/cli.js.map +1 -1
- package/dist/src/platforms/discord/commands/index.d.ts +1 -0
- package/dist/src/platforms/discord/commands/index.d.ts.map +1 -1
- package/dist/src/platforms/discord/commands/index.js +1 -0
- package/dist/src/platforms/discord/commands/index.js.map +1 -1
- package/dist/src/platforms/discord/commands/whoami.d.ts +6 -0
- package/dist/src/platforms/discord/commands/whoami.d.ts.map +1 -0
- package/dist/src/platforms/discord/commands/whoami.js +33 -0
- package/dist/src/platforms/discord/commands/whoami.js.map +1 -0
- package/dist/src/platforms/discordbot/cli.d.ts.map +1 -1
- package/dist/src/platforms/discordbot/cli.js +2 -1
- package/dist/src/platforms/discordbot/cli.js.map +1 -1
- package/dist/src/platforms/discordbot/commands/index.d.ts +1 -0
- package/dist/src/platforms/discordbot/commands/index.d.ts.map +1 -1
- package/dist/src/platforms/discordbot/commands/index.js +1 -0
- package/dist/src/platforms/discordbot/commands/index.js.map +1 -1
- package/dist/src/platforms/discordbot/commands/whoami.d.ts +14 -0
- package/dist/src/platforms/discordbot/commands/whoami.d.ts.map +1 -0
- package/dist/src/platforms/discordbot/commands/whoami.js +32 -0
- package/dist/src/platforms/discordbot/commands/whoami.js.map +1 -0
- package/dist/src/platforms/instagram/cli.d.ts.map +1 -1
- package/dist/src/platforms/instagram/cli.js +2 -1
- package/dist/src/platforms/instagram/cli.js.map +1 -1
- package/dist/src/platforms/instagram/client.d.ts +6 -0
- package/dist/src/platforms/instagram/client.d.ts.map +1 -1
- package/dist/src/platforms/instagram/client.js +12 -0
- package/dist/src/platforms/instagram/client.js.map +1 -1
- package/dist/src/platforms/instagram/commands/index.d.ts +1 -0
- package/dist/src/platforms/instagram/commands/index.d.ts.map +1 -1
- package/dist/src/platforms/instagram/commands/index.js +1 -0
- package/dist/src/platforms/instagram/commands/index.js.map +1 -1
- package/dist/src/platforms/instagram/commands/whoami.d.ts +7 -0
- package/dist/src/platforms/instagram/commands/whoami.d.ts.map +1 -0
- package/dist/src/platforms/instagram/commands/whoami.js +19 -0
- package/dist/src/platforms/instagram/commands/whoami.js.map +1 -0
- package/dist/src/platforms/kakaotalk/cli.js +2 -2
- package/dist/src/platforms/kakaotalk/cli.js.map +1 -1
- package/dist/src/platforms/kakaotalk/client.d.ts +4 -1
- package/dist/src/platforms/kakaotalk/client.d.ts.map +1 -1
- package/dist/src/platforms/kakaotalk/client.js +193 -27
- package/dist/src/platforms/kakaotalk/client.js.map +1 -1
- package/dist/src/platforms/kakaotalk/commands/auth.d.ts.map +1 -1
- package/dist/src/platforms/kakaotalk/commands/auth.js +24 -55
- package/dist/src/platforms/kakaotalk/commands/auth.js.map +1 -1
- package/dist/src/platforms/kakaotalk/commands/index.d.ts +1 -1
- package/dist/src/platforms/kakaotalk/commands/index.d.ts.map +1 -1
- package/dist/src/platforms/kakaotalk/commands/index.js +1 -1
- package/dist/src/platforms/kakaotalk/commands/index.js.map +1 -1
- package/dist/src/platforms/kakaotalk/commands/whoami.d.ts +3 -0
- package/dist/src/platforms/kakaotalk/commands/whoami.d.ts.map +1 -0
- package/dist/src/platforms/kakaotalk/commands/{profile.js → whoami.js} +5 -5
- package/dist/src/platforms/kakaotalk/commands/whoami.js.map +1 -0
- package/dist/src/platforms/kakaotalk/credential-manager.d.ts.map +1 -1
- package/dist/src/platforms/kakaotalk/credential-manager.js +1 -0
- package/dist/src/platforms/kakaotalk/credential-manager.js.map +1 -1
- package/dist/src/platforms/kakaotalk/index.d.ts +1 -1
- package/dist/src/platforms/kakaotalk/index.d.ts.map +1 -1
- package/dist/src/platforms/kakaotalk/index.js.map +1 -1
- package/dist/src/platforms/kakaotalk/listener.js +2 -2
- package/dist/src/platforms/kakaotalk/listener.js.map +1 -1
- package/dist/src/platforms/kakaotalk/protocol/config.d.ts +8 -2
- package/dist/src/platforms/kakaotalk/protocol/config.d.ts.map +1 -1
- package/dist/src/platforms/kakaotalk/protocol/config.js +15 -2
- package/dist/src/platforms/kakaotalk/protocol/config.js.map +1 -1
- package/dist/src/platforms/kakaotalk/protocol/session.d.ts +6 -2
- package/dist/src/platforms/kakaotalk/protocol/session.d.ts.map +1 -1
- package/dist/src/platforms/kakaotalk/protocol/session.js +37 -15
- package/dist/src/platforms/kakaotalk/protocol/session.js.map +1 -1
- package/dist/src/platforms/kakaotalk/protocol/types.d.ts +17 -0
- package/dist/src/platforms/kakaotalk/protocol/types.d.ts.map +1 -1
- package/dist/src/platforms/kakaotalk/protocol/types.js.map +1 -1
- package/dist/src/platforms/kakaotalk/types.d.ts +22 -0
- package/dist/src/platforms/kakaotalk/types.d.ts.map +1 -1
- package/dist/src/platforms/kakaotalk/types.js +7 -0
- package/dist/src/platforms/kakaotalk/types.js.map +1 -1
- package/dist/src/platforms/line/cli.js +2 -2
- package/dist/src/platforms/line/cli.js.map +1 -1
- package/dist/src/platforms/line/commands/auth.d.ts.map +1 -1
- package/dist/src/platforms/line/commands/auth.js +9 -59
- package/dist/src/platforms/line/commands/auth.js.map +1 -1
- package/dist/src/platforms/line/commands/index.d.ts +1 -1
- package/dist/src/platforms/line/commands/index.d.ts.map +1 -1
- package/dist/src/platforms/line/commands/index.js +1 -1
- package/dist/src/platforms/line/commands/index.js.map +1 -1
- package/dist/src/platforms/line/commands/whoami.d.ts +3 -0
- package/dist/src/platforms/line/commands/whoami.d.ts.map +1 -0
- package/dist/src/platforms/line/commands/{profile.js → whoami.js} +5 -5
- package/dist/src/platforms/line/commands/whoami.js.map +1 -0
- package/dist/src/platforms/slack/cli.d.ts.map +1 -1
- package/dist/src/platforms/slack/cli.js +2 -1
- package/dist/src/platforms/slack/cli.js.map +1 -1
- package/dist/src/platforms/slack/commands/index.d.ts +1 -0
- package/dist/src/platforms/slack/commands/index.d.ts.map +1 -1
- package/dist/src/platforms/slack/commands/index.js +1 -0
- package/dist/src/platforms/slack/commands/index.js.map +1 -1
- package/dist/src/platforms/slack/commands/whoami.d.ts +6 -0
- package/dist/src/platforms/slack/commands/whoami.d.ts.map +1 -0
- package/dist/src/platforms/slack/commands/whoami.js +39 -0
- package/dist/src/platforms/slack/commands/whoami.js.map +1 -0
- package/dist/src/platforms/slackbot/cli.d.ts.map +1 -1
- package/dist/src/platforms/slackbot/cli.js +2 -1
- package/dist/src/platforms/slackbot/cli.js.map +1 -1
- package/dist/src/platforms/slackbot/commands/index.d.ts +1 -0
- package/dist/src/platforms/slackbot/commands/index.d.ts.map +1 -1
- package/dist/src/platforms/slackbot/commands/index.js +1 -0
- package/dist/src/platforms/slackbot/commands/index.js.map +1 -1
- package/dist/src/platforms/slackbot/commands/whoami.d.ts +14 -0
- package/dist/src/platforms/slackbot/commands/whoami.d.ts.map +1 -0
- package/dist/src/platforms/slackbot/commands/whoami.js +32 -0
- package/dist/src/platforms/slackbot/commands/whoami.js.map +1 -0
- package/dist/src/platforms/teams/cli.d.ts.map +1 -1
- package/dist/src/platforms/teams/cli.js +2 -1
- package/dist/src/platforms/teams/cli.js.map +1 -1
- package/dist/src/platforms/teams/commands/index.d.ts +1 -0
- package/dist/src/platforms/teams/commands/index.d.ts.map +1 -1
- package/dist/src/platforms/teams/commands/index.js +1 -0
- package/dist/src/platforms/teams/commands/index.js.map +1 -1
- package/dist/src/platforms/teams/commands/whoami.d.ts +6 -0
- package/dist/src/platforms/teams/commands/whoami.d.ts.map +1 -0
- package/dist/src/platforms/teams/commands/whoami.js +30 -0
- package/dist/src/platforms/teams/commands/whoami.js.map +1 -0
- package/dist/src/platforms/telegram/cli.d.ts.map +1 -1
- package/dist/src/platforms/telegram/cli.js +2 -1
- package/dist/src/platforms/telegram/cli.js.map +1 -1
- package/dist/src/platforms/telegram/commands/index.d.ts +1 -0
- package/dist/src/platforms/telegram/commands/index.d.ts.map +1 -1
- package/dist/src/platforms/telegram/commands/index.js +1 -0
- package/dist/src/platforms/telegram/commands/index.js.map +1 -1
- package/dist/src/platforms/telegram/commands/whoami.d.ts +7 -0
- package/dist/src/platforms/telegram/commands/whoami.d.ts.map +1 -0
- package/dist/src/platforms/telegram/commands/whoami.js +27 -0
- package/dist/src/platforms/telegram/commands/whoami.js.map +1 -0
- package/dist/src/platforms/webex/cli.d.ts.map +1 -1
- package/dist/src/platforms/webex/cli.js +2 -1
- package/dist/src/platforms/webex/cli.js.map +1 -1
- package/dist/src/platforms/webex/commands/index.d.ts +1 -0
- package/dist/src/platforms/webex/commands/index.d.ts.map +1 -1
- package/dist/src/platforms/webex/commands/index.js +1 -0
- package/dist/src/platforms/webex/commands/index.js.map +1 -1
- package/dist/src/platforms/webex/commands/message.js +1 -1
- package/dist/src/platforms/webex/commands/message.js.map +1 -1
- package/dist/src/platforms/webex/commands/whoami.d.ts +6 -0
- package/dist/src/platforms/webex/commands/whoami.d.ts.map +1 -0
- package/dist/src/platforms/webex/commands/whoami.js +30 -0
- package/dist/src/platforms/webex/commands/whoami.js.map +1 -0
- package/dist/src/platforms/wechatbot/cli.d.ts.map +1 -1
- package/dist/src/platforms/wechatbot/cli.js +2 -1
- package/dist/src/platforms/wechatbot/cli.js.map +1 -1
- package/dist/src/platforms/wechatbot/commands/index.d.ts +1 -0
- package/dist/src/platforms/wechatbot/commands/index.d.ts.map +1 -1
- package/dist/src/platforms/wechatbot/commands/index.js +1 -0
- package/dist/src/platforms/wechatbot/commands/index.js.map +1 -1
- package/dist/src/platforms/wechatbot/commands/whoami.d.ts +12 -0
- package/dist/src/platforms/wechatbot/commands/whoami.d.ts.map +1 -0
- package/dist/src/platforms/wechatbot/commands/whoami.js +33 -0
- package/dist/src/platforms/wechatbot/commands/whoami.js.map +1 -0
- package/dist/src/platforms/whatsapp/cli.d.ts.map +1 -1
- package/dist/src/platforms/whatsapp/cli.js +2 -1
- package/dist/src/platforms/whatsapp/cli.js.map +1 -1
- package/dist/src/platforms/whatsapp/client.d.ts +8 -0
- package/dist/src/platforms/whatsapp/client.d.ts.map +1 -1
- package/dist/src/platforms/whatsapp/client.js +116 -8
- package/dist/src/platforms/whatsapp/client.js.map +1 -1
- package/dist/src/platforms/whatsapp/commands/auth.d.ts.map +1 -1
- package/dist/src/platforms/whatsapp/commands/auth.js +115 -45
- package/dist/src/platforms/whatsapp/commands/auth.js.map +1 -1
- package/dist/src/platforms/whatsapp/commands/index.d.ts +1 -0
- package/dist/src/platforms/whatsapp/commands/index.d.ts.map +1 -1
- package/dist/src/platforms/whatsapp/commands/index.js +1 -0
- package/dist/src/platforms/whatsapp/commands/index.js.map +1 -1
- package/dist/src/platforms/whatsapp/commands/shared.js +2 -2
- package/dist/src/platforms/whatsapp/commands/shared.js.map +1 -1
- package/dist/src/platforms/whatsapp/commands/whoami.d.ts +7 -0
- package/dist/src/platforms/whatsapp/commands/whoami.d.ts.map +1 -0
- package/dist/src/platforms/whatsapp/commands/whoami.js +19 -0
- package/dist/src/platforms/whatsapp/commands/whoami.js.map +1 -0
- package/dist/src/platforms/whatsapp/ensure-auth.js +2 -2
- package/dist/src/platforms/whatsapp/ensure-auth.js.map +1 -1
- package/dist/src/platforms/whatsappbot/cli.d.ts.map +1 -1
- package/dist/src/platforms/whatsappbot/cli.js +2 -1
- package/dist/src/platforms/whatsappbot/cli.js.map +1 -1
- package/dist/src/platforms/whatsappbot/commands/index.d.ts +1 -0
- package/dist/src/platforms/whatsappbot/commands/index.d.ts.map +1 -1
- package/dist/src/platforms/whatsappbot/commands/index.js +1 -0
- package/dist/src/platforms/whatsappbot/commands/index.js.map +1 -1
- package/dist/src/platforms/whatsappbot/commands/whoami.d.ts +17 -0
- package/dist/src/platforms/whatsappbot/commands/whoami.d.ts.map +1 -0
- package/dist/src/platforms/whatsappbot/commands/whoami.js +39 -0
- package/dist/src/platforms/whatsappbot/commands/whoami.js.map +1 -0
- package/dist/src/shared/utils/qr.d.ts +15 -0
- package/dist/src/shared/utils/qr.d.ts.map +1 -0
- package/dist/src/shared/utils/qr.js +74 -0
- package/dist/src/shared/utils/qr.js.map +1 -0
- package/dist/src/tui/adapters/kakaotalk-adapter.d.ts.map +1 -1
- package/dist/src/tui/adapters/kakaotalk-adapter.js +5 -2
- package/dist/src/tui/adapters/kakaotalk-adapter.js.map +1 -1
- package/dist/src/tui/adapters/whatsapp-adapter.d.ts.map +1 -1
- package/dist/src/tui/adapters/whatsapp-adapter.js +20 -15
- package/dist/src/tui/adapters/whatsapp-adapter.js.map +1 -1
- package/docs/content/docs/cli/channeltalk.mdx +11 -0
- package/docs/content/docs/cli/channeltalkbot.mdx +9 -0
- package/docs/content/docs/cli/discord.mdx +10 -0
- package/docs/content/docs/cli/discordbot.mdx +9 -0
- package/docs/content/docs/cli/instagram.mdx +11 -0
- package/docs/content/docs/cli/kakaotalk.mdx +27 -39
- package/docs/content/docs/cli/line.mdx +4 -4
- package/docs/content/docs/cli/slack.mdx +10 -0
- package/docs/content/docs/cli/slackbot.mdx +9 -0
- package/docs/content/docs/cli/teams.mdx +10 -0
- package/docs/content/docs/cli/telegram.mdx +11 -0
- package/docs/content/docs/cli/webex.mdx +10 -0
- package/docs/content/docs/cli/wechatbot.mdx +9 -0
- package/docs/content/docs/cli/whatsapp.mdx +36 -7
- package/docs/content/docs/cli/whatsappbot.mdx +9 -0
- package/e2e/config.ts +1 -1
- package/package.json +3 -1
- package/skills/agent-channeltalk/SKILL.md +12 -1
- package/skills/agent-channeltalkbot/SKILL.md +10 -1
- package/skills/agent-discord/SKILL.md +11 -1
- package/skills/agent-discordbot/SKILL.md +10 -1
- package/skills/agent-instagram/SKILL.md +12 -1
- package/skills/agent-kakaotalk/SKILL.md +24 -70
- package/skills/agent-kakaotalk/references/authentication.md +4 -69
- package/skills/agent-kakaotalk/references/common-patterns.md +14 -1
- package/skills/agent-line/SKILL.md +5 -5
- package/skills/agent-slack/SKILL.md +11 -1
- package/skills/agent-slackbot/SKILL.md +10 -1
- package/skills/agent-teams/SKILL.md +11 -1
- package/skills/agent-telegram/SKILL.md +6 -1
- package/skills/agent-webex/SKILL.md +11 -1
- package/skills/agent-wechatbot/SKILL.md +10 -1
- package/skills/agent-whatsapp/SKILL.md +52 -15
- package/skills/agent-whatsapp/references/authentication.md +36 -6
- package/skills/agent-whatsappbot/SKILL.md +10 -1
- package/src/platforms/channeltalk/cli.ts +2 -0
- package/src/platforms/channeltalk/commands/index.ts +1 -0
- package/src/platforms/channeltalk/commands/whoami.test.ts +64 -0
- package/src/platforms/channeltalk/commands/whoami.ts +62 -0
- package/src/platforms/channeltalkbot/cli.ts +2 -0
- package/src/platforms/channeltalkbot/commands/index.ts +1 -0
- package/src/platforms/channeltalkbot/commands/whoami.test.ts +104 -0
- package/src/platforms/channeltalkbot/commands/whoami.ts +42 -0
- package/src/platforms/discord/cli.ts +2 -0
- package/src/platforms/discord/commands/index.ts +1 -0
- package/src/platforms/discord/commands/whoami.test.ts +91 -0
- package/src/platforms/discord/commands/whoami.ts +36 -0
- package/src/platforms/discordbot/cli.ts +2 -0
- package/src/platforms/discordbot/commands/index.ts +1 -0
- package/src/platforms/discordbot/commands/whoami.test.ts +96 -0
- package/src/platforms/discordbot/commands/whoami.ts +44 -0
- package/src/platforms/instagram/cli.ts +2 -1
- package/src/platforms/instagram/client.ts +13 -0
- package/src/platforms/instagram/commands/chat.test.ts +1 -5
- package/src/platforms/instagram/commands/index.ts +1 -0
- package/src/platforms/instagram/commands/message.test.ts +1 -5
- package/src/platforms/instagram/commands/whoami.test.ts +60 -0
- package/src/platforms/instagram/commands/whoami.ts +21 -0
- package/src/platforms/kakaotalk/cli.ts +2 -2
- package/src/platforms/kakaotalk/client.test.ts +25 -14
- package/src/platforms/kakaotalk/client.ts +228 -33
- package/src/platforms/kakaotalk/commands/auth.ts +22 -73
- package/src/platforms/kakaotalk/commands/index.ts +1 -1
- package/src/platforms/kakaotalk/commands/{profile.test.ts → whoami.test.ts} +37 -5
- package/src/platforms/kakaotalk/commands/{profile.ts → whoami.ts} +4 -4
- package/src/platforms/kakaotalk/credential-manager.ts +1 -0
- package/src/platforms/kakaotalk/index.ts +1 -0
- package/src/platforms/kakaotalk/listener.test.ts +2 -2
- package/src/platforms/kakaotalk/listener.ts +2 -2
- package/src/platforms/kakaotalk/protocol/config.ts +26 -2
- package/src/platforms/kakaotalk/protocol/session.ts +42 -16
- package/src/platforms/kakaotalk/protocol/types.ts +9 -0
- package/src/platforms/kakaotalk/types.ts +16 -0
- package/src/platforms/line/cli.ts +2 -2
- package/src/platforms/line/commands/auth.ts +37 -70
- package/src/platforms/line/commands/index.ts +1 -1
- package/src/platforms/line/commands/{profile.test.ts → whoami.test.ts} +11 -11
- package/src/platforms/line/commands/{profile.ts → whoami.ts} +4 -4
- package/src/platforms/slack/cli.ts +2 -0
- package/src/platforms/slack/commands/index.ts +1 -0
- package/src/platforms/slack/commands/whoami.test.ts +126 -0
- package/src/platforms/slack/commands/whoami.ts +40 -0
- package/src/platforms/slackbot/cli.ts +2 -1
- package/src/platforms/slackbot/commands/index.ts +1 -0
- package/src/platforms/slackbot/commands/whoami.test.ts +102 -0
- package/src/platforms/slackbot/commands/whoami.ts +44 -0
- package/src/platforms/teams/cli.ts +2 -0
- package/src/platforms/teams/commands/index.ts +1 -0
- package/src/platforms/teams/commands/whoami.test.ts +83 -0
- package/src/platforms/teams/commands/whoami.ts +33 -0
- package/src/platforms/telegram/cli.ts +2 -1
- package/src/platforms/telegram/commands/index.ts +1 -0
- package/src/platforms/telegram/commands/whoami.test.ts +75 -0
- package/src/platforms/telegram/commands/whoami.ts +29 -0
- package/src/platforms/webex/cli.ts +2 -1
- package/src/platforms/webex/commands/auth.test.ts +58 -46
- package/src/platforms/webex/commands/index.ts +1 -0
- package/src/platforms/webex/commands/member.test.ts +1 -5
- package/src/platforms/webex/commands/message.test.ts +1 -5
- package/src/platforms/webex/commands/message.ts +1 -1
- package/src/platforms/webex/commands/snapshot.test.ts +1 -5
- package/src/platforms/webex/commands/space.test.ts +1 -5
- package/src/platforms/webex/commands/whoami.test.ts +113 -0
- package/src/platforms/webex/commands/whoami.ts +31 -0
- package/src/platforms/webex/credential-manager.test.ts +0 -1
- package/src/platforms/wechatbot/cli.ts +2 -1
- package/src/platforms/wechatbot/commands/index.ts +1 -0
- package/src/platforms/wechatbot/commands/whoami.test.ts +109 -0
- package/src/platforms/wechatbot/commands/whoami.ts +43 -0
- package/src/platforms/whatsapp/cli.ts +2 -1
- package/src/platforms/whatsapp/client.ts +156 -24
- package/src/platforms/whatsapp/commands/auth.ts +176 -70
- package/src/platforms/whatsapp/commands/index.ts +1 -0
- package/src/platforms/whatsapp/commands/shared.ts +2 -2
- package/src/platforms/whatsapp/commands/whoami.test.ts +59 -0
- package/src/platforms/whatsapp/commands/whoami.ts +21 -0
- package/src/platforms/whatsapp/ensure-auth.ts +2 -2
- package/src/platforms/whatsappbot/cli.ts +2 -1
- package/src/platforms/whatsappbot/commands/index.ts +1 -0
- package/src/platforms/whatsappbot/commands/whoami.test.ts +100 -0
- package/src/platforms/whatsappbot/commands/whoami.ts +57 -0
- package/src/shared/utils/qr.ts +92 -0
- package/src/tui/adapters/kakaotalk-adapter.ts +5 -2
- package/src/tui/adapters/whatsapp-adapter.ts +19 -16
- package/dist/src/platforms/kakaotalk/commands/profile.d.ts +0 -3
- package/dist/src/platforms/kakaotalk/commands/profile.d.ts.map +0 -1
- package/dist/src/platforms/kakaotalk/commands/profile.js.map +0 -1
- package/dist/src/platforms/line/commands/profile.d.ts +0 -3
- package/dist/src/platforms/line/commands/profile.d.ts.map +0 -1
- package/dist/src/platforms/line/commands/profile.js.map +0 -1
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { Command } from 'commander'
|
|
2
|
+
import { handleError } from '@/shared/utils/error-handler'
|
|
3
|
+
import { formatOutput } from '@/shared/utils/output'
|
|
4
|
+
import { SlackClient } from '../client'
|
|
5
|
+
import { CredentialManager } from '../credential-manager'
|
|
6
|
+
|
|
7
|
+
export async function whoamiAction(options: { pretty?: boolean }): Promise<void> {
|
|
8
|
+
try {
|
|
9
|
+
const credManager = new CredentialManager()
|
|
10
|
+
const workspace = await credManager.getWorkspace()
|
|
11
|
+
if (!workspace) {
|
|
12
|
+
console.log(formatOutput({ error: 'No current workspace set. Run "auth extract" first.' }, options.pretty))
|
|
13
|
+
return process.exit(1)
|
|
14
|
+
}
|
|
15
|
+
const client = await new SlackClient().login({ token: workspace.token, cookie: workspace.cookie })
|
|
16
|
+
const authInfo = await client.testAuth()
|
|
17
|
+
const user = await client.getUser(authInfo.user_id)
|
|
18
|
+
|
|
19
|
+
const output = {
|
|
20
|
+
id: user.id,
|
|
21
|
+
name: user.name,
|
|
22
|
+
real_name: user.real_name,
|
|
23
|
+
is_admin: user.is_admin,
|
|
24
|
+
is_owner: user.is_owner,
|
|
25
|
+
is_bot: user.is_bot,
|
|
26
|
+
is_app_user: user.is_app_user,
|
|
27
|
+
team_id: authInfo.team_id,
|
|
28
|
+
team: authInfo.team,
|
|
29
|
+
profile: user.profile,
|
|
30
|
+
}
|
|
31
|
+
console.log(formatOutput(output, options.pretty))
|
|
32
|
+
} catch (error) {
|
|
33
|
+
handleError(error as Error)
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export const whoamiCommand = new Command('whoami')
|
|
38
|
+
.description('Show current authenticated user')
|
|
39
|
+
.option('--pretty', 'Pretty print JSON output')
|
|
40
|
+
.action(whoamiAction)
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import { Command } from 'commander'
|
|
4
4
|
|
|
5
5
|
import pkg from '../../../package.json' with { type: 'json' }
|
|
6
|
-
import { authCommand, channelCommand, messageCommand, reactionCommand, userCommand } from './commands/index'
|
|
6
|
+
import { authCommand, channelCommand, messageCommand, reactionCommand, userCommand, whoamiCommand } from './commands/index'
|
|
7
7
|
|
|
8
8
|
const program = new Command()
|
|
9
9
|
|
|
@@ -14,6 +14,7 @@ program
|
|
|
14
14
|
.option('--bot <id>', 'Use specific bot (default: current)')
|
|
15
15
|
|
|
16
16
|
program.addCommand(authCommand)
|
|
17
|
+
program.addCommand(whoamiCommand)
|
|
17
18
|
program.addCommand(messageCommand)
|
|
18
19
|
program.addCommand(channelCommand)
|
|
19
20
|
program.addCommand(userCommand)
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { afterEach, beforeEach, describe, expect, mock, test } from 'bun:test'
|
|
2
|
+
import { existsSync, rmSync } from 'node:fs'
|
|
3
|
+
import { mkdir } from 'node:fs/promises'
|
|
4
|
+
import { tmpdir } from 'node:os'
|
|
5
|
+
import { join } from 'node:path'
|
|
6
|
+
|
|
7
|
+
const mockTestAuth = mock(() =>
|
|
8
|
+
Promise.resolve({
|
|
9
|
+
user_id: 'U123',
|
|
10
|
+
team_id: 'T456',
|
|
11
|
+
bot_id: 'B789',
|
|
12
|
+
user: 'testbot',
|
|
13
|
+
team: 'Test Team',
|
|
14
|
+
}),
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
mock.module('../client', () => ({
|
|
18
|
+
SlackBotClient: class MockSlackBotClient {
|
|
19
|
+
async login(_credentials?: any) {
|
|
20
|
+
return this
|
|
21
|
+
}
|
|
22
|
+
testAuth = mockTestAuth
|
|
23
|
+
},
|
|
24
|
+
}))
|
|
25
|
+
|
|
26
|
+
import { SlackBotCredentialManager } from '../credential-manager'
|
|
27
|
+
import { whoamiAction } from './whoami'
|
|
28
|
+
|
|
29
|
+
describe('whoami command', () => {
|
|
30
|
+
let tempDir: string
|
|
31
|
+
let originalEnv: NodeJS.ProcessEnv
|
|
32
|
+
|
|
33
|
+
beforeEach(async () => {
|
|
34
|
+
tempDir = join(tmpdir(), `slackbot-whoami-test-${Date.now()}`)
|
|
35
|
+
await mkdir(tempDir, { recursive: true })
|
|
36
|
+
originalEnv = { ...process.env }
|
|
37
|
+
delete process.env.E2E_SLACKBOT_TOKEN
|
|
38
|
+
mockTestAuth.mockClear()
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
afterEach(() => {
|
|
42
|
+
if (existsSync(tempDir)) {
|
|
43
|
+
rmSync(tempDir, { recursive: true })
|
|
44
|
+
}
|
|
45
|
+
process.env = originalEnv
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
test('returns auth info for current bot', async () => {
|
|
49
|
+
const manager = new SlackBotCredentialManager(tempDir)
|
|
50
|
+
await manager.setCredentials({
|
|
51
|
+
token: 'xoxb-test-token',
|
|
52
|
+
workspace_id: 'T456',
|
|
53
|
+
workspace_name: 'Test Workspace',
|
|
54
|
+
bot_id: 'B789',
|
|
55
|
+
bot_name: 'Test Bot',
|
|
56
|
+
})
|
|
57
|
+
|
|
58
|
+
const result = await whoamiAction({ _credManager: manager })
|
|
59
|
+
|
|
60
|
+
expect(result.user_id).toBe('U123')
|
|
61
|
+
expect(result.team_id).toBe('T456')
|
|
62
|
+
expect(result.bot_id).toBe('B789')
|
|
63
|
+
expect(result.user).toBe('testbot')
|
|
64
|
+
expect(result.team).toBe('Test Team')
|
|
65
|
+
expect(result.error).toBeUndefined()
|
|
66
|
+
})
|
|
67
|
+
|
|
68
|
+
test('returns auth info for specific --bot', async () => {
|
|
69
|
+
const manager = new SlackBotCredentialManager(tempDir)
|
|
70
|
+
await manager.setCredentials({
|
|
71
|
+
token: 'xoxb-test-token',
|
|
72
|
+
workspace_id: 'T456',
|
|
73
|
+
workspace_name: 'Test Workspace',
|
|
74
|
+
bot_id: 'deploy',
|
|
75
|
+
bot_name: 'Deploy Bot',
|
|
76
|
+
})
|
|
77
|
+
|
|
78
|
+
const result = await whoamiAction({ bot: 'deploy', _credManager: manager })
|
|
79
|
+
|
|
80
|
+
expect(result.user_id).toBe('U123')
|
|
81
|
+
expect(result.team_id).toBe('T456')
|
|
82
|
+
expect(mockTestAuth).toHaveBeenCalledTimes(1)
|
|
83
|
+
})
|
|
84
|
+
|
|
85
|
+
test('returns error when client throws', async () => {
|
|
86
|
+
mockTestAuth.mockImplementationOnce(() => Promise.reject(new Error('API Error')))
|
|
87
|
+
|
|
88
|
+
const manager = new SlackBotCredentialManager(tempDir)
|
|
89
|
+
await manager.setCredentials({
|
|
90
|
+
token: 'xoxb-test-token',
|
|
91
|
+
workspace_id: 'T456',
|
|
92
|
+
workspace_name: 'Test Workspace',
|
|
93
|
+
bot_id: 'B789',
|
|
94
|
+
bot_name: 'Test Bot',
|
|
95
|
+
})
|
|
96
|
+
|
|
97
|
+
const result = await whoamiAction({ _credManager: manager })
|
|
98
|
+
|
|
99
|
+
expect(result.error).toBeDefined()
|
|
100
|
+
expect(result.error).toContain('API Error')
|
|
101
|
+
})
|
|
102
|
+
})
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { Command } from 'commander'
|
|
2
|
+
|
|
3
|
+
import { formatOutput } from '@/shared/utils/output'
|
|
4
|
+
|
|
5
|
+
import type { BotOption } from './shared'
|
|
6
|
+
import { getClient } from './shared'
|
|
7
|
+
|
|
8
|
+
interface WhoamiResult {
|
|
9
|
+
user_id?: string
|
|
10
|
+
team_id?: string
|
|
11
|
+
bot_id?: string
|
|
12
|
+
user?: string
|
|
13
|
+
team?: string
|
|
14
|
+
error?: string
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export async function whoamiAction(options: BotOption): Promise<WhoamiResult> {
|
|
18
|
+
try {
|
|
19
|
+
const client = await getClient(options)
|
|
20
|
+
const info = await client.testAuth()
|
|
21
|
+
return {
|
|
22
|
+
user_id: info.user_id,
|
|
23
|
+
team_id: info.team_id,
|
|
24
|
+
bot_id: info.bot_id,
|
|
25
|
+
user: info.user,
|
|
26
|
+
team: info.team,
|
|
27
|
+
}
|
|
28
|
+
} catch (error) {
|
|
29
|
+
return { error: (error as Error).message }
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function cliOutput(result: WhoamiResult, pretty?: boolean): void {
|
|
34
|
+
console.log(formatOutput(result, pretty))
|
|
35
|
+
if (result.error) process.exit(1)
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export const whoamiCommand = new Command('whoami')
|
|
39
|
+
.description('Show current authenticated bot')
|
|
40
|
+
.option('--bot <id>', 'Bot ID to use')
|
|
41
|
+
.option('--pretty', 'Pretty print JSON output')
|
|
42
|
+
.action(async (opts: BotOption) => {
|
|
43
|
+
cliOutput(await whoamiAction(opts), opts.pretty)
|
|
44
|
+
})
|
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
snapshotCommand,
|
|
14
14
|
teamCommand,
|
|
15
15
|
userCommand,
|
|
16
|
+
whoamiCommand,
|
|
16
17
|
} from './commands'
|
|
17
18
|
import { TeamsCredentialManager } from './credential-manager'
|
|
18
19
|
import { ensureTeamsAuth } from './ensure-auth'
|
|
@@ -53,6 +54,7 @@ program.addCommand(messageCommand)
|
|
|
53
54
|
program.addCommand(reactionCommand)
|
|
54
55
|
program.addCommand(snapshotCommand)
|
|
55
56
|
program.addCommand(userCommand)
|
|
57
|
+
program.addCommand(whoamiCommand)
|
|
56
58
|
|
|
57
59
|
program.parse(process.argv)
|
|
58
60
|
|
|
@@ -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,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
|
|