agent-messenger 1.0.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 +92 -0
- package/.claude-plugin/README.md +144 -0
- package/.claude-plugin/marketplace.json +37 -0
- package/.claude-plugin/plugin.json +17 -0
- package/.github/workflows/ci.yml +30 -0
- package/CLAUDE.md +106 -0
- package/CONTRIBUTING.md +131 -0
- package/README.md +140 -0
- package/biome.json +34 -0
- package/bun.lock +252 -0
- package/dist/cli.d.ts +5 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +21 -0
- package/dist/cli.js.map +1 -0
- package/dist/commands/auth.d.ts +3 -0
- package/dist/commands/auth.d.ts.map +1 -0
- package/dist/commands/auth.js +140 -0
- package/dist/commands/auth.js.map +1 -0
- package/dist/commands/channel.d.ts +3 -0
- package/dist/commands/channel.d.ts.map +1 -0
- package/dist/commands/channel.js +118 -0
- package/dist/commands/channel.js.map +1 -0
- package/dist/commands/file.d.ts +3 -0
- package/dist/commands/file.d.ts.map +1 -0
- package/dist/commands/file.js +113 -0
- package/dist/commands/file.js.map +1 -0
- package/dist/commands/index.d.ts +9 -0
- package/dist/commands/index.d.ts.map +1 -0
- package/dist/commands/index.js +9 -0
- package/dist/commands/index.js.map +1 -0
- package/dist/commands/message.d.ts +3 -0
- package/dist/commands/message.d.ts.map +1 -0
- package/dist/commands/message.js +214 -0
- package/dist/commands/message.js.map +1 -0
- package/dist/commands/reaction.d.ts +3 -0
- package/dist/commands/reaction.d.ts.map +1 -0
- package/dist/commands/reaction.js +100 -0
- package/dist/commands/reaction.js.map +1 -0
- package/dist/commands/snapshot.d.ts +3 -0
- package/dist/commands/snapshot.d.ts.map +1 -0
- package/dist/commands/snapshot.js +88 -0
- package/dist/commands/snapshot.js.map +1 -0
- package/dist/commands/user.d.ts +3 -0
- package/dist/commands/user.d.ts.map +1 -0
- package/dist/commands/user.js +96 -0
- package/dist/commands/user.js.map +1 -0
- package/dist/commands/workspace.d.ts +3 -0
- package/dist/commands/workspace.d.ts.map +1 -0
- package/dist/commands/workspace.js +89 -0
- package/dist/commands/workspace.js.map +1 -0
- package/dist/lib/credential-manager.d.ts +13 -0
- package/dist/lib/credential-manager.d.ts.map +1 -0
- package/dist/lib/credential-manager.js +58 -0
- package/dist/lib/credential-manager.js.map +1 -0
- package/dist/lib/index.d.ts +3 -0
- package/dist/lib/index.d.ts.map +1 -0
- package/dist/lib/index.js +3 -0
- package/dist/lib/index.js.map +1 -0
- package/dist/lib/ref-manager.d.ts +26 -0
- package/dist/lib/ref-manager.d.ts.map +1 -0
- package/dist/lib/ref-manager.js +92 -0
- package/dist/lib/ref-manager.js.map +1 -0
- package/dist/lib/slack-client.d.ts +37 -0
- package/dist/lib/slack-client.d.ts.map +1 -0
- package/dist/lib/slack-client.js +379 -0
- package/dist/lib/slack-client.js.map +1 -0
- package/dist/lib/token-extractor.d.ts +28 -0
- package/dist/lib/token-extractor.d.ts.map +1 -0
- package/dist/lib/token-extractor.js +401 -0
- package/dist/lib/token-extractor.js.map +1 -0
- package/dist/package.json +37 -0
- package/dist/src/cli.d.ts +5 -0
- package/dist/src/cli.d.ts.map +1 -0
- package/dist/src/cli.js +22 -0
- package/dist/src/cli.js.map +1 -0
- package/dist/src/platforms/discord/cli.d.ts +5 -0
- package/dist/src/platforms/discord/cli.d.ts.map +1 -0
- package/dist/src/platforms/discord/cli.js +22 -0
- package/dist/src/platforms/discord/cli.js.map +1 -0
- package/dist/src/platforms/discord/client.d.ts +34 -0
- package/dist/src/platforms/discord/client.d.ts.map +1 -0
- package/dist/src/platforms/discord/client.js +187 -0
- package/dist/src/platforms/discord/client.js.map +1 -0
- package/dist/src/platforms/discord/client.test.d.ts +2 -0
- package/dist/src/platforms/discord/client.test.d.ts.map +1 -0
- package/dist/src/platforms/discord/client.test.js +367 -0
- package/dist/src/platforms/discord/client.test.js.map +1 -0
- package/dist/src/platforms/discord/commands/auth.d.ts +13 -0
- package/dist/src/platforms/discord/commands/auth.d.ts.map +1 -0
- package/dist/src/platforms/discord/commands/auth.js +155 -0
- package/dist/src/platforms/discord/commands/auth.js.map +1 -0
- package/dist/src/platforms/discord/commands/auth.test.d.ts +2 -0
- package/dist/src/platforms/discord/commands/auth.test.d.ts.map +1 -0
- package/dist/src/platforms/discord/commands/auth.test.js +65 -0
- package/dist/src/platforms/discord/commands/auth.test.js.map +1 -0
- package/dist/src/platforms/discord/commands/channel.d.ts +13 -0
- package/dist/src/platforms/discord/commands/channel.d.ts.map +1 -0
- package/dist/src/platforms/discord/commands/channel.js +99 -0
- package/dist/src/platforms/discord/commands/channel.js.map +1 -0
- package/dist/src/platforms/discord/commands/channel.test.d.ts +2 -0
- package/dist/src/platforms/discord/commands/channel.test.d.ts.map +1 -0
- package/dist/src/platforms/discord/commands/channel.test.js +136 -0
- package/dist/src/platforms/discord/commands/channel.test.js.map +1 -0
- package/dist/src/platforms/discord/commands/file.d.ts +13 -0
- package/dist/src/platforms/discord/commands/file.d.ts.map +1 -0
- package/dist/src/platforms/discord/commands/file.js +99 -0
- package/dist/src/platforms/discord/commands/file.js.map +1 -0
- package/dist/src/platforms/discord/commands/file.test.d.ts +2 -0
- package/dist/src/platforms/discord/commands/file.test.d.ts.map +1 -0
- package/dist/src/platforms/discord/commands/file.test.js +83 -0
- package/dist/src/platforms/discord/commands/file.test.js.map +1 -0
- package/dist/src/platforms/discord/commands/guild.d.ts +15 -0
- package/dist/src/platforms/discord/commands/guild.d.ts.map +1 -0
- package/dist/src/platforms/discord/commands/guild.js +102 -0
- package/dist/src/platforms/discord/commands/guild.js.map +1 -0
- package/dist/src/platforms/discord/commands/guild.test.d.ts +2 -0
- package/dist/src/platforms/discord/commands/guild.test.d.ts.map +1 -0
- package/dist/src/platforms/discord/commands/guild.test.js +100 -0
- package/dist/src/platforms/discord/commands/guild.test.js.map +1 -0
- package/dist/src/platforms/discord/commands/index.d.ts +9 -0
- package/dist/src/platforms/discord/commands/index.d.ts.map +1 -0
- package/dist/src/platforms/discord/commands/index.js +9 -0
- package/dist/src/platforms/discord/commands/index.js.map +1 -0
- package/dist/src/platforms/discord/commands/message.d.ts +17 -0
- package/dist/src/platforms/discord/commands/message.d.ts.map +1 -0
- package/dist/src/platforms/discord/commands/message.js +131 -0
- package/dist/src/platforms/discord/commands/message.js.map +1 -0
- package/dist/src/platforms/discord/commands/message.test.d.ts +2 -0
- package/dist/src/platforms/discord/commands/message.test.d.ts.map +1 -0
- package/dist/src/platforms/discord/commands/message.test.js +91 -0
- package/dist/src/platforms/discord/commands/message.test.js.map +1 -0
- package/dist/src/platforms/discord/commands/reaction.d.ts +12 -0
- package/dist/src/platforms/discord/commands/reaction.d.ts.map +1 -0
- package/dist/src/platforms/discord/commands/reaction.js +99 -0
- package/dist/src/platforms/discord/commands/reaction.js.map +1 -0
- package/dist/src/platforms/discord/commands/reaction.test.d.ts +2 -0
- package/dist/src/platforms/discord/commands/reaction.test.d.ts.map +1 -0
- package/dist/src/platforms/discord/commands/reaction.test.js +115 -0
- package/dist/src/platforms/discord/commands/reaction.test.js.map +1 -0
- package/dist/src/platforms/discord/commands/snapshot.d.ts +9 -0
- package/dist/src/platforms/discord/commands/snapshot.d.ts.map +1 -0
- package/dist/src/platforms/discord/commands/snapshot.js +80 -0
- package/dist/src/platforms/discord/commands/snapshot.js.map +1 -0
- package/dist/src/platforms/discord/commands/snapshot.test.d.ts +2 -0
- package/dist/src/platforms/discord/commands/snapshot.test.d.ts.map +1 -0
- package/dist/src/platforms/discord/commands/snapshot.test.js +25 -0
- package/dist/src/platforms/discord/commands/snapshot.test.js.map +1 -0
- package/dist/src/platforms/discord/commands/user.d.ts +3 -0
- package/dist/src/platforms/discord/commands/user.d.ts.map +1 -0
- package/dist/src/platforms/discord/commands/user.js +94 -0
- package/dist/src/platforms/discord/commands/user.js.map +1 -0
- package/dist/src/platforms/discord/commands/user.test.d.ts +2 -0
- package/dist/src/platforms/discord/commands/user.test.d.ts.map +1 -0
- package/dist/src/platforms/discord/commands/user.test.js +103 -0
- package/dist/src/platforms/discord/commands/user.test.js.map +1 -0
- package/dist/src/platforms/discord/credential-manager.d.ts +33 -0
- package/dist/src/platforms/discord/credential-manager.d.ts.map +1 -0
- package/dist/src/platforms/discord/credential-manager.js +73 -0
- package/dist/src/platforms/discord/credential-manager.js.map +1 -0
- package/dist/src/platforms/discord/credential-manager.test.d.ts +2 -0
- package/dist/src/platforms/discord/credential-manager.test.d.ts.map +1 -0
- package/dist/src/platforms/discord/credential-manager.test.js +136 -0
- package/dist/src/platforms/discord/credential-manager.test.js.map +1 -0
- package/dist/src/platforms/discord/token-extractor.d.ts +55 -0
- package/dist/src/platforms/discord/token-extractor.d.ts.map +1 -0
- package/dist/src/platforms/discord/token-extractor.js +462 -0
- package/dist/src/platforms/discord/token-extractor.js.map +1 -0
- package/dist/src/platforms/discord/token-extractor.test.d.ts +2 -0
- package/dist/src/platforms/discord/token-extractor.test.d.ts.map +1 -0
- package/dist/src/platforms/discord/token-extractor.test.js +789 -0
- package/dist/src/platforms/discord/token-extractor.test.js.map +1 -0
- package/dist/src/platforms/discord/types.d.ts +251 -0
- package/dist/src/platforms/discord/types.d.ts.map +1 -0
- package/dist/src/platforms/discord/types.js +74 -0
- package/dist/src/platforms/discord/types.js.map +1 -0
- package/dist/src/platforms/discord/types.test.d.ts +2 -0
- package/dist/src/platforms/discord/types.test.d.ts.map +1 -0
- package/dist/src/platforms/discord/types.test.js +211 -0
- package/dist/src/platforms/discord/types.test.js.map +1 -0
- package/dist/src/platforms/slack/cli.d.ts +5 -0
- package/dist/src/platforms/slack/cli.d.ts.map +1 -0
- package/dist/src/platforms/slack/cli.js +22 -0
- package/dist/src/platforms/slack/cli.js.map +1 -0
- package/dist/src/platforms/slack/client.d.ts +47 -0
- package/dist/src/platforms/slack/client.d.ts.map +1 -0
- package/dist/src/platforms/slack/client.js +412 -0
- package/dist/src/platforms/slack/client.js.map +1 -0
- package/dist/src/platforms/slack/commands/auth.d.ts +3 -0
- package/dist/src/platforms/slack/commands/auth.d.ts.map +1 -0
- package/dist/src/platforms/slack/commands/auth.js +156 -0
- package/dist/src/platforms/slack/commands/auth.js.map +1 -0
- package/dist/src/platforms/slack/commands/channel.d.ts +3 -0
- package/dist/src/platforms/slack/commands/channel.d.ts.map +1 -0
- package/dist/src/platforms/slack/commands/channel.js +118 -0
- package/dist/src/platforms/slack/commands/channel.js.map +1 -0
- package/dist/src/platforms/slack/commands/file.d.ts +3 -0
- package/dist/src/platforms/slack/commands/file.d.ts.map +1 -0
- package/dist/src/platforms/slack/commands/file.js +113 -0
- package/dist/src/platforms/slack/commands/file.js.map +1 -0
- package/dist/src/platforms/slack/commands/index.d.ts +9 -0
- package/dist/src/platforms/slack/commands/index.d.ts.map +1 -0
- package/dist/src/platforms/slack/commands/index.js +9 -0
- package/dist/src/platforms/slack/commands/index.js.map +1 -0
- package/dist/src/platforms/slack/commands/message.d.ts +3 -0
- package/dist/src/platforms/slack/commands/message.d.ts.map +1 -0
- package/dist/src/platforms/slack/commands/message.js +263 -0
- package/dist/src/platforms/slack/commands/message.js.map +1 -0
- package/dist/src/platforms/slack/commands/reaction.d.ts +3 -0
- package/dist/src/platforms/slack/commands/reaction.d.ts.map +1 -0
- package/dist/src/platforms/slack/commands/reaction.js +100 -0
- package/dist/src/platforms/slack/commands/reaction.js.map +1 -0
- package/dist/src/platforms/slack/commands/snapshot.d.ts +3 -0
- package/dist/src/platforms/slack/commands/snapshot.d.ts.map +1 -0
- package/dist/src/platforms/slack/commands/snapshot.js +87 -0
- package/dist/src/platforms/slack/commands/snapshot.js.map +1 -0
- package/dist/src/platforms/slack/commands/user.d.ts +3 -0
- package/dist/src/platforms/slack/commands/user.d.ts.map +1 -0
- package/dist/src/platforms/slack/commands/user.js +96 -0
- package/dist/src/platforms/slack/commands/user.js.map +1 -0
- package/dist/src/platforms/slack/commands/workspace.d.ts +3 -0
- package/dist/src/platforms/slack/commands/workspace.d.ts.map +1 -0
- package/dist/src/platforms/slack/commands/workspace.js +89 -0
- package/dist/src/platforms/slack/commands/workspace.js.map +1 -0
- package/dist/src/platforms/slack/credential-manager.d.ts +13 -0
- package/dist/src/platforms/slack/credential-manager.d.ts.map +1 -0
- package/dist/src/platforms/slack/credential-manager.js +58 -0
- package/dist/src/platforms/slack/credential-manager.js.map +1 -0
- package/dist/src/platforms/slack/index.d.ts +3 -0
- package/dist/src/platforms/slack/index.d.ts.map +1 -0
- package/dist/src/platforms/slack/index.js +3 -0
- package/dist/src/platforms/slack/index.js.map +1 -0
- package/dist/src/platforms/slack/token-extractor.d.ts +28 -0
- package/dist/src/platforms/slack/token-extractor.d.ts.map +1 -0
- package/dist/src/platforms/slack/token-extractor.js +401 -0
- package/dist/src/platforms/slack/token-extractor.js.map +1 -0
- package/dist/src/platforms/slack/types.d.ts +369 -0
- package/dist/src/platforms/slack/types.d.ts.map +1 -0
- package/dist/src/platforms/slack/types.js +92 -0
- package/dist/src/platforms/slack/types.js.map +1 -0
- package/dist/src/shared/utils/concurrency.d.ts +2 -0
- package/dist/src/shared/utils/concurrency.d.ts.map +1 -0
- package/dist/src/shared/utils/concurrency.js +14 -0
- package/dist/src/shared/utils/concurrency.js.map +1 -0
- package/dist/src/shared/utils/concurrency.test.d.ts +2 -0
- package/dist/src/shared/utils/concurrency.test.d.ts.map +1 -0
- package/dist/src/shared/utils/concurrency.test.js +39 -0
- package/dist/src/shared/utils/concurrency.test.js.map +1 -0
- package/dist/src/shared/utils/error-handler.d.ts +2 -0
- package/dist/src/shared/utils/error-handler.d.ts.map +1 -0
- package/dist/src/shared/utils/error-handler.js +5 -0
- package/dist/src/shared/utils/error-handler.js.map +1 -0
- package/dist/src/shared/utils/output.d.ts +2 -0
- package/dist/src/shared/utils/output.d.ts.map +1 -0
- package/dist/src/shared/utils/output.js +4 -0
- package/dist/src/shared/utils/output.js.map +1 -0
- package/dist/tests/cli.test.d.ts +2 -0
- package/dist/tests/cli.test.d.ts.map +1 -0
- package/dist/tests/cli.test.js +83 -0
- package/dist/tests/cli.test.js.map +1 -0
- package/dist/tests/commands/.test-slack-data/Local Storage/leveldb/CURRENT +1 -0
- package/dist/tests/commands/.test-slack-data/Local Storage/leveldb/LOCK +0 -0
- package/dist/tests/commands/.test-slack-data/Local Storage/leveldb/LOG +3 -0
- package/dist/tests/commands/.test-slack-data/Local Storage/leveldb/LOG.old +1 -0
- package/dist/tests/commands/.test-slack-data/Local Storage/leveldb/MANIFEST-000004 +0 -0
- package/dist/tests/commands/auth.test.d.ts +2 -0
- package/dist/tests/commands/auth.test.d.ts.map +1 -0
- package/dist/tests/commands/auth.test.js +304 -0
- package/dist/tests/commands/auth.test.js.map +1 -0
- package/dist/tests/commands/channel.test.d.ts +2 -0
- package/dist/tests/commands/channel.test.d.ts.map +1 -0
- package/dist/tests/commands/channel.test.js +166 -0
- package/dist/tests/commands/channel.test.js.map +1 -0
- package/dist/tests/commands/file.test.d.ts +2 -0
- package/dist/tests/commands/file.test.d.ts.map +1 -0
- package/dist/tests/commands/file.test.js +175 -0
- package/dist/tests/commands/file.test.js.map +1 -0
- package/dist/tests/commands/message.test.d.ts +2 -0
- package/dist/tests/commands/message.test.d.ts.map +1 -0
- package/dist/tests/commands/message.test.js +293 -0
- package/dist/tests/commands/message.test.js.map +1 -0
- package/dist/tests/commands/reaction.test.d.ts +2 -0
- package/dist/tests/commands/reaction.test.d.ts.map +1 -0
- package/dist/tests/commands/reaction.test.js +84 -0
- package/dist/tests/commands/reaction.test.js.map +1 -0
- package/dist/tests/commands/snapshot.test.d.ts +2 -0
- package/dist/tests/commands/snapshot.test.d.ts.map +1 -0
- package/dist/tests/commands/snapshot.test.js +280 -0
- package/dist/tests/commands/snapshot.test.js.map +1 -0
- package/dist/tests/commands/user.test.d.ts +2 -0
- package/dist/tests/commands/user.test.d.ts.map +1 -0
- package/dist/tests/commands/user.test.js +117 -0
- package/dist/tests/commands/user.test.js.map +1 -0
- package/dist/tests/commands/workspace.test.d.ts +2 -0
- package/dist/tests/commands/workspace.test.d.ts.map +1 -0
- package/dist/tests/commands/workspace.test.js +453 -0
- package/dist/tests/commands/workspace.test.js.map +1 -0
- package/dist/tests/credential-manager.test.d.ts +2 -0
- package/dist/tests/credential-manager.test.d.ts.map +1 -0
- package/dist/tests/credential-manager.test.js +199 -0
- package/dist/tests/credential-manager.test.js.map +1 -0
- package/dist/tests/slack-client.test.d.ts +2 -0
- package/dist/tests/slack-client.test.d.ts.map +1 -0
- package/dist/tests/slack-client.test.js +741 -0
- package/dist/tests/slack-client.test.js.map +1 -0
- package/dist/tests/types.test.d.ts +2 -0
- package/dist/tests/types.test.d.ts.map +1 -0
- package/dist/tests/types.test.js +215 -0
- package/dist/tests/types.test.js.map +1 -0
- package/dist/types/index.d.ts +369 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +92 -0
- package/dist/types/index.js.map +1 -0
- package/dist/utils/error-handler.d.ts +2 -0
- package/dist/utils/error-handler.d.ts.map +1 -0
- package/dist/utils/error-handler.js +5 -0
- package/dist/utils/error-handler.js.map +1 -0
- package/dist/utils/output.d.ts +2 -0
- package/dist/utils/output.d.ts.map +1 -0
- package/dist/utils/output.js +4 -0
- package/dist/utils/output.js.map +1 -0
- package/docs/discord.md +182 -0
- package/docs/slack.md +160 -0
- package/package.json +37 -0
- package/skills/agent-discord/SKILL.md +273 -0
- package/skills/agent-discord/references/authentication.md +294 -0
- package/skills/agent-discord/references/common-patterns.md +455 -0
- package/skills/agent-discord/templates/guild-summary.sh +167 -0
- package/skills/agent-discord/templates/monitor-channel.sh +180 -0
- package/skills/agent-discord/templates/post-message.sh +173 -0
- package/skills/agent-slack/SKILL.md +268 -0
- package/skills/agent-slack/references/authentication.md +332 -0
- package/skills/agent-slack/references/common-patterns.md +527 -0
- package/skills/agent-slack/templates/monitor-channel.sh +186 -0
- package/skills/agent-slack/templates/post-message.sh +130 -0
- package/skills/agent-slack/templates/workspace-summary.sh +149 -0
- package/src/cli.ts +29 -0
- package/src/platforms/discord/cli.ts +36 -0
- package/src/platforms/discord/client.test.ts +456 -0
- package/src/platforms/discord/client.ts +281 -0
- package/src/platforms/discord/commands/auth.test.ts +72 -0
- package/src/platforms/discord/commands/auth.ts +206 -0
- package/src/platforms/discord/commands/channel.test.ts +153 -0
- package/src/platforms/discord/commands/channel.ts +127 -0
- package/src/platforms/discord/commands/file.test.ts +98 -0
- package/src/platforms/discord/commands/file.ts +134 -0
- package/src/platforms/discord/commands/guild.test.ts +117 -0
- package/src/platforms/discord/commands/guild.ts +129 -0
- package/src/platforms/discord/commands/index.ts +8 -0
- package/src/platforms/discord/commands/message.test.ts +107 -0
- package/src/platforms/discord/commands/message.ts +182 -0
- package/src/platforms/discord/commands/reaction.test.ts +123 -0
- package/src/platforms/discord/commands/reaction.ts +156 -0
- package/src/platforms/discord/commands/snapshot.test.ts +29 -0
- package/src/platforms/discord/commands/snapshot.ts +104 -0
- package/src/platforms/discord/commands/user.test.ts +115 -0
- package/src/platforms/discord/commands/user.ts +124 -0
- package/src/platforms/discord/credential-manager.test.ts +173 -0
- package/src/platforms/discord/credential-manager.ts +95 -0
- package/src/platforms/discord/token-extractor.test.ts +918 -0
- package/src/platforms/discord/token-extractor.ts +549 -0
- package/src/platforms/discord/types.test.ts +245 -0
- package/src/platforms/discord/types.ts +158 -0
- package/src/platforms/slack/cli.ts +36 -0
- package/src/platforms/slack/client.ts +466 -0
- package/src/platforms/slack/commands/auth.ts +211 -0
- package/src/platforms/slack/commands/channel.ts +158 -0
- package/src/platforms/slack/commands/file.ts +153 -0
- package/src/platforms/slack/commands/index.ts +8 -0
- package/src/platforms/slack/commands/message.ts +369 -0
- package/src/platforms/slack/commands/reaction.ts +166 -0
- package/src/platforms/slack/commands/snapshot.ts +114 -0
- package/src/platforms/slack/commands/user.ts +110 -0
- package/src/platforms/slack/commands/workspace.ts +111 -0
- package/src/platforms/slack/credential-manager.ts +74 -0
- package/src/platforms/slack/index.ts +2 -0
- package/src/platforms/slack/token-extractor.ts +496 -0
- package/src/platforms/slack/types.ts +193 -0
- package/src/shared/utils/concurrency.test.ts +53 -0
- package/src/shared/utils/concurrency.ts +20 -0
- package/src/shared/utils/error-handler.ts +4 -0
- package/src/shared/utils/output.ts +3 -0
- package/tests/cli.test.ts +94 -0
- package/tests/commands/auth.test.ts +383 -0
- package/tests/commands/channel.test.ts +185 -0
- package/tests/commands/file.test.ts +204 -0
- package/tests/commands/message.test.ts +344 -0
- package/tests/commands/reaction.test.ts +101 -0
- package/tests/commands/snapshot.test.ts +308 -0
- package/tests/commands/user.test.ts +138 -0
- package/tests/commands/workspace.test.ts +528 -0
- package/tests/credential-manager.test.ts +241 -0
- package/tests/slack-client.test.ts +916 -0
- package/tests/types.test.ts +241 -0
- package/tsconfig.json +36 -0
|
@@ -0,0 +1,155 @@
|
|
|
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
|
+
import { DiscordTokenExtractor } from '../token-extractor';
|
|
7
|
+
export async function extractAction(options) {
|
|
8
|
+
try {
|
|
9
|
+
const extractor = new DiscordTokenExtractor();
|
|
10
|
+
if (process.platform === 'darwin') {
|
|
11
|
+
console.log('');
|
|
12
|
+
console.log(' Extracting your Discord credentials...');
|
|
13
|
+
console.log('');
|
|
14
|
+
console.log(' Your Mac may ask for your password to access Keychain.');
|
|
15
|
+
console.log(' This is required because Discord encrypts your login token');
|
|
16
|
+
console.log(' using macOS Keychain for security.');
|
|
17
|
+
console.log('');
|
|
18
|
+
console.log(' What happens:');
|
|
19
|
+
console.log(" 1. We read the encrypted token from Discord's local storage");
|
|
20
|
+
console.log(' 2. macOS Keychain decrypts it (requires your password)');
|
|
21
|
+
console.log(' 3. The token is stored locally in ~/.config/agent-messenger/');
|
|
22
|
+
console.log('');
|
|
23
|
+
console.log(' Your password is never stored or transmitted anywhere.');
|
|
24
|
+
console.log('');
|
|
25
|
+
}
|
|
26
|
+
if (options.debug) {
|
|
27
|
+
console.error(`[debug] Extracting Discord token...`);
|
|
28
|
+
}
|
|
29
|
+
const extracted = await extractor.extract();
|
|
30
|
+
if (!extracted) {
|
|
31
|
+
console.log(formatOutput({
|
|
32
|
+
error: 'No Discord token found. Make sure Discord desktop app is installed and logged in.',
|
|
33
|
+
hint: options.debug ? undefined : 'Run with --debug for more info.',
|
|
34
|
+
}, options.pretty));
|
|
35
|
+
process.exit(1);
|
|
36
|
+
}
|
|
37
|
+
if (options.debug) {
|
|
38
|
+
console.error(`[debug] Token extracted: ${extracted.token.substring(0, 20)}...`);
|
|
39
|
+
}
|
|
40
|
+
try {
|
|
41
|
+
const client = new DiscordClient(extracted.token);
|
|
42
|
+
if (options.debug) {
|
|
43
|
+
console.error(`[debug] Testing token validity...`);
|
|
44
|
+
}
|
|
45
|
+
const authInfo = await client.testAuth();
|
|
46
|
+
if (options.debug) {
|
|
47
|
+
console.error(`[debug] ✓ Token valid for user: ${authInfo.username}`);
|
|
48
|
+
console.error(`[debug] Discovering guilds...`);
|
|
49
|
+
}
|
|
50
|
+
const guilds = await client.listGuilds();
|
|
51
|
+
if (options.debug) {
|
|
52
|
+
console.error(`[debug] ✓ Found ${guilds.length} guild(s)`);
|
|
53
|
+
}
|
|
54
|
+
if (guilds.length === 0) {
|
|
55
|
+
console.log(formatOutput({
|
|
56
|
+
error: 'No guilds found. Make sure you are a member of at least one Discord server.',
|
|
57
|
+
}, options.pretty));
|
|
58
|
+
process.exit(1);
|
|
59
|
+
}
|
|
60
|
+
const credManager = new DiscordCredentialManager();
|
|
61
|
+
const guildMap = {};
|
|
62
|
+
for (const guild of guilds) {
|
|
63
|
+
guildMap[guild.id] = {
|
|
64
|
+
guild_id: guild.id,
|
|
65
|
+
guild_name: guild.name,
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
const config = {
|
|
69
|
+
token: extracted.token,
|
|
70
|
+
current_guild: guilds[0].id,
|
|
71
|
+
guilds: guildMap,
|
|
72
|
+
};
|
|
73
|
+
await credManager.save(config);
|
|
74
|
+
if (options.debug) {
|
|
75
|
+
console.error(`[debug] ✓ Credentials saved`);
|
|
76
|
+
}
|
|
77
|
+
const output = {
|
|
78
|
+
guilds: guilds.map((g) => `${g.id}/${g.name}`),
|
|
79
|
+
current: guilds[0].id,
|
|
80
|
+
};
|
|
81
|
+
console.log(formatOutput(output, options.pretty));
|
|
82
|
+
}
|
|
83
|
+
catch (error) {
|
|
84
|
+
console.log(formatOutput({
|
|
85
|
+
error: `Token validation failed: ${error.message}`,
|
|
86
|
+
hint: 'Make sure your Discord token is valid and has not expired.',
|
|
87
|
+
}, options.pretty));
|
|
88
|
+
process.exit(1);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
catch (error) {
|
|
92
|
+
handleError(error);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
export async function logoutAction(options) {
|
|
96
|
+
try {
|
|
97
|
+
const credManager = new DiscordCredentialManager();
|
|
98
|
+
const config = await credManager.load();
|
|
99
|
+
if (!config.token) {
|
|
100
|
+
console.log(formatOutput({ error: 'Not authenticated. Run "auth extract" first.' }, options.pretty));
|
|
101
|
+
process.exit(1);
|
|
102
|
+
}
|
|
103
|
+
await credManager.clearToken();
|
|
104
|
+
console.log(formatOutput({ removed: 'discord', success: true }, options.pretty));
|
|
105
|
+
}
|
|
106
|
+
catch (error) {
|
|
107
|
+
handleError(error);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
export async function statusAction(options) {
|
|
111
|
+
try {
|
|
112
|
+
const credManager = new DiscordCredentialManager();
|
|
113
|
+
const config = await credManager.load();
|
|
114
|
+
if (!config.token) {
|
|
115
|
+
console.log(formatOutput({ error: 'Not authenticated. Run "auth extract" first.' }, options.pretty));
|
|
116
|
+
process.exit(1);
|
|
117
|
+
}
|
|
118
|
+
let authInfo = null;
|
|
119
|
+
let valid = false;
|
|
120
|
+
try {
|
|
121
|
+
const client = new DiscordClient(config.token);
|
|
122
|
+
authInfo = await client.testAuth();
|
|
123
|
+
valid = true;
|
|
124
|
+
}
|
|
125
|
+
catch {
|
|
126
|
+
valid = false;
|
|
127
|
+
}
|
|
128
|
+
const output = {
|
|
129
|
+
authenticated: valid,
|
|
130
|
+
user: authInfo?.username,
|
|
131
|
+
current_guild: config.current_guild,
|
|
132
|
+
guilds_count: Object.keys(config.guilds).length,
|
|
133
|
+
};
|
|
134
|
+
console.log(formatOutput(output, options.pretty));
|
|
135
|
+
}
|
|
136
|
+
catch (error) {
|
|
137
|
+
handleError(error);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
export const authCommand = new Command('auth')
|
|
141
|
+
.description('Authentication commands')
|
|
142
|
+
.addCommand(new Command('extract')
|
|
143
|
+
.description('Extract token from Discord desktop app')
|
|
144
|
+
.option('--pretty', 'Pretty print JSON output')
|
|
145
|
+
.option('--debug', 'Show debug output for troubleshooting')
|
|
146
|
+
.action(extractAction))
|
|
147
|
+
.addCommand(new Command('logout')
|
|
148
|
+
.description('Logout from Discord')
|
|
149
|
+
.option('--pretty', 'Pretty print JSON output')
|
|
150
|
+
.action(logoutAction))
|
|
151
|
+
.addCommand(new Command('status')
|
|
152
|
+
.description('Show authentication status')
|
|
153
|
+
.option('--pretty', 'Pretty print JSON output')
|
|
154
|
+
.action(statusAction));
|
|
155
|
+
//# sourceMappingURL=auth.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../../../../src/platforms/discord/commands/auth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,WAAW,EAAE,MAAM,qCAAqC,CAAA;AACjE,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAA;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAA;AACzC,OAAO,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,C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 @@
|
|
|
1
|
+
{"version":3,"file":"auth.test.d.ts","sourceRoot":"","sources":["../../../../../src/platforms/discord/commands/auth.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { expect, mock, test } from 'bun:test';
|
|
2
|
+
import { DiscordClient } from '../client';
|
|
3
|
+
import { DiscordCredentialManager } from '../credential-manager';
|
|
4
|
+
import { DiscordTokenExtractor } from '../token-extractor';
|
|
5
|
+
// Mock modules
|
|
6
|
+
mock.module('../token-extractor', () => ({
|
|
7
|
+
DiscordTokenExtractor: mock(() => ({
|
|
8
|
+
extract: mock(async () => ({
|
|
9
|
+
token: 'test-token-123',
|
|
10
|
+
})),
|
|
11
|
+
})),
|
|
12
|
+
}));
|
|
13
|
+
mock.module('../client', () => ({
|
|
14
|
+
DiscordClient: mock((_token) => ({
|
|
15
|
+
testAuth: mock(async () => ({
|
|
16
|
+
id: 'user-123',
|
|
17
|
+
username: 'testuser',
|
|
18
|
+
})),
|
|
19
|
+
listGuilds: mock(async () => [
|
|
20
|
+
{ id: 'guild-1', name: 'Guild One' },
|
|
21
|
+
{ id: 'guild-2', name: 'Guild Two' },
|
|
22
|
+
]),
|
|
23
|
+
})),
|
|
24
|
+
}));
|
|
25
|
+
mock.module('../credential-manager', () => ({
|
|
26
|
+
DiscordCredentialManager: mock(() => ({
|
|
27
|
+
load: mock(async () => ({
|
|
28
|
+
token: null,
|
|
29
|
+
current_guild: null,
|
|
30
|
+
guilds: {},
|
|
31
|
+
})),
|
|
32
|
+
save: mock(async () => { }),
|
|
33
|
+
clearToken: mock(async () => { }),
|
|
34
|
+
})),
|
|
35
|
+
}));
|
|
36
|
+
test('extract: calls DiscordTokenExtractor', async () => {
|
|
37
|
+
const extractor = new DiscordTokenExtractor();
|
|
38
|
+
const result = await extractor.extract();
|
|
39
|
+
expect(result).toBeDefined();
|
|
40
|
+
expect(result?.token).toBe('test-token-123');
|
|
41
|
+
});
|
|
42
|
+
test('extract: validates token with DiscordClient', async () => {
|
|
43
|
+
const client = new DiscordClient('test-token-123');
|
|
44
|
+
const authInfo = await client.testAuth();
|
|
45
|
+
expect(authInfo).toBeDefined();
|
|
46
|
+
expect(authInfo.id).toBe('user-123');
|
|
47
|
+
});
|
|
48
|
+
test('extract: discovers guilds', async () => {
|
|
49
|
+
const client = new DiscordClient('test-token-123');
|
|
50
|
+
const guilds = await client.listGuilds();
|
|
51
|
+
expect(guilds).toHaveLength(2);
|
|
52
|
+
expect(guilds[0].id).toBe('guild-1');
|
|
53
|
+
});
|
|
54
|
+
test('logout: clears credentials', async () => {
|
|
55
|
+
const credManager = new DiscordCredentialManager();
|
|
56
|
+
await credManager.clearToken();
|
|
57
|
+
expect(credManager.clearToken).toHaveBeenCalled();
|
|
58
|
+
});
|
|
59
|
+
test('status: returns auth state', async () => {
|
|
60
|
+
const credManager = new DiscordCredentialManager();
|
|
61
|
+
const config = await credManager.load();
|
|
62
|
+
expect(config.token).toBeNull();
|
|
63
|
+
expect(config.current_guild).toBeNull();
|
|
64
|
+
});
|
|
65
|
+
//# sourceMappingURL=auth.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.test.js","sourceRoot":"","sources":["../../../../../src/platforms/discord/commands/auth.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,UAAU,CAAA;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAA;AACzC,OAAO,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAA;AAChE,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAA;AAE1D,eAAe;AACf,IAAI,CAAC,MAAM,CAAC,oBAAoB,EAAE,GAAG,EAAE,CAAC,CAAC;IACvC,qBAAqB,EAAE,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC;QACjC,OAAO,EAAE,IAAI,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC;YACzB,KA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CAAC,KAAK,CAAC,CAAC,QAAQ,EAAE,CAAA;IAC/B,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,QAAQ,EAAE,CAAA;AACzC,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
export declare function listAction(options: {
|
|
3
|
+
pretty?: boolean;
|
|
4
|
+
}): Promise<void>;
|
|
5
|
+
export declare function infoAction(channelId: string, options: {
|
|
6
|
+
pretty?: boolean;
|
|
7
|
+
}): Promise<void>;
|
|
8
|
+
export declare function historyAction(channelId: string, options: {
|
|
9
|
+
limit?: number;
|
|
10
|
+
pretty?: boolean;
|
|
11
|
+
}): Promise<void>;
|
|
12
|
+
export declare const channelCommand: Command;
|
|
13
|
+
//# sourceMappingURL=channel.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"channel.d.ts","sourceRoot":"","sources":["../../../../../src/platforms/discord/commands/channel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAMnC,wBAAsB,UAAU,CAAC,OAAO,EAAE;IAAE,MAAM,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CA6B7E;AAED,wBAAsB,UAAU,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE;IAAE,MAAM,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CA4BhG;AAED,wBAAsB,aAAa,CACjC,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,OAAO,CAAA;CAAE,GAC5C,OAAO,CAAC,IAAI,CAAC,CA2Bf;AAED,eAAO,MAAM,cAAc,SA2BxB,CAAA"}
|
|
@@ -0,0 +1,99 @@
|
|
|
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
|
+
export async function listAction(options) {
|
|
7
|
+
try {
|
|
8
|
+
const credManager = new DiscordCredentialManager();
|
|
9
|
+
const config = await credManager.load();
|
|
10
|
+
if (!config.token || !config.current_guild) {
|
|
11
|
+
console.log(formatOutput({ error: 'Not authenticated. Run "auth extract" first.' }, options.pretty));
|
|
12
|
+
process.exit(1);
|
|
13
|
+
}
|
|
14
|
+
const client = new DiscordClient(config.token);
|
|
15
|
+
const channels = await client.listChannels(config.current_guild);
|
|
16
|
+
const textChannels = channels.filter((ch) => ch.type === 0);
|
|
17
|
+
const output = textChannels.map((ch) => ({
|
|
18
|
+
id: ch.id,
|
|
19
|
+
name: ch.name,
|
|
20
|
+
type: ch.type,
|
|
21
|
+
parent_id: ch.parent_id || null,
|
|
22
|
+
topic: ch.topic || null,
|
|
23
|
+
}));
|
|
24
|
+
console.log(formatOutput(output, options.pretty));
|
|
25
|
+
}
|
|
26
|
+
catch (error) {
|
|
27
|
+
handleError(error);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
export async function infoAction(channelId, options) {
|
|
31
|
+
try {
|
|
32
|
+
const credManager = new DiscordCredentialManager();
|
|
33
|
+
const config = await credManager.load();
|
|
34
|
+
if (!config.token) {
|
|
35
|
+
console.log(formatOutput({ error: 'Not authenticated. Run "auth extract" first.' }, options.pretty));
|
|
36
|
+
process.exit(1);
|
|
37
|
+
}
|
|
38
|
+
const client = new DiscordClient(config.token);
|
|
39
|
+
const channel = await client.getChannel(channelId);
|
|
40
|
+
const output = {
|
|
41
|
+
id: channel.id,
|
|
42
|
+
name: channel.name,
|
|
43
|
+
type: channel.type,
|
|
44
|
+
guild_id: channel.guild_id,
|
|
45
|
+
topic: channel.topic || null,
|
|
46
|
+
parent_id: channel.parent_id || null,
|
|
47
|
+
};
|
|
48
|
+
console.log(formatOutput(output, options.pretty));
|
|
49
|
+
}
|
|
50
|
+
catch (error) {
|
|
51
|
+
handleError(error);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
export async function historyAction(channelId, options) {
|
|
55
|
+
try {
|
|
56
|
+
const credManager = new DiscordCredentialManager();
|
|
57
|
+
const config = await credManager.load();
|
|
58
|
+
if (!config.token) {
|
|
59
|
+
console.log(formatOutput({ error: 'Not authenticated. Run "auth extract" first.' }, options.pretty));
|
|
60
|
+
process.exit(1);
|
|
61
|
+
}
|
|
62
|
+
const client = new DiscordClient(config.token);
|
|
63
|
+
const messages = await client.getMessages(channelId, options.limit || 50);
|
|
64
|
+
const output = messages.map((msg) => ({
|
|
65
|
+
id: msg.id,
|
|
66
|
+
author: msg.author.username,
|
|
67
|
+
content: msg.content,
|
|
68
|
+
timestamp: msg.timestamp,
|
|
69
|
+
thread_id: msg.thread_id || null,
|
|
70
|
+
}));
|
|
71
|
+
console.log(formatOutput(output, options.pretty));
|
|
72
|
+
}
|
|
73
|
+
catch (error) {
|
|
74
|
+
handleError(error);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
export const channelCommand = new Command('channel')
|
|
78
|
+
.description('Channel commands')
|
|
79
|
+
.addCommand(new Command('list')
|
|
80
|
+
.description('List channels in current guild')
|
|
81
|
+
.option('--pretty', 'Pretty print JSON output')
|
|
82
|
+
.action(listAction))
|
|
83
|
+
.addCommand(new Command('info')
|
|
84
|
+
.description('Get channel info')
|
|
85
|
+
.argument('<channel-id>', 'Channel ID')
|
|
86
|
+
.option('--pretty', 'Pretty print JSON output')
|
|
87
|
+
.action(infoAction))
|
|
88
|
+
.addCommand(new Command('history')
|
|
89
|
+
.description('Get channel message history')
|
|
90
|
+
.argument('<channel-id>', 'Channel ID')
|
|
91
|
+
.option('--limit <n>', 'Number of messages to fetch', '50')
|
|
92
|
+
.option('--pretty', 'Pretty print JSON output')
|
|
93
|
+
.action((channelId, options) => {
|
|
94
|
+
historyAction(channelId, {
|
|
95
|
+
limit: parseInt(options.limit, 10),
|
|
96
|
+
pretty: options.pretty,
|
|
97
|
+
});
|
|
98
|
+
}));
|
|
99
|
+
//# sourceMappingURL=channel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"channel.js","sourceRoot":"","sources":["../../../../../src/platforms/discord/commands/channel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,WAAW,EAAE,MAAM,qCAAqC,CAAA;AACjE,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAA;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAA;AACzC,OAAO,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAA;AAEhE,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,OAA6B;IAC5D,IAAI,CAAC;QACH,MAAM,WAAW,GAAG,IAAI,wBAAwB,EAAE,CAAA;QAClD,MAAM,MAAM,GAAG,MAAM,WAAW,CAAC,IAAI,EAAE,CAAA;QAEvC,IAAI,CAAC,MAAM,CAAC,KAAK,IAAI,CAAC,MAAM,CAAC,aAAa,EAAE,CAAC;YAC3C,OAAO,CAAC,GAAG,CACT,YAAY,CAAC,EAAE,KAAK,EAAE,8CAA8C,EAAE,EAAE,OAAO,CAAC,MAAM,CAAC,CACxF,CAAA;YACD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;QACjB,CAAC;QAED,MAAM,MAAM,GAAG,IAAI,aAAa,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;QAC9C,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,YAAY,CAAC,MAAM,CAAC,aAAa,CAAC,CAAA;QAEhE,MAAM,YAAY,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,IAAI,KAAK,CAAC,CAAC,CAAA;QAE3D,M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YAAY,CAAC,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,CAAA;IACnD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,WAAW,CAAC,KAAc,CAAC,CAAA;IAC7B,CAAC;AACH,CAAC;AAED,MAAM,CAAC,MAAM,cAAc,GAAG,IAAI,OAAO,CAAC,SAAS,CAAC;KACjD,WAAW,CAAC,kBAAkB,CAAC;KAC/B,UAAU,CACT,IAAI,OAAO,CAAC,MAAM,CAAC;KAChB,WAAW,CAAC,gCAAgC,CAAC;KAC7C,MAAM,CAAC,UAAU,EAAE,0BAA0B,CAAC;KAC9C,MAAM,CAAC,UAAU,CAAC,CACtB;KACA,UAAU,CACT,IAAI,OAAO,CAAC,MAAM,CAAC;KAChB,WAAW,CAAC,kBAAkB,CAAC;KAC/B,QAAQ,CAAC,cAAc,EAAE,YAAY,CAAC;KACtC,MAAM,CAAC,UAAU,EAAE,0BAA0B,CAAC;KAC9C,MAAM,CAAC,UAAU,CAAC,CACtB;KACA,UAAU,CACT,IAAI,OAAO,CAAC,SAAS,CAAC;KACnB,WAAW,CAAC,6BAA6B,CAAC;KAC1C,QAAQ,CAAC,cAAc,EAAE,YAAY,CAAC;KACtC,MAAM,CAAC,aAAa,EAAE,6BAA6B,EAAE,IAAI,CAAC;KAC1D,MAAM,CAAC,UAAU,EAAE,0BAA0B,CAAC;KAC9C,MAAM,CAAC,CAAC,SAAS,EAAE,OAAO,EAAE,EAAE;IAC7B,aAAa,CAAC,SAAS,EAAE;QACvB,KAAK,EAAE,QAAQ,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC;QAClC,MAAM,EAAE,OAAO,CAAC,MAAM;KACvB,CAAC,CAAA;AACJ,CAAC,CAAC,CACL,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"channel.test.d.ts","sourceRoot":"","sources":["../../../../../src/platforms/discord/commands/channel.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { expect, mock, test } from 'bun:test';
|
|
2
|
+
import { DiscordClient } from '../client';
|
|
3
|
+
// Mock modules
|
|
4
|
+
mock.module('../client', () => ({
|
|
5
|
+
DiscordClient: mock((_token) => ({
|
|
6
|
+
listChannels: mock(async (guildId) => [
|
|
7
|
+
{ id: 'ch-1', guild_id: guildId, name: 'general', type: 0, topic: 'General discussion' },
|
|
8
|
+
{ id: 'ch-2', guild_id: guildId, name: 'announcements', type: 0, topic: 'Announcements' },
|
|
9
|
+
{ id: 'ch-3', guild_id: guildId, name: 'voice-channel', type: 2, topic: null },
|
|
10
|
+
]),
|
|
11
|
+
getChannel: mock(async (channelId) => {
|
|
12
|
+
if (channelId === 'ch-1') {
|
|
13
|
+
return {
|
|
14
|
+
id: 'ch-1',
|
|
15
|
+
guild_id: 'guild-1',
|
|
16
|
+
name: 'general',
|
|
17
|
+
type: 0,
|
|
18
|
+
topic: 'General discussion',
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
if (channelId === 'ch-2') {
|
|
22
|
+
return {
|
|
23
|
+
id: 'ch-2',
|
|
24
|
+
guild_id: 'guild-1',
|
|
25
|
+
name: 'announcements',
|
|
26
|
+
type: 0,
|
|
27
|
+
topic: 'Announcements',
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
throw new Error('Channel not found');
|
|
31
|
+
}),
|
|
32
|
+
getMessages: mock(async (channelId, _limit) => [
|
|
33
|
+
{
|
|
34
|
+
id: 'msg-1',
|
|
35
|
+
channel_id: channelId,
|
|
36
|
+
author: { id: 'user-1', username: 'alice' },
|
|
37
|
+
content: 'Hello world',
|
|
38
|
+
timestamp: '2024-01-29T10:00:00Z',
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
id: 'msg-2',
|
|
42
|
+
channel_id: channelId,
|
|
43
|
+
author: { id: 'user-2', username: 'bob' },
|
|
44
|
+
content: 'Hi there',
|
|
45
|
+
timestamp: '2024-01-29T09:00:00Z',
|
|
46
|
+
},
|
|
47
|
+
]),
|
|
48
|
+
})),
|
|
49
|
+
}));
|
|
50
|
+
mock.module('../credential-manager', () => ({
|
|
51
|
+
DiscordCredentialManager: mock(() => ({
|
|
52
|
+
load: mock(async () => ({
|
|
53
|
+
token: 'test-token',
|
|
54
|
+
current_guild: 'guild-1',
|
|
55
|
+
guilds: {
|
|
56
|
+
'guild-1': { guild_id: 'guild-1', guild_name: 'Guild One' },
|
|
57
|
+
},
|
|
58
|
+
})),
|
|
59
|
+
})),
|
|
60
|
+
}));
|
|
61
|
+
test('list: returns text channels (type=0) from guild', async () => {
|
|
62
|
+
// given: discord client with channels
|
|
63
|
+
const client = new DiscordClient('test-token');
|
|
64
|
+
const channels = await client.listChannels('guild-1');
|
|
65
|
+
// when: filtering text channels
|
|
66
|
+
const textChannels = channels.filter((ch) => ch.type === 0);
|
|
67
|
+
// then: only text channels are returned
|
|
68
|
+
expect(textChannels).toHaveLength(2);
|
|
69
|
+
expect(textChannels[0].name).toBe('general');
|
|
70
|
+
expect(textChannels[1].name).toBe('announcements');
|
|
71
|
+
});
|
|
72
|
+
test('list: includes channel metadata', async () => {
|
|
73
|
+
// given: discord client with channels
|
|
74
|
+
const client = new DiscordClient('test-token');
|
|
75
|
+
const channels = await client.listChannels('guild-1');
|
|
76
|
+
const textChannels = channels.filter((ch) => ch.type === 0);
|
|
77
|
+
// when: checking channel properties
|
|
78
|
+
const channel = textChannels[0];
|
|
79
|
+
// then: channel has id, name, type, topic
|
|
80
|
+
expect(channel.id).toBeDefined();
|
|
81
|
+
expect(channel.name).toBeDefined();
|
|
82
|
+
expect(channel.type).toBe(0);
|
|
83
|
+
expect(channel.topic).toBeDefined();
|
|
84
|
+
});
|
|
85
|
+
test('info: returns channel details', async () => {
|
|
86
|
+
// given: discord client with channel data
|
|
87
|
+
const client = new DiscordClient('test-token');
|
|
88
|
+
const channel = await client.getChannel('ch-1');
|
|
89
|
+
// when: getting channel info
|
|
90
|
+
expect(channel).toBeDefined();
|
|
91
|
+
// then: channel details are returned
|
|
92
|
+
expect(channel.id).toBe('ch-1');
|
|
93
|
+
expect(channel.name).toBe('general');
|
|
94
|
+
expect(channel.type).toBe(0);
|
|
95
|
+
expect(channel.topic).toBe('General discussion');
|
|
96
|
+
});
|
|
97
|
+
test('info: throws error for non-existent channel', async () => {
|
|
98
|
+
// given: discord client
|
|
99
|
+
const client = new DiscordClient('test-token');
|
|
100
|
+
// when: getting non-existent channel
|
|
101
|
+
// then: error is thrown
|
|
102
|
+
try {
|
|
103
|
+
await client.getChannel('non-existent');
|
|
104
|
+
expect(true).toBe(false); // should not reach here
|
|
105
|
+
}
|
|
106
|
+
catch (error) {
|
|
107
|
+
expect(error.message).toContain('Channel not found');
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
test('history: returns messages in reverse chronological order', async () => {
|
|
111
|
+
// given: discord client with messages
|
|
112
|
+
const client = new DiscordClient('test-token');
|
|
113
|
+
const messages = await client.getMessages('ch-1', 50);
|
|
114
|
+
// when: getting message history
|
|
115
|
+
expect(messages).toBeDefined();
|
|
116
|
+
// then: messages are returned (Discord API returns newest first)
|
|
117
|
+
expect(messages).toHaveLength(2);
|
|
118
|
+
expect(messages[0].id).toBe('msg-1');
|
|
119
|
+
expect(messages[0].author.username).toBe('alice');
|
|
120
|
+
expect(messages[1].id).toBe('msg-2');
|
|
121
|
+
expect(messages[1].author.username).toBe('bob');
|
|
122
|
+
});
|
|
123
|
+
test('history: includes message metadata', async () => {
|
|
124
|
+
// given: discord client with messages
|
|
125
|
+
const client = new DiscordClient('test-token');
|
|
126
|
+
const messages = await client.getMessages('ch-1', 50);
|
|
127
|
+
// when: checking message properties
|
|
128
|
+
const message = messages[0];
|
|
129
|
+
// then: message has id, content, author, timestamp
|
|
130
|
+
expect(message.id).toBeDefined();
|
|
131
|
+
expect(message.content).toBeDefined();
|
|
132
|
+
expect(message.author).toBeDefined();
|
|
133
|
+
expect(message.author.username).toBeDefined();
|
|
134
|
+
expect(message.timestamp).toBeDefined();
|
|
135
|
+
});
|
|
136
|
+
//# sourceMappingURL=channel.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"channel.test.js","sourceRoot":"","sources":["../../../../../src/platforms/discord/commands/channel.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,UAAU,CAAA;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAA;AAEzC,eAAe;AACf,IAAI,CAAC,MAAM,CAAC,WAAW,EAAE,GAAG,EAAE,CAAC,CAAC;IAC9B,aAAa,EAAE,IAAI,CAAC,CAAC,MAAc,EAAE,EAAE,CAAC,CAAC;QACvC,YAAY,EAAE,IAAI,CAAC,KAAK,EAAE,OAAe,EAAE,EAAE,CAAC;YAC5C,EAAE,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,oBAAoB,EAAE;YACxF,EAAE,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,eAAe,EAAE,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,eAAe,EAAE;YACzF,EAAE,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,eAAe,EAAE,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE;SAC/E,CAAC;QACF,UAAU,EAAE,IAAI,CAAC,KAAK,EAAE,SAAiB,EAAE,EAAE;YAC3C,IAAI,SAAS,KAAK,MAAM,EAAE,CAAC;gBACzB,OAAO;oBACL,EAAE,EAAE,MAAM;oBACV,QAAQ,EAAE,SAAS;oBACnB,IAAI,EAAE,SAAS;oBACf,IAAI,EAAE,CAAC;oBACP,KAAK,EAAE,oBAAoB;iBAC5B,CAAA;YACH,CAAC;YACD,IAAI,SAAS,KAAK,MAAM,EAAE,C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C,CAAC,WAAW,EAAE,CAAA;IAC7C,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,WAAW,EAAE,CAAA;AACzC,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
export declare function uploadAction(channelId: string, path: string, options: {
|
|
3
|
+
filename?: string;
|
|
4
|
+
pretty?: boolean;
|
|
5
|
+
}): Promise<void>;
|
|
6
|
+
export declare function listAction(channelId: string, options: {
|
|
7
|
+
pretty?: boolean;
|
|
8
|
+
}): Promise<void>;
|
|
9
|
+
export declare function infoAction(channelId: string, fileId: string, options: {
|
|
10
|
+
pretty?: boolean;
|
|
11
|
+
}): Promise<void>;
|
|
12
|
+
export declare const fileCommand: Command;
|
|
13
|
+
//# sourceMappingURL=file.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file.d.ts","sourceRoot":"","sources":["../../../../../src/platforms/discord/commands/file.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAOnC,wBAAsB,YAAY,CAChC,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE;IAAE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,OAAO,CAAA;CAAE,GAC/C,OAAO,CAAC,IAAI,CAAC,CA6Bf;AAED,wBAAsB,UAAU,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE;IAAE,MAAM,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CA2BhG;AAED,wBAAsB,UAAU,CAC9B,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,MAAM,EACd,OAAO,EAAE;IAAE,MAAM,CAAC,EAAE,OAAO,CAAA;CAAE,GAC5B,OAAO,CAAC,IAAI,CAAC,CAiCf;AAED,eAAO,MAAM,WAAW,SAsBrB,CAAA"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { resolve } from 'node:path';
|
|
2
|
+
import { Command } from 'commander';
|
|
3
|
+
import { handleError } from '../../../shared/utils/error-handler';
|
|
4
|
+
import { formatOutput } from '../../../shared/utils/output';
|
|
5
|
+
import { DiscordClient } from '../client';
|
|
6
|
+
import { DiscordCredentialManager } from '../credential-manager';
|
|
7
|
+
export async function uploadAction(channelId, path, options) {
|
|
8
|
+
try {
|
|
9
|
+
const credManager = new DiscordCredentialManager();
|
|
10
|
+
const config = await credManager.load();
|
|
11
|
+
if (!config.token) {
|
|
12
|
+
console.log(formatOutput({ error: 'Not authenticated. Run "auth extract" first.' }, options.pretty));
|
|
13
|
+
process.exit(1);
|
|
14
|
+
}
|
|
15
|
+
const client = new DiscordClient(config.token);
|
|
16
|
+
const filePath = resolve(path);
|
|
17
|
+
const file = await client.uploadFile(channelId, filePath);
|
|
18
|
+
const output = {
|
|
19
|
+
id: file.id,
|
|
20
|
+
filename: file.filename,
|
|
21
|
+
size: file.size,
|
|
22
|
+
url: file.url,
|
|
23
|
+
content_type: file.content_type || null,
|
|
24
|
+
};
|
|
25
|
+
console.log(formatOutput(output, options.pretty));
|
|
26
|
+
}
|
|
27
|
+
catch (error) {
|
|
28
|
+
handleError(error);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
export async function listAction(channelId, options) {
|
|
32
|
+
try {
|
|
33
|
+
const credManager = new DiscordCredentialManager();
|
|
34
|
+
const config = await credManager.load();
|
|
35
|
+
if (!config.token) {
|
|
36
|
+
console.log(formatOutput({ error: 'Not authenticated. Run "auth extract" first.' }, options.pretty));
|
|
37
|
+
process.exit(1);
|
|
38
|
+
}
|
|
39
|
+
const client = new DiscordClient(config.token);
|
|
40
|
+
const files = await client.listFiles(channelId);
|
|
41
|
+
const output = files.map((file) => ({
|
|
42
|
+
id: file.id,
|
|
43
|
+
filename: file.filename,
|
|
44
|
+
size: file.size,
|
|
45
|
+
url: file.url,
|
|
46
|
+
content_type: file.content_type || null,
|
|
47
|
+
}));
|
|
48
|
+
console.log(formatOutput(output, options.pretty));
|
|
49
|
+
}
|
|
50
|
+
catch (error) {
|
|
51
|
+
handleError(error);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
export async function infoAction(channelId, fileId, options) {
|
|
55
|
+
try {
|
|
56
|
+
const credManager = new DiscordCredentialManager();
|
|
57
|
+
const config = await credManager.load();
|
|
58
|
+
if (!config.token) {
|
|
59
|
+
console.log(formatOutput({ error: 'Not authenticated. Run "auth extract" first.' }, options.pretty));
|
|
60
|
+
process.exit(1);
|
|
61
|
+
}
|
|
62
|
+
const client = new DiscordClient(config.token);
|
|
63
|
+
const files = await client.listFiles(channelId);
|
|
64
|
+
const fileData = files.find((f) => f.id === fileId);
|
|
65
|
+
if (!fileData) {
|
|
66
|
+
console.log(formatOutput({ error: `File not found: ${fileId}` }, options.pretty));
|
|
67
|
+
process.exit(1);
|
|
68
|
+
}
|
|
69
|
+
const output = {
|
|
70
|
+
id: fileData.id,
|
|
71
|
+
filename: fileData.filename,
|
|
72
|
+
size: fileData.size,
|
|
73
|
+
url: fileData.url,
|
|
74
|
+
content_type: fileData.content_type || null,
|
|
75
|
+
};
|
|
76
|
+
console.log(formatOutput(output, options.pretty));
|
|
77
|
+
}
|
|
78
|
+
catch (error) {
|
|
79
|
+
handleError(error);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
export const fileCommand = new Command('file')
|
|
83
|
+
.description('file commands')
|
|
84
|
+
.addCommand(new Command('upload')
|
|
85
|
+
.description('upload file to channel')
|
|
86
|
+
.argument('<channel>', 'channel ID')
|
|
87
|
+
.argument('<path>', 'file path')
|
|
88
|
+
.option('--filename <name>', 'override filename')
|
|
89
|
+
.action(uploadAction))
|
|
90
|
+
.addCommand(new Command('list')
|
|
91
|
+
.description('list files in channel')
|
|
92
|
+
.argument('<channel>', 'channel ID')
|
|
93
|
+
.action(listAction))
|
|
94
|
+
.addCommand(new Command('info')
|
|
95
|
+
.description('show file details')
|
|
96
|
+
.argument('<channel>', 'channel ID')
|
|
97
|
+
.argument('<file>', 'file ID')
|
|
98
|
+
.action(infoAction));
|
|
99
|
+
//# sourceMappingURL=file.js.map
|