webagents 0.1.13__py3-none-any.whl → 0.2.2__py3-none-any.whl

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 (77) hide show
  1. webagents/__init__.py +1 -1
  2. webagents/__main__.py +55 -0
  3. webagents/agents/__init__.py +1 -1
  4. webagents/agents/core/__init__.py +1 -1
  5. webagents/agents/core/base_agent.py +15 -15
  6. webagents/agents/core/handoffs.py +1 -1
  7. webagents/agents/skills/__init__.py +11 -11
  8. webagents/agents/skills/base.py +1 -1
  9. webagents/agents/skills/core/llm/litellm/__init__.py +1 -1
  10. webagents/agents/skills/core/llm/litellm/skill.py +1 -1
  11. webagents/agents/skills/core/mcp/README.md +2 -2
  12. webagents/agents/skills/core/mcp/skill.py +2 -2
  13. webagents/agents/skills/core/memory/long_term_memory/memory_skill.py +14 -14
  14. webagents/agents/skills/core/memory/short_term_memory/__init__.py +1 -1
  15. webagents/agents/skills/core/memory/short_term_memory/skill.py +1 -1
  16. webagents/agents/skills/core/memory/vector_memory/skill.py +6 -6
  17. webagents/agents/skills/core/planning/__init__.py +1 -1
  18. webagents/agents/skills/ecosystem/crewai/__init__.py +3 -1
  19. webagents/agents/skills/ecosystem/crewai/skill.py +158 -0
  20. webagents/agents/skills/ecosystem/database/__init__.py +3 -1
  21. webagents/agents/skills/ecosystem/database/skill.py +522 -0
  22. webagents/agents/skills/ecosystem/google/calendar/skill.py +1 -1
  23. webagents/agents/skills/ecosystem/mongodb/__init__.py +3 -0
  24. webagents/agents/skills/ecosystem/mongodb/skill.py +428 -0
  25. webagents/agents/skills/ecosystem/n8n/README.md +287 -0
  26. webagents/agents/skills/ecosystem/n8n/__init__.py +3 -0
  27. webagents/agents/skills/ecosystem/n8n/skill.py +341 -0
  28. webagents/agents/skills/ecosystem/x_com/README.md +401 -0
  29. webagents/agents/skills/ecosystem/x_com/__init__.py +3 -0
  30. webagents/agents/skills/ecosystem/x_com/skill.py +1048 -0
  31. webagents/agents/skills/ecosystem/zapier/README.md +363 -0
  32. webagents/agents/skills/ecosystem/zapier/__init__.py +3 -0
  33. webagents/agents/skills/ecosystem/zapier/skill.py +337 -0
  34. webagents/agents/skills/robutler/__init__.py +2 -2
  35. webagents/agents/skills/robutler/auth/__init__.py +3 -3
  36. webagents/agents/skills/robutler/auth/skill.py +16 -16
  37. webagents/agents/skills/robutler/crm/__init__.py +2 -2
  38. webagents/agents/skills/robutler/crm/skill.py +5 -5
  39. webagents/agents/skills/robutler/discovery/README.md +5 -5
  40. webagents/agents/skills/robutler/discovery/__init__.py +2 -2
  41. webagents/agents/skills/robutler/discovery/skill.py +21 -21
  42. webagents/agents/skills/robutler/message_history/__init__.py +2 -2
  43. webagents/agents/skills/robutler/message_history/skill.py +5 -5
  44. webagents/agents/skills/robutler/nli/__init__.py +1 -1
  45. webagents/agents/skills/robutler/nli/skill.py +9 -9
  46. webagents/agents/skills/robutler/payments/__init__.py +3 -3
  47. webagents/agents/skills/robutler/payments/exceptions.py +1 -1
  48. webagents/agents/skills/robutler/payments/skill.py +23 -23
  49. webagents/agents/skills/robutler/storage/__init__.py +2 -2
  50. webagents/agents/skills/robutler/storage/files/__init__.py +2 -2
  51. webagents/agents/skills/robutler/storage/files/skill.py +4 -4
  52. webagents/agents/skills/robutler/storage/json/__init__.py +1 -1
  53. webagents/agents/skills/robutler/storage/json/skill.py +3 -3
  54. webagents/agents/skills/robutler/storage/kv/skill.py +3 -3
  55. webagents/agents/skills/robutler/storage.py +6 -6
  56. webagents/agents/tools/decorators.py +12 -12
  57. webagents/server/__init__.py +3 -3
  58. webagents/server/context/context_vars.py +2 -2
  59. webagents/server/core/app.py +13 -13
  60. webagents/server/core/middleware.py +3 -3
  61. webagents/server/core/models.py +1 -1
  62. webagents/server/core/monitoring.py +2 -2
  63. webagents/server/middleware.py +1 -1
  64. webagents/server/models.py +2 -2
  65. webagents/server/monitoring.py +15 -15
  66. webagents/utils/logging.py +20 -20
  67. webagents-0.2.2.dist-info/METADATA +266 -0
  68. webagents-0.2.2.dist-info/RECORD +105 -0
  69. webagents-0.2.2.dist-info/licenses/LICENSE +20 -0
  70. webagents/api/__init__.py +0 -17
  71. webagents/api/client.py +0 -1207
  72. webagents/api/types.py +0 -253
  73. webagents-0.1.13.dist-info/METADATA +0 -32
  74. webagents-0.1.13.dist-info/RECORD +0 -96
  75. webagents-0.1.13.dist-info/licenses/LICENSE +0 -1
  76. {webagents-0.1.13.dist-info → webagents-0.2.2.dist-info}/WHEEL +0 -0
  77. {webagents-0.1.13.dist-info → webagents-0.2.2.dist-info}/entry_points.txt +0 -0
@@ -0,0 +1,401 @@
1
+ # X.com (Twitter) OAuth 1.0a Skill
2
+
3
+ A comprehensive X.com integration skill for WebAgents that implements OAuth 1.0a User Context authentication, enabling multitenant applications with per-user rate limits.
4
+
5
+ ## Features
6
+
7
+ - **OAuth 1.0a User Context Authentication**: Full 3-legged OAuth flow
8
+ - **Per-User Rate Limits**: Scale rate limits with your user base instead of app-wide limits
9
+ - **Auth & KV Skill Integration**: Secure credential storage using WebAgents auth and KV skills
10
+ - **Real-time Webhook Monitoring**: Monitor posts, mentions, likes, follows, and DMs
11
+ - **Agent/LLM-Powered Responses**: Automatic agent/LLM responses to webhook events
12
+ - **Smart Notification System**: Configurable notifications with keyword filtering
13
+ - **Comprehensive API Coverage**: Post tweets, search, user info, rate limit tracking
14
+ - **Rate Limit Management**: Automatic rate limit header tracking and error handling
15
+ - **Multitenant Ready**: Designed for applications serving multiple users with isolated data
16
+
17
+ ## Setup
18
+
19
+ ### 1. Environment Variables
20
+
21
+ Set the following environment variables:
22
+
23
+ ```bash
24
+ # Required: X.com API credentials
25
+ X_API_KEY=your_api_key_here
26
+ X_API_SECRET=your_api_secret_here
27
+
28
+ # Optional: Base URL for OAuth callbacks (defaults to http://localhost:2224)
29
+ AGENTS_BASE_URL=https://your-domain.com
30
+ ```
31
+
32
+ ### 2. X.com Developer Setup
33
+
34
+ 1. Create a developer account at [developer.x.com](https://developer.x.com)
35
+ 2. Create a new project and app
36
+ 3. Get your API Key and API Secret
37
+ 4. Configure OAuth 1.0a settings in your app:
38
+ - **App permissions**: Read and Write (or as needed)
39
+ - **Callback URLs**: Add your callback URL pattern:
40
+ - `http://localhost:2224/agents/{agent-name}/oauth/x/callback` (development)
41
+ - `https://your-domain.com/agents/{agent-name}/oauth/x/callback` (production)
42
+
43
+ ### 3. Agent Configuration
44
+
45
+ Add the skill to your agent along with required auth and KV skills:
46
+
47
+ ```python
48
+ from webagents.agents.skills.ecosystem.x_com.skill import XComSkill
49
+ from webagents.agents.skills.robutler.auth.skill import AuthSkill
50
+ from webagents.agents.skills.robutler.kv.skill import KVSkill
51
+
52
+ # In your agent initialization
53
+ agent = BaseAgent(
54
+ name="x-com-agent",
55
+ model="openai/gpt-4o",
56
+ skills={
57
+ "auth": AuthSkill(), # Required for user authentication
58
+ "kv": KVSkill(), # Required for secure credential storage
59
+ "x_com": XComSkill() # X.com integration
60
+ }
61
+ )
62
+ ```
63
+
64
+ ## Usage
65
+
66
+ ### Authentication Flow
67
+
68
+ 1. **Initialize Authentication**:
69
+ ```python
70
+ # User calls this tool to start OAuth flow
71
+ result = await agent.call_tool("init_x_auth")
72
+ # Returns: "🔗 Open this link to authorize X.com access: https://api.x.com/oauth/authorize?..."
73
+ ```
74
+
75
+ 2. **User Authorization**: User opens the provided URL and authorizes your app
76
+
77
+ 3. **Automatic Token Storage**: After authorization, tokens are automatically stored per user
78
+
79
+ ### Available Tools
80
+
81
+ #### Core Authentication & API Tools
82
+
83
+ #### `init_x_auth()`
84
+ Initialize OAuth authentication flow. Returns authorization URL for the user.
85
+
86
+ **Returns**: Authorization URL string
87
+
88
+ #### `post_tweet(text: str)`
89
+ Post a tweet to X.com.
90
+
91
+ **Parameters**:
92
+ - `text`: Tweet content (up to 280 characters)
93
+
94
+ **Returns**: Success message with tweet ID
95
+
96
+ #### `search_tweets(query: str, max_results: int = 10)`
97
+ Search for recent tweets.
98
+
99
+ **Parameters**:
100
+ - `query`: Search query string
101
+ - `max_results`: Maximum number of tweets to return (1-100)
102
+
103
+ **Returns**: Formatted list of tweets with metrics
104
+
105
+ #### `get_user_info()`
106
+ Get information about the authenticated user.
107
+
108
+ **Returns**: User profile information including followers, tweets, etc.
109
+
110
+ #### `get_rate_limits()`
111
+ Check current rate limit status for the authenticated user.
112
+
113
+ **Returns**: Rate limit status information
114
+
115
+ #### Webhook Management Tools (Owner-Only)
116
+
117
+ #### `setup_webhook_monitoring(keywords: List[str] = None, mentions_only: bool = False, send_notifications: bool = True)`
118
+ Set up webhook monitoring for X.com posts and events.
119
+
120
+ **Parameters**:
121
+ - `keywords`: List of keywords to monitor (optional)
122
+ - `mentions_only`: Only trigger on mentions of authenticated user
123
+ - `send_notifications`: Whether to send notifications for events
124
+
125
+ **Returns**: Configuration summary and webhook URL
126
+
127
+ #### `get_webhook_config()`
128
+ Get current webhook monitoring configuration.
129
+
130
+ **Returns**: Current webhook configuration details
131
+
132
+ #### `update_webhook_config(keywords: List[str] = None, mentions_only: bool = None, send_notifications: bool = None)`
133
+ Update webhook monitoring configuration.
134
+
135
+ **Parameters**: Same as setup_webhook_monitoring (all optional)
136
+
137
+ **Returns**: Success confirmation
138
+
139
+ #### `disable_webhook_monitoring()`
140
+ Disable webhook monitoring.
141
+
142
+ **Returns**: Confirmation message
143
+
144
+ #### `get_notifications(limit: int = 10)`
145
+ Get recent notifications from webhook events.
146
+
147
+ **Parameters**:
148
+ - `limit`: Maximum number of notifications to return
149
+
150
+ **Returns**: List of recent notifications with read status
151
+
152
+ #### `mark_notifications_read()`
153
+ Mark all notifications as read.
154
+
155
+ **Returns**: Confirmation message
156
+
157
+ ## Rate Limits
158
+
159
+ ### Per-User vs App-Wide Limits
160
+
161
+ - **OAuth 1.0a User Context** (this skill): ~900 requests per 15-minute window **per user**
162
+ - **OAuth 2.0 Bearer Token**: ~450 requests per 15-minute window for entire app
163
+
164
+ With 100 authenticated users, you get 90,000 requests per 15-minute window instead of 450!
165
+
166
+ ### Rate Limit Headers
167
+
168
+ The skill automatically tracks rate limit headers from X.com API responses:
169
+ - `x-rate-limit-limit`: Total requests allowed
170
+ - `x-rate-limit-remaining`: Requests remaining in current window
171
+ - `x-rate-limit-reset`: Unix timestamp when limits reset
172
+
173
+ ### Shared User Limits
174
+
175
+ ⚠️ **Important**: Per-user rate limits are shared across ALL applications the user has authorized, including X's own apps. If a user is active on multiple X.com applications, their rate limit is consumed across all of them.
176
+
177
+ ## Security
178
+
179
+ ### Token Storage
180
+
181
+ - Tokens are stored using the KV skill with namespace "auth"
182
+ - Fallback to secure in-memory storage if KV skill unavailable
183
+ - All tokens are associated with user IDs from the request context
184
+
185
+ ### OAuth Security
186
+
187
+ - Uses HMAC-SHA1 signatures for all requests
188
+ - Implements proper nonce and timestamp generation
189
+ - Secure state parameter for callback correlation
190
+ - Request token secrets are temporarily stored for callback processing
191
+
192
+ ## Error Handling
193
+
194
+ The skill provides comprehensive error handling:
195
+
196
+ - **Authentication Errors**: Clear messages when tokens are missing or expired
197
+ - **Rate Limit Errors**: Specific handling for 429 responses
198
+ - **API Errors**: Detailed error messages from X.com API
199
+ - **Network Errors**: Timeout and connection error handling
200
+
201
+ ## Testing
202
+
203
+ Run the test suite:
204
+
205
+ ```bash
206
+ cd /home/vs/webagents
207
+ python -m pytest tests/test_x_com_skill.py -v
208
+ ```
209
+
210
+ The tests cover:
211
+ - OAuth 1.0a signature generation
212
+ - Token storage and retrieval
213
+ - All API endpoints
214
+ - Error conditions
215
+ - Rate limit handling
216
+
217
+ ## Architecture
218
+
219
+ ### OAuth 1.0a Flow
220
+
221
+ 1. **Request Token**: Get temporary credentials from X.com
222
+ 2. **User Authorization**: Redirect user to X.com for authorization
223
+ 3. **Access Token**: Exchange authorized request token for access token
224
+ 4. **API Requests**: Use access token for all subsequent API calls
225
+
226
+ ### Multitenant Design
227
+
228
+ - User tokens stored per user ID from request context
229
+ - Each user gets their own rate limit allocation
230
+ - Secure token isolation between users
231
+ - Automatic cleanup of temporary tokens
232
+
233
+ ### Integration with WebAgents
234
+
235
+ - Follows WebAgents skill architecture patterns
236
+ - Uses standard decorators: `@tool`, `@prompt`, `@http`
237
+ - Integrates with context system for user identification
238
+ - Supports KV skill for persistent storage
239
+
240
+ ### Webhook Architecture
241
+
242
+ #### Event Flow
243
+ 1. **X.com sends webhook** → Agent endpoint (`/webhook/x/events`)
244
+ 2. **Signature verification** → HMAC-SHA256 validation
245
+ 3. **Event processing** → Extract and categorize event data
246
+ 4. **Agent/LLM trigger** → Generate contextual response
247
+ 5. **Notification delivery** → Store and optionally notify user
248
+
249
+ #### Supported Event Types
250
+ - **Tweet Events**: New tweets, retweets, quote tweets
251
+ - **Engagement Events**: Likes, replies, mentions
252
+ - **Follow Events**: New followers, unfollows
253
+ - **Direct Messages**: Incoming DMs
254
+ - **User Events**: Profile updates, blocking
255
+
256
+ #### Security Features
257
+ - **Webhook Signature Verification**: HMAC-SHA256 signature validation
258
+ - **Challenge Response Check (CRC)**: Automatic webhook validation
259
+ - **User Isolation**: Per-user webhook configurations and tokens
260
+ - **Scope-Based Access**: Owner-only webhook management tools
261
+ - **Secure Storage**: All configurations stored via KV skill
262
+
263
+ ## Examples
264
+
265
+ ### Basic Tweet Posting
266
+
267
+ ```python
268
+ # User authenticates first
269
+ auth_result = await agent.call_tool("init_x_auth")
270
+ # User opens URL and authorizes
271
+
272
+ # Post a tweet
273
+ result = await agent.call_tool("post_tweet", text="Hello from WebAgents! 🤖")
274
+ # Returns: "✅ Tweet posted successfully! ID: 1234567890"
275
+ ```
276
+
277
+ ### Search and Analyze
278
+
279
+ ```python
280
+ # Search for tweets
281
+ tweets = await agent.call_tool("search_tweets", query="webagents", max_results=5)
282
+ # Returns formatted list of tweets with engagement metrics
283
+
284
+ # Get user info
285
+ user_info = await agent.call_tool("get_user_info")
286
+ # Returns: "👤 **User Name** (@username) - ✅ Verified\n📝 Bio text\n..."
287
+ ```
288
+
289
+ ### Webhook Monitoring Setup
290
+
291
+ ```python
292
+ # Set up webhook monitoring for specific keywords
293
+ result = await agent.call_tool("setup_webhook_monitoring",
294
+ keywords=["webagents", "AI", "automation"],
295
+ mentions_only=False,
296
+ send_notifications=True)
297
+ # Returns: "✅ Webhook monitoring set up successfully! ..."
298
+
299
+ # Monitor only mentions of the authenticated user
300
+ result = await agent.call_tool("setup_webhook_monitoring",
301
+ mentions_only=True)
302
+ ```
303
+
304
+ ### Webhook Configuration Management
305
+
306
+ ```python
307
+ # Check current webhook configuration
308
+ config = await agent.call_tool("get_webhook_config")
309
+ # Returns: "📡 Webhook Monitoring Configuration\nStatus: 🟢 Active..."
310
+
311
+ # Update configuration
312
+ result = await agent.call_tool("update_webhook_config",
313
+ keywords=["new", "keywords"],
314
+ send_notifications=False)
315
+
316
+ # Disable monitoring
317
+ result = await agent.call_tool("disable_webhook_monitoring")
318
+ ```
319
+
320
+ ### Notification Management
321
+
322
+ ```python
323
+ # Get recent notifications
324
+ notifications = await agent.call_tool("get_notifications", limit=5)
325
+ # Returns: "🔔 Recent Notifications:\n1. 🔴 [tweet_created] ..."
326
+
327
+ # Mark all notifications as read
328
+ result = await agent.call_tool("mark_notifications_read")
329
+ # Returns: "✅ All notifications marked as read"
330
+ ```
331
+
332
+ ### Complete Multitenant Workflow
333
+
334
+ ```python
335
+ # 1. User authenticates
336
+ auth_url = await agent.call_tool("init_x_auth")
337
+ # User completes OAuth flow
338
+
339
+ # 2. Set up monitoring
340
+ webhook_result = await agent.call_tool("setup_webhook_monitoring",
341
+ keywords=["support", "help", "issue"],
342
+ send_notifications=True)
343
+
344
+ # 3. Agent automatically responds to relevant tweets
345
+ # (Webhook events trigger agent/LLM responses automatically)
346
+
347
+ # 4. Check notifications periodically
348
+ notifications = await agent.call_tool("get_notifications")
349
+
350
+ # 5. Post responses or take actions
351
+ response = await agent.call_tool("post_tweet",
352
+ text="Thanks for reaching out! We're here to help. 🤝")
353
+ ```
354
+
355
+ ### Rate Limit Monitoring
356
+
357
+ ```python
358
+ # Check current rate limits
359
+ limits = await agent.call_tool("get_rate_limits")
360
+ # Returns rate limit status for monitoring
361
+ ```
362
+
363
+ ## Troubleshooting
364
+
365
+ ### Common Issues
366
+
367
+ 1. **"❌ X.com API credentials not configured"**
368
+ - Ensure `X_API_KEY` and `X_API_SECRET` environment variables are set
369
+
370
+ 2. **"❌ Authentication expired"**
371
+ - User needs to re-run `init_x_auth()` to refresh tokens
372
+
373
+ 3. **"❌ Rate limit exceeded"**
374
+ - User has hit their per-user rate limit, wait for reset
375
+
376
+ 4. **OAuth callback errors**
377
+ - Verify callback URL is correctly configured in X.com app settings
378
+ - Check `AGENTS_BASE_URL` environment variable
379
+
380
+ ### Debugging
381
+
382
+ Enable debug logging:
383
+
384
+ ```python
385
+ import logging
386
+ logging.getLogger('skill.x_com').setLevel(logging.DEBUG)
387
+ ```
388
+
389
+ ## Contributing
390
+
391
+ When contributing to this skill:
392
+
393
+ 1. Follow the existing code patterns
394
+ 2. Add tests for new functionality
395
+ 3. Update this README for new features
396
+ 4. Ensure proper error handling
397
+ 5. Test with real X.com API credentials
398
+
399
+ ## License
400
+
401
+ This skill is part of the WebAgents framework and follows the same license terms.
@@ -0,0 +1,3 @@
1
+ from .skill import XComSkill
2
+
3
+ __all__ = ['XComSkill']