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
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import { existsSync } from 'node:fs'
|
|
2
|
+
import { chmod, mkdir, readFile, writeFile } from 'node:fs/promises'
|
|
3
|
+
import { homedir } from 'node:os'
|
|
4
|
+
import { join } from 'node:path'
|
|
5
|
+
|
|
6
|
+
import type { WeChatBotAccountEntry, WeChatBotConfig, WeChatBotCredentials } from './types'
|
|
7
|
+
import { WeChatBotConfigSchema } from './types'
|
|
8
|
+
|
|
9
|
+
export class WeChatBotCredentialManager {
|
|
10
|
+
private configDir: string
|
|
11
|
+
private credentialsPath: string
|
|
12
|
+
|
|
13
|
+
constructor(configDir?: string) {
|
|
14
|
+
this.configDir = configDir ?? join(homedir(), '.config', 'agent-messenger')
|
|
15
|
+
this.credentialsPath = join(this.configDir, 'wechatbot-credentials.json')
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
async load(): Promise<WeChatBotConfig> {
|
|
19
|
+
if (!existsSync(this.credentialsPath)) {
|
|
20
|
+
return { current: null, accounts: {} }
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const content = await readFile(this.credentialsPath, 'utf-8')
|
|
24
|
+
let json: unknown
|
|
25
|
+
try {
|
|
26
|
+
json = JSON.parse(content)
|
|
27
|
+
} catch {
|
|
28
|
+
return { current: null, accounts: {} }
|
|
29
|
+
}
|
|
30
|
+
const parsed = WeChatBotConfigSchema.safeParse(json)
|
|
31
|
+
if (!parsed.success) {
|
|
32
|
+
return { current: null, accounts: {} }
|
|
33
|
+
}
|
|
34
|
+
return parsed.data
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
async save(config: WeChatBotConfig): Promise<void> {
|
|
38
|
+
await mkdir(this.configDir, { recursive: true })
|
|
39
|
+
await writeFile(this.credentialsPath, JSON.stringify(config, null, 2), { mode: 0o600 })
|
|
40
|
+
await chmod(this.credentialsPath, 0o600)
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
async getCredentials(accountId?: string): Promise<WeChatBotCredentials | null> {
|
|
44
|
+
const envAppId = process.env.E2E_WECHATBOT_APP_ID
|
|
45
|
+
const envAppSecret = process.env.E2E_WECHATBOT_APP_SECRET
|
|
46
|
+
|
|
47
|
+
if (envAppId && envAppSecret && !accountId) {
|
|
48
|
+
return {
|
|
49
|
+
app_id: envAppId,
|
|
50
|
+
app_secret: envAppSecret,
|
|
51
|
+
account_name: 'env',
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const config = await this.load()
|
|
56
|
+
|
|
57
|
+
if (accountId) {
|
|
58
|
+
const account = config.accounts[accountId]
|
|
59
|
+
if (!account) return null
|
|
60
|
+
return {
|
|
61
|
+
app_id: account.app_id,
|
|
62
|
+
app_secret: account.app_secret,
|
|
63
|
+
account_name: account.account_name,
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
if (!config.current) {
|
|
68
|
+
return null
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const account = config.accounts[config.current.account_id]
|
|
72
|
+
if (!account) return null
|
|
73
|
+
|
|
74
|
+
return {
|
|
75
|
+
app_id: account.app_id,
|
|
76
|
+
app_secret: account.app_secret,
|
|
77
|
+
account_name: account.account_name,
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
async setCredentials(entry: WeChatBotAccountEntry): Promise<void> {
|
|
82
|
+
const config = await this.load()
|
|
83
|
+
|
|
84
|
+
config.accounts[entry.app_id] = {
|
|
85
|
+
app_id: entry.app_id,
|
|
86
|
+
app_secret: entry.app_secret,
|
|
87
|
+
account_name: entry.account_name,
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
config.current = {
|
|
91
|
+
account_id: entry.app_id,
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
await this.save(config)
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
async removeAccount(accountId: string): Promise<boolean> {
|
|
98
|
+
const config = await this.load()
|
|
99
|
+
|
|
100
|
+
if (!config.accounts[accountId]) {
|
|
101
|
+
return false
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
delete config.accounts[accountId]
|
|
105
|
+
|
|
106
|
+
if (config.current?.account_id === accountId) {
|
|
107
|
+
config.current = null
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
await this.save(config)
|
|
111
|
+
return true
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
async setCurrent(accountId: string): Promise<boolean> {
|
|
115
|
+
const config = await this.load()
|
|
116
|
+
|
|
117
|
+
if (!config.accounts[accountId]) {
|
|
118
|
+
return false
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
config.current = {
|
|
122
|
+
account_id: accountId,
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
await this.save(config)
|
|
126
|
+
return true
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
async listAll(): Promise<Array<WeChatBotAccountEntry & { is_current: boolean }>> {
|
|
130
|
+
const config = await this.load()
|
|
131
|
+
const results: Array<WeChatBotAccountEntry & { is_current: boolean }> = []
|
|
132
|
+
|
|
133
|
+
for (const account of Object.values(config.accounts)) {
|
|
134
|
+
results.push({
|
|
135
|
+
app_id: account.app_id,
|
|
136
|
+
app_secret: account.app_secret,
|
|
137
|
+
account_name: account.account_name,
|
|
138
|
+
is_current: config.current?.account_id === account.app_id,
|
|
139
|
+
})
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
return results
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
async clearCredentials(): Promise<void> {
|
|
146
|
+
await this.save({ current: null, accounts: {} })
|
|
147
|
+
}
|
|
148
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { expect, test } from 'bun:test'
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
WeChatBotAccountEntrySchema,
|
|
5
|
+
WeChatBotClient,
|
|
6
|
+
WeChatBotConfigSchema,
|
|
7
|
+
WeChatBotCredentialManager,
|
|
8
|
+
WeChatBotCredentialsSchema,
|
|
9
|
+
WeChatBotError,
|
|
10
|
+
WeChatBotNewsArticleSchema,
|
|
11
|
+
WeChatBotTemplateSchema,
|
|
12
|
+
WeChatBotUserInfoSchema,
|
|
13
|
+
} from '@/platforms/wechatbot/index'
|
|
14
|
+
|
|
15
|
+
test('WeChatBotClient is exported from barrel', () => {
|
|
16
|
+
expect(typeof WeChatBotClient).toBe('function')
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
test('WeChatBotCredentialManager is exported from barrel', () => {
|
|
20
|
+
expect(typeof WeChatBotCredentialManager).toBe('function')
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
test('WeChatBotError is exported from barrel', () => {
|
|
24
|
+
expect(typeof WeChatBotError).toBe('function')
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
test('WeChatBotAccountEntrySchema is exported from barrel', () => {
|
|
28
|
+
expect(typeof WeChatBotAccountEntrySchema.parse).toBe('function')
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
test('WeChatBotConfigSchema is exported from barrel', () => {
|
|
32
|
+
expect(typeof WeChatBotConfigSchema.parse).toBe('function')
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
test('WeChatBotCredentialsSchema is exported from barrel', () => {
|
|
36
|
+
expect(typeof WeChatBotCredentialsSchema.parse).toBe('function')
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
test('WeChatBotNewsArticleSchema is exported from barrel', () => {
|
|
40
|
+
expect(typeof WeChatBotNewsArticleSchema.parse).toBe('function')
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
test('WeChatBotTemplateSchema is exported from barrel', () => {
|
|
44
|
+
expect(typeof WeChatBotTemplateSchema.parse).toBe('function')
|
|
45
|
+
})
|
|
46
|
+
|
|
47
|
+
test('WeChatBotUserInfoSchema is exported from barrel', () => {
|
|
48
|
+
expect(typeof WeChatBotUserInfoSchema.parse).toBe('function')
|
|
49
|
+
})
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export { WeChatBotClient } from './client'
|
|
2
|
+
export { WeChatBotCredentialManager } from './credential-manager'
|
|
3
|
+
export type {
|
|
4
|
+
WeChatBotAccountEntry,
|
|
5
|
+
WeChatBotConfig,
|
|
6
|
+
WeChatBotCredentials,
|
|
7
|
+
WeChatBotNewsArticle,
|
|
8
|
+
WeChatBotTemplate,
|
|
9
|
+
WeChatBotUserInfo,
|
|
10
|
+
} from './types'
|
|
11
|
+
export {
|
|
12
|
+
WeChatBotAccountEntrySchema,
|
|
13
|
+
WeChatBotConfigSchema,
|
|
14
|
+
WeChatBotCredentialsSchema,
|
|
15
|
+
WeChatBotError,
|
|
16
|
+
WeChatBotNewsArticleSchema,
|
|
17
|
+
WeChatBotTemplateSchema,
|
|
18
|
+
WeChatBotUserInfoSchema,
|
|
19
|
+
} from './types'
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
import { expect, test } from 'bun:test'
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
WeChatBotAccountEntrySchema,
|
|
5
|
+
WeChatBotConfigSchema,
|
|
6
|
+
WeChatBotCredentialsSchema,
|
|
7
|
+
WeChatBotError,
|
|
8
|
+
WeChatBotNewsArticleSchema,
|
|
9
|
+
WeChatBotTemplateSchema,
|
|
10
|
+
WeChatBotUserInfoSchema,
|
|
11
|
+
} from '@/platforms/wechatbot/types'
|
|
12
|
+
|
|
13
|
+
test('WeChatBotAccountEntrySchema validates correct data', () => {
|
|
14
|
+
const result = WeChatBotAccountEntrySchema.safeParse({
|
|
15
|
+
app_id: 'wx123',
|
|
16
|
+
app_secret: 'secret123',
|
|
17
|
+
account_name: 'My Account',
|
|
18
|
+
})
|
|
19
|
+
expect(result.success).toBe(true)
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
test('WeChatBotAccountEntrySchema rejects missing app_id', () => {
|
|
23
|
+
const result = WeChatBotAccountEntrySchema.safeParse({
|
|
24
|
+
app_secret: 'secret123',
|
|
25
|
+
account_name: 'My Account',
|
|
26
|
+
})
|
|
27
|
+
expect(result.success).toBe(false)
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
test('WeChatBotAccountEntrySchema rejects missing app_secret', () => {
|
|
31
|
+
const result = WeChatBotAccountEntrySchema.safeParse({
|
|
32
|
+
app_id: 'wx123',
|
|
33
|
+
account_name: 'My Account',
|
|
34
|
+
})
|
|
35
|
+
expect(result.success).toBe(false)
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
test('WeChatBotAccountEntrySchema rejects missing account_name', () => {
|
|
39
|
+
const result = WeChatBotAccountEntrySchema.safeParse({
|
|
40
|
+
app_id: 'wx123',
|
|
41
|
+
app_secret: 'secret123',
|
|
42
|
+
})
|
|
43
|
+
expect(result.success).toBe(false)
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
test('WeChatBotConfigSchema validates with current account', () => {
|
|
47
|
+
const result = WeChatBotConfigSchema.safeParse({
|
|
48
|
+
current: { account_id: 'wx123' },
|
|
49
|
+
accounts: {
|
|
50
|
+
wx123: { app_id: 'wx123', app_secret: 'secret123', account_name: 'My Account' },
|
|
51
|
+
},
|
|
52
|
+
})
|
|
53
|
+
expect(result.success).toBe(true)
|
|
54
|
+
})
|
|
55
|
+
|
|
56
|
+
test('WeChatBotConfigSchema validates with current null and empty accounts', () => {
|
|
57
|
+
const result = WeChatBotConfigSchema.safeParse({
|
|
58
|
+
current: null,
|
|
59
|
+
accounts: {},
|
|
60
|
+
})
|
|
61
|
+
expect(result.success).toBe(true)
|
|
62
|
+
})
|
|
63
|
+
|
|
64
|
+
test('WeChatBotConfigSchema validates with multiple accounts', () => {
|
|
65
|
+
const result = WeChatBotConfigSchema.safeParse({
|
|
66
|
+
current: { account_id: 'wx-a' },
|
|
67
|
+
accounts: {
|
|
68
|
+
'wx-a': { app_id: 'wx-a', app_secret: 'secret-a', account_name: 'Account A' },
|
|
69
|
+
'wx-b': { app_id: 'wx-b', app_secret: 'secret-b', account_name: 'Account B' },
|
|
70
|
+
},
|
|
71
|
+
})
|
|
72
|
+
expect(result.success).toBe(true)
|
|
73
|
+
})
|
|
74
|
+
|
|
75
|
+
test('WeChatBotConfigSchema rejects missing accounts field', () => {
|
|
76
|
+
const result = WeChatBotConfigSchema.safeParse({ current: null })
|
|
77
|
+
expect(result.success).toBe(false)
|
|
78
|
+
})
|
|
79
|
+
|
|
80
|
+
test('WeChatBotConfigSchema rejects missing current field', () => {
|
|
81
|
+
const result = WeChatBotConfigSchema.safeParse({ accounts: {} })
|
|
82
|
+
expect(result.success).toBe(false)
|
|
83
|
+
})
|
|
84
|
+
|
|
85
|
+
test('WeChatBotCredentialsSchema validates correct data', () => {
|
|
86
|
+
const result = WeChatBotCredentialsSchema.safeParse({
|
|
87
|
+
app_id: 'wx123',
|
|
88
|
+
app_secret: 'secret123',
|
|
89
|
+
account_name: 'My Account',
|
|
90
|
+
})
|
|
91
|
+
expect(result.success).toBe(true)
|
|
92
|
+
})
|
|
93
|
+
|
|
94
|
+
test('WeChatBotCredentialsSchema rejects missing app_id', () => {
|
|
95
|
+
const result = WeChatBotCredentialsSchema.safeParse({
|
|
96
|
+
app_secret: 'secret123',
|
|
97
|
+
account_name: 'My Account',
|
|
98
|
+
})
|
|
99
|
+
expect(result.success).toBe(false)
|
|
100
|
+
})
|
|
101
|
+
|
|
102
|
+
test('WeChatBotCredentialsSchema rejects missing app_secret', () => {
|
|
103
|
+
const result = WeChatBotCredentialsSchema.safeParse({
|
|
104
|
+
app_id: 'wx123',
|
|
105
|
+
account_name: 'My Account',
|
|
106
|
+
})
|
|
107
|
+
expect(result.success).toBe(false)
|
|
108
|
+
})
|
|
109
|
+
|
|
110
|
+
test('WeChatBotCredentialsSchema rejects missing account_name', () => {
|
|
111
|
+
const result = WeChatBotCredentialsSchema.safeParse({
|
|
112
|
+
app_id: 'wx123',
|
|
113
|
+
app_secret: 'secret123',
|
|
114
|
+
})
|
|
115
|
+
expect(result.success).toBe(false)
|
|
116
|
+
})
|
|
117
|
+
|
|
118
|
+
test('WeChatBotNewsArticleSchema validates correct data', () => {
|
|
119
|
+
const result = WeChatBotNewsArticleSchema.safeParse({
|
|
120
|
+
title: 'Test Article',
|
|
121
|
+
description: 'Test description',
|
|
122
|
+
url: 'https://example.com',
|
|
123
|
+
picurl: 'https://example.com/pic.jpg',
|
|
124
|
+
})
|
|
125
|
+
expect(result.success).toBe(true)
|
|
126
|
+
})
|
|
127
|
+
|
|
128
|
+
test('WeChatBotNewsArticleSchema rejects missing title', () => {
|
|
129
|
+
const result = WeChatBotNewsArticleSchema.safeParse({
|
|
130
|
+
description: 'Test description',
|
|
131
|
+
url: 'https://example.com',
|
|
132
|
+
picurl: 'https://example.com/pic.jpg',
|
|
133
|
+
})
|
|
134
|
+
expect(result.success).toBe(false)
|
|
135
|
+
})
|
|
136
|
+
|
|
137
|
+
test('WeChatBotTemplateSchema validates correct data', () => {
|
|
138
|
+
const result = WeChatBotTemplateSchema.safeParse({
|
|
139
|
+
template_id: 'tmpl-001',
|
|
140
|
+
title: 'Order Notification',
|
|
141
|
+
primary_industry: 'IT科技',
|
|
142
|
+
deputy_industry: '互联网|电子商务',
|
|
143
|
+
content: 'ORDER_STATUS {{status.DATA}}',
|
|
144
|
+
example: 'Order shipped',
|
|
145
|
+
})
|
|
146
|
+
expect(result.success).toBe(true)
|
|
147
|
+
})
|
|
148
|
+
|
|
149
|
+
test('WeChatBotTemplateSchema rejects missing template_id', () => {
|
|
150
|
+
const result = WeChatBotTemplateSchema.safeParse({
|
|
151
|
+
title: 'Order Notification',
|
|
152
|
+
primary_industry: 'IT科技',
|
|
153
|
+
deputy_industry: '互联网|电子商务',
|
|
154
|
+
content: 'ORDER_STATUS {{status.DATA}}',
|
|
155
|
+
example: 'Order shipped',
|
|
156
|
+
})
|
|
157
|
+
expect(result.success).toBe(false)
|
|
158
|
+
})
|
|
159
|
+
|
|
160
|
+
test('WeChatBotUserInfoSchema validates correct data', () => {
|
|
161
|
+
const result = WeChatBotUserInfoSchema.safeParse({
|
|
162
|
+
subscribe: 1,
|
|
163
|
+
openid: 'openid-123',
|
|
164
|
+
language: 'zh_CN',
|
|
165
|
+
subscribe_time: 1609459200,
|
|
166
|
+
remark: '',
|
|
167
|
+
tagid_list: [1, 2],
|
|
168
|
+
subscribe_scene: 'ADD_SCENE_QR_CODE',
|
|
169
|
+
qr_scene: 0,
|
|
170
|
+
qr_scene_str: '',
|
|
171
|
+
})
|
|
172
|
+
expect(result.success).toBe(true)
|
|
173
|
+
})
|
|
174
|
+
|
|
175
|
+
test('WeChatBotUserInfoSchema validates with optional unionid', () => {
|
|
176
|
+
const result = WeChatBotUserInfoSchema.safeParse({
|
|
177
|
+
subscribe: 1,
|
|
178
|
+
openid: 'openid-123',
|
|
179
|
+
language: 'zh_CN',
|
|
180
|
+
subscribe_time: 1609459200,
|
|
181
|
+
unionid: 'union-id-xyz',
|
|
182
|
+
remark: '',
|
|
183
|
+
tagid_list: [],
|
|
184
|
+
subscribe_scene: 'ADD_SCENE_SEARCH',
|
|
185
|
+
qr_scene: 0,
|
|
186
|
+
qr_scene_str: '',
|
|
187
|
+
})
|
|
188
|
+
expect(result.success).toBe(true)
|
|
189
|
+
})
|
|
190
|
+
|
|
191
|
+
test('WeChatBotUserInfoSchema rejects missing openid', () => {
|
|
192
|
+
const result = WeChatBotUserInfoSchema.safeParse({
|
|
193
|
+
subscribe: 1,
|
|
194
|
+
language: 'zh_CN',
|
|
195
|
+
subscribe_time: 1609459200,
|
|
196
|
+
remark: '',
|
|
197
|
+
tagid_list: [],
|
|
198
|
+
subscribe_scene: 'ADD_SCENE_QR_CODE',
|
|
199
|
+
qr_scene: 0,
|
|
200
|
+
qr_scene_str: '',
|
|
201
|
+
})
|
|
202
|
+
expect(result.success).toBe(false)
|
|
203
|
+
})
|
|
204
|
+
|
|
205
|
+
test('WeChatBotError has correct name', () => {
|
|
206
|
+
const error = new WeChatBotError('Test error', 'TEST_CODE')
|
|
207
|
+
expect(error.name).toBe('WeChatBotError')
|
|
208
|
+
})
|
|
209
|
+
|
|
210
|
+
test('WeChatBotError has correct message', () => {
|
|
211
|
+
const error = new WeChatBotError('Test error', 'TEST_CODE')
|
|
212
|
+
expect(error.message).toBe('Test error')
|
|
213
|
+
})
|
|
214
|
+
|
|
215
|
+
test('WeChatBotError has correct code', () => {
|
|
216
|
+
const error = new WeChatBotError('Test error', 'TEST_CODE')
|
|
217
|
+
expect(error.code).toBe('TEST_CODE')
|
|
218
|
+
})
|
|
219
|
+
|
|
220
|
+
test('WeChatBotError is instance of Error', () => {
|
|
221
|
+
const error = new WeChatBotError('Test error', 'TEST_CODE')
|
|
222
|
+
expect(error instanceof Error).toBe(true)
|
|
223
|
+
})
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { z } from 'zod'
|
|
2
|
+
|
|
3
|
+
export interface WeChatBotAccountEntry {
|
|
4
|
+
app_id: string
|
|
5
|
+
app_secret: string
|
|
6
|
+
account_name: string
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface WeChatBotConfig {
|
|
10
|
+
current: { account_id: string } | null
|
|
11
|
+
accounts: Record<string, WeChatBotAccountEntry>
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface WeChatBotCredentials {
|
|
15
|
+
app_id: string
|
|
16
|
+
app_secret: string
|
|
17
|
+
account_name: string
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface WeChatBotNewsArticle {
|
|
21
|
+
title: string
|
|
22
|
+
description: string
|
|
23
|
+
url: string
|
|
24
|
+
picurl: string
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface WeChatBotTemplate {
|
|
28
|
+
template_id: string
|
|
29
|
+
title: string
|
|
30
|
+
primary_industry: string
|
|
31
|
+
deputy_industry: string
|
|
32
|
+
content: string
|
|
33
|
+
example: string
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export interface WeChatBotUserInfo {
|
|
37
|
+
subscribe: number
|
|
38
|
+
openid: string
|
|
39
|
+
language: string
|
|
40
|
+
subscribe_time: number
|
|
41
|
+
unionid?: string
|
|
42
|
+
remark: string
|
|
43
|
+
tagid_list: number[]
|
|
44
|
+
subscribe_scene: string
|
|
45
|
+
qr_scene: number
|
|
46
|
+
qr_scene_str: string
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export class WeChatBotError extends Error {
|
|
50
|
+
code: string
|
|
51
|
+
|
|
52
|
+
constructor(message: string, code: string) {
|
|
53
|
+
super(message)
|
|
54
|
+
this.name = 'WeChatBotError'
|
|
55
|
+
this.code = code
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export const WeChatBotAccountEntrySchema = z.object({
|
|
60
|
+
app_id: z.string(),
|
|
61
|
+
app_secret: z.string(),
|
|
62
|
+
account_name: z.string(),
|
|
63
|
+
})
|
|
64
|
+
|
|
65
|
+
export const WeChatBotConfigSchema = z.object({
|
|
66
|
+
current: z
|
|
67
|
+
.object({
|
|
68
|
+
account_id: z.string(),
|
|
69
|
+
})
|
|
70
|
+
.nullable(),
|
|
71
|
+
accounts: z.record(z.string(), WeChatBotAccountEntrySchema),
|
|
72
|
+
})
|
|
73
|
+
|
|
74
|
+
export const WeChatBotCredentialsSchema = z.object({
|
|
75
|
+
app_id: z.string(),
|
|
76
|
+
app_secret: z.string(),
|
|
77
|
+
account_name: z.string(),
|
|
78
|
+
})
|
|
79
|
+
|
|
80
|
+
export const WeChatBotNewsArticleSchema = z.object({
|
|
81
|
+
title: z.string(),
|
|
82
|
+
description: z.string(),
|
|
83
|
+
url: z.string(),
|
|
84
|
+
picurl: z.string(),
|
|
85
|
+
})
|
|
86
|
+
|
|
87
|
+
export const WeChatBotTemplateSchema = z.object({
|
|
88
|
+
template_id: z.string(),
|
|
89
|
+
title: z.string(),
|
|
90
|
+
primary_industry: z.string(),
|
|
91
|
+
deputy_industry: z.string(),
|
|
92
|
+
content: z.string(),
|
|
93
|
+
example: z.string(),
|
|
94
|
+
})
|
|
95
|
+
|
|
96
|
+
export const WeChatBotUserInfoSchema = z.object({
|
|
97
|
+
subscribe: z.number(),
|
|
98
|
+
openid: z.string(),
|
|
99
|
+
language: z.string(),
|
|
100
|
+
subscribe_time: z.number(),
|
|
101
|
+
unionid: z.string().optional(),
|
|
102
|
+
remark: z.string(),
|
|
103
|
+
tagid_list: z.array(z.number()),
|
|
104
|
+
subscribe_scene: z.string(),
|
|
105
|
+
qr_scene: z.number(),
|
|
106
|
+
qr_scene_str: z.string(),
|
|
107
|
+
})
|
|
@@ -5,7 +5,7 @@ import type { Command as CommandType } from 'commander'
|
|
|
5
5
|
import { Command } from 'commander'
|
|
6
6
|
|
|
7
7
|
import pkg from '../../../package.json' with { type: 'json' }
|
|
8
|
-
import { authCommand, chatCommand, messageCommand } from './commands/index'
|
|
8
|
+
import { authCommand, chatCommand, messageCommand, whoamiCommand } from './commands/index'
|
|
9
9
|
import { ensureWhatsAppAuth } from './ensure-auth'
|
|
10
10
|
|
|
11
11
|
function isAuthCommand(command: CommandType): boolean {
|
|
@@ -32,6 +32,7 @@ program.hook('preAction', async (_thisCommand, actionCommand) => {
|
|
|
32
32
|
program.addCommand(authCommand)
|
|
33
33
|
program.addCommand(chatCommand)
|
|
34
34
|
program.addCommand(messageCommand)
|
|
35
|
+
program.addCommand(whoamiCommand)
|
|
35
36
|
|
|
36
37
|
program.parse(process.argv)
|
|
37
38
|
|