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
|
@@ -16,27 +16,27 @@ export async function snapshotAction(options: {
|
|
|
16
16
|
const credManager = new DiscordCredentialManager()
|
|
17
17
|
const config = await credManager.load()
|
|
18
18
|
|
|
19
|
-
if (!config.token || !config.
|
|
19
|
+
if (!config.token || !config.current_server) {
|
|
20
20
|
console.log(
|
|
21
|
-
formatOutput({ error: 'No current
|
|
21
|
+
formatOutput({ error: 'No current server set. Run "server switch" first.' }, options.pretty)
|
|
22
22
|
)
|
|
23
23
|
process.exit(1)
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
const client = new DiscordClient(config.token as string)
|
|
27
|
-
const
|
|
27
|
+
const serverId = config.current_server as string
|
|
28
28
|
const messageLimit = options.limit || 20
|
|
29
29
|
|
|
30
30
|
const snapshot: Record<string, any> = {}
|
|
31
31
|
|
|
32
|
-
const
|
|
33
|
-
snapshot.
|
|
34
|
-
id:
|
|
35
|
-
name:
|
|
32
|
+
const server = await client.getServer(serverId)
|
|
33
|
+
snapshot.server = {
|
|
34
|
+
id: server.id,
|
|
35
|
+
name: server.name,
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
if (!options.usersOnly) {
|
|
39
|
-
const channels = await client.listChannels(
|
|
39
|
+
const channels = await client.listChannels(serverId)
|
|
40
40
|
|
|
41
41
|
snapshot.channels = channels.map((ch) => ({
|
|
42
42
|
id: ch.id,
|
|
@@ -73,7 +73,7 @@ export async function snapshotAction(options: {
|
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
if (!options.channelsOnly) {
|
|
76
|
-
const users = await client.listUsers(
|
|
76
|
+
const users = await client.listUsers(serverId)
|
|
77
77
|
|
|
78
78
|
snapshot.members = users.map((u) => ({
|
|
79
79
|
id: u.id,
|
|
@@ -90,7 +90,7 @@ export async function snapshotAction(options: {
|
|
|
90
90
|
|
|
91
91
|
export const snapshotCommand = new Command()
|
|
92
92
|
.name('snapshot')
|
|
93
|
-
.description('Get comprehensive
|
|
93
|
+
.description('Get comprehensive server state for AI agents')
|
|
94
94
|
.option('--channels-only', 'Include only channels (exclude messages and members)')
|
|
95
95
|
.option('--users-only', 'Include only members (exclude channels and messages)')
|
|
96
96
|
.option('--limit <n>', 'Number of recent messages per channel (default: 20)', '20')
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { afterEach, beforeEach, expect, spyOn, test } from 'bun:test'
|
|
2
|
+
import { DiscordClient } from '../client'
|
|
3
|
+
import { DiscordCredentialManager } from '../credential-manager'
|
|
4
|
+
|
|
5
|
+
let clientCreateThreadSpy: ReturnType<typeof spyOn>
|
|
6
|
+
let clientArchiveThreadSpy: ReturnType<typeof spyOn>
|
|
7
|
+
let credManagerLoadSpy: ReturnType<typeof spyOn>
|
|
8
|
+
|
|
9
|
+
beforeEach(() => {
|
|
10
|
+
clientCreateThreadSpy = spyOn(DiscordClient.prototype, 'createThread').mockResolvedValue({
|
|
11
|
+
id: 'thread-1',
|
|
12
|
+
guild_id: 'guild-1',
|
|
13
|
+
name: 'Test Thread',
|
|
14
|
+
type: 11,
|
|
15
|
+
parent_id: 'ch-1',
|
|
16
|
+
})
|
|
17
|
+
|
|
18
|
+
clientArchiveThreadSpy = spyOn(DiscordClient.prototype, 'archiveThread').mockResolvedValue({
|
|
19
|
+
id: 'thread-1',
|
|
20
|
+
guild_id: 'guild-1',
|
|
21
|
+
name: 'Test Thread',
|
|
22
|
+
type: 11,
|
|
23
|
+
parent_id: 'ch-1',
|
|
24
|
+
thread_metadata: {
|
|
25
|
+
archived: true,
|
|
26
|
+
auto_archive_duration: 1440,
|
|
27
|
+
archive_timestamp: '2024-01-29T10:00:00Z',
|
|
28
|
+
},
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
credManagerLoadSpy = spyOn(DiscordCredentialManager.prototype, 'load').mockResolvedValue({
|
|
32
|
+
token: 'test-token',
|
|
33
|
+
current_server: 'server-1',
|
|
34
|
+
servers: {
|
|
35
|
+
'server-1': { server_id: 'server-1', server_name: 'Server One' },
|
|
36
|
+
},
|
|
37
|
+
})
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
afterEach(() => {
|
|
41
|
+
clientCreateThreadSpy?.mockRestore()
|
|
42
|
+
clientArchiveThreadSpy?.mockRestore()
|
|
43
|
+
credManagerLoadSpy?.mockRestore()
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
test('createThread: creates thread with name', async () => {
|
|
47
|
+
// given: discord client
|
|
48
|
+
const client = new DiscordClient('test-token')
|
|
49
|
+
|
|
50
|
+
// when: creating thread
|
|
51
|
+
const thread = await client.createThread('ch-1', 'Test Thread')
|
|
52
|
+
|
|
53
|
+
// then: thread is created
|
|
54
|
+
expect(thread).toBeDefined()
|
|
55
|
+
expect(thread.id).toBe('thread-1')
|
|
56
|
+
expect(thread.name).toBe('Test Thread')
|
|
57
|
+
expect(thread.type).toBe(11)
|
|
58
|
+
expect(thread.parent_id).toBe('ch-1')
|
|
59
|
+
})
|
|
60
|
+
|
|
61
|
+
test('createThread: creates thread with auto_archive_duration', async () => {
|
|
62
|
+
// given: discord client
|
|
63
|
+
const client = new DiscordClient('test-token')
|
|
64
|
+
|
|
65
|
+
// when: creating thread with auto_archive_duration
|
|
66
|
+
await client.createThread('ch-1', 'Test Thread', { auto_archive_duration: 60 })
|
|
67
|
+
|
|
68
|
+
// then: createThread is called with options
|
|
69
|
+
expect(clientCreateThreadSpy).toHaveBeenCalledWith('ch-1', 'Test Thread', {
|
|
70
|
+
auto_archive_duration: 60,
|
|
71
|
+
})
|
|
72
|
+
})
|
|
73
|
+
|
|
74
|
+
test('createThread: creates thread with rate_limit_per_user', async () => {
|
|
75
|
+
// given: discord client
|
|
76
|
+
const client = new DiscordClient('test-token')
|
|
77
|
+
|
|
78
|
+
// when: creating thread with rate_limit_per_user
|
|
79
|
+
await client.createThread('ch-1', 'Test Thread', { rate_limit_per_user: 10 })
|
|
80
|
+
|
|
81
|
+
// then: createThread is called with options
|
|
82
|
+
expect(clientCreateThreadSpy).toHaveBeenCalledWith('ch-1', 'Test Thread', {
|
|
83
|
+
rate_limit_per_user: 10,
|
|
84
|
+
})
|
|
85
|
+
})
|
|
86
|
+
|
|
87
|
+
test('archiveThread: archives thread', async () => {
|
|
88
|
+
// given: discord client
|
|
89
|
+
const client = new DiscordClient('test-token')
|
|
90
|
+
|
|
91
|
+
// when: archiving thread
|
|
92
|
+
const thread = await client.archiveThread('thread-1')
|
|
93
|
+
|
|
94
|
+
// then: thread is archived
|
|
95
|
+
expect(thread).toBeDefined()
|
|
96
|
+
expect(thread.id).toBe('thread-1')
|
|
97
|
+
expect(thread.thread_metadata?.archived).toBe(true)
|
|
98
|
+
})
|
|
99
|
+
|
|
100
|
+
test('archiveThread: unarchives thread when archived=false', async () => {
|
|
101
|
+
// given: discord client with unarchive mock
|
|
102
|
+
clientArchiveThreadSpy.mockResolvedValue({
|
|
103
|
+
id: 'thread-1',
|
|
104
|
+
guild_id: 'guild-1',
|
|
105
|
+
name: 'Test Thread',
|
|
106
|
+
type: 11,
|
|
107
|
+
parent_id: 'ch-1',
|
|
108
|
+
thread_metadata: {
|
|
109
|
+
archived: false,
|
|
110
|
+
auto_archive_duration: 1440,
|
|
111
|
+
},
|
|
112
|
+
})
|
|
113
|
+
const client = new DiscordClient('test-token')
|
|
114
|
+
|
|
115
|
+
// when: unarchiving thread
|
|
116
|
+
const thread = await client.archiveThread('thread-1', false)
|
|
117
|
+
|
|
118
|
+
// then: thread is unarchived
|
|
119
|
+
expect(thread).toBeDefined()
|
|
120
|
+
expect(thread.thread_metadata?.archived).toBe(false)
|
|
121
|
+
})
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { Command } from 'commander'
|
|
2
|
+
import { handleError } from '../../../shared/utils/error-handler'
|
|
3
|
+
import { formatOutput } from '../../../shared/utils/output'
|
|
4
|
+
import { DiscordClient } from '../client'
|
|
5
|
+
import { DiscordCredentialManager } from '../credential-manager'
|
|
6
|
+
|
|
7
|
+
export async function createAction(
|
|
8
|
+
channelId: string,
|
|
9
|
+
name: string,
|
|
10
|
+
options: { autoArchiveDuration?: string; pretty?: boolean }
|
|
11
|
+
): Promise<void> {
|
|
12
|
+
try {
|
|
13
|
+
const credManager = new DiscordCredentialManager()
|
|
14
|
+
const config = await credManager.load()
|
|
15
|
+
|
|
16
|
+
if (!config.token) {
|
|
17
|
+
console.log(
|
|
18
|
+
formatOutput({ error: 'Not authenticated. Run "auth extract" first.' }, options.pretty)
|
|
19
|
+
)
|
|
20
|
+
process.exit(1)
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const client = new DiscordClient(config.token)
|
|
24
|
+
const threadOptions: { auto_archive_duration?: number } = {}
|
|
25
|
+
|
|
26
|
+
if (options.autoArchiveDuration) {
|
|
27
|
+
threadOptions.auto_archive_duration = parseInt(options.autoArchiveDuration, 10)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const thread = await client.createThread(channelId, name, threadOptions)
|
|
31
|
+
|
|
32
|
+
const output = {
|
|
33
|
+
id: thread.id,
|
|
34
|
+
name: thread.name,
|
|
35
|
+
type: thread.type,
|
|
36
|
+
parent_id: thread.parent_id,
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
console.log(formatOutput(output, options.pretty))
|
|
40
|
+
} catch (error) {
|
|
41
|
+
handleError(error as Error)
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export async function archiveAction(
|
|
46
|
+
threadId: string,
|
|
47
|
+
options: { pretty?: boolean }
|
|
48
|
+
): Promise<void> {
|
|
49
|
+
try {
|
|
50
|
+
const credManager = new DiscordCredentialManager()
|
|
51
|
+
const config = await credManager.load()
|
|
52
|
+
|
|
53
|
+
if (!config.token) {
|
|
54
|
+
console.log(
|
|
55
|
+
formatOutput({ error: 'Not authenticated. Run "auth extract" first.' }, options.pretty)
|
|
56
|
+
)
|
|
57
|
+
process.exit(1)
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const client = new DiscordClient(config.token)
|
|
61
|
+
const thread = await client.archiveThread(threadId)
|
|
62
|
+
|
|
63
|
+
const output = {
|
|
64
|
+
id: thread.id,
|
|
65
|
+
name: thread.name,
|
|
66
|
+
archived: thread.thread_metadata?.archived || false,
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
console.log(formatOutput(output, options.pretty))
|
|
70
|
+
} catch (error) {
|
|
71
|
+
handleError(error as Error)
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export const threadCommand = new Command('thread')
|
|
76
|
+
.description('Thread commands')
|
|
77
|
+
.addCommand(
|
|
78
|
+
new Command('create')
|
|
79
|
+
.description('Create a thread')
|
|
80
|
+
.argument('<channel-id>', 'Channel ID')
|
|
81
|
+
.argument('<name>', 'Thread name')
|
|
82
|
+
.option('--auto-archive-duration <minutes>', 'Auto archive duration in minutes')
|
|
83
|
+
.option('--pretty', 'Pretty print JSON output')
|
|
84
|
+
.action(createAction)
|
|
85
|
+
)
|
|
86
|
+
.addCommand(
|
|
87
|
+
new Command('archive')
|
|
88
|
+
.description('Archive a thread')
|
|
89
|
+
.argument('<thread-id>', 'Thread ID')
|
|
90
|
+
.option('--pretty', 'Pretty print JSON output')
|
|
91
|
+
.action(archiveAction)
|
|
92
|
+
)
|
|
@@ -16,7 +16,7 @@ const mockClient = {
|
|
|
16
16
|
avatar: 'avatar_hash',
|
|
17
17
|
bot: false,
|
|
18
18
|
})),
|
|
19
|
-
listUsers: mock(async (
|
|
19
|
+
listUsers: mock(async (_serverId: string) => [
|
|
20
20
|
{
|
|
21
21
|
id: 'user1',
|
|
22
22
|
username: 'alice',
|
|
@@ -80,12 +80,12 @@ test('info returns user details by id', async () => {
|
|
|
80
80
|
expect(result.username).toBe('testuser')
|
|
81
81
|
})
|
|
82
82
|
|
|
83
|
-
test('list returns
|
|
84
|
-
// given:
|
|
85
|
-
const
|
|
83
|
+
test('list returns server members', async () => {
|
|
84
|
+
// given: server id
|
|
85
|
+
const serverId = 'server123'
|
|
86
86
|
|
|
87
87
|
// when: listing users
|
|
88
|
-
const users = await mockClient.listUsers(
|
|
88
|
+
const users = await mockClient.listUsers(serverId)
|
|
89
89
|
const result = users.map((u) => ({
|
|
90
90
|
id: u.id,
|
|
91
91
|
username: u.username,
|
|
@@ -102,9 +102,9 @@ test('list returns guild members', async () => {
|
|
|
102
102
|
})
|
|
103
103
|
|
|
104
104
|
test('list filters out bots when flag not set', async () => {
|
|
105
|
-
// given:
|
|
106
|
-
const
|
|
107
|
-
const users = await mockClient.listUsers(
|
|
105
|
+
// given: server id and users with bots
|
|
106
|
+
const serverId = 'server123'
|
|
107
|
+
const users = await mockClient.listUsers(serverId)
|
|
108
108
|
|
|
109
109
|
// when: filtering out bots
|
|
110
110
|
const filtered = users.filter((u) => !u.bot)
|
|
@@ -3,6 +3,7 @@ import { handleError } from '../../../shared/utils/error-handler'
|
|
|
3
3
|
import { formatOutput } from '../../../shared/utils/output'
|
|
4
4
|
import { DiscordClient } from '../client'
|
|
5
5
|
import { DiscordCredentialManager } from '../credential-manager'
|
|
6
|
+
import type { DiscordUser } from '../types'
|
|
6
7
|
|
|
7
8
|
async function listAction(options: { pretty?: boolean }): Promise<void> {
|
|
8
9
|
try {
|
|
@@ -16,10 +17,10 @@ async function listAction(options: { pretty?: boolean }): Promise<void> {
|
|
|
16
17
|
process.exit(1)
|
|
17
18
|
}
|
|
18
19
|
|
|
19
|
-
if (!config.
|
|
20
|
+
if (!config.current_server) {
|
|
20
21
|
console.log(
|
|
21
22
|
formatOutput(
|
|
22
|
-
{ error: 'No current
|
|
23
|
+
{ error: 'No current server set. Run "server switch <id>" first.' },
|
|
23
24
|
options.pretty
|
|
24
25
|
)
|
|
25
26
|
)
|
|
@@ -27,7 +28,7 @@ async function listAction(options: { pretty?: boolean }): Promise<void> {
|
|
|
27
28
|
}
|
|
28
29
|
|
|
29
30
|
const client = new DiscordClient(config.token)
|
|
30
|
-
const users = await client.listUsers(config.
|
|
31
|
+
const users = await client.listUsers(config.current_server)
|
|
31
32
|
|
|
32
33
|
const output = users.map((user) => ({
|
|
33
34
|
id: user.id,
|
|
@@ -56,7 +57,17 @@ async function infoAction(userId: string, options: { pretty?: boolean }): Promis
|
|
|
56
57
|
}
|
|
57
58
|
|
|
58
59
|
const client = new DiscordClient(config.token)
|
|
59
|
-
|
|
60
|
+
|
|
61
|
+
// Check if requesting current user - use @me endpoint (works with user tokens)
|
|
62
|
+
const me = await client.testAuth()
|
|
63
|
+
let user: DiscordUser
|
|
64
|
+
|
|
65
|
+
if (userId === me.id) {
|
|
66
|
+
user = me
|
|
67
|
+
} else {
|
|
68
|
+
// For other users, try the regular endpoint (requires bot token)
|
|
69
|
+
user = await client.getUser(userId)
|
|
70
|
+
}
|
|
60
71
|
|
|
61
72
|
const output = {
|
|
62
73
|
id: user.id,
|
|
@@ -105,7 +116,7 @@ export const userCommand = new Command('user')
|
|
|
105
116
|
.description('User commands')
|
|
106
117
|
.addCommand(
|
|
107
118
|
new Command('list')
|
|
108
|
-
.description('List
|
|
119
|
+
.description('List server members')
|
|
109
120
|
.option('--pretty', 'Pretty print JSON output')
|
|
110
121
|
.action(listAction)
|
|
111
122
|
)
|
|
@@ -1,173 +1,174 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { existsSync } from 'node:fs'
|
|
3
|
-
import { rm } from 'node:fs/promises'
|
|
1
|
+
import { afterAll, describe, expect, test } from 'bun:test'
|
|
2
|
+
import { existsSync, rmSync } from 'node:fs'
|
|
4
3
|
import { join } from 'node:path'
|
|
5
4
|
import { DiscordCredentialManager } from './credential-manager'
|
|
6
5
|
|
|
7
|
-
const
|
|
6
|
+
const testDirs: string[] = []
|
|
8
7
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
8
|
+
function setup(): DiscordCredentialManager {
|
|
9
|
+
const testConfigDir = join(
|
|
10
|
+
import.meta.dir,
|
|
11
|
+
`.test-discord-config-${Date.now()}-${Math.random().toString(36).slice(2)}`
|
|
12
|
+
)
|
|
13
|
+
testDirs.push(testConfigDir)
|
|
14
|
+
return new DiscordCredentialManager(testConfigDir)
|
|
15
|
+
}
|
|
14
16
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
17
|
+
afterAll(() => {
|
|
18
|
+
for (const dir of testDirs) {
|
|
19
|
+
rmSync(dir, { recursive: true, force: true })
|
|
18
20
|
}
|
|
19
21
|
})
|
|
20
22
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
23
|
+
describe('DiscordCredentialManager', () => {
|
|
24
|
+
test('load returns default config when file does not exist', async () => {
|
|
25
|
+
const manager = setup()
|
|
26
|
+
const config = await manager.load()
|
|
24
27
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
28
|
+
expect(config).toEqual({
|
|
29
|
+
token: null,
|
|
30
|
+
current_server: null,
|
|
31
|
+
servers: {},
|
|
32
|
+
})
|
|
29
33
|
})
|
|
30
|
-
})
|
|
31
|
-
|
|
32
|
-
test('save creates config file with correct permissions', async () => {
|
|
33
|
-
const manager = new DiscordCredentialManager(TEST_CONFIG_DIR)
|
|
34
|
-
const config = {
|
|
35
|
-
token: 'test-token',
|
|
36
|
-
current_guild: 'guild-123',
|
|
37
|
-
guilds: {
|
|
38
|
-
'guild-123': { guild_id: 'guild-123', guild_name: 'Test Guild' },
|
|
39
|
-
},
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
await manager.save(config)
|
|
43
|
-
|
|
44
|
-
const credentialsPath = join(TEST_CONFIG_DIR, 'discord-credentials.json')
|
|
45
|
-
expect(existsSync(credentialsPath)).toBe(true)
|
|
46
|
-
|
|
47
|
-
const file = Bun.file(credentialsPath)
|
|
48
|
-
const content = await file.text()
|
|
49
|
-
const loaded = JSON.parse(content)
|
|
50
|
-
expect(loaded).toEqual(config)
|
|
51
|
-
})
|
|
52
|
-
|
|
53
|
-
test('getToken returns null when not authenticated', async () => {
|
|
54
|
-
const manager = new DiscordCredentialManager(TEST_CONFIG_DIR)
|
|
55
|
-
const token = await manager.getToken()
|
|
56
34
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
test
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
35
|
+
test('save creates config file with correct permissions', async () => {
|
|
36
|
+
const testConfigDir = join(
|
|
37
|
+
import.meta.dir,
|
|
38
|
+
`.test-discord-config-${Date.now()}-${Math.random().toString(36).slice(2)}`
|
|
39
|
+
)
|
|
40
|
+
testDirs.push(testConfigDir)
|
|
41
|
+
const manager = new DiscordCredentialManager(testConfigDir)
|
|
42
|
+
const config = {
|
|
43
|
+
token: 'test-token',
|
|
44
|
+
current_server: 'server-123',
|
|
45
|
+
servers: {
|
|
46
|
+
'server-123': { server_id: 'server-123', server_name: 'Test Server' },
|
|
47
|
+
},
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
await manager.save(config)
|
|
51
|
+
|
|
52
|
+
const credentialsPath = join(testConfigDir, 'discord-credentials.json')
|
|
53
|
+
expect(existsSync(credentialsPath)).toBe(true)
|
|
54
|
+
|
|
55
|
+
const file = Bun.file(credentialsPath)
|
|
56
|
+
const content = await file.text()
|
|
57
|
+
const loaded = JSON.parse(content)
|
|
58
|
+
expect(loaded).toEqual(config)
|
|
59
|
+
})
|
|
67
60
|
|
|
68
|
-
test('getToken returns
|
|
69
|
-
|
|
70
|
-
|
|
61
|
+
test('getToken returns null when not authenticated', async () => {
|
|
62
|
+
const manager = setup()
|
|
63
|
+
const token = await manager.getToken()
|
|
64
|
+
expect(token).toBeNull()
|
|
65
|
+
})
|
|
71
66
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
67
|
+
test('setToken saves token to config', async () => {
|
|
68
|
+
const manager = setup()
|
|
69
|
+
await manager.setToken('test-token-123')
|
|
75
70
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
await manager.clearToken()
|
|
71
|
+
const token = await manager.getToken()
|
|
72
|
+
expect(token).toBe('test-token-123')
|
|
73
|
+
})
|
|
80
74
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
75
|
+
test('getToken returns previously set token', async () => {
|
|
76
|
+
const manager = setup()
|
|
77
|
+
await manager.setToken('my-token')
|
|
84
78
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
79
|
+
const token = await manager.getToken()
|
|
80
|
+
expect(token).toBe('my-token')
|
|
81
|
+
})
|
|
88
82
|
|
|
89
|
-
|
|
90
|
-
|
|
83
|
+
test('clearToken removes token from config', async () => {
|
|
84
|
+
const manager = setup()
|
|
85
|
+
await manager.setToken('test-token')
|
|
86
|
+
await manager.clearToken()
|
|
91
87
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
88
|
+
const token = await manager.getToken()
|
|
89
|
+
expect(token).toBeNull()
|
|
90
|
+
})
|
|
95
91
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
92
|
+
test('getCurrentServer returns null when not set', async () => {
|
|
93
|
+
const manager = setup()
|
|
94
|
+
const server = await manager.getCurrentServer()
|
|
95
|
+
expect(server).toBeNull()
|
|
96
|
+
})
|
|
99
97
|
|
|
100
|
-
test('
|
|
101
|
-
|
|
102
|
-
|
|
98
|
+
test('setCurrentServer saves server id', async () => {
|
|
99
|
+
const manager = setup()
|
|
100
|
+
await manager.setCurrentServer('server-456')
|
|
103
101
|
|
|
104
|
-
|
|
105
|
-
|
|
102
|
+
const server = await manager.getCurrentServer()
|
|
103
|
+
expect(server).toBe('server-456')
|
|
104
|
+
})
|
|
106
105
|
|
|
107
|
-
test('
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
}
|
|
106
|
+
test('getServers returns empty object when no servers set', async () => {
|
|
107
|
+
const manager = setup()
|
|
108
|
+
const servers = await manager.getServers()
|
|
109
|
+
expect(servers).toEqual({})
|
|
110
|
+
})
|
|
113
111
|
|
|
114
|
-
|
|
112
|
+
test('setServers saves servers to config', async () => {
|
|
113
|
+
const manager = setup()
|
|
114
|
+
const servers = {
|
|
115
|
+
'server-1': { server_id: 'server-1', server_name: 'Server One' },
|
|
116
|
+
'server-2': { server_id: 'server-2', server_name: 'Server Two' },
|
|
117
|
+
}
|
|
115
118
|
|
|
116
|
-
|
|
117
|
-
expect(loaded).toEqual(guilds)
|
|
118
|
-
})
|
|
119
|
+
await manager.setServers(servers)
|
|
119
120
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
121
|
+
const loaded = await manager.getServers()
|
|
122
|
+
expect(loaded).toEqual(servers)
|
|
123
|
+
})
|
|
123
124
|
|
|
124
|
-
|
|
125
|
-
|
|
125
|
+
test('getCredentials returns null when not authenticated', async () => {
|
|
126
|
+
const manager = setup()
|
|
127
|
+
const creds = await manager.getCredentials()
|
|
128
|
+
expect(creds).toBeNull()
|
|
129
|
+
})
|
|
126
130
|
|
|
127
|
-
test('getCredentials returns null when token exists but no
|
|
128
|
-
|
|
129
|
-
|
|
131
|
+
test('getCredentials returns null when token exists but no server selected', async () => {
|
|
132
|
+
const manager = setup()
|
|
133
|
+
await manager.setToken('test-token')
|
|
130
134
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
})
|
|
135
|
+
const creds = await manager.getCredentials()
|
|
136
|
+
expect(creds).toBeNull()
|
|
137
|
+
})
|
|
134
138
|
|
|
135
|
-
test('getCredentials returns null when
|
|
136
|
-
|
|
137
|
-
|
|
139
|
+
test('getCredentials returns null when server selected but no token', async () => {
|
|
140
|
+
const manager = setup()
|
|
141
|
+
await manager.setCurrentServer('server-123')
|
|
138
142
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
})
|
|
143
|
+
const creds = await manager.getCredentials()
|
|
144
|
+
expect(creds).toBeNull()
|
|
145
|
+
})
|
|
142
146
|
|
|
143
|
-
test('getCredentials returns token and
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
+
test('getCredentials returns token and serverId when both are set', async () => {
|
|
148
|
+
const manager = setup()
|
|
149
|
+
await manager.setToken('test-token-xyz')
|
|
150
|
+
await manager.setCurrentServer('server-789')
|
|
147
151
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
+
const creds = await manager.getCredentials()
|
|
153
|
+
expect(creds).toEqual({
|
|
154
|
+
token: 'test-token-xyz',
|
|
155
|
+
serverId: 'server-789',
|
|
156
|
+
})
|
|
152
157
|
})
|
|
153
|
-
})
|
|
154
158
|
|
|
155
|
-
test('multiple operations preserve existing data', async () => {
|
|
156
|
-
|
|
159
|
+
test('multiple operations preserve existing data', async () => {
|
|
160
|
+
const manager = setup()
|
|
161
|
+
await manager.setToken('token-1')
|
|
162
|
+
await manager.setCurrentServer('server-1')
|
|
163
|
+
const servers = {
|
|
164
|
+
'server-1': { server_id: 'server-1', server_name: 'Server One' },
|
|
165
|
+
}
|
|
166
|
+
await manager.setServers(servers)
|
|
157
167
|
|
|
158
|
-
|
|
159
|
-
await manager.setToken('token-1')
|
|
160
|
-
await manager.setCurrentGuild('guild-1')
|
|
161
|
-
const guilds = {
|
|
162
|
-
'guild-1': { guild_id: 'guild-1', guild_name: 'Guild One' },
|
|
163
|
-
}
|
|
164
|
-
await manager.setGuilds(guilds)
|
|
168
|
+
await manager.setToken('token-2')
|
|
165
169
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
expect(await manager.getToken()).toBe('token-2')
|
|
171
|
-
expect(await manager.getCurrentGuild()).toBe('guild-1')
|
|
172
|
-
expect(await manager.getGuilds()).toEqual(guilds)
|
|
170
|
+
expect(await manager.getToken()).toBe('token-2')
|
|
171
|
+
expect(await manager.getCurrentServer()).toBe('server-1')
|
|
172
|
+
expect(await manager.getServers()).toEqual(servers)
|
|
173
|
+
})
|
|
173
174
|
})
|