agent-messenger 2.17.0 → 2.19.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 (112) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/bunfig.toml +1 -0
  3. package/dist/package.json +1 -1
  4. package/dist/src/platforms/discordbot/client.d.ts +1 -0
  5. package/dist/src/platforms/discordbot/client.d.ts.map +1 -1
  6. package/dist/src/platforms/discordbot/client.js +3 -0
  7. package/dist/src/platforms/discordbot/client.js.map +1 -1
  8. package/dist/src/platforms/discordbot/commands/message.d.ts +1 -0
  9. package/dist/src/platforms/discordbot/commands/message.d.ts.map +1 -1
  10. package/dist/src/platforms/discordbot/commands/message.js +2 -0
  11. package/dist/src/platforms/discordbot/commands/message.js.map +1 -1
  12. package/dist/src/platforms/instagram/commands/auth.d.ts.map +1 -1
  13. package/dist/src/platforms/instagram/commands/auth.js +1 -3
  14. package/dist/src/platforms/instagram/commands/auth.js.map +1 -1
  15. package/dist/src/platforms/kakaotalk/client.d.ts +4 -2
  16. package/dist/src/platforms/kakaotalk/client.d.ts.map +1 -1
  17. package/dist/src/platforms/kakaotalk/client.js +16 -2
  18. package/dist/src/platforms/kakaotalk/client.js.map +1 -1
  19. package/dist/src/platforms/kakaotalk/commands/auth.d.ts.map +1 -1
  20. package/dist/src/platforms/kakaotalk/commands/auth.js +2 -17
  21. package/dist/src/platforms/kakaotalk/commands/auth.js.map +1 -1
  22. package/dist/src/platforms/kakaotalk/commands/message.d.ts.map +1 -1
  23. package/dist/src/platforms/kakaotalk/commands/message.js +23 -1
  24. package/dist/src/platforms/kakaotalk/commands/message.js.map +1 -1
  25. package/dist/src/platforms/kakaotalk/index.d.ts +1 -1
  26. package/dist/src/platforms/kakaotalk/index.d.ts.map +1 -1
  27. package/dist/src/platforms/kakaotalk/index.js.map +1 -1
  28. package/dist/src/platforms/kakaotalk/protocol/session.d.ts +2 -1
  29. package/dist/src/platforms/kakaotalk/protocol/session.d.ts.map +1 -1
  30. package/dist/src/platforms/kakaotalk/protocol/session.js +15 -0
  31. package/dist/src/platforms/kakaotalk/protocol/session.js.map +1 -1
  32. package/dist/src/platforms/kakaotalk/types.d.ts +18 -0
  33. package/dist/src/platforms/kakaotalk/types.d.ts.map +1 -1
  34. package/dist/src/platforms/kakaotalk/types.js +1 -0
  35. package/dist/src/platforms/kakaotalk/types.js.map +1 -1
  36. package/dist/src/platforms/line/commands/auth.d.ts.map +1 -1
  37. package/dist/src/platforms/line/commands/auth.js +2 -4
  38. package/dist/src/platforms/line/commands/auth.js.map +1 -1
  39. package/dist/src/platforms/telegram/commands/auth.d.ts.map +1 -1
  40. package/dist/src/platforms/telegram/commands/auth.js +5 -7
  41. package/dist/src/platforms/telegram/commands/auth.js.map +1 -1
  42. package/dist/src/platforms/webex/commands/auth.d.ts +5 -2
  43. package/dist/src/platforms/webex/commands/auth.d.ts.map +1 -1
  44. package/dist/src/platforms/webex/commands/auth.js +59 -1
  45. package/dist/src/platforms/webex/commands/auth.js.map +1 -1
  46. package/dist/src/platforms/webex/credential-manager.d.ts +11 -0
  47. package/dist/src/platforms/webex/credential-manager.d.ts.map +1 -1
  48. package/dist/src/platforms/webex/credential-manager.js +37 -0
  49. package/dist/src/platforms/webex/credential-manager.js.map +1 -1
  50. package/dist/src/platforms/whatsapp/commands/auth.d.ts.map +1 -1
  51. package/dist/src/platforms/whatsapp/commands/auth.js +2 -4
  52. package/dist/src/platforms/whatsapp/commands/auth.js.map +1 -1
  53. package/dist/src/shared/chromium/browsers.js +1 -1
  54. package/dist/src/shared/chromium/browsers.js.map +1 -1
  55. package/dist/src/shared/utils/interactive.d.ts +3 -0
  56. package/dist/src/shared/utils/interactive.d.ts.map +1 -0
  57. package/dist/src/shared/utils/interactive.js +16 -0
  58. package/dist/src/shared/utils/interactive.js.map +1 -0
  59. package/docs/content/docs/cli/discordbot.mdx +6 -0
  60. package/docs/content/docs/sdk/discordbot.mdx +4 -0
  61. package/package.json +1 -1
  62. package/skills/agent-channeltalk/SKILL.md +1 -1
  63. package/skills/agent-channeltalkbot/SKILL.md +1 -1
  64. package/skills/agent-discord/SKILL.md +1 -1
  65. package/skills/agent-discordbot/SKILL.md +9 -1
  66. package/skills/agent-instagram/SKILL.md +1 -1
  67. package/skills/agent-kakaotalk/SKILL.md +24 -1
  68. package/skills/agent-line/SKILL.md +1 -1
  69. package/skills/agent-slack/SKILL.md +1 -1
  70. package/skills/agent-slackbot/SKILL.md +1 -1
  71. package/skills/agent-teams/SKILL.md +1 -1
  72. package/skills/agent-telegram/SKILL.md +1 -1
  73. package/skills/agent-telegrambot/SKILL.md +1 -1
  74. package/skills/agent-webex/SKILL.md +32 -1
  75. package/skills/agent-wechatbot/SKILL.md +1 -1
  76. package/skills/agent-whatsapp/SKILL.md +1 -1
  77. package/skills/agent-whatsappbot/SKILL.md +1 -1
  78. package/src/platforms/discord/commands/dm.test.ts +28 -20
  79. package/src/platforms/discord/commands/reaction.test.ts +12 -7
  80. package/src/platforms/discordbot/client.test.ts +17 -0
  81. package/src/platforms/discordbot/client.ts +9 -2
  82. package/src/platforms/discordbot/commands/message.test.ts +28 -11
  83. package/src/platforms/discordbot/commands/message.ts +4 -2
  84. package/src/platforms/instagram/commands/auth.test.ts +11 -9
  85. package/src/platforms/instagram/commands/auth.ts +1 -4
  86. package/src/platforms/instagram/commands/chat.test.ts +8 -6
  87. package/src/platforms/instagram/commands/message.test.ts +8 -6
  88. package/src/platforms/kakaotalk/client.test.ts +57 -0
  89. package/src/platforms/kakaotalk/client.ts +23 -2
  90. package/src/platforms/kakaotalk/commands/auth.ts +2 -18
  91. package/src/platforms/kakaotalk/commands/message.test.ts +42 -0
  92. package/src/platforms/kakaotalk/commands/message.ts +33 -2
  93. package/src/platforms/kakaotalk/index.ts +2 -0
  94. package/src/platforms/kakaotalk/protocol/session.ts +15 -1
  95. package/src/platforms/kakaotalk/types.ts +24 -0
  96. package/src/platforms/line/commands/auth.ts +2 -5
  97. package/src/platforms/telegram/commands/auth.ts +5 -8
  98. package/src/platforms/webex/commands/auth.test.ts +178 -14
  99. package/src/platforms/webex/commands/auth.ts +102 -3
  100. package/src/platforms/webex/commands/member.test.ts +14 -20
  101. package/src/platforms/webex/commands/message.test.ts +11 -20
  102. package/src/platforms/webex/commands/snapshot.test.ts +11 -20
  103. package/src/platforms/webex/commands/space.test.ts +15 -23
  104. package/src/platforms/webex/commands/whoami.test.ts +8 -22
  105. package/src/platforms/webex/credential-manager.test.ts +78 -0
  106. package/src/platforms/webex/credential-manager.ts +59 -0
  107. package/src/platforms/whatsapp/commands/auth.ts +2 -5
  108. package/src/shared/chromium/browsers.ts +1 -1
  109. package/src/shared/utils/interactive.test.ts +55 -0
  110. package/src/shared/utils/interactive.ts +15 -0
  111. package/src/test-setup.ts +5 -0
  112. package/tsconfig.json +1 -1
@@ -3,6 +3,7 @@ import { rm } from 'node:fs/promises'
3
3
  import { Command } from 'commander'
4
4
 
5
5
  import { handleError } from '@/shared/utils/error-handler'
6
+ import { isInteractive } from '@/shared/utils/interactive'
6
7
  import { formatOutput } from '@/shared/utils/output'
7
8
  import { displayQR } from '@/shared/utils/qr'
8
9
  import { info } from '@/shared/utils/stderr'
@@ -22,10 +23,6 @@ interface StatusOptions {
22
23
  pretty?: boolean
23
24
  }
24
25
 
25
- function isInteractiveSession(): boolean {
26
- return Boolean(process.stdin.isTTY && process.stdout.isTTY)
27
- }
28
-
29
26
  async function loginWithPairingCode(options: LoginOptions & { phone: string }): Promise<void> {
30
27
  const manager = new WhatsAppCredentialManager()
31
28
  const accountId = createAccountId(options.phone)
@@ -95,7 +92,7 @@ async function loginWithQR(options: LoginOptions): Promise<void> {
95
92
  await rm(existingPaths.auth_dir, { recursive: true, force: true })
96
93
  const paths = await manager.ensureAccountPaths(accountId)
97
94
  const client = await new WhatsAppClient().login({ authDir: paths.auth_dir })
98
- const interactive = isInteractiveSession()
95
+ const interactive = isInteractive()
99
96
 
100
97
  let waitForAuth: () => Promise<void>
101
98
  let browserOpened = false
@@ -75,7 +75,7 @@ export function discoverBrowserProfileDirs(browserBase: string): string[] {
75
75
  dirs.push(join(browserBase, 'Default'))
76
76
  if (!existsSync(browserBase)) return dirs
77
77
  try {
78
- const entries = readdirSync(browserBase, { withFileTypes: true })
78
+ const entries = readdirSync(browserBase, { withFileTypes: true }).sort((a, b) => a.name.localeCompare(b.name))
79
79
  for (const entry of entries) {
80
80
  if (!entry.isDirectory()) continue
81
81
  if (!/^Profile \d+$/i.test(entry.name)) continue
@@ -0,0 +1,55 @@
1
+ import { afterEach, beforeEach, describe, expect, it } from 'bun:test'
2
+
3
+ import { hasTTY, isInteractive } from './interactive'
4
+
5
+ describe('isInteractive', () => {
6
+ let originalStdinTTY: boolean | undefined
7
+ let originalStdoutTTY: boolean | undefined
8
+
9
+ beforeEach(() => {
10
+ originalStdinTTY = process.stdin.isTTY
11
+ originalStdoutTTY = process.stdout.isTTY
12
+ })
13
+
14
+ afterEach(() => {
15
+ Object.defineProperty(process.stdin, 'isTTY', { value: originalStdinTTY, writable: true, configurable: true })
16
+ Object.defineProperty(process.stdout, 'isTTY', { value: originalStdoutTTY, writable: true, configurable: true })
17
+ })
18
+
19
+ function setTTY(stdin: boolean | undefined, stdout: boolean | undefined): void {
20
+ Object.defineProperty(process.stdin, 'isTTY', { value: stdin, writable: true, configurable: true })
21
+ Object.defineProperty(process.stdout, 'isTTY', { value: stdout, writable: true, configurable: true })
22
+ }
23
+
24
+ it('returns true when both stdin and stdout are TTY', () => {
25
+ setTTY(true, true)
26
+ expect(isInteractive()).toBe(true)
27
+ })
28
+
29
+ it('returns false when stdin is not a TTY (piped input)', () => {
30
+ setTTY(undefined, true)
31
+ expect(isInteractive()).toBe(false)
32
+ })
33
+
34
+ it('returns false when stdout is not a TTY (piped output)', () => {
35
+ setTTY(true, undefined)
36
+ expect(isInteractive()).toBe(false)
37
+ })
38
+
39
+ it('returns false when neither is a TTY', () => {
40
+ setTTY(undefined, undefined)
41
+ expect(isInteractive()).toBe(false)
42
+ })
43
+
44
+ it('returns false when stdin/stdout isTTY is explicitly false', () => {
45
+ setTTY(false, false)
46
+ expect(isInteractive()).toBe(false)
47
+ })
48
+ })
49
+
50
+ describe('hasTTY', () => {
51
+ it('returns a boolean reflecting whether a controlling TTY can be opened', () => {
52
+ const result = hasTTY()
53
+ expect(typeof result).toBe('boolean')
54
+ })
55
+ })
@@ -0,0 +1,15 @@
1
+ export function isInteractive(): boolean {
2
+ return Boolean(process.stdin.isTTY && process.stdout.isTTY)
3
+ }
4
+
5
+ export function hasTTY(): boolean {
6
+ try {
7
+ const { openSync, closeSync } = require('node:fs') as typeof import('node:fs')
8
+ const ttyDevice = process.platform === 'win32' ? 'CONIN$' : '/dev/tty'
9
+ const fd = openSync(ttyDevice, 'r')
10
+ closeSync(fd)
11
+ return true
12
+ } catch {
13
+ return false
14
+ }
15
+ }
@@ -0,0 +1,5 @@
1
+ import { afterEach, mock } from 'bun:test'
2
+
3
+ afterEach(() => {
4
+ mock.restore()
5
+ })
package/tsconfig.json CHANGED
@@ -38,5 +38,5 @@
38
38
  "noFallthroughCasesInSwitch": true
39
39
  },
40
40
  "include": ["src/**/*", "tests/**/*"],
41
- "exclude": ["node_modules", "dist", "**/*.test.ts", "**/*-test.ts"]
41
+ "exclude": ["node_modules", "dist", "**/*.test.ts", "**/*-test.ts", "src/test-setup.ts"]
42
42
  }