agent0-sdk 0.3rc1__py3-none-any.whl → 0.5__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.
- agent0_sdk/__init__.py +1 -1
- agent0_sdk/core/agent.py +303 -29
- agent0_sdk/core/contracts.py +93 -58
- agent0_sdk/core/feedback_manager.py +90 -161
- agent0_sdk/core/indexer.py +54 -26
- agent0_sdk/core/models.py +7 -19
- agent0_sdk/core/oasf_validator.py +98 -0
- agent0_sdk/core/sdk.py +31 -16
- agent0_sdk/core/subgraph_client.py +34 -15
- agent0_sdk/core/web3_client.py +184 -17
- agent0_sdk/taxonomies/all_domains.json +1565 -0
- agent0_sdk/taxonomies/all_skills.json +1030 -0
- {agent0_sdk-0.3rc1.dist-info → agent0_sdk-0.5.dist-info}/METADATA +78 -5
- agent0_sdk-0.5.dist-info/RECORD +19 -0
- {agent0_sdk-0.3rc1.dist-info → agent0_sdk-0.5.dist-info}/top_level.txt +0 -1
- agent0_sdk-0.3rc1.dist-info/RECORD +0 -29
- tests/__init__.py +0 -1
- tests/config.py +0 -46
- tests/conftest.py +0 -22
- tests/discover_test_data.py +0 -445
- tests/test_feedback.py +0 -417
- tests/test_models.py +0 -224
- tests/test_multi_chain.py +0 -588
- tests/test_real_public_servers.py +0 -103
- tests/test_registration.py +0 -267
- tests/test_registrationIpfs.py +0 -227
- tests/test_sdk.py +0 -240
- tests/test_search.py +0 -415
- tests/test_transfer.py +0 -255
- {agent0_sdk-0.3rc1.dist-info → agent0_sdk-0.5.dist-info}/WHEEL +0 -0
- {agent0_sdk-0.3rc1.dist-info → agent0_sdk-0.5.dist-info}/licenses/LICENSE +0 -0
tests/test_multi_chain.py
DELETED
|
@@ -1,588 +0,0 @@
|
|
|
1
|
-
"""
|
|
2
|
-
Test for Multi-Chain Agent Operations
|
|
3
|
-
Tests all multi-chain functionality using real subgraph queries.
|
|
4
|
-
|
|
5
|
-
Flow:
|
|
6
|
-
1. Test getAgent() with chainId:agentId format across all chains
|
|
7
|
-
2. Test searchFeedback() with chainId:agentId format across all chains
|
|
8
|
-
3. Test searchAgentsByReputation() with chains parameter (single, multiple, "all")
|
|
9
|
-
4. Test getReputationSummary() with chainId:agentId format across all chains
|
|
10
|
-
5. Test various chain combinations
|
|
11
|
-
"""
|
|
12
|
-
|
|
13
|
-
import logging
|
|
14
|
-
import sys
|
|
15
|
-
|
|
16
|
-
# Configure logging: root logger at WARNING to suppress noisy dependencies
|
|
17
|
-
logging.basicConfig(
|
|
18
|
-
level=logging.WARNING,
|
|
19
|
-
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
|
|
20
|
-
datefmt='%Y-%m-%d %H:%M:%S',
|
|
21
|
-
handlers=[logging.StreamHandler(sys.stdout)]
|
|
22
|
-
)
|
|
23
|
-
|
|
24
|
-
# Set debug level ONLY for agent0_sdk
|
|
25
|
-
logging.getLogger('agent0_sdk').setLevel(logging.DEBUG)
|
|
26
|
-
logging.getLogger('agent0_sdk.core').setLevel(logging.DEBUG)
|
|
27
|
-
|
|
28
|
-
from agent0_sdk import SDK, SearchParams
|
|
29
|
-
from config import CHAIN_ID, RPC_URL, print_config
|
|
30
|
-
|
|
31
|
-
# Supported chains for multi-chain testing
|
|
32
|
-
SUPPORTED_CHAINS = [11155111, 84532, 80002] # ETH Sepolia, Base Sepolia, Polygon Amoy
|
|
33
|
-
|
|
34
|
-
# Known test agents with feedback (from discovery script)
|
|
35
|
-
TEST_AGENTS_WITH_FEEDBACK = {
|
|
36
|
-
11155111: ["11155111:1377", "11155111:1340"], # Both have feedback
|
|
37
|
-
84532: ["84532:557", "84532:545", "84532:543", "84532:541", "84532:540", "84532:539", "84532:538", "84532:536"], # All have feedback and averageScore=5.0
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
# Known agents with reputation (averageScore) for reputation search tests
|
|
41
|
-
TEST_AGENTS_WITH_REPUTATION = {
|
|
42
|
-
11155111: [], # No agents with calculated averageScore on this chain
|
|
43
|
-
84532: ["84532:557", "84532:545", "84532:543", "84532:541", "84532:540", "84532:539", "84532:538", "84532:536"], # All have averageScore=5.0
|
|
44
|
-
80002: [], # No agents with reputation on this chain
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
# Known tags that exist in feedback data
|
|
48
|
-
TEST_TAGS = ["price", "analysis"]
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
def main():
|
|
52
|
-
print("🌐 Testing Multi-Chain Agent Operations")
|
|
53
|
-
print_config()
|
|
54
|
-
print("=" * 60)
|
|
55
|
-
|
|
56
|
-
# Initialize SDK without signer (read-only operations)
|
|
57
|
-
# Using default chain (ETH Sepolia)
|
|
58
|
-
sdk = SDK(
|
|
59
|
-
chainId=CHAIN_ID,
|
|
60
|
-
rpcUrl=RPC_URL
|
|
61
|
-
)
|
|
62
|
-
|
|
63
|
-
print(f"\n📍 Step 1: Test getAgent() with chainId:agentId format")
|
|
64
|
-
print("-" * 60)
|
|
65
|
-
print("Testing getAgent() across all supported chains...")
|
|
66
|
-
|
|
67
|
-
for chain_id in SUPPORTED_CHAINS:
|
|
68
|
-
try:
|
|
69
|
-
# First, search for agents on this chain to get a real agent ID
|
|
70
|
-
params = SearchParams()
|
|
71
|
-
params.chains = [chain_id]
|
|
72
|
-
search_result = sdk.indexer.search_agents(params, sort=[], page_size=1)
|
|
73
|
-
|
|
74
|
-
if search_result.get('items') and len(search_result['items']) > 0:
|
|
75
|
-
agent_summary = search_result['items'][0]
|
|
76
|
-
# Handle both dict and AgentSummary object
|
|
77
|
-
agent_id = agent_summary.get('agentId') if isinstance(agent_summary, dict) else agent_summary.agentId
|
|
78
|
-
|
|
79
|
-
# Format as chainId:agentId
|
|
80
|
-
if ':' in agent_id:
|
|
81
|
-
token_id = agent_id.split(':')[-1]
|
|
82
|
-
else:
|
|
83
|
-
token_id = agent_id
|
|
84
|
-
full_agent_id = f"{chain_id}:{token_id}"
|
|
85
|
-
|
|
86
|
-
# Test getAgent with chainId:agentId format
|
|
87
|
-
agent = sdk.indexer.get_agent(full_agent_id)
|
|
88
|
-
|
|
89
|
-
print(f"✅ Chain {chain_id}: Found agent {agent.name}")
|
|
90
|
-
print(f" Agent ID: {agent.agentId}")
|
|
91
|
-
print(f" Chain ID: {agent.chainId} (verified)")
|
|
92
|
-
print(f" Active: {agent.active}")
|
|
93
|
-
else:
|
|
94
|
-
print(f"⚠️ Chain {chain_id}: No agents found")
|
|
95
|
-
except Exception as e:
|
|
96
|
-
print(f"❌ Chain {chain_id}: Failed - {e}")
|
|
97
|
-
|
|
98
|
-
print(f"\n📍 Step 2: Test getAgent() with default chain (no chainId prefix)")
|
|
99
|
-
print("-" * 60)
|
|
100
|
-
try:
|
|
101
|
-
# Test with just agentId (uses SDK's default chain)
|
|
102
|
-
params = SearchParams()
|
|
103
|
-
params.chains = [CHAIN_ID]
|
|
104
|
-
search_result = sdk.indexer.search_agents(params, sort=[], page_size=1)
|
|
105
|
-
|
|
106
|
-
if search_result.get('items') and len(search_result['items']) > 0:
|
|
107
|
-
agent_item = search_result['items'][0]
|
|
108
|
-
# Handle both dict and AgentSummary object
|
|
109
|
-
agent_id = agent_item.get('agentId') if isinstance(agent_item, dict) else agent_item.agentId
|
|
110
|
-
# Remove chainId prefix if present
|
|
111
|
-
if ':' in agent_id:
|
|
112
|
-
token_id = agent_id.split(':')[-1]
|
|
113
|
-
else:
|
|
114
|
-
token_id = agent_id
|
|
115
|
-
|
|
116
|
-
agent = sdk.indexer.get_agent(token_id)
|
|
117
|
-
print(f"✅ Default chain: Found agent {agent.name}")
|
|
118
|
-
print(f" Agent ID: {agent.agentId}")
|
|
119
|
-
print(f" Chain ID: {agent.chainId} (should match SDK default: {CHAIN_ID})")
|
|
120
|
-
else:
|
|
121
|
-
print("⚠️ No agents found on default chain")
|
|
122
|
-
except Exception as e:
|
|
123
|
-
print(f"❌ Default chain: Failed - {e}")
|
|
124
|
-
|
|
125
|
-
print(f"\n📍 Step 3: Test searchFeedback() with chainId:agentId format")
|
|
126
|
-
print("-" * 60)
|
|
127
|
-
print("Testing searchFeedback() across all supported chains...")
|
|
128
|
-
|
|
129
|
-
for chain_id in SUPPORTED_CHAINS:
|
|
130
|
-
try:
|
|
131
|
-
# Use known agents with feedback if available, otherwise search for any agent
|
|
132
|
-
test_agent_id = None
|
|
133
|
-
if chain_id in TEST_AGENTS_WITH_FEEDBACK and TEST_AGENTS_WITH_FEEDBACK[chain_id]:
|
|
134
|
-
test_agent_id = TEST_AGENTS_WITH_FEEDBACK[chain_id][0]
|
|
135
|
-
else:
|
|
136
|
-
# Fallback: search for any agent
|
|
137
|
-
params = SearchParams()
|
|
138
|
-
params.chains = [chain_id]
|
|
139
|
-
search_result = sdk.indexer.search_agents(params, sort=[], page_size=1)
|
|
140
|
-
|
|
141
|
-
if search_result.get('items') and len(search_result['items']) > 0:
|
|
142
|
-
agent_summary = search_result['items'][0]
|
|
143
|
-
# Handle both dict and AgentSummary object
|
|
144
|
-
agent_id = agent_summary.get('agentId') if isinstance(agent_summary, dict) else agent_summary.agentId
|
|
145
|
-
|
|
146
|
-
# Format as chainId:agentId
|
|
147
|
-
if ':' in agent_id:
|
|
148
|
-
token_id = agent_id.split(':')[-1]
|
|
149
|
-
else:
|
|
150
|
-
token_id = agent_id
|
|
151
|
-
test_agent_id = f"{chain_id}:{token_id}"
|
|
152
|
-
|
|
153
|
-
if test_agent_id:
|
|
154
|
-
# Test searchFeedback with chainId:agentId format
|
|
155
|
-
feedbacks = sdk.indexer.search_feedback(
|
|
156
|
-
agentId=test_agent_id,
|
|
157
|
-
first=10,
|
|
158
|
-
skip=0
|
|
159
|
-
)
|
|
160
|
-
|
|
161
|
-
print(f"✅ Chain {chain_id}: Found {len(feedbacks)} feedback entries")
|
|
162
|
-
print(f" Agent ID: {test_agent_id}")
|
|
163
|
-
if feedbacks:
|
|
164
|
-
print(f" First feedback score: {feedbacks[0].score if feedbacks[0].score else 'N/A'}")
|
|
165
|
-
if feedbacks[0].tags:
|
|
166
|
-
print(f" First feedback tags: {feedbacks[0].tags}")
|
|
167
|
-
else:
|
|
168
|
-
print(f" ⚠️ No feedback found for this agent")
|
|
169
|
-
else:
|
|
170
|
-
print(f"⚠️ Chain {chain_id}: No agents found")
|
|
171
|
-
except Exception as e:
|
|
172
|
-
print(f"❌ Chain {chain_id}: Failed - {e}")
|
|
173
|
-
|
|
174
|
-
print(f"\n📍 Step 4: Test searchFeedback() with default chain (no chainId prefix)")
|
|
175
|
-
print("-" * 60)
|
|
176
|
-
try:
|
|
177
|
-
# Use known agent with feedback if available
|
|
178
|
-
test_agent_id = None
|
|
179
|
-
if CHAIN_ID in TEST_AGENTS_WITH_FEEDBACK and TEST_AGENTS_WITH_FEEDBACK[CHAIN_ID]:
|
|
180
|
-
full_id = TEST_AGENTS_WITH_FEEDBACK[CHAIN_ID][0]
|
|
181
|
-
# Extract token ID for default chain test
|
|
182
|
-
test_agent_id = full_id.split(':')[-1] if ':' in full_id else full_id
|
|
183
|
-
else:
|
|
184
|
-
# Fallback: search for any agent
|
|
185
|
-
params = SearchParams()
|
|
186
|
-
params.chains = [CHAIN_ID]
|
|
187
|
-
search_result = sdk.indexer.search_agents(params, sort=[], page_size=1)
|
|
188
|
-
|
|
189
|
-
if search_result.get('items') and len(search_result['items']) > 0:
|
|
190
|
-
agent_item = search_result['items'][0]
|
|
191
|
-
# Handle both dict and AgentSummary object
|
|
192
|
-
agent_id = agent_item.get('agentId') if isinstance(agent_item, dict) else agent_item.agentId
|
|
193
|
-
# Remove chainId prefix if present
|
|
194
|
-
if ':' in agent_id:
|
|
195
|
-
test_agent_id = agent_id.split(':')[-1]
|
|
196
|
-
else:
|
|
197
|
-
test_agent_id = agent_id
|
|
198
|
-
|
|
199
|
-
if test_agent_id:
|
|
200
|
-
feedbacks = sdk.indexer.search_feedback(
|
|
201
|
-
agentId=test_agent_id,
|
|
202
|
-
first=10,
|
|
203
|
-
skip=0
|
|
204
|
-
)
|
|
205
|
-
|
|
206
|
-
print(f"✅ Default chain: Found {len(feedbacks)} feedback entries")
|
|
207
|
-
print(f" Agent ID: {test_agent_id}")
|
|
208
|
-
if feedbacks:
|
|
209
|
-
print(f" First feedback score: {feedbacks[0].score if feedbacks[0].score else 'N/A'}")
|
|
210
|
-
else:
|
|
211
|
-
print("⚠️ No agents found on default chain")
|
|
212
|
-
except Exception as e:
|
|
213
|
-
print(f"❌ Default chain: Failed - {e}")
|
|
214
|
-
|
|
215
|
-
print(f"\n📍 Step 5: Test searchAgentsByReputation() with single chains")
|
|
216
|
-
print("-" * 60)
|
|
217
|
-
print("Testing searchAgentsByReputation() with individual chains...")
|
|
218
|
-
|
|
219
|
-
for chain_id in SUPPORTED_CHAINS:
|
|
220
|
-
try:
|
|
221
|
-
# Use known agents with reputation for this chain
|
|
222
|
-
known_agents = TEST_AGENTS_WITH_REPUTATION.get(chain_id, [])
|
|
223
|
-
|
|
224
|
-
if known_agents:
|
|
225
|
-
# First, verify agents exist using getAgent
|
|
226
|
-
found_agents = []
|
|
227
|
-
for agent_id in known_agents[:5]:
|
|
228
|
-
try:
|
|
229
|
-
agent = sdk.indexer.get_agent(agent_id)
|
|
230
|
-
found_agents.append(agent)
|
|
231
|
-
except Exception:
|
|
232
|
-
continue
|
|
233
|
-
|
|
234
|
-
if found_agents:
|
|
235
|
-
# Now try reputation search - use general search to find agents with reputation
|
|
236
|
-
result = sdk.searchAgentsByReputation(
|
|
237
|
-
page_size=10,
|
|
238
|
-
chains=[chain_id]
|
|
239
|
-
)
|
|
240
|
-
agents = result.get('items', [])
|
|
241
|
-
|
|
242
|
-
if agents:
|
|
243
|
-
print(f"✅ Chain {chain_id}: Found {len(agents)} agents by reputation")
|
|
244
|
-
print(f" Verified {len(found_agents)} known agents exist via getAgent")
|
|
245
|
-
|
|
246
|
-
# Verify all results are from the requested chain
|
|
247
|
-
all_correct_chain = all(agent.chainId == chain_id for agent in agents)
|
|
248
|
-
if all_correct_chain:
|
|
249
|
-
print(f" ✓ All agents verified from chain {chain_id}")
|
|
250
|
-
|
|
251
|
-
# Show first agent details
|
|
252
|
-
first_agent = agents[0]
|
|
253
|
-
avg_score = first_agent.extras.get('averageScore', 'N/A') if first_agent.extras else 'N/A'
|
|
254
|
-
print(f" First agent: {first_agent.name} (Avg Score: {avg_score})")
|
|
255
|
-
else:
|
|
256
|
-
print(f"⚠️ Chain {chain_id}: Reputation search found 0 agents")
|
|
257
|
-
print(f" Known agents exist: {[a.agentId for a in found_agents[:3]]}")
|
|
258
|
-
else:
|
|
259
|
-
print(f"⚠️ Chain {chain_id}: Could not find any known agents via getAgent")
|
|
260
|
-
else:
|
|
261
|
-
# For chains without reputation data, try general search
|
|
262
|
-
result = sdk.searchAgentsByReputation(
|
|
263
|
-
page_size=10,
|
|
264
|
-
chains=[chain_id]
|
|
265
|
-
)
|
|
266
|
-
agents = result.get('items', [])
|
|
267
|
-
if agents:
|
|
268
|
-
print(f"✅ Chain {chain_id}: Found {len(agents)} agents by reputation")
|
|
269
|
-
else:
|
|
270
|
-
print(f"✅ Chain {chain_id}: Found 0 agents (expected: 0 - no reputation data)")
|
|
271
|
-
except Exception as e:
|
|
272
|
-
print(f"❌ Chain {chain_id}: Failed - {e}")
|
|
273
|
-
|
|
274
|
-
print(f"\n📍 Step 6: Test searchAgentsByReputation() with multiple chains")
|
|
275
|
-
print("-" * 60)
|
|
276
|
-
print("Testing with chain combinations...")
|
|
277
|
-
|
|
278
|
-
# Test with 2 chains
|
|
279
|
-
chain_pairs = [
|
|
280
|
-
[11155111, 84532],
|
|
281
|
-
[11155111, 80002],
|
|
282
|
-
[84532, 80002],
|
|
283
|
-
]
|
|
284
|
-
|
|
285
|
-
for chains in chain_pairs:
|
|
286
|
-
try:
|
|
287
|
-
# Collect known agents with reputation from all chains in this pair
|
|
288
|
-
known_agents = []
|
|
289
|
-
for cid in chains:
|
|
290
|
-
known_agents.extend(TEST_AGENTS_WITH_REPUTATION.get(cid, []))
|
|
291
|
-
|
|
292
|
-
# Try reputation search
|
|
293
|
-
result = sdk.searchAgentsByReputation(
|
|
294
|
-
page_size=20,
|
|
295
|
-
chains=chains
|
|
296
|
-
)
|
|
297
|
-
|
|
298
|
-
agents = result.get('items', [])
|
|
299
|
-
meta = result.get('meta', {})
|
|
300
|
-
successful_chains = meta.get('successfulChains', [])
|
|
301
|
-
failed_chains = meta.get('failedChains', [])
|
|
302
|
-
|
|
303
|
-
chain_ids = set(agent.chainId for agent in agents)
|
|
304
|
-
if agents:
|
|
305
|
-
print(f"✅ Chains {chains}: Found {len(agents)} agents by reputation search")
|
|
306
|
-
else:
|
|
307
|
-
print(f"⚠️ Chains {chains}: Reputation search found 0 agents")
|
|
308
|
-
if known_agents:
|
|
309
|
-
print(f" Known agents: {known_agents[:5]}")
|
|
310
|
-
else:
|
|
311
|
-
print(f" ✅ Chains {chains}: Found 0 agents (expected: 0 - no reputation data)")
|
|
312
|
-
|
|
313
|
-
print(f" Successful chains: {successful_chains}")
|
|
314
|
-
if failed_chains:
|
|
315
|
-
print(f" Failed chains: {failed_chains}")
|
|
316
|
-
print(f" Unique chains in results: {list(chain_ids)}")
|
|
317
|
-
|
|
318
|
-
# Show sample agents
|
|
319
|
-
if agents:
|
|
320
|
-
print(f" Sample agents:")
|
|
321
|
-
for i, agent in enumerate(agents[:3], 1):
|
|
322
|
-
avg_score = agent.extras.get('averageScore', 'N/A') if agent.extras else 'N/A'
|
|
323
|
-
print(f" {i}. {agent.name} (Chain: {agent.chainId}, Avg: {avg_score})")
|
|
324
|
-
except Exception as e:
|
|
325
|
-
print(f"❌ Chains {chains}: Failed - {e}")
|
|
326
|
-
|
|
327
|
-
print(f"\n📍 Step 7: Test searchAgentsByReputation() with chains='all'")
|
|
328
|
-
print("-" * 60)
|
|
329
|
-
try:
|
|
330
|
-
# Collect all known agents with reputation
|
|
331
|
-
all_known_agents = []
|
|
332
|
-
for chain_id in SUPPORTED_CHAINS:
|
|
333
|
-
all_known_agents.extend(TEST_AGENTS_WITH_REPUTATION.get(chain_id, []))
|
|
334
|
-
|
|
335
|
-
if all_known_agents:
|
|
336
|
-
# Query for specific agents we know have reputation
|
|
337
|
-
result = sdk.searchAgentsByReputation(
|
|
338
|
-
agents=all_known_agents, # Query for all known agents
|
|
339
|
-
page_size=20,
|
|
340
|
-
chains="all"
|
|
341
|
-
)
|
|
342
|
-
else:
|
|
343
|
-
# General search if no known agents
|
|
344
|
-
result = sdk.searchAgentsByReputation(
|
|
345
|
-
page_size=20,
|
|
346
|
-
chains="all"
|
|
347
|
-
)
|
|
348
|
-
|
|
349
|
-
agents = result.get('items', [])
|
|
350
|
-
meta = result.get('meta', {})
|
|
351
|
-
successful_chains = meta.get('successfulChains', [])
|
|
352
|
-
failed_chains = meta.get('failedChains', [])
|
|
353
|
-
|
|
354
|
-
chain_ids = set(agent.chainId for agent in agents)
|
|
355
|
-
if agents:
|
|
356
|
-
print(f"✅ Found {len(agents)} agents across all chains")
|
|
357
|
-
else:
|
|
358
|
-
# If search returned 0, verify agents exist and show reputation
|
|
359
|
-
if all_known_agents:
|
|
360
|
-
print(f"⚠️ Reputation search found 0 agents")
|
|
361
|
-
print(f" Verifying {len(all_known_agents)} known agents exist...")
|
|
362
|
-
reputation_found = 0
|
|
363
|
-
for agent_id in all_known_agents[:5]:
|
|
364
|
-
try:
|
|
365
|
-
agent = sdk.indexer.get_agent(agent_id)
|
|
366
|
-
summary = sdk.getReputationSummary(agent_id)
|
|
367
|
-
if summary.get('count', 0) > 0:
|
|
368
|
-
reputation_found += 1
|
|
369
|
-
if reputation_found <= 3: # Show first 3
|
|
370
|
-
print(f" ✅ {agent_id}: {summary['count']} feedback, avg: {summary['averageScore']:.2f}")
|
|
371
|
-
except Exception:
|
|
372
|
-
continue
|
|
373
|
-
if reputation_found > 0:
|
|
374
|
-
print(f" ✓ Found reputation data for {reputation_found} agents via getReputationSummary")
|
|
375
|
-
else:
|
|
376
|
-
print(f"✅ Found 0 agents (expected: 0 - no reputation data)")
|
|
377
|
-
print(f" Successful chains: {successful_chains}")
|
|
378
|
-
if failed_chains:
|
|
379
|
-
print(f" Failed chains: {failed_chains}")
|
|
380
|
-
print(f" Unique chains in results: {list(chain_ids)}")
|
|
381
|
-
|
|
382
|
-
# Show sample agents from different chains
|
|
383
|
-
if agents:
|
|
384
|
-
print(f" Sample agents:")
|
|
385
|
-
for i, agent in enumerate(agents[:5], 1):
|
|
386
|
-
avg_score = agent.extras.get('averageScore', 'N/A') if agent.extras else 'N/A'
|
|
387
|
-
print(f" {i}. {agent.name} (Chain: {agent.chainId}, Avg: {avg_score})")
|
|
388
|
-
except Exception as e:
|
|
389
|
-
print(f"❌ All chains: Failed - {e}")
|
|
390
|
-
|
|
391
|
-
print(f"\n📍 Step 8: Test searchAgentsByReputation() with filters and multi-chain")
|
|
392
|
-
print("-" * 60)
|
|
393
|
-
try:
|
|
394
|
-
# Use known tags that exist in feedback data
|
|
395
|
-
# Test with chains that have reputation data (84532 has agents with averageScore)
|
|
396
|
-
result = sdk.searchAgentsByReputation(
|
|
397
|
-
tags=TEST_TAGS[:1], # Use "price" tag which exists in feedback
|
|
398
|
-
minAverageScore=0, # No threshold to see any results
|
|
399
|
-
page_size=20,
|
|
400
|
-
chains=[84532] # Use chain with reputation data
|
|
401
|
-
)
|
|
402
|
-
|
|
403
|
-
agents = result.get('items', [])
|
|
404
|
-
print(f"✅ Found {len(agents)} agents with filters")
|
|
405
|
-
print(f" Filter: tags={TEST_TAGS[:1]}, chains=[84532]")
|
|
406
|
-
if agents:
|
|
407
|
-
for i, agent in enumerate(agents[:3], 1):
|
|
408
|
-
avg_score = agent.extras.get('averageScore', 'N/A') if agent.extras else 'N/A'
|
|
409
|
-
print(f" {i}. {agent.name} (Chain: {agent.chainId}, Avg: {avg_score})")
|
|
410
|
-
else:
|
|
411
|
-
print(f" ⚠️ No agents found with tag '{TEST_TAGS[0]}' (may need to check if tag filtering works)")
|
|
412
|
-
except Exception as e:
|
|
413
|
-
print(f"❌ Filtered multi-chain search: Failed - {e}")
|
|
414
|
-
|
|
415
|
-
print(f"\n📍 Step 9: Test getReputationSummary() with chainId:agentId format")
|
|
416
|
-
print("-" * 60)
|
|
417
|
-
print("Testing getReputationSummary() across all supported chains...")
|
|
418
|
-
|
|
419
|
-
for chain_id in SUPPORTED_CHAINS:
|
|
420
|
-
try:
|
|
421
|
-
# Use known agents with feedback if available
|
|
422
|
-
test_agent_id = None
|
|
423
|
-
if chain_id in TEST_AGENTS_WITH_FEEDBACK and TEST_AGENTS_WITH_FEEDBACK[chain_id]:
|
|
424
|
-
test_agent_id = TEST_AGENTS_WITH_FEEDBACK[chain_id][0]
|
|
425
|
-
else:
|
|
426
|
-
# Fallback: search for agents and try each one
|
|
427
|
-
params = SearchParams()
|
|
428
|
-
params.chains = [chain_id]
|
|
429
|
-
search_result = sdk.indexer.search_agents(params, sort=[], page_size=10)
|
|
430
|
-
|
|
431
|
-
if search_result.get('items') and len(search_result['items']) > 0:
|
|
432
|
-
# Try to get reputation for each agent until we find one with feedback
|
|
433
|
-
for agent_summary in search_result['items']:
|
|
434
|
-
# Handle both dict and AgentSummary object
|
|
435
|
-
agent_id = agent_summary.get('agentId') if isinstance(agent_summary, dict) else agent_summary.agentId
|
|
436
|
-
if ':' in agent_id:
|
|
437
|
-
token_id = agent_id.split(':')[-1]
|
|
438
|
-
else:
|
|
439
|
-
token_id = agent_id
|
|
440
|
-
test_agent_id = f"{chain_id}:{token_id}"
|
|
441
|
-
|
|
442
|
-
try:
|
|
443
|
-
summary = sdk.getReputationSummary(test_agent_id)
|
|
444
|
-
# If we get here, we found one with feedback
|
|
445
|
-
break
|
|
446
|
-
except Exception:
|
|
447
|
-
test_agent_id = None
|
|
448
|
-
continue
|
|
449
|
-
|
|
450
|
-
if test_agent_id:
|
|
451
|
-
try:
|
|
452
|
-
summary = sdk.getReputationSummary(test_agent_id)
|
|
453
|
-
|
|
454
|
-
print(f"✅ Chain {chain_id}: Got reputation summary")
|
|
455
|
-
print(f" Agent ID: {test_agent_id}")
|
|
456
|
-
print(f" Count: {summary['count']}")
|
|
457
|
-
print(f" Average Score: {summary['averageScore']:.2f}")
|
|
458
|
-
except Exception as e:
|
|
459
|
-
print(f"⚠️ Chain {chain_id}: Failed to get reputation for {test_agent_id}: {e}")
|
|
460
|
-
else:
|
|
461
|
-
print(f"⚠️ Chain {chain_id}: No agents with feedback found")
|
|
462
|
-
except Exception as e:
|
|
463
|
-
print(f"❌ Chain {chain_id}: Failed - {e}")
|
|
464
|
-
|
|
465
|
-
print(f"\n📍 Step 10: Test getReputationSummary() with default chain (no chainId prefix)")
|
|
466
|
-
print("-" * 60)
|
|
467
|
-
try:
|
|
468
|
-
# Use known agent with feedback if available
|
|
469
|
-
test_agent_id = None
|
|
470
|
-
if CHAIN_ID in TEST_AGENTS_WITH_FEEDBACK and TEST_AGENTS_WITH_FEEDBACK[CHAIN_ID]:
|
|
471
|
-
full_id = TEST_AGENTS_WITH_FEEDBACK[CHAIN_ID][0]
|
|
472
|
-
# Extract token ID for default chain test
|
|
473
|
-
test_agent_id = full_id.split(':')[-1] if ':' in full_id else full_id
|
|
474
|
-
else:
|
|
475
|
-
# Fallback: search for agents and try each one
|
|
476
|
-
params = SearchParams()
|
|
477
|
-
params.chains = [CHAIN_ID]
|
|
478
|
-
search_result = sdk.indexer.search_agents(params, sort=[], page_size=10)
|
|
479
|
-
|
|
480
|
-
if search_result.get('items') and len(search_result['items']) > 0:
|
|
481
|
-
# Try to get reputation for each agent until we find one with feedback
|
|
482
|
-
for agent_summary in search_result['items']:
|
|
483
|
-
# Handle both dict and AgentSummary object
|
|
484
|
-
agent_id = agent_summary.get('agentId') if isinstance(agent_summary, dict) else agent_summary.agentId
|
|
485
|
-
if ':' in agent_id:
|
|
486
|
-
test_agent_id = agent_id.split(':')[-1]
|
|
487
|
-
else:
|
|
488
|
-
test_agent_id = agent_id
|
|
489
|
-
|
|
490
|
-
try:
|
|
491
|
-
summary = sdk.getReputationSummary(test_agent_id)
|
|
492
|
-
# If we get here, we found one with feedback
|
|
493
|
-
break
|
|
494
|
-
except Exception:
|
|
495
|
-
test_agent_id = None
|
|
496
|
-
continue
|
|
497
|
-
|
|
498
|
-
if test_agent_id:
|
|
499
|
-
try:
|
|
500
|
-
summary = sdk.getReputationSummary(test_agent_id)
|
|
501
|
-
|
|
502
|
-
print(f"✅ Default chain: Got reputation summary")
|
|
503
|
-
print(f" Agent ID: {test_agent_id}")
|
|
504
|
-
print(f" Count: {summary['count']}")
|
|
505
|
-
print(f" Average Score: {summary['averageScore']:.2f}")
|
|
506
|
-
except Exception as e:
|
|
507
|
-
print(f"⚠️ Default chain: Failed to get reputation for {test_agent_id}: {e}")
|
|
508
|
-
else:
|
|
509
|
-
print("⚠️ No agents with feedback found on default chain")
|
|
510
|
-
except Exception as e:
|
|
511
|
-
print(f"❌ Default chain: Failed - {e}")
|
|
512
|
-
|
|
513
|
-
print(f"\n📍 Step 11: Test all three chains together")
|
|
514
|
-
print("-" * 60)
|
|
515
|
-
try:
|
|
516
|
-
# Collect all known agents with reputation
|
|
517
|
-
all_known_agents = []
|
|
518
|
-
for chain_id in SUPPORTED_CHAINS:
|
|
519
|
-
all_known_agents.extend(TEST_AGENTS_WITH_REPUTATION.get(chain_id, []))
|
|
520
|
-
|
|
521
|
-
if all_known_agents:
|
|
522
|
-
# Query for specific agents we know have reputation
|
|
523
|
-
result = sdk.searchAgentsByReputation(
|
|
524
|
-
agents=all_known_agents, # Query for all known agents
|
|
525
|
-
page_size=20,
|
|
526
|
-
chains=SUPPORTED_CHAINS
|
|
527
|
-
)
|
|
528
|
-
else:
|
|
529
|
-
# General search if no known agents
|
|
530
|
-
result = sdk.searchAgentsByReputation(
|
|
531
|
-
page_size=20,
|
|
532
|
-
chains=SUPPORTED_CHAINS
|
|
533
|
-
)
|
|
534
|
-
|
|
535
|
-
agents = result.get('items', [])
|
|
536
|
-
chain_ids = set(agent.chainId for agent in agents)
|
|
537
|
-
|
|
538
|
-
if agents:
|
|
539
|
-
print(f"✅ All three chains: Found {len(agents)} agents")
|
|
540
|
-
else:
|
|
541
|
-
# If search returned 0, verify agents exist and show reputation
|
|
542
|
-
if all_known_agents:
|
|
543
|
-
print(f"⚠️ Reputation search found 0 agents")
|
|
544
|
-
print(f" Verifying {len(all_known_agents)} known agents exist...")
|
|
545
|
-
reputation_found = 0
|
|
546
|
-
for agent_id in all_known_agents[:5]:
|
|
547
|
-
try:
|
|
548
|
-
agent = sdk.indexer.get_agent(agent_id)
|
|
549
|
-
summary = sdk.getReputationSummary(agent_id)
|
|
550
|
-
if summary.get('count', 0) > 0:
|
|
551
|
-
reputation_found += 1
|
|
552
|
-
if reputation_found <= 3: # Show first 3
|
|
553
|
-
print(f" ✅ {agent_id}: {summary['count']} feedback, avg: {summary['averageScore']:.2f}")
|
|
554
|
-
except Exception:
|
|
555
|
-
continue
|
|
556
|
-
if reputation_found > 0:
|
|
557
|
-
print(f" ✓ Found reputation data for {reputation_found} agents via getReputationSummary")
|
|
558
|
-
else:
|
|
559
|
-
print(f"✅ All three chains: Found 0 agents (expected: 0 - no reputation data)")
|
|
560
|
-
print(f" Unique chains in results: {list(chain_ids)}")
|
|
561
|
-
|
|
562
|
-
# Group by chain
|
|
563
|
-
by_chain = {}
|
|
564
|
-
for agent in agents:
|
|
565
|
-
chain = agent.chainId
|
|
566
|
-
if chain not in by_chain:
|
|
567
|
-
by_chain[chain] = []
|
|
568
|
-
by_chain[chain].append(agent)
|
|
569
|
-
|
|
570
|
-
for chain, chain_agents in by_chain.items():
|
|
571
|
-
print(f" Chain {chain}: {len(chain_agents)} agents")
|
|
572
|
-
|
|
573
|
-
# Show sample agents
|
|
574
|
-
if agents:
|
|
575
|
-
print(f" Sample agents:")
|
|
576
|
-
for i, agent in enumerate(agents[:5], 1):
|
|
577
|
-
avg_score = agent.extras.get('averageScore', 'N/A') if agent.extras else 'N/A'
|
|
578
|
-
print(f" {i}. {agent.name} (Chain: {agent.chainId}, Avg: {avg_score})")
|
|
579
|
-
except Exception as e:
|
|
580
|
-
print(f"❌ All three chains: Failed - {e}")
|
|
581
|
-
|
|
582
|
-
print("\n" + "=" * 60)
|
|
583
|
-
print("✅ Multi-Chain Tests Completed!")
|
|
584
|
-
print("=" * 60)
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
if __name__ == "__main__":
|
|
588
|
-
main()
|
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
"""
|
|
2
|
-
Test Endpoint Crawler with Real Public MCP and A2A Servers
|
|
3
|
-
Tests against actual public servers provided by the user.
|
|
4
|
-
"""
|
|
5
|
-
|
|
6
|
-
import logging
|
|
7
|
-
import sys
|
|
8
|
-
import os
|
|
9
|
-
|
|
10
|
-
# Configure logging: root logger at WARNING to suppress noisy dependencies
|
|
11
|
-
logging.basicConfig(
|
|
12
|
-
level=logging.WARNING,
|
|
13
|
-
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
|
|
14
|
-
datefmt='%Y-%m-%d %H:%M:%S',
|
|
15
|
-
handlers=[logging.StreamHandler(sys.stdout)]
|
|
16
|
-
)
|
|
17
|
-
|
|
18
|
-
# Set debug level ONLY for agent0_sdk
|
|
19
|
-
logging.getLogger('agent0_sdk').setLevel(logging.DEBUG)
|
|
20
|
-
logging.getLogger('agent0_sdk.core').setLevel(logging.DEBUG)
|
|
21
|
-
|
|
22
|
-
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..', 'src'))
|
|
23
|
-
|
|
24
|
-
from agent0_sdk.core.endpoint_crawler import EndpointCrawler
|
|
25
|
-
import json
|
|
26
|
-
|
|
27
|
-
def main():
|
|
28
|
-
print("🧪 Testing Endpoint Crawler with Real Public Servers")
|
|
29
|
-
print("=" * 70)
|
|
30
|
-
|
|
31
|
-
crawler = EndpointCrawler(timeout=10) # Longer timeout for real servers
|
|
32
|
-
|
|
33
|
-
# Real public endpoints
|
|
34
|
-
test_cases = [
|
|
35
|
-
{
|
|
36
|
-
"type": "A2A",
|
|
37
|
-
"endpoint": "https://hello-world-gxfr.onrender.com",
|
|
38
|
-
"description": "Real A2A Hello World Server"
|
|
39
|
-
},
|
|
40
|
-
{
|
|
41
|
-
"type": "MCP",
|
|
42
|
-
"endpoint": "https://mcp.atlassian.com/v1/forge/mcp",
|
|
43
|
-
"description": "Atlassian MCP Server (requires authentication, will fail gracefully)"
|
|
44
|
-
}
|
|
45
|
-
]
|
|
46
|
-
|
|
47
|
-
successful_tests = []
|
|
48
|
-
failed_tests = []
|
|
49
|
-
|
|
50
|
-
for i, test_case in enumerate(test_cases, 1):
|
|
51
|
-
print(f"\n📍 Test {i}: {test_case['type']} Endpoint")
|
|
52
|
-
print("-" * 70)
|
|
53
|
-
print(f"URL: {test_case['endpoint']}")
|
|
54
|
-
print(f"Description: {test_case['description']}")
|
|
55
|
-
print()
|
|
56
|
-
|
|
57
|
-
if test_case['type'] == 'A2A':
|
|
58
|
-
capabilities = crawler.fetch_a2a_capabilities(test_case['endpoint'])
|
|
59
|
-
if capabilities:
|
|
60
|
-
print("✅ SUCCESS! Fetched A2A capabilities:")
|
|
61
|
-
print(json.dumps(capabilities, indent=2))
|
|
62
|
-
successful_tests.append(test_case)
|
|
63
|
-
else:
|
|
64
|
-
print("❌ Failed to fetch A2A capabilities")
|
|
65
|
-
failed_tests.append(test_case)
|
|
66
|
-
|
|
67
|
-
elif test_case['type'] == 'MCP':
|
|
68
|
-
capabilities = crawler.fetch_mcp_capabilities(test_case['endpoint'])
|
|
69
|
-
if capabilities:
|
|
70
|
-
print("✅ SUCCESS! Fetched MCP capabilities:")
|
|
71
|
-
print(json.dumps(capabilities, indent=2))
|
|
72
|
-
successful_tests.append(test_case)
|
|
73
|
-
else:
|
|
74
|
-
print("❌ Failed to fetch MCP capabilities")
|
|
75
|
-
failed_tests.append(test_case)
|
|
76
|
-
|
|
77
|
-
# Summary
|
|
78
|
-
print("\n" + "=" * 70)
|
|
79
|
-
print("📊 Summary")
|
|
80
|
-
print("-" * 70)
|
|
81
|
-
print(f"✅ Successful: {len(successful_tests)}")
|
|
82
|
-
print(f"❌ Failed: {len(failed_tests)}")
|
|
83
|
-
|
|
84
|
-
if successful_tests:
|
|
85
|
-
print("\n✅ Successfully tested endpoints:")
|
|
86
|
-
for test in successful_tests:
|
|
87
|
-
print(f" - {test['type']}: {test['endpoint']}")
|
|
88
|
-
|
|
89
|
-
if failed_tests:
|
|
90
|
-
print("\n⚠️ Failed endpoints:")
|
|
91
|
-
for test in failed_tests:
|
|
92
|
-
print(f" - {test['type']}: {test['endpoint']}")
|
|
93
|
-
|
|
94
|
-
print("\n" + "=" * 70)
|
|
95
|
-
if successful_tests:
|
|
96
|
-
print("🎉 Endpoint crawler is working with real public servers!")
|
|
97
|
-
else:
|
|
98
|
-
print("⚠️ No capabilities fetched. Check endpoints or network connection.")
|
|
99
|
-
print("=" * 70)
|
|
100
|
-
|
|
101
|
-
if __name__ == "__main__":
|
|
102
|
-
main()
|
|
103
|
-
|