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.
- package/.claude-plugin/README.md +16 -16
- package/.claude-plugin/marketplace.json +29 -29
- package/.claude-plugin/plugin.json +5 -5
- package/.github/workflows/release.yml +0 -12
- package/CONTRIBUTING.md +1 -1
- package/README.md +11 -8
- package/bun.lock +70 -110
- package/bunfig.toml +3 -0
- package/dist/package.json +11 -3
- 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/client.js +2 -2
- package/dist/src/platforms/discordbot/client.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.d.ts.map +1 -1
- package/dist/src/platforms/kakaotalk/cli.js +2 -1
- package/dist/src/platforms/kakaotalk/cli.js.map +1 -1
- package/dist/src/platforms/kakaotalk/client.d.ts +2 -1
- package/dist/src/platforms/kakaotalk/client.d.ts.map +1 -1
- package/dist/src/platforms/kakaotalk/client.js +225 -23
- package/dist/src/platforms/kakaotalk/client.js.map +1 -1
- package/dist/src/platforms/kakaotalk/commands/index.d.ts +1 -0
- package/dist/src/platforms/kakaotalk/commands/index.d.ts.map +1 -1
- package/dist/src/platforms/kakaotalk/commands/index.js +1 -0
- 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/whoami.js +19 -0
- package/dist/src/platforms/kakaotalk/commands/whoami.js.map +1 -0
- package/dist/src/platforms/kakaotalk/index.d.ts +2 -2
- package/dist/src/platforms/kakaotalk/index.d.ts.map +1 -1
- package/dist/src/platforms/kakaotalk/index.js +1 -1
- package/dist/src/platforms/kakaotalk/index.js.map +1 -1
- package/dist/src/platforms/kakaotalk/protocol/session.d.ts +4 -2
- package/dist/src/platforms/kakaotalk/protocol/session.d.ts.map +1 -1
- package/dist/src/platforms/kakaotalk/protocol/session.js +27 -7
- 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 +28 -0
- package/dist/src/platforms/kakaotalk/types.d.ts.map +1 -1
- package/dist/src/platforms/kakaotalk/types.js +14 -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/client.d.ts.map +1 -1
- package/dist/src/platforms/line/client.js +9 -36
- package/dist/src/platforms/line/client.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 -47
- 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/reaction.d.ts.map +1 -1
- package/dist/src/platforms/teams/commands/reaction.js +2 -0
- package/dist/src/platforms/teams/commands/reaction.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 +5 -0
- package/dist/src/platforms/wechatbot/cli.d.ts.map +1 -0
- package/dist/src/platforms/wechatbot/cli.js +19 -0
- package/dist/src/platforms/wechatbot/cli.js.map +1 -0
- package/dist/src/platforms/wechatbot/client.d.ts +36 -0
- package/dist/src/platforms/wechatbot/client.d.ts.map +1 -0
- package/dist/src/platforms/wechatbot/client.js +208 -0
- package/dist/src/platforms/wechatbot/client.js.map +1 -0
- package/dist/src/platforms/wechatbot/commands/auth.d.ts +28 -0
- package/dist/src/platforms/wechatbot/commands/auth.d.ts.map +1 -0
- package/dist/src/platforms/wechatbot/commands/auth.js +164 -0
- package/dist/src/platforms/wechatbot/commands/auth.js.map +1 -0
- package/dist/src/platforms/wechatbot/commands/index.d.ts +6 -0
- package/dist/src/platforms/wechatbot/commands/index.d.ts.map +1 -0
- package/dist/src/platforms/wechatbot/commands/index.js +6 -0
- package/dist/src/platforms/wechatbot/commands/index.js.map +1 -0
- package/dist/src/platforms/wechatbot/commands/message.d.ts +18 -0
- package/dist/src/platforms/wechatbot/commands/message.d.ts.map +1 -0
- package/dist/src/platforms/wechatbot/commands/message.js +80 -0
- package/dist/src/platforms/wechatbot/commands/message.js.map +1 -0
- package/dist/src/platforms/wechatbot/commands/shared.d.ts +9 -0
- package/dist/src/platforms/wechatbot/commands/shared.d.ts.map +1 -0
- package/dist/src/platforms/wechatbot/commands/shared.js +13 -0
- package/dist/src/platforms/wechatbot/commands/shared.js.map +1 -0
- package/dist/src/platforms/wechatbot/commands/template.d.ts +19 -0
- package/dist/src/platforms/wechatbot/commands/template.d.ts.map +1 -0
- package/dist/src/platforms/wechatbot/commands/template.js +76 -0
- package/dist/src/platforms/wechatbot/commands/template.js.map +1 -0
- package/dist/src/platforms/wechatbot/commands/user.d.ts +20 -0
- package/dist/src/platforms/wechatbot/commands/user.d.ts.map +1 -0
- package/dist/src/platforms/wechatbot/commands/user.js +53 -0
- package/dist/src/platforms/wechatbot/commands/user.js.map +1 -0
- 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/wechatbot/credential-manager.d.ts +17 -0
- package/dist/src/platforms/wechatbot/credential-manager.d.ts.map +1 -0
- package/dist/src/platforms/wechatbot/credential-manager.js +121 -0
- package/dist/src/platforms/wechatbot/credential-manager.js.map +1 -0
- package/dist/src/platforms/wechatbot/index.d.ts +5 -0
- package/dist/src/platforms/wechatbot/index.d.ts.map +1 -0
- package/dist/src/platforms/wechatbot/index.js +4 -0
- package/dist/src/platforms/wechatbot/index.js.map +1 -0
- package/dist/src/platforms/wechatbot/types.d.ts +94 -0
- package/dist/src/platforms/wechatbot/types.d.ts.map +1 -0
- package/dist/src/platforms/wechatbot/types.js +54 -0
- package/dist/src/platforms/wechatbot/types.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 +9 -0
- package/dist/src/platforms/whatsapp/client.d.ts.map +1 -1
- package/dist/src/platforms/whatsapp/client.js +143 -21
- 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 +133 -60
- 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/credential-manager.d.ts.map +1 -1
- package/dist/src/platforms/whatsapp/credential-manager.js +14 -8
- package/dist/src/platforms/whatsapp/credential-manager.js.map +1 -1
- 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/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/agent-skills.mdx +4 -4
- package/docs/content/docs/cli/channeltalk.mdx +12 -1
- package/docs/content/docs/cli/channeltalkbot.mdx +10 -1
- package/docs/content/docs/cli/discord.mdx +11 -1
- package/docs/content/docs/cli/discordbot.mdx +10 -1
- package/docs/content/docs/cli/instagram.mdx +12 -1
- package/docs/content/docs/cli/kakaotalk.mdx +25 -1
- package/docs/content/docs/cli/line.mdx +5 -5
- package/docs/content/docs/cli/meta.json +1 -0
- package/docs/content/docs/cli/slack.mdx +11 -1
- package/docs/content/docs/cli/slackbot.mdx +10 -1
- package/docs/content/docs/cli/teams.mdx +11 -1
- package/docs/content/docs/cli/telegram.mdx +11 -0
- package/docs/content/docs/cli/webex.mdx +11 -1
- package/docs/content/docs/cli/wechatbot.mdx +188 -0
- package/docs/content/docs/cli/whatsapp.mdx +37 -8
- package/docs/content/docs/cli/whatsappbot.mdx +10 -1
- package/docs/content/docs/sdk/meta.json +1 -1
- package/docs/content/docs/sdk/wechatbot.mdx +282 -0
- package/docs/content/docs/tui.mdx +1 -1
- package/docs/src/app/page.tsx +5 -5
- package/package.json +11 -3
- 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 +30 -1
- package/skills/agent-kakaotalk/references/common-patterns.md +1 -1
- package/skills/agent-line/SKILL.md +11 -15
- package/skills/agent-line/references/authentication.md +13 -4
- 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 +394 -0
- package/skills/agent-whatsapp/SKILL.md +63 -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/discord/credential-manager.test.ts +18 -1
- package/src/platforms/discordbot/cli.ts +2 -0
- package/src/platforms/discordbot/client.ts +2 -2
- 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/auth.test.ts +216 -0
- package/src/platforms/instagram/commands/chat.test.ts +123 -0
- package/src/platforms/instagram/commands/index.ts +1 -0
- package/src/platforms/instagram/commands/message.test.ts +174 -0
- 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 -1
- package/src/platforms/kakaotalk/client.test.ts +182 -14
- package/src/platforms/kakaotalk/client.ts +261 -27
- package/src/platforms/kakaotalk/commands/auth.test.ts +299 -0
- package/src/platforms/kakaotalk/commands/chat.test.ts +97 -0
- package/src/platforms/kakaotalk/commands/index.ts +1 -0
- package/src/platforms/kakaotalk/commands/message.test.ts +113 -0
- package/src/platforms/kakaotalk/commands/whoami.test.ts +116 -0
- package/src/platforms/kakaotalk/commands/whoami.ts +21 -0
- package/src/platforms/kakaotalk/index.test.ts +5 -0
- package/src/platforms/kakaotalk/index.ts +2 -0
- package/src/platforms/kakaotalk/protocol/session.ts +29 -7
- package/src/platforms/kakaotalk/protocol/types.ts +9 -0
- package/src/platforms/kakaotalk/types.ts +30 -0
- package/src/platforms/line/cli.ts +2 -2
- package/src/platforms/line/client.ts +14 -39
- package/src/platforms/line/commands/auth.test.ts +141 -0
- package/src/platforms/line/commands/auth.ts +37 -61
- package/src/platforms/line/commands/chat.test.ts +110 -0
- package/src/platforms/line/commands/friend.test.ts +98 -0
- package/src/platforms/line/commands/index.ts +1 -1
- package/src/platforms/line/commands/message.test.ts +119 -0
- package/src/platforms/line/commands/whoami.test.ts +85 -0
- 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/channel.test.ts +139 -0
- package/src/platforms/slackbot/commands/index.ts +1 -0
- package/src/platforms/slackbot/commands/message.test.ts +226 -0
- package/src/platforms/slackbot/commands/reaction.test.ts +90 -0
- package/src/platforms/slackbot/commands/user.test.ts +143 -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/reaction.test.ts +45 -61
- package/src/platforms/teams/commands/reaction.ts +2 -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/chat.test.ts +125 -0
- package/src/platforms/telegram/commands/index.ts +1 -0
- package/src/platforms/telegram/commands/message.test.ts +92 -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 +60 -57
- package/src/platforms/webex/commands/message.test.ts +74 -121
- package/src/platforms/webex/commands/message.ts +1 -1
- package/src/platforms/webex/commands/snapshot.test.ts +54 -45
- package/src/platforms/webex/commands/space.test.ts +46 -49
- 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 +25 -0
- package/src/platforms/wechatbot/client.test.ts +497 -0
- package/src/platforms/wechatbot/client.ts +268 -0
- package/src/platforms/wechatbot/commands/auth.test.ts +211 -0
- package/src/platforms/wechatbot/commands/auth.ts +203 -0
- package/src/platforms/wechatbot/commands/index.ts +5 -0
- package/src/platforms/wechatbot/commands/message.test.ts +155 -0
- package/src/platforms/wechatbot/commands/message.ts +104 -0
- package/src/platforms/wechatbot/commands/shared.ts +22 -0
- package/src/platforms/wechatbot/commands/template.test.ts +199 -0
- package/src/platforms/wechatbot/commands/template.ts +102 -0
- package/src/platforms/wechatbot/commands/user.test.ts +165 -0
- package/src/platforms/wechatbot/commands/user.ts +75 -0
- package/src/platforms/wechatbot/commands/whoami.test.ts +109 -0
- package/src/platforms/wechatbot/commands/whoami.ts +43 -0
- package/src/platforms/wechatbot/credential-manager.test.ts +255 -0
- package/src/platforms/wechatbot/credential-manager.ts +148 -0
- package/src/platforms/wechatbot/index.test.ts +49 -0
- package/src/platforms/wechatbot/index.ts +19 -0
- package/src/platforms/wechatbot/types.test.ts +223 -0
- package/src/platforms/wechatbot/types.ts +107 -0
- package/src/platforms/whatsapp/cli.ts +2 -1
- package/src/platforms/whatsapp/client.ts +180 -37
- package/src/platforms/whatsapp/commands/auth.test.ts +311 -0
- package/src/platforms/whatsapp/commands/auth.ts +194 -84
- package/src/platforms/whatsapp/commands/chat.test.ts +198 -0
- package/src/platforms/whatsapp/commands/index.ts +1 -0
- package/src/platforms/whatsapp/commands/message.test.ts +231 -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/credential-manager.test.ts +20 -0
- package/src/platforms/whatsapp/credential-manager.ts +17 -8
- package/src/platforms/whatsapp/ensure-auth.ts +2 -2
- package/src/platforms/whatsappbot/cli.ts +2 -1
- package/src/platforms/whatsappbot/commands/auth.test.ts +217 -0
- package/src/platforms/whatsappbot/commands/index.ts +1 -0
- package/src/platforms/whatsappbot/commands/message.test.ts +198 -0
- package/src/platforms/whatsappbot/commands/template.test.ts +112 -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/whatsapp-adapter.ts +19 -16
- 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
|
@@ -410,6 +410,19 @@ export class InstagramClient {
|
|
|
410
410
|
return this.userId
|
|
411
411
|
}
|
|
412
412
|
|
|
413
|
+
async getProfile(): Promise<{ user_id: string; username: string; full_name: string | null; profile_pic_url: string | null }> {
|
|
414
|
+
if (!this.userId) {
|
|
415
|
+
throw new InstagramError('Not authenticated. Call login() first.', 'not_authenticated')
|
|
416
|
+
}
|
|
417
|
+
const account = await this.credentialManager.getAccount()
|
|
418
|
+
return {
|
|
419
|
+
user_id: this.userId,
|
|
420
|
+
username: account?.username ?? '',
|
|
421
|
+
full_name: account?.full_name ?? null,
|
|
422
|
+
profile_pic_url: account?.profile_pic_url ?? null,
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
|
|
413
426
|
private async preLoginFlow(): Promise<{ keyId: string; publicKey: string } | null> {
|
|
414
427
|
const url = `${IG_BASE_URL}/qe/sync/`
|
|
415
428
|
const headers = this.buildHeaders()
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
import { afterEach, beforeEach, describe, expect, mock, spyOn, test } from 'bun:test'
|
|
2
|
+
|
|
3
|
+
const originalConsoleLog = console.log
|
|
4
|
+
import type { Command } from 'commander'
|
|
5
|
+
|
|
6
|
+
const mockGetAccount = mock(() => Promise.resolve(null))
|
|
7
|
+
const mockListAccounts = mock(() => Promise.resolve([]))
|
|
8
|
+
const mockSetCurrent = mock(() => Promise.resolve(true))
|
|
9
|
+
const mockRemoveAccount = mock(() => Promise.resolve(true))
|
|
10
|
+
|
|
11
|
+
mock.module('../credential-manager', () => ({
|
|
12
|
+
InstagramCredentialManager: class {
|
|
13
|
+
getAccount = mockGetAccount
|
|
14
|
+
listAccounts = mockListAccounts
|
|
15
|
+
setCurrent = mockSetCurrent
|
|
16
|
+
removeAccount = mockRemoveAccount
|
|
17
|
+
},
|
|
18
|
+
}))
|
|
19
|
+
|
|
20
|
+
import { authCommand } from './auth'
|
|
21
|
+
|
|
22
|
+
function resetCommandState(cmd: Command): void {
|
|
23
|
+
for (const sub of cmd.commands) {
|
|
24
|
+
(sub as unknown as { _optionValues: Record<string, unknown>; _optionValueSources: Record<string, unknown> })._optionValues = {}
|
|
25
|
+
;(sub as unknown as { _optionValues: Record<string, unknown>; _optionValueSources: Record<string, unknown> })._optionValueSources = {}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
describe('auth commands', () => {
|
|
30
|
+
let consoleLogSpy: ReturnType<typeof mock>
|
|
31
|
+
let processExitSpy: ReturnType<typeof spyOn>
|
|
32
|
+
|
|
33
|
+
beforeEach(() => {
|
|
34
|
+
resetCommandState(authCommand)
|
|
35
|
+
|
|
36
|
+
mockGetAccount.mockReset()
|
|
37
|
+
mockListAccounts.mockReset()
|
|
38
|
+
mockSetCurrent.mockReset()
|
|
39
|
+
mockRemoveAccount.mockReset()
|
|
40
|
+
|
|
41
|
+
consoleLogSpy = mock((..._args: unknown[]) => {}); console.log = consoleLogSpy
|
|
42
|
+
processExitSpy = spyOn(process, 'exit').mockImplementation(() => {
|
|
43
|
+
throw new Error('process.exit called')
|
|
44
|
+
})
|
|
45
|
+
})
|
|
46
|
+
|
|
47
|
+
afterEach(() => {
|
|
48
|
+
console.log = originalConsoleLog
|
|
49
|
+
processExitSpy.mockRestore()
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
describe('status', () => {
|
|
53
|
+
test('outputs error and exits when no account found', async () => {
|
|
54
|
+
mockGetAccount.mockImplementation(() => Promise.resolve(null))
|
|
55
|
+
|
|
56
|
+
await expect(
|
|
57
|
+
authCommand.parseAsync(['status'], { from: 'user' }),
|
|
58
|
+
).rejects.toThrow('process.exit called')
|
|
59
|
+
|
|
60
|
+
expect(processExitSpy).toHaveBeenCalledWith(1)
|
|
61
|
+
const output = JSON.parse(consoleLogSpy.mock.calls[0][0])
|
|
62
|
+
expect(output.error).toContain('No Instagram account configured')
|
|
63
|
+
})
|
|
64
|
+
|
|
65
|
+
test('outputs account info when account exists', async () => {
|
|
66
|
+
mockGetAccount.mockImplementation(() =>
|
|
67
|
+
Promise.resolve({
|
|
68
|
+
account_id: 'user_testuser',
|
|
69
|
+
username: 'testuser',
|
|
70
|
+
pk: '12345',
|
|
71
|
+
created_at: '2024-01-01T00:00:00.000Z',
|
|
72
|
+
updated_at: '2024-01-01T00:00:00.000Z',
|
|
73
|
+
}),
|
|
74
|
+
)
|
|
75
|
+
|
|
76
|
+
await authCommand.parseAsync(['status'], { from: 'user' })
|
|
77
|
+
|
|
78
|
+
const output = JSON.parse(consoleLogSpy.mock.calls[0][0])
|
|
79
|
+
expect(output.account_id).toBe('user_testuser')
|
|
80
|
+
expect(output.username).toBe('testuser')
|
|
81
|
+
expect(output.pk).toBe('12345')
|
|
82
|
+
})
|
|
83
|
+
|
|
84
|
+
test('outputs error for specific account not found', async () => {
|
|
85
|
+
mockGetAccount.mockImplementation(() => Promise.resolve(null))
|
|
86
|
+
|
|
87
|
+
await expect(
|
|
88
|
+
authCommand.parseAsync(['status', '--account', 'missing_account'], { from: 'user' }),
|
|
89
|
+
).rejects.toThrow('process.exit called')
|
|
90
|
+
|
|
91
|
+
const output = JSON.parse(consoleLogSpy.mock.calls[0][0])
|
|
92
|
+
expect(output.error).toContain('missing_account')
|
|
93
|
+
})
|
|
94
|
+
})
|
|
95
|
+
|
|
96
|
+
describe('list', () => {
|
|
97
|
+
test('outputs empty array when no accounts', async () => {
|
|
98
|
+
mockListAccounts.mockImplementation(() => Promise.resolve([]))
|
|
99
|
+
|
|
100
|
+
await authCommand.parseAsync(['list'], { from: 'user' })
|
|
101
|
+
|
|
102
|
+
const output = JSON.parse(consoleLogSpy.mock.calls[0][0])
|
|
103
|
+
expect(output).toEqual([])
|
|
104
|
+
})
|
|
105
|
+
|
|
106
|
+
test('outputs accounts list', async () => {
|
|
107
|
+
mockListAccounts.mockImplementation(() =>
|
|
108
|
+
Promise.resolve([
|
|
109
|
+
{
|
|
110
|
+
account_id: 'user_alice',
|
|
111
|
+
username: 'alice',
|
|
112
|
+
pk: '111',
|
|
113
|
+
created_at: '2024-01-01T00:00:00.000Z',
|
|
114
|
+
updated_at: '2024-01-01T00:00:00.000Z',
|
|
115
|
+
is_current: true,
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
account_id: 'user_bob',
|
|
119
|
+
username: 'bob',
|
|
120
|
+
pk: '222',
|
|
121
|
+
created_at: '2024-01-02T00:00:00.000Z',
|
|
122
|
+
updated_at: '2024-01-02T00:00:00.000Z',
|
|
123
|
+
is_current: false,
|
|
124
|
+
},
|
|
125
|
+
]),
|
|
126
|
+
)
|
|
127
|
+
|
|
128
|
+
await authCommand.parseAsync(['list'], { from: 'user' })
|
|
129
|
+
|
|
130
|
+
const output = JSON.parse(consoleLogSpy.mock.calls[0][0])
|
|
131
|
+
expect(output).toHaveLength(2)
|
|
132
|
+
expect(output[0].account_id).toBe('user_alice')
|
|
133
|
+
expect(output[0].is_current).toBe(true)
|
|
134
|
+
expect(output[1].account_id).toBe('user_bob')
|
|
135
|
+
expect(output[1].is_current).toBe(false)
|
|
136
|
+
})
|
|
137
|
+
})
|
|
138
|
+
|
|
139
|
+
describe('use', () => {
|
|
140
|
+
test('switches to specified account', async () => {
|
|
141
|
+
mockSetCurrent.mockImplementation(() => Promise.resolve(true))
|
|
142
|
+
mockGetAccount.mockImplementation(() =>
|
|
143
|
+
Promise.resolve({
|
|
144
|
+
account_id: 'user_alice',
|
|
145
|
+
username: 'alice',
|
|
146
|
+
pk: '111',
|
|
147
|
+
created_at: '2024-01-01T00:00:00.000Z',
|
|
148
|
+
updated_at: '2024-01-01T00:00:00.000Z',
|
|
149
|
+
}),
|
|
150
|
+
)
|
|
151
|
+
|
|
152
|
+
await authCommand.parseAsync(['use', 'user_alice'], { from: 'user' })
|
|
153
|
+
|
|
154
|
+
expect(mockSetCurrent).toHaveBeenCalledWith('user_alice')
|
|
155
|
+
const output = JSON.parse(consoleLogSpy.mock.calls[0][0])
|
|
156
|
+
expect(output.success).toBe(true)
|
|
157
|
+
expect(output.account_id).toBe('user_alice')
|
|
158
|
+
})
|
|
159
|
+
|
|
160
|
+
test('outputs error when account not found', async () => {
|
|
161
|
+
mockSetCurrent.mockImplementation(() => Promise.resolve(false))
|
|
162
|
+
|
|
163
|
+
await expect(
|
|
164
|
+
authCommand.parseAsync(['use', 'missing_account'], { from: 'user' }),
|
|
165
|
+
).rejects.toThrow('process.exit called')
|
|
166
|
+
|
|
167
|
+
const output = JSON.parse(consoleLogSpy.mock.calls[0][0])
|
|
168
|
+
expect(output.error).toContain('missing_account')
|
|
169
|
+
})
|
|
170
|
+
})
|
|
171
|
+
|
|
172
|
+
describe('logout', () => {
|
|
173
|
+
test('removes account and outputs success', async () => {
|
|
174
|
+
mockGetAccount.mockImplementation(() =>
|
|
175
|
+
Promise.resolve({
|
|
176
|
+
account_id: 'user_alice',
|
|
177
|
+
username: 'alice',
|
|
178
|
+
pk: '111',
|
|
179
|
+
created_at: '2024-01-01T00:00:00.000Z',
|
|
180
|
+
updated_at: '2024-01-01T00:00:00.000Z',
|
|
181
|
+
}),
|
|
182
|
+
)
|
|
183
|
+
mockRemoveAccount.mockImplementation(() => Promise.resolve(true))
|
|
184
|
+
|
|
185
|
+
await authCommand.parseAsync(['logout'], { from: 'user' })
|
|
186
|
+
|
|
187
|
+
expect(mockRemoveAccount).toHaveBeenCalledWith('user_alice')
|
|
188
|
+
const output = JSON.parse(consoleLogSpy.mock.calls[0][0])
|
|
189
|
+
expect(output.success).toBe(true)
|
|
190
|
+
expect(output.logged_out).toBe(true)
|
|
191
|
+
expect(output.account_id).toBe('user_alice')
|
|
192
|
+
})
|
|
193
|
+
|
|
194
|
+
test('outputs error when no account configured', async () => {
|
|
195
|
+
mockGetAccount.mockImplementation(() => Promise.resolve(null))
|
|
196
|
+
|
|
197
|
+
await expect(
|
|
198
|
+
authCommand.parseAsync(['logout'], { from: 'user' }),
|
|
199
|
+
).rejects.toThrow('process.exit called')
|
|
200
|
+
|
|
201
|
+
const output = JSON.parse(consoleLogSpy.mock.calls[0][0])
|
|
202
|
+
expect(output.error).toContain('No Instagram account configured')
|
|
203
|
+
})
|
|
204
|
+
|
|
205
|
+
test('outputs error for specific account not found', async () => {
|
|
206
|
+
mockGetAccount.mockImplementation(() => Promise.resolve(null))
|
|
207
|
+
|
|
208
|
+
await expect(
|
|
209
|
+
authCommand.parseAsync(['logout', '--account', 'missing_account'], { from: 'user' }),
|
|
210
|
+
).rejects.toThrow('process.exit called')
|
|
211
|
+
|
|
212
|
+
const output = JSON.parse(consoleLogSpy.mock.calls[0][0])
|
|
213
|
+
expect(output.error).toContain('missing_account')
|
|
214
|
+
})
|
|
215
|
+
})
|
|
216
|
+
})
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { afterEach, beforeEach, describe, expect, mock, spyOn, test } from 'bun:test'
|
|
2
|
+
|
|
3
|
+
const originalConsoleLog = console.log
|
|
4
|
+
import type { Command } from 'commander'
|
|
5
|
+
|
|
6
|
+
const mockListChats = mock(() =>
|
|
7
|
+
Promise.resolve([
|
|
8
|
+
{ id: 'thread-1', title: 'Alice', last_message: 'Hi' },
|
|
9
|
+
{ id: 'thread-2', title: 'Bob', last_message: 'Hey' },
|
|
10
|
+
]),
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
const mockSearchChats = mock(() =>
|
|
14
|
+
Promise.resolve([{ id: 'thread-1', title: 'Alice', last_message: 'Hi' }]),
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
const mockClient = {
|
|
18
|
+
listChats: mockListChats,
|
|
19
|
+
searchChats: mockSearchChats,
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
mock.module('./shared', () => ({
|
|
23
|
+
withInstagramClient: async (_options: unknown, fn: (client: typeof mockClient) => Promise<unknown>) => {
|
|
24
|
+
return fn(mockClient)
|
|
25
|
+
},
|
|
26
|
+
}))
|
|
27
|
+
|
|
28
|
+
import { chatCommand } from './chat'
|
|
29
|
+
|
|
30
|
+
function resetCommandState(cmd: Command): void {
|
|
31
|
+
for (const sub of cmd.commands) {
|
|
32
|
+
(sub as unknown as { _optionValues: Record<string, unknown>; _optionValueSources: Record<string, unknown> })._optionValues = {}
|
|
33
|
+
;(sub as unknown as { _optionValues: Record<string, unknown>; _optionValueSources: Record<string, unknown> })._optionValueSources = {}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
describe('chat commands', () => {
|
|
38
|
+
let consoleLogSpy: ReturnType<typeof mock>
|
|
39
|
+
let processExitSpy: ReturnType<typeof spyOn>
|
|
40
|
+
|
|
41
|
+
beforeEach(() => {
|
|
42
|
+
resetCommandState(chatCommand)
|
|
43
|
+
|
|
44
|
+
mockListChats.mockReset()
|
|
45
|
+
mockSearchChats.mockReset()
|
|
46
|
+
|
|
47
|
+
mockListChats.mockImplementation(() =>
|
|
48
|
+
Promise.resolve([
|
|
49
|
+
{ id: 'thread-1', title: 'Alice', last_message: 'Hi' },
|
|
50
|
+
{ id: 'thread-2', title: 'Bob', last_message: 'Hey' },
|
|
51
|
+
]),
|
|
52
|
+
)
|
|
53
|
+
mockSearchChats.mockImplementation(() =>
|
|
54
|
+
Promise.resolve([{ id: 'thread-1', title: 'Alice', last_message: 'Hi' }]),
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
consoleLogSpy = mock((..._args: unknown[]) => {}); console.log = consoleLogSpy
|
|
58
|
+
processExitSpy = spyOn(process, 'exit').mockImplementation(() => {
|
|
59
|
+
throw new Error('process.exit called')
|
|
60
|
+
})
|
|
61
|
+
})
|
|
62
|
+
|
|
63
|
+
afterEach(() => {
|
|
64
|
+
console.log = originalConsoleLog
|
|
65
|
+
processExitSpy.mockRestore()
|
|
66
|
+
})
|
|
67
|
+
|
|
68
|
+
describe('list', () => {
|
|
69
|
+
test('lists DM conversations', async () => {
|
|
70
|
+
await expect(
|
|
71
|
+
chatCommand.parseAsync(['list'], { from: 'user' }),
|
|
72
|
+
).rejects.toThrow('process.exit called')
|
|
73
|
+
|
|
74
|
+
expect(processExitSpy).toHaveBeenCalledWith(0)
|
|
75
|
+
expect(mockListChats).toHaveBeenCalledWith(20)
|
|
76
|
+
const output = JSON.parse(consoleLogSpy.mock.calls[0][0])
|
|
77
|
+
expect(output).toHaveLength(2)
|
|
78
|
+
expect(output[0].id).toBe('thread-1')
|
|
79
|
+
expect(output[1].id).toBe('thread-2')
|
|
80
|
+
})
|
|
81
|
+
|
|
82
|
+
test('passes custom limit', async () => {
|
|
83
|
+
await expect(
|
|
84
|
+
chatCommand.parseAsync(['list', '--limit', '5'], { from: 'user' }),
|
|
85
|
+
).rejects.toThrow('process.exit called')
|
|
86
|
+
|
|
87
|
+
expect(mockListChats).toHaveBeenCalledWith(5)
|
|
88
|
+
})
|
|
89
|
+
})
|
|
90
|
+
|
|
91
|
+
describe('search', () => {
|
|
92
|
+
test('searches DM conversations by query', async () => {
|
|
93
|
+
await expect(
|
|
94
|
+
chatCommand.parseAsync(['search', 'Alice'], { from: 'user' }),
|
|
95
|
+
).rejects.toThrow('process.exit called')
|
|
96
|
+
|
|
97
|
+
expect(processExitSpy).toHaveBeenCalledWith(0)
|
|
98
|
+
expect(mockSearchChats).toHaveBeenCalledWith('Alice', 20)
|
|
99
|
+
const output = JSON.parse(consoleLogSpy.mock.calls[0][0])
|
|
100
|
+
expect(output).toHaveLength(1)
|
|
101
|
+
expect(output[0].id).toBe('thread-1')
|
|
102
|
+
})
|
|
103
|
+
|
|
104
|
+
test('passes custom limit to search', async () => {
|
|
105
|
+
await expect(
|
|
106
|
+
chatCommand.parseAsync(['search', 'Alice', '--limit', '10'], { from: 'user' }),
|
|
107
|
+
).rejects.toThrow('process.exit called')
|
|
108
|
+
|
|
109
|
+
expect(mockSearchChats).toHaveBeenCalledWith('Alice', 10)
|
|
110
|
+
})
|
|
111
|
+
|
|
112
|
+
test('returns empty array when no results', async () => {
|
|
113
|
+
mockSearchChats.mockImplementation(() => Promise.resolve([]))
|
|
114
|
+
|
|
115
|
+
await expect(
|
|
116
|
+
chatCommand.parseAsync(['search', 'nobody'], { from: 'user' }),
|
|
117
|
+
).rejects.toThrow('process.exit called')
|
|
118
|
+
|
|
119
|
+
const output = JSON.parse(consoleLogSpy.mock.calls[0][0])
|
|
120
|
+
expect(output).toEqual([])
|
|
121
|
+
})
|
|
122
|
+
})
|
|
123
|
+
})
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import { afterEach, beforeEach, describe, expect, mock, spyOn, test } from 'bun:test'
|
|
2
|
+
|
|
3
|
+
const originalConsoleLog = console.log
|
|
4
|
+
import type { Command } from 'commander'
|
|
5
|
+
|
|
6
|
+
const mockGetMessages = mock(() => Promise.resolve([{ id: 'msg-1', text: 'Hello' }]))
|
|
7
|
+
const mockSendMessage = mock(() => Promise.resolve({ id: 'msg-2', text: 'Sent' }))
|
|
8
|
+
const mockSendMessageToUser = mock(() => Promise.resolve({ id: 'msg-3', text: 'Sent to user' }))
|
|
9
|
+
const mockSearchMessages = mock(() => Promise.resolve([{ id: 'msg-4', text: 'Found' }]))
|
|
10
|
+
const mockSearchUsers = mock(() => Promise.resolve([{ pk: '999', username: 'targetuser' }]))
|
|
11
|
+
|
|
12
|
+
const mockClient = {
|
|
13
|
+
getMessages: mockGetMessages,
|
|
14
|
+
sendMessage: mockSendMessage,
|
|
15
|
+
sendMessageToUser: mockSendMessageToUser,
|
|
16
|
+
searchMessages: mockSearchMessages,
|
|
17
|
+
searchUsers: mockSearchUsers,
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
mock.module('./shared', () => ({
|
|
21
|
+
withInstagramClient: async (_options: unknown, fn: (client: typeof mockClient) => Promise<unknown>) => {
|
|
22
|
+
return fn(mockClient)
|
|
23
|
+
},
|
|
24
|
+
}))
|
|
25
|
+
|
|
26
|
+
import { messageCommand } from './message'
|
|
27
|
+
|
|
28
|
+
function resetCommandState(cmd: Command): void {
|
|
29
|
+
for (const sub of cmd.commands) {
|
|
30
|
+
(sub as unknown as { _optionValues: Record<string, unknown>; _optionValueSources: Record<string, unknown> })._optionValues = {}
|
|
31
|
+
;(sub as unknown as { _optionValues: Record<string, unknown>; _optionValueSources: Record<string, unknown> })._optionValueSources = {}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
describe('message commands', () => {
|
|
36
|
+
let consoleLogSpy: ReturnType<typeof mock>
|
|
37
|
+
let processExitSpy: ReturnType<typeof spyOn>
|
|
38
|
+
|
|
39
|
+
beforeEach(() => {
|
|
40
|
+
resetCommandState(messageCommand)
|
|
41
|
+
|
|
42
|
+
mockGetMessages.mockReset()
|
|
43
|
+
mockSendMessage.mockReset()
|
|
44
|
+
mockSendMessageToUser.mockReset()
|
|
45
|
+
mockSearchMessages.mockReset()
|
|
46
|
+
mockSearchUsers.mockReset()
|
|
47
|
+
|
|
48
|
+
mockGetMessages.mockImplementation(() => Promise.resolve([{ id: 'msg-1', text: 'Hello' }]))
|
|
49
|
+
mockSendMessage.mockImplementation(() => Promise.resolve({ id: 'msg-2', text: 'Sent' }))
|
|
50
|
+
mockSendMessageToUser.mockImplementation(() => Promise.resolve({ id: 'msg-3', text: 'Sent to user' }))
|
|
51
|
+
mockSearchMessages.mockImplementation(() => Promise.resolve([{ id: 'msg-4', text: 'Found' }]))
|
|
52
|
+
mockSearchUsers.mockImplementation(() => Promise.resolve([{ pk: '999', username: 'targetuser' }]))
|
|
53
|
+
|
|
54
|
+
consoleLogSpy = mock((..._args: unknown[]) => {}); console.log = consoleLogSpy
|
|
55
|
+
processExitSpy = spyOn(process, 'exit').mockImplementation(() => {
|
|
56
|
+
throw new Error('process.exit called')
|
|
57
|
+
})
|
|
58
|
+
})
|
|
59
|
+
|
|
60
|
+
afterEach(() => {
|
|
61
|
+
console.log = originalConsoleLog
|
|
62
|
+
processExitSpy.mockRestore()
|
|
63
|
+
})
|
|
64
|
+
|
|
65
|
+
describe('list', () => {
|
|
66
|
+
test('lists messages from a thread', async () => {
|
|
67
|
+
await expect(
|
|
68
|
+
messageCommand.parseAsync(['list', 'thread-123'], { from: 'user' }),
|
|
69
|
+
).rejects.toThrow('process.exit called')
|
|
70
|
+
|
|
71
|
+
expect(processExitSpy).toHaveBeenCalledWith(0)
|
|
72
|
+
expect(mockGetMessages).toHaveBeenCalledWith('thread-123', 25)
|
|
73
|
+
const output = JSON.parse(consoleLogSpy.mock.calls[0][0])
|
|
74
|
+
expect(output).toEqual([{ id: 'msg-1', text: 'Hello' }])
|
|
75
|
+
})
|
|
76
|
+
|
|
77
|
+
test('passes custom limit', async () => {
|
|
78
|
+
await expect(
|
|
79
|
+
messageCommand.parseAsync(['list', 'thread-123', '--limit', '10'], { from: 'user' }),
|
|
80
|
+
).rejects.toThrow('process.exit called')
|
|
81
|
+
|
|
82
|
+
expect(mockGetMessages).toHaveBeenCalledWith('thread-123', 10)
|
|
83
|
+
})
|
|
84
|
+
})
|
|
85
|
+
|
|
86
|
+
describe('send', () => {
|
|
87
|
+
test('sends a message to a thread', async () => {
|
|
88
|
+
await expect(
|
|
89
|
+
messageCommand.parseAsync(['send', 'thread-123', 'Hello world'], { from: 'user' }),
|
|
90
|
+
).rejects.toThrow('process.exit called')
|
|
91
|
+
|
|
92
|
+
expect(processExitSpy).toHaveBeenCalledWith(0)
|
|
93
|
+
expect(mockSendMessage).toHaveBeenCalledWith('thread-123', 'Hello world')
|
|
94
|
+
const output = JSON.parse(consoleLogSpy.mock.calls[0][0])
|
|
95
|
+
expect(output).toEqual({ id: 'msg-2', text: 'Sent' })
|
|
96
|
+
})
|
|
97
|
+
})
|
|
98
|
+
|
|
99
|
+
describe('send-to', () => {
|
|
100
|
+
test('sends a message to a user by username', async () => {
|
|
101
|
+
await expect(
|
|
102
|
+
messageCommand.parseAsync(['send-to', 'targetuser', 'Hi there'], { from: 'user' }),
|
|
103
|
+
).rejects.toThrow('process.exit called')
|
|
104
|
+
|
|
105
|
+
expect(processExitSpy).toHaveBeenCalledWith(0)
|
|
106
|
+
expect(mockSearchUsers).toHaveBeenCalledWith('targetuser')
|
|
107
|
+
expect(mockSendMessageToUser).toHaveBeenCalledWith('999', 'Hi there')
|
|
108
|
+
const output = JSON.parse(consoleLogSpy.mock.calls[0][0])
|
|
109
|
+
expect(output).toEqual({ id: 'msg-3', text: 'Sent to user' })
|
|
110
|
+
})
|
|
111
|
+
|
|
112
|
+
test('strips @ prefix from username', async () => {
|
|
113
|
+
await expect(
|
|
114
|
+
messageCommand.parseAsync(['send-to', '@targetuser', 'Hi there'], { from: 'user' }),
|
|
115
|
+
).rejects.toThrow('process.exit called')
|
|
116
|
+
|
|
117
|
+
expect(mockSearchUsers).toHaveBeenCalledWith('targetuser')
|
|
118
|
+
})
|
|
119
|
+
|
|
120
|
+
test('handles user not found error', async () => {
|
|
121
|
+
mockSearchUsers.mockImplementation(() => Promise.resolve([]))
|
|
122
|
+
|
|
123
|
+
try {
|
|
124
|
+
await messageCommand.parseAsync(['send-to', 'unknownuser', 'Hi'], { from: 'user' })
|
|
125
|
+
} catch {
|
|
126
|
+
/* empty */
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
expect(mockSendMessageToUser).not.toHaveBeenCalled()
|
|
130
|
+
})
|
|
131
|
+
})
|
|
132
|
+
|
|
133
|
+
describe('search', () => {
|
|
134
|
+
test('searches messages by query', async () => {
|
|
135
|
+
await expect(
|
|
136
|
+
messageCommand.parseAsync(['search', 'hello'], { from: 'user' }),
|
|
137
|
+
).rejects.toThrow('process.exit called')
|
|
138
|
+
|
|
139
|
+
expect(processExitSpy).toHaveBeenCalledWith(0)
|
|
140
|
+
expect(mockSearchMessages).toHaveBeenCalledWith('hello', { threadId: undefined, limit: 20 })
|
|
141
|
+
const output = JSON.parse(consoleLogSpy.mock.calls[0][0])
|
|
142
|
+
expect(output).toEqual([{ id: 'msg-4', text: 'Found' }])
|
|
143
|
+
})
|
|
144
|
+
|
|
145
|
+
test('passes thread option to search', async () => {
|
|
146
|
+
await expect(
|
|
147
|
+
messageCommand.parseAsync(['search', 'hello', '--thread', 'thread-456'], { from: 'user' }),
|
|
148
|
+
).rejects.toThrow('process.exit called')
|
|
149
|
+
|
|
150
|
+
expect(mockSearchMessages).toHaveBeenCalledWith('hello', { threadId: 'thread-456', limit: 20 })
|
|
151
|
+
})
|
|
152
|
+
|
|
153
|
+
test('passes limit option to search', async () => {
|
|
154
|
+
await expect(
|
|
155
|
+
messageCommand.parseAsync(['search', 'hello2', '--limit', '5'], { from: 'user' }),
|
|
156
|
+
).rejects.toThrow('process.exit called')
|
|
157
|
+
|
|
158
|
+
expect(mockSearchMessages).toHaveBeenCalledWith('hello2', { threadId: undefined, limit: 5 })
|
|
159
|
+
})
|
|
160
|
+
})
|
|
161
|
+
|
|
162
|
+
describe('search-users', () => {
|
|
163
|
+
test('searches users by query', async () => {
|
|
164
|
+
await expect(
|
|
165
|
+
messageCommand.parseAsync(['search-users', 'target'], { from: 'user' }),
|
|
166
|
+
).rejects.toThrow('process.exit called')
|
|
167
|
+
|
|
168
|
+
expect(processExitSpy).toHaveBeenCalledWith(0)
|
|
169
|
+
expect(mockSearchUsers).toHaveBeenCalledWith('target')
|
|
170
|
+
const output = JSON.parse(consoleLogSpy.mock.calls[0][0])
|
|
171
|
+
expect(output).toEqual([{ pk: '999', username: 'targetuser' }])
|
|
172
|
+
})
|
|
173
|
+
})
|
|
174
|
+
})
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { afterEach, beforeEach, describe, expect, spyOn, test } from 'bun:test'
|
|
2
|
+
|
|
3
|
+
import { InstagramClient } from '../client'
|
|
4
|
+
import * as sharedModule from './shared'
|
|
5
|
+
import { whoamiAction } from './whoami'
|
|
6
|
+
|
|
7
|
+
let withInstagramClientSpy: ReturnType<typeof spyOn>
|
|
8
|
+
let getProfileSpy: ReturnType<typeof spyOn>
|
|
9
|
+
let consoleLogSpy: ReturnType<typeof spyOn>
|
|
10
|
+
|
|
11
|
+
describe('whoami command', () => {
|
|
12
|
+
beforeEach(() => {
|
|
13
|
+
getProfileSpy = spyOn(InstagramClient.prototype, 'getProfile').mockResolvedValue({
|
|
14
|
+
user_id: '987654321',
|
|
15
|
+
username: 'testuser',
|
|
16
|
+
full_name: 'Test User',
|
|
17
|
+
profile_pic_url: 'https://example.com/pic.jpg',
|
|
18
|
+
})
|
|
19
|
+
withInstagramClientSpy = spyOn(sharedModule, 'withInstagramClient').mockImplementation(
|
|
20
|
+
async (_opts, fn) => {
|
|
21
|
+
const fakeClient = Object.create(InstagramClient.prototype) as InstagramClient
|
|
22
|
+
return fn(fakeClient)
|
|
23
|
+
},
|
|
24
|
+
)
|
|
25
|
+
consoleLogSpy = spyOn(console, 'log').mockImplementation(() => {})
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
afterEach(() => {
|
|
29
|
+
getProfileSpy?.mockRestore()
|
|
30
|
+
withInstagramClientSpy?.mockRestore()
|
|
31
|
+
consoleLogSpy?.mockRestore()
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
test('outputs profile information', async () => {
|
|
35
|
+
await whoamiAction({})
|
|
36
|
+
|
|
37
|
+
expect(consoleLogSpy).toHaveBeenCalledTimes(1)
|
|
38
|
+
const output = JSON.parse(consoleLogSpy.mock.calls[0][0] as string)
|
|
39
|
+
expect(output.user_id).toBe('987654321')
|
|
40
|
+
expect(output.username).toBe('testuser')
|
|
41
|
+
expect(output.full_name).toBe('Test User')
|
|
42
|
+
expect(output.profile_pic_url).toBe('https://example.com/pic.jpg')
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
test('outputs profile with null optional fields', async () => {
|
|
46
|
+
getProfileSpy.mockResolvedValue({
|
|
47
|
+
user_id: '987654321',
|
|
48
|
+
username: 'testuser',
|
|
49
|
+
full_name: null,
|
|
50
|
+
profile_pic_url: null,
|
|
51
|
+
})
|
|
52
|
+
|
|
53
|
+
await whoamiAction({})
|
|
54
|
+
|
|
55
|
+
expect(consoleLogSpy).toHaveBeenCalledTimes(1)
|
|
56
|
+
const output = JSON.parse(consoleLogSpy.mock.calls[0][0] as string)
|
|
57
|
+
expect(output.full_name).toBeNull()
|
|
58
|
+
expect(output.profile_pic_url).toBeNull()
|
|
59
|
+
})
|
|
60
|
+
})
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Command } from 'commander'
|
|
2
|
+
|
|
3
|
+
import { handleError } from '@/shared/utils/error-handler'
|
|
4
|
+
import { formatOutput } from '@/shared/utils/output'
|
|
5
|
+
|
|
6
|
+
import { withInstagramClient } from './shared'
|
|
7
|
+
|
|
8
|
+
export async function whoamiAction(options: { account?: string; pretty?: boolean }): Promise<void> {
|
|
9
|
+
try {
|
|
10
|
+
const profile = await withInstagramClient(options, (client) => client.getProfile())
|
|
11
|
+
console.log(formatOutput(profile, options.pretty))
|
|
12
|
+
} catch (error) {
|
|
13
|
+
handleError(error as Error)
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export const whoamiCommand = new Command('whoami')
|
|
18
|
+
.description('Show current authenticated user')
|
|
19
|
+
.option('--account <id>', 'Use a specific Instagram account')
|
|
20
|
+
.option('--pretty', 'Pretty print JSON output')
|
|
21
|
+
.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, chatCommand, messageCommand } from './commands/index'
|
|
7
|
+
import { authCommand, chatCommand, messageCommand, whoamiCommand } from './commands/index'
|
|
8
8
|
import { ensureKakaoAuth } from './ensure-auth'
|
|
9
9
|
|
|
10
10
|
function isAuthCommand(command: CommandType): boolean {
|
|
@@ -31,6 +31,7 @@ program.hook('preAction', async (_thisCommand, actionCommand) => {
|
|
|
31
31
|
program.addCommand(authCommand)
|
|
32
32
|
program.addCommand(chatCommand)
|
|
33
33
|
program.addCommand(messageCommand)
|
|
34
|
+
program.addCommand(whoamiCommand)
|
|
34
35
|
|
|
35
36
|
program.parse(process.argv)
|
|
36
37
|
|