webagents 0.1.0__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 (94) hide show
  1. webagents/__init__.py +18 -0
  2. webagents/__main__.py +55 -0
  3. webagents/agents/__init__.py +13 -0
  4. webagents/agents/core/__init__.py +19 -0
  5. webagents/agents/core/base_agent.py +1834 -0
  6. webagents/agents/core/handoffs.py +293 -0
  7. webagents/agents/handoffs/__init__.py +0 -0
  8. webagents/agents/interfaces/__init__.py +0 -0
  9. webagents/agents/lifecycle/__init__.py +0 -0
  10. webagents/agents/skills/__init__.py +109 -0
  11. webagents/agents/skills/base.py +136 -0
  12. webagents/agents/skills/core/__init__.py +8 -0
  13. webagents/agents/skills/core/guardrails/__init__.py +0 -0
  14. webagents/agents/skills/core/llm/__init__.py +0 -0
  15. webagents/agents/skills/core/llm/anthropic/__init__.py +1 -0
  16. webagents/agents/skills/core/llm/litellm/__init__.py +10 -0
  17. webagents/agents/skills/core/llm/litellm/skill.py +538 -0
  18. webagents/agents/skills/core/llm/openai/__init__.py +1 -0
  19. webagents/agents/skills/core/llm/xai/__init__.py +1 -0
  20. webagents/agents/skills/core/mcp/README.md +375 -0
  21. webagents/agents/skills/core/mcp/__init__.py +15 -0
  22. webagents/agents/skills/core/mcp/skill.py +731 -0
  23. webagents/agents/skills/core/memory/__init__.py +11 -0
  24. webagents/agents/skills/core/memory/long_term_memory/__init__.py +10 -0
  25. webagents/agents/skills/core/memory/long_term_memory/memory_skill.py +639 -0
  26. webagents/agents/skills/core/memory/short_term_memory/__init__.py +9 -0
  27. webagents/agents/skills/core/memory/short_term_memory/skill.py +341 -0
  28. webagents/agents/skills/core/memory/vector_memory/skill.py +447 -0
  29. webagents/agents/skills/core/planning/__init__.py +9 -0
  30. webagents/agents/skills/core/planning/planner.py +343 -0
  31. webagents/agents/skills/ecosystem/__init__.py +0 -0
  32. webagents/agents/skills/ecosystem/crewai/__init__.py +1 -0
  33. webagents/agents/skills/ecosystem/database/__init__.py +1 -0
  34. webagents/agents/skills/ecosystem/filesystem/__init__.py +0 -0
  35. webagents/agents/skills/ecosystem/google/__init__.py +0 -0
  36. webagents/agents/skills/ecosystem/google/calendar/__init__.py +6 -0
  37. webagents/agents/skills/ecosystem/google/calendar/skill.py +306 -0
  38. webagents/agents/skills/ecosystem/n8n/__init__.py +0 -0
  39. webagents/agents/skills/ecosystem/openai_agents/__init__.py +0 -0
  40. webagents/agents/skills/ecosystem/web/__init__.py +0 -0
  41. webagents/agents/skills/ecosystem/zapier/__init__.py +0 -0
  42. webagents/agents/skills/robutler/__init__.py +11 -0
  43. webagents/agents/skills/robutler/auth/README.md +63 -0
  44. webagents/agents/skills/robutler/auth/__init__.py +17 -0
  45. webagents/agents/skills/robutler/auth/skill.py +354 -0
  46. webagents/agents/skills/robutler/crm/__init__.py +18 -0
  47. webagents/agents/skills/robutler/crm/skill.py +368 -0
  48. webagents/agents/skills/robutler/discovery/README.md +281 -0
  49. webagents/agents/skills/robutler/discovery/__init__.py +16 -0
  50. webagents/agents/skills/robutler/discovery/skill.py +230 -0
  51. webagents/agents/skills/robutler/kv/__init__.py +6 -0
  52. webagents/agents/skills/robutler/kv/skill.py +80 -0
  53. webagents/agents/skills/robutler/message_history/__init__.py +9 -0
  54. webagents/agents/skills/robutler/message_history/skill.py +270 -0
  55. webagents/agents/skills/robutler/messages/__init__.py +0 -0
  56. webagents/agents/skills/robutler/nli/__init__.py +13 -0
  57. webagents/agents/skills/robutler/nli/skill.py +687 -0
  58. webagents/agents/skills/robutler/notifications/__init__.py +5 -0
  59. webagents/agents/skills/robutler/notifications/skill.py +141 -0
  60. webagents/agents/skills/robutler/payments/__init__.py +41 -0
  61. webagents/agents/skills/robutler/payments/exceptions.py +255 -0
  62. webagents/agents/skills/robutler/payments/skill.py +610 -0
  63. webagents/agents/skills/robutler/storage/__init__.py +10 -0
  64. webagents/agents/skills/robutler/storage/files/__init__.py +9 -0
  65. webagents/agents/skills/robutler/storage/files/skill.py +445 -0
  66. webagents/agents/skills/robutler/storage/json/__init__.py +9 -0
  67. webagents/agents/skills/robutler/storage/json/skill.py +336 -0
  68. webagents/agents/skills/robutler/storage/kv/skill.py +88 -0
  69. webagents/agents/skills/robutler/storage.py +389 -0
  70. webagents/agents/tools/__init__.py +0 -0
  71. webagents/agents/tools/decorators.py +426 -0
  72. webagents/agents/tracing/__init__.py +0 -0
  73. webagents/agents/workflows/__init__.py +0 -0
  74. webagents/scripts/__init__.py +0 -0
  75. webagents/server/__init__.py +28 -0
  76. webagents/server/context/__init__.py +0 -0
  77. webagents/server/context/context_vars.py +121 -0
  78. webagents/server/core/__init__.py +0 -0
  79. webagents/server/core/app.py +843 -0
  80. webagents/server/core/middleware.py +69 -0
  81. webagents/server/core/models.py +98 -0
  82. webagents/server/core/monitoring.py +59 -0
  83. webagents/server/endpoints/__init__.py +0 -0
  84. webagents/server/interfaces/__init__.py +0 -0
  85. webagents/server/middleware.py +330 -0
  86. webagents/server/models.py +92 -0
  87. webagents/server/monitoring.py +659 -0
  88. webagents/utils/__init__.py +0 -0
  89. webagents/utils/logging.py +359 -0
  90. webagents-0.1.0.dist-info/METADATA +230 -0
  91. webagents-0.1.0.dist-info/RECORD +94 -0
  92. webagents-0.1.0.dist-info/WHEEL +4 -0
  93. webagents-0.1.0.dist-info/entry_points.txt +2 -0
  94. webagents-0.1.0.dist-info/licenses/LICENSE +20 -0
@@ -0,0 +1,359 @@
1
+ """
2
+ WebAgents V2.0 Logging System
3
+
4
+ Comprehensive logging with color-coded agent names, structured output,
5
+ and context-aware logging for agents, skills, and server components.
6
+ """
7
+
8
+ import logging
9
+ import sys
10
+ import time
11
+ from typing import Optional, Dict, Any
12
+ from colorama import Fore, Back, Style, init
13
+ from datetime import datetime
14
+ from contextvars import ContextVar
15
+
16
+ # Initialize colorama for cross-platform color support
17
+ init(autoreset=True)
18
+
19
+ # Context variables for logging
20
+ CURRENT_AGENT: ContextVar[Optional[str]] = ContextVar('current_agent', default=None)
21
+ CURRENT_REQUEST_ID: ContextVar[Optional[str]] = ContextVar('current_request_id', default=None)
22
+ CURRENT_USER_ID: ContextVar[Optional[str]] = ContextVar('current_user_id', default=None)
23
+
24
+ # Color mapping for different agent types/names
25
+ AGENT_COLORS = {
26
+ # Core system colors
27
+ 'system': Fore.CYAN,
28
+ 'server': Fore.BLUE,
29
+ 'router': Fore.MAGENTA,
30
+
31
+ # Agent name-based colors (hash-based for consistency)
32
+ 'default': Fore.GREEN,
33
+ }
34
+
35
+ def get_agent_color(agent_name: str) -> str:
36
+ """Get consistent color for agent name based on hash"""
37
+ if agent_name in AGENT_COLORS:
38
+ return AGENT_COLORS[agent_name]
39
+
40
+ # Generate consistent color based on agent name hash
41
+ colors = [Fore.GREEN, Fore.YELLOW, Fore.BLUE, Fore.MAGENTA, Fore.CYAN, Fore.RED]
42
+ color_index = hash(agent_name) % len(colors)
43
+ return colors[color_index]
44
+
45
+ class WebAgentsFormatter(logging.Formatter):
46
+ """Custom formatter with color-coded agent names and structured output"""
47
+
48
+ def format(self, record):
49
+ # Get context information
50
+ agent_name = CURRENT_AGENT.get() or getattr(record, 'agent_name', None)
51
+ request_id = CURRENT_REQUEST_ID.get() or getattr(record, 'request_id', None)
52
+ user_id = CURRENT_USER_ID.get() or getattr(record, 'user_id', None)
53
+
54
+ # Format timestamp
55
+ timestamp = datetime.fromtimestamp(record.created).strftime('%H:%M:%S.%f')[:-3]
56
+
57
+ # Format level with color
58
+ level_colors = {
59
+ 'DEBUG': Fore.WHITE,
60
+ 'INFO': Fore.GREEN,
61
+ 'WARNING': Fore.YELLOW,
62
+ 'ERROR': Fore.RED,
63
+ 'CRITICAL': Fore.RED + Back.WHITE
64
+ }
65
+ level_color = level_colors.get(record.levelname, Fore.WHITE)
66
+ colored_level = f"{level_color}{record.levelname:8s}{Style.RESET_ALL}"
67
+
68
+ # Format agent name with color
69
+ if agent_name:
70
+ agent_color = get_agent_color(agent_name)
71
+ colored_agent = f"{agent_color}{agent_name:15s}{Style.RESET_ALL}"
72
+ else:
73
+ # Try to extract agent name from logger name (e.g., openlicense-image.tool)
74
+ logger_parts = record.name.split('.')
75
+ if len(logger_parts) > 0 and '-' in logger_parts[0]:
76
+ potential_agent = logger_parts[0]
77
+ agent_color = get_agent_color(potential_agent)
78
+ colored_agent = f"{agent_color}{potential_agent[:15]:15s}{Style.RESET_ALL}"
79
+ else:
80
+ colored_agent = f"{'system':15s}"
81
+
82
+ # Format component (logger name)
83
+ component = record.name.split('.')[-1] if '.' in record.name else record.name
84
+ # Truncate very long component names
85
+ if len(component) > 12:
86
+ component = component[:12]
87
+
88
+ # Build context string
89
+ context_parts = []
90
+ if request_id:
91
+ context_parts.append(f"req={request_id[:8]}")
92
+ if user_id:
93
+ context_parts.append(f"user={user_id[:8]}")
94
+
95
+ context_str = f" [{':'.join(context_parts)}]" if context_parts else ""
96
+
97
+ # Format the log message
98
+ message = record.getMessage()
99
+
100
+ # Build final log line
101
+ log_line = f"{Fore.WHITE}{timestamp}{Style.RESET_ALL} {colored_level} {colored_agent} {Fore.BLUE}{component:12s}{Style.RESET_ALL}{context_str} {message}"
102
+
103
+ # Add exception info if present
104
+ if record.exc_info:
105
+ log_line += '\n' + self.formatException(record.exc_info)
106
+
107
+ return log_line
108
+
109
+ class AgentContextAdapter(logging.LoggerAdapter):
110
+ """Logger adapter that automatically includes agent context"""
111
+
112
+ def __init__(self, logger, agent_name: str):
113
+ super().__init__(logger, {})
114
+ self.agent_name = agent_name
115
+
116
+ def process(self, msg, kwargs):
117
+ # Add agent context to log record
118
+ extra = kwargs.get('extra', {})
119
+ extra['agent_name'] = self.agent_name
120
+
121
+ # Add current context if available
122
+ request_id = CURRENT_REQUEST_ID.get()
123
+ user_id = CURRENT_USER_ID.get()
124
+
125
+ if request_id:
126
+ extra['request_id'] = request_id
127
+ if user_id:
128
+ extra['user_id'] = user_id
129
+
130
+ kwargs['extra'] = extra
131
+ return msg, kwargs
132
+
133
+ def setup_logging(level: str = "INFO", log_file: Optional[str] = None) -> None:
134
+ """Setup the WebAgents logging system"""
135
+
136
+ # Convert string level to logging constant
137
+ numeric_level = getattr(logging, level.upper(), logging.INFO)
138
+
139
+ # Create root logger
140
+ root_logger = logging.getLogger('webagents')
141
+ root_logger.setLevel(numeric_level)
142
+
143
+ # Clear any existing handlers
144
+ root_logger.handlers.clear()
145
+
146
+ # Console handler with color formatter
147
+ console_handler = logging.StreamHandler(sys.stdout)
148
+ console_handler.setLevel(numeric_level)
149
+ console_handler.setFormatter(WebAgentsFormatter())
150
+ root_logger.addHandler(console_handler)
151
+
152
+ # File handler if specified (without colors)
153
+ if log_file:
154
+ file_handler = logging.FileHandler(log_file)
155
+ file_handler.setLevel(numeric_level)
156
+ file_formatter = logging.Formatter(
157
+ '%(asctime)s %(levelname)-8s %(name)-20s [%(agent_name)s] %(message)s',
158
+ datefmt='%Y-%m-%d %H:%M:%S'
159
+ )
160
+ file_handler.setFormatter(file_formatter)
161
+ root_logger.addHandler(file_handler)
162
+
163
+ # Disable propagation to avoid duplicate logs
164
+ root_logger.propagate = False
165
+
166
+ # Set levels for noisy libraries
167
+ logging.getLogger('urllib3').setLevel(logging.WARNING)
168
+ logging.getLogger('httpx').setLevel(logging.WARNING)
169
+ logging.getLogger('openai').setLevel(logging.WARNING)
170
+
171
+ # Configure LiteLLM logging to use our formatter
172
+ litellm_logger = logging.getLogger('LiteLLM')
173
+ litellm_logger.setLevel(logging.WARNING) # Only show warnings and errors
174
+ # Clear any existing handlers from LiteLLM
175
+ litellm_logger.handlers.clear()
176
+ # Add our console handler with formatter
177
+ litellm_handler = logging.StreamHandler(sys.stdout)
178
+ litellm_handler.setFormatter(WebAgentsFormatter())
179
+ litellm_logger.addHandler(litellm_handler)
180
+ litellm_logger.propagate = False
181
+
182
+ # Also configure the root logger to catch any unconfigured loggers
183
+ # This will catch any dynamically created loggers that don't have handlers
184
+ root = logging.getLogger()
185
+ if not root.handlers:
186
+ # Only add handler if root doesn't have one already
187
+ root_handler = logging.StreamHandler(sys.stdout)
188
+ root_handler.setFormatter(WebAgentsFormatter())
189
+ root_handler.setLevel(numeric_level)
190
+ root.addHandler(root_handler)
191
+ else:
192
+ # Update existing root handlers to use our formatter
193
+ for handler in root.handlers:
194
+ if isinstance(handler, logging.StreamHandler):
195
+ handler.setFormatter(WebAgentsFormatter())
196
+ handler.setLevel(numeric_level)
197
+
198
+ def get_logger(name: str, agent_name: Optional[str] = None) -> logging.Logger:
199
+ """Get a logger for a specific component, optionally with agent context"""
200
+
201
+ logger_name = f"webagents.{name}" if not name.startswith('webagents') else name
202
+ logger = logging.getLogger(logger_name)
203
+
204
+ if agent_name:
205
+ return AgentContextAdapter(logger, agent_name)
206
+
207
+ return logger
208
+
209
+ def set_agent_context(agent_name: str, request_id: Optional[str] = None, user_id: Optional[str] = None):
210
+ """Set the current agent context for logging"""
211
+ CURRENT_AGENT.set(agent_name)
212
+ if request_id:
213
+ CURRENT_REQUEST_ID.set(request_id)
214
+ if user_id:
215
+ CURRENT_USER_ID.set(user_id)
216
+
217
+ def clear_agent_context():
218
+ """Clear the current agent context"""
219
+ CURRENT_AGENT.set(None)
220
+ CURRENT_REQUEST_ID.set(None)
221
+ CURRENT_USER_ID.set(None)
222
+
223
+ # Convenience functions for different log types
224
+ def log_agent_action(agent_name: str, action: str, details: Optional[Dict[str, Any]] = None):
225
+ """Log an agent action with structured data"""
226
+ logger = get_logger('agent.action', agent_name)
227
+ details_str = f" {details}" if details else ""
228
+ logger.info(f"{action}{details_str}")
229
+
230
+ def log_skill_event(agent_name: str, skill_name: str, event: str, details: Optional[Dict[str, Any]] = None):
231
+ """Log a skill event"""
232
+ logger = get_logger(f'skill.{skill_name}', agent_name)
233
+ details_str = f" {details}" if details else ""
234
+ logger.info(f"{event}{details_str}")
235
+
236
+ def log_tool_execution(agent_name: str, tool_name: str, duration_ms: int, success: bool = True):
237
+ """Log tool execution with timing"""
238
+ logger = get_logger('tool.execution', agent_name)
239
+ status = "SUCCESS" if success else "FAILED"
240
+ logger.info(f"Tool {tool_name} {status} ({duration_ms}ms)")
241
+
242
+ def log_handoff(agent_name: str, handoff_type: str, target: str, success: bool = True):
243
+ """Log handoff execution"""
244
+ logger = get_logger('handoff', agent_name)
245
+ status = "SUCCESS" if success else "FAILED"
246
+ logger.info(f"Handoff {handoff_type} -> {target} {status}")
247
+
248
+ def log_server_request(endpoint: str, method: str, status_code: int, duration_ms: int, agent_name: Optional[str] = None):
249
+ """Log server request with timing"""
250
+ logger = get_logger('server.request', agent_name)
251
+ logger.info(f"{method} {endpoint} {status_code} ({duration_ms}ms)")
252
+
253
+ # Performance logging utilities
254
+ class LogTimer:
255
+ """Context manager for timing operations with automatic logging"""
256
+
257
+ def __init__(self, operation_name: str, logger: logging.Logger, level: int = logging.INFO):
258
+ self.operation_name = operation_name
259
+ self.logger = logger
260
+ self.level = level
261
+ self.start_time = None
262
+
263
+ def __enter__(self):
264
+ self.start_time = time.time()
265
+ self.logger.log(self.level, f"Starting {self.operation_name}")
266
+ return self
267
+
268
+ def __exit__(self, exc_type, exc_val, exc_tb):
269
+ duration_ms = int((time.time() - self.start_time) * 1000)
270
+ if exc_type:
271
+ self.logger.error(f"{self.operation_name} FAILED ({duration_ms}ms): {exc_val}")
272
+ else:
273
+ self.logger.log(self.level, f"{self.operation_name} completed ({duration_ms}ms)")
274
+
275
+ def timer(operation_name: str, agent_name: Optional[str] = None, level: int = logging.INFO):
276
+ """Create a timing context manager"""
277
+ logger = get_logger('performance', agent_name)
278
+ return LogTimer(operation_name, logger, level)
279
+
280
+ def configure_external_logger(logger_name: str, level: Optional[str] = None) -> None:
281
+ """Configure an external logger to use our structured format
282
+
283
+ Args:
284
+ logger_name: Name of the logger to configure (e.g., 'litellm', 'openlicense')
285
+ level: Optional log level to set (defaults to current root level)
286
+ """
287
+ logger = logging.getLogger(logger_name)
288
+
289
+ # Clear any existing handlers
290
+ logger.handlers.clear()
291
+
292
+ # Get the current root level if not specified
293
+ if level is None:
294
+ root_logger = logging.getLogger('webagents')
295
+ numeric_level = root_logger.level
296
+ else:
297
+ numeric_level = getattr(logging, level.upper(), logging.INFO)
298
+
299
+ # Add our formatted handler
300
+ handler = logging.StreamHandler(sys.stdout)
301
+ handler.setFormatter(WebAgentsFormatter())
302
+ handler.setLevel(numeric_level)
303
+ logger.addHandler(handler)
304
+ logger.setLevel(numeric_level)
305
+ logger.propagate = False
306
+
307
+ def capture_all_loggers() -> None:
308
+ """Ensure all existing loggers use our structured format
309
+
310
+ This function should be called after all modules are imported
311
+ to ensure any dynamically created loggers are properly configured.
312
+ """
313
+ root_formatter = WebAgentsFormatter()
314
+ root_level = logging.getLogger('webagents').level
315
+
316
+ # Get all existing loggers
317
+ for name in logging.Logger.manager.loggerDict:
318
+ logger = logging.getLogger(name)
319
+
320
+ # Skip if it's already a webagents logger
321
+ if name.startswith('webagents'):
322
+ continue
323
+
324
+ # Skip if it has handlers (already configured)
325
+ if logger.handlers:
326
+ # Update handlers to use our formatter
327
+ for handler in logger.handlers:
328
+ if isinstance(handler, logging.StreamHandler):
329
+ handler.setFormatter(root_formatter)
330
+ else:
331
+ # Add our handler if no handlers exist
332
+ handler = logging.StreamHandler(sys.stdout)
333
+ handler.setFormatter(root_formatter)
334
+ handler.setLevel(root_level)
335
+ logger.addHandler(handler)
336
+ logger.propagate = False
337
+
338
+ # Custom logger class that automatically uses our formatter
339
+ class WebAgentsLogger(logging.Logger):
340
+ """Custom logger that automatically gets our formatter"""
341
+
342
+ def __init__(self, name):
343
+ super().__init__(name)
344
+ # Automatically add our handler if this is a new logger
345
+ if not self.handlers and not name.startswith('webagents'):
346
+ handler = logging.StreamHandler(sys.stdout)
347
+ handler.setFormatter(WebAgentsFormatter())
348
+ # Get the root level
349
+ root_level = logging.getLogger('webagents').level if logging.getLogger('webagents').level else logging.INFO
350
+ handler.setLevel(root_level)
351
+ self.addHandler(handler)
352
+ self.setLevel(root_level)
353
+ self.propagate = False
354
+
355
+ # Set our custom logger class as the default
356
+ logging.setLoggerClass(WebAgentsLogger)
357
+
358
+ # Initialize logging on import (can be reconfigured later)
359
+ setup_logging()
@@ -0,0 +1,230 @@
1
+ Metadata-Version: 2.4
2
+ Name: webagents
3
+ Version: 0.1.0
4
+ Summary: Foundation framework for the Web of Agents - build, serve and monetize AI agents
5
+ Author: Awesome Opensource Contributors and Robutler Team
6
+ License: MIT License
7
+
8
+ Copyright (c) 2025 Robutler
9
+
10
+ Permission is hereby granted, free of charge, to any person obtaining a copy
11
+ of this software and associated documentation files (the "Software"), to deal
12
+ in the Software without restriction, including without limitation the rights
13
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
+ copies of the Software, and to permit persons to whom the Software is
15
+ furnished to do so, subject to the following conditions:
16
+
17
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
18
+
19
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25
+ SOFTWARE.
26
+ License-File: LICENSE
27
+ Requires-Python: >=3.10
28
+ Requires-Dist: colorama>=0.4.6
29
+ Requires-Dist: fastapi>=0.100.0
30
+ Requires-Dist: fastmcp>=2.3.0
31
+ Requires-Dist: httpx>=0.24.0
32
+ Requires-Dist: litellm>=1.0.0
33
+ Requires-Dist: pillow>=10.0.0
34
+ Requires-Dist: pydantic-settings>=2.0.0
35
+ Requires-Dist: pydantic>=2.7.0
36
+ Requires-Dist: python-dotenv>=1.0.0
37
+ Requires-Dist: tiktoken>=0.5.0
38
+ Requires-Dist: uvicorn>=0.23.0
39
+ Provides-Extra: dev
40
+ Requires-Dist: black>=23.0.0; extra == 'dev'
41
+ Requires-Dist: mypy>=1.0.0; extra == 'dev'
42
+ Requires-Dist: pytest-asyncio>=0.21.0; extra == 'dev'
43
+ Requires-Dist: pytest>=7.0.0; extra == 'dev'
44
+ Requires-Dist: ruff>=0.0.270; extra == 'dev'
45
+ Provides-Extra: examples
46
+ Requires-Dist: openai-agents>=0.0.16; extra == 'examples'
47
+ Description-Content-Type: text/markdown
48
+
49
+ # WebAgents - core framework for the Web of Agents
50
+
51
+ **Build, Serve and Monetize AI Agents**
52
+
53
+ WebAgents is a powerful opensource framework for building connected AI agents with a simple yet comprehensive API. Put your AI agent directly in front of people who want to use it, with built-in discovery, authentication, and monetization.
54
+
55
+ [![PyPI version](https://badge.fury.io/py/webagents.svg)](https://badge.fury.io/py/webagents)
56
+ [![Python 3.10+](https://img.shields.io/badge/python-3.10+-blue.svg)](https://www.python.org/downloads/)
57
+ [![License](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE)
58
+
59
+ ## πŸš€ Key Features
60
+
61
+ - **🧩 Modular Skills System** - Combine tools, prompts, hooks, and HTTP endpoints into reusable packages
62
+ - **🀝 Agent-to-Agent Delegation** - Delegate tasks to other agents via natural language. Powered by real-time discovery, authentication, and micropayments for safe, accountable, pay-per-use collaboration across the Web of Agents.
63
+ - **πŸ” Real-Time Discovery** - Agents discover each other through intent matching - no manual integration
64
+ - **πŸ’° Built-in Monetization** - Earn credits from priced tools with automatic billing
65
+ - **πŸ” Trust & Security** - Secure authentication and scope-based access control
66
+ - **🌐 Protocol agnostic connectivity** - Deploy agents as standard chat completion endpoints with coming support for OpenAI Responses/Realtime, ACP, A2A and other common AI communication protocols and frameworks.
67
+ - **πŸ”Œ Build or Integrate** - Build from scratch with WebAgents, or integrate existing agents from popular SDKs and platforms into the Web of Agents (e.g., Azure AI Foundry, Google Vertex AI, CrewAI, n8n, Zapier).
68
+
69
+ With WebAgents delegation, your agent is as powerful as the whole ecosystem, and capabilities of your agent grow together with the whole ecosystem.
70
+
71
+ ## πŸ“¦ Installation
72
+
73
+ ```bash
74
+ pip install webagents
75
+ ```
76
+
77
+ ## πŸƒβ€β™‚οΈ Quick Start
78
+
79
+ ### Create Your First Agent
80
+
81
+ ```python
82
+ from webagents.agents.core.base_agent import BaseAgent
83
+
84
+ # Create a basic agent
85
+ agent = BaseAgent(
86
+ name="assistant",
87
+ instructions="You are a helpful AI assistant.",
88
+ model="openai/gpt-4o-mini" # Automatically creates LLM skill
89
+ )
90
+
91
+ # Run chat completion
92
+ messages = [{"role": "user", "content": "Hello! What can you help me with?"}]
93
+ response = await agent.run(messages=messages)
94
+ print(response.content)
95
+ ```
96
+
97
+ ### Serve Your Agent
98
+
99
+ Deploy your agent as an OpenAI-compatible API server:
100
+
101
+ ```python
102
+ from webagents.server.core.app import create_server
103
+ import uvicorn
104
+
105
+ # Create server with your agent
106
+ server = create_server(agents=[agent])
107
+
108
+ # Run the server
109
+ uvicorn.run(server.app, host="0.0.0.0", port=8000)
110
+ ```
111
+
112
+ Test your agent API:
113
+ ```bash
114
+ curl -X POST http://localhost:8000/assistant/chat/completions \
115
+ -H "Content-Type: application/json" \
116
+ -d '{"messages": [{"role": "user", "content": "Hello!"}]}'
117
+ ```
118
+
119
+ ## 🧩 Skills Framework
120
+
121
+ Skills combine tools, prompts, hooks, and HTTP endpoints into easy-to-integrate packages:
122
+
123
+ ```python
124
+ from webagents.agents.skills.base import Skill
125
+ from webagents.agents.tools.decorators import tool, prompt, hook, http
126
+ from webagents.agents.skills.robutler.payments.skill import pricing
127
+
128
+ class NotificationsSkill(Skill):
129
+ @prompt(scope=["owner"])
130
+ def get_prompt(self) -> str:
131
+ return "You can send notifications using send_notification()."
132
+
133
+ @tool(scope="owner")
134
+ @pricing(credits_per_call=0.01)
135
+ async def send_notification(self, title: str, body: str) -> str:
136
+ # Your API integration
137
+ return f"βœ… Notification sent: {title}"
138
+
139
+ @hook("on_message")
140
+ async def log_messages(self, context):
141
+ # React to incoming messages
142
+ return context
143
+
144
+ @http("POST", "/webhook")
145
+ async def handle_webhook(self, request):
146
+ # Custom HTTP endpoint
147
+ return {"status": "received"}
148
+ ```
149
+
150
+ **Core Skills** - Essential functionality:
151
+ - **LLM Skills**: OpenAI, Anthropic, LiteLLM integration
152
+ - **Memory Skills**: Short-term, long-term, and vector memory
153
+ - **MCP Skill**: Model Context Protocol integration
154
+
155
+ **Platform Skills** - WebAgents ecosystem:
156
+ - **Discovery**: Real-time agent discovery and routing
157
+ - **Authentication**: Secure agent-to-agent communication
158
+ - **Payments**: Monetization and automatic billing
159
+ - **Storage**: Persistent data and messaging
160
+
161
+ **Ecosystem Skills** - External integrations:
162
+ - **Google**: Calendar, Drive, Gmail integration
163
+ - **Database**: SQL and NoSQL database access
164
+ - **Workflow**: CrewAI, N8N, Zapier automation
165
+
166
+ ## πŸ’° Monetization
167
+
168
+ Add payments to earn credits from your agent:
169
+
170
+ ```python
171
+ from webagents.agents.core.base_agent import BaseAgent
172
+ from webagents.agents.skills.robutler.payments.skill import PaymentSkill
173
+
174
+ agent = BaseAgent(
175
+ name="image-generator",
176
+ model="openai/gpt-4o-mini",
177
+ skills={
178
+ "payments": PaymentSkill(),
179
+ "image": ImageGenerationSkill() # Contains @pricing decorated tools
180
+ }
181
+ )
182
+ ```
183
+
184
+ ## πŸ”§ Environment Setup
185
+
186
+ Set up your API keys for LLM providers:
187
+
188
+ ```bash
189
+ # Required for OpenAI models
190
+ export OPENAI_API_KEY="your-openai-key"
191
+
192
+ # Optional for other providers
193
+ export ANTHROPIC_API_KEY="your-anthropic-key"
194
+ export WEBAGENTS_API_KEY="your-webagents-key"
195
+ ```
196
+
197
+ ## 🌐 Web of Agents
198
+
199
+ WebAgents enables dynamic real-time orchestration where each AI agent acts as a building block for other agents:
200
+
201
+ - **πŸš€ Real-Time Discovery**: Think DNS for agent intents - agents find each other through natural language
202
+ - **πŸ” Trust & Security**: Secure authentication with audit trails for all transactions
203
+ - **πŸ’‘ Delegation by Design**: Seamless delegation across agents, enabled by real-time discovery, scoped authentication, and micropayments. No custom integrations or API keys to juggleβ€”describe the need, and the right agent is invoked on demand.
204
+
205
+ ## πŸ“š Documentation
206
+
207
+ - **[Full Documentation](https://webagents.robutler.ai)** - Complete guides and API reference
208
+ - **[Skills Framework](https://webagents.robutler.ai/skills/overview/)** - Deep dive into modular capabilities
209
+ - **[Agent Architecture](https://webagents.robutler.ai/agent/overview/)** - Understand agent communication
210
+ - **[Custom Skills](https://webagents.robutler.ai/skills/custom/)** - Build your own capabilities
211
+
212
+ ## 🀝 Contributing
213
+
214
+ We welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for details.
215
+
216
+ ## πŸ“„ License
217
+
218
+ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
219
+
220
+ ## πŸ†˜ Support
221
+
222
+ - **GitHub Issues**: [Report bugs and request features](https://github.com/robutlerai/webagents/issues)
223
+ - **Documentation**: [webagents.robutler.ai](https://webagents.robutler.ai)
224
+ - **Community**: Join our Discord server for discussions and support
225
+
226
+ ---
227
+
228
+ **Focus on what makes your agent unique instead of spending time on plumbing.**
229
+
230
+ Built with ❀️ by the WebAgents team and community contributors.