agent-messenger 2.21.0 → 2.22.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.
Files changed (65) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/dist/package.json +1 -1
  3. package/dist/src/platforms/webex/client.d.ts +19 -0
  4. package/dist/src/platforms/webex/client.d.ts.map +1 -1
  5. package/dist/src/platforms/webex/client.js +81 -1
  6. package/dist/src/platforms/webex/client.js.map +1 -1
  7. package/dist/src/platforms/webexbot/cli.d.ts.map +1 -1
  8. package/dist/src/platforms/webexbot/cli.js +4 -1
  9. package/dist/src/platforms/webexbot/cli.js.map +1 -1
  10. package/dist/src/platforms/webexbot/client.d.ts +20 -0
  11. package/dist/src/platforms/webexbot/client.d.ts.map +1 -1
  12. package/dist/src/platforms/webexbot/client.js +15 -1
  13. package/dist/src/platforms/webexbot/client.js.map +1 -1
  14. package/dist/src/platforms/webexbot/commands/file.d.ts +22 -0
  15. package/dist/src/platforms/webexbot/commands/file.d.ts.map +1 -0
  16. package/dist/src/platforms/webexbot/commands/file.js +64 -0
  17. package/dist/src/platforms/webexbot/commands/file.js.map +1 -0
  18. package/dist/src/platforms/webexbot/commands/index.d.ts +3 -0
  19. package/dist/src/platforms/webexbot/commands/index.d.ts.map +1 -1
  20. package/dist/src/platforms/webexbot/commands/index.js +3 -0
  21. package/dist/src/platforms/webexbot/commands/index.js.map +1 -1
  22. package/dist/src/platforms/webexbot/commands/message.d.ts +7 -0
  23. package/dist/src/platforms/webexbot/commands/message.d.ts.map +1 -1
  24. package/dist/src/platforms/webexbot/commands/message.js +52 -1
  25. package/dist/src/platforms/webexbot/commands/message.js.map +1 -1
  26. package/dist/src/platforms/webexbot/commands/snapshot.d.ts +24 -0
  27. package/dist/src/platforms/webexbot/commands/snapshot.d.ts.map +1 -0
  28. package/dist/src/platforms/webexbot/commands/snapshot.js +37 -0
  29. package/dist/src/platforms/webexbot/commands/snapshot.js.map +1 -0
  30. package/dist/src/platforms/webexbot/commands/user.d.ts +30 -0
  31. package/dist/src/platforms/webexbot/commands/user.d.ts.map +1 -0
  32. package/dist/src/platforms/webexbot/commands/user.js +66 -0
  33. package/dist/src/platforms/webexbot/commands/user.js.map +1 -0
  34. package/docs/content/docs/cli/webexbot.mdx +2 -0
  35. package/docs/content/docs/sdk/webexbot.mdx +2 -0
  36. package/package.json +1 -1
  37. package/skills/agent-channeltalk/SKILL.md +1 -1
  38. package/skills/agent-channeltalkbot/SKILL.md +1 -1
  39. package/skills/agent-discord/SKILL.md +1 -1
  40. package/skills/agent-discordbot/SKILL.md +1 -1
  41. package/skills/agent-instagram/SKILL.md +1 -1
  42. package/skills/agent-kakaotalk/SKILL.md +1 -1
  43. package/skills/agent-line/SKILL.md +1 -1
  44. package/skills/agent-slack/SKILL.md +1 -1
  45. package/skills/agent-slackbot/SKILL.md +1 -1
  46. package/skills/agent-teams/SKILL.md +1 -1
  47. package/skills/agent-telegram/SKILL.md +1 -1
  48. package/skills/agent-telegrambot/SKILL.md +1 -1
  49. package/skills/agent-webex/SKILL.md +1 -1
  50. package/skills/agent-webexbot/SKILL.md +58 -5
  51. package/skills/agent-webexbot/references/common-patterns.md +118 -0
  52. package/skills/agent-wechatbot/SKILL.md +1 -1
  53. package/skills/agent-whatsapp/SKILL.md +1 -1
  54. package/skills/agent-whatsappbot/SKILL.md +1 -1
  55. package/src/platforms/webex/client.test.ts +10 -0
  56. package/src/platforms/webex/client.ts +97 -3
  57. package/src/platforms/webexbot/cli.ts +6 -0
  58. package/src/platforms/webexbot/client.test.ts +198 -0
  59. package/src/platforms/webexbot/client.ts +29 -3
  60. package/src/platforms/webexbot/commands/file.ts +104 -0
  61. package/src/platforms/webexbot/commands/index.ts +3 -0
  62. package/src/platforms/webexbot/commands/message.ts +68 -2
  63. package/src/platforms/webexbot/commands/snapshot.ts +60 -0
  64. package/src/platforms/webexbot/commands/user.test.ts +77 -0
  65. package/src/platforms/webexbot/commands/user.ts +98 -0
@@ -0,0 +1,104 @@
1
+ import { readFile, writeFile } from 'node:fs/promises'
2
+ import { basename, resolve } from 'node:path'
3
+
4
+ import { Command } from 'commander'
5
+
6
+ import { cliOutput } from '@/shared/utils/cli-output'
7
+
8
+ import type { BotOption } from './shared'
9
+ import { getClient } from './shared'
10
+
11
+ interface FileResult {
12
+ id?: string
13
+ roomId?: string
14
+ files?: string[]
15
+ created?: string
16
+ downloaded?: string
17
+ filename?: string
18
+ contentType?: string
19
+ size?: number
20
+ error?: string
21
+ }
22
+
23
+ export async function uploadAction(
24
+ space: string,
25
+ path: string,
26
+ options: BotOption & { text?: string; markdown?: boolean; parent?: string },
27
+ ): Promise<FileResult> {
28
+ try {
29
+ const client = await getClient(options)
30
+ const filePath = resolve(path)
31
+ const content = await readFile(filePath)
32
+ const message = await client.uploadFile(
33
+ space,
34
+ { content: new Blob([content]), filename: basename(filePath) },
35
+ { text: options.text, markdown: options.markdown, parentId: options.parent },
36
+ )
37
+
38
+ return {
39
+ id: message.id,
40
+ roomId: message.roomId,
41
+ files: message.files,
42
+ created: message.created,
43
+ }
44
+ } catch (error) {
45
+ return { error: (error as Error).message }
46
+ }
47
+ }
48
+
49
+ export async function downloadAction(
50
+ contentRef: string,
51
+ output: string | undefined,
52
+ options: BotOption,
53
+ ): Promise<FileResult> {
54
+ try {
55
+ const client = await getClient(options)
56
+ const { data, filename, contentType } = await client.downloadContent(contentRef)
57
+ // When no explicit output is given, confine the server-provided name to cwd.
58
+ const outputPath = output ? resolve(output) : resolve(process.cwd(), basename(filename))
59
+ await writeFile(outputPath, Buffer.from(data))
60
+
61
+ return {
62
+ downloaded: outputPath,
63
+ filename,
64
+ contentType,
65
+ size: data.byteLength,
66
+ }
67
+ } catch (error) {
68
+ return { error: (error as Error).message }
69
+ }
70
+ }
71
+
72
+ export const fileCommand = new Command('file')
73
+ .description('File commands')
74
+ .addCommand(
75
+ new Command('upload')
76
+ .description('Upload a local file to a space')
77
+ .argument('<space>', 'Space/Room ID')
78
+ .argument('<path>', 'Local file path')
79
+ .option('--text <text>', 'Optional message to send with the file')
80
+ .option('--markdown', 'Treat --text as markdown')
81
+ .option('--parent <id>', 'Reply within a thread (parent message ID)')
82
+ .option('--bot <id>', 'Use specific bot')
83
+ .option('--pretty', 'Pretty print JSON output')
84
+ .action(
85
+ async (
86
+ space: string,
87
+ path: string,
88
+ opts: BotOption & { text?: string; markdown?: boolean; parent?: string },
89
+ ) => {
90
+ cliOutput(await uploadAction(space, path, opts), opts.pretty)
91
+ },
92
+ ),
93
+ )
94
+ .addCommand(
95
+ new Command('download')
96
+ .description('Download a file attachment by content URL or ID')
97
+ .argument('<content>', 'File content URL (from message.files) or content ID')
98
+ .argument('[output]', 'Output path (defaults to original filename)')
99
+ .option('--bot <id>', 'Use specific bot')
100
+ .option('--pretty', 'Pretty print JSON output')
101
+ .action(async (content: string, output: string | undefined, opts: BotOption) => {
102
+ cliOutput(await downloadAction(content, output, opts), opts.pretty)
103
+ }),
104
+ )
@@ -1,6 +1,9 @@
1
1
  export { authCommand } from './auth'
2
+ export { fileCommand } from './file'
2
3
  export { listenCommand } from './listen'
3
4
  export { memberCommand } from './member'
4
5
  export { messageCommand } from './message'
6
+ export { snapshotCommand } from './snapshot'
5
7
  export { spaceCommand } from './space'
8
+ export { userCommand } from './user'
6
9
  export { whoamiCommand } from './whoami'
@@ -40,11 +40,27 @@ function formatMessage(message: WebexMessage): MessageResult {
40
40
  export async function sendAction(
41
41
  space: string,
42
42
  text: string,
43
+ options: BotOption & { markdown?: boolean; parent?: string },
44
+ ): Promise<MessageResult> {
45
+ try {
46
+ const client = await getClient(options)
47
+ const message = await client.sendMessage(space, text, { markdown: options.markdown, parentId: options.parent })
48
+
49
+ return formatMessage(message)
50
+ } catch (error) {
51
+ return { error: (error as Error).message }
52
+ }
53
+ }
54
+
55
+ export async function replyAction(
56
+ space: string,
57
+ parentId: string,
58
+ text: string,
43
59
  options: BotOption & { markdown?: boolean },
44
60
  ): Promise<MessageResult> {
45
61
  try {
46
62
  const client = await getClient(options)
47
- const message = await client.sendMessage(space, text, { markdown: options.markdown })
63
+ const message = await client.sendMessage(space, text, { markdown: options.markdown, parentId })
48
64
 
49
65
  return formatMessage(message)
50
66
  } catch (error) {
@@ -52,6 +68,30 @@ export async function sendAction(
52
68
  }
53
69
  }
54
70
 
71
+ export async function repliesAction(
72
+ space: string,
73
+ parentId: string,
74
+ options: BotOption & { max?: string },
75
+ ): Promise<MessageResult> {
76
+ try {
77
+ const client = await getClient(options)
78
+ const max = options.max ? parseInt(options.max, 10) : 50
79
+ const messages = await client.listReplies(space, parentId, { max })
80
+
81
+ return {
82
+ messages: messages.map((msg) => ({
83
+ id: msg.id,
84
+ roomId: msg.roomId,
85
+ text: msg.text,
86
+ personEmail: msg.personEmail,
87
+ created: msg.created,
88
+ })),
89
+ }
90
+ } catch (error) {
91
+ return { error: (error as Error).message }
92
+ }
93
+ }
94
+
55
95
  export async function dmAction(
56
96
  email: string,
57
97
  text: string,
@@ -133,12 +173,38 @@ export const messageCommand = new Command('message')
133
173
  .argument('<space>', 'Space/Room ID')
134
174
  .argument('<text>', 'Message text')
135
175
  .option('--markdown', 'Send as markdown')
176
+ .option('--parent <id>', 'Reply within a thread (parent message ID)')
136
177
  .option('--bot <id>', 'Use specific bot')
137
178
  .option('--pretty', 'Pretty print JSON output')
138
- .action(async (space: string, text: string, opts: BotOption & { markdown?: boolean }) => {
179
+ .action(async (space: string, text: string, opts: BotOption & { markdown?: boolean; parent?: string }) => {
139
180
  cliOutput(await sendAction(space, text, opts), opts.pretty)
140
181
  }),
141
182
  )
183
+ .addCommand(
184
+ new Command('reply')
185
+ .description('Reply to a message in a thread')
186
+ .argument('<space>', 'Space/Room ID')
187
+ .argument('<parent>', 'Parent message ID')
188
+ .argument('<text>', 'Reply text')
189
+ .option('--markdown', 'Send as markdown')
190
+ .option('--bot <id>', 'Use specific bot')
191
+ .option('--pretty', 'Pretty print JSON output')
192
+ .action(async (space: string, parent: string, text: string, opts: BotOption & { markdown?: boolean }) => {
193
+ cliOutput(await replyAction(space, parent, text, opts), opts.pretty)
194
+ }),
195
+ )
196
+ .addCommand(
197
+ new Command('replies')
198
+ .description('List replies in a thread')
199
+ .argument('<space>', 'Space/Room ID')
200
+ .argument('<parent>', 'Parent message ID')
201
+ .option('--max <n>', 'Number of replies to fetch', '50')
202
+ .option('--bot <id>', 'Use specific bot')
203
+ .option('--pretty', 'Pretty print JSON output')
204
+ .action(async (space: string, parent: string, opts: BotOption & { max?: string }) => {
205
+ cliOutput(await repliesAction(space, parent, opts), opts.pretty)
206
+ }),
207
+ )
142
208
  .addCommand(
143
209
  new Command('dm')
144
210
  .description('Send a direct message by recipient email')
@@ -0,0 +1,60 @@
1
+ import { Command } from 'commander'
2
+
3
+ import { cliOutput } from '@/shared/utils/cli-output'
4
+
5
+ import type { BotOption } from './shared'
6
+ import { getClient } from './shared'
7
+
8
+ interface SnapshotResult {
9
+ bot?: {
10
+ id: string
11
+ displayName: string
12
+ emails: string[]
13
+ }
14
+ spaces?: Array<{
15
+ id: string
16
+ title: string
17
+ type?: 'group' | 'direct'
18
+ lastActivity?: string
19
+ }>
20
+ hint?: string
21
+ error?: string
22
+ }
23
+
24
+ export async function snapshotAction(options: BotOption & { full?: boolean; max?: string }): Promise<SnapshotResult> {
25
+ try {
26
+ const client = await getClient(options)
27
+ const max = options.max ? parseInt(options.max, 10) : 100
28
+
29
+ const [me, spaces] = await Promise.all([client.testAuth(), client.listSpaces({ max })])
30
+
31
+ const result: SnapshotResult = {
32
+ bot: {
33
+ id: me.id,
34
+ displayName: me.displayName,
35
+ emails: me.emails,
36
+ },
37
+ spaces: options.full
38
+ ? spaces.map((s) => ({ id: s.id, title: s.title, type: s.type, lastActivity: s.lastActivity }))
39
+ : spaces.map((s) => ({ id: s.id, title: s.title })),
40
+ }
41
+
42
+ if (!options.full) {
43
+ result.hint = "Use 'message list <space>' for messages, 'space info <space>' for details."
44
+ }
45
+
46
+ return result
47
+ } catch (error) {
48
+ return { error: (error as Error).message }
49
+ }
50
+ }
51
+
52
+ export const snapshotCommand = new Command('snapshot')
53
+ .description('Workspace overview for AI agents (brief by default, --full for details)')
54
+ .option('--full', 'Include full space details')
55
+ .option('--max <n>', 'Number of spaces to retrieve', '100')
56
+ .option('--bot <id>', 'Use specific bot')
57
+ .option('--pretty', 'Pretty print JSON output')
58
+ .action(async (opts: BotOption & { full?: boolean; max?: string }) => {
59
+ cliOutput(await snapshotAction(opts), opts.pretty)
60
+ })
@@ -0,0 +1,77 @@
1
+ import { afterEach, beforeEach, describe, expect, it, mock } from 'bun:test'
2
+ import { existsSync, rmSync } from 'node:fs'
3
+ import { mkdir } from 'node:fs/promises'
4
+ import { tmpdir } from 'node:os'
5
+ import { join } from 'node:path'
6
+
7
+ const mockListPeople = mock(() =>
8
+ Promise.resolve([
9
+ {
10
+ id: 'p1',
11
+ emails: ['alice@example.com'],
12
+ displayName: 'Alice',
13
+ orgId: 'o1',
14
+ type: 'person' as const,
15
+ created: '',
16
+ },
17
+ ]),
18
+ )
19
+
20
+ const mockGetPerson = mock(() =>
21
+ Promise.resolve({
22
+ id: 'p1',
23
+ emails: ['alice@example.com'],
24
+ displayName: 'Alice',
25
+ orgId: 'o1',
26
+ type: 'person' as const,
27
+ created: '2024-01-01T00:00:00Z',
28
+ }),
29
+ )
30
+
31
+ mock.module('../client', () => ({
32
+ WebexBotClient: class MockWebexBotClient {
33
+ async login(): Promise<this> {
34
+ return this
35
+ }
36
+ listPeople = mockListPeople
37
+ getPerson = mockGetPerson
38
+ },
39
+ }))
40
+
41
+ import { WebexBotCredentialManager } from '../credential-manager'
42
+ import { infoAction, listAction } from './user'
43
+
44
+ describe('webexbot user commands', () => {
45
+ let tempDir: string
46
+ let manager: WebexBotCredentialManager
47
+
48
+ beforeEach(async () => {
49
+ tempDir = join(tmpdir(), `webexbot-user-test-${Date.now()}`)
50
+ await mkdir(tempDir, { recursive: true })
51
+ manager = new WebexBotCredentialManager(tempDir)
52
+ await manager.setCredentials({ token: 'token123', bot_id: 'bot1', bot_name: 'Bot' })
53
+ mockListPeople.mockClear()
54
+ mockGetPerson.mockClear()
55
+ })
56
+
57
+ afterEach(() => {
58
+ if (existsSync(tempDir)) {
59
+ rmSync(tempDir, { recursive: true })
60
+ }
61
+ })
62
+
63
+ it('lists people by email', async () => {
64
+ const result = await listAction({ _credManager: manager, email: 'alice@example.com' })
65
+
66
+ expect(result.users).toHaveLength(1)
67
+ expect(result.users?.[0].displayName).toBe('Alice')
68
+ expect(mockListPeople).toHaveBeenCalled()
69
+ })
70
+
71
+ it('gets a person by id', async () => {
72
+ const result = await infoAction('p1', { _credManager: manager })
73
+
74
+ expect(result.id).toBe('p1')
75
+ expect(result.displayName).toBe('Alice')
76
+ })
77
+ })
@@ -0,0 +1,98 @@
1
+ import { Command } from 'commander'
2
+
3
+ import { cliOutput } from '@/shared/utils/cli-output'
4
+
5
+ import type { WebexPerson } from '../../webex/types'
6
+ import type { BotOption } from './shared'
7
+ import { getClient } from './shared'
8
+
9
+ interface UserResult {
10
+ id?: string
11
+ emails?: string[]
12
+ displayName?: string
13
+ nickName?: string
14
+ firstName?: string
15
+ lastName?: string
16
+ avatar?: string
17
+ orgId?: string
18
+ type?: 'person' | 'bot'
19
+ created?: string
20
+ users?: Array<{
21
+ id: string
22
+ emails: string[]
23
+ displayName: string
24
+ type: 'person' | 'bot'
25
+ }>
26
+ error?: string
27
+ }
28
+
29
+ function formatPerson(person: WebexPerson): UserResult {
30
+ return {
31
+ id: person.id,
32
+ emails: person.emails,
33
+ displayName: person.displayName,
34
+ nickName: person.nickName,
35
+ firstName: person.firstName,
36
+ lastName: person.lastName,
37
+ avatar: person.avatar,
38
+ orgId: person.orgId,
39
+ type: person.type,
40
+ created: person.created,
41
+ }
42
+ }
43
+
44
+ export async function listAction(
45
+ options: BotOption & { email?: string; displayName?: string; max?: string },
46
+ ): Promise<UserResult> {
47
+ try {
48
+ const client = await getClient(options)
49
+ const max = options.max ? parseInt(options.max, 10) : undefined
50
+ const people = await client.listPeople({ email: options.email, displayName: options.displayName, max })
51
+
52
+ return {
53
+ users: people.map((p) => ({
54
+ id: p.id,
55
+ emails: p.emails,
56
+ displayName: p.displayName,
57
+ type: p.type,
58
+ })),
59
+ }
60
+ } catch (error) {
61
+ return { error: (error as Error).message }
62
+ }
63
+ }
64
+
65
+ export async function infoAction(personId: string, options: BotOption): Promise<UserResult> {
66
+ try {
67
+ const client = await getClient(options)
68
+ const person = await client.getPerson(personId)
69
+ return formatPerson(person)
70
+ } catch (error) {
71
+ return { error: (error as Error).message }
72
+ }
73
+ }
74
+
75
+ export const userCommand = new Command('user')
76
+ .description('User commands')
77
+ .addCommand(
78
+ new Command('list')
79
+ .description('Search people by email or display name')
80
+ .option('--email <email>', 'Filter by exact email')
81
+ .option('--display-name <name>', 'Filter by display name prefix')
82
+ .option('--max <n>', 'Number of users to retrieve')
83
+ .option('--bot <id>', 'Use specific bot')
84
+ .option('--pretty', 'Pretty print JSON output')
85
+ .action(async (opts: BotOption & { email?: string; displayName?: string; max?: string }) => {
86
+ cliOutput(await listAction(opts), opts.pretty)
87
+ }),
88
+ )
89
+ .addCommand(
90
+ new Command('info')
91
+ .description('Get details for a person')
92
+ .argument('<id>', 'Person ID')
93
+ .option('--bot <id>', 'Use specific bot')
94
+ .option('--pretty', 'Pretty print JSON output')
95
+ .action(async (personId: string, opts: BotOption) => {
96
+ cliOutput(await infoAction(personId, opts), opts.pretty)
97
+ }),
98
+ )