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,527 @@
|
|
|
1
|
+
# Common Patterns
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
This guide covers typical workflows for AI agents interacting with Slack using agent-slack.
|
|
6
|
+
|
|
7
|
+
## Pattern 1: Send a Simple Message
|
|
8
|
+
|
|
9
|
+
**Use case**: Post a notification or update to a channel
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
#!/bin/bash
|
|
13
|
+
|
|
14
|
+
# Direct approach - use channel name
|
|
15
|
+
agent-slack message send general "Deployment completed successfully!"
|
|
16
|
+
|
|
17
|
+
# With error handling
|
|
18
|
+
RESULT=$(agent-slack message send general "Hello world")
|
|
19
|
+
if echo "$RESULT" | jq -e '.success' > /dev/null; then
|
|
20
|
+
echo "Message sent!"
|
|
21
|
+
else
|
|
22
|
+
echo "Failed: $(echo "$RESULT" | jq -r '.error.message')"
|
|
23
|
+
exit 1
|
|
24
|
+
fi
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
**When to use**: Simple one-off messages where you know the channel name.
|
|
28
|
+
|
|
29
|
+
## Pattern 2: Monitor Channel for New Messages
|
|
30
|
+
|
|
31
|
+
**Use case**: Watch a channel and respond to new messages
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
#!/bin/bash
|
|
35
|
+
|
|
36
|
+
CHANNEL="general"
|
|
37
|
+
LAST_TS=""
|
|
38
|
+
|
|
39
|
+
while true; do
|
|
40
|
+
# Get latest message
|
|
41
|
+
MESSAGES=$(agent-slack message list "$CHANNEL" --limit 1)
|
|
42
|
+
LATEST_TS=$(echo "$MESSAGES" | jq -r '.data.messages[0].ts')
|
|
43
|
+
|
|
44
|
+
# Check if new message
|
|
45
|
+
if [ "$LATEST_TS" != "$LAST_TS" ] && [ -n "$LAST_TS" ]; then
|
|
46
|
+
TEXT=$(echo "$MESSAGES" | jq -r '.data.messages[0].text')
|
|
47
|
+
USER=$(echo "$MESSAGES" | jq -r '.data.messages[0].user')
|
|
48
|
+
|
|
49
|
+
echo "New message from $USER: $TEXT"
|
|
50
|
+
|
|
51
|
+
# Process message here
|
|
52
|
+
# Example: Respond to mentions
|
|
53
|
+
if echo "$TEXT" | grep -q "@bot"; then
|
|
54
|
+
agent-slack message send "$CHANNEL" "You called?" --thread "$LATEST_TS"
|
|
55
|
+
fi
|
|
56
|
+
fi
|
|
57
|
+
|
|
58
|
+
LAST_TS="$LATEST_TS"
|
|
59
|
+
sleep 5
|
|
60
|
+
done
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
**When to use**: Building a simple bot that reacts to messages.
|
|
64
|
+
|
|
65
|
+
**Limitations**: Polling-based, not real-time. For production bots, use Slack's Events API.
|
|
66
|
+
|
|
67
|
+
## Pattern 3: Get Workspace Overview
|
|
68
|
+
|
|
69
|
+
**Use case**: Understand workspace state before taking action
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
#!/bin/bash
|
|
73
|
+
|
|
74
|
+
# Get full snapshot
|
|
75
|
+
SNAPSHOT=$(agent-slack snapshot)
|
|
76
|
+
|
|
77
|
+
# Extract key information
|
|
78
|
+
WORKSPACE_NAME=$(echo "$SNAPSHOT" | jq -r '.data.workspace.name')
|
|
79
|
+
CHANNEL_COUNT=$(echo "$SNAPSHOT" | jq -r '.data.channels | length')
|
|
80
|
+
USER_COUNT=$(echo "$SNAPSHOT" | jq -r '.data.users | length')
|
|
81
|
+
|
|
82
|
+
echo "Workspace: $WORKSPACE_NAME"
|
|
83
|
+
echo "Channels: $CHANNEL_COUNT"
|
|
84
|
+
echo "Users: $USER_COUNT"
|
|
85
|
+
|
|
86
|
+
# List all channels
|
|
87
|
+
echo -e "\nChannels:"
|
|
88
|
+
echo "$SNAPSHOT" | jq -r '.channels[] | " \(.name) (\(.id))"'
|
|
89
|
+
|
|
90
|
+
# List recent activity
|
|
91
|
+
echo -e "\nRecent messages:"
|
|
92
|
+
echo "$SNAPSHOT" | jq -r '.data.messages[] | " \(.channel_name): \(.text[0:50])"'
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
**When to use**: Initial context gathering, status reports, workspace summaries.
|
|
96
|
+
|
|
97
|
+
## Pattern 4: Thread Conversation
|
|
98
|
+
|
|
99
|
+
**Use case**: Reply to a message in a thread
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
#!/bin/bash
|
|
103
|
+
|
|
104
|
+
CHANNEL="general"
|
|
105
|
+
|
|
106
|
+
# Send initial message
|
|
107
|
+
RESULT=$(agent-slack message send "$CHANNEL" "Starting deployment...")
|
|
108
|
+
THREAD_TS=$(echo "$RESULT" | jq -r '.data.ts')
|
|
109
|
+
|
|
110
|
+
# Send updates in thread
|
|
111
|
+
agent-slack message send "$CHANNEL" "Building application..." --thread "$THREAD_TS"
|
|
112
|
+
sleep 2
|
|
113
|
+
agent-slack message send "$CHANNEL" "Running tests..." --thread "$THREAD_TS"
|
|
114
|
+
sleep 2
|
|
115
|
+
agent-slack message send "$CHANNEL" "Deploying to production..." --thread "$THREAD_TS"
|
|
116
|
+
sleep 2
|
|
117
|
+
agent-slack message send "$CHANNEL" "✅ Deployment complete!" --thread "$THREAD_TS"
|
|
118
|
+
|
|
119
|
+
# Add reaction to parent message
|
|
120
|
+
agent-slack reaction add "$CHANNEL" "$THREAD_TS" white_check_mark
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
**When to use**: Multi-step processes, progress updates, keeping related messages together.
|
|
124
|
+
|
|
125
|
+
## Pattern 5: Search and Respond
|
|
126
|
+
|
|
127
|
+
**Use case**: Find specific messages and take action
|
|
128
|
+
|
|
129
|
+
```bash
|
|
130
|
+
#!/bin/bash
|
|
131
|
+
|
|
132
|
+
CHANNEL="support"
|
|
133
|
+
|
|
134
|
+
# Get recent messages
|
|
135
|
+
MESSAGES=$(agent-slack message list "$CHANNEL" --limit 50)
|
|
136
|
+
|
|
137
|
+
# Find messages containing "urgent"
|
|
138
|
+
URGENT_MESSAGES=$(echo "$MESSAGES" | jq -r '.data.messages[] | select(.text | contains("urgent"))')
|
|
139
|
+
|
|
140
|
+
# Process each urgent message
|
|
141
|
+
echo "$URGENT_MESSAGES" | jq -c '.' | while read -r msg; do
|
|
142
|
+
TS=$(echo "$msg" | jq -r '.ts')
|
|
143
|
+
TEXT=$(echo "$msg" | jq -r '.text')
|
|
144
|
+
USER=$(echo "$msg" | jq -r '.user')
|
|
145
|
+
|
|
146
|
+
echo "Found urgent message from $USER: $TEXT"
|
|
147
|
+
|
|
148
|
+
# Add eyes reaction to acknowledge
|
|
149
|
+
agent-slack reaction add "$CHANNEL" "$TS" eyes
|
|
150
|
+
|
|
151
|
+
# Reply in thread
|
|
152
|
+
agent-slack message send "$CHANNEL" "I've flagged this for the team!" --thread "$TS"
|
|
153
|
+
done
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
**When to use**: Automated triage, keyword monitoring, support automation.
|
|
157
|
+
|
|
158
|
+
## Pattern 6: Multi-Channel Broadcast
|
|
159
|
+
|
|
160
|
+
**Use case**: Send the same message to multiple channels
|
|
161
|
+
|
|
162
|
+
```bash
|
|
163
|
+
#!/bin/bash
|
|
164
|
+
|
|
165
|
+
MESSAGE="🚨 System maintenance in 30 minutes"
|
|
166
|
+
CHANNELS=("general" "engineering" "ops")
|
|
167
|
+
|
|
168
|
+
for channel in "${CHANNELS[@]}"; do
|
|
169
|
+
echo "Posting to #$channel..."
|
|
170
|
+
RESULT=$(agent-slack message send "$channel" "$MESSAGE")
|
|
171
|
+
|
|
172
|
+
if echo "$RESULT" | jq -e '.success' > /dev/null; then
|
|
173
|
+
echo " ✓ Posted to #$channel"
|
|
174
|
+
else
|
|
175
|
+
echo " ✗ Failed to post to #$channel"
|
|
176
|
+
fi
|
|
177
|
+
|
|
178
|
+
# Rate limit: Don't spam Slack API
|
|
179
|
+
sleep 1
|
|
180
|
+
done
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
**When to use**: Announcements, alerts, status updates across teams.
|
|
184
|
+
|
|
185
|
+
## Pattern 7: File Upload with Context
|
|
186
|
+
|
|
187
|
+
**Use case**: Share a file with explanation
|
|
188
|
+
|
|
189
|
+
```bash
|
|
190
|
+
#!/bin/bash
|
|
191
|
+
|
|
192
|
+
CHANNEL="engineering"
|
|
193
|
+
REPORT_FILE="./daily-report.pdf"
|
|
194
|
+
|
|
195
|
+
# Upload file
|
|
196
|
+
UPLOAD_RESULT=$(agent-slack file upload "$CHANNEL" "$REPORT_FILE")
|
|
197
|
+
|
|
198
|
+
if echo "$UPLOAD_RESULT" | jq -e '.success' > /dev/null; then
|
|
199
|
+
FILE_ID=$(echo "$UPLOAD_RESULT" | jq -r '.data.id')
|
|
200
|
+
echo "File uploaded: $FILE_ID"
|
|
201
|
+
|
|
202
|
+
# Send context message
|
|
203
|
+
agent-slack message send "$CHANNEL" "📊 Daily report is ready! Key highlights:
|
|
204
|
+
• 95% test coverage
|
|
205
|
+
• 3 bugs fixed
|
|
206
|
+
• 2 new features deployed"
|
|
207
|
+
else
|
|
208
|
+
echo "Upload failed: $(echo "$UPLOAD_RESULT" | jq -r '.error.message')"
|
|
209
|
+
exit 1
|
|
210
|
+
fi
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
**When to use**: Automated reporting, log sharing, artifact distribution.
|
|
214
|
+
|
|
215
|
+
## Pattern 8: User Lookup and Mention
|
|
216
|
+
|
|
217
|
+
**Use case**: Find a user and mention them in a message
|
|
218
|
+
|
|
219
|
+
```bash
|
|
220
|
+
#!/bin/bash
|
|
221
|
+
|
|
222
|
+
CHANNEL="general"
|
|
223
|
+
USERNAME="john.doe"
|
|
224
|
+
|
|
225
|
+
# Get user info
|
|
226
|
+
USERS=$(agent-slack user list)
|
|
227
|
+
USER_ID=$(echo "$USERS" | jq -r ".data.users[] | select(.name==\"$USERNAME\") | .id")
|
|
228
|
+
|
|
229
|
+
if [ -z "$USER_ID" ]; then
|
|
230
|
+
echo "User $USERNAME not found"
|
|
231
|
+
exit 1
|
|
232
|
+
fi
|
|
233
|
+
|
|
234
|
+
# Send message with mention
|
|
235
|
+
agent-slack message send "$CHANNEL" "Hey <@$USER_ID>, the build is ready for review!"
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
**When to use**: Notifications, task assignments, code review requests.
|
|
239
|
+
|
|
240
|
+
**Note**: Slack mentions require actual user IDs (e.g., `<@U06WXYZ5678>`).
|
|
241
|
+
|
|
242
|
+
## Pattern 9: Reaction-Based Workflow
|
|
243
|
+
|
|
244
|
+
**Use case**: Use reactions as simple state indicators
|
|
245
|
+
|
|
246
|
+
```bash
|
|
247
|
+
#!/bin/bash
|
|
248
|
+
|
|
249
|
+
CHANNEL="deployments"
|
|
250
|
+
|
|
251
|
+
# Send deployment message
|
|
252
|
+
RESULT=$(agent-slack message send "$CHANNEL" "Deploying v2.1.0 to production...")
|
|
253
|
+
MSG_TS=$(echo "$RESULT" | jq -r '.data.ts')
|
|
254
|
+
|
|
255
|
+
# Mark as in-progress
|
|
256
|
+
agent-slack reaction add "$CHANNEL" "$MSG_TS" hourglass_flowing_sand
|
|
257
|
+
|
|
258
|
+
# Simulate deployment
|
|
259
|
+
sleep 5
|
|
260
|
+
|
|
261
|
+
# Remove in-progress, add success
|
|
262
|
+
agent-slack reaction remove "$CHANNEL" "$MSG_TS" hourglass_flowing_sand
|
|
263
|
+
agent-slack reaction add "$CHANNEL" "$MSG_TS" white_check_mark
|
|
264
|
+
|
|
265
|
+
# Update message
|
|
266
|
+
agent-slack message update "$CHANNEL" "$MSG_TS" "✅ Deployed v2.1.0 to production successfully!"
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
**When to use**: Visual status tracking, workflow states, quick acknowledgments.
|
|
270
|
+
|
|
271
|
+
## Pattern 10: Error Handling and Retry
|
|
272
|
+
|
|
273
|
+
**Use case**: Robust message sending with retries
|
|
274
|
+
|
|
275
|
+
```bash
|
|
276
|
+
#!/bin/bash
|
|
277
|
+
|
|
278
|
+
send_with_retry() {
|
|
279
|
+
local channel=$1
|
|
280
|
+
local message=$2
|
|
281
|
+
local max_attempts=3
|
|
282
|
+
local attempt=1
|
|
283
|
+
|
|
284
|
+
while [ $attempt -le $max_attempts ]; do
|
|
285
|
+
echo "Attempt $attempt/$max_attempts..."
|
|
286
|
+
|
|
287
|
+
RESULT=$(agent-slack message send "$channel" "$message")
|
|
288
|
+
|
|
289
|
+
if echo "$RESULT" | jq -e '.success' > /dev/null; then
|
|
290
|
+
echo "Message sent successfully!"
|
|
291
|
+
return 0
|
|
292
|
+
fi
|
|
293
|
+
|
|
294
|
+
ERROR_CODE=$(echo "$RESULT" | jq -r '.error.code')
|
|
295
|
+
|
|
296
|
+
# Don't retry on certain errors
|
|
297
|
+
if [ "$ERROR_CODE" = "INVALID_CHANNEL" ]; then
|
|
298
|
+
echo "Channel not found - not retrying"
|
|
299
|
+
return 1
|
|
300
|
+
fi
|
|
301
|
+
|
|
302
|
+
echo "Failed: $(echo "$RESULT" | jq -r '.error.message')"
|
|
303
|
+
|
|
304
|
+
if [ $attempt -lt $max_attempts ]; then
|
|
305
|
+
sleep $((attempt * 2)) # Exponential backoff
|
|
306
|
+
fi
|
|
307
|
+
|
|
308
|
+
attempt=$((attempt + 1))
|
|
309
|
+
done
|
|
310
|
+
|
|
311
|
+
echo "Failed after $max_attempts attempts"
|
|
312
|
+
return 1
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
# Usage
|
|
316
|
+
send_with_retry "general" "Important message!"
|
|
317
|
+
```
|
|
318
|
+
|
|
319
|
+
**When to use**: Production scripts, critical notifications, unreliable networks.
|
|
320
|
+
|
|
321
|
+
## Pattern 11: Daily Digest
|
|
322
|
+
|
|
323
|
+
**Use case**: Summarize channel activity
|
|
324
|
+
|
|
325
|
+
```bash
|
|
326
|
+
#!/bin/bash
|
|
327
|
+
|
|
328
|
+
CHANNEL="engineering"
|
|
329
|
+
HOURS_AGO=24
|
|
330
|
+
|
|
331
|
+
# Calculate timestamp for 24 hours ago
|
|
332
|
+
OLDEST_TS=$(date -u -v-${HOURS_AGO}H +%s)
|
|
333
|
+
|
|
334
|
+
# Get messages
|
|
335
|
+
MESSAGES=$(agent-slack message list "$CHANNEL" --limit 100)
|
|
336
|
+
|
|
337
|
+
# Filter messages from last 24 hours
|
|
338
|
+
RECENT=$(echo "$MESSAGES" | jq --arg oldest "$OLDEST_TS" '
|
|
339
|
+
.data.messages[] |
|
|
340
|
+
select((.ts | tonumber) > ($oldest | tonumber))
|
|
341
|
+
')
|
|
342
|
+
|
|
343
|
+
# Count messages
|
|
344
|
+
MSG_COUNT=$(echo "$RECENT" | jq -s 'length')
|
|
345
|
+
|
|
346
|
+
# Count unique users
|
|
347
|
+
USER_COUNT=$(echo "$RECENT" | jq -s '[.[].user] | unique | length')
|
|
348
|
+
|
|
349
|
+
# Build digest
|
|
350
|
+
DIGEST="📊 Daily Digest for #$CHANNEL
|
|
351
|
+
|
|
352
|
+
Messages: $MSG_COUNT
|
|
353
|
+
Active users: $USER_COUNT
|
|
354
|
+
|
|
355
|
+
Top messages:"
|
|
356
|
+
|
|
357
|
+
# Add top 3 messages
|
|
358
|
+
TOP_MESSAGES=$(echo "$RECENT" | jq -s 'sort_by(.reaction_count) | reverse | .[0:3]')
|
|
359
|
+
|
|
360
|
+
echo "$TOP_MESSAGES" | jq -r '.[] | "• \(.text[0:100])"' | while read -r line; do
|
|
361
|
+
DIGEST="$DIGEST
|
|
362
|
+
$line"
|
|
363
|
+
done
|
|
364
|
+
|
|
365
|
+
# Send digest
|
|
366
|
+
agent-slack message send "$CHANNEL" "$DIGEST"
|
|
367
|
+
```
|
|
368
|
+
|
|
369
|
+
**When to use**: Daily summaries, activity reports, team updates.
|
|
370
|
+
|
|
371
|
+
## Pattern 12: Conditional Messaging
|
|
372
|
+
|
|
373
|
+
**Use case**: Send message only if condition is met
|
|
374
|
+
|
|
375
|
+
```bash
|
|
376
|
+
#!/bin/bash
|
|
377
|
+
|
|
378
|
+
CHANNEL="alerts"
|
|
379
|
+
|
|
380
|
+
# Check some condition (e.g., disk space)
|
|
381
|
+
DISK_USAGE=$(df -h / | awk 'NR==2 {print $5}' | sed 's/%//')
|
|
382
|
+
|
|
383
|
+
if [ "$DISK_USAGE" -gt 80 ]; then
|
|
384
|
+
agent-slack message send "$CHANNEL" "⚠️ Disk usage is at ${DISK_USAGE}%! Please investigate."
|
|
385
|
+
|
|
386
|
+
# Add urgent reaction
|
|
387
|
+
RESULT=$(agent-slack message list "$CHANNEL" --limit 1)
|
|
388
|
+
MSG_TS=$(echo "$RESULT" | jq -r '.data.messages[0].ts')
|
|
389
|
+
agent-slack reaction add "$CHANNEL" "$MSG_TS" rotating_light
|
|
390
|
+
fi
|
|
391
|
+
```
|
|
392
|
+
|
|
393
|
+
**When to use**: Alerts, threshold monitoring, conditional notifications.
|
|
394
|
+
|
|
395
|
+
## Best Practices
|
|
396
|
+
|
|
397
|
+
### 1. Always Check Success
|
|
398
|
+
|
|
399
|
+
```bash
|
|
400
|
+
# Good
|
|
401
|
+
RESULT=$(agent-slack message send general "Hello")
|
|
402
|
+
if echo "$RESULT" | jq -e '.success' > /dev/null; then
|
|
403
|
+
echo "Success!"
|
|
404
|
+
else
|
|
405
|
+
echo "Failed: $(echo "$RESULT" | jq -r '.error.message')"
|
|
406
|
+
fi
|
|
407
|
+
|
|
408
|
+
# Bad
|
|
409
|
+
agent-slack message send general "Hello" # No error checking
|
|
410
|
+
```
|
|
411
|
+
|
|
412
|
+
### 2. Use Channel Names for Simplicity
|
|
413
|
+
|
|
414
|
+
```bash
|
|
415
|
+
# Good - readable and maintainable
|
|
416
|
+
agent-slack message send general "Hello"
|
|
417
|
+
|
|
418
|
+
# Also good - use ID from snapshot
|
|
419
|
+
SNAPSHOT=$(agent-slack snapshot)
|
|
420
|
+
CHANNEL_ID=$(echo "$SNAPSHOT" | jq -r '.channels[0].id')
|
|
421
|
+
agent-slack message send "$CHANNEL_ID" "Hello"
|
|
422
|
+
|
|
423
|
+
# Bad - hardcoded IDs in scripts
|
|
424
|
+
agent-slack message send C06ABCD1234 "Hello"
|
|
425
|
+
```
|
|
426
|
+
|
|
427
|
+
### 3. Rate Limit Your Requests
|
|
428
|
+
|
|
429
|
+
```bash
|
|
430
|
+
# Good - respect Slack API limits
|
|
431
|
+
for channel in "${CHANNELS[@]}"; do
|
|
432
|
+
agent-slack message send "$channel" "$MESSAGE"
|
|
433
|
+
sleep 1 # 1 second between requests
|
|
434
|
+
done
|
|
435
|
+
|
|
436
|
+
# Bad - rapid-fire requests
|
|
437
|
+
for channel in "${CHANNELS[@]}"; do
|
|
438
|
+
agent-slack message send "$channel" "$MESSAGE"
|
|
439
|
+
done
|
|
440
|
+
```
|
|
441
|
+
|
|
442
|
+
### 4. Keep Threads Organized
|
|
443
|
+
|
|
444
|
+
```bash
|
|
445
|
+
# Good - use threads for related messages
|
|
446
|
+
PARENT_TS=$(agent-slack message send general "Task started" | jq -r '.data.ts')
|
|
447
|
+
agent-slack message send general "Step 1 complete" --thread "$PARENT_TS"
|
|
448
|
+
agent-slack message send general "Step 2 complete" --thread "$PARENT_TS"
|
|
449
|
+
|
|
450
|
+
# Bad - spam channel with separate messages
|
|
451
|
+
agent-slack message send general "Task started"
|
|
452
|
+
agent-slack message send general "Step 1 complete"
|
|
453
|
+
agent-slack message send general "Step 2 complete"
|
|
454
|
+
```
|
|
455
|
+
|
|
456
|
+
### 5. Use Reactions for Quick Feedback
|
|
457
|
+
|
|
458
|
+
```bash
|
|
459
|
+
# Good - reactions are lightweight
|
|
460
|
+
agent-slack reaction add general "$MSG_TS" thumbsup
|
|
461
|
+
|
|
462
|
+
# Okay - but verbose
|
|
463
|
+
agent-slack message send general "Acknowledged!" --thread "$MSG_TS"
|
|
464
|
+
```
|
|
465
|
+
|
|
466
|
+
## Anti-Patterns
|
|
467
|
+
|
|
468
|
+
### ❌ Don't Poll Too Frequently
|
|
469
|
+
|
|
470
|
+
```bash
|
|
471
|
+
# Bad - polls every second
|
|
472
|
+
while true; do
|
|
473
|
+
agent-slack message list general --limit 1
|
|
474
|
+
sleep 1
|
|
475
|
+
done
|
|
476
|
+
|
|
477
|
+
# Good - reasonable interval
|
|
478
|
+
while true; do
|
|
479
|
+
agent-slack message list general --limit 1
|
|
480
|
+
sleep 30 # 30 seconds
|
|
481
|
+
done
|
|
482
|
+
```
|
|
483
|
+
|
|
484
|
+
### ❌ Don't Hardcode IDs
|
|
485
|
+
|
|
486
|
+
```bash
|
|
487
|
+
# Bad
|
|
488
|
+
agent-slack message send C06ABCD1234 "Hello"
|
|
489
|
+
|
|
490
|
+
# Good
|
|
491
|
+
agent-slack message send general "Hello"
|
|
492
|
+
```
|
|
493
|
+
|
|
494
|
+
### ❌ Don't Ignore Errors
|
|
495
|
+
|
|
496
|
+
```bash
|
|
497
|
+
# Bad
|
|
498
|
+
agent-slack message send general "Hello"
|
|
499
|
+
# Continues even if it failed
|
|
500
|
+
|
|
501
|
+
# Good
|
|
502
|
+
if ! agent-slack message send general "Hello" | jq -e '.success' > /dev/null; then
|
|
503
|
+
echo "Failed to send message"
|
|
504
|
+
exit 1
|
|
505
|
+
fi
|
|
506
|
+
```
|
|
507
|
+
|
|
508
|
+
### ❌ Don't Spam Channels
|
|
509
|
+
|
|
510
|
+
```bash
|
|
511
|
+
# Bad - sends 100 messages
|
|
512
|
+
for i in {1..100}; do
|
|
513
|
+
agent-slack message send general "Message $i"
|
|
514
|
+
done
|
|
515
|
+
|
|
516
|
+
# Good - batch into single message
|
|
517
|
+
MESSAGE="Updates:\n"
|
|
518
|
+
for i in {1..100}; do
|
|
519
|
+
MESSAGE="$MESSAGE\n$i. Item $i"
|
|
520
|
+
done
|
|
521
|
+
agent-slack message send general "$MESSAGE"
|
|
522
|
+
```
|
|
523
|
+
|
|
524
|
+
## See Also
|
|
525
|
+
|
|
526
|
+
- [Authentication Guide](authentication.md) - Setting up credentials
|
|
527
|
+
- [Templates](../templates/) - Runnable example scripts
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
#
|
|
3
|
+
# monitor-channel.sh - Monitor a Slack channel for new messages
|
|
4
|
+
#
|
|
5
|
+
# Usage:
|
|
6
|
+
# ./monitor-channel.sh <channel> [interval]
|
|
7
|
+
#
|
|
8
|
+
# Arguments:
|
|
9
|
+
# channel - Channel name or ID to monitor
|
|
10
|
+
# interval - Polling interval in seconds (default: 10)
|
|
11
|
+
#
|
|
12
|
+
# Example:
|
|
13
|
+
# ./monitor-channel.sh general
|
|
14
|
+
# ./monitor-channel.sh engineering 5
|
|
15
|
+
|
|
16
|
+
set -euo pipefail
|
|
17
|
+
|
|
18
|
+
# Check arguments
|
|
19
|
+
if [ $# -lt 1 ]; then
|
|
20
|
+
echo "Usage: $0 <channel> [interval]"
|
|
21
|
+
echo ""
|
|
22
|
+
echo "Examples:"
|
|
23
|
+
echo " $0 general # Monitor #general, poll every 10s"
|
|
24
|
+
echo " $0 engineering 5 # Monitor #engineering, poll every 5s"
|
|
25
|
+
exit 1
|
|
26
|
+
fi
|
|
27
|
+
|
|
28
|
+
CHANNEL="$1"
|
|
29
|
+
INTERVAL="${2:-10}" # Default 10 seconds
|
|
30
|
+
|
|
31
|
+
# Colors for output
|
|
32
|
+
RED='\033[0;31m'
|
|
33
|
+
GREEN='\033[0;32m'
|
|
34
|
+
YELLOW='\033[1;33m'
|
|
35
|
+
BLUE='\033[0;34m'
|
|
36
|
+
NC='\033[0m' # No Color
|
|
37
|
+
|
|
38
|
+
# State tracking
|
|
39
|
+
LAST_TS=""
|
|
40
|
+
FIRST_RUN=true
|
|
41
|
+
|
|
42
|
+
# Function to format timestamp
|
|
43
|
+
format_time() {
|
|
44
|
+
local ts=$1
|
|
45
|
+
# Extract seconds part (before decimal)
|
|
46
|
+
local seconds=${ts%.*}
|
|
47
|
+
date -r "$seconds" "+%Y-%m-%d %H:%M:%S"
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
# Function to truncate text
|
|
51
|
+
truncate_text() {
|
|
52
|
+
local text=$1
|
|
53
|
+
local max_length=100
|
|
54
|
+
|
|
55
|
+
if [ ${#text} -gt $max_length ]; then
|
|
56
|
+
echo "${text:0:$max_length}..."
|
|
57
|
+
else
|
|
58
|
+
echo "$text"
|
|
59
|
+
fi
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
# Function to check for new messages
|
|
63
|
+
check_messages() {
|
|
64
|
+
# Get latest message
|
|
65
|
+
MESSAGES=$(agent-slack message list "$CHANNEL" --limit 1 2>&1)
|
|
66
|
+
|
|
67
|
+
# Check if successful
|
|
68
|
+
if ! echo "$MESSAGES" | jq -e '.success' > /dev/null 2>&1; then
|
|
69
|
+
ERROR_MSG=$(echo "$MESSAGES" | jq -r '.error.message // "Unknown error"')
|
|
70
|
+
echo -e "${RED}Error: $ERROR_MSG${NC}"
|
|
71
|
+
return 1
|
|
72
|
+
fi
|
|
73
|
+
|
|
74
|
+
# Extract latest message
|
|
75
|
+
LATEST_TS=$(echo "$MESSAGES" | jq -r '.data.messages[0].ts // ""')
|
|
76
|
+
|
|
77
|
+
# No messages in channel
|
|
78
|
+
if [ -z "$LATEST_TS" ]; then
|
|
79
|
+
if [ "$FIRST_RUN" = true ]; then
|
|
80
|
+
echo -e "${YELLOW}No messages in channel yet${NC}"
|
|
81
|
+
fi
|
|
82
|
+
return 0
|
|
83
|
+
fi
|
|
84
|
+
|
|
85
|
+
# Check if new message
|
|
86
|
+
if [ "$LATEST_TS" != "$LAST_TS" ]; then
|
|
87
|
+
# Skip notification on first run (just initialize)
|
|
88
|
+
if [ "$FIRST_RUN" = false ] && [ -n "$LAST_TS" ]; then
|
|
89
|
+
# Extract message details
|
|
90
|
+
TEXT=$(echo "$MESSAGES" | jq -r '.data.messages[0].text // ""')
|
|
91
|
+
USER_ID=$(echo "$MESSAGES" | jq -r '.data.messages[0].user // ""')
|
|
92
|
+
|
|
93
|
+
# Get user name
|
|
94
|
+
if [ -n "$USER_ID" ]; then
|
|
95
|
+
USER_INFO=$(agent-slack user info "$USER_ID" 2>&1)
|
|
96
|
+
if echo "$USER_INFO" | jq -e '.success' > /dev/null 2>&1; then
|
|
97
|
+
USER_NAME=$(echo "$USER_INFO" | jq -r '.data.name // "Unknown"')
|
|
98
|
+
else
|
|
99
|
+
USER_NAME="Unknown"
|
|
100
|
+
fi
|
|
101
|
+
else
|
|
102
|
+
USER_NAME="Unknown"
|
|
103
|
+
fi
|
|
104
|
+
|
|
105
|
+
# Format timestamp
|
|
106
|
+
TIME=$(format_time "$LATEST_TS")
|
|
107
|
+
|
|
108
|
+
# Display new message
|
|
109
|
+
echo ""
|
|
110
|
+
echo -e "${GREEN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
|
|
111
|
+
echo -e "${BLUE}New message in #$CHANNEL${NC}"
|
|
112
|
+
echo -e "${GREEN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
|
|
113
|
+
echo -e "Time: $TIME"
|
|
114
|
+
echo -e "From: $USER_NAME"
|
|
115
|
+
echo -e "Message: $(truncate_text "$TEXT")"
|
|
116
|
+
echo -e "${GREEN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
|
|
117
|
+
|
|
118
|
+
# Example: Auto-respond to mentions
|
|
119
|
+
# Uncomment to enable
|
|
120
|
+
# if echo "$TEXT" | grep -q "@bot"; then
|
|
121
|
+
# echo -e "${YELLOW}Detected mention, responding...${NC}"
|
|
122
|
+
# agent-slack message send "$CHANNEL" "You called?" --thread "$LATEST_TS"
|
|
123
|
+
# fi
|
|
124
|
+
fi
|
|
125
|
+
|
|
126
|
+
LAST_TS="$LATEST_TS"
|
|
127
|
+
fi
|
|
128
|
+
|
|
129
|
+
FIRST_RUN=false
|
|
130
|
+
return 0
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
# Check if agent-slack is installed
|
|
134
|
+
if ! command -v agent-slack &> /dev/null; then
|
|
135
|
+
echo -e "${RED}Error: agent-slack not found${NC}"
|
|
136
|
+
echo ""
|
|
137
|
+
echo "Install it with:"
|
|
138
|
+
echo " bun install -g agent-slack"
|
|
139
|
+
exit 1
|
|
140
|
+
fi
|
|
141
|
+
|
|
142
|
+
# Check authentication
|
|
143
|
+
echo "Checking authentication..."
|
|
144
|
+
AUTH_STATUS=$(agent-slack auth status 2>&1)
|
|
145
|
+
|
|
146
|
+
if ! echo "$AUTH_STATUS" | jq -e '.success' > /dev/null 2>&1; then
|
|
147
|
+
echo -e "${RED}Not authenticated!${NC}"
|
|
148
|
+
echo ""
|
|
149
|
+
echo "Run this to authenticate:"
|
|
150
|
+
echo " agent-slack auth extract"
|
|
151
|
+
exit 1
|
|
152
|
+
fi
|
|
153
|
+
|
|
154
|
+
WORKSPACE_NAME=$(echo "$AUTH_STATUS" | jq -r '.data.workspace_name // "Unknown"')
|
|
155
|
+
echo -e "${GREEN}✓ Authenticated to: $WORKSPACE_NAME${NC}"
|
|
156
|
+
echo ""
|
|
157
|
+
|
|
158
|
+
# Verify channel exists
|
|
159
|
+
echo "Verifying channel..."
|
|
160
|
+
CHANNEL_INFO=$(agent-slack channel info "$CHANNEL" 2>&1)
|
|
161
|
+
|
|
162
|
+
if ! echo "$CHANNEL_INFO" | jq -e '.success' > /dev/null 2>&1; then
|
|
163
|
+
echo -e "${RED}Channel '$CHANNEL' not found${NC}"
|
|
164
|
+
echo ""
|
|
165
|
+
echo "List available channels with:"
|
|
166
|
+
echo " agent-slack channel list"
|
|
167
|
+
exit 1
|
|
168
|
+
fi
|
|
169
|
+
|
|
170
|
+
CHANNEL_NAME=$(echo "$CHANNEL_INFO" | jq -r '.data.name // "Unknown"')
|
|
171
|
+
echo -e "${GREEN}✓ Monitoring: #$CHANNEL_NAME${NC}"
|
|
172
|
+
echo ""
|
|
173
|
+
|
|
174
|
+
# Start monitoring
|
|
175
|
+
echo -e "${YELLOW}Monitoring for new messages (polling every ${INTERVAL}s)...${NC}"
|
|
176
|
+
echo -e "${YELLOW}Press Ctrl+C to stop${NC}"
|
|
177
|
+
echo ""
|
|
178
|
+
|
|
179
|
+
# Trap Ctrl+C for clean exit
|
|
180
|
+
trap 'echo -e "\n${YELLOW}Monitoring stopped${NC}"; exit 0' INT
|
|
181
|
+
|
|
182
|
+
# Main monitoring loop
|
|
183
|
+
while true; do
|
|
184
|
+
check_messages
|
|
185
|
+
sleep "$INTERVAL"
|
|
186
|
+
done
|