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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../../../../src/platforms/webex/cli.ts"],"names":[],"mappings":";AAEA,OAAO,KAAK,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,WAAW,CAAA;AAgBvD,QAAA,MAAM,OAAO,aAAgB,CAAA;
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../../../../src/platforms/webex/cli.ts"],"names":[],"mappings":";AAEA,OAAO,KAAK,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,WAAW,CAAA;AAgBvD,QAAA,MAAM,OAAO,aAAgB,CAAA;AAqB7B,eAAe,OAAO,CAAA"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
import { Command } from 'commander';
|
|
3
3
|
import pkg from '../../../package.json' with { type: 'json' };
|
|
4
|
-
import { authCommand, memberCommand, messageCommand, snapshotCommand, spaceCommand } from './commands/index.js';
|
|
4
|
+
import { authCommand, memberCommand, messageCommand, snapshotCommand, spaceCommand, whoamiCommand } from './commands/index.js';
|
|
5
5
|
import { ensureWebexAuth } from './ensure-auth.js';
|
|
6
6
|
function isAuthCommand(command) {
|
|
7
7
|
let cmd = command;
|
|
@@ -27,6 +27,7 @@ program.addCommand(memberCommand);
|
|
|
27
27
|
program.addCommand(messageCommand);
|
|
28
28
|
program.addCommand(snapshotCommand);
|
|
29
29
|
program.addCommand(spaceCommand);
|
|
30
|
+
program.addCommand(whoamiCommand);
|
|
30
31
|
program.parse(process.argv);
|
|
31
32
|
export default program;
|
|
32
33
|
//# sourceMappingURL=cli.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../../../../src/platforms/webex/cli.ts"],"names":[],"mappings":";AAGA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAEnC,OAAO,GAAG,MAAM,uBAAuB,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAA;AAC7D,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,cAAc,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../../../../src/platforms/webex/cli.ts"],"names":[],"mappings":";AAGA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAEnC,OAAO,GAAG,MAAM,uBAAuB,CAA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js';
|
|
|
3
3
|
export { messageCommand } from './message.js';
|
|
4
4
|
export { snapshotAction, snapshotCommand } from './snapshot.js';
|
|
5
5
|
export { spaceCommand } from './space.js';
|
|
6
|
+
export { whoamiCommand } from './whoami.js';
|
|
6
7
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/platforms/webex/commands/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAA;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AACxC,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AAC1C,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/platforms/webex/commands/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAA;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AACxC,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AAC1C,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AACtC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA"}
|
|
@@ -3,4 +3,5 @@ export { memberCommand } from './member.js';
|
|
|
3
3
|
export { messageCommand } from './message.js';
|
|
4
4
|
export { snapshotAction, snapshotCommand } from './snapshot.js';
|
|
5
5
|
export { spaceCommand } from './space.js';
|
|
6
|
+
export { whoamiCommand } from './whoami.js';
|
|
6
7
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/platforms/webex/commands/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAA;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AACxC,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AAC1C,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/platforms/webex/commands/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAA;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AACxC,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AAC1C,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AACtC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA"}
|
|
@@ -58,7 +58,7 @@ export async function deleteAction(messageId, options) {
|
|
|
58
58
|
try {
|
|
59
59
|
if (!options.force) {
|
|
60
60
|
console.log(formatOutput({ warning: 'Use --force to confirm deletion', messageId }, options.pretty));
|
|
61
|
-
process.exit(0);
|
|
61
|
+
return process.exit(0);
|
|
62
62
|
}
|
|
63
63
|
const client = await new WebexClient().login();
|
|
64
64
|
await client.deleteMessage(messageId);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"message.js","sourceRoot":"","sources":["../../../../../src/platforms/webex/commands/message.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAEnC,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAA;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AAEpD,OAAO,EAAE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OAAO,CAAC,MAAM,CAAC;KAChB,WAAW,CAAC,gBAAgB,CAAC;KAC7B,QAAQ,CAAC,cAAc,EAAE,YAAY,CAAC;KACtC,QAAQ,CAAC,YAAY,EAAE,uCAAuC,CAAC;KAC/D,QAAQ,CAAC,QAAQ,EAAE,kBAAkB,CAAC;KACtC,MAAM,CAAC,YAAY,EAAE,kBAAkB,CAAC;KACxC,MAAM,CAAC,UAAU,EAAE,0BAA0B,CAAC;KAC9C,MAAM,CAAC,UAAU,CAAC,CACtB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"whoami.d.ts","sourceRoot":"","sources":["../../../../../src/platforms/webex/commands/whoami.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAKnC,wBAAsB,YAAY,CAAC,OAAO,EAAE;IAAE,MAAM,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAoB/E;AAED,eAAO,MAAM,aAAa,SAGH,CAAA"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import { handleError } from '../../../shared/utils/error-handler.js';
|
|
3
|
+
import { formatOutput } from '../../../shared/utils/output.js';
|
|
4
|
+
import { WebexClient } from '../client.js';
|
|
5
|
+
export async function whoamiAction(options) {
|
|
6
|
+
try {
|
|
7
|
+
const client = await new WebexClient().login();
|
|
8
|
+
const user = await client.testAuth();
|
|
9
|
+
const output = {
|
|
10
|
+
id: user.id,
|
|
11
|
+
emails: user.emails,
|
|
12
|
+
displayName: user.displayName,
|
|
13
|
+
nickName: user.nickName,
|
|
14
|
+
firstName: user.firstName,
|
|
15
|
+
lastName: user.lastName,
|
|
16
|
+
avatar: user.avatar,
|
|
17
|
+
orgId: user.orgId,
|
|
18
|
+
type: user.type,
|
|
19
|
+
};
|
|
20
|
+
console.log(formatOutput(output, options.pretty));
|
|
21
|
+
}
|
|
22
|
+
catch (error) {
|
|
23
|
+
handleError(error);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
export const whoamiCommand = new Command('whoami')
|
|
27
|
+
.description('Show current authenticated user')
|
|
28
|
+
.option('--pretty', 'Pretty print JSON output')
|
|
29
|
+
.action(whoamiAction);
|
|
30
|
+
//# sourceMappingURL=whoami.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"whoami.js","sourceRoot":"","sources":["../../../../../src/platforms/webex/commands/whoami.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAA;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AAEvC,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,OAA6B;IAC9D,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,MAAM,IAAI,WAAW,EAAE,CAAC,KAAK,EAAE,CAAA;QAC9C,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,QAAQ,EAAE,CAAA;QAEpC,MAAM,MAAM,GAAG;YACb,EAAE,EAAE,IAAI,CAAC,EAAE;YACX,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,IAAI,EAAE,IAAI,CAAC,IAAI;SAChB,CAAA;QACD,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,CAAA;IACnD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,WAAW,CAAC,KAAc,CAAC,CAAA;IAC7B,CAAC;AACH,CAAC;AAED,MAAM,CAAC,MAAM,aAAa,GAAG,IAAI,OAAO,CAAC,QAAQ,CAAC;KAC/C,WAAW,CAAC,iCAAiC,CAAC;KAC9C,MAAM,CAAC,UAAU,EAAE,0BAA0B,CAAC;KAC9C,MAAM,CAAC,YAAY,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../../../../src/platforms/wechatbot/cli.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAKnC,QAAA,MAAM,OAAO,SAAgB,CAAA;AAiB7B,eAAe,OAAO,CAAA"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
|
+
import { Command } from 'commander';
|
|
3
|
+
import pkg from '../../../package.json' with { type: 'json' };
|
|
4
|
+
import { authCommand, messageCommand, templateCommand, userCommand, whoamiCommand } from './commands/index.js';
|
|
5
|
+
const program = new Command();
|
|
6
|
+
program
|
|
7
|
+
.name('agent-wechatbot')
|
|
8
|
+
.description('CLI tool for WeChat Official Account bot integration')
|
|
9
|
+
.version(pkg.version)
|
|
10
|
+
.option('--pretty', 'Pretty-print JSON output')
|
|
11
|
+
.option('--account <id>', 'Account ID to use');
|
|
12
|
+
program.addCommand(authCommand);
|
|
13
|
+
program.addCommand(whoamiCommand);
|
|
14
|
+
program.addCommand(messageCommand);
|
|
15
|
+
program.addCommand(templateCommand);
|
|
16
|
+
program.addCommand(userCommand);
|
|
17
|
+
program.parseAsync(process.argv);
|
|
18
|
+
export default program;
|
|
19
|
+
//# sourceMappingURL=cli.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../../../../src/platforms/wechatbot/cli.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAEnC,OAAO,GAAG,MAAM,uBAAuB,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAA;AAC7D,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,eAAe,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAE3G,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAA;AAE7B,OAAO;KACJ,IAAI,CAAC,iBAAiB,CAAC;KACvB,WAAW,CAAC,sDAAsD,CAAC;KACnE,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC;KACpB,MAAM,CAAC,UAAU,EAAE,0BAA0B,CAAC;KAC9C,MAAM,CAAC,gBAAgB,EAAE,mBAAmB,CAAC,CAAA;AAEhD,OAAO,CAAC,UAAU,CAAC,WAAW,CAAC,CAAA;AAC/B,OAAO,CAAC,UAAU,CAAC,aAAa,CAAC,CAAA;AACjC,OAAO,CAAC,UAAU,CAAC,cAAc,CAAC,CAAA;AAClC,OAAO,CAAC,UAAU,CAAC,eAAe,CAAC,CAAA;AACnC,OAAO,CAAC,UAAU,CAAC,WAAW,CAAC,CAAA;AAE/B,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;AAEhC,eAAe,OAAO,CAAA"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { WeChatBotNewsArticle, WeChatBotTemplate, WeChatBotUserInfo } from './types.js';
|
|
2
|
+
export declare class WeChatBotClient {
|
|
3
|
+
private appId;
|
|
4
|
+
private appSecret;
|
|
5
|
+
private accessToken;
|
|
6
|
+
private tokenExpiresAt;
|
|
7
|
+
login(credentials?: {
|
|
8
|
+
appId: string;
|
|
9
|
+
appSecret: string;
|
|
10
|
+
}): Promise<this>;
|
|
11
|
+
private ensureAuth;
|
|
12
|
+
private ensureAccessToken;
|
|
13
|
+
private fetchAccessToken;
|
|
14
|
+
verifyCredentials(): Promise<boolean>;
|
|
15
|
+
sendTextMessage(openId: string, text: string): Promise<void>;
|
|
16
|
+
sendImageMessage(openId: string, mediaId: string): Promise<void>;
|
|
17
|
+
sendNewsMessage(openId: string, articles: WeChatBotNewsArticle[]): Promise<void>;
|
|
18
|
+
sendTemplateMessage(openId: string, templateId: string, data: Record<string, {
|
|
19
|
+
value: string;
|
|
20
|
+
}>, url?: string): Promise<{
|
|
21
|
+
msgid: number;
|
|
22
|
+
}>;
|
|
23
|
+
listTemplates(): Promise<WeChatBotTemplate[]>;
|
|
24
|
+
deleteTemplate(templateId: string): Promise<void>;
|
|
25
|
+
getFollowers(nextOpenId?: string): Promise<{
|
|
26
|
+
total: number;
|
|
27
|
+
count: number;
|
|
28
|
+
openids: string[];
|
|
29
|
+
next_openid: string;
|
|
30
|
+
}>;
|
|
31
|
+
getUserInfo(openId: string, lang?: string): Promise<WeChatBotUserInfo>;
|
|
32
|
+
private request;
|
|
33
|
+
private buildPath;
|
|
34
|
+
private sleep;
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../../src/platforms/wechatbot/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAOzF,qBAAa,eAAe;IAC1B,OAAO,CAAC,KAAK,CAAsB;IACnC,OAAO,CAAC,SAAS,CAAsB;IACvC,OAAO,CAAC,WAAW,CAAsB;IACzC,OAAO,CAAC,cAAc,CAAY;IAE5B,KAAK,CAAC,WAAW,CAAC,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAwB9E,OAAO,CAAC,UAAU;YAMJ,iBAAiB;YAWjB,gBAAgB;IAuBxB,iBAAiB,IAAI,OAAO,CAAC,OAAO,CAAC;IAUrC,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAQ5D,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAQhE,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,oBAAoB,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAQhF,mBAAmB,CACvB,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,EACvC,GAAG,CAAC,EAAE,MAAM,GACX,OAAO,CAAC;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;IASvB,aAAa,IAAI,OAAO,CAAC,iBAAiB,EAAE,CAAC;IAQ7C,cAAc,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAMjD,YAAY,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;QAC/C,KAAK,EAAE,MAAM,CAAA;QACb,KAAK,EAAE,MAAM,CAAA;QACb,OAAO,EAAE,MAAM,EAAE,CAAA;QACjB,WAAW,EAAE,MAAM,CAAA;KACpB,CAAC;IAgBI,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,SAAU,GAAG,OAAO,CAAC,iBAAiB,CAAC;YAK/D,OAAO;IA+ErB,OAAO,CAAC,SAAS;IAoBjB,OAAO,CAAC,KAAK;CAGd"}
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
import { WeChatBotError } from './types.js';
|
|
2
|
+
const BASE_URL = 'https://api.weixin.qq.com';
|
|
3
|
+
const MAX_RETRIES = 3;
|
|
4
|
+
const BASE_BACKOFF_MS = 100;
|
|
5
|
+
export class WeChatBotClient {
|
|
6
|
+
appId = null;
|
|
7
|
+
appSecret = null;
|
|
8
|
+
accessToken = null;
|
|
9
|
+
tokenExpiresAt = 0;
|
|
10
|
+
async login(credentials) {
|
|
11
|
+
if (credentials) {
|
|
12
|
+
if (!credentials.appId) {
|
|
13
|
+
throw new WeChatBotError('App ID is required', 'missing_app_id');
|
|
14
|
+
}
|
|
15
|
+
if (!credentials.appSecret) {
|
|
16
|
+
throw new WeChatBotError('App Secret is required', 'missing_app_secret');
|
|
17
|
+
}
|
|
18
|
+
this.appId = credentials.appId;
|
|
19
|
+
this.appSecret = credentials.appSecret;
|
|
20
|
+
return this;
|
|
21
|
+
}
|
|
22
|
+
const { WeChatBotCredentialManager } = await import('./credential-manager.js');
|
|
23
|
+
const credManager = new WeChatBotCredentialManager();
|
|
24
|
+
const creds = await credManager.getCredentials();
|
|
25
|
+
if (!creds) {
|
|
26
|
+
throw new WeChatBotError('No WeChat Bot credentials found. Run "agent-wechatbot auth set" first.', 'no_credentials');
|
|
27
|
+
}
|
|
28
|
+
return this.login({ appId: creds.app_id, appSecret: creds.app_secret });
|
|
29
|
+
}
|
|
30
|
+
ensureAuth() {
|
|
31
|
+
if (this.appId === null) {
|
|
32
|
+
throw new WeChatBotError('Not authenticated. Call .login() first.', 'not_authenticated');
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
async ensureAccessToken() {
|
|
36
|
+
const now = Date.now();
|
|
37
|
+
if (this.accessToken && now < this.tokenExpiresAt) {
|
|
38
|
+
return this.accessToken;
|
|
39
|
+
}
|
|
40
|
+
const result = await this.fetchAccessToken();
|
|
41
|
+
this.accessToken = result.access_token;
|
|
42
|
+
this.tokenExpiresAt = now + (result.expires_in - 10) * 1000;
|
|
43
|
+
return this.accessToken;
|
|
44
|
+
}
|
|
45
|
+
async fetchAccessToken() {
|
|
46
|
+
const url = `${BASE_URL}/cgi-bin/token?grant_type=client_credential&appid=${this.appId}&secret=${this.appSecret}`;
|
|
47
|
+
let response;
|
|
48
|
+
try {
|
|
49
|
+
response = await fetch(url);
|
|
50
|
+
}
|
|
51
|
+
catch (error) {
|
|
52
|
+
const msg = error instanceof Error ? error.message : String(error);
|
|
53
|
+
throw new WeChatBotError(`Network error fetching access token: ${msg}`, 'network_error');
|
|
54
|
+
}
|
|
55
|
+
const data = (await response.json());
|
|
56
|
+
if (data.errcode) {
|
|
57
|
+
throw new WeChatBotError(data.errmsg ?? `Error ${data.errcode}`, String(data.errcode));
|
|
58
|
+
}
|
|
59
|
+
if (!data.access_token) {
|
|
60
|
+
throw new WeChatBotError('Failed to obtain access token', 'token_fetch_failed');
|
|
61
|
+
}
|
|
62
|
+
return { access_token: data.access_token, expires_in: data.expires_in ?? 7200 };
|
|
63
|
+
}
|
|
64
|
+
async verifyCredentials() {
|
|
65
|
+
this.ensureAuth();
|
|
66
|
+
try {
|
|
67
|
+
await this.fetchAccessToken();
|
|
68
|
+
return true;
|
|
69
|
+
}
|
|
70
|
+
catch {
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
async sendTextMessage(openId, text) {
|
|
75
|
+
await this.request('POST', '/cgi-bin/message/custom/send', {
|
|
76
|
+
touser: openId,
|
|
77
|
+
msgtype: 'text',
|
|
78
|
+
text: { content: text },
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
async sendImageMessage(openId, mediaId) {
|
|
82
|
+
await this.request('POST', '/cgi-bin/message/custom/send', {
|
|
83
|
+
touser: openId,
|
|
84
|
+
msgtype: 'image',
|
|
85
|
+
image: { media_id: mediaId },
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
async sendNewsMessage(openId, articles) {
|
|
89
|
+
await this.request('POST', '/cgi-bin/message/custom/send', {
|
|
90
|
+
touser: openId,
|
|
91
|
+
msgtype: 'news',
|
|
92
|
+
news: { articles },
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
async sendTemplateMessage(openId, templateId, data, url) {
|
|
96
|
+
return this.request('POST', '/cgi-bin/message/template/send', {
|
|
97
|
+
touser: openId,
|
|
98
|
+
template_id: templateId,
|
|
99
|
+
url,
|
|
100
|
+
data,
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
async listTemplates() {
|
|
104
|
+
const result = await this.request('GET', '/cgi-bin/template/get_all_private_template');
|
|
105
|
+
return result.template_list;
|
|
106
|
+
}
|
|
107
|
+
async deleteTemplate(templateId) {
|
|
108
|
+
await this.request('POST', '/cgi-bin/template/del_private_template', {
|
|
109
|
+
template_id: templateId,
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
async getFollowers(nextOpenId) {
|
|
113
|
+
const path = this.buildPath('/cgi-bin/user/get', nextOpenId ? { next_openid: nextOpenId } : undefined);
|
|
114
|
+
const result = await this.request('GET', path);
|
|
115
|
+
return {
|
|
116
|
+
total: result.total,
|
|
117
|
+
count: result.count,
|
|
118
|
+
openids: result.data?.openid ?? [],
|
|
119
|
+
next_openid: result.next_openid,
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
async getUserInfo(openId, lang = 'zh_CN') {
|
|
123
|
+
const path = this.buildPath('/cgi-bin/user/info', { openid: openId, lang });
|
|
124
|
+
return this.request('GET', path);
|
|
125
|
+
}
|
|
126
|
+
async request(method, path, body) {
|
|
127
|
+
this.ensureAuth();
|
|
128
|
+
let lastError;
|
|
129
|
+
let tokenInvalidated = false;
|
|
130
|
+
for (let attempt = 0; attempt <= MAX_RETRIES; attempt++) {
|
|
131
|
+
const token = await this.ensureAccessToken();
|
|
132
|
+
const url = `${BASE_URL}${path}${path.includes('?') ? '&' : '?'}access_token=${token}`;
|
|
133
|
+
const options = {
|
|
134
|
+
method,
|
|
135
|
+
headers: {
|
|
136
|
+
'Content-Type': 'application/json',
|
|
137
|
+
},
|
|
138
|
+
};
|
|
139
|
+
if (body !== undefined) {
|
|
140
|
+
options.body = JSON.stringify(body);
|
|
141
|
+
}
|
|
142
|
+
let response;
|
|
143
|
+
try {
|
|
144
|
+
response = await fetch(url, options);
|
|
145
|
+
}
|
|
146
|
+
catch (error) {
|
|
147
|
+
lastError = error instanceof Error ? error : new Error(String(error));
|
|
148
|
+
if (attempt < MAX_RETRIES && method === 'GET') {
|
|
149
|
+
await this.sleep(BASE_BACKOFF_MS * 2 ** attempt);
|
|
150
|
+
continue;
|
|
151
|
+
}
|
|
152
|
+
throw new WeChatBotError(`Network error: ${lastError.message}`, 'network_error');
|
|
153
|
+
}
|
|
154
|
+
if (response.status >= 500 && response.status <= 599) {
|
|
155
|
+
if (attempt < MAX_RETRIES && method === 'GET') {
|
|
156
|
+
await this.sleep(BASE_BACKOFF_MS * 2 ** attempt);
|
|
157
|
+
continue;
|
|
158
|
+
}
|
|
159
|
+
throw new WeChatBotError(`HTTP ${response.status}`, `http_${response.status}`);
|
|
160
|
+
}
|
|
161
|
+
const data = (await response.json());
|
|
162
|
+
if (data.errcode === 40001 || data.errcode === 42001) {
|
|
163
|
+
if (!tokenInvalidated) {
|
|
164
|
+
tokenInvalidated = true;
|
|
165
|
+
this.accessToken = null;
|
|
166
|
+
this.tokenExpiresAt = 0;
|
|
167
|
+
continue;
|
|
168
|
+
}
|
|
169
|
+
throw new WeChatBotError(data.errmsg ?? `Error ${data.errcode}`, String(data.errcode));
|
|
170
|
+
}
|
|
171
|
+
if (data.errcode === -1) {
|
|
172
|
+
if (attempt < MAX_RETRIES) {
|
|
173
|
+
await this.sleep(BASE_BACKOFF_MS * 2 ** attempt);
|
|
174
|
+
continue;
|
|
175
|
+
}
|
|
176
|
+
throw new WeChatBotError('WeChat system busy', '-1');
|
|
177
|
+
}
|
|
178
|
+
if (data.errcode === 45009) {
|
|
179
|
+
throw new WeChatBotError('WeChat API frequency limit exceeded', '45009');
|
|
180
|
+
}
|
|
181
|
+
if (data.errcode && data.errcode !== 0) {
|
|
182
|
+
throw new WeChatBotError(data.errmsg ?? `Error ${data.errcode}`, String(data.errcode));
|
|
183
|
+
}
|
|
184
|
+
return data;
|
|
185
|
+
}
|
|
186
|
+
throw lastError ?? new WeChatBotError('Request failed after retries', 'max_retries');
|
|
187
|
+
}
|
|
188
|
+
buildPath(path, params) {
|
|
189
|
+
if (!params) {
|
|
190
|
+
return path;
|
|
191
|
+
}
|
|
192
|
+
const searchParams = new URLSearchParams();
|
|
193
|
+
for (const [key, value] of Object.entries(params)) {
|
|
194
|
+
if (value !== undefined) {
|
|
195
|
+
searchParams.set(key, String(value));
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
const query = searchParams.toString();
|
|
199
|
+
if (!query) {
|
|
200
|
+
return path;
|
|
201
|
+
}
|
|
202
|
+
return `${path}?${query}`;
|
|
203
|
+
}
|
|
204
|
+
sleep(ms) {
|
|
205
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../../../src/platforms/wechatbot/client.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAExC,MAAM,QAAQ,GAAG,2BAA2B,CAAA;AAC5C,MAAM,WAAW,GAAG,CAAC,CAAA;AACrB,MAAM,eAAe,GAAG,GAAG,CAAA;AAE3B,MAAM,OAAO,eAAe;IAClB,KAAK,GAAkB,IAAI,CAAA;IAC3B,SAAS,GAAkB,IAAI,CAAA;IAC/B,WAAW,GAAkB,IAAI,CAAA;IACjC,cAAc,GAAW,CAAC,CAAA;IAElC,KAAK,CAAC,KAAK,CAAC,WAAkD;QAC5D,IAAI,WAAW,EAAE,CAAC;YAChB,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE,CAAC;gBACvB,MAAM,IAAI,cAAc,CAAC,oBAAoB,EAAE,gBAAgB,CAAC,CAAA;YAClE,CAAC;YACD,IAAI,CAAC,WAAW,CAAC,SAAS,EAAE,CAAC;gBAC3B,MAAM,IAAI,cAAc,CAAC,wBAAwB,EAAE,oBAAoB,CAAC,CAAA;YAC1E,CAAC;YACD,IAAI,CAAC,KAAK,GAAG,WAAW,CAAC,KA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CAAC;QAED,MAAM,YAAY,GAAG,IAAI,eAAe,EAAE,CAAA;QAC1C,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;YAClD,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;gBACxB,YAAY,CAAC,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAA;YACtC,CAAC;QACH,CAAC;QAED,MAAM,KAAK,GAAG,YAAY,CAAC,QAAQ,EAAE,CAAA;QACrC,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,OAAO,IAAI,CAAA;QACb,CAAC;QAED,OAAO,GAAG,IAAI,IAAI,KAAK,EAAE,CAAA;IAC3B,CAAC;IAEO,KAAK,CAAC,EAAU;QACtB,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAA;IAC1D,CAAC;CACF"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import { WeChatBotCredentialManager } from '../credential-manager.js';
|
|
3
|
+
interface ActionOptions {
|
|
4
|
+
account?: string;
|
|
5
|
+
pretty?: boolean;
|
|
6
|
+
_credManager?: WeChatBotCredentialManager;
|
|
7
|
+
}
|
|
8
|
+
interface ActionResult {
|
|
9
|
+
success?: boolean;
|
|
10
|
+
error?: string;
|
|
11
|
+
valid?: boolean;
|
|
12
|
+
app_id?: string;
|
|
13
|
+
account_name?: string;
|
|
14
|
+
accounts?: Array<{
|
|
15
|
+
app_id: string;
|
|
16
|
+
account_name: string;
|
|
17
|
+
is_current: boolean;
|
|
18
|
+
}>;
|
|
19
|
+
}
|
|
20
|
+
export declare function setAction(appId: string, appSecret: string, options: ActionOptions): Promise<ActionResult>;
|
|
21
|
+
export declare function statusAction(options: ActionOptions): Promise<ActionResult>;
|
|
22
|
+
export declare function clearAction(options: ActionOptions): Promise<ActionResult>;
|
|
23
|
+
export declare function listAction(options: ActionOptions): Promise<ActionResult>;
|
|
24
|
+
export declare function useAction(accountId: string, options: ActionOptions): Promise<ActionResult>;
|
|
25
|
+
export declare function removeAction(accountId: string, options: ActionOptions): Promise<ActionResult>;
|
|
26
|
+
export declare const authCommand: Command;
|
|
27
|
+
export {};
|
|
28
|
+
//# sourceMappingURL=auth.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../../../../src/platforms/wechatbot/commands/auth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAKnC,OAAO,EAAE,0BAA0B,EAAE,MAAM,uBAAuB,CAAA;AAElE,UAAU,aAAa;IACrB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,YAAY,CAAC,EAAE,0BAA0B,CAAA;CAC1C;AAED,UAAU,YAAY;IACpB,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,EAAE,KAAK,CAAC;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,YAAY,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,OAAO,CAAA;KAAE,CAAC,CAAA;CAChF;AAED,wBAAsB,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,YAAY,CAAC,CAoB/G;AAED,wBAAsB,YAAY,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,YAAY,CAAC,CAiChF;AAED,wBAAsB,WAAW,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,YAAY,CAAC,CAQ/E;AAED,wBAAsB,UAAU,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,YAAY,CAAC,CAe9E;AAED,wBAAsB,SAAS,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,YAAY,CAAC,CAkBhG;AAED,wBAAsB,YAAY,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,YAAY,CAAC,CAanG;AAOD,eAAO,MAAM,WAAW,SAwDrB,CAAA"}
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import { formatOutput } from '../../../shared/utils/output.js';
|
|
3
|
+
import { WeChatBotClient } from '../client.js';
|
|
4
|
+
import { WeChatBotCredentialManager } from '../credential-manager.js';
|
|
5
|
+
export async function setAction(appId, appSecret, options) {
|
|
6
|
+
try {
|
|
7
|
+
const client = await new WeChatBotClient().login({ appId, appSecret });
|
|
8
|
+
const valid = await client.verifyCredentials();
|
|
9
|
+
if (!valid) {
|
|
10
|
+
return { error: 'Invalid credentials. Could not obtain access token.' };
|
|
11
|
+
}
|
|
12
|
+
const credManager = options._credManager ?? new WeChatBotCredentialManager();
|
|
13
|
+
await credManager.setCredentials({
|
|
14
|
+
app_id: appId,
|
|
15
|
+
app_secret: appSecret,
|
|
16
|
+
account_name: appId,
|
|
17
|
+
});
|
|
18
|
+
return { success: true, app_id: appId, account_name: appId };
|
|
19
|
+
}
|
|
20
|
+
catch (error) {
|
|
21
|
+
return { error: error.message };
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
export async function statusAction(options) {
|
|
25
|
+
try {
|
|
26
|
+
const credManager = options._credManager ?? new WeChatBotCredentialManager();
|
|
27
|
+
const creds = await credManager.getCredentials(options.account);
|
|
28
|
+
if (!creds) {
|
|
29
|
+
return {
|
|
30
|
+
valid: false,
|
|
31
|
+
error: options.account
|
|
32
|
+
? `Account "${options.account}" not found. Run "auth list" to see available accounts.`
|
|
33
|
+
: 'No credentials configured. Run "auth set <app-id> <app-secret>" first.',
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
let valid = false;
|
|
37
|
+
let appId;
|
|
38
|
+
let accountName;
|
|
39
|
+
try {
|
|
40
|
+
const client = await new WeChatBotClient().login({ appId: creds.app_id, appSecret: creds.app_secret });
|
|
41
|
+
valid = await client.verifyCredentials();
|
|
42
|
+
appId = creds.app_id;
|
|
43
|
+
accountName = creds.account_name;
|
|
44
|
+
}
|
|
45
|
+
catch {
|
|
46
|
+
valid = false;
|
|
47
|
+
appId = creds.app_id;
|
|
48
|
+
accountName = creds.account_name;
|
|
49
|
+
}
|
|
50
|
+
return { valid, app_id: appId, account_name: accountName };
|
|
51
|
+
}
|
|
52
|
+
catch (error) {
|
|
53
|
+
return { error: error.message };
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
export async function clearAction(options) {
|
|
57
|
+
try {
|
|
58
|
+
const credManager = options._credManager ?? new WeChatBotCredentialManager();
|
|
59
|
+
await credManager.clearCredentials();
|
|
60
|
+
return { success: true };
|
|
61
|
+
}
|
|
62
|
+
catch (error) {
|
|
63
|
+
return { error: error.message };
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
export async function listAction(options) {
|
|
67
|
+
try {
|
|
68
|
+
const credManager = options._credManager ?? new WeChatBotCredentialManager();
|
|
69
|
+
const all = await credManager.listAll();
|
|
70
|
+
return {
|
|
71
|
+
accounts: all.map((a) => ({
|
|
72
|
+
app_id: a.app_id,
|
|
73
|
+
account_name: a.account_name,
|
|
74
|
+
is_current: a.is_current,
|
|
75
|
+
})),
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
catch (error) {
|
|
79
|
+
return { error: error.message };
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
export async function useAction(accountId, options) {
|
|
83
|
+
try {
|
|
84
|
+
const credManager = options._credManager ?? new WeChatBotCredentialManager();
|
|
85
|
+
const found = await credManager.setCurrent(accountId);
|
|
86
|
+
if (!found) {
|
|
87
|
+
return { error: `Account "${accountId}" not found. Run "auth list" to see available accounts.` };
|
|
88
|
+
}
|
|
89
|
+
const creds = await credManager.getCredentials();
|
|
90
|
+
return {
|
|
91
|
+
success: true,
|
|
92
|
+
app_id: creds?.app_id,
|
|
93
|
+
account_name: creds?.account_name,
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
catch (error) {
|
|
97
|
+
return { error: error.message };
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
export async function removeAction(accountId, options) {
|
|
101
|
+
try {
|
|
102
|
+
const credManager = options._credManager ?? new WeChatBotCredentialManager();
|
|
103
|
+
const removed = await credManager.removeAccount(accountId);
|
|
104
|
+
if (!removed) {
|
|
105
|
+
return { error: `Account "${accountId}" not found. Run "auth list" to see available accounts.` };
|
|
106
|
+
}
|
|
107
|
+
return { success: true };
|
|
108
|
+
}
|
|
109
|
+
catch (error) {
|
|
110
|
+
return { error: error.message };
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
function cliOutput(result, pretty, exitOnError = true) {
|
|
114
|
+
console.log(formatOutput(result, pretty));
|
|
115
|
+
if (result.error && exitOnError)
|
|
116
|
+
process.exit(1);
|
|
117
|
+
}
|
|
118
|
+
export const authCommand = new Command('auth')
|
|
119
|
+
.description('Authentication commands')
|
|
120
|
+
.addCommand(new Command('set')
|
|
121
|
+
.description('Set account credentials')
|
|
122
|
+
.argument('<app-id>', 'WeChat Official Account App ID')
|
|
123
|
+
.argument('<app-secret>', 'WeChat Official Account App Secret')
|
|
124
|
+
.option('--pretty', 'Pretty print JSON output')
|
|
125
|
+
.action(async (appId, appSecret, opts) => {
|
|
126
|
+
cliOutput(await setAction(appId, appSecret, opts), opts.pretty);
|
|
127
|
+
}))
|
|
128
|
+
.addCommand(new Command('status')
|
|
129
|
+
.description('Show authentication status')
|
|
130
|
+
.option('--account <id>', 'Check specific account (default: current)')
|
|
131
|
+
.option('--pretty', 'Pretty print JSON output')
|
|
132
|
+
.action(async (opts) => {
|
|
133
|
+
const result = await statusAction(opts);
|
|
134
|
+
console.log(formatOutput(result, opts.pretty));
|
|
135
|
+
if (!result.valid)
|
|
136
|
+
process.exit(1);
|
|
137
|
+
}))
|
|
138
|
+
.addCommand(new Command('clear')
|
|
139
|
+
.description('Clear all stored credentials')
|
|
140
|
+
.option('--pretty', 'Pretty print JSON output')
|
|
141
|
+
.action(async (opts) => {
|
|
142
|
+
cliOutput(await clearAction(opts), opts.pretty);
|
|
143
|
+
}))
|
|
144
|
+
.addCommand(new Command('list')
|
|
145
|
+
.description('List all stored accounts')
|
|
146
|
+
.option('--pretty', 'Pretty print JSON output')
|
|
147
|
+
.action(async (opts) => {
|
|
148
|
+
cliOutput(await listAction(opts), opts.pretty);
|
|
149
|
+
}))
|
|
150
|
+
.addCommand(new Command('use')
|
|
151
|
+
.description('Switch active account')
|
|
152
|
+
.argument('<account-id>', 'Account ID (App ID)')
|
|
153
|
+
.option('--pretty', 'Pretty print JSON output')
|
|
154
|
+
.action(async (accountId, opts) => {
|
|
155
|
+
cliOutput(await useAction(accountId, opts), opts.pretty);
|
|
156
|
+
}))
|
|
157
|
+
.addCommand(new Command('remove')
|
|
158
|
+
.description('Remove a stored account')
|
|
159
|
+
.argument('<account-id>', 'Account ID (App ID)')
|
|
160
|
+
.option('--pretty', 'Pretty print JSON output')
|
|
161
|
+
.action(async (accountId, opts) => {
|
|
162
|
+
cliOutput(await removeAction(accountId, opts), opts.pretty);
|
|
163
|
+
}));
|
|
164
|
+
//# sourceMappingURL=auth.js.map
|