agent-messenger 2.8.0 → 2.9.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-plugin/plugin.json +1 -1
- package/README.md +0 -11
- package/dist/package.json +1 -1
- package/dist/src/platforms/channeltalk/commands/snapshot.d.ts +4 -2
- package/dist/src/platforms/channeltalk/commands/snapshot.d.ts.map +1 -1
- package/dist/src/platforms/channeltalk/commands/snapshot.js +86 -31
- package/dist/src/platforms/channeltalk/commands/snapshot.js.map +1 -1
- package/dist/src/platforms/channeltalkbot/commands/snapshot.d.ts +3 -1
- package/dist/src/platforms/channeltalkbot/commands/snapshot.d.ts.map +1 -1
- package/dist/src/platforms/channeltalkbot/commands/snapshot.js +110 -60
- package/dist/src/platforms/channeltalkbot/commands/snapshot.js.map +1 -1
- package/dist/src/platforms/discord/commands/snapshot.d.ts +1 -0
- package/dist/src/platforms/discord/commands/snapshot.d.ts.map +1 -1
- package/dist/src/platforms/discord/commands/snapshot.js +48 -34
- package/dist/src/platforms/discord/commands/snapshot.js.map +1 -1
- package/dist/src/platforms/discordbot/commands/snapshot.d.ts +2 -0
- package/dist/src/platforms/discordbot/commands/snapshot.d.ts.map +1 -1
- package/dist/src/platforms/discordbot/commands/snapshot.js +46 -34
- package/dist/src/platforms/discordbot/commands/snapshot.js.map +1 -1
- package/dist/src/platforms/slack/commands/snapshot.d.ts.map +1 -1
- package/dist/src/platforms/slack/commands/snapshot.js +75 -55
- package/dist/src/platforms/slack/commands/snapshot.js.map +1 -1
- package/dist/src/platforms/teams/commands/snapshot.d.ts +1 -0
- package/dist/src/platforms/teams/commands/snapshot.d.ts.map +1 -1
- package/dist/src/platforms/teams/commands/snapshot.js +44 -31
- package/dist/src/platforms/teams/commands/snapshot.js.map +1 -1
- package/dist/src/platforms/webex/commands/snapshot.d.ts +1 -0
- package/dist/src/platforms/webex/commands/snapshot.d.ts.map +1 -1
- package/dist/src/platforms/webex/commands/snapshot.js +14 -7
- package/dist/src/platforms/webex/commands/snapshot.js.map +1 -1
- package/docs/content/docs/agent-skills.mdx +0 -10
- package/docs/content/docs/cli/channeltalk.mdx +18 -8
- package/docs/content/docs/cli/channeltalkbot.mdx +16 -6
- package/docs/content/docs/cli/discord.mdx +23 -7
- package/docs/content/docs/cli/discordbot.mdx +23 -7
- package/docs/content/docs/cli/slack.mdx +24 -7
- package/docs/content/docs/cli/teams.mdx +24 -8
- package/docs/content/docs/cli/webex.mdx +15 -2
- package/package.json +1 -1
- package/skills/agent-channeltalk/SKILL.md +19 -9
- package/skills/agent-channeltalk/references/common-patterns.md +10 -9
- package/skills/agent-channeltalkbot/SKILL.md +19 -9
- package/skills/agent-channeltalkbot/references/common-patterns.md +10 -9
- package/skills/agent-discord/SKILL.md +18 -9
- package/skills/agent-discord/references/common-patterns.md +8 -7
- package/skills/agent-discordbot/SKILL.md +18 -9
- package/skills/agent-instagram/SKILL.md +1 -1
- package/skills/agent-kakaotalk/SKILL.md +1 -1
- package/skills/agent-line/SKILL.md +1 -1
- package/skills/agent-slack/SKILL.md +19 -10
- package/skills/agent-slack/references/common-patterns.md +4 -7
- package/skills/agent-slackbot/SKILL.md +1 -1
- package/skills/agent-teams/SKILL.md +18 -9
- package/skills/agent-teams/references/common-patterns.md +9 -7
- package/skills/agent-telegram/SKILL.md +1 -1
- package/skills/agent-webex/SKILL.md +13 -4
- package/skills/agent-webex/references/common-patterns.md +8 -2
- package/skills/agent-wechatbot/SKILL.md +1 -1
- package/skills/agent-whatsapp/SKILL.md +1 -1
- package/skills/agent-whatsappbot/SKILL.md +1 -1
- package/src/platforms/channeltalk/commands/snapshot.test.ts +58 -26
- package/src/platforms/channeltalk/commands/snapshot.ts +107 -33
- package/src/platforms/channeltalkbot/commands/snapshot.test.ts +26 -8
- package/src/platforms/channeltalkbot/commands/snapshot.ts +131 -64
- package/src/platforms/discord/commands/snapshot.test.ts +1 -1
- package/src/platforms/discord/commands/snapshot.ts +58 -42
- package/src/platforms/discordbot/commands/snapshot.test.ts +40 -18
- package/src/platforms/discordbot/commands/snapshot.ts +54 -37
- package/src/platforms/slack/commands/snapshot.test.ts +63 -8
- package/src/platforms/slack/commands/snapshot.ts +98 -66
- package/src/platforms/teams/commands/snapshot.test.ts +1 -1
- package/src/platforms/teams/commands/snapshot.ts +53 -38
- package/src/platforms/webex/commands/snapshot.test.ts +14 -1
- package/src/platforms/webex/commands/snapshot.ts +17 -9
|
@@ -10,6 +10,7 @@ import { getClient } from './shared'
|
|
|
10
10
|
interface SnapshotOption extends BotOption {
|
|
11
11
|
channelsOnly?: boolean
|
|
12
12
|
usersOnly?: boolean
|
|
13
|
+
full?: boolean
|
|
13
14
|
limit?: number
|
|
14
15
|
}
|
|
15
16
|
|
|
@@ -31,6 +32,7 @@ interface SnapshotResult {
|
|
|
31
32
|
username: string
|
|
32
33
|
global_name: string | null
|
|
33
34
|
}>
|
|
35
|
+
hint?: string
|
|
34
36
|
error?: string
|
|
35
37
|
}
|
|
36
38
|
|
|
@@ -43,53 +45,66 @@ export async function snapshotAction(options: SnapshotOption): Promise<SnapshotR
|
|
|
43
45
|
}
|
|
44
46
|
|
|
45
47
|
const client = await getClient(options)
|
|
46
|
-
const limit = options.limit ?? 5
|
|
47
48
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
49
|
+
const isFull = options.full || options.channelsOnly || options.usersOnly
|
|
50
|
+
if (isFull) {
|
|
51
|
+
const limit = options.limit ?? 5
|
|
52
|
+
|
|
53
|
+
if (options.usersOnly) {
|
|
54
|
+
const users = await client.listUsers(serverId)
|
|
55
|
+
return {
|
|
56
|
+
server_id: serverId,
|
|
57
|
+
users: users.map((u) => ({
|
|
58
|
+
id: u.id,
|
|
59
|
+
username: u.username,
|
|
60
|
+
global_name: u.global_name ?? null,
|
|
61
|
+
})),
|
|
62
|
+
}
|
|
57
63
|
}
|
|
58
|
-
}
|
|
59
64
|
|
|
60
|
-
|
|
61
|
-
|
|
65
|
+
const allChannels = await client.listChannels(serverId)
|
|
66
|
+
const textChannels = allChannels.filter((ch) => ch.type === 0)
|
|
67
|
+
|
|
68
|
+
if (options.channelsOnly) {
|
|
69
|
+
return {
|
|
70
|
+
server_id: serverId,
|
|
71
|
+
channels: textChannels.map((ch) => ({
|
|
72
|
+
id: ch.id,
|
|
73
|
+
name: ch.name,
|
|
74
|
+
type: ch.type,
|
|
75
|
+
})),
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const channelsWithMessages = await Promise.all(
|
|
80
|
+
textChannels.map(async (ch) => {
|
|
81
|
+
const messages = await client.getMessages(ch.id, limit)
|
|
82
|
+
return {
|
|
83
|
+
id: ch.id,
|
|
84
|
+
name: ch.name,
|
|
85
|
+
messages: messages.map((msg) => ({
|
|
86
|
+
id: msg.id,
|
|
87
|
+
author: msg.author.username,
|
|
88
|
+
content: msg.content,
|
|
89
|
+
timestamp: msg.timestamp,
|
|
90
|
+
})),
|
|
91
|
+
}
|
|
92
|
+
}),
|
|
93
|
+
)
|
|
62
94
|
|
|
63
|
-
if (options.channelsOnly) {
|
|
64
95
|
return {
|
|
65
96
|
server_id: serverId,
|
|
66
|
-
channels:
|
|
67
|
-
id: ch.id,
|
|
68
|
-
name: ch.name,
|
|
69
|
-
type: ch.type,
|
|
70
|
-
})),
|
|
97
|
+
channels: channelsWithMessages,
|
|
71
98
|
}
|
|
72
99
|
}
|
|
73
100
|
|
|
74
|
-
const
|
|
75
|
-
|
|
76
|
-
const messages = await client.getMessages(ch.id, limit)
|
|
77
|
-
return {
|
|
78
|
-
id: ch.id,
|
|
79
|
-
name: ch.name,
|
|
80
|
-
messages: messages.map((msg) => ({
|
|
81
|
-
id: msg.id,
|
|
82
|
-
author: msg.author.username,
|
|
83
|
-
content: msg.content,
|
|
84
|
-
timestamp: msg.timestamp,
|
|
85
|
-
})),
|
|
86
|
-
}
|
|
87
|
-
}),
|
|
88
|
-
)
|
|
101
|
+
const allChannels = await client.listChannels(serverId)
|
|
102
|
+
const textChannels = allChannels.filter((ch) => ch.type === 0)
|
|
89
103
|
|
|
90
104
|
return {
|
|
91
105
|
server_id: serverId,
|
|
92
|
-
channels:
|
|
106
|
+
channels: textChannels.map((ch) => ({ id: ch.id, name: ch.name })),
|
|
107
|
+
hint: "Use 'message list <channel>' for messages, 'channel info <channel>' for channel details, 'user list' for members.",
|
|
93
108
|
}
|
|
94
109
|
} catch (error) {
|
|
95
110
|
return { error: (error as Error).message }
|
|
@@ -97,10 +112,11 @@ export async function snapshotAction(options: SnapshotOption): Promise<SnapshotR
|
|
|
97
112
|
}
|
|
98
113
|
|
|
99
114
|
export const snapshotCommand = new Command('snapshot')
|
|
100
|
-
.description('Server overview for AI
|
|
115
|
+
.description('Server overview for AI agents (brief by default, use --full for comprehensive data)')
|
|
116
|
+
.option('--full', 'Include messages and members (verbose)')
|
|
101
117
|
.option('--channels-only', 'List channels only, skip messages')
|
|
102
118
|
.option('--users-only', 'List users only')
|
|
103
|
-
.option('--limit <n>', 'Messages per channel (default: 5)', '5')
|
|
119
|
+
.option('--limit <n>', 'Messages per channel with --full (default: 5)', '5')
|
|
104
120
|
.option('--server <id>', 'Use specific server')
|
|
105
121
|
.option('--bot <id>', 'Use specific bot')
|
|
106
122
|
.option('--pretty', 'Pretty print JSON output')
|
|
@@ -108,6 +124,7 @@ export const snapshotCommand = new Command('snapshot')
|
|
|
108
124
|
try {
|
|
109
125
|
const result = await snapshotAction({
|
|
110
126
|
...options,
|
|
127
|
+
full: options.full,
|
|
111
128
|
limit: parseInt(options.limit, 10),
|
|
112
129
|
})
|
|
113
130
|
console.log(formatOutput(result, options.pretty))
|
|
@@ -34,6 +34,12 @@ test('snapshot command has --limit option', () => {
|
|
|
34
34
|
expect(hasLimit).toBe(true)
|
|
35
35
|
})
|
|
36
36
|
|
|
37
|
+
test('snapshot command has --full option', () => {
|
|
38
|
+
const options = snapshotCommand.options
|
|
39
|
+
const hasFull = options.some((opt: any) => opt.long === '--full')
|
|
40
|
+
expect(hasFull).toBe(true)
|
|
41
|
+
})
|
|
42
|
+
|
|
37
43
|
// Test snapshot logic using spyOn (no global mock pollution)
|
|
38
44
|
let credManagerSpy: ReturnType<typeof spyOn>
|
|
39
45
|
let clientTestAuthSpy: ReturnType<typeof spyOn>
|
|
@@ -147,11 +153,66 @@ afterEach(() => {
|
|
|
147
153
|
clientGetMessagesSpy?.mockRestore()
|
|
148
154
|
})
|
|
149
155
|
|
|
156
|
+
test('brief snapshot (default) returns workspace, channels as {id, name}, and hint', async () => {
|
|
157
|
+
const client = await new SlackClient().login({ token: 'xoxc-test', cookie: 'test-cookie' })
|
|
158
|
+
|
|
159
|
+
const auth = await client.testAuth()
|
|
160
|
+
const channels = await client.listChannels()
|
|
161
|
+
const active = channels.filter((ch) => !ch.is_archived)
|
|
162
|
+
|
|
163
|
+
const snapshot = {
|
|
164
|
+
workspace: {
|
|
165
|
+
id: auth.team_id,
|
|
166
|
+
name: auth.team,
|
|
167
|
+
},
|
|
168
|
+
channels: active.map((ch) => ({ id: ch.id, name: ch.name })),
|
|
169
|
+
hint: "Use 'message list <channel>' for messages, 'channel info <channel>' for channel details, 'user list' for users, 'usergroup list' for groups.",
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
expect(snapshot.workspace).toBeDefined()
|
|
173
|
+
expect(snapshot.workspace.id).toBe('T123')
|
|
174
|
+
expect(snapshot.workspace.name).toBe('Test Workspace')
|
|
175
|
+
|
|
176
|
+
expect(snapshot.channels).toBeDefined()
|
|
177
|
+
expect(snapshot.channels.length).toBe(2)
|
|
178
|
+
expect(snapshot.channels[0]).toEqual({ id: 'C123', name: 'general' })
|
|
179
|
+
expect(snapshot.channels[1]).toEqual({ id: 'C456', name: 'random' })
|
|
180
|
+
|
|
181
|
+
expect((snapshot as any).recent_messages).toBeUndefined()
|
|
182
|
+
expect((snapshot as any).users).toBeUndefined()
|
|
183
|
+
expect((snapshot as any).usergroups).toBeUndefined()
|
|
184
|
+
|
|
185
|
+
expect(snapshot.hint).toContain('message list')
|
|
186
|
+
})
|
|
187
|
+
|
|
188
|
+
test('brief snapshot excludes archived channels', async () => {
|
|
189
|
+
const channelsWithArchived: SlackChannel[] = [
|
|
190
|
+
...mockChannels,
|
|
191
|
+
{
|
|
192
|
+
id: 'C789',
|
|
193
|
+
name: 'old-channel',
|
|
194
|
+
is_private: false,
|
|
195
|
+
is_archived: true,
|
|
196
|
+
created: 1234567800,
|
|
197
|
+
creator: 'U123',
|
|
198
|
+
topic: { value: 'Archived', creator: 'U123', last_set: 1234567800 },
|
|
199
|
+
purpose: { value: 'Old channel', creator: 'U123', last_set: 1234567800 },
|
|
200
|
+
},
|
|
201
|
+
]
|
|
202
|
+
|
|
203
|
+
clientListChannelsSpy.mockResolvedValue(channelsWithArchived)
|
|
204
|
+
|
|
205
|
+
const client = await new SlackClient().login({ token: 'xoxc-test', cookie: 'test-cookie' })
|
|
206
|
+
const channels = await client.listChannels()
|
|
207
|
+
const active = channels.filter((ch) => !ch.is_archived)
|
|
208
|
+
|
|
209
|
+
expect(active.length).toBe(2)
|
|
210
|
+
expect(active.every((ch) => !ch.is_archived)).toBe(true)
|
|
211
|
+
})
|
|
212
|
+
|
|
150
213
|
test('full snapshot returns workspace, channels, messages, and users', async () => {
|
|
151
|
-
const credManager = new CredentialManager()
|
|
152
214
|
const client = await new SlackClient().login({ token: 'xoxc-test', cookie: 'test-cookie' })
|
|
153
215
|
|
|
154
|
-
const _workspace = await credManager.getWorkspace()
|
|
155
216
|
const auth = await client.testAuth()
|
|
156
217
|
const channels = await client.listChannels()
|
|
157
218
|
const users = await client.listUsers()
|
|
@@ -218,10 +279,8 @@ test('full snapshot returns workspace, channels, messages, and users', async ()
|
|
|
218
279
|
})
|
|
219
280
|
|
|
220
281
|
test('snapshot with --channels-only excludes messages and users', async () => {
|
|
221
|
-
const credManager = new CredentialManager()
|
|
222
282
|
const client = await new SlackClient().login({ token: 'xoxc-test', cookie: 'test-cookie' })
|
|
223
283
|
|
|
224
|
-
const _workspace = await credManager.getWorkspace()
|
|
225
284
|
const auth = await client.testAuth()
|
|
226
285
|
const channels = await client.listChannels()
|
|
227
286
|
|
|
@@ -249,10 +308,8 @@ test('snapshot with --channels-only excludes messages and users', async () => {
|
|
|
249
308
|
})
|
|
250
309
|
|
|
251
310
|
test('snapshot with --users-only excludes channels and messages', async () => {
|
|
252
|
-
const credManager = new CredentialManager()
|
|
253
311
|
const client = await new SlackClient().login({ token: 'xoxc-test', cookie: 'test-cookie' })
|
|
254
312
|
|
|
255
|
-
const _workspace = await credManager.getWorkspace()
|
|
256
313
|
const auth = await client.testAuth()
|
|
257
314
|
const users = await client.listUsers()
|
|
258
315
|
|
|
@@ -279,10 +336,8 @@ test('snapshot with --users-only excludes channels and messages', async () => {
|
|
|
279
336
|
})
|
|
280
337
|
|
|
281
338
|
test('snapshot respects --limit option for messages', async () => {
|
|
282
|
-
const credManager = new CredentialManager()
|
|
283
339
|
const client = await new SlackClient().login({ token: 'xoxc-test', cookie: 'test-cookie' })
|
|
284
340
|
|
|
285
|
-
const _workspace = await credManager.getWorkspace()
|
|
286
341
|
const auth = await client.testAuth()
|
|
287
342
|
const channels = await client.listChannels()
|
|
288
343
|
|
|
@@ -11,6 +11,7 @@ import type { SlackChannel } from '../types'
|
|
|
11
11
|
async function snapshotAction(options: {
|
|
12
12
|
channelsOnly?: boolean
|
|
13
13
|
usersOnly?: boolean
|
|
14
|
+
full?: boolean
|
|
14
15
|
limit?: number
|
|
15
16
|
pretty?: boolean
|
|
16
17
|
}): Promise<void> {
|
|
@@ -26,7 +27,6 @@ async function snapshotAction(options: {
|
|
|
26
27
|
const client = await new SlackClient().login({ token: workspace.token, cookie: workspace.cookie })
|
|
27
28
|
|
|
28
29
|
const auth = await client.testAuth()
|
|
29
|
-
const messageLimit = options.limit || 20
|
|
30
30
|
|
|
31
31
|
const snapshot: Record<string, any> = {
|
|
32
32
|
workspace: {
|
|
@@ -35,88 +35,120 @@ async function snapshotAction(options: {
|
|
|
35
35
|
},
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
name: ch.name,
|
|
44
|
-
is_private: ch.is_private,
|
|
45
|
-
is_archived: ch.is_archived,
|
|
46
|
-
created: ch.created,
|
|
47
|
-
topic: ch.topic?.value,
|
|
48
|
-
purpose: ch.purpose?.value,
|
|
49
|
-
}))
|
|
50
|
-
|
|
51
|
-
if (!options.channelsOnly) {
|
|
52
|
-
const activeChannels = channels.filter((ch) => !ch.is_archived)
|
|
53
|
-
|
|
54
|
-
const channelMessages = await parallelMap(
|
|
55
|
-
activeChannels,
|
|
56
|
-
async (channel: SlackChannel) => {
|
|
57
|
-
const messages = await client.getMessages(channel.id, messageLimit)
|
|
58
|
-
return messages.map((msg) => ({
|
|
59
|
-
...msg,
|
|
60
|
-
channel_id: channel.id,
|
|
61
|
-
channel_name: channel.name,
|
|
62
|
-
}))
|
|
63
|
-
},
|
|
64
|
-
5,
|
|
65
|
-
)
|
|
66
|
-
|
|
67
|
-
snapshot.recent_messages = channelMessages.flat().map((msg) => ({
|
|
68
|
-
channel_id: msg.channel_id,
|
|
69
|
-
channel_name: msg.channel_name,
|
|
70
|
-
ts: msg.ts,
|
|
71
|
-
text: msg.text,
|
|
72
|
-
user: msg.user,
|
|
73
|
-
username: msg.username,
|
|
74
|
-
thread_ts: msg.thread_ts,
|
|
75
|
-
}))
|
|
76
|
-
}
|
|
38
|
+
const isFull = options.full || options.channelsOnly || options.usersOnly
|
|
39
|
+
if (isFull) {
|
|
40
|
+
await buildFullSnapshot(client, snapshot, options)
|
|
41
|
+
} else {
|
|
42
|
+
await buildBriefSnapshot(client, snapshot, options)
|
|
77
43
|
}
|
|
78
44
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
name: u.name,
|
|
85
|
-
real_name: u.real_name,
|
|
86
|
-
is_admin: u.is_admin,
|
|
87
|
-
is_bot: u.is_bot,
|
|
88
|
-
profile: u.profile,
|
|
89
|
-
}))
|
|
90
|
-
}
|
|
45
|
+
console.log(formatOutput(snapshot, options.pretty))
|
|
46
|
+
} catch (error) {
|
|
47
|
+
handleError(error as Error)
|
|
48
|
+
}
|
|
49
|
+
}
|
|
91
50
|
|
|
92
|
-
|
|
93
|
-
|
|
51
|
+
async function buildBriefSnapshot(
|
|
52
|
+
client: SlackClient,
|
|
53
|
+
snapshot: Record<string, any>,
|
|
54
|
+
options: { channelsOnly?: boolean; usersOnly?: boolean },
|
|
55
|
+
): Promise<void> {
|
|
56
|
+
if (!options.usersOnly) {
|
|
57
|
+
const channels = await client.listChannels()
|
|
58
|
+
const active = channels.filter((ch) => !ch.is_archived)
|
|
59
|
+
snapshot.channels = active.map((ch) => ({ id: ch.id, name: ch.name }))
|
|
60
|
+
}
|
|
94
61
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
62
|
+
snapshot.hint =
|
|
63
|
+
"Use 'message list <channel>' for messages, 'channel info <channel>' for channel details, 'user list' for users, 'usergroup list' for groups."
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
async function buildFullSnapshot(
|
|
67
|
+
client: SlackClient,
|
|
68
|
+
snapshot: Record<string, any>,
|
|
69
|
+
options: { channelsOnly?: boolean; usersOnly?: boolean; limit?: number },
|
|
70
|
+
): Promise<void> {
|
|
71
|
+
const messageLimit = options.limit || 20
|
|
72
|
+
|
|
73
|
+
if (!options.usersOnly) {
|
|
74
|
+
const channels = await client.listChannels()
|
|
75
|
+
|
|
76
|
+
snapshot.channels = channels.map((ch) => ({
|
|
77
|
+
id: ch.id,
|
|
78
|
+
name: ch.name,
|
|
79
|
+
is_private: ch.is_private,
|
|
80
|
+
is_archived: ch.is_archived,
|
|
81
|
+
created: ch.created,
|
|
82
|
+
topic: ch.topic?.value,
|
|
83
|
+
purpose: ch.purpose?.value,
|
|
84
|
+
}))
|
|
85
|
+
|
|
86
|
+
if (!options.channelsOnly) {
|
|
87
|
+
const activeChannels = channels.filter((ch) => !ch.is_archived)
|
|
88
|
+
|
|
89
|
+
const channelMessages = await parallelMap(
|
|
90
|
+
activeChannels,
|
|
91
|
+
async (channel: SlackChannel) => {
|
|
92
|
+
const messages = await client.getMessages(channel.id, messageLimit)
|
|
93
|
+
return messages.map((msg) => ({
|
|
94
|
+
...msg,
|
|
95
|
+
channel_id: channel.id,
|
|
96
|
+
channel_name: channel.name,
|
|
97
|
+
}))
|
|
98
|
+
},
|
|
99
|
+
5,
|
|
100
|
+
)
|
|
101
|
+
|
|
102
|
+
snapshot.recent_messages = channelMessages.flat().map((msg) => ({
|
|
103
|
+
channel_id: msg.channel_id,
|
|
104
|
+
channel_name: msg.channel_name,
|
|
105
|
+
ts: msg.ts,
|
|
106
|
+
text: msg.text,
|
|
107
|
+
user: msg.user,
|
|
108
|
+
username: msg.username,
|
|
109
|
+
thread_ts: msg.thread_ts,
|
|
102
110
|
}))
|
|
103
111
|
}
|
|
112
|
+
}
|
|
104
113
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
114
|
+
if (!options.channelsOnly) {
|
|
115
|
+
const users = await client.listUsers()
|
|
116
|
+
|
|
117
|
+
snapshot.users = users.map((u) => ({
|
|
118
|
+
id: u.id,
|
|
119
|
+
name: u.name,
|
|
120
|
+
real_name: u.real_name,
|
|
121
|
+
is_admin: u.is_admin,
|
|
122
|
+
is_bot: u.is_bot,
|
|
123
|
+
profile: u.profile,
|
|
124
|
+
}))
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
if (!options.channelsOnly && !options.usersOnly) {
|
|
128
|
+
const usergroups = await client.listUsergroups({ includeUsers: true, includeCount: true })
|
|
129
|
+
|
|
130
|
+
snapshot.usergroups = usergroups.map((ug) => ({
|
|
131
|
+
id: ug.id,
|
|
132
|
+
name: ug.name,
|
|
133
|
+
handle: ug.handle,
|
|
134
|
+
description: ug.description,
|
|
135
|
+
user_count: ug.user_count,
|
|
136
|
+
users: ug.users,
|
|
137
|
+
}))
|
|
108
138
|
}
|
|
109
139
|
}
|
|
110
140
|
|
|
111
141
|
export const snapshotCommand = new Command('snapshot')
|
|
112
|
-
.description('Get
|
|
142
|
+
.description('Get workspace overview for AI agents (brief by default, use --full for comprehensive data)')
|
|
143
|
+
.option('--full', 'Include messages, users, and user groups (verbose)')
|
|
113
144
|
.option('--channels-only', 'Include only channels (exclude messages and users)')
|
|
114
145
|
.option('--users-only', 'Include only users (exclude channels and messages)')
|
|
115
|
-
.option('--limit <n>', 'Number of recent messages per channel (default: 20)', '20')
|
|
146
|
+
.option('--limit <n>', 'Number of recent messages per channel with --full (default: 20)', '20')
|
|
116
147
|
.action(async (options) => {
|
|
117
148
|
await snapshotAction({
|
|
118
149
|
channelsOnly: options.channelsOnly,
|
|
119
150
|
usersOnly: options.usersOnly,
|
|
151
|
+
full: options.full,
|
|
120
152
|
limit: parseInt(options.limit, 10),
|
|
121
153
|
pretty: options.pretty,
|
|
122
154
|
})
|
|
@@ -8,7 +8,7 @@ test('snapshot: command is defined', () => {
|
|
|
8
8
|
})
|
|
9
9
|
|
|
10
10
|
test('snapshot: command has correct description', () => {
|
|
11
|
-
expect(snapshotCommand.description()).toContain('team
|
|
11
|
+
expect(snapshotCommand.description()).toContain('team overview')
|
|
12
12
|
})
|
|
13
13
|
|
|
14
14
|
test('snapshot: command has --channels-only option', () => {
|
|
@@ -11,6 +11,7 @@ import type { TeamsChannel } from '../types'
|
|
|
11
11
|
export async function snapshotAction(options: {
|
|
12
12
|
channelsOnly?: boolean
|
|
13
13
|
usersOnly?: boolean
|
|
14
|
+
full?: boolean
|
|
14
15
|
limit?: number
|
|
15
16
|
teamId?: string
|
|
16
17
|
pretty?: boolean
|
|
@@ -34,7 +35,6 @@ export async function snapshotAction(options: {
|
|
|
34
35
|
}
|
|
35
36
|
|
|
36
37
|
const client = await new TeamsClient().login({ token: cred.token, tokenExpiresAt: cred.tokenExpiresAt })
|
|
37
|
-
const messageLimit = options.limit || 20
|
|
38
38
|
|
|
39
39
|
const snapshot: Record<string, unknown> = {}
|
|
40
40
|
|
|
@@ -45,47 +45,60 @@ export async function snapshotAction(options: {
|
|
|
45
45
|
description: team.description,
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
const isFull = options.full || options.channelsOnly || options.usersOnly
|
|
49
|
+
if (isFull) {
|
|
50
|
+
const messageLimit = options.limit || 20
|
|
50
51
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
name: ch.name,
|
|
54
|
-
type: ch.type,
|
|
55
|
-
}))
|
|
52
|
+
if (!options.usersOnly) {
|
|
53
|
+
const channels = await client.listChannels(teamId)
|
|
56
54
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
const messages = await client.getMessages(teamId, channel.id, messageLimit)
|
|
62
|
-
return messages.map((msg) => ({
|
|
63
|
-
...msg,
|
|
64
|
-
channel_name: channel.name,
|
|
65
|
-
}))
|
|
66
|
-
},
|
|
67
|
-
5,
|
|
68
|
-
)
|
|
69
|
-
|
|
70
|
-
snapshot.recent_messages = channelMessages.flat().map((msg) => ({
|
|
71
|
-
channel_id: msg.channel_id,
|
|
72
|
-
channel_name: msg.channel_name,
|
|
73
|
-
id: msg.id,
|
|
74
|
-
author: msg.author.displayName,
|
|
75
|
-
content: msg.content,
|
|
76
|
-
timestamp: msg.timestamp,
|
|
55
|
+
snapshot.channels = channels.map((ch) => ({
|
|
56
|
+
id: ch.id,
|
|
57
|
+
name: ch.name,
|
|
58
|
+
type: ch.type,
|
|
77
59
|
}))
|
|
60
|
+
|
|
61
|
+
if (!options.channelsOnly) {
|
|
62
|
+
const channelMessages = await parallelMap(
|
|
63
|
+
channels,
|
|
64
|
+
async (channel: TeamsChannel) => {
|
|
65
|
+
const messages = await client.getMessages(teamId, channel.id, messageLimit)
|
|
66
|
+
return messages.map((msg) => ({
|
|
67
|
+
...msg,
|
|
68
|
+
channel_name: channel.name,
|
|
69
|
+
}))
|
|
70
|
+
},
|
|
71
|
+
5,
|
|
72
|
+
)
|
|
73
|
+
|
|
74
|
+
snapshot.recent_messages = channelMessages.flat().map((msg) => ({
|
|
75
|
+
channel_id: msg.channel_id,
|
|
76
|
+
channel_name: msg.channel_name,
|
|
77
|
+
id: msg.id,
|
|
78
|
+
author: msg.author.displayName,
|
|
79
|
+
content: msg.content,
|
|
80
|
+
timestamp: msg.timestamp,
|
|
81
|
+
}))
|
|
82
|
+
}
|
|
78
83
|
}
|
|
79
|
-
}
|
|
80
84
|
|
|
81
|
-
|
|
82
|
-
|
|
85
|
+
if (!options.channelsOnly) {
|
|
86
|
+
const users = await client.listUsers(teamId)
|
|
87
|
+
|
|
88
|
+
snapshot.members = users.map((u) => ({
|
|
89
|
+
id: u.id,
|
|
90
|
+
displayName: u.displayName,
|
|
91
|
+
email: u.email || null,
|
|
92
|
+
}))
|
|
93
|
+
}
|
|
94
|
+
} else {
|
|
95
|
+
if (!options.usersOnly) {
|
|
96
|
+
const channels = await client.listChannels(teamId)
|
|
97
|
+
snapshot.channels = channels.map((ch) => ({ id: ch.id, name: ch.name }))
|
|
98
|
+
}
|
|
83
99
|
|
|
84
|
-
snapshot.
|
|
85
|
-
|
|
86
|
-
displayName: u.displayName,
|
|
87
|
-
email: u.email || null,
|
|
88
|
-
}))
|
|
100
|
+
snapshot.hint =
|
|
101
|
+
"Use 'message list <channel>' for messages, 'channel info <channel>' for channel details, 'user list' for members."
|
|
89
102
|
}
|
|
90
103
|
|
|
91
104
|
console.log(formatOutput(snapshot, options.pretty))
|
|
@@ -95,16 +108,18 @@ export async function snapshotAction(options: {
|
|
|
95
108
|
}
|
|
96
109
|
|
|
97
110
|
export const snapshotCommand = new Command('snapshot')
|
|
98
|
-
.description('Get
|
|
111
|
+
.description('Get team overview for AI agents (brief by default, use --full for comprehensive data)')
|
|
112
|
+
.option('--full', 'Include messages and members (verbose)')
|
|
99
113
|
.option('--channels-only', 'Include only channels (exclude messages and members)')
|
|
100
114
|
.option('--users-only', 'Include only members (exclude channels and messages)')
|
|
101
|
-
.option('--limit <n>', 'Number of recent messages per channel (default: 20)', '20')
|
|
115
|
+
.option('--limit <n>', 'Number of recent messages per channel with --full (default: 20)', '20')
|
|
102
116
|
.option('--team-id <id>', 'Team ID (defaults to current team)')
|
|
103
117
|
.option('--pretty', 'Pretty print JSON output')
|
|
104
118
|
.action(async (options) => {
|
|
105
119
|
await snapshotAction({
|
|
106
120
|
channelsOnly: options.channelsOnly,
|
|
107
121
|
usersOnly: options.usersOnly,
|
|
122
|
+
full: options.full,
|
|
108
123
|
limit: parseInt(options.limit, 10),
|
|
109
124
|
teamId: options.teamId,
|
|
110
125
|
pretty: options.pretty,
|
|
@@ -79,9 +79,21 @@ describe('snapshot command', () => {
|
|
|
79
79
|
consoleSpy.mockRestore()
|
|
80
80
|
})
|
|
81
81
|
|
|
82
|
-
test('returns spaces with id
|
|
82
|
+
test('brief snapshot returns spaces with id and title only', async () => {
|
|
83
83
|
await snapshotAction({})
|
|
84
84
|
|
|
85
|
+
expect(consoleSpy).toHaveBeenCalled()
|
|
86
|
+
const output = JSON.parse(consoleSpy.mock.calls[consoleSpy.mock.calls.length - 1][0])
|
|
87
|
+
expect(output.spaces).toHaveLength(1)
|
|
88
|
+
expect(output.spaces[0].id).toBe('space-1')
|
|
89
|
+
expect(output.spaces[0].title).toBe('General')
|
|
90
|
+
expect(output.spaces[0].type).toBeUndefined()
|
|
91
|
+
expect(output.hint).toBeDefined()
|
|
92
|
+
})
|
|
93
|
+
|
|
94
|
+
test('full snapshot returns spaces with id, title, type, lastActivity', async () => {
|
|
95
|
+
await snapshotAction({ full: true })
|
|
96
|
+
|
|
85
97
|
expect(consoleSpy).toHaveBeenCalled()
|
|
86
98
|
const output = JSON.parse(consoleSpy.mock.calls[consoleSpy.mock.calls.length - 1][0])
|
|
87
99
|
expect(output.spaces).toHaveLength(1)
|
|
@@ -89,6 +101,7 @@ describe('snapshot command', () => {
|
|
|
89
101
|
expect(output.spaces[0].title).toBe('General')
|
|
90
102
|
expect(output.spaces[0].type).toBe('group')
|
|
91
103
|
expect(output.spaces[0].lastActivity).toBe('2024-01-15T00:00:00.000Z')
|
|
104
|
+
expect(output.hint).toBeUndefined()
|
|
92
105
|
})
|
|
93
106
|
|
|
94
107
|
test('filters spaces to only those in my memberships', async () => {
|
|
@@ -5,7 +5,7 @@ import { formatOutput } from '@/shared/utils/output'
|
|
|
5
5
|
|
|
6
6
|
import { WebexClient } from '../client'
|
|
7
7
|
|
|
8
|
-
export async function snapshotAction(options: { pretty?: boolean }): Promise<void> {
|
|
8
|
+
export async function snapshotAction(options: { full?: boolean; pretty?: boolean }): Promise<void> {
|
|
9
9
|
try {
|
|
10
10
|
const client = await new WebexClient().login()
|
|
11
11
|
|
|
@@ -15,13 +15,19 @@ export async function snapshotAction(options: { pretty?: boolean }): Promise<voi
|
|
|
15
15
|
const allSpaces = await client.listSpaces({ max: 100 })
|
|
16
16
|
const spaces = allSpaces.filter((s) => myRoomIds.has(s.id))
|
|
17
17
|
|
|
18
|
-
const snapshot = {
|
|
19
|
-
spaces:
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
18
|
+
const snapshot: Record<string, any> = {
|
|
19
|
+
spaces: options.full
|
|
20
|
+
? spaces.map((s) => ({
|
|
21
|
+
id: s.id,
|
|
22
|
+
title: s.title,
|
|
23
|
+
type: s.type,
|
|
24
|
+
lastActivity: s.lastActivity,
|
|
25
|
+
}))
|
|
26
|
+
: spaces.map((s) => ({ id: s.id, title: s.title })),
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
if (!options.full) {
|
|
30
|
+
snapshot.hint = "Use 'message list <space>' for messages, 'space info <space>' for space details."
|
|
25
31
|
}
|
|
26
32
|
|
|
27
33
|
console.log(formatOutput(snapshot, options.pretty))
|
|
@@ -31,10 +37,12 @@ export async function snapshotAction(options: { pretty?: boolean }): Promise<voi
|
|
|
31
37
|
}
|
|
32
38
|
|
|
33
39
|
export const snapshotCommand = new Command('snapshot')
|
|
34
|
-
.description('Get workspace
|
|
40
|
+
.description('Get workspace overview for AI agents (brief by default, use --full for comprehensive data)')
|
|
41
|
+
.option('--full', 'Include full space details (verbose)')
|
|
35
42
|
.option('--pretty', 'Pretty print JSON output')
|
|
36
43
|
.action(async (options) => {
|
|
37
44
|
await snapshotAction({
|
|
45
|
+
full: options.full,
|
|
38
46
|
pretty: options.pretty,
|
|
39
47
|
})
|
|
40
48
|
})
|