agent-messenger 1.2.0 → 1.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/marketplace.json +27 -1
- package/.claude-plugin/plugin.json +17 -4
- package/.env.template +3 -0
- package/.github/workflows/release.yml +94 -0
- package/AGENTS.md +48 -0
- package/README.md +25 -20
- package/biome.json +15 -39
- package/bun.lock +69 -0
- package/dist/package.json +12 -4
- package/dist/src/cli.d.ts.map +1 -1
- package/dist/src/cli.js +1 -4
- package/dist/src/cli.js.map +1 -1
- package/dist/src/platforms/discord/client.d.ts.map +1 -1
- package/dist/src/platforms/discord/client.js.map +1 -1
- package/dist/src/platforms/discord/commands/auth.d.ts.map +1 -1
- package/dist/src/platforms/discord/commands/auth.js.map +1 -1
- package/dist/src/platforms/discord/commands/channel.d.ts.map +1 -1
- package/dist/src/platforms/discord/commands/channel.js.map +1 -1
- package/dist/src/platforms/discord/commands/dm.d.ts.map +1 -1
- package/dist/src/platforms/discord/commands/dm.js.map +1 -1
- package/dist/src/platforms/discord/commands/file.d.ts.map +1 -1
- package/dist/src/platforms/discord/commands/file.js +1 -4
- package/dist/src/platforms/discord/commands/file.js.map +1 -1
- package/dist/src/platforms/discord/commands/friend.d.ts.map +1 -1
- package/dist/src/platforms/discord/commands/friend.js +1 -3
- package/dist/src/platforms/discord/commands/friend.js.map +1 -1
- package/dist/src/platforms/discord/commands/member.d.ts.map +1 -1
- package/dist/src/platforms/discord/commands/member.js.map +1 -1
- package/dist/src/platforms/discord/commands/mention.d.ts.map +1 -1
- package/dist/src/platforms/discord/commands/mention.js.map +1 -1
- package/dist/src/platforms/discord/commands/message.d.ts.map +1 -1
- package/dist/src/platforms/discord/commands/message.js.map +1 -1
- package/dist/src/platforms/discord/commands/note.d.ts.map +1 -1
- package/dist/src/platforms/discord/commands/note.js.map +1 -1
- package/dist/src/platforms/discord/commands/profile.d.ts.map +1 -1
- package/dist/src/platforms/discord/commands/profile.js.map +1 -1
- package/dist/src/platforms/discord/commands/reaction.d.ts.map +1 -1
- package/dist/src/platforms/discord/commands/reaction.js.map +1 -1
- package/dist/src/platforms/discord/commands/server.d.ts.map +1 -1
- package/dist/src/platforms/discord/commands/server.js.map +1 -1
- package/dist/src/platforms/discord/commands/snapshot.d.ts.map +1 -1
- package/dist/src/platforms/discord/commands/snapshot.js.map +1 -1
- package/dist/src/platforms/discord/commands/thread.d.ts.map +1 -1
- package/dist/src/platforms/discord/commands/thread.js.map +1 -1
- package/dist/src/platforms/discord/commands/user.d.ts.map +1 -1
- package/dist/src/platforms/discord/commands/user.js.map +1 -1
- package/dist/src/platforms/discord/credential-manager.d.ts.map +1 -1
- package/dist/src/platforms/discord/credential-manager.js.map +1 -1
- package/dist/src/platforms/discord/token-extractor.d.ts.map +1 -1
- package/dist/src/platforms/discord/token-extractor.js +2 -7
- package/dist/src/platforms/discord/token-extractor.js.map +1 -1
- package/dist/src/platforms/slack/client.d.ts.map +1 -1
- package/dist/src/platforms/slack/client.js.map +1 -1
- package/dist/src/platforms/slack/commands/activity.d.ts.map +1 -1
- package/dist/src/platforms/slack/commands/activity.js.map +1 -1
- package/dist/src/platforms/slack/commands/auth.d.ts.map +1 -1
- package/dist/src/platforms/slack/commands/auth.js.map +1 -1
- package/dist/src/platforms/slack/commands/channel.d.ts.map +1 -1
- package/dist/src/platforms/slack/commands/channel.js.map +1 -1
- package/dist/src/platforms/slack/commands/drafts.d.ts.map +1 -1
- package/dist/src/platforms/slack/commands/drafts.js.map +1 -1
- package/dist/src/platforms/slack/commands/file.d.ts.map +1 -1
- package/dist/src/platforms/slack/commands/file.js +1 -4
- package/dist/src/platforms/slack/commands/file.js.map +1 -1
- package/dist/src/platforms/slack/commands/message.d.ts.map +1 -1
- package/dist/src/platforms/slack/commands/message.js.map +1 -1
- package/dist/src/platforms/slack/commands/reaction.d.ts.map +1 -1
- package/dist/src/platforms/slack/commands/reaction.js.map +1 -1
- package/dist/src/platforms/slack/commands/saved.d.ts.map +1 -1
- package/dist/src/platforms/slack/commands/saved.js.map +1 -1
- package/dist/src/platforms/slack/commands/sections.d.ts.map +1 -1
- package/dist/src/platforms/slack/commands/sections.js.map +1 -1
- package/dist/src/platforms/slack/commands/snapshot.d.ts.map +1 -1
- package/dist/src/platforms/slack/commands/snapshot.js.map +1 -1
- package/dist/src/platforms/slack/commands/unread.d.ts.map +1 -1
- package/dist/src/platforms/slack/commands/unread.js.map +1 -1
- package/dist/src/platforms/slack/commands/user.d.ts.map +1 -1
- package/dist/src/platforms/slack/commands/user.js.map +1 -1
- package/dist/src/platforms/slack/commands/workspace.d.ts.map +1 -1
- package/dist/src/platforms/slack/commands/workspace.js.map +1 -1
- package/dist/src/platforms/slack/token-extractor.d.ts.map +1 -1
- package/dist/src/platforms/slack/token-extractor.js +4 -5
- package/dist/src/platforms/slack/token-extractor.js.map +1 -1
- package/dist/src/platforms/slackbot/cli.d.ts +5 -0
- package/dist/src/platforms/slackbot/cli.d.ts.map +1 -0
- package/dist/src/platforms/slackbot/cli.js +19 -0
- package/dist/src/platforms/slackbot/cli.js.map +1 -0
- package/dist/src/platforms/slackbot/client.d.ts +43 -0
- package/dist/src/platforms/slackbot/client.d.ts.map +1 -0
- package/dist/src/platforms/slackbot/client.js +347 -0
- package/dist/src/platforms/slackbot/client.js.map +1 -0
- package/dist/src/platforms/slackbot/commands/auth.d.ts +35 -0
- package/dist/src/platforms/slackbot/commands/auth.d.ts.map +1 -0
- package/dist/src/platforms/slackbot/commands/auth.js +185 -0
- package/dist/src/platforms/slackbot/commands/auth.js.map +1 -0
- package/dist/src/platforms/slackbot/commands/channel.d.ts +3 -0
- package/dist/src/platforms/slackbot/commands/channel.d.ts.map +1 -0
- package/dist/src/platforms/slackbot/commands/channel.js +40 -0
- package/dist/src/platforms/slackbot/commands/channel.js.map +1 -0
- package/dist/src/platforms/slackbot/commands/index.d.ts +6 -0
- package/dist/src/platforms/slackbot/commands/index.d.ts.map +1 -0
- package/dist/src/platforms/slackbot/commands/index.js +6 -0
- package/dist/src/platforms/slackbot/commands/index.js.map +1 -0
- package/dist/src/platforms/slackbot/commands/message.d.ts +3 -0
- package/dist/src/platforms/slackbot/commands/message.d.ts.map +1 -0
- package/dist/src/platforms/slackbot/commands/message.js +135 -0
- package/dist/src/platforms/slackbot/commands/message.js.map +1 -0
- package/dist/src/platforms/slackbot/commands/reaction.d.ts +3 -0
- package/dist/src/platforms/slackbot/commands/reaction.d.ts.map +1 -0
- package/dist/src/platforms/slackbot/commands/reaction.js +43 -0
- package/dist/src/platforms/slackbot/commands/reaction.js.map +1 -0
- package/dist/src/platforms/slackbot/commands/shared.d.ts +9 -0
- package/dist/src/platforms/slackbot/commands/shared.d.ts.map +1 -0
- package/dist/src/platforms/slackbot/commands/shared.js +13 -0
- package/dist/src/platforms/slackbot/commands/shared.js.map +1 -0
- package/dist/src/platforms/slackbot/commands/user.d.ts +3 -0
- package/dist/src/platforms/slackbot/commands/user.d.ts.map +1 -0
- package/dist/src/platforms/slackbot/commands/user.js +40 -0
- package/dist/src/platforms/slackbot/commands/user.js.map +1 -0
- package/dist/src/platforms/slackbot/credential-manager.d.ts +18 -0
- package/dist/src/platforms/slackbot/credential-manager.d.ts.map +1 -0
- package/dist/src/platforms/slackbot/credential-manager.js +185 -0
- package/dist/src/platforms/slackbot/credential-manager.js.map +1 -0
- package/dist/src/platforms/slackbot/index.d.ts +4 -0
- package/dist/src/platforms/slackbot/index.d.ts.map +1 -0
- package/dist/src/platforms/slackbot/index.js +4 -0
- package/dist/src/platforms/slackbot/index.js.map +1 -0
- package/dist/src/platforms/slackbot/types.d.ts +460 -0
- package/dist/src/platforms/slackbot/types.d.ts.map +1 -0
- package/dist/src/platforms/slackbot/types.js +114 -0
- package/dist/src/platforms/slackbot/types.js.map +1 -0
- package/dist/src/platforms/teams/client.d.ts.map +1 -1
- package/dist/src/platforms/teams/client.js.map +1 -1
- package/dist/src/platforms/teams/commands/auth.d.ts.map +1 -1
- package/dist/src/platforms/teams/commands/auth.js.map +1 -1
- package/dist/src/platforms/teams/commands/channel.d.ts.map +1 -1
- package/dist/src/platforms/teams/commands/channel.js.map +1 -1
- package/dist/src/platforms/teams/commands/file.d.ts.map +1 -1
- package/dist/src/platforms/teams/commands/file.js.map +1 -1
- package/dist/src/platforms/teams/commands/message.d.ts.map +1 -1
- package/dist/src/platforms/teams/commands/message.js.map +1 -1
- package/dist/src/platforms/teams/commands/reaction.d.ts.map +1 -1
- package/dist/src/platforms/teams/commands/reaction.js.map +1 -1
- package/dist/src/platforms/teams/commands/snapshot.d.ts.map +1 -1
- package/dist/src/platforms/teams/commands/snapshot.js.map +1 -1
- package/dist/src/platforms/teams/commands/team.d.ts.map +1 -1
- package/dist/src/platforms/teams/commands/team.js +1 -4
- package/dist/src/platforms/teams/commands/team.js.map +1 -1
- package/dist/src/platforms/teams/commands/user.d.ts.map +1 -1
- package/dist/src/platforms/teams/commands/user.js.map +1 -1
- package/dist/src/platforms/teams/token-extractor.d.ts.map +1 -1
- package/dist/src/platforms/teams/token-extractor.js +3 -1
- package/dist/src/platforms/teams/token-extractor.js.map +1 -1
- package/docs/content/docs/agent-skills.mdx +4 -4
- package/docs/content/docs/index.mdx +11 -18
- package/docs/content/docs/integrations/discord.mdx +65 -1
- package/docs/content/docs/integrations/meta.json +1 -1
- package/docs/content/docs/integrations/slack.mdx +51 -1
- package/docs/content/docs/integrations/slackbot.mdx +214 -0
- package/docs/content/docs/integrations/teams.mdx +4 -1
- package/docs/content/docs/quick-start.mdx +3 -2
- package/docs/src/app/icon.png +0 -0
- package/docs/src/app/layout.config.tsx +8 -1
- package/docs/src/app/page.tsx +18 -1
- package/e2e/config.ts +26 -0
- package/e2e/helpers.ts +6 -1
- package/e2e/slackbot.e2e.test.ts +306 -0
- package/package.json +16 -8
- package/scripts/prepublish.ts +11 -0
- package/skills/agent-slackbot/SKILL.md +285 -0
- package/skills/agent-slackbot/references/authentication.md +253 -0
- package/skills/agent-slackbot/references/common-patterns.md +218 -0
- package/skills/agent-slackbot/templates/monitor-channel.sh +98 -0
- package/skills/agent-slackbot/templates/post-message.sh +107 -0
- package/skills/agent-slackbot/templates/workspace-summary.sh +113 -0
- package/src/cli.ts +1 -4
- package/src/platforms/discord/client.test.ts +6 -14
- package/src/platforms/discord/client.ts +12 -34
- package/src/platforms/discord/commands/auth.test.ts +2 -7
- package/src/platforms/discord/commands/auth.ts +14 -19
- package/src/platforms/discord/commands/channel.test.ts +18 -20
- package/src/platforms/discord/commands/channel.ts +9 -18
- package/src/platforms/discord/commands/dm.test.ts +1 -3
- package/src/platforms/discord/commands/dm.ts +6 -10
- package/src/platforms/discord/commands/file.ts +10 -23
- package/src/platforms/discord/commands/friend.ts +33 -35
- package/src/platforms/discord/commands/member.ts +5 -7
- package/src/platforms/discord/commands/mention.ts +5 -11
- package/src/platforms/discord/commands/message.test.ts +1 -3
- package/src/platforms/discord/commands/message.ts +23 -61
- package/src/platforms/discord/commands/note.ts +7 -15
- package/src/platforms/discord/commands/profile.ts +4 -6
- package/src/platforms/discord/commands/reaction.test.ts +1 -3
- package/src/platforms/discord/commands/reaction.ts +19 -29
- package/src/platforms/discord/commands/server.test.ts +14 -18
- package/src/platforms/discord/commands/server.ts +9 -15
- package/src/platforms/discord/commands/snapshot.ts +5 -7
- package/src/platforms/discord/commands/thread.ts +8 -15
- package/src/platforms/discord/commands/user.ts +9 -20
- package/src/platforms/discord/credential-manager.test.ts +2 -2
- package/src/platforms/discord/credential-manager.ts +1 -3
- package/src/platforms/discord/token-extractor.test.ts +28 -57
- package/src/platforms/discord/token-extractor.ts +10 -30
- package/src/platforms/discord/types.ts +1 -1
- package/src/platforms/slack/client.test.ts +14 -20
- package/src/platforms/slack/client.ts +4 -11
- package/src/platforms/slack/commands/activity.test.ts +3 -9
- package/src/platforms/slack/commands/activity.ts +7 -12
- package/src/platforms/slack/commands/auth.test.ts +2 -2
- package/src/platforms/slack/commands/auth.ts +15 -31
- package/src/platforms/slack/commands/channel.ts +10 -32
- package/src/platforms/slack/commands/drafts.ts +5 -14
- package/src/platforms/slack/commands/file.ts +9 -29
- package/src/platforms/slack/commands/message.ts +23 -67
- package/src/platforms/slack/commands/reaction.ts +19 -48
- package/src/platforms/slack/commands/saved.ts +5 -14
- package/src/platforms/slack/commands/sections.ts +4 -11
- package/src/platforms/slack/commands/snapshot.test.ts +1 -3
- package/src/platforms/slack/commands/snapshot.ts +5 -10
- package/src/platforms/slack/commands/unread.test.ts +6 -8
- package/src/platforms/slack/commands/unread.ts +10 -33
- package/src/platforms/slack/commands/user.test.ts +1 -4
- package/src/platforms/slack/commands/user.ts +6 -8
- package/src/platforms/slack/commands/workspace.test.ts +1 -1
- package/src/platforms/slack/commands/workspace.ts +7 -12
- package/src/platforms/slack/token-extractor-node-test.ts +1 -1
- package/src/platforms/slack/token-extractor.ts +8 -17
- package/src/platforms/slack/types.ts +1 -1
- package/src/platforms/slackbot/cli.ts +24 -0
- package/src/platforms/slackbot/client.test.ts +282 -0
- package/src/platforms/slackbot/client.ts +394 -0
- package/src/platforms/slackbot/commands/auth.test.ts +245 -0
- package/src/platforms/slackbot/commands/auth.ts +240 -0
- package/src/platforms/slackbot/commands/channel.ts +46 -0
- package/src/platforms/slackbot/commands/index.ts +5 -0
- package/src/platforms/slackbot/commands/message.ts +169 -0
- package/src/platforms/slackbot/commands/reaction.ts +49 -0
- package/src/platforms/slackbot/commands/shared.ts +21 -0
- package/src/platforms/slackbot/commands/user.ts +46 -0
- package/src/platforms/slackbot/credential-manager.test.ts +264 -0
- package/src/platforms/slackbot/credential-manager.ts +213 -0
- package/src/platforms/slackbot/index.ts +19 -0
- package/src/platforms/slackbot/types.test.ts +90 -0
- package/src/platforms/slackbot/types.ts +222 -0
- package/src/platforms/teams/client.test.ts +15 -32
- package/src/platforms/teams/client.ts +18 -51
- package/src/platforms/teams/commands/auth.test.ts +6 -16
- package/src/platforms/teams/commands/auth.ts +16 -26
- package/src/platforms/teams/commands/channel.test.ts +2 -5
- package/src/platforms/teams/commands/channel.ts +10 -20
- package/src/platforms/teams/commands/file.test.ts +1 -4
- package/src/platforms/teams/commands/file.ts +11 -21
- package/src/platforms/teams/commands/message.test.ts +1 -3
- package/src/platforms/teams/commands/message.ts +15 -25
- package/src/platforms/teams/commands/reaction.test.ts +2 -7
- package/src/platforms/teams/commands/reaction.ts +12 -16
- package/src/platforms/teams/commands/snapshot.ts +6 -11
- package/src/platforms/teams/commands/team.test.ts +15 -26
- package/src/platforms/teams/commands/team.ts +10 -19
- package/src/platforms/teams/commands/user.ts +8 -14
- package/src/platforms/teams/credential-manager.test.ts +2 -5
- package/src/platforms/teams/token-extractor.test.ts +21 -50
- package/src/platforms/teams/token-extractor.ts +12 -20
- package/src/platforms/teams/types.ts +1 -1
- package/src/shared/utils/concurrency.test.ts +2 -2
- package/src/shared/utils/concurrency.ts +1 -1
- package/.claude/commands/release.md +0 -92
- package/dist/src/platforms/discord/commands/guild.d.ts +0 -15
- package/dist/src/platforms/discord/commands/guild.d.ts.map +0 -1
- package/dist/src/platforms/discord/commands/guild.js +0 -102
- package/dist/src/platforms/discord/commands/guild.js.map +0 -1
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import { SlackBotCredentialManager } from '../credential-manager';
|
|
3
|
+
interface ActionOptions {
|
|
4
|
+
pretty?: boolean;
|
|
5
|
+
bot?: string;
|
|
6
|
+
name?: string;
|
|
7
|
+
_credManager?: SlackBotCredentialManager;
|
|
8
|
+
}
|
|
9
|
+
interface ActionResult {
|
|
10
|
+
success?: boolean;
|
|
11
|
+
error?: string;
|
|
12
|
+
workspace_id?: string;
|
|
13
|
+
workspace_name?: string;
|
|
14
|
+
bot_id?: string;
|
|
15
|
+
bot_name?: string;
|
|
16
|
+
user?: string;
|
|
17
|
+
team?: string;
|
|
18
|
+
valid?: boolean;
|
|
19
|
+
bots?: Array<{
|
|
20
|
+
workspace_id: string;
|
|
21
|
+
workspace_name: string;
|
|
22
|
+
bot_id: string;
|
|
23
|
+
bot_name: string;
|
|
24
|
+
is_current: boolean;
|
|
25
|
+
}>;
|
|
26
|
+
}
|
|
27
|
+
export declare function setAction(token: string, options: ActionOptions): Promise<ActionResult>;
|
|
28
|
+
export declare function clearAction(options: ActionOptions): Promise<ActionResult>;
|
|
29
|
+
export declare function statusAction(options: ActionOptions): Promise<ActionResult>;
|
|
30
|
+
export declare function listAction(options: ActionOptions): Promise<ActionResult>;
|
|
31
|
+
export declare function useAction(botId: string, options: ActionOptions): Promise<ActionResult>;
|
|
32
|
+
export declare function removeAction(botId: string, options: ActionOptions): Promise<ActionResult>;
|
|
33
|
+
export declare const authCommand: Command;
|
|
34
|
+
export {};
|
|
35
|
+
//# sourceMappingURL=auth.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../../../../src/platforms/slackbot/commands/auth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAGnC,OAAO,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAA;AAEjE,UAAU,aAAa;IACrB,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,YAAY,CAAC,EAAE,yBAAyB,CAAA;CACzC;AAED,UAAU,YAAY;IACpB,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,IAAI,CAAC,EAAE,KAAK,CAAC;QACX,YAAY,EAAE,MAAM,CAAA;QACpB,cAAc,EAAE,MAAM,CAAA;QACtB,MAAM,EAAE,MAAM,CAAA;QACd,QAAQ,EAAE,MAAM,CAAA;QAChB,UAAU,EAAE,OAAO,CAAA;KACpB,CAAC,CAAA;CACH;AAED,wBAAsB,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,YAAY,CAAC,CAiC5F;AAED,wBAAsB,WAAW,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,YAAY,CAAC,CAQ/E;AAED,wBAAsB,YAAY,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,YAAY,CAAC,CA2ChF;AAED,wBAAsB,UAAU,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,YAAY,CAAC,CAiB9E;AAED,wBAAsB,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,YAAY,CAAC,CAoB5F;AAED,wBAAsB,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,YAAY,CAAC,CAa/F;AAOD,eAAO,MAAM,WAAW,SAyDrB,CAAA"}
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import { formatOutput } from '../../../shared/utils/output';
|
|
3
|
+
import { SlackBotClient } from '../client';
|
|
4
|
+
import { SlackBotCredentialManager } from '../credential-manager';
|
|
5
|
+
export async function setAction(token, options) {
|
|
6
|
+
try {
|
|
7
|
+
if (!token.startsWith('xoxb-')) {
|
|
8
|
+
return { error: 'Token must be a bot token (xoxb-). User tokens (xoxp-) are not supported.' };
|
|
9
|
+
}
|
|
10
|
+
const client = new SlackBotClient(token);
|
|
11
|
+
const authInfo = await client.testAuth();
|
|
12
|
+
const botId = options.bot || authInfo.bot_id || authInfo.user || 'default';
|
|
13
|
+
const botName = options.name || authInfo.user || botId;
|
|
14
|
+
const credManager = options._credManager ?? new SlackBotCredentialManager();
|
|
15
|
+
await credManager.setCredentials({
|
|
16
|
+
token,
|
|
17
|
+
workspace_id: authInfo.team_id,
|
|
18
|
+
workspace_name: authInfo.team || authInfo.team_id,
|
|
19
|
+
bot_id: botId,
|
|
20
|
+
bot_name: botName,
|
|
21
|
+
});
|
|
22
|
+
return {
|
|
23
|
+
success: true,
|
|
24
|
+
workspace_id: authInfo.team_id,
|
|
25
|
+
workspace_name: authInfo.team || authInfo.team_id,
|
|
26
|
+
bot_id: botId,
|
|
27
|
+
bot_name: botName,
|
|
28
|
+
user: authInfo.user,
|
|
29
|
+
team: authInfo.team,
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
catch (error) {
|
|
33
|
+
return { error: error.message };
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
export async function clearAction(options) {
|
|
37
|
+
try {
|
|
38
|
+
const credManager = options._credManager ?? new SlackBotCredentialManager();
|
|
39
|
+
await credManager.clearCredentials();
|
|
40
|
+
return { success: true };
|
|
41
|
+
}
|
|
42
|
+
catch (error) {
|
|
43
|
+
return { error: error.message };
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
export async function statusAction(options) {
|
|
47
|
+
try {
|
|
48
|
+
const credManager = options._credManager ?? new SlackBotCredentialManager();
|
|
49
|
+
const creds = await credManager.getCredentials(options.bot);
|
|
50
|
+
if (!creds) {
|
|
51
|
+
return {
|
|
52
|
+
valid: false,
|
|
53
|
+
error: options.bot
|
|
54
|
+
? `Bot "${options.bot}" not found. Run "auth list" to see available bots.`
|
|
55
|
+
: 'No credentials configured. Run "auth set <token>" first.',
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
let valid = false;
|
|
59
|
+
let authInfo = null;
|
|
60
|
+
try {
|
|
61
|
+
const client = new SlackBotClient(creds.token);
|
|
62
|
+
authInfo = await client.testAuth();
|
|
63
|
+
valid = true;
|
|
64
|
+
}
|
|
65
|
+
catch {
|
|
66
|
+
valid = false;
|
|
67
|
+
}
|
|
68
|
+
return {
|
|
69
|
+
valid,
|
|
70
|
+
workspace_id: creds.workspace_id,
|
|
71
|
+
workspace_name: creds.workspace_name,
|
|
72
|
+
bot_id: creds.bot_id,
|
|
73
|
+
bot_name: creds.bot_name,
|
|
74
|
+
user: authInfo?.user,
|
|
75
|
+
team: authInfo?.team,
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
catch (error) {
|
|
79
|
+
return { error: error.message };
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
export async function listAction(options) {
|
|
83
|
+
try {
|
|
84
|
+
const credManager = options._credManager ?? new SlackBotCredentialManager();
|
|
85
|
+
const all = await credManager.listAll();
|
|
86
|
+
return {
|
|
87
|
+
bots: all.map((b) => ({
|
|
88
|
+
workspace_id: b.workspace_id,
|
|
89
|
+
workspace_name: b.workspace_name,
|
|
90
|
+
bot_id: b.bot_id,
|
|
91
|
+
bot_name: b.bot_name,
|
|
92
|
+
is_current: b.is_current,
|
|
93
|
+
})),
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
catch (error) {
|
|
97
|
+
return { error: error.message };
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
export async function useAction(botId, options) {
|
|
101
|
+
try {
|
|
102
|
+
const credManager = options._credManager ?? new SlackBotCredentialManager();
|
|
103
|
+
const found = await credManager.setCurrent(botId);
|
|
104
|
+
if (!found) {
|
|
105
|
+
return { error: `Bot "${botId}" not found. Run "auth list" to see available bots.` };
|
|
106
|
+
}
|
|
107
|
+
const creds = await credManager.getCredentials();
|
|
108
|
+
return {
|
|
109
|
+
success: true,
|
|
110
|
+
workspace_id: creds?.workspace_id,
|
|
111
|
+
workspace_name: creds?.workspace_name,
|
|
112
|
+
bot_id: creds?.bot_id,
|
|
113
|
+
bot_name: creds?.bot_name,
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
catch (error) {
|
|
117
|
+
return { error: error.message };
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
export async function removeAction(botId, options) {
|
|
121
|
+
try {
|
|
122
|
+
const credManager = options._credManager ?? new SlackBotCredentialManager();
|
|
123
|
+
const removed = await credManager.removeBot(botId);
|
|
124
|
+
if (!removed) {
|
|
125
|
+
return { error: `Bot "${botId}" not found. Run "auth list" to see available bots.` };
|
|
126
|
+
}
|
|
127
|
+
return { success: true };
|
|
128
|
+
}
|
|
129
|
+
catch (error) {
|
|
130
|
+
return { error: error.message };
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
function cliOutput(result, pretty, exitOnError = true) {
|
|
134
|
+
console.log(formatOutput(result, pretty));
|
|
135
|
+
if (result.error && exitOnError)
|
|
136
|
+
process.exit(1);
|
|
137
|
+
}
|
|
138
|
+
export const authCommand = new Command('auth')
|
|
139
|
+
.description('Bot authentication commands')
|
|
140
|
+
.addCommand(new Command('set')
|
|
141
|
+
.description('Set bot token')
|
|
142
|
+
.argument('<token>', 'Bot token (xoxb-...)')
|
|
143
|
+
.option('--bot <id>', 'Bot identifier for switching later')
|
|
144
|
+
.option('--name <name>', 'Human-readable bot name')
|
|
145
|
+
.option('--pretty', 'Pretty print JSON output')
|
|
146
|
+
.action(async (token, opts) => {
|
|
147
|
+
cliOutput(await setAction(token, opts), opts.pretty);
|
|
148
|
+
}))
|
|
149
|
+
.addCommand(new Command('clear')
|
|
150
|
+
.description('Clear all stored credentials')
|
|
151
|
+
.option('--pretty', 'Pretty print JSON output')
|
|
152
|
+
.action(async (opts) => {
|
|
153
|
+
cliOutput(await clearAction(opts), opts.pretty);
|
|
154
|
+
}))
|
|
155
|
+
.addCommand(new Command('status')
|
|
156
|
+
.description('Show authentication status')
|
|
157
|
+
.option('--bot <id>', 'Check specific bot (default: current)')
|
|
158
|
+
.option('--pretty', 'Pretty print JSON output')
|
|
159
|
+
.action(async (opts) => {
|
|
160
|
+
const result = await statusAction(opts);
|
|
161
|
+
console.log(formatOutput(result, opts.pretty));
|
|
162
|
+
if (!result.valid)
|
|
163
|
+
process.exit(1);
|
|
164
|
+
}))
|
|
165
|
+
.addCommand(new Command('list')
|
|
166
|
+
.description('List all stored bots')
|
|
167
|
+
.option('--pretty', 'Pretty print JSON output')
|
|
168
|
+
.action(async (opts) => {
|
|
169
|
+
cliOutput(await listAction(opts), opts.pretty);
|
|
170
|
+
}))
|
|
171
|
+
.addCommand(new Command('use')
|
|
172
|
+
.description('Switch active bot')
|
|
173
|
+
.argument('<bot>', 'Bot ID or workspace_id/bot_id')
|
|
174
|
+
.option('--pretty', 'Pretty print JSON output')
|
|
175
|
+
.action(async (botId, opts) => {
|
|
176
|
+
cliOutput(await useAction(botId, opts), opts.pretty);
|
|
177
|
+
}))
|
|
178
|
+
.addCommand(new Command('remove')
|
|
179
|
+
.description('Remove a stored bot')
|
|
180
|
+
.argument('<bot>', 'Bot ID or workspace_id/bot_id')
|
|
181
|
+
.option('--pretty', 'Pretty print JSON output')
|
|
182
|
+
.action(async (botId, opts) => {
|
|
183
|
+
cliOutput(await removeAction(botId, opts), opts.pretty);
|
|
184
|
+
}));
|
|
185
|
+
//# sourceMappingURL=auth.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../../../../src/platforms/slackbot/commands/auth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AAC1C,OAAO,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAA;AA4BjE,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,KAAa,EAAE,OAAsB;IACnE,IAAI,CAAC;QACH,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;YAC/B,OAAO,EAAE,KAAK,EAAE,2EAA2E,EAAE,CAAA;QAC/F,CAAC;QAED,MAAM,MAAM,GAA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AAC,CACL;KACA,UAAU,CACT,IAAI,OAAO,CAAC,KAAK,CAAC;KACf,WAAW,CAAC,mBAAmB,CAAC;KAChC,QAAQ,CAAC,OAAO,EAAE,+BAA+B,CAAC;KAClD,MAAM,CAAC,UAAU,EAAE,0BAA0B,CAAC;KAC9C,MAAM,CAAC,KAAK,EAAE,KAAa,EAAE,IAA0B,EAAE,EAAE;IAC1D,SAAS,CAAC,MAAM,SAAS,CAAC,KAAK,EAAE,IAAI,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,CAAA;AACtD,CAAC,CAAC,CACL;KACA,UAAU,CACT,IAAI,OAAO,CAAC,QAAQ,CAAC;KAClB,WAAW,CAAC,qBAAqB,CAAC;KAClC,QAAQ,CAAC,OAAO,EAAE,+BAA+B,CAAC;KAClD,MAAM,CAAC,UAAU,EAAE,0BAA0B,CAAC;KAC9C,MAAM,CAAC,KAAK,EAAE,KAAa,EAAE,IAA0B,EAAE,EAAE;IAC1D,SAAS,CAAC,MAAM,YAAY,CAAC,KAAK,EAAE,IAAI,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,CAAA;AACzD,CAAC,CAAC,CACL,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"channel.d.ts","sourceRoot":"","sources":["../../../../../src/platforms/slackbot/commands/channel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AA4BnC,eAAO,MAAM,cAAc,SAiBxB,CAAA"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import { handleError } from '../../../shared/utils/error-handler';
|
|
3
|
+
import { formatOutput } from '../../../shared/utils/output';
|
|
4
|
+
import { getClient } from './shared';
|
|
5
|
+
async function listAction(options) {
|
|
6
|
+
try {
|
|
7
|
+
const client = await getClient(options);
|
|
8
|
+
const limit = options.limit ? parseInt(options.limit, 10) : undefined;
|
|
9
|
+
const channels = await client.listChannels(limit ? { limit } : undefined);
|
|
10
|
+
console.log(formatOutput(channels, options.pretty));
|
|
11
|
+
}
|
|
12
|
+
catch (error) {
|
|
13
|
+
handleError(error);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
async function infoAction(channel, options) {
|
|
17
|
+
try {
|
|
18
|
+
const client = await getClient(options);
|
|
19
|
+
const info = await client.getChannelInfo(channel);
|
|
20
|
+
console.log(formatOutput(info, options.pretty));
|
|
21
|
+
}
|
|
22
|
+
catch (error) {
|
|
23
|
+
handleError(error);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
export const channelCommand = new Command('channel')
|
|
27
|
+
.description('Channel commands')
|
|
28
|
+
.addCommand(new Command('list')
|
|
29
|
+
.description('List channels')
|
|
30
|
+
.option('--limit <n>', 'Number of channels to fetch')
|
|
31
|
+
.option('--bot <id>', 'Use specific bot')
|
|
32
|
+
.option('--pretty', 'Pretty print JSON output')
|
|
33
|
+
.action(listAction))
|
|
34
|
+
.addCommand(new Command('info')
|
|
35
|
+
.description('Get channel info')
|
|
36
|
+
.argument('<channel>', 'Channel ID')
|
|
37
|
+
.option('--bot <id>', 'Use specific bot')
|
|
38
|
+
.option('--pretty', 'Pretty print JSON output')
|
|
39
|
+
.action(infoAction));
|
|
40
|
+
//# sourceMappingURL=channel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"channel.js","sourceRoot":"","sources":["../../../../../src/platforms/slackbot/commands/channel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAA;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AACpD,OAAO,EAAkB,SAAS,EAAE,MAAM,UAAU,CAAA;AAEpD,KAAK,UAAU,UAAU,CAAC,OAAuC;IAC/D,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,OAAO,CAAC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I,OAAO,CAAC,MAAM,CAAC;KAChB,WAAW,CAAC,kBAAkB,CAAC;KAC/B,QAAQ,CAAC,WAAW,EAAE,YAAY,CAAC;KACnC,MAAM,CAAC,YAAY,EAAE,kBAAkB,CAAC;KACxC,MAAM,CAAC,UAAU,EAAE,0BAA0B,CAAC;KAC9C,MAAM,CAAC,UAAU,CAAC,CACtB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/platforms/slackbot/commands/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAA;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AAC1C,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/platforms/slackbot/commands/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAA;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AAC1C,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"message.d.ts","sourceRoot":"","sources":["../../../../../src/platforms/slackbot/commands/message.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AA6GnC,eAAO,MAAM,cAAc,SA2DxB,CAAA"}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import { handleError } from '../../../shared/utils/error-handler';
|
|
3
|
+
import { formatOutput } from '../../../shared/utils/output';
|
|
4
|
+
import { getClient } from './shared';
|
|
5
|
+
async function sendAction(channel, text, options) {
|
|
6
|
+
try {
|
|
7
|
+
const client = await getClient(options);
|
|
8
|
+
const result = await client.postMessage(channel, text, {
|
|
9
|
+
thread_ts: options.thread,
|
|
10
|
+
});
|
|
11
|
+
console.log(formatOutput({
|
|
12
|
+
ts: result.ts,
|
|
13
|
+
channel,
|
|
14
|
+
text: result.text,
|
|
15
|
+
thread_ts: result.thread_ts,
|
|
16
|
+
}, options.pretty));
|
|
17
|
+
}
|
|
18
|
+
catch (error) {
|
|
19
|
+
handleError(error);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
async function listAction(channel, options) {
|
|
23
|
+
try {
|
|
24
|
+
const client = await getClient(options);
|
|
25
|
+
const limit = options.limit ? parseInt(options.limit, 10) : 20;
|
|
26
|
+
const messages = await client.getConversationHistory(channel, { limit });
|
|
27
|
+
console.log(formatOutput(messages, options.pretty));
|
|
28
|
+
}
|
|
29
|
+
catch (error) {
|
|
30
|
+
handleError(error);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
async function getAction(channel, ts, options) {
|
|
34
|
+
try {
|
|
35
|
+
const client = await getClient(options);
|
|
36
|
+
const message = await client.getMessage(channel, ts);
|
|
37
|
+
if (!message) {
|
|
38
|
+
console.log(formatOutput({ error: 'Message not found' }, options.pretty));
|
|
39
|
+
process.exit(1);
|
|
40
|
+
}
|
|
41
|
+
console.log(formatOutput(message, options.pretty));
|
|
42
|
+
}
|
|
43
|
+
catch (error) {
|
|
44
|
+
handleError(error);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
async function updateAction(channel, ts, text, options) {
|
|
48
|
+
try {
|
|
49
|
+
const client = await getClient(options);
|
|
50
|
+
const message = await client.updateMessage(channel, ts, text);
|
|
51
|
+
console.log(formatOutput({
|
|
52
|
+
ts: message.ts,
|
|
53
|
+
text: message.text,
|
|
54
|
+
type: message.type,
|
|
55
|
+
user: message.user,
|
|
56
|
+
}, options.pretty));
|
|
57
|
+
}
|
|
58
|
+
catch (error) {
|
|
59
|
+
handleError(error);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
async function deleteAction(channel, ts, options) {
|
|
63
|
+
try {
|
|
64
|
+
if (!options.force) {
|
|
65
|
+
console.log(formatOutput({ warning: 'Use --force to confirm deletion', ts }, options.pretty));
|
|
66
|
+
process.exit(1);
|
|
67
|
+
}
|
|
68
|
+
const client = await getClient(options);
|
|
69
|
+
await client.deleteMessage(channel, ts);
|
|
70
|
+
console.log(formatOutput({ deleted: ts }, options.pretty));
|
|
71
|
+
}
|
|
72
|
+
catch (error) {
|
|
73
|
+
handleError(error);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
async function repliesAction(channel, threadTs, options) {
|
|
77
|
+
try {
|
|
78
|
+
const client = await getClient(options);
|
|
79
|
+
const limit = options.limit ? parseInt(options.limit, 10) : 100;
|
|
80
|
+
const messages = await client.getThreadReplies(channel, threadTs, { limit });
|
|
81
|
+
console.log(formatOutput(messages, options.pretty));
|
|
82
|
+
}
|
|
83
|
+
catch (error) {
|
|
84
|
+
handleError(error);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
export const messageCommand = new Command('message')
|
|
88
|
+
.description('Message commands')
|
|
89
|
+
.addCommand(new Command('send')
|
|
90
|
+
.description('Send a message to a channel')
|
|
91
|
+
.argument('<channel>', 'Channel ID')
|
|
92
|
+
.argument('<text>', 'Message text')
|
|
93
|
+
.option('--thread <ts>', 'Thread timestamp for replies')
|
|
94
|
+
.option('--bot <id>', 'Use specific bot')
|
|
95
|
+
.option('--pretty', 'Pretty print JSON output')
|
|
96
|
+
.action(sendAction))
|
|
97
|
+
.addCommand(new Command('list')
|
|
98
|
+
.description('List messages in a channel')
|
|
99
|
+
.argument('<channel>', 'Channel ID')
|
|
100
|
+
.option('--limit <n>', 'Number of messages to fetch', '20')
|
|
101
|
+
.option('--bot <id>', 'Use specific bot')
|
|
102
|
+
.option('--pretty', 'Pretty print JSON output')
|
|
103
|
+
.action(listAction))
|
|
104
|
+
.addCommand(new Command('get')
|
|
105
|
+
.description('Get a single message')
|
|
106
|
+
.argument('<channel>', 'Channel ID')
|
|
107
|
+
.argument('<ts>', 'Message timestamp')
|
|
108
|
+
.option('--bot <id>', 'Use specific bot')
|
|
109
|
+
.option('--pretty', 'Pretty print JSON output')
|
|
110
|
+
.action(getAction))
|
|
111
|
+
.addCommand(new Command('update')
|
|
112
|
+
.description('Update a message')
|
|
113
|
+
.argument('<channel>', 'Channel ID')
|
|
114
|
+
.argument('<ts>', 'Message timestamp')
|
|
115
|
+
.argument('<text>', 'New message text')
|
|
116
|
+
.option('--bot <id>', 'Use specific bot')
|
|
117
|
+
.option('--pretty', 'Pretty print JSON output')
|
|
118
|
+
.action(updateAction))
|
|
119
|
+
.addCommand(new Command('delete')
|
|
120
|
+
.description('Delete a message')
|
|
121
|
+
.argument('<channel>', 'Channel ID')
|
|
122
|
+
.argument('<ts>', 'Message timestamp')
|
|
123
|
+
.option('--force', 'Skip confirmation')
|
|
124
|
+
.option('--bot <id>', 'Use specific bot')
|
|
125
|
+
.option('--pretty', 'Pretty print JSON output')
|
|
126
|
+
.action(deleteAction))
|
|
127
|
+
.addCommand(new Command('replies')
|
|
128
|
+
.description('Get thread replies')
|
|
129
|
+
.argument('<channel>', 'Channel ID')
|
|
130
|
+
.argument('<thread_ts>', 'Thread timestamp')
|
|
131
|
+
.option('--limit <n>', 'Number of replies to fetch', '100')
|
|
132
|
+
.option('--bot <id>', 'Use specific bot')
|
|
133
|
+
.option('--pretty', 'Pretty print JSON output')
|
|
134
|
+
.action(repliesAction));
|
|
135
|
+
//# sourceMappingURL=message.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"message.js","sourceRoot":"","sources":["../../../../../src/platforms/slackbot/commands/message.ts"],"names":[],"m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E,YAAY,CAAC;KACnC,QAAQ,CAAC,MAAM,EAAE,mBAAmB,CAAC;KACrC,QAAQ,CAAC,QAAQ,EAAE,kBAAkB,CAAC;KACtC,MAAM,CAAC,YAAY,EAAE,kBAAkB,CAAC;KACxC,MAAM,CAAC,UAAU,EAAE,0BAA0B,CAAC;KAC9C,MAAM,CAAC,YAAY,CAAC,CACxB;KACA,UAAU,CACT,IAAI,OAAO,CAAC,QAAQ,CAAC;KAClB,WAAW,CAAC,kBAAkB,CAAC;KAC/B,QAAQ,CAAC,WAAW,EAAE,YAAY,CAAC;KACnC,QAAQ,CAAC,MAAM,EAAE,mBAAmB,CAAC;KACrC,MAAM,CAAC,SAAS,EAAE,mBAAmB,CAAC;KACtC,MAAM,CAAC,YAAY,EAAE,kBAAkB,CAAC;KACxC,MAAM,CAAC,UAAU,EAAE,0BAA0B,CAAC;KAC9C,MAAM,CAAC,YAAY,CAAC,CACxB;KACA,UAAU,CACT,IAAI,OAAO,CAAC,SAAS,CAAC;KACnB,WAAW,CAAC,oBAAoB,CAAC;KACjC,QAAQ,CAAC,WAAW,EAAE,YAAY,CAAC;KACnC,QAAQ,CAAC,aAAa,EAAE,kBAAkB,CAAC;KAC3C,MAAM,CAAC,aAAa,EAAE,4BAA4B,EAAE,KAAK,CAAC;KAC1D,MAAM,CAAC,YAAY,EAAE,kBAAkB,CAAC;KACxC,MAAM,CAAC,UAAU,EAAE,0BAA0B,CAAC;KAC9C,MAAM,CAAC,aAAa,CAAC,CACzB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reaction.d.ts","sourceRoot":"","sources":["../../../../../src/platforms/slackbot/commands/reaction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AA2BnC,eAAO,MAAM,eAAe,SAqBzB,CAAA"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import { handleError } from '../../../shared/utils/error-handler';
|
|
3
|
+
import { formatOutput } from '../../../shared/utils/output';
|
|
4
|
+
import { getClient } from './shared';
|
|
5
|
+
async function addAction(channel, timestamp, emoji, options) {
|
|
6
|
+
try {
|
|
7
|
+
const client = await getClient(options);
|
|
8
|
+
await client.addReaction(channel, timestamp, emoji);
|
|
9
|
+
console.log(formatOutput({ success: true, channel, timestamp, emoji }, options.pretty));
|
|
10
|
+
}
|
|
11
|
+
catch (error) {
|
|
12
|
+
handleError(error);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
async function removeAction(channel, timestamp, emoji, options) {
|
|
16
|
+
try {
|
|
17
|
+
const client = await getClient(options);
|
|
18
|
+
await client.removeReaction(channel, timestamp, emoji);
|
|
19
|
+
console.log(formatOutput({ success: true, channel, timestamp, emoji }, options.pretty));
|
|
20
|
+
}
|
|
21
|
+
catch (error) {
|
|
22
|
+
handleError(error);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
export const reactionCommand = new Command('reaction')
|
|
26
|
+
.description('Reaction commands')
|
|
27
|
+
.addCommand(new Command('add')
|
|
28
|
+
.description('Add a reaction to a message')
|
|
29
|
+
.argument('<channel>', 'Channel ID')
|
|
30
|
+
.argument('<timestamp>', 'Message timestamp')
|
|
31
|
+
.argument('<emoji>', 'Emoji name (with or without colons)')
|
|
32
|
+
.option('--bot <id>', 'Use specific bot')
|
|
33
|
+
.option('--pretty', 'Pretty print JSON output')
|
|
34
|
+
.action(addAction))
|
|
35
|
+
.addCommand(new Command('remove')
|
|
36
|
+
.description('Remove a reaction from a message')
|
|
37
|
+
.argument('<channel>', 'Channel ID')
|
|
38
|
+
.argument('<timestamp>', 'Message timestamp')
|
|
39
|
+
.argument('<emoji>', 'Emoji name (with or without colons)')
|
|
40
|
+
.option('--bot <id>', 'Use specific bot')
|
|
41
|
+
.option('--pretty', 'Pretty print JSON output')
|
|
42
|
+
.action(removeAction));
|
|
43
|
+
//# sourceMappingURL=reaction.js.map
|
|
@@ -0,0 +1 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AC,CAAA;IAC7B,CAAC;AACH,CAAC;AAED,MAAM,CAAC,MAAM,eAAe,GAAG,IAAI,OAAO,CAAC,UAAU,CAAC;KACnD,WAAW,CAAC,mBAAmB,CAAC;KAChC,UAAU,CACT,IAAI,OAAO,CAAC,KAAK,CAAC;KACf,WAAW,CAAC,6BAA6B,CAAC;KAC1C,QAAQ,CAAC,WAAW,EAAE,YAAY,CAAC;KACnC,QAAQ,CAAC,aAAa,EAAE,mBAAmB,CAAC;KAC5C,QAAQ,CAAC,SAAS,EAAE,qCAAqC,CAAC;KAC1D,MAAM,CAAC,YAAY,EAAE,kBAAkB,CAAC;KACxC,MAAM,CAAC,UAAU,EAAE,0BAA0B,CAAC;KAC9C,MAAM,CAAC,SAAS,CAAC,CACrB;KACA,UAAU,CACT,IAAI,OAAO,CAAC,QAAQ,CAAC;KAClB,WAAW,CAAC,kCAAkC,CAAC;KAC/C,QAAQ,CAAC,WAAW,EAAE,YAAY,CAAC;KACnC,QAAQ,CAAC,aAAa,EAAE,mBAAmB,CAAC;KAC5C,QAAQ,CAAC,SAAS,EAAE,qCAAqC,CAAC;KAC1D,MAAM,CAAC,YAAY,EAAE,kBAAkB,CAAC;KACxC,MAAM,CAAC,UAAU,EAAE,0BAA0B,CAAC;KAC9C,MAAM,CAAC,YAAY,CAAC,CACxB,CAAA"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { SlackBotClient } from '../client';
|
|
2
|
+
import { SlackBotCredentialManager } from '../credential-manager';
|
|
3
|
+
export interface BotOption {
|
|
4
|
+
bot?: string;
|
|
5
|
+
pretty?: boolean;
|
|
6
|
+
_credManager?: SlackBotCredentialManager;
|
|
7
|
+
}
|
|
8
|
+
export declare function getClient(options: BotOption): Promise<SlackBotClient>;
|
|
9
|
+
//# sourceMappingURL=shared.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../../../../src/platforms/slackbot/commands/shared.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AAC1C,OAAO,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAA;AAEjE,MAAM,WAAW,SAAS;IACxB,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,YAAY,CAAC,EAAE,yBAAyB,CAAA;CACzC;AAED,wBAAsB,SAAS,CAAC,OAAO,EAAE,SAAS,GAAG,OAAO,CAAC,cAAc,CAAC,CAU3E"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { formatOutput } from '../../../shared/utils/output';
|
|
2
|
+
import { SlackBotClient } from '../client';
|
|
3
|
+
import { SlackBotCredentialManager } from '../credential-manager';
|
|
4
|
+
export async function getClient(options) {
|
|
5
|
+
const credManager = options._credManager ?? new SlackBotCredentialManager();
|
|
6
|
+
const creds = await credManager.getCredentials(options.bot);
|
|
7
|
+
if (!creds) {
|
|
8
|
+
console.log(formatOutput({ error: 'No credentials. Run "auth set <token>" first.' }, options.pretty));
|
|
9
|
+
process.exit(1);
|
|
10
|
+
}
|
|
11
|
+
return new SlackBotClient(creds.token);
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=shared.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shared.js","sourceRoot":"","sources":["../../../../../src/platforms/slackbot/commands/shared.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AAC1C,OAAO,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAA;AAQjE,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,OAAkB;IAChD,MAAM,WAAW,GAAG,OAAO,CAAC,YAAY,IAAI,IAAI,yBAAyB,EAAE,CAAA;IAC3E,MAAM,KAAK,GAAG,MAAM,WAAW,CAAC,cAAc,CAAC,OAAO,CAAC,GAAG,CAAC,CAAA;IAE3D,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,EAAE,KAAK,EAAE,+CAA+C,EAAE,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,CAAA;QACrG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IACjB,CAAC;IAED,OAAO,IAAI,cAAc,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;AACxC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"user.d.ts","sourceRoot":"","sources":["../../../../../src/platforms/slackbot/commands/user.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AA4BnC,eAAO,MAAM,WAAW,SAiBrB,CAAA"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import { handleError } from '../../../shared/utils/error-handler';
|
|
3
|
+
import { formatOutput } from '../../../shared/utils/output';
|
|
4
|
+
import { getClient } from './shared';
|
|
5
|
+
async function listAction(options) {
|
|
6
|
+
try {
|
|
7
|
+
const client = await getClient(options);
|
|
8
|
+
const limit = options.limit ? parseInt(options.limit, 10) : undefined;
|
|
9
|
+
const users = await client.listUsers(limit ? { limit } : undefined);
|
|
10
|
+
console.log(formatOutput(users, options.pretty));
|
|
11
|
+
}
|
|
12
|
+
catch (error) {
|
|
13
|
+
handleError(error);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
async function infoAction(userId, options) {
|
|
17
|
+
try {
|
|
18
|
+
const client = await getClient(options);
|
|
19
|
+
const user = await client.getUserInfo(userId);
|
|
20
|
+
console.log(formatOutput(user, options.pretty));
|
|
21
|
+
}
|
|
22
|
+
catch (error) {
|
|
23
|
+
handleError(error);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
export const userCommand = new Command('user')
|
|
27
|
+
.description('User commands')
|
|
28
|
+
.addCommand(new Command('list')
|
|
29
|
+
.description('List users')
|
|
30
|
+
.option('--limit <n>', 'Number of users to fetch')
|
|
31
|
+
.option('--bot <id>', 'Use specific bot')
|
|
32
|
+
.option('--pretty', 'Pretty print JSON output')
|
|
33
|
+
.action(listAction))
|
|
34
|
+
.addCommand(new Command('info')
|
|
35
|
+
.description('Get user info')
|
|
36
|
+
.argument('<user>', 'User ID')
|
|
37
|
+
.option('--bot <id>', 'Use specific bot')
|
|
38
|
+
.option('--pretty', 'Pretty print JSON output')
|
|
39
|
+
.action(infoAction));
|
|
40
|
+
//# sourceMappingURL=user.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"user.js","sourceRoot":"","sources":["../../../../../src/platforms/slackbot/commands/user.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAA;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AACpD,OAAO,EAAkB,SAAS,EAAE,MAAM,UAAU,CAAA;AAEpD,KAAK,UAAU,UAAU,CAAC,OAAuC;IAC/D,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,OAAO,CAAC,CAAA;QACvC,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,CAAA;QACrE,MAAM,KAAK,GAAG,MAAM,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAA;QAEnE,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,KAAK,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,CAAA;IAClD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,WAAW,CAAC,KAAc,CAAC,CAAA;IAC7B,CAAC;AACH,CAAC;AAED,KAAK,UAAU,UAAU,CAAC,MAAc,EAAE,OAAkB;IAC1D,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,OAAO,CAAC,CAAA;QACvC,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,CAAA;QAE7C,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,IAAI,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,CAAA;IACjD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,WAAW,CAAC,KAAc,CAAC,CAAA;IAC7B,CAAC;AACH,CAAC;AAED,MAAM,CAAC,MAAM,WAAW,GAAG,IAAI,OAAO,CAAC,MAAM,CAAC;KAC3C,WAAW,CAAC,eAAe,CAAC;KAC5B,UAAU,CACT,IAAI,OAAO,CAAC,MAAM,CAAC;KAChB,WAAW,CAAC,YAAY,CAAC;KACzB,MAAM,CAAC,aAAa,EAAE,0BAA0B,CAAC;KACjD,MAAM,CAAC,YAAY,EAAE,kBAAkB,CAAC;KACxC,MAAM,CAAC,UAAU,EAAE,0BAA0B,CAAC;KAC9C,MAAM,CAAC,UAAU,CAAC,CACtB;KACA,UAAU,CACT,IAAI,OAAO,CAAC,MAAM,CAAC;KAChB,WAAW,CAAC,eAAe,CAAC;KAC5B,QAAQ,CAAC,QAAQ,EAAE,SAAS,CAAC;KAC7B,MAAM,CAAC,YAAY,EAAE,kBAAkB,CAAC;KACxC,MAAM,CAAC,UAAU,EAAE,0BAA0B,CAAC;KAC9C,MAAM,CAAC,UAAU,CAAC,CACtB,CAAA"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { SlackBotConfig, SlackBotCredentials } from './types';
|
|
2
|
+
export declare class SlackBotCredentialManager {
|
|
3
|
+
private configDir;
|
|
4
|
+
private credentialsPath;
|
|
5
|
+
constructor(configDir?: string);
|
|
6
|
+
load(): Promise<SlackBotConfig>;
|
|
7
|
+
save(config: SlackBotConfig): Promise<void>;
|
|
8
|
+
getCredentials(botId?: string): Promise<SlackBotCredentials | null>;
|
|
9
|
+
private findBot;
|
|
10
|
+
setCredentials(creds: SlackBotCredentials): Promise<void>;
|
|
11
|
+
removeBot(botId: string): Promise<boolean>;
|
|
12
|
+
setCurrent(botId: string): Promise<boolean>;
|
|
13
|
+
listAll(): Promise<Array<SlackBotCredentials & {
|
|
14
|
+
is_current: boolean;
|
|
15
|
+
}>>;
|
|
16
|
+
clearCredentials(): Promise<void>;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=credential-manager.d.ts.map
|