agent-messenger 1.0.0 → 1.2.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/commands/release.md +1 -1
- package/.claude-plugin/plugin.json +1 -1
- package/.github/workflows/ci.yml +1 -1
- package/.github/workflows/e2e.yml.disabled +69 -0
- package/CONTRIBUTING.md +2 -2
- package/README.md +18 -15
- package/biome.json +34 -2
- package/bun.lock +63 -0
- package/dist/package.json +8 -4
- package/dist/src/cli.d.ts.map +1 -1
- package/dist/src/cli.js +4 -1
- package/dist/src/cli.js.map +1 -1
- package/dist/src/platforms/discord/cli.js +4 -4
- package/dist/src/platforms/discord/cli.js.map +1 -1
- package/dist/src/platforms/discord/client.d.ts +26 -5
- package/dist/src/platforms/discord/client.d.ts.map +1 -1
- package/dist/src/platforms/discord/client.js +115 -17
- package/dist/src/platforms/discord/client.js.map +1 -1
- package/dist/src/platforms/discord/commands/auth.js +16 -16
- package/dist/src/platforms/discord/commands/auth.js.map +1 -1
- package/dist/src/platforms/discord/commands/channel.js +4 -4
- package/dist/src/platforms/discord/commands/channel.js.map +1 -1
- package/dist/src/platforms/discord/commands/dm.d.ts +9 -0
- package/dist/src/platforms/discord/commands/dm.d.ts.map +1 -0
- package/dist/src/platforms/discord/commands/dm.js +68 -0
- package/dist/src/platforms/discord/commands/dm.js.map +1 -0
- package/dist/src/platforms/discord/commands/friend.d.ts +3 -0
- package/dist/src/platforms/discord/commands/friend.d.ts.map +1 -0
- package/dist/src/platforms/discord/commands/friend.js +39 -0
- package/dist/src/platforms/discord/commands/friend.js.map +1 -0
- package/dist/src/platforms/discord/commands/index.d.ts +1 -1
- package/dist/src/platforms/discord/commands/index.d.ts.map +1 -1
- package/dist/src/platforms/discord/commands/index.js +1 -1
- package/dist/src/platforms/discord/commands/index.js.map +1 -1
- package/dist/src/platforms/discord/commands/member.d.ts +3 -0
- package/dist/src/platforms/discord/commands/member.d.ts.map +1 -0
- package/dist/src/platforms/discord/commands/member.js +47 -0
- package/dist/src/platforms/discord/commands/member.js.map +1 -0
- package/dist/src/platforms/discord/commands/mention.d.ts +8 -0
- package/dist/src/platforms/discord/commands/mention.d.ts.map +1 -0
- package/dist/src/platforms/discord/commands/mention.js +47 -0
- package/dist/src/platforms/discord/commands/mention.js.map +1 -0
- package/dist/src/platforms/discord/commands/message.d.ts +13 -0
- package/dist/src/platforms/discord/commands/message.d.ts.map +1 -1
- package/dist/src/platforms/discord/commands/message.js +95 -1
- package/dist/src/platforms/discord/commands/message.js.map +1 -1
- package/dist/src/platforms/discord/commands/note.d.ts +3 -0
- package/dist/src/platforms/discord/commands/note.d.ts.map +1 -0
- package/dist/src/platforms/discord/commands/note.js +56 -0
- package/dist/src/platforms/discord/commands/note.js.map +1 -0
- package/dist/src/platforms/discord/commands/profile.d.ts +3 -0
- package/dist/src/platforms/discord/commands/profile.d.ts.map +1 -0
- package/dist/src/platforms/discord/commands/profile.js +47 -0
- package/dist/src/platforms/discord/commands/profile.js.map +1 -0
- package/dist/src/platforms/discord/commands/server.d.ts +15 -0
- package/dist/src/platforms/discord/commands/server.d.ts.map +1 -0
- package/dist/src/platforms/discord/commands/server.js +102 -0
- package/dist/src/platforms/discord/commands/server.js.map +1 -0
- package/dist/src/platforms/discord/commands/snapshot.js +10 -10
- package/dist/src/platforms/discord/commands/snapshot.js.map +1 -1
- package/dist/src/platforms/discord/commands/thread.d.ts +10 -0
- package/dist/src/platforms/discord/commands/thread.d.ts.map +1 -0
- package/dist/src/platforms/discord/commands/thread.js +67 -0
- package/dist/src/platforms/discord/commands/thread.js.map +1 -0
- package/dist/src/platforms/discord/commands/user.d.ts.map +1 -1
- package/dist/src/platforms/discord/commands/user.js +14 -5
- package/dist/src/platforms/discord/commands/user.js.map +1 -1
- package/dist/src/platforms/discord/credential-manager.d.ts +13 -13
- package/dist/src/platforms/discord/credential-manager.d.ts.map +1 -1
- package/dist/src/platforms/discord/credential-manager.js +28 -22
- package/dist/src/platforms/discord/credential-manager.js.map +1 -1
- package/dist/src/platforms/discord/super-properties.d.ts +4 -0
- package/dist/src/platforms/discord/super-properties.d.ts.map +1 -0
- package/dist/src/platforms/discord/super-properties.js +50 -0
- package/dist/src/platforms/discord/super-properties.js.map +1 -0
- package/dist/src/platforms/discord/token-extractor.d.ts +6 -1
- package/dist/src/platforms/discord/token-extractor.d.ts.map +1 -1
- package/dist/src/platforms/discord/token-extractor.js +27 -2
- package/dist/src/platforms/discord/token-extractor.js.map +1 -1
- package/dist/src/platforms/discord/types.d.ts +389 -22
- package/dist/src/platforms/discord/types.d.ts.map +1 -1
- package/dist/src/platforms/discord/types.js +46 -4
- package/dist/src/platforms/discord/types.js.map +1 -1
- package/dist/src/platforms/slack/cli.d.ts.map +1 -1
- package/dist/src/platforms/slack/cli.js +7 -2
- package/dist/src/platforms/slack/cli.js.map +1 -1
- package/dist/src/platforms/slack/client.d.ts +19 -1
- package/dist/src/platforms/slack/client.d.ts.map +1 -1
- package/dist/src/platforms/slack/client.js +134 -0
- package/dist/src/platforms/slack/client.js.map +1 -1
- package/dist/src/platforms/slack/commands/activity.d.ts +3 -0
- package/dist/src/platforms/slack/commands/activity.d.ts.map +1 -0
- package/dist/src/platforms/slack/commands/activity.js +40 -0
- package/dist/src/platforms/slack/commands/activity.js.map +1 -0
- package/dist/src/platforms/slack/commands/drafts.d.ts +3 -0
- package/dist/src/platforms/slack/commands/drafts.d.ts.map +1 -0
- package/dist/src/platforms/slack/commands/drafts.js +45 -0
- package/dist/src/platforms/slack/commands/drafts.js.map +1 -0
- package/dist/src/platforms/slack/commands/index.d.ts +5 -0
- package/dist/src/platforms/slack/commands/index.d.ts.map +1 -1
- package/dist/src/platforms/slack/commands/index.js +5 -0
- package/dist/src/platforms/slack/commands/index.js.map +1 -1
- package/dist/src/platforms/slack/commands/saved.d.ts +3 -0
- package/dist/src/platforms/slack/commands/saved.d.ts.map +1 -0
- package/dist/src/platforms/slack/commands/saved.js +54 -0
- package/dist/src/platforms/slack/commands/saved.js.map +1 -0
- package/dist/src/platforms/slack/commands/sections.d.ts +3 -0
- package/dist/src/platforms/slack/commands/sections.d.ts.map +1 -0
- package/dist/src/platforms/slack/commands/sections.js +37 -0
- package/dist/src/platforms/slack/commands/sections.js.map +1 -0
- package/dist/src/platforms/slack/commands/unread.d.ts +12 -0
- package/dist/src/platforms/slack/commands/unread.d.ts.map +1 -0
- package/dist/src/platforms/slack/commands/unread.js +89 -0
- package/dist/src/platforms/slack/commands/unread.js.map +1 -0
- package/dist/src/platforms/slack/credential-manager.d.ts.map +1 -1
- package/dist/src/platforms/slack/credential-manager.js +20 -6
- package/dist/src/platforms/slack/credential-manager.js.map +1 -1
- package/dist/src/platforms/slack/token-extractor.d.ts +8 -1
- package/dist/src/platforms/slack/token-extractor.d.ts.map +1 -1
- package/dist/src/platforms/slack/token-extractor.js +83 -11
- package/dist/src/platforms/slack/token-extractor.js.map +1 -1
- package/dist/src/platforms/slack/types.d.ts +52 -0
- package/dist/src/platforms/slack/types.d.ts.map +1 -1
- package/dist/src/platforms/slack/types.js.map +1 -1
- package/dist/src/platforms/teams/cli.d.ts.map +1 -0
- package/dist/{cli.js → src/platforms/teams/cli.js} +11 -10
- package/dist/src/platforms/teams/cli.js.map +1 -0
- package/dist/src/platforms/teams/client.d.ts +32 -0
- package/dist/src/platforms/teams/client.d.ts.map +1 -0
- package/dist/src/platforms/teams/client.js +202 -0
- package/dist/src/platforms/teams/client.js.map +1 -0
- package/dist/src/platforms/teams/commands/auth.d.ts +14 -0
- package/dist/src/platforms/teams/commands/auth.d.ts.map +1 -0
- package/dist/src/platforms/teams/commands/auth.js +176 -0
- package/dist/src/platforms/teams/commands/auth.js.map +1 -0
- package/dist/src/platforms/teams/commands/channel.d.ts +13 -0
- package/dist/src/platforms/teams/commands/channel.d.ts.map +1 -0
- package/dist/src/platforms/teams/commands/channel.js +97 -0
- package/dist/src/platforms/teams/commands/channel.js.map +1 -0
- package/dist/src/platforms/teams/commands/file.d.ts +12 -0
- package/dist/src/platforms/teams/commands/file.d.ts.map +1 -0
- package/dist/src/platforms/teams/commands/file.js +104 -0
- package/dist/src/platforms/teams/commands/file.js.map +1 -0
- package/dist/{commands → src/platforms/teams/commands}/index.d.ts +5 -2
- package/dist/src/platforms/teams/commands/index.d.ts.map +1 -0
- package/dist/{commands → src/platforms/teams/commands}/index.js +5 -2
- package/dist/src/platforms/teams/commands/index.js.map +1 -0
- package/dist/src/platforms/teams/commands/message.d.ts +17 -0
- package/dist/src/platforms/teams/commands/message.d.ts.map +1 -0
- package/dist/src/platforms/teams/commands/message.js +133 -0
- package/dist/src/platforms/teams/commands/message.js.map +1 -0
- package/dist/src/platforms/teams/commands/reaction.d.ts +9 -0
- package/dist/src/platforms/teams/commands/reaction.d.ts.map +1 -0
- package/dist/src/platforms/teams/commands/reaction.js +68 -0
- package/dist/src/platforms/teams/commands/reaction.js.map +1 -0
- package/dist/src/platforms/teams/commands/snapshot.d.ts +10 -0
- package/dist/src/platforms/teams/commands/snapshot.d.ts.map +1 -0
- package/dist/src/platforms/teams/commands/snapshot.js +85 -0
- package/dist/src/platforms/teams/commands/snapshot.js.map +1 -0
- package/dist/src/platforms/teams/commands/team.d.ts +18 -0
- package/dist/src/platforms/teams/commands/team.d.ts.map +1 -0
- package/dist/src/platforms/teams/commands/team.js +130 -0
- package/dist/src/platforms/teams/commands/team.js.map +1 -0
- package/dist/src/platforms/teams/commands/user.d.ts.map +1 -0
- package/dist/src/platforms/teams/commands/user.js +88 -0
- package/dist/src/platforms/teams/commands/user.js.map +1 -0
- package/dist/src/platforms/teams/credential-manager.d.ts +18 -0
- package/dist/src/platforms/teams/credential-manager.d.ts.map +1 -0
- package/dist/src/platforms/teams/credential-manager.js +81 -0
- package/dist/src/platforms/teams/credential-manager.js.map +1 -0
- package/dist/src/platforms/teams/index.d.ts +4 -0
- package/dist/src/platforms/teams/index.d.ts.map +1 -0
- package/dist/src/platforms/teams/index.js +6 -0
- package/dist/src/platforms/teams/index.js.map +1 -0
- package/dist/src/platforms/teams/token-extractor.d.ts +41 -0
- package/dist/src/platforms/teams/token-extractor.d.ts.map +1 -0
- package/dist/src/platforms/teams/token-extractor.js +360 -0
- package/dist/src/platforms/teams/token-extractor.js.map +1 -0
- package/dist/src/platforms/teams/types.d.ts +209 -0
- package/dist/src/platforms/teams/types.d.ts.map +1 -0
- package/dist/src/platforms/teams/types.js +65 -0
- package/dist/src/platforms/teams/types.js.map +1 -0
- package/dist/src/shared/utils/derived-key-cache.d.ts +20 -0
- package/dist/src/shared/utils/derived-key-cache.d.ts.map +1 -0
- package/dist/src/shared/utils/derived-key-cache.js +52 -0
- package/dist/src/shared/utils/derived-key-cache.js.map +1 -0
- package/docs/README.md +113 -0
- package/docs/biome.json +8 -0
- package/docs/bun.lock +1426 -0
- package/docs/content/docs/agent-skills.mdx +98 -0
- package/docs/content/docs/index.mdx +124 -0
- package/docs/{discord.md → content/docs/integrations/discord.mdx} +46 -21
- package/docs/content/docs/integrations/meta.json +5 -0
- package/docs/{slack.md → content/docs/integrations/slack.mdx} +5 -4
- package/docs/content/docs/integrations/teams.mdx +322 -0
- package/docs/content/docs/meta.json +8 -0
- package/docs/content/docs/quick-start.mdx +103 -0
- package/docs/eslint.config.mjs +30 -0
- package/docs/next.config.ts +10 -0
- package/docs/package.json +42 -0
- package/docs/postcss.config.mjs +7 -0
- package/docs/public/file.svg +1 -0
- package/docs/public/globe.svg +1 -0
- package/docs/public/next.svg +1 -0
- package/docs/public/vercel.svg +1 -0
- package/docs/public/window.svg +1 -0
- package/docs/source.config.ts +11 -0
- package/docs/src/app/api/search/route.ts +4 -0
- package/docs/src/app/docs/[[...slug]]/page.tsx +53 -0
- package/docs/src/app/docs/layout.tsx +21 -0
- package/docs/src/app/globals.css +10 -0
- package/docs/src/app/icon.png +0 -0
- package/docs/src/app/layout.config.tsx +7 -0
- package/docs/src/app/layout.tsx +35 -0
- package/docs/src/app/page.tsx +489 -0
- package/docs/src/lib/source.ts +15 -0
- package/docs/src/mdx-components.tsx +18 -0
- package/docs/tsconfig.json +36 -0
- package/e2e/README.md +256 -0
- package/e2e/config.ts +51 -0
- package/e2e/discord.e2e.test.ts +252 -0
- package/e2e/helpers.ts +107 -0
- package/e2e/slack.e2e.test.ts +309 -0
- package/package.json +8 -4
- package/scripts/postbuild.ts +15 -0
- package/skills/agent-discord/SKILL.md +96 -30
- package/skills/agent-discord/references/authentication.md +27 -27
- package/skills/agent-discord/references/common-patterns.md +15 -15
- package/skills/agent-discord/templates/post-message.sh +6 -6
- package/skills/agent-discord/templates/{guild-summary.sh → server-summary.sh} +20 -20
- package/skills/agent-slack/SKILL.md +53 -0
- package/skills/agent-teams/SKILL.md +292 -0
- package/skills/agent-teams/references/authentication.md +375 -0
- package/skills/agent-teams/references/common-patterns.md +596 -0
- package/skills/agent-teams/templates/monitor-channel.sh +239 -0
- package/skills/agent-teams/templates/post-message.sh +224 -0
- package/skills/agent-teams/templates/team-summary.sh +210 -0
- package/src/cli.ts +4 -0
- package/src/platforms/discord/cli.ts +3 -3
- package/src/platforms/discord/client.test.ts +15 -15
- package/src/platforms/discord/client.ts +163 -17
- package/src/platforms/discord/commands/auth.test.ts +53 -37
- package/src/platforms/discord/commands/auth.ts +16 -16
- package/src/platforms/discord/commands/channel.test.ts +58 -46
- package/src/platforms/discord/commands/channel.ts +4 -4
- package/src/platforms/discord/commands/dm.test.ts +146 -0
- package/src/platforms/discord/commands/dm.ts +85 -0
- package/src/platforms/discord/commands/file.test.ts +40 -53
- package/src/platforms/discord/commands/friend.test.ts +134 -0
- package/src/platforms/discord/commands/friend.ts +45 -0
- package/src/platforms/discord/commands/index.ts +1 -1
- package/src/platforms/discord/commands/member.test.ts +98 -0
- package/src/platforms/discord/commands/member.ts +59 -0
- package/src/platforms/discord/commands/mention.test.ts +129 -0
- package/src/platforms/discord/commands/mention.ts +59 -0
- package/src/platforms/discord/commands/message.test.ts +139 -44
- package/src/platforms/discord/commands/message.ts +134 -1
- package/src/platforms/discord/commands/note.test.ts +84 -0
- package/src/platforms/discord/commands/note.ts +73 -0
- package/src/platforms/discord/commands/profile.test.ts +107 -0
- package/src/platforms/discord/commands/profile.ts +55 -0
- package/src/platforms/discord/commands/reaction.test.ts +54 -42
- package/src/platforms/discord/commands/server.test.ts +137 -0
- package/src/platforms/discord/commands/{guild.ts → server.ts} +31 -31
- package/src/platforms/discord/commands/snapshot.test.ts +1 -1
- package/src/platforms/discord/commands/snapshot.ts +10 -10
- package/src/platforms/discord/commands/thread.test.ts +121 -0
- package/src/platforms/discord/commands/thread.ts +92 -0
- package/src/platforms/discord/commands/user.test.ts +8 -8
- package/src/platforms/discord/commands/user.ts +16 -5
- package/src/platforms/discord/credential-manager.test.ts +137 -136
- package/src/platforms/discord/credential-manager.ts +35 -26
- package/src/platforms/discord/super-properties.ts +55 -0
- package/src/platforms/discord/token-extractor.test.ts +133 -383
- package/src/platforms/discord/token-extractor.ts +37 -3
- package/src/platforms/discord/types.test.ts +8 -8
- package/src/platforms/discord/types.ts +144 -8
- package/{tests → src/platforms/slack}/cli.test.ts +3 -3
- package/src/platforms/slack/cli.ts +10 -0
- package/{tests/slack-client.test.ts → src/platforms/slack/client.test.ts} +1 -1
- package/src/platforms/slack/client.ts +172 -1
- package/src/platforms/slack/commands/activity.test.ts +147 -0
- package/src/platforms/slack/commands/activity.ts +65 -0
- package/{tests → src/platforms/slack}/commands/auth.test.ts +25 -13
- package/{tests → src/platforms/slack}/commands/channel.test.ts +2 -2
- package/src/platforms/slack/commands/drafts.test.ts +136 -0
- package/src/platforms/slack/commands/drafts.ts +62 -0
- package/{tests → src/platforms/slack}/commands/file.test.ts +2 -2
- package/src/platforms/slack/commands/index.ts +5 -0
- package/{tests → src/platforms/slack}/commands/message.test.ts +2 -2
- package/{tests → src/platforms/slack}/commands/reaction.test.ts +1 -1
- package/src/platforms/slack/commands/saved.test.ts +140 -0
- package/src/platforms/slack/commands/saved.ts +71 -0
- package/src/platforms/slack/commands/sections.test.ts +80 -0
- package/src/platforms/slack/commands/sections.ts +50 -0
- package/{tests → src/platforms/slack}/commands/snapshot.test.ts +117 -105
- package/src/platforms/slack/commands/unread.test.ts +139 -0
- package/src/platforms/slack/commands/unread.ts +129 -0
- package/{tests → src/platforms/slack}/commands/user.test.ts +3 -3
- package/{tests → src/platforms/slack}/commands/workspace.test.ts +44 -95
- package/{tests → src/platforms/slack}/credential-manager.test.ts +2 -2
- package/src/platforms/slack/credential-manager.ts +22 -7
- package/src/platforms/slack/token-extractor-node-test.ts +40 -0
- package/src/platforms/slack/token-extractor-node.test.ts +10 -0
- package/src/platforms/slack/token-extractor.ts +93 -12
- package/{tests → src/platforms/slack}/types.test.ts +1 -1
- package/src/platforms/slack/types.ts +58 -0
- package/src/platforms/teams/cli.ts +36 -0
- package/src/platforms/teams/client.test.ts +500 -0
- package/src/platforms/teams/client.ts +365 -0
- package/src/platforms/teams/commands/auth.test.ts +99 -0
- package/src/platforms/teams/commands/auth.ts +232 -0
- package/src/platforms/teams/commands/channel.test.ts +147 -0
- package/src/platforms/teams/commands/channel.ts +129 -0
- package/src/platforms/teams/commands/file.test.ts +88 -0
- package/src/platforms/teams/commands/file.ts +144 -0
- package/src/platforms/teams/commands/index.ts +12 -0
- package/src/platforms/teams/commands/message.test.ts +110 -0
- package/src/platforms/teams/commands/message.ts +188 -0
- package/src/platforms/teams/commands/reaction.test.ts +87 -0
- package/src/platforms/teams/commands/reaction.ts +104 -0
- package/src/platforms/teams/commands/snapshot.test.ts +35 -0
- package/src/platforms/teams/commands/snapshot.ts +115 -0
- package/src/platforms/teams/commands/team.test.ts +157 -0
- package/src/platforms/teams/commands/team.ts +164 -0
- package/src/platforms/teams/commands/user.test.ts +83 -0
- package/src/platforms/teams/commands/user.ts +112 -0
- package/src/platforms/teams/credential-manager.test.ts +178 -0
- package/src/platforms/teams/credential-manager.ts +92 -0
- package/src/platforms/teams/index.ts +5 -0
- package/src/platforms/teams/token-extractor.test.ts +429 -0
- package/src/platforms/teams/token-extractor.ts +490 -0
- package/src/platforms/teams/types.test.ts +226 -0
- package/src/platforms/teams/types.ts +140 -0
- package/src/shared/utils/derived-key-cache.test.ts +136 -0
- package/src/shared/utils/derived-key-cache.ts +63 -0
- package/tsconfig.json +1 -1
- package/dist/cli.d.ts.map +0 -1
- package/dist/cli.js.map +0 -1
- package/dist/commands/auth.d.ts +0 -3
- package/dist/commands/auth.d.ts.map +0 -1
- package/dist/commands/auth.js +0 -140
- package/dist/commands/auth.js.map +0 -1
- package/dist/commands/channel.d.ts +0 -3
- package/dist/commands/channel.d.ts.map +0 -1
- package/dist/commands/channel.js +0 -118
- package/dist/commands/channel.js.map +0 -1
- package/dist/commands/file.d.ts +0 -3
- package/dist/commands/file.d.ts.map +0 -1
- package/dist/commands/file.js +0 -113
- package/dist/commands/file.js.map +0 -1
- package/dist/commands/index.d.ts.map +0 -1
- package/dist/commands/index.js.map +0 -1
- package/dist/commands/message.d.ts +0 -3
- package/dist/commands/message.d.ts.map +0 -1
- package/dist/commands/message.js +0 -214
- package/dist/commands/message.js.map +0 -1
- package/dist/commands/reaction.d.ts +0 -3
- package/dist/commands/reaction.d.ts.map +0 -1
- package/dist/commands/reaction.js +0 -100
- package/dist/commands/reaction.js.map +0 -1
- package/dist/commands/snapshot.d.ts +0 -3
- package/dist/commands/snapshot.d.ts.map +0 -1
- package/dist/commands/snapshot.js +0 -88
- package/dist/commands/snapshot.js.map +0 -1
- package/dist/commands/user.d.ts.map +0 -1
- package/dist/commands/user.js +0 -96
- package/dist/commands/user.js.map +0 -1
- package/dist/commands/workspace.d.ts +0 -3
- package/dist/commands/workspace.d.ts.map +0 -1
- package/dist/commands/workspace.js +0 -89
- package/dist/commands/workspace.js.map +0 -1
- package/dist/lib/credential-manager.d.ts +0 -13
- package/dist/lib/credential-manager.d.ts.map +0 -1
- package/dist/lib/credential-manager.js +0 -58
- package/dist/lib/credential-manager.js.map +0 -1
- package/dist/lib/index.d.ts +0 -3
- package/dist/lib/index.d.ts.map +0 -1
- package/dist/lib/index.js +0 -3
- package/dist/lib/index.js.map +0 -1
- package/dist/lib/ref-manager.d.ts +0 -26
- package/dist/lib/ref-manager.d.ts.map +0 -1
- package/dist/lib/ref-manager.js +0 -92
- package/dist/lib/ref-manager.js.map +0 -1
- package/dist/lib/slack-client.d.ts +0 -37
- package/dist/lib/slack-client.d.ts.map +0 -1
- package/dist/lib/slack-client.js +0 -379
- package/dist/lib/slack-client.js.map +0 -1
- package/dist/lib/token-extractor.d.ts +0 -28
- package/dist/lib/token-extractor.d.ts.map +0 -1
- package/dist/lib/token-extractor.js +0 -401
- package/dist/lib/token-extractor.js.map +0 -1
- package/dist/src/platforms/discord/client.test.d.ts +0 -2
- package/dist/src/platforms/discord/client.test.d.ts.map +0 -1
- package/dist/src/platforms/discord/client.test.js +0 -367
- package/dist/src/platforms/discord/client.test.js.map +0 -1
- package/dist/src/platforms/discord/commands/auth.test.d.ts +0 -2
- package/dist/src/platforms/discord/commands/auth.test.d.ts.map +0 -1
- package/dist/src/platforms/discord/commands/auth.test.js +0 -65
- package/dist/src/platforms/discord/commands/auth.test.js.map +0 -1
- package/dist/src/platforms/discord/commands/channel.test.d.ts +0 -2
- package/dist/src/platforms/discord/commands/channel.test.d.ts.map +0 -1
- package/dist/src/platforms/discord/commands/channel.test.js +0 -136
- package/dist/src/platforms/discord/commands/channel.test.js.map +0 -1
- package/dist/src/platforms/discord/commands/file.test.d.ts +0 -2
- package/dist/src/platforms/discord/commands/file.test.d.ts.map +0 -1
- package/dist/src/platforms/discord/commands/file.test.js +0 -83
- package/dist/src/platforms/discord/commands/file.test.js.map +0 -1
- package/dist/src/platforms/discord/commands/guild.test.d.ts +0 -2
- package/dist/src/platforms/discord/commands/guild.test.d.ts.map +0 -1
- package/dist/src/platforms/discord/commands/guild.test.js +0 -100
- package/dist/src/platforms/discord/commands/guild.test.js.map +0 -1
- package/dist/src/platforms/discord/commands/message.test.d.ts +0 -2
- package/dist/src/platforms/discord/commands/message.test.d.ts.map +0 -1
- package/dist/src/platforms/discord/commands/message.test.js +0 -91
- package/dist/src/platforms/discord/commands/message.test.js.map +0 -1
- package/dist/src/platforms/discord/commands/reaction.test.d.ts +0 -2
- package/dist/src/platforms/discord/commands/reaction.test.d.ts.map +0 -1
- package/dist/src/platforms/discord/commands/reaction.test.js +0 -115
- package/dist/src/platforms/discord/commands/reaction.test.js.map +0 -1
- package/dist/src/platforms/discord/commands/snapshot.test.d.ts +0 -2
- package/dist/src/platforms/discord/commands/snapshot.test.d.ts.map +0 -1
- package/dist/src/platforms/discord/commands/snapshot.test.js +0 -25
- package/dist/src/platforms/discord/commands/snapshot.test.js.map +0 -1
- package/dist/src/platforms/discord/commands/user.test.d.ts +0 -2
- package/dist/src/platforms/discord/commands/user.test.d.ts.map +0 -1
- package/dist/src/platforms/discord/commands/user.test.js +0 -103
- package/dist/src/platforms/discord/commands/user.test.js.map +0 -1
- package/dist/src/platforms/discord/credential-manager.test.d.ts +0 -2
- package/dist/src/platforms/discord/credential-manager.test.d.ts.map +0 -1
- package/dist/src/platforms/discord/credential-manager.test.js +0 -136
- package/dist/src/platforms/discord/credential-manager.test.js.map +0 -1
- package/dist/src/platforms/discord/token-extractor.test.d.ts +0 -2
- package/dist/src/platforms/discord/token-extractor.test.d.ts.map +0 -1
- package/dist/src/platforms/discord/token-extractor.test.js +0 -789
- package/dist/src/platforms/discord/token-extractor.test.js.map +0 -1
- package/dist/src/platforms/discord/types.test.d.ts +0 -2
- package/dist/src/platforms/discord/types.test.d.ts.map +0 -1
- package/dist/src/platforms/discord/types.test.js +0 -211
- package/dist/src/platforms/discord/types.test.js.map +0 -1
- package/dist/src/shared/utils/concurrency.test.d.ts +0 -2
- package/dist/src/shared/utils/concurrency.test.d.ts.map +0 -1
- package/dist/src/shared/utils/concurrency.test.js +0 -39
- package/dist/src/shared/utils/concurrency.test.js.map +0 -1
- package/dist/tests/cli.test.d.ts +0 -2
- package/dist/tests/cli.test.d.ts.map +0 -1
- package/dist/tests/cli.test.js +0 -83
- package/dist/tests/cli.test.js.map +0 -1
- package/dist/tests/commands/.test-slack-data/Local Storage/leveldb/CURRENT +0 -1
- package/dist/tests/commands/.test-slack-data/Local Storage/leveldb/LOCK +0 -0
- package/dist/tests/commands/.test-slack-data/Local Storage/leveldb/LOG +0 -3
- package/dist/tests/commands/.test-slack-data/Local Storage/leveldb/LOG.old +0 -1
- package/dist/tests/commands/.test-slack-data/Local Storage/leveldb/MANIFEST-000004 +0 -0
- package/dist/tests/commands/auth.test.d.ts +0 -2
- package/dist/tests/commands/auth.test.d.ts.map +0 -1
- package/dist/tests/commands/auth.test.js +0 -304
- package/dist/tests/commands/auth.test.js.map +0 -1
- package/dist/tests/commands/channel.test.d.ts +0 -2
- package/dist/tests/commands/channel.test.d.ts.map +0 -1
- package/dist/tests/commands/channel.test.js +0 -166
- package/dist/tests/commands/channel.test.js.map +0 -1
- package/dist/tests/commands/file.test.d.ts +0 -2
- package/dist/tests/commands/file.test.d.ts.map +0 -1
- package/dist/tests/commands/file.test.js +0 -175
- package/dist/tests/commands/file.test.js.map +0 -1
- package/dist/tests/commands/message.test.d.ts +0 -2
- package/dist/tests/commands/message.test.d.ts.map +0 -1
- package/dist/tests/commands/message.test.js +0 -293
- package/dist/tests/commands/message.test.js.map +0 -1
- package/dist/tests/commands/reaction.test.d.ts +0 -2
- package/dist/tests/commands/reaction.test.d.ts.map +0 -1
- package/dist/tests/commands/reaction.test.js +0 -84
- package/dist/tests/commands/reaction.test.js.map +0 -1
- package/dist/tests/commands/snapshot.test.d.ts +0 -2
- package/dist/tests/commands/snapshot.test.d.ts.map +0 -1
- package/dist/tests/commands/snapshot.test.js +0 -280
- package/dist/tests/commands/snapshot.test.js.map +0 -1
- package/dist/tests/commands/user.test.d.ts +0 -2
- package/dist/tests/commands/user.test.d.ts.map +0 -1
- package/dist/tests/commands/user.test.js +0 -117
- package/dist/tests/commands/user.test.js.map +0 -1
- package/dist/tests/commands/workspace.test.d.ts +0 -2
- package/dist/tests/commands/workspace.test.d.ts.map +0 -1
- package/dist/tests/commands/workspace.test.js +0 -453
- package/dist/tests/commands/workspace.test.js.map +0 -1
- package/dist/tests/credential-manager.test.d.ts +0 -2
- package/dist/tests/credential-manager.test.d.ts.map +0 -1
- package/dist/tests/credential-manager.test.js +0 -199
- package/dist/tests/credential-manager.test.js.map +0 -1
- package/dist/tests/slack-client.test.d.ts +0 -2
- package/dist/tests/slack-client.test.d.ts.map +0 -1
- package/dist/tests/slack-client.test.js +0 -741
- package/dist/tests/slack-client.test.js.map +0 -1
- package/dist/tests/types.test.d.ts +0 -2
- package/dist/tests/types.test.d.ts.map +0 -1
- package/dist/tests/types.test.js +0 -215
- package/dist/tests/types.test.js.map +0 -1
- package/dist/types/index.d.ts +0 -369
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/index.js +0 -92
- package/dist/types/index.js.map +0 -1
- package/dist/utils/error-handler.d.ts +0 -2
- package/dist/utils/error-handler.d.ts.map +0 -1
- package/dist/utils/error-handler.js +0 -5
- package/dist/utils/error-handler.js.map +0 -1
- package/dist/utils/output.d.ts +0 -2
- package/dist/utils/output.d.ts.map +0 -1
- package/dist/utils/output.js +0 -4
- package/dist/utils/output.js.map +0 -1
- package/src/platforms/discord/commands/guild.test.ts +0 -117
- /package/dist/{cli.d.ts → src/platforms/teams/cli.d.ts} +0 -0
- /package/dist/{commands → src/platforms/teams/commands}/user.d.ts +0 -0
|
@@ -6,9 +6,9 @@ import {
|
|
|
6
6
|
authCommand,
|
|
7
7
|
channelCommand,
|
|
8
8
|
fileCommand,
|
|
9
|
-
guildCommand,
|
|
10
9
|
messageCommand,
|
|
11
10
|
reactionCommand,
|
|
11
|
+
serverCommand,
|
|
12
12
|
snapshotCommand,
|
|
13
13
|
userCommand,
|
|
14
14
|
} from './commands'
|
|
@@ -20,10 +20,10 @@ program
|
|
|
20
20
|
.description('CLI tool for Discord communication')
|
|
21
21
|
.version(pkg.version)
|
|
22
22
|
.option('--pretty', 'Pretty-print JSON output')
|
|
23
|
-
.option('--
|
|
23
|
+
.option('--server <id>', 'Use specific server')
|
|
24
24
|
|
|
25
25
|
program.addCommand(authCommand)
|
|
26
|
-
program.addCommand(
|
|
26
|
+
program.addCommand(serverCommand)
|
|
27
27
|
program.addCommand(channelCommand)
|
|
28
28
|
program.addCommand(fileCommand)
|
|
29
29
|
program.addCommand(messageCommand)
|
|
@@ -90,37 +90,37 @@ describe('DiscordClient', () => {
|
|
|
90
90
|
})
|
|
91
91
|
})
|
|
92
92
|
|
|
93
|
-
describe('
|
|
94
|
-
test('returns list of
|
|
93
|
+
describe('listServers', () => {
|
|
94
|
+
test('returns list of servers', async () => {
|
|
95
95
|
mockResponse([
|
|
96
|
-
{ id: '111', name: '
|
|
97
|
-
{ id: '222', name: '
|
|
96
|
+
{ id: '111', name: 'Server One' },
|
|
97
|
+
{ id: '222', name: 'Server Two' },
|
|
98
98
|
])
|
|
99
99
|
|
|
100
100
|
const client = new DiscordClient('test-token')
|
|
101
|
-
const
|
|
101
|
+
const servers = await client.listServers()
|
|
102
102
|
|
|
103
|
-
expect(
|
|
104
|
-
expect(
|
|
103
|
+
expect(servers).toHaveLength(2)
|
|
104
|
+
expect(servers[0].name).toBe('Server One')
|
|
105
105
|
expect(fetchCalls[0].url).toBe('https://discord.com/api/v10/users/@me/guilds')
|
|
106
106
|
})
|
|
107
107
|
})
|
|
108
108
|
|
|
109
|
-
describe('
|
|
110
|
-
test('returns
|
|
111
|
-
mockResponse({ id: '111', name: 'Test
|
|
109
|
+
describe('getServer', () => {
|
|
110
|
+
test('returns server info', async () => {
|
|
111
|
+
mockResponse({ id: '111', name: 'Test Server' })
|
|
112
112
|
|
|
113
113
|
const client = new DiscordClient('test-token')
|
|
114
|
-
const
|
|
114
|
+
const server = await client.getServer('111')
|
|
115
115
|
|
|
116
|
-
expect(
|
|
117
|
-
expect(
|
|
116
|
+
expect(server.id).toBe('111')
|
|
117
|
+
expect(server.name).toBe('Test Server')
|
|
118
118
|
expect(fetchCalls[0].url).toBe('https://discord.com/api/v10/guilds/111')
|
|
119
119
|
})
|
|
120
120
|
})
|
|
121
121
|
|
|
122
122
|
describe('listChannels', () => {
|
|
123
|
-
test('returns list of channels for
|
|
123
|
+
test('returns list of channels for server', async () => {
|
|
124
124
|
mockResponse([
|
|
125
125
|
{ id: 'ch1', guild_id: '111', name: 'general', type: 0 },
|
|
126
126
|
{ id: 'ch2', guild_id: '111', name: 'random', type: 0 },
|
|
@@ -257,7 +257,7 @@ describe('DiscordClient', () => {
|
|
|
257
257
|
})
|
|
258
258
|
|
|
259
259
|
describe('listUsers', () => {
|
|
260
|
-
test('returns list of
|
|
260
|
+
test('returns list of server members', async () => {
|
|
261
261
|
mockResponse([
|
|
262
262
|
{ user: { id: 'u1', username: 'user1' } },
|
|
263
263
|
{ user: { id: 'u2', username: 'user2' } },
|
|
@@ -1,9 +1,20 @@
|
|
|
1
|
+
import { readFile } from 'node:fs/promises'
|
|
2
|
+
import { getDiscordHeaders } from './super-properties'
|
|
1
3
|
import type {
|
|
2
4
|
DiscordChannel,
|
|
5
|
+
DiscordDMChannel,
|
|
3
6
|
DiscordFile,
|
|
4
7
|
DiscordGuild,
|
|
8
|
+
DiscordGuildMember,
|
|
9
|
+
DiscordMention,
|
|
5
10
|
DiscordMessage,
|
|
11
|
+
DiscordRelationship,
|
|
12
|
+
DiscordSearchOptions,
|
|
13
|
+
DiscordSearchResponse,
|
|
14
|
+
DiscordSearchResult,
|
|
6
15
|
DiscordUser,
|
|
16
|
+
DiscordUserNote,
|
|
17
|
+
DiscordUserProfile,
|
|
7
18
|
} from './types'
|
|
8
19
|
|
|
9
20
|
export class DiscordError extends Error {
|
|
@@ -99,10 +110,7 @@ export class DiscordClient {
|
|
|
99
110
|
for (let attempt = 0; attempt <= MAX_RETRIES; attempt++) {
|
|
100
111
|
await this.waitForRateLimit(bucketKey)
|
|
101
112
|
|
|
102
|
-
const headers: Record<string, string> =
|
|
103
|
-
Authorization: this.token,
|
|
104
|
-
'Content-Type': 'application/json',
|
|
105
|
-
}
|
|
113
|
+
const headers: Record<string, string> = getDiscordHeaders(this.token)
|
|
106
114
|
|
|
107
115
|
const options: RequestInit = {
|
|
108
116
|
method,
|
|
@@ -110,6 +118,7 @@ export class DiscordClient {
|
|
|
110
118
|
}
|
|
111
119
|
|
|
112
120
|
if (body !== undefined) {
|
|
121
|
+
headers['Content-Type'] = 'application/json'
|
|
113
122
|
options.body = JSON.stringify(body)
|
|
114
123
|
}
|
|
115
124
|
|
|
@@ -154,11 +163,10 @@ export class DiscordClient {
|
|
|
154
163
|
|
|
155
164
|
await this.waitForRateLimit(bucketKey)
|
|
156
165
|
|
|
166
|
+
const headers = getDiscordHeaders(this.token)
|
|
157
167
|
const response = await fetch(url, {
|
|
158
168
|
method: 'POST',
|
|
159
|
-
headers
|
|
160
|
-
Authorization: this.token,
|
|
161
|
-
},
|
|
169
|
+
headers,
|
|
162
170
|
body: formData,
|
|
163
171
|
})
|
|
164
172
|
|
|
@@ -179,16 +187,16 @@ export class DiscordClient {
|
|
|
179
187
|
return this.request<DiscordUser>('GET', '/users/@me')
|
|
180
188
|
}
|
|
181
189
|
|
|
182
|
-
async
|
|
190
|
+
async listServers(): Promise<DiscordGuild[]> {
|
|
183
191
|
return this.request<DiscordGuild[]>('GET', '/users/@me/guilds')
|
|
184
192
|
}
|
|
185
193
|
|
|
186
|
-
async
|
|
187
|
-
return this.request<DiscordGuild>('GET', `/guilds/${
|
|
194
|
+
async getServer(serverId: string): Promise<DiscordGuild> {
|
|
195
|
+
return this.request<DiscordGuild>('GET', `/guilds/${serverId}`)
|
|
188
196
|
}
|
|
189
197
|
|
|
190
|
-
async listChannels(
|
|
191
|
-
return this.request<DiscordChannel[]>('GET', `/guilds/${
|
|
198
|
+
async listChannels(serverId: string): Promise<DiscordChannel[]> {
|
|
199
|
+
return this.request<DiscordChannel[]>('GET', `/guilds/${serverId}/channels`)
|
|
192
200
|
}
|
|
193
201
|
|
|
194
202
|
async getChannel(channelId: string): Promise<DiscordChannel> {
|
|
@@ -227,13 +235,19 @@ export class DiscordClient {
|
|
|
227
235
|
)
|
|
228
236
|
}
|
|
229
237
|
|
|
230
|
-
async
|
|
238
|
+
async ackMessage(channelId: string, messageId: string): Promise<void> {
|
|
239
|
+
return this.request<void>('POST', `/channels/${channelId}/messages/${messageId}/ack`, {
|
|
240
|
+
token: null,
|
|
241
|
+
})
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
async listUsers(serverId: string): Promise<DiscordUser[]> {
|
|
231
245
|
interface GuildMember {
|
|
232
246
|
user: DiscordUser
|
|
233
247
|
}
|
|
234
248
|
const members = await this.request<GuildMember[]>(
|
|
235
249
|
'GET',
|
|
236
|
-
`/guilds/${
|
|
250
|
+
`/guilds/${serverId}/members?limit=1000`
|
|
237
251
|
)
|
|
238
252
|
return members.map((m) => m.user)
|
|
239
253
|
}
|
|
@@ -243,12 +257,11 @@ export class DiscordClient {
|
|
|
243
257
|
}
|
|
244
258
|
|
|
245
259
|
async uploadFile(channelId: string, filePath: string): Promise<DiscordFile> {
|
|
246
|
-
const
|
|
260
|
+
const fileBuffer = await readFile(filePath)
|
|
247
261
|
const filename = filePath.split('/').pop() || 'file'
|
|
248
|
-
const blob = await file.arrayBuffer()
|
|
249
262
|
|
|
250
263
|
const formData = new FormData()
|
|
251
|
-
formData.append('files[0]', new Blob([
|
|
264
|
+
formData.append('files[0]', new Blob([fileBuffer]), filename)
|
|
252
265
|
|
|
253
266
|
interface MessageWithAttachments extends DiscordMessage {
|
|
254
267
|
attachments: DiscordFile[]
|
|
@@ -278,4 +291,137 @@ export class DiscordClient {
|
|
|
278
291
|
}
|
|
279
292
|
return files
|
|
280
293
|
}
|
|
294
|
+
|
|
295
|
+
async listDMChannels(): Promise<DiscordDMChannel[]> {
|
|
296
|
+
return this.request<DiscordDMChannel[]>('GET', '/users/@me/channels')
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
async createDM(userId: string): Promise<DiscordDMChannel> {
|
|
300
|
+
return this.request<DiscordDMChannel>('POST', '/users/@me/channels', {
|
|
301
|
+
recipient_id: userId,
|
|
302
|
+
})
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
async getMentions(options?: { limit?: number; guildId?: string }): Promise<DiscordMention[]> {
|
|
306
|
+
const params = new URLSearchParams()
|
|
307
|
+
params.set('limit', (options?.limit ?? 25).toString())
|
|
308
|
+
params.set('roles', 'true')
|
|
309
|
+
params.set('everyone', 'true')
|
|
310
|
+
|
|
311
|
+
if (options?.guildId) {
|
|
312
|
+
params.set('guild_id', options.guildId)
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
return this.request<DiscordMention[]>('GET', `/users/@me/mentions?${params.toString()}`)
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
async getUserNote(userId: string): Promise<DiscordUserNote | null> {
|
|
319
|
+
try {
|
|
320
|
+
return await this.request<DiscordUserNote>('GET', `/users/@me/notes/${userId}`)
|
|
321
|
+
} catch (error) {
|
|
322
|
+
if (error instanceof DiscordError && error.code === 'http_404') {
|
|
323
|
+
return null
|
|
324
|
+
}
|
|
325
|
+
throw error
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
async setUserNote(userId: string, note: string): Promise<DiscordUserNote> {
|
|
330
|
+
return this.request<DiscordUserNote>('PUT', `/users/@me/notes/${userId}`, { note })
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
async getRelationships(): Promise<DiscordRelationship[]> {
|
|
334
|
+
return this.request<DiscordRelationship[]>('GET', '/users/@me/relationships')
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
async searchMembers(
|
|
338
|
+
guildId: string,
|
|
339
|
+
query: string,
|
|
340
|
+
limit: number = 10
|
|
341
|
+
): Promise<DiscordGuildMember[]> {
|
|
342
|
+
const params = new URLSearchParams()
|
|
343
|
+
params.set('query', query)
|
|
344
|
+
params.set('limit', limit.toString())
|
|
345
|
+
|
|
346
|
+
return this.request<DiscordGuildMember[]>(
|
|
347
|
+
'GET',
|
|
348
|
+
`/guilds/${guildId}/members/search?${params.toString()}`
|
|
349
|
+
)
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
async searchMessages(
|
|
353
|
+
guildId: string,
|
|
354
|
+
query: string,
|
|
355
|
+
options: DiscordSearchOptions = {}
|
|
356
|
+
): Promise<{ results: DiscordSearchResult[]; total: number }> {
|
|
357
|
+
const params = new URLSearchParams()
|
|
358
|
+
params.set('content', query)
|
|
359
|
+
|
|
360
|
+
if (options.channelId) {
|
|
361
|
+
params.set('channel_id', options.channelId)
|
|
362
|
+
}
|
|
363
|
+
if (options.authorId) {
|
|
364
|
+
params.set('author_id', options.authorId)
|
|
365
|
+
}
|
|
366
|
+
if (options.has) {
|
|
367
|
+
params.set('has', options.has)
|
|
368
|
+
}
|
|
369
|
+
if (options.sortBy) {
|
|
370
|
+
params.set('sort_by', options.sortBy)
|
|
371
|
+
}
|
|
372
|
+
if (options.sortOrder) {
|
|
373
|
+
params.set('sort_order', options.sortOrder)
|
|
374
|
+
}
|
|
375
|
+
if (options.limit !== undefined) {
|
|
376
|
+
params.set('limit', Math.max(1, Math.min(options.limit, 25)).toString())
|
|
377
|
+
}
|
|
378
|
+
if (options.offset !== undefined) {
|
|
379
|
+
params.set('offset', options.offset.toString())
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
const response = await this.request<DiscordSearchResponse>(
|
|
383
|
+
'GET',
|
|
384
|
+
`/guilds/${guildId}/messages/search?${params.toString()}`
|
|
385
|
+
)
|
|
386
|
+
|
|
387
|
+
const results = response.messages
|
|
388
|
+
.flat()
|
|
389
|
+
.filter((msg) => msg.hit)
|
|
390
|
+
.map((msg) => ({
|
|
391
|
+
id: msg.id,
|
|
392
|
+
channel_id: msg.channel_id,
|
|
393
|
+
guild_id: msg.guild_id,
|
|
394
|
+
content: msg.content,
|
|
395
|
+
author: msg.author,
|
|
396
|
+
timestamp: msg.timestamp,
|
|
397
|
+
hit: msg.hit,
|
|
398
|
+
}))
|
|
399
|
+
|
|
400
|
+
return {
|
|
401
|
+
results,
|
|
402
|
+
total: response.total_results,
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
async getUserProfile(userId: string): Promise<DiscordUserProfile> {
|
|
407
|
+
return this.request<DiscordUserProfile>('GET', `/users/${userId}/profile`)
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
async createThread(
|
|
411
|
+
channelId: string,
|
|
412
|
+
name: string,
|
|
413
|
+
options?: {
|
|
414
|
+
auto_archive_duration?: number
|
|
415
|
+
rate_limit_per_user?: number
|
|
416
|
+
}
|
|
417
|
+
): Promise<DiscordChannel> {
|
|
418
|
+
return this.request<DiscordChannel>('POST', `/channels/${channelId}/threads`, {
|
|
419
|
+
name,
|
|
420
|
+
...options,
|
|
421
|
+
})
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
async archiveThread(threadId: string, archived: boolean = true): Promise<DiscordChannel> {
|
|
425
|
+
return this.request<DiscordChannel>('PATCH', `/channels/${threadId}`, { archived })
|
|
426
|
+
}
|
|
281
427
|
}
|
|
@@ -1,41 +1,57 @@
|
|
|
1
|
-
import { expect,
|
|
1
|
+
import { afterEach, beforeEach, expect, spyOn, test } from 'bun:test'
|
|
2
2
|
import { DiscordClient } from '../client'
|
|
3
3
|
import { DiscordCredentialManager } from '../credential-manager'
|
|
4
4
|
import { DiscordTokenExtractor } from '../token-extractor'
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
})),
|
|
13
|
-
}))
|
|
6
|
+
let extractorExtractSpy: ReturnType<typeof spyOn>
|
|
7
|
+
let clientTestAuthSpy: ReturnType<typeof spyOn>
|
|
8
|
+
let clientListServersSpy: ReturnType<typeof spyOn>
|
|
9
|
+
let credManagerLoadSpy: ReturnType<typeof spyOn>
|
|
10
|
+
let credManagerSaveSpy: ReturnType<typeof spyOn>
|
|
11
|
+
let credManagerClearTokenSpy: ReturnType<typeof spyOn>
|
|
14
12
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
})),
|
|
21
|
-
listGuilds: mock(async () => [
|
|
22
|
-
{ id: 'guild-1', name: 'Guild One' },
|
|
23
|
-
{ id: 'guild-2', name: 'Guild Two' },
|
|
24
|
-
]),
|
|
25
|
-
})),
|
|
26
|
-
}))
|
|
13
|
+
beforeEach(() => {
|
|
14
|
+
// Spy on DiscordTokenExtractor.prototype.extract
|
|
15
|
+
extractorExtractSpy = spyOn(DiscordTokenExtractor.prototype, 'extract').mockResolvedValue({
|
|
16
|
+
token: 'test-token-123',
|
|
17
|
+
})
|
|
27
18
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
19
|
+
// Spy on DiscordClient.prototype methods
|
|
20
|
+
clientTestAuthSpy = spyOn(DiscordClient.prototype, 'testAuth').mockResolvedValue({
|
|
21
|
+
id: 'user-123',
|
|
22
|
+
username: 'testuser',
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
clientListServersSpy = spyOn(DiscordClient.prototype, 'listServers').mockResolvedValue([
|
|
26
|
+
{ id: 'server-1', name: 'Server One' },
|
|
27
|
+
{ id: 'server-2', name: 'Server Two' },
|
|
28
|
+
])
|
|
29
|
+
|
|
30
|
+
// Spy on DiscordCredentialManager.prototype methods
|
|
31
|
+
credManagerLoadSpy = spyOn(DiscordCredentialManager.prototype, 'load').mockResolvedValue({
|
|
32
|
+
token: null,
|
|
33
|
+
current_server: null,
|
|
34
|
+
servers: {},
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
credManagerSaveSpy = spyOn(DiscordCredentialManager.prototype, 'save').mockResolvedValue(
|
|
38
|
+
undefined
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
credManagerClearTokenSpy = spyOn(
|
|
42
|
+
DiscordCredentialManager.prototype,
|
|
43
|
+
'clearToken'
|
|
44
|
+
).mockResolvedValue(undefined)
|
|
45
|
+
})
|
|
46
|
+
|
|
47
|
+
afterEach(() => {
|
|
48
|
+
extractorExtractSpy?.mockRestore()
|
|
49
|
+
clientTestAuthSpy?.mockRestore()
|
|
50
|
+
clientListServersSpy?.mockRestore()
|
|
51
|
+
credManagerLoadSpy?.mockRestore()
|
|
52
|
+
credManagerSaveSpy?.mockRestore()
|
|
53
|
+
credManagerClearTokenSpy?.mockRestore()
|
|
54
|
+
})
|
|
39
55
|
|
|
40
56
|
test('extract: calls DiscordTokenExtractor', async () => {
|
|
41
57
|
const extractor = new DiscordTokenExtractor()
|
|
@@ -51,11 +67,11 @@ test('extract: validates token with DiscordClient', async () => {
|
|
|
51
67
|
expect(authInfo.id).toBe('user-123')
|
|
52
68
|
})
|
|
53
69
|
|
|
54
|
-
test('extract: discovers
|
|
70
|
+
test('extract: discovers servers', async () => {
|
|
55
71
|
const client = new DiscordClient('test-token-123')
|
|
56
|
-
const
|
|
57
|
-
expect(
|
|
58
|
-
expect(
|
|
72
|
+
const servers = await client.listServers()
|
|
73
|
+
expect(servers).toHaveLength(2)
|
|
74
|
+
expect(servers[0].id).toBe('server-1')
|
|
59
75
|
})
|
|
60
76
|
|
|
61
77
|
test('logout: clears credentials', async () => {
|
|
@@ -68,5 +84,5 @@ test('status: returns auth state', async () => {
|
|
|
68
84
|
const credManager = new DiscordCredentialManager()
|
|
69
85
|
const config = await credManager.load()
|
|
70
86
|
expect(config.token).toBeNull()
|
|
71
|
-
expect(config.
|
|
87
|
+
expect(config.current_server).toBeNull()
|
|
72
88
|
})
|
|
@@ -61,20 +61,20 @@ export async function extractAction(options: { pretty?: boolean; debug?: boolean
|
|
|
61
61
|
|
|
62
62
|
if (options.debug) {
|
|
63
63
|
console.error(`[debug] ✓ Token valid for user: ${authInfo.username}`)
|
|
64
|
-
console.error(`[debug] Discovering
|
|
64
|
+
console.error(`[debug] Discovering servers...`)
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
-
const
|
|
67
|
+
const servers = await client.listServers()
|
|
68
68
|
|
|
69
69
|
if (options.debug) {
|
|
70
|
-
console.error(`[debug] ✓ Found ${
|
|
70
|
+
console.error(`[debug] ✓ Found ${servers.length} server(s)`)
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
-
if (
|
|
73
|
+
if (servers.length === 0) {
|
|
74
74
|
console.log(
|
|
75
75
|
formatOutput(
|
|
76
76
|
{
|
|
77
|
-
error: 'No
|
|
77
|
+
error: 'No servers found. Make sure you are a member of at least one Discord server.',
|
|
78
78
|
},
|
|
79
79
|
options.pretty
|
|
80
80
|
)
|
|
@@ -83,19 +83,19 @@ export async function extractAction(options: { pretty?: boolean; debug?: boolean
|
|
|
83
83
|
}
|
|
84
84
|
|
|
85
85
|
const credManager = new DiscordCredentialManager()
|
|
86
|
-
const
|
|
86
|
+
const serverMap: Record<string, { server_id: string; server_name: string }> = {}
|
|
87
87
|
|
|
88
|
-
for (const
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
88
|
+
for (const server of servers) {
|
|
89
|
+
serverMap[server.id] = {
|
|
90
|
+
server_id: server.id,
|
|
91
|
+
server_name: server.name,
|
|
92
92
|
}
|
|
93
93
|
}
|
|
94
94
|
|
|
95
95
|
const config = {
|
|
96
96
|
token: extracted.token,
|
|
97
|
-
|
|
98
|
-
|
|
97
|
+
current_server: servers[0].id,
|
|
98
|
+
servers: serverMap,
|
|
99
99
|
}
|
|
100
100
|
|
|
101
101
|
await credManager.save(config)
|
|
@@ -105,8 +105,8 @@ export async function extractAction(options: { pretty?: boolean; debug?: boolean
|
|
|
105
105
|
}
|
|
106
106
|
|
|
107
107
|
const output = {
|
|
108
|
-
|
|
109
|
-
current:
|
|
108
|
+
servers: servers.map((g) => `${g.id}/${g.name}`),
|
|
109
|
+
current: servers[0].id,
|
|
110
110
|
}
|
|
111
111
|
|
|
112
112
|
console.log(formatOutput(output, options.pretty))
|
|
@@ -173,8 +173,8 @@ export async function statusAction(options: { pretty?: boolean }): Promise<void>
|
|
|
173
173
|
const output = {
|
|
174
174
|
authenticated: valid,
|
|
175
175
|
user: authInfo?.username,
|
|
176
|
-
|
|
177
|
-
|
|
176
|
+
current_server: config.current_server,
|
|
177
|
+
servers_count: Object.keys(config.servers).length,
|
|
178
178
|
}
|
|
179
179
|
|
|
180
180
|
console.log(formatOutput(output, options.pretty))
|
|
@@ -1,15 +1,22 @@
|
|
|
1
|
-
import { expect,
|
|
1
|
+
import { afterEach, beforeEach, expect, spyOn, test } from 'bun:test'
|
|
2
2
|
import { DiscordClient } from '../client'
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
3
|
+
import { DiscordCredentialManager } from '../credential-manager'
|
|
4
|
+
|
|
5
|
+
let clientListChannelsSpy: ReturnType<typeof spyOn>
|
|
6
|
+
let clientGetChannelSpy: ReturnType<typeof spyOn>
|
|
7
|
+
let clientGetMessagesSpy: ReturnType<typeof spyOn>
|
|
8
|
+
let credManagerLoadSpy: ReturnType<typeof spyOn>
|
|
9
|
+
|
|
10
|
+
beforeEach(() => {
|
|
11
|
+
// Spy on DiscordClient.prototype methods
|
|
12
|
+
clientListChannelsSpy = spyOn(DiscordClient.prototype, 'listChannels').mockResolvedValue([
|
|
13
|
+
{ id: 'ch-1', guild_id: 'guild-1', name: 'general', type: 0, topic: 'General discussion' },
|
|
14
|
+
{ id: 'ch-2', guild_id: 'guild-1', name: 'announcements', type: 0, topic: 'Announcements' },
|
|
15
|
+
{ id: 'ch-3', guild_id: 'guild-1', name: 'voice-channel', type: 2, topic: undefined },
|
|
16
|
+
])
|
|
17
|
+
|
|
18
|
+
clientGetChannelSpy = spyOn(DiscordClient.prototype, 'getChannel').mockImplementation(
|
|
19
|
+
async (channelId: string) => {
|
|
13
20
|
if (channelId === 'ch-1') {
|
|
14
21
|
return {
|
|
15
22
|
id: 'ch-1',
|
|
@@ -29,42 +36,47 @@ mock.module('../client', () => ({
|
|
|
29
36
|
}
|
|
30
37
|
}
|
|
31
38
|
throw new Error('Channel not found')
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
DiscordCredentialManager
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
39
|
+
}
|
|
40
|
+
)
|
|
41
|
+
|
|
42
|
+
clientGetMessagesSpy = spyOn(DiscordClient.prototype, 'getMessages').mockResolvedValue([
|
|
43
|
+
{
|
|
44
|
+
id: 'msg-1',
|
|
45
|
+
channel_id: 'ch-1',
|
|
46
|
+
author: { id: 'user-1', username: 'alice' },
|
|
47
|
+
content: 'Hello world',
|
|
48
|
+
timestamp: '2024-01-29T10:00:00Z',
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
id: 'msg-2',
|
|
52
|
+
channel_id: 'ch-1',
|
|
53
|
+
author: { id: 'user-2', username: 'bob' },
|
|
54
|
+
content: 'Hi there',
|
|
55
|
+
timestamp: '2024-01-29T09:00:00Z',
|
|
56
|
+
},
|
|
57
|
+
])
|
|
58
|
+
|
|
59
|
+
// Spy on DiscordCredentialManager.prototype methods
|
|
60
|
+
credManagerLoadSpy = spyOn(DiscordCredentialManager.prototype, 'load').mockResolvedValue({
|
|
61
|
+
token: 'test-token',
|
|
62
|
+
current_server: 'server-1',
|
|
63
|
+
servers: {
|
|
64
|
+
'server-1': { server_id: 'server-1', server_name: 'Server One' },
|
|
65
|
+
},
|
|
66
|
+
})
|
|
67
|
+
})
|
|
68
|
+
|
|
69
|
+
afterEach(() => {
|
|
70
|
+
clientListChannelsSpy?.mockRestore()
|
|
71
|
+
clientGetChannelSpy?.mockRestore()
|
|
72
|
+
clientGetMessagesSpy?.mockRestore()
|
|
73
|
+
credManagerLoadSpy?.mockRestore()
|
|
74
|
+
})
|
|
75
|
+
|
|
76
|
+
test('list: returns text channels (type=0) from server', async () => {
|
|
65
77
|
// given: discord client with channels
|
|
66
78
|
const client = new DiscordClient('test-token')
|
|
67
|
-
const channels = await client.listChannels('
|
|
79
|
+
const channels = await client.listChannels('server-1')
|
|
68
80
|
|
|
69
81
|
// when: filtering text channels
|
|
70
82
|
const textChannels = channels.filter((ch) => ch.type === 0)
|
|
@@ -78,7 +90,7 @@ test('list: returns text channels (type=0) from guild', async () => {
|
|
|
78
90
|
test('list: includes channel metadata', async () => {
|
|
79
91
|
// given: discord client with channels
|
|
80
92
|
const client = new DiscordClient('test-token')
|
|
81
|
-
const channels = await client.listChannels('
|
|
93
|
+
const channels = await client.listChannels('server-1')
|
|
82
94
|
const textChannels = channels.filter((ch) => ch.type === 0)
|
|
83
95
|
|
|
84
96
|
// when: checking channel properties
|