agent-messenger 2.0.0 → 2.1.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 (119) hide show
  1. package/.claude-plugin/marketplace.json +14 -1
  2. package/.claude-plugin/plugin.json +4 -2
  3. package/README.md +33 -29
  4. package/dist/package.json +10 -2
  5. package/dist/src/cli.d.ts.map +1 -1
  6. package/dist/src/cli.js +3 -0
  7. package/dist/src/cli.js.map +1 -1
  8. package/dist/src/platforms/webex/app-config.d.ts +7 -0
  9. package/dist/src/platforms/webex/app-config.d.ts.map +1 -0
  10. package/dist/src/platforms/webex/app-config.js +20 -0
  11. package/dist/src/platforms/webex/app-config.js.map +1 -0
  12. package/dist/src/platforms/webex/cli.d.ts +5 -0
  13. package/dist/src/platforms/webex/cli.d.ts.map +1 -0
  14. package/dist/src/platforms/webex/cli.js +32 -0
  15. package/dist/src/platforms/webex/cli.js.map +1 -0
  16. package/dist/src/platforms/webex/client.d.ts +45 -0
  17. package/dist/src/platforms/webex/client.d.ts.map +1 -0
  18. package/dist/src/platforms/webex/client.js +175 -0
  19. package/dist/src/platforms/webex/client.js.map +1 -0
  20. package/dist/src/platforms/webex/commands/auth.d.ts +15 -0
  21. package/dist/src/platforms/webex/commands/auth.d.ts.map +1 -0
  22. package/dist/src/platforms/webex/commands/auth.js +124 -0
  23. package/dist/src/platforms/webex/commands/auth.js.map +1 -0
  24. package/dist/src/platforms/webex/commands/index.d.ts +6 -0
  25. package/dist/src/platforms/webex/commands/index.d.ts.map +1 -0
  26. package/dist/src/platforms/webex/commands/index.js +6 -0
  27. package/dist/src/platforms/webex/commands/index.js.map +1 -0
  28. package/dist/src/platforms/webex/commands/member.d.ts +7 -0
  29. package/dist/src/platforms/webex/commands/member.d.ts.map +1 -0
  30. package/dist/src/platforms/webex/commands/member.js +34 -0
  31. package/dist/src/platforms/webex/commands/member.js.map +1 -0
  32. package/dist/src/platforms/webex/commands/message.d.ts +26 -0
  33. package/dist/src/platforms/webex/commands/message.d.ts.map +1 -0
  34. package/dist/src/platforms/webex/commands/message.js +153 -0
  35. package/dist/src/platforms/webex/commands/message.js.map +1 -0
  36. package/dist/src/platforms/webex/commands/snapshot.d.ts +9 -0
  37. package/dist/src/platforms/webex/commands/snapshot.d.ts.map +1 -0
  38. package/dist/src/platforms/webex/commands/snapshot.js +72 -0
  39. package/dist/src/platforms/webex/commands/snapshot.js.map +1 -0
  40. package/dist/src/platforms/webex/commands/space.d.ts +11 -0
  41. package/dist/src/platforms/webex/commands/space.d.ts.map +1 -0
  42. package/dist/src/platforms/webex/commands/space.js +59 -0
  43. package/dist/src/platforms/webex/commands/space.js.map +1 -0
  44. package/dist/src/platforms/webex/credential-manager.d.ts +23 -0
  45. package/dist/src/platforms/webex/credential-manager.d.ts.map +1 -0
  46. package/dist/src/platforms/webex/credential-manager.js +148 -0
  47. package/dist/src/platforms/webex/credential-manager.js.map +1 -0
  48. package/dist/src/platforms/webex/ensure-auth.d.ts +2 -0
  49. package/dist/src/platforms/webex/ensure-auth.d.ts.map +1 -0
  50. package/dist/src/platforms/webex/ensure-auth.js +20 -0
  51. package/dist/src/platforms/webex/ensure-auth.js.map +1 -0
  52. package/dist/src/platforms/webex/index.d.ts +6 -0
  53. package/dist/src/platforms/webex/index.d.ts.map +1 -0
  54. package/dist/src/platforms/webex/index.js +5 -0
  55. package/dist/src/platforms/webex/index.js.map +1 -0
  56. package/dist/src/platforms/webex/types.d.ts +124 -0
  57. package/dist/src/platforms/webex/types.d.ts.map +1 -0
  58. package/dist/src/platforms/webex/types.js +63 -0
  59. package/dist/src/platforms/webex/types.js.map +1 -0
  60. package/dist/src/tui/adapters/webex-adapter.d.ts +14 -0
  61. package/dist/src/tui/adapters/webex-adapter.d.ts.map +1 -0
  62. package/dist/src/tui/adapters/webex-adapter.js +79 -0
  63. package/dist/src/tui/adapters/webex-adapter.js.map +1 -0
  64. package/dist/src/tui/app.d.ts.map +1 -1
  65. package/dist/src/tui/app.js +2 -0
  66. package/dist/src/tui/app.js.map +1 -1
  67. package/docs/content/docs/cli/meta.json +1 -0
  68. package/docs/content/docs/cli/webex.mdx +291 -0
  69. package/docs/content/docs/sdk/meta.json +1 -1
  70. package/docs/content/docs/sdk/webex.mdx +260 -0
  71. package/docs/content/docs/tui.mdx +4 -3
  72. package/docs/src/app/page.tsx +2 -2
  73. package/package.json +10 -2
  74. package/skills/agent-channeltalk/SKILL.md +1 -1
  75. package/skills/agent-channeltalkbot/SKILL.md +1 -1
  76. package/skills/agent-discord/SKILL.md +1 -1
  77. package/skills/agent-discordbot/SKILL.md +1 -1
  78. package/skills/agent-instagram/SKILL.md +1 -1
  79. package/skills/agent-kakaotalk/SKILL.md +1 -1
  80. package/skills/agent-line/SKILL.md +1 -1
  81. package/skills/agent-slack/SKILL.md +1 -1
  82. package/skills/agent-slackbot/SKILL.md +1 -1
  83. package/skills/agent-teams/SKILL.md +1 -1
  84. package/skills/agent-telegram/SKILL.md +1 -1
  85. package/skills/agent-webex/SKILL.md +386 -0
  86. package/skills/agent-webex/references/authentication.md +318 -0
  87. package/skills/agent-webex/references/common-patterns.md +723 -0
  88. package/skills/agent-webex/templates/monitor-space.sh +165 -0
  89. package/skills/agent-webex/templates/post-message.sh +170 -0
  90. package/skills/agent-whatsapp/SKILL.md +1 -1
  91. package/skills/agent-whatsappbot/SKILL.md +1 -1
  92. package/src/cli.ts +4 -0
  93. package/src/platforms/webex/app-config.test.ts +98 -0
  94. package/src/platforms/webex/app-config.ts +31 -0
  95. package/src/platforms/webex/cli.test.ts +58 -0
  96. package/src/platforms/webex/cli.ts +39 -0
  97. package/src/platforms/webex/client.test.ts +429 -0
  98. package/src/platforms/webex/client.ts +247 -0
  99. package/src/platforms/webex/commands/auth.test.ts +222 -0
  100. package/src/platforms/webex/commands/auth.ts +180 -0
  101. package/src/platforms/webex/commands/index.ts +5 -0
  102. package/src/platforms/webex/commands/member.test.ts +103 -0
  103. package/src/platforms/webex/commands/member.ts +45 -0
  104. package/src/platforms/webex/commands/message.test.ts +231 -0
  105. package/src/platforms/webex/commands/message.ts +204 -0
  106. package/src/platforms/webex/commands/snapshot.test.ts +96 -0
  107. package/src/platforms/webex/commands/snapshot.ts +91 -0
  108. package/src/platforms/webex/commands/space.test.ts +206 -0
  109. package/src/platforms/webex/commands/space.ts +74 -0
  110. package/src/platforms/webex/credential-manager.test.ts +314 -0
  111. package/src/platforms/webex/credential-manager.ts +197 -0
  112. package/src/platforms/webex/ensure-auth.test.ts +85 -0
  113. package/src/platforms/webex/ensure-auth.ts +19 -0
  114. package/src/platforms/webex/index.test.ts +25 -0
  115. package/src/platforms/webex/index.ts +17 -0
  116. package/src/platforms/webex/types.test.ts +307 -0
  117. package/src/platforms/webex/types.ts +127 -0
  118. package/src/tui/adapters/webex-adapter.ts +103 -0
  119. package/src/tui/app.ts +2 -0
@@ -0,0 +1,318 @@
1
+ # Authentication Guide
2
+
3
+ ## Overview
4
+
5
+ agent-webex supports three authentication methods against the Webex REST API (`https://webexapis.com/v1`):
6
+
7
+ 1. **OAuth Device Grant** (default): Zero-config. Run `auth login`, approve in browser, done. Tokens refresh automatically.
8
+ 2. **Bot Token**: Pass via `auth login --token`. Never expires. Best for CI/CD.
9
+ 3. **Personal Access Token (PAT)**: Pass via `auth login --token`. Expires in 12 hours. For quick testing.
10
+
11
+ ## Token Types
12
+
13
+ ### OAuth Device Grant (default)
14
+
15
+ The primary authentication method. No credentials to copy, no developer portal setup required.
16
+
17
+ - **How it works**: Run `agent-webex auth login`. The CLI requests a device code from Webex, opens your browser, and waits for you to approve. Once approved, access and refresh tokens are stored automatically.
18
+ - **Access token lifetime**: 14 days
19
+ - **Refresh token lifetime**: 90 days
20
+ - **Auto-refresh**: The CLI refreshes expired access tokens automatically using the stored refresh token. No manual intervention needed until the refresh token itself expires (90 days).
21
+ - **Permissions**: `spark:all` scope (full access to your Webex account)
22
+ - **Best for**: Interactive use, development, any scenario where a human can approve via browser
23
+
24
+ ```bash
25
+ agent-webex auth login
26
+ ```
27
+
28
+ The CLI ships with built-in Integration credentials so this works out of the box. You can override them with your own (see [Environment Variables](#environment-variables)).
29
+
30
+ ### Bot Token
31
+
32
+ A permanent token tied to a Webex bot identity.
33
+
34
+ - **Lifetime**: Never expires (unless you regenerate it)
35
+ - **How to get one**: Create a bot at https://developer.webex.com/my-apps/new/bot. The token is shown once at creation time. Save it immediately.
36
+ - **Permissions**: The bot can only interact with spaces it has been added to
37
+ - **Best for**: Long-running automations, CI/CD pipelines, production scripts
38
+
39
+ ```bash
40
+ agent-webex auth login --token "YOUR_BOT_TOKEN_HERE"
41
+ ```
42
+
43
+ ### Personal Access Token (PAT)
44
+
45
+ A short-lived token for development and testing.
46
+
47
+ - **Lifetime**: 12 hours from generation
48
+ - **How to get one**: Visit https://developer.webex.com/docs/getting-started and copy the token shown on the page
49
+ - **Permissions**: Full access to everything your Webex account can do
50
+ - **Best for**: Quick testing, one-off scripts
51
+
52
+ ```bash
53
+ agent-webex auth login --token "YOUR_PAT_HERE"
54
+ ```
55
+
56
+ ## Logging In
57
+
58
+ ```bash
59
+ # Device Grant (default, zero-config)
60
+ agent-webex auth login
61
+
62
+ # With custom Integration credentials
63
+ agent-webex auth login --client-id <id> --client-secret <secret>
64
+
65
+ # Bot token
66
+ agent-webex auth login --token <bot-token>
67
+
68
+ # PAT
69
+ agent-webex auth login --token <pat>
70
+ ```
71
+
72
+ When using `--token`, the CLI validates the token against the Webex API before saving. If validation fails, you'll see an error and the token won't be stored.
73
+
74
+ When using Device Grant, the CLI prints a URL and code, opens your browser, then polls until you approve (or the code expires).
75
+
76
+ ## Checking Status
77
+
78
+ ```bash
79
+ agent-webex auth status
80
+ ```
81
+
82
+ Output when authenticated:
83
+
84
+ ```json
85
+ {
86
+ "authenticated": true,
87
+ "user": {
88
+ "id": "Y2lz...",
89
+ "displayName": "Alice Chen",
90
+ "emails": ["alice@example.com"]
91
+ }
92
+ }
93
+ ```
94
+
95
+ Output when not authenticated:
96
+
97
+ ```json
98
+ {
99
+ "error": "Not authenticated. Run \"auth login\" first."
100
+ }
101
+ ```
102
+
103
+ ## Logging Out
104
+
105
+ ```bash
106
+ agent-webex auth logout
107
+ ```
108
+
109
+ This removes the stored credentials from disk.
110
+
111
+ ## Credential Storage
112
+
113
+ ### Location
114
+
115
+ ```
116
+ ~/.config/agent-messenger/webex-credentials.json
117
+ ```
118
+
119
+ ### Format
120
+
121
+ OAuth credentials (from Device Grant):
122
+
123
+ ```json
124
+ {
125
+ "accessToken": "...",
126
+ "refreshToken": "...",
127
+ "expiresAt": 1234567890,
128
+ "clientId": "...",
129
+ "clientSecret": "...",
130
+ "tokenType": "oauth"
131
+ }
132
+ ```
133
+
134
+ Manual credentials (from `--token`):
135
+
136
+ ```json
137
+ {
138
+ "accessToken": "...",
139
+ "refreshToken": "",
140
+ "expiresAt": 0,
141
+ "tokenType": "manual"
142
+ }
143
+ ```
144
+
145
+ ### Security
146
+
147
+ - File permissions: `0600` (owner read/write only)
148
+ - Credentials are stored in plaintext (same approach as other agent-messenger platforms)
149
+ - Writes are atomic (tmp file + rename) to prevent corruption
150
+ - Keep this file secure. It grants access to your Webex account
151
+ - Built-in OAuth credentials are public bootstrap credentials, not secrets
152
+ - Custom client secrets (from `--client-id`/`--client-secret` or env vars) are stored in plaintext alongside tokens
153
+ - Bot tokens never expire. Treat them like passwords
154
+ - PATs auto-expire in 12 hours, which limits exposure
155
+
156
+ ## Token Lifecycle
157
+
158
+ ### OAuth Device Grant
159
+
160
+ ```
161
+ auth login -> Device code -> Browser approval -> Access token (14 days) + Refresh token (90 days)
162
+ |
163
+ Token expires
164
+ |
165
+ Auto-refresh via refresh token
166
+ |
167
+ Refresh token expires (90 days)
168
+ |
169
+ Re-run "auth login"
170
+ ```
171
+
172
+ The CLI checks token expiry before each API call and refreshes automatically when needed. You won't notice this happening.
173
+
174
+ ### Bot Tokens
175
+
176
+ ```
177
+ Created with bot registration -> Valid forever -> Only invalidated if you regenerate
178
+ ```
179
+
180
+ Bot tokens are ideal for automation. The bot must be added to each space it needs to interact with.
181
+
182
+ ### Personal Access Tokens
183
+
184
+ ```
185
+ Generated at developer.webex.com -> Valid for 12 hours -> Expires -> Generate a new one
186
+ ```
187
+
188
+ PATs are the quickest way to get started but require manual renewal. For scripts that run longer than 12 hours, use a bot token or Device Grant.
189
+
190
+ ## Environment Variables
191
+
192
+ Override the built-in Integration credentials with your own:
193
+
194
+ | Variable | Description |
195
+ |---|---|
196
+ | `AGENT_WEBEX_CLIENT_ID` | Webex Integration client ID |
197
+ | `AGENT_WEBEX_CLIENT_SECRET` | Webex Integration client secret |
198
+
199
+ Both must be set together. When set, `auth login` (without `--token`) uses these instead of the built-in credentials.
200
+
201
+ Legacy aliases `AGENT_MESSENGER_WEBEX_CLIENT_ID` and `AGENT_MESSENGER_WEBEX_CLIENT_SECRET` are also supported.
202
+
203
+ ## Troubleshooting
204
+
205
+ ### "Not authenticated"
206
+
207
+ No credentials stored. Log in first:
208
+
209
+ ```bash
210
+ agent-webex auth login
211
+ ```
212
+
213
+ ### "401 Unauthorized"
214
+
215
+ Token is expired or invalid.
216
+
217
+ **If using Device Grant**: The CLI auto-refreshes tokens, so this usually means the refresh token has expired (after 90 days). Run `agent-webex auth login` again.
218
+
219
+ **If using a PAT**: Generate a new one at https://developer.webex.com/docs/getting-started
220
+
221
+ ```bash
222
+ agent-webex auth login --token <new-pat>
223
+ ```
224
+
225
+ **If using a bot token**: Bot tokens don't expire. Double-check you copied the full token. If you lost it, regenerate at https://developer.webex.com/my-apps.
226
+
227
+ ### "Device authorization failed"
228
+
229
+ The device code request was rejected. Possible causes:
230
+
231
+ - Network connectivity issues
232
+ - Custom client ID is invalid or revoked
233
+ - Webex API is temporarily unavailable
234
+
235
+ ### "Device authorization timed out"
236
+
237
+ You didn't approve the request in the browser before the code expired. Run `auth login` again.
238
+
239
+ ### "Token validation failed"
240
+
241
+ The token was rejected by the Webex API during login. Common causes:
242
+
243
+ - Token was copied incorrectly (missing characters, extra whitespace)
244
+ - Token has already expired (PATs last 12 hours)
245
+ - Token was revoked or regenerated
246
+
247
+ ### Permission errors on credentials file
248
+
249
+ ```bash
250
+ # Fix permissions
251
+ chmod 600 ~/.config/agent-messenger/webex-credentials.json
252
+ ```
253
+
254
+ ### Token works in browser but not in CLI
255
+
256
+ Make sure you're using the actual API token, not a session cookie or CSRF token from the browser. The correct token comes from the Developer Portal's "Getting Started" page or from bot/integration creation.
257
+
258
+ ## Security Considerations
259
+
260
+ ### What agent-webex Can Access
261
+
262
+ With a valid token, agent-webex has the same permissions as the token owner:
263
+
264
+ - **OAuth Device Grant**: `spark:all` scope, full access to your Webex account
265
+ - **PAT**: Read and write to all spaces you belong to, list members, send messages
266
+ - **Bot**: Read and write only in spaces the bot has been added to
267
+
268
+ ### What agent-webex Cannot Do
269
+
270
+ - Access spaces you (or the bot) haven't been added to
271
+ - Perform admin operations (unless the token owner is an admin)
272
+ - Create or delete spaces (not implemented in the CLI)
273
+ - Upload or download files (not implemented in the CLI)
274
+
275
+ ### Best Practices
276
+
277
+ 1. **Use Device Grant for interactive work**: Zero-config, auto-refreshing, scoped access
278
+ 2. **Use bot tokens for automation**: They don't expire and have scoped access
279
+ 3. **Protect credentials.json**: Never commit to version control
280
+ 4. **Rotate PATs regularly**: Don't reuse expired tokens. Generate fresh ones
281
+ 5. **Revoke compromised tokens**: Regenerate bot tokens at https://developer.webex.com/my-apps if compromised
282
+ 6. **Use custom Integration credentials for production**: Set `AGENT_WEBEX_CLIENT_ID` and `AGENT_WEBEX_CLIENT_SECRET` instead of relying on built-in bootstrap credentials
283
+
284
+ ## Manual Credential Setup (Advanced)
285
+
286
+ If you need to create the credentials file manually:
287
+
288
+ ```bash
289
+ # Create config directory
290
+ mkdir -p ~/.config/agent-messenger
291
+
292
+ # OAuth credentials
293
+ cat > ~/.config/agent-messenger/webex-credentials.json << 'EOF'
294
+ {
295
+ "accessToken": "YOUR_ACCESS_TOKEN",
296
+ "refreshToken": "YOUR_REFRESH_TOKEN",
297
+ "expiresAt": 1234567890000,
298
+ "clientId": "YOUR_CLIENT_ID",
299
+ "clientSecret": "YOUR_CLIENT_SECRET",
300
+ "tokenType": "oauth"
301
+ }
302
+ EOF
303
+
304
+ # Or manual token
305
+ cat > ~/.config/agent-messenger/webex-credentials.json << 'EOF'
306
+ {
307
+ "accessToken": "YOUR_TOKEN_HERE",
308
+ "refreshToken": "",
309
+ "expiresAt": 0,
310
+ "tokenType": "manual"
311
+ }
312
+ EOF
313
+
314
+ # Set secure permissions
315
+ chmod 600 ~/.config/agent-messenger/webex-credentials.json
316
+ ```
317
+
318
+ Always prefer `agent-webex auth login` over manual file creation. The login command validates tokens and handles the OAuth flow correctly.