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.
- webagents/__init__.py +1 -1
- webagents/__main__.py +55 -0
- webagents/agents/__init__.py +1 -1
- webagents/agents/core/__init__.py +1 -1
- webagents/agents/core/base_agent.py +15 -15
- webagents/agents/core/handoffs.py +1 -1
- webagents/agents/skills/__init__.py +11 -11
- webagents/agents/skills/base.py +1 -1
- webagents/agents/skills/core/llm/litellm/__init__.py +1 -1
- webagents/agents/skills/core/llm/litellm/skill.py +1 -1
- webagents/agents/skills/core/mcp/README.md +2 -2
- webagents/agents/skills/core/mcp/skill.py +2 -2
- webagents/agents/skills/core/memory/long_term_memory/memory_skill.py +14 -14
- webagents/agents/skills/core/memory/short_term_memory/__init__.py +1 -1
- webagents/agents/skills/core/memory/short_term_memory/skill.py +1 -1
- webagents/agents/skills/core/memory/vector_memory/skill.py +6 -6
- webagents/agents/skills/core/planning/__init__.py +1 -1
- webagents/agents/skills/ecosystem/crewai/__init__.py +3 -1
- webagents/agents/skills/ecosystem/crewai/skill.py +158 -0
- webagents/agents/skills/ecosystem/database/__init__.py +3 -1
- webagents/agents/skills/ecosystem/database/skill.py +522 -0
- webagents/agents/skills/ecosystem/google/calendar/skill.py +1 -1
- webagents/agents/skills/ecosystem/mongodb/__init__.py +3 -0
- webagents/agents/skills/ecosystem/mongodb/skill.py +428 -0
- webagents/agents/skills/ecosystem/n8n/README.md +287 -0
- webagents/agents/skills/ecosystem/n8n/__init__.py +3 -0
- webagents/agents/skills/ecosystem/n8n/skill.py +341 -0
- webagents/agents/skills/ecosystem/x_com/README.md +401 -0
- webagents/agents/skills/ecosystem/x_com/__init__.py +3 -0
- webagents/agents/skills/ecosystem/x_com/skill.py +1048 -0
- webagents/agents/skills/ecosystem/zapier/README.md +363 -0
- webagents/agents/skills/ecosystem/zapier/__init__.py +3 -0
- webagents/agents/skills/ecosystem/zapier/skill.py +337 -0
- webagents/agents/skills/robutler/__init__.py +2 -2
- webagents/agents/skills/robutler/auth/__init__.py +3 -3
- webagents/agents/skills/robutler/auth/skill.py +16 -16
- webagents/agents/skills/robutler/crm/__init__.py +2 -2
- webagents/agents/skills/robutler/crm/skill.py +5 -5
- webagents/agents/skills/robutler/discovery/README.md +5 -5
- webagents/agents/skills/robutler/discovery/__init__.py +2 -2
- webagents/agents/skills/robutler/discovery/skill.py +21 -21
- webagents/agents/skills/robutler/message_history/__init__.py +2 -2
- webagents/agents/skills/robutler/message_history/skill.py +5 -5
- webagents/agents/skills/robutler/nli/__init__.py +1 -1
- webagents/agents/skills/robutler/nli/skill.py +9 -9
- webagents/agents/skills/robutler/payments/__init__.py +3 -3
- webagents/agents/skills/robutler/payments/exceptions.py +1 -1
- webagents/agents/skills/robutler/payments/skill.py +23 -23
- webagents/agents/skills/robutler/storage/__init__.py +2 -2
- webagents/agents/skills/robutler/storage/files/__init__.py +2 -2
- webagents/agents/skills/robutler/storage/files/skill.py +4 -4
- webagents/agents/skills/robutler/storage/json/__init__.py +1 -1
- webagents/agents/skills/robutler/storage/json/skill.py +3 -3
- webagents/agents/skills/robutler/storage/kv/skill.py +3 -3
- webagents/agents/skills/robutler/storage.py +6 -6
- webagents/agents/tools/decorators.py +12 -12
- webagents/server/__init__.py +3 -3
- webagents/server/context/context_vars.py +2 -2
- webagents/server/core/app.py +13 -13
- webagents/server/core/middleware.py +3 -3
- webagents/server/core/models.py +1 -1
- webagents/server/core/monitoring.py +2 -2
- webagents/server/middleware.py +1 -1
- webagents/server/models.py +2 -2
- webagents/server/monitoring.py +15 -15
- webagents/utils/logging.py +20 -20
- webagents-0.2.2.dist-info/METADATA +266 -0
- webagents-0.2.2.dist-info/RECORD +105 -0
- webagents-0.2.2.dist-info/licenses/LICENSE +20 -0
- webagents/api/__init__.py +0 -17
- webagents/api/client.py +0 -1207
- webagents/api/types.py +0 -253
- webagents-0.1.13.dist-info/METADATA +0 -32
- webagents-0.1.13.dist-info/RECORD +0 -96
- webagents-0.1.13.dist-info/licenses/LICENSE +0 -1
- {webagents-0.1.13.dist-info → webagents-0.2.2.dist-info}/WHEEL +0 -0
- {webagents-0.1.13.dist-info → webagents-0.2.2.dist-info}/entry_points.txt +0 -0
@@ -1,9 +1,9 @@
|
|
1
1
|
"""
|
2
|
-
AuthSkill Package -
|
2
|
+
AuthSkill Package - WebAgents V2.0
|
3
3
|
|
4
|
-
Authentication and authorization skill for
|
4
|
+
Authentication and authorization skill for WebAgents platform.
|
5
5
|
Provides user authentication, API key validation, role-based access control,
|
6
|
-
and integration with
|
6
|
+
and integration with WebAgents platform services.
|
7
7
|
"""
|
8
8
|
|
9
9
|
from .skill import AuthSkill, AuthScope, AuthContext, AuthenticationError, AuthorizationError
|
@@ -1,8 +1,8 @@
|
|
1
1
|
"""
|
2
|
-
AuthSkill -
|
2
|
+
AuthSkill - WebAgents V2.0 Platform Integration
|
3
3
|
|
4
|
-
Authentication and authorization skill for
|
5
|
-
Integrates with
|
4
|
+
Authentication and authorization skill for WebAgents platform.
|
5
|
+
Integrates with WebAgents Portal APIs for user authentication, API key validation,
|
6
6
|
and platform service integration.
|
7
7
|
"""
|
8
8
|
|
@@ -13,8 +13,8 @@ from enum import Enum
|
|
13
13
|
|
14
14
|
from webagents.agents.skills.base import Skill
|
15
15
|
from webagents.agents.tools.decorators import tool, hook
|
16
|
-
from
|
17
|
-
from
|
16
|
+
from robutler.api import RobutlerClient
|
17
|
+
from robutler.api.types import User, ApiKey, AuthResponse
|
18
18
|
from typing import Any as _Any
|
19
19
|
try:
|
20
20
|
from jose import jwt as jose_jwt # python-jose
|
@@ -49,10 +49,10 @@ class AuthContext:
|
|
49
49
|
|
50
50
|
class AuthSkill(Skill):
|
51
51
|
"""
|
52
|
-
Authentication and authorization skill for
|
52
|
+
Authentication and authorization skill for WebAgents platform
|
53
53
|
|
54
54
|
Features:
|
55
|
-
- Platform integration with
|
55
|
+
- Platform integration with WebAgents Portal APIs
|
56
56
|
- API key authentication and validation
|
57
57
|
- User information retrieval
|
58
58
|
- Credit tracking and usage management
|
@@ -82,13 +82,13 @@ class AuthSkill(Skill):
|
|
82
82
|
self.client: Optional[RobutlerClient] = None
|
83
83
|
|
84
84
|
async def initialize(self, agent) -> None:
|
85
|
-
"""Initialize AuthSkill with
|
85
|
+
"""Initialize AuthSkill with WebAgents Platform client"""
|
86
86
|
from webagents.utils.logging import get_logger, log_skill_event
|
87
87
|
|
88
88
|
self.agent = agent
|
89
|
-
self.logger = get_logger('skill.
|
89
|
+
self.logger = get_logger('skill.webagents.auth', agent.name)
|
90
90
|
|
91
|
-
# Initialize
|
91
|
+
# Initialize WebAgents Platform client
|
92
92
|
try:
|
93
93
|
# Use api_key as priority, fallback to agent's API key
|
94
94
|
final_api_key = self.api_key or getattr(agent, 'api_key', None)
|
@@ -101,12 +101,12 @@ class AuthSkill(Skill):
|
|
101
101
|
# Test connection
|
102
102
|
health_response = await self.client.health_check()
|
103
103
|
if health_response.success:
|
104
|
-
self.logger.info(f"Connected to
|
104
|
+
self.logger.info(f"Connected to WebAgents Platform: {self.platform_api_url}")
|
105
105
|
else:
|
106
106
|
self.logger.warning(f"Platform health check failed: {health_response.message}")
|
107
107
|
|
108
108
|
except Exception as e:
|
109
|
-
self.logger.error(f"Failed to initialize
|
109
|
+
self.logger.error(f"Failed to initialize WebAgents Platform client: {e}")
|
110
110
|
# Continue without platform integration for testing
|
111
111
|
self.client = None
|
112
112
|
|
@@ -121,7 +121,7 @@ class AuthSkill(Skill):
|
|
121
121
|
|
122
122
|
@hook("on_connection", priority=0, scope="all")
|
123
123
|
async def validate_request_auth(self, context) -> Any:
|
124
|
-
"""Validate authentication for incoming requests using
|
124
|
+
"""Validate authentication for incoming requests using WebAgents Platform"""
|
125
125
|
if not self.require_auth:
|
126
126
|
return context
|
127
127
|
|
@@ -241,7 +241,7 @@ class AuthSkill(Skill):
|
|
241
241
|
assertion_token,
|
242
242
|
selected_key,
|
243
243
|
algorithms=['RS256'],
|
244
|
-
audience=f"
|
244
|
+
audience=f"webagents-agent:{getattr(self.agent, 'id', '')}",
|
245
245
|
)
|
246
246
|
if claims.get('agent_id') and getattr(self.agent, 'id', None) and claims['agent_id'] != getattr(self.agent, 'id'):
|
247
247
|
raise Exception('Owner assertion agent_id mismatch')
|
@@ -265,7 +265,7 @@ class AuthSkill(Skill):
|
|
265
265
|
return None
|
266
266
|
|
267
267
|
async def _authenticate_api_key(self, api_key: str) -> Optional[AuthContext]:
|
268
|
-
"""Authenticate API key with
|
268
|
+
"""Authenticate API key with WebAgents Platform and merge optional owner assertion (JWT)."""
|
269
269
|
|
270
270
|
if not self.client:
|
271
271
|
self.logger.warning("Platform client not available for authentication")
|
@@ -321,7 +321,7 @@ class AuthSkill(Skill):
|
|
321
321
|
assertion_token,
|
322
322
|
selected_key,
|
323
323
|
algorithms=['RS256'],
|
324
|
-
audience=f"
|
324
|
+
audience=f"webagents-agent:{getattr(self.agent, 'id', '')}",
|
325
325
|
)
|
326
326
|
# Enforce agent binding if claim present
|
327
327
|
if claims.get('agent_id') and getattr(self.agent, 'id', None) and claims['agent_id'] != getattr(self.agent, 'id'):
|
@@ -1,7 +1,7 @@
|
|
1
1
|
"""
|
2
|
-
CRM & Analytics Skill Package -
|
2
|
+
CRM & Analytics Skill Package - WebAgents Platform Integration
|
3
3
|
|
4
|
-
CRM and analytics skill for
|
4
|
+
CRM and analytics skill for WebAgents platform.
|
5
5
|
Provides contact management and event tracking capabilities.
|
6
6
|
"""
|
7
7
|
|
@@ -1,5 +1,5 @@
|
|
1
1
|
"""
|
2
|
-
|
2
|
+
WebAgents CRM & Analytics Skill
|
3
3
|
|
4
4
|
This skill provides agents with CRM and analytics capabilities, allowing them to:
|
5
5
|
- Track and manage contacts
|
@@ -65,7 +65,7 @@ class AnalyticsEvent:
|
|
65
65
|
|
66
66
|
class CRMAnalyticsSkill(Skill):
|
67
67
|
"""
|
68
|
-
CRM & Analytics skill for
|
68
|
+
CRM & Analytics skill for WebAgents agents
|
69
69
|
|
70
70
|
Provides comprehensive CRM and analytics capabilities for agents to track
|
71
71
|
users, events, and build intelligent marketing campaigns.
|
@@ -73,8 +73,8 @@ class CRMAnalyticsSkill(Skill):
|
|
73
73
|
|
74
74
|
def __init__(self, config: Dict[str, Any] = None, scope: str = "all"):
|
75
75
|
super().__init__(config, scope)
|
76
|
-
self.api_base_url = config.get('api_base_url', os.getenv('ROBUTLER_API_URL', 'https://
|
77
|
-
self.api_key = config.get('api_key', os.getenv('
|
76
|
+
self.api_base_url = config.get('api_base_url', os.getenv('ROBUTLER_API_URL', 'https://webagents.ai/api'))
|
77
|
+
self.api_key = config.get('api_key', os.getenv('WEBAGENTS_API_KEY'))
|
78
78
|
self.subject_type = config.get('subject_type', 'agent')
|
79
79
|
self.subject_id = config.get('subject_id', str(uuid4()))
|
80
80
|
self.namespace = config.get('namespace')
|
@@ -86,7 +86,7 @@ class CRMAnalyticsSkill(Skill):
|
|
86
86
|
from webagents.utils.logging import get_logger, log_skill_event
|
87
87
|
|
88
88
|
self.agent = agent
|
89
|
-
self.logger = get_logger('skill.
|
89
|
+
self.logger = get_logger('skill.webagents.crm', self.agent.name)
|
90
90
|
|
91
91
|
# Initialize HTTP session
|
92
92
|
self.session = aiohttp.ClientSession(
|
@@ -35,7 +35,7 @@ The `DiscoverySkill` provides comprehensive **intent-based agent search** and **
|
|
35
35
|
- **API Key Resolution Hierarchy**:
|
36
36
|
1. `config.robutler_api_key` (explicit configuration)
|
37
37
|
2. `agent.api_key` (agent's API key)
|
38
|
-
3. `
|
38
|
+
3. `WEBAGENTS_API_KEY` environment variable
|
39
39
|
4. `rok_testapikey` (default for development)
|
40
40
|
|
41
41
|
- **Base URL Resolution**:
|
@@ -69,7 +69,7 @@ The `DiscoverySkill` provides comprehensive **intent-based agent search** and **
|
|
69
69
|
### Basic Configuration
|
70
70
|
|
71
71
|
```python
|
72
|
-
from
|
72
|
+
from webagents.agents.skills.robutler.discovery import DiscoverySkill
|
73
73
|
|
74
74
|
# Default configuration
|
75
75
|
discovery = DiscoverySkill()
|
@@ -87,8 +87,8 @@ discovery = DiscoverySkill({
|
|
87
87
|
### Agent Integration
|
88
88
|
|
89
89
|
```python
|
90
|
-
from
|
91
|
-
from
|
90
|
+
from webagents.agents.core.base_agent import BaseAgent
|
91
|
+
from webagents.agents.skills.robutler.discovery import DiscoverySkill
|
92
92
|
|
93
93
|
agent = BaseAgent(
|
94
94
|
name="discovery-agent",
|
@@ -236,7 +236,7 @@ None - all configuration is optional with sensible defaults.
|
|
236
236
|
|
237
237
|
### Environment Variables
|
238
238
|
- `ROBUTLER_API_URL` - Platform API base URL
|
239
|
-
- `
|
239
|
+
- `WEBAGENTS_API_KEY` - Platform API key
|
240
240
|
|
241
241
|
## Dependencies
|
242
242
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
"""
|
2
|
-
DiscoverySkill Package - Simplified
|
2
|
+
DiscoverySkill Package - Simplified WebAgents Platform Integration
|
3
3
|
|
4
|
-
Agent discovery skill for
|
4
|
+
Agent discovery skill for WebAgents platform.
|
5
5
|
Provides intent-based agent discovery and intent publishing capabilities.
|
6
6
|
"""
|
7
7
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
"""
|
2
|
-
DiscoverySkill - Simplified
|
2
|
+
DiscoverySkill - Simplified WebAgents Platform Integration
|
3
3
|
|
4
|
-
Agent discovery skill for
|
4
|
+
Agent discovery skill for WebAgents platform.
|
5
5
|
Provides intent-based agent discovery and intent publishing capabilities.
|
6
6
|
"""
|
7
7
|
|
@@ -26,7 +26,7 @@ class DiscoveryResult:
|
|
26
26
|
|
27
27
|
class DiscoverySkill(Skill):
|
28
28
|
"""
|
29
|
-
Simplified agent discovery skill for
|
29
|
+
Simplified agent discovery skill for WebAgents platform
|
30
30
|
|
31
31
|
Key Features:
|
32
32
|
- Intent-based agent discovery via Portal API
|
@@ -36,7 +36,7 @@ class DiscoverySkill(Skill):
|
|
36
36
|
Configuration hierarchy for robutler_api_key:
|
37
37
|
1. config.robutler_api_key (explicit configuration)
|
38
38
|
2. agent.api_key (agent's API key)
|
39
|
-
3.
|
39
|
+
3. WEBAGENTS_API_KEY environment variable
|
40
40
|
4. SERVICE_TOKEN environment variable
|
41
41
|
|
42
42
|
Configuration hierarchy for agent_base_url:
|
@@ -52,12 +52,12 @@ class DiscoverySkill(Skill):
|
|
52
52
|
self.config = config or {}
|
53
53
|
self.enable_discovery = self.config.get('enable_discovery', True)
|
54
54
|
|
55
|
-
#
|
56
|
-
self.
|
55
|
+
# WebAgents platform configuration
|
56
|
+
self.webagents_api_url = (
|
57
57
|
os.getenv('ROBUTLER_INTERNAL_API_URL') or
|
58
58
|
os.getenv('ROBUTLER_API_URL') or
|
59
|
-
self.config.get('
|
60
|
-
'https://
|
59
|
+
self.config.get('webagents_api_url') or
|
60
|
+
'https://webagents.ai'
|
61
61
|
)
|
62
62
|
|
63
63
|
# Agent communication base URL configuration (for dynamic agent URLs in prompts)
|
@@ -75,16 +75,16 @@ class DiscoverySkill(Skill):
|
|
75
75
|
from webagents.utils.logging import get_logger, log_skill_event
|
76
76
|
|
77
77
|
self.agent = agent
|
78
|
-
self.logger = get_logger('skill.
|
78
|
+
self.logger = get_logger('skill.webagents.discovery', self.agent.name)
|
79
79
|
|
80
|
-
# Resolve
|
80
|
+
# Resolve WebAgents API key using hierarchy: config -> agent.api_key -> env
|
81
81
|
if not self.robutler_api_key:
|
82
82
|
if hasattr(self.agent, 'api_key') and self.agent.api_key:
|
83
83
|
self.robutler_api_key = self.agent.api_key
|
84
|
-
self.logger.debug(f"Using agent's API key for
|
85
|
-
elif os.getenv('
|
86
|
-
self.robutler_api_key = os.getenv('
|
87
|
-
self.logger.debug(f"Using
|
84
|
+
self.logger.debug(f"Using agent's API key for WebAgents platform")
|
85
|
+
elif os.getenv('WEBAGENTS_API_KEY'):
|
86
|
+
self.robutler_api_key = os.getenv('WEBAGENTS_API_KEY')
|
87
|
+
self.logger.debug(f"Using WEBAGENTS_API_KEY from environment")
|
88
88
|
elif os.getenv('SERVICE_TOKEN'):
|
89
89
|
self.robutler_api_key = os.getenv('SERVICE_TOKEN')
|
90
90
|
self.logger.debug(f"Using SERVICE_TOKEN from environment")
|
@@ -93,7 +93,7 @@ class DiscoverySkill(Skill):
|
|
93
93
|
|
94
94
|
log_skill_event(self.agent.name, 'discovery', 'initialized', {
|
95
95
|
'enable_discovery': self.enable_discovery,
|
96
|
-
'
|
96
|
+
'webagents_api_url': self.webagents_api_url,
|
97
97
|
'agent_base_url': self.agent_base_url,
|
98
98
|
'has_api_key': bool(self.robutler_api_key)
|
99
99
|
})
|
@@ -105,12 +105,12 @@ class DiscoverySkill(Skill):
|
|
105
105
|
base_url = self.agent_base_url.rstrip('/')
|
106
106
|
return f"You are part of a network of AI agents working for their owners. Each agent has their own name and address. @agentname corresponds to {base_url}/agents/agentname. Use discovery_tool to discover other agents and their capabilities."
|
107
107
|
|
108
|
-
@tool(description="Discover agents and their capabilities across the
|
108
|
+
@tool(description="Discover agents and their capabilities across the WebAgents network by intent. Make the intent as specific as possible. When presenting the results, make it simple and non-technical.", scope="all")
|
109
109
|
async def discovery_tool(self,
|
110
110
|
intent: str,
|
111
111
|
top_k: int = 10,
|
112
112
|
context=None) -> Dict[str, Any]:
|
113
|
-
"""Discover agents by intent across the
|
113
|
+
"""Discover agents by intent across the WebAgents network"""
|
114
114
|
if not self.enable_discovery:
|
115
115
|
return {'success': False, 'error': 'Discovery disabled'}
|
116
116
|
|
@@ -125,7 +125,7 @@ class DiscoverySkill(Skill):
|
|
125
125
|
|
126
126
|
async with aiohttp.ClientSession() as session:
|
127
127
|
async with session.post(
|
128
|
-
f"{self.
|
128
|
+
f"{self.webagents_api_url}/api/intents/search",
|
129
129
|
headers={
|
130
130
|
'Authorization': f'Bearer {self.robutler_api_key}',
|
131
131
|
'Content-Type': 'application/json',
|
@@ -174,7 +174,7 @@ class DiscoverySkill(Skill):
|
|
174
174
|
intents: List[str],
|
175
175
|
description: str,
|
176
176
|
context=None) -> Dict[str, Any]:
|
177
|
-
"""Publish agent intents to the
|
177
|
+
"""Publish agent intents to the WebAgents platform"""
|
178
178
|
if not self.enable_discovery:
|
179
179
|
return {'success': False, 'error': 'Discovery disabled'}
|
180
180
|
|
@@ -186,7 +186,7 @@ class DiscoverySkill(Skill):
|
|
186
186
|
|
187
187
|
# Get agent information
|
188
188
|
agent_id = getattr(self.agent, 'name', 'unknown')
|
189
|
-
agent_url = self.config.get('agent_url', f"https://
|
189
|
+
agent_url = self.config.get('agent_url', f"https://webagents.ai/agents/{agent_id}")
|
190
190
|
|
191
191
|
# Prepare intent data
|
192
192
|
intents_data = [
|
@@ -201,7 +201,7 @@ class DiscoverySkill(Skill):
|
|
201
201
|
|
202
202
|
async with aiohttp.ClientSession() as session:
|
203
203
|
async with session.post(
|
204
|
-
f"{self.
|
204
|
+
f"{self.webagents_api_url}/api/intents/publish",
|
205
205
|
headers={
|
206
206
|
'Authorization': f'Bearer {self.robutler_api_key}',
|
207
207
|
'Content-Type': 'application/json',
|
@@ -1,7 +1,7 @@
|
|
1
1
|
"""
|
2
|
-
Message History Skill for
|
2
|
+
Message History Skill for WebAgents Agents
|
3
3
|
|
4
|
-
Enables agents to save conversation messages to persistent storage in
|
4
|
+
Enables agents to save conversation messages to persistent storage in WebAgents Portal.
|
5
5
|
"""
|
6
6
|
|
7
7
|
from .skill import MessageHistorySkill
|
@@ -1,5 +1,5 @@
|
|
1
1
|
"""
|
2
|
-
MessageHistorySkill - Save agent conversation messages to
|
2
|
+
MessageHistorySkill - Save agent conversation messages to WebAgents Portal
|
3
3
|
|
4
4
|
This skill enables agents to:
|
5
5
|
- Automatically save conversation messages on connection finalization
|
@@ -19,7 +19,7 @@ from webagents.utils.logging import get_logger, log_skill_event
|
|
19
19
|
|
20
20
|
class MessageHistorySkill(Skill):
|
21
21
|
"""
|
22
|
-
Skill for automatically saving agent conversation history in
|
22
|
+
Skill for automatically saving agent conversation history in WebAgents Portal
|
23
23
|
|
24
24
|
Features:
|
25
25
|
- Automatic message saving on connection finalization
|
@@ -51,13 +51,13 @@ class MessageHistorySkill(Skill):
|
|
51
51
|
|
52
52
|
# Initialize API client
|
53
53
|
try:
|
54
|
-
from
|
54
|
+
from robutler.api.client import RobutlerClient
|
55
55
|
|
56
56
|
# Get API key from agent config, skill config, or environment
|
57
57
|
api_key = (
|
58
58
|
self.api_key or
|
59
59
|
getattr(agent, 'api_key', None) or
|
60
|
-
os.getenv('
|
60
|
+
os.getenv('WEBAGENTS_API_KEY')
|
61
61
|
)
|
62
62
|
|
63
63
|
if not api_key:
|
@@ -66,7 +66,7 @@ class MessageHistorySkill(Skill):
|
|
66
66
|
|
67
67
|
self.api_client = RobutlerClient(
|
68
68
|
api_key=api_key,
|
69
|
-
base_url=self.portal_url or os.getenv('ROBUTLER_API_URL', 'https://
|
69
|
+
base_url=self.portal_url or os.getenv('ROBUTLER_API_URL', 'https://webagents.ai')
|
70
70
|
)
|
71
71
|
|
72
72
|
log_skill_event(agent.name, 'message_history', 'initialized', {
|
@@ -1,7 +1,7 @@
|
|
1
1
|
"""
|
2
2
|
NLI Skill - Natural Language Interface for Agent-to-Agent Communication
|
3
3
|
|
4
|
-
Provides HTTP-based communication between
|
4
|
+
Provides HTTP-based communication between WebAgents agents with natural language messages.
|
5
5
|
"""
|
6
6
|
|
7
7
|
from .skill import NLISkill, NLICommunication, AgentEndpoint
|
@@ -1,7 +1,7 @@
|
|
1
1
|
"""
|
2
2
|
NLISkill - Natural Language Interface for Agent-to-Agent Communication
|
3
3
|
|
4
|
-
Enables
|
4
|
+
Enables WebAgents agents to communicate with other agents via natural language.
|
5
5
|
Provides HTTP-based communication with authorization limits and error handling.
|
6
6
|
"""
|
7
7
|
|
@@ -59,7 +59,7 @@ class NLISkill(Skill):
|
|
59
59
|
Natural Language Interface skill for agent-to-agent communication
|
60
60
|
|
61
61
|
Features:
|
62
|
-
- HTTP-based communication with other
|
62
|
+
- HTTP-based communication with other WebAgents agents
|
63
63
|
- Authorization limits and cost tracking
|
64
64
|
- Communication history and success rate tracking
|
65
65
|
- Automatic timeout and retry handling
|
@@ -104,7 +104,7 @@ class NLISkill(Skill):
|
|
104
104
|
from webagents.utils.logging import get_logger, log_skill_event
|
105
105
|
|
106
106
|
self.agent = agent
|
107
|
-
self.logger = get_logger('skill.
|
107
|
+
self.logger = get_logger('skill.webagents.nli', agent.name)
|
108
108
|
|
109
109
|
# Initialize HTTP client for agent communication
|
110
110
|
if HTTPX_AVAILABLE:
|
@@ -160,7 +160,7 @@ class NLISkill(Skill):
|
|
160
160
|
if not target_agent_id:
|
161
161
|
return None
|
162
162
|
portal_base_url = os.getenv('ROBUTLER_INTERNAL_API_URL') or os.getenv('ROBUTLER_API_URL') or 'http://localhost:3000'
|
163
|
-
service_token = os.getenv('SERVICE_TOKEN') or os.getenv('
|
163
|
+
service_token = os.getenv('SERVICE_TOKEN') or os.getenv('WEBAGENTS_API_KEY')
|
164
164
|
if not service_token:
|
165
165
|
return None
|
166
166
|
# Acting user id is strongly recommended for correct scoping
|
@@ -241,7 +241,7 @@ CRITICAL: When you need to communicate with another agent:
|
|
241
241
|
|
242
242
|
"""
|
243
243
|
|
244
|
-
@tool(description="Communicate with other
|
244
|
+
@tool(description="Communicate with other WebAgents agents via natural language", scope="all")
|
245
245
|
async def nli_tool(self,
|
246
246
|
agent_url: str,
|
247
247
|
message: str,
|
@@ -249,7 +249,7 @@ CRITICAL: When you need to communicate with another agent:
|
|
249
249
|
timeout: float = None,
|
250
250
|
context=None) -> str:
|
251
251
|
"""
|
252
|
-
Natural Language Interface to communicate with other
|
252
|
+
Natural Language Interface to communicate with other WebAgents agents.
|
253
253
|
|
254
254
|
Use this tool to send natural language messages to other agents and receive their responses.
|
255
255
|
This enables agent-to-agent collaboration, delegation, and information sharing.
|
@@ -303,13 +303,13 @@ CRITICAL: When you need to communicate with another agent:
|
|
303
303
|
# Add authorization headers
|
304
304
|
headers = {
|
305
305
|
"Content-Type": "application/json",
|
306
|
-
"User-Agent": f"
|
306
|
+
"User-Agent": f"WebAgents-NLI/{self.agent.name}",
|
307
307
|
"X-Authorization-Amount": str(authorized_amount),
|
308
308
|
"X-Origin-Agent": self.agent.name,
|
309
309
|
}
|
310
310
|
|
311
311
|
# Include Authorization if available (target agents commonly require it)
|
312
|
-
bearer = os.getenv('
|
312
|
+
bearer = os.getenv('WEBAGENTS_API_KEY') or os.getenv('SERVICE_TOKEN')
|
313
313
|
if bearer:
|
314
314
|
headers["Authorization"] = f"Bearer {bearer}"
|
315
315
|
headers["X-API-Key"] = bearer
|
@@ -363,7 +363,7 @@ CRITICAL: When you need to communicate with another agent:
|
|
363
363
|
name_from_path = target.get('name')
|
364
364
|
if name_from_path and HTTPX_AVAILABLE:
|
365
365
|
portal_base_url = os.getenv('ROBUTLER_INTERNAL_API_URL') or os.getenv('ROBUTLER_API_URL') or 'http://localhost:3000'
|
366
|
-
bearer_lookup = os.getenv('
|
366
|
+
bearer_lookup = os.getenv('WEBAGENTS_API_KEY') or os.getenv('SERVICE_TOKEN')
|
367
367
|
try:
|
368
368
|
async with httpx.AsyncClient(timeout=5.0) as client:
|
369
369
|
# 1) User/service /agents/:id-or-name (prefer service token if available)
|
@@ -1,9 +1,9 @@
|
|
1
1
|
"""
|
2
|
-
PaymentSkill Package -
|
2
|
+
PaymentSkill Package - WebAgents V2.0
|
3
3
|
|
4
|
-
Payment processing and billing skill for
|
4
|
+
Payment processing and billing skill for WebAgents platform.
|
5
5
|
Validates payment tokens, calculates costs using LiteLLM, and charges on connection finalization.
|
6
|
-
Based on
|
6
|
+
Based on webagents_v1 implementation patterns.
|
7
7
|
"""
|
8
8
|
|
9
9
|
from .skill import PaymentSkill, PaymentContext, PricingInfo, pricing
|
@@ -1,5 +1,5 @@
|
|
1
1
|
"""
|
2
|
-
Payment Exceptions -
|
2
|
+
Payment Exceptions - WebAgents V2.0 Platform Integration
|
3
3
|
|
4
4
|
Comprehensive payment error hierarchy for distinguishing between different 402 payment failure scenarios.
|
5
5
|
Provides specific error codes, subcodes, and context for better error handling and user experience.
|
@@ -1,9 +1,9 @@
|
|
1
1
|
"""
|
2
|
-
PaymentSkill -
|
2
|
+
PaymentSkill - WebAgents V2.0 Platform Integration
|
3
3
|
|
4
|
-
Payment processing and billing skill for
|
4
|
+
Payment processing and billing skill for WebAgents platform.
|
5
5
|
Validates payment tokens, calculates costs using LiteLLM, and charges on connection finalization.
|
6
|
-
Based on
|
6
|
+
Based on webagents_v1 implementation patterns.
|
7
7
|
"""
|
8
8
|
|
9
9
|
import os
|
@@ -17,8 +17,8 @@ from enum import Enum
|
|
17
17
|
|
18
18
|
from webagents.agents.skills.base import Skill
|
19
19
|
from webagents.agents.tools.decorators import tool, hook, prompt
|
20
|
-
from
|
21
|
-
from
|
20
|
+
from robutler.api import RobutlerClient
|
21
|
+
from robutler.api.types import ApiResponse
|
22
22
|
from .exceptions import (
|
23
23
|
PaymentError,
|
24
24
|
create_token_required_error,
|
@@ -95,7 +95,7 @@ def pricing(credits_per_call: Optional[float] = None,
|
|
95
95
|
"""
|
96
96
|
def decorator(func: Callable) -> Callable:
|
97
97
|
# Store pricing metadata on function for extraction by PaymentSkill
|
98
|
-
func.
|
98
|
+
func._webagents_pricing = {
|
99
99
|
'credits_per_call': credits_per_call,
|
100
100
|
'reason': reason or f"Tool '{func.__name__}' execution",
|
101
101
|
'on_success': on_success,
|
@@ -149,7 +149,7 @@ def pricing(credits_per_call: Optional[float] = None,
|
|
149
149
|
wrapper = sync_wrapper
|
150
150
|
|
151
151
|
# Copy pricing metadata to wrapper
|
152
|
-
wrapper.
|
152
|
+
wrapper._webagents_pricing = func._webagents_pricing
|
153
153
|
|
154
154
|
return wrapper
|
155
155
|
|
@@ -166,7 +166,7 @@ class PaymentContext:
|
|
166
166
|
|
167
167
|
class PaymentSkill(Skill):
|
168
168
|
"""
|
169
|
-
Payment processing and billing skill for
|
169
|
+
Payment processing and billing skill for WebAgents platform
|
170
170
|
|
171
171
|
Key Features:
|
172
172
|
- Payment token validation on connection
|
@@ -175,7 +175,7 @@ class PaymentSkill(Skill):
|
|
175
175
|
- Connection finalization charging
|
176
176
|
- Transaction creation via Portal API
|
177
177
|
|
178
|
-
Based on
|
178
|
+
Based on webagents_v1 implementation patterns.
|
179
179
|
"""
|
180
180
|
|
181
181
|
def __init__(self, config: Dict[str, Any] = None):
|
@@ -191,10 +191,10 @@ class PaymentSkill(Skill):
|
|
191
191
|
# Optional external amount calculator: (llm_cost_usd, tool_cost_usd, agent_pricing_percent_percent) -> amount_to_charge
|
192
192
|
self.amount_calculator: Optional[Callable[[float, float, float], float]] = self.config.get('amount_calculator')
|
193
193
|
|
194
|
-
#
|
194
|
+
# WebAgents integration
|
195
195
|
# Prefer internal portal URL for in-cluster calls, then public URL, then localhost for dev
|
196
|
-
self.
|
197
|
-
self.config.get('
|
196
|
+
self.webagents_api_url = (
|
197
|
+
self.config.get('webagents_api_url')
|
198
198
|
or os.getenv('ROBUTLER_INTERNAL_API_URL')
|
199
199
|
or os.getenv('ROBUTLER_API_URL')
|
200
200
|
or 'http://localhost:3000'
|
@@ -211,32 +211,32 @@ class PaymentSkill(Skill):
|
|
211
211
|
self.logger.warning("LiteLLM not available - cost calculations will use fallback methods")
|
212
212
|
|
213
213
|
async def initialize(self, agent) -> None:
|
214
|
-
"""Initialize PaymentSkill with
|
214
|
+
"""Initialize PaymentSkill with WebAgents Platform client"""
|
215
215
|
from webagents.utils.logging import get_logger, log_skill_event
|
216
216
|
|
217
217
|
self.agent = agent
|
218
|
-
self.logger = get_logger('skill.
|
218
|
+
self.logger = get_logger('skill.webagents.payments', agent.name)
|
219
219
|
|
220
220
|
# Log level is configured globally via setup_logging() - no need for manual configuration
|
221
221
|
|
222
|
-
# Resolve
|
222
|
+
# Resolve WebAgents API key: config -> agent's api_key -> environment -> default
|
223
223
|
if not self.robutler_api_key:
|
224
224
|
self.logger.error("No agent API key provided - cannot initialize platform client for payments")
|
225
225
|
raise ValueError("Agent API key is required for payment processing")
|
226
226
|
|
227
|
-
# Initialize
|
227
|
+
# Initialize WebAgents Platform client
|
228
228
|
try:
|
229
229
|
# Log init (no secrets)
|
230
230
|
self.logger.debug(
|
231
|
-
f"🔐 Initializing RobutlerClient | base_url={self.
|
231
|
+
f"🔐 Initializing RobutlerClient | base_url={self.webagents_api_url} using agent API key"
|
232
232
|
)
|
233
233
|
self.client = RobutlerClient(
|
234
234
|
api_key=self.robutler_api_key,
|
235
|
-
base_url=self.
|
235
|
+
base_url=self.webagents_api_url
|
236
236
|
)
|
237
237
|
|
238
238
|
except Exception as e:
|
239
|
-
self.logger.error(f"Failed to initialize
|
239
|
+
self.logger.error(f"Failed to initialize WebAgents Platform client: {e}")
|
240
240
|
# Continue without platform integration for testing
|
241
241
|
self.client = None
|
242
242
|
|
@@ -245,8 +245,8 @@ class PaymentSkill(Skill):
|
|
245
245
|
'agent_pricing_percent': self.agent_pricing_percent,
|
246
246
|
'minimum_balance': self.minimum_balance,
|
247
247
|
'min_balance_agent': self.min_balance_agent,
|
248
|
-
'
|
249
|
-
'
|
248
|
+
'webagents_api_url': self.webagents_api_url,
|
249
|
+
'has_webagents_client': bool(self.client),
|
250
250
|
'litellm_available': LITELLM_AVAILABLE
|
251
251
|
})
|
252
252
|
|
@@ -533,7 +533,7 @@ class PaymentSkill(Skill):
|
|
533
533
|
return headers.get(header_name) or headers.get(header_name.lower())
|
534
534
|
|
535
535
|
async def _validate_payment_token(self, token: str) -> bool:
|
536
|
-
"""Validate payment token with
|
536
|
+
"""Validate payment token with WebAgents Platform"""
|
537
537
|
try:
|
538
538
|
if not self.client:
|
539
539
|
self.logger.warning("Cannot validate payment token - no platform client")
|
@@ -555,7 +555,7 @@ class PaymentSkill(Skill):
|
|
555
555
|
)
|
556
556
|
|
557
557
|
async def _validate_payment_token_with_balance(self, token: str) -> Dict[str, Any]:
|
558
|
-
"""Validate payment token and check balance with
|
558
|
+
"""Validate payment token and check balance with WebAgents Platform"""
|
559
559
|
try:
|
560
560
|
if not self.client:
|
561
561
|
raise create_platform_unavailable_error("token balance check")
|