agent0-sdk 1.2.0__py3-none-any.whl → 1.4.1__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.
@@ -53,6 +53,12 @@ class SubgraphClient:
53
53
  if ("has no field" in msg and "responseURI" in msg) and ("responseURI" in query):
54
54
  logger.debug("Subgraph schema missing responseURI; retrying query with responseUri")
55
55
  return _do_query(query.replace("responseURI", "responseUri"))
56
+ # Some deployments still expose `x402support` instead of `x402Support`.
57
+ if (("has no field" in msg and "x402Support" in msg) or ("Cannot query field" in msg and "x402Support" in msg)) and (
58
+ "x402Support" in query
59
+ ):
60
+ logger.debug("Subgraph schema missing x402Support; retrying query with x402support")
61
+ return _do_query(query.replace("x402Support", "x402support"))
56
62
  # Some deployments don't expose agentWallet fields on AgentRegistrationFile.
57
63
  if (
58
64
  "Type `AgentRegistrationFile` has no field `agentWallet`" in msg
@@ -115,7 +121,7 @@ class SubgraphClient:
115
121
  description
116
122
  image
117
123
  active
118
- x402support
124
+ x402Support
119
125
  supportedTrusts
120
126
  mcpEndpoint
121
127
  mcpVersion
@@ -183,7 +189,7 @@ class SubgraphClient:
183
189
  description
184
190
  image
185
191
  active
186
- x402support
192
+ x402Support
187
193
  supportedTrusts
188
194
  mcpEndpoint
189
195
  mcpVersion
@@ -772,7 +778,7 @@ class SubgraphClient:
772
778
  description
773
779
  image
774
780
  active
775
- x402support
781
+ x402Support
776
782
  supportedTrusts
777
783
  mcpEndpoint
778
784
  mcpVersion
@@ -0,0 +1,71 @@
1
+ from __future__ import annotations
2
+
3
+ from dataclasses import dataclass
4
+ from typing import Any, Callable, Dict, Generic, TypeVar, TYPE_CHECKING
5
+
6
+ if TYPE_CHECKING:
7
+ from .web3_client import Web3Client
8
+
9
+ T = TypeVar("T")
10
+
11
+
12
+ @dataclass
13
+ class TransactionMined(Generic[T]):
14
+ receipt: Dict[str, Any]
15
+ result: T
16
+
17
+
18
+ class TransactionHandle(Generic[T]):
19
+ """
20
+ Transaction lifecycle handle (submitted-by-default).
21
+
22
+ - `tx_hash` is available immediately after submission.
23
+ - `wait_mined` / `wait_confirmed` can be called to await a receipt (and optional confirmations)
24
+ and produce a domain result.
25
+ """
26
+
27
+ def __init__(
28
+ self,
29
+ *,
30
+ web3_client: Web3Client,
31
+ tx_hash: str,
32
+ compute_result: Callable[[Dict[str, Any]], T],
33
+ ):
34
+ self.web3_client = web3_client
35
+ self.tx_hash = tx_hash
36
+ self._compute_result = compute_result
37
+ self._memo: Dict[str, TransactionMined[T]] = {}
38
+
39
+ def wait_mined(
40
+ self,
41
+ *,
42
+ timeout: int = 60,
43
+ confirmations: int = 1,
44
+ throw_on_revert: bool = True,
45
+ ) -> TransactionMined[T]:
46
+ key = f"{timeout}:{confirmations}:{int(bool(throw_on_revert))}"
47
+ existing = self._memo.get(key)
48
+ if existing is not None:
49
+ return existing
50
+
51
+ receipt = self.web3_client.wait_for_transaction(
52
+ self.tx_hash,
53
+ timeout=timeout,
54
+ confirmations=confirmations,
55
+ throw_on_revert=throw_on_revert,
56
+ )
57
+ result = self._compute_result(receipt)
58
+ mined = TransactionMined(receipt=receipt, result=result)
59
+ self._memo[key] = mined
60
+ return mined
61
+
62
+ def wait_confirmed(
63
+ self,
64
+ *,
65
+ timeout: int = 60,
66
+ confirmations: int = 1,
67
+ throw_on_revert: bool = True,
68
+ ) -> TransactionMined[T]:
69
+ return self.wait_mined(timeout=timeout, confirmations=confirmations, throw_on_revert=throw_on_revert)
70
+
71
+
@@ -1,7 +1,7 @@
1
1
  """
2
2
  Value encoding utilities for ReputationRegistry (Jan 2026).
3
3
 
4
- On-chain representation: (value:int256, valueDecimals:uint8)
4
+ On-chain representation: (value:int128, valueDecimals:uint8)
5
5
  Human representation: value / 10^valueDecimals
6
6
  """
7
7
 
@@ -17,8 +17,8 @@ logger = logging.getLogger(__name__)
17
17
  getcontext().prec = 120
18
18
 
19
19
  MAX_DECIMALS = 18
20
- # Solidity constant (raw int256 magnitude)
21
- MAX_ABS_VALUE_RAW = 10**50
20
+ # Solidity constant (raw int128 magnitude). Contract enforces abs(value) <= 1e38.
21
+ MAX_ABS_VALUE_RAW = 10**38
22
22
 
23
23
 
24
24
  def encode_feedback_value(input_value: Union[int, float, str, Decimal]) -> Tuple[int, int, str]:
@@ -5,6 +5,7 @@ Web3 integration layer for smart contract interactions.
5
5
  from __future__ import annotations
6
6
 
7
7
  import json
8
+ import time
8
9
  from typing import Any, Dict, List, Optional, Tuple, Union, Callable
9
10
 
10
11
  try:
@@ -99,9 +100,48 @@ class Web3Client:
99
100
 
100
101
  return tx_hash.hex()
101
102
 
102
- def wait_for_transaction(self, tx_hash: str, timeout: int = 60) -> Dict[str, Any]:
103
- """Wait for transaction to be mined."""
104
- return self.w3.eth.wait_for_transaction_receipt(tx_hash, timeout=timeout)
103
+ def wait_for_transaction(
104
+ self,
105
+ tx_hash: str,
106
+ timeout: int = 60,
107
+ confirmations: int = 1,
108
+ throw_on_revert: bool = True,
109
+ ) -> Dict[str, Any]:
110
+ """Wait for transaction to be mined, optionally waiting for additional confirmations."""
111
+ if confirmations < 1:
112
+ raise ValueError("confirmations must be >= 1")
113
+
114
+ start = time.time()
115
+ receipt = self.w3.eth.wait_for_transaction_receipt(tx_hash, timeout=timeout)
116
+
117
+ if throw_on_revert:
118
+ status = receipt.get("status")
119
+ # Most chains return 1 for success, 0 for revert (may be int or HexBytes-like).
120
+ try:
121
+ status_int = int(status)
122
+ except Exception:
123
+ try:
124
+ status_int = int(status.hex(), 16) # type: ignore[attr-defined]
125
+ except Exception:
126
+ status_int = 1 # if unknown, don't falsely throw
127
+ if status_int == 0:
128
+ raise ValueError(f"Transaction reverted: {tx_hash}")
129
+
130
+ if confirmations > 1:
131
+ block_number = receipt.get("blockNumber")
132
+ if block_number is not None:
133
+ target_block = int(block_number) + (confirmations - 1)
134
+ while True:
135
+ current = int(self.w3.eth.block_number)
136
+ if current >= target_block:
137
+ break
138
+ if time.time() - start > timeout:
139
+ raise TimeoutError(
140
+ f"Timed out waiting for confirmations (tx={tx_hash}, confirmations={confirmations})"
141
+ )
142
+ time.sleep(1.0)
143
+
144
+ return receipt
105
145
 
106
146
  def get_events(
107
147
  self,
@@ -209,7 +249,7 @@ class Web3Client:
209
249
  verifying_contract: str,
210
250
  chain_id: int,
211
251
  ) -> Dict[str, Any]:
212
- """Build EIP-712 typed data for ERC-8004 IdentityRegistry setAgentWallet.
252
+ """Build EIP-712 typed data for the agent wallet verification message.
213
253
 
214
254
  Contract expects:
215
255
  - domain: name="ERC8004IdentityRegistry", version="1"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: agent0-sdk
3
- Version: 1.2.0
3
+ Version: 1.4.1
4
4
  Summary: Python SDK for agent portability, discovery and trust based on ERC-8004
5
5
  Author-email: Agent0 Team <team@ag0.xyz>
6
6
  License: MIT License
@@ -158,20 +158,23 @@ agent.setTrust(reputation=True, cryptoEconomic=True)
158
158
  agent.setMetadata({"version": "1.0.0", "category": "ai-assistant"})
159
159
  agent.setActive(True)
160
160
 
161
- # Register on-chain with IPFS
162
- agent.registerIPFS()
163
- print(f"Agent registered: {agent.agentId}") # e.g., "11155111:123"
164
- print(f"Agent URI: {agent.agentURI}") # e.g., "ipfs://Qm..."
161
+ # Register on-chain with IPFS (submitted-by-default)
162
+ reg_tx = agent.registerIPFS()
163
+ reg = reg_tx.wait_confirmed(timeout=180).result
164
+ print(f"Agent registered: {reg.agentId}") # e.g., "11155111:123"
165
+ print(f"Agent URI: {reg.agentURI}") # e.g., "ipfs://Qm..."
165
166
 
166
167
  # (Optional) Change the agent wallet after registration
167
168
  # - On mint/registration, `agentWallet` defaults to the current owner address.
168
169
  # - Call this only if you want a DIFFERENT wallet (or after a transfer, since the wallet resets to zero).
169
170
  # - Transaction is sent by the SDK signer (agent owner), but the signature must be produced by the NEW wallet.
170
- agent.setAgentWallet(
171
+ wallet_tx = agent.setWallet(
171
172
  "0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb",
172
173
  chainId=11155111,
173
174
  new_wallet_signer=os.getenv("NEW_WALLET_PRIVATE_KEY"),
174
175
  )
176
+ if wallet_tx:
177
+ wallet_tx.wait_confirmed(timeout=180)
175
178
  ```
176
179
 
177
180
  ### 3. Load and Edit Agent
@@ -185,8 +188,9 @@ agent.updateInfo(description="Updated description with new capabilities")
185
188
  agent.setMCP("https://new-mcp.example.com/")
186
189
 
187
190
  # Re-register to update on-chain
188
- agent.registerIPFS()
189
- print(f"Updated: {agent.agentURI}")
191
+ update_tx = agent.registerIPFS()
192
+ update = update_tx.wait_confirmed(timeout=180).result
193
+ print(f"Updated: {update.agentURI}")
190
194
  ```
191
195
 
192
196
  ### 4. Search Agents
@@ -214,13 +218,14 @@ agent_summary = sdk.getAgent("11155111:123")
214
218
 
215
219
  ```python
216
220
  # On-chain-only feedback (no off-chain upload, even if IPFS is configured)
217
- feedback = sdk.giveFeedback(
221
+ tx = sdk.giveFeedback(
218
222
  agentId="11155111:123",
219
223
  value=85, # number|string
220
224
  tag1="data_analyst", # Optional: tags are strings
221
225
  tag2="finance",
222
226
  endpoint="https://example.com/endpoint", # Optional: saved on-chain
223
227
  )
228
+ feedback = tx.wait_confirmed(timeout=180).result
224
229
 
225
230
  # Rich feedback (optional off-chain file + on-chain fields)
226
231
  feedback_file = sdk.prepareFeedbackFile({
@@ -230,7 +235,7 @@ feedback_file = sdk.prepareFeedbackFile({
230
235
  "text": "Great agent!", # Optional
231
236
  })
232
237
 
233
- feedback = sdk.giveFeedback(
238
+ tx = sdk.giveFeedback(
234
239
  agentId="11155111:123",
235
240
  value=85,
236
241
  tag1="data_analyst",
@@ -238,6 +243,7 @@ feedback = sdk.giveFeedback(
238
243
  endpoint="https://example.com/endpoint",
239
244
  feedbackFile=feedback_file, # If provided, requires IPFS configured
240
245
  )
246
+ feedback = tx.wait_confirmed(timeout=180).result
241
247
 
242
248
  # Search feedback
243
249
  results = sdk.searchFeedback(
@@ -247,6 +253,16 @@ results = sdk.searchFeedback(
247
253
  maxValue=100
248
254
  )
249
255
 
256
+ # NEW: Search feedback given by a reviewer wallet (across all agents; subgraph required)
257
+ given = sdk.searchFeedback(
258
+ reviewers=["0x742d35cc6634c0532925a3b844bc9e7595f0beb7"]
259
+ )
260
+
261
+ # NEW: Search feedback across multiple agents at once
262
+ multi = sdk.searchFeedback(
263
+ agents=["11155111:123", "11155111:456", "11155111:789"]
264
+ )
265
+
250
266
  # Get reputation summary
251
267
  summary = sdk.getReputationSummary("11155111:123")
252
268
  print(f"Average value: {summary['averageValue']}")
@@ -0,0 +1,21 @@
1
+ agent0_sdk/__init__.py,sha256=dz1Rxuq5FoLGuA6F-6O8sopQ8WVVmWjYHLJGwVvrKsY,1102
2
+ agent0_sdk/core/agent.py,sha256=P3AX7zm4G5qkWdTJcjOvR69cCyOovHefbRoKejj6QKY,48062
3
+ agent0_sdk/core/contracts.py,sha256=5AAY0_GCOkw8FL49_dDpGF6TwFk1OCwzFe8Je0jb7Oc,22787
4
+ agent0_sdk/core/endpoint_crawler.py,sha256=QBkFc3tBSQqHj6PtSTZ5D3_HVB00KJZJdxE3uYpI9po,13611
5
+ agent0_sdk/core/feedback_manager.py,sha256=gHCyBYK17Yc5HcxDcbhl_blXYqulYO-7oiEvoPQomms,42585
6
+ agent0_sdk/core/indexer.py,sha256=gz4DDQQcRbe1RQtFSgq4OZLLFwXHFIe4v2-CcpD077A,72661
7
+ agent0_sdk/core/ipfs_client.py,sha256=17XXMpJgLWhcNUSkmduAZt409c8oJXlj9C_eTGVk-Io,14185
8
+ agent0_sdk/core/models.py,sha256=kiCtRm_ORdBph-Ces0HStsY92jnevY5yCpITb0PZErw,12218
9
+ agent0_sdk/core/oasf_validator.py,sha256=ZOtYYzQd7cJj3eJegi7Ch5ydoapJEjaJSxMvwzKSp5o,2980
10
+ agent0_sdk/core/sdk.py,sha256=w1Q6oCrQoXnCd9fgFlz1rOM0P1JbLYWAB8gs1Upz4IU,39510
11
+ agent0_sdk/core/subgraph_client.py,sha256=seEisw__r9nqQl1CgXa5DiUb6EvZ2GG7qS4wQPLILWo,29854
12
+ agent0_sdk/core/transaction_handle.py,sha256=tKo6ny02m3eIeDGo0Wjikf-yUtl_8KYJy5YxFkPvyHo,1958
13
+ agent0_sdk/core/value_encoding.py,sha256=NQUUvjTRAr5Tqj8t4HUGlfhak8VDmB8E5WMlfAqJwVk,3311
14
+ agent0_sdk/core/web3_client.py,sha256=9w5ZgHILteCHSOisae3QluwuIsX3OD-VkoAc01koQWA,13786
15
+ agent0_sdk/taxonomies/all_domains.json,sha256=buM8_6mpY8_AMbBIPzM-gtu14Tl30QDmhuQxxrlJU4c,74625
16
+ agent0_sdk/taxonomies/all_skills.json,sha256=WVsutw3fqoj1jfDPru3CyWTr1kc1a5-EhBOWPfXnEi8,47483
17
+ agent0_sdk-1.4.1.dist-info/licenses/LICENSE,sha256=rhZZbZm_Ovz4Oa9LNQ-ms8a1tA36wWh90ZkC0OR7WMw,1072
18
+ agent0_sdk-1.4.1.dist-info/METADATA,sha256=hUaaBL4JaACaiDuJQIc4UPLklW1aygaH0bo-dY_zbDQ,15179
19
+ agent0_sdk-1.4.1.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
20
+ agent0_sdk-1.4.1.dist-info/top_level.txt,sha256=p4520WUKNfhU0lVWJgkrB_jdeUfvHSY3K18k4oYLNfI,11
21
+ agent0_sdk-1.4.1.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (80.9.0)
2
+ Generator: setuptools (80.10.2)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,20 +0,0 @@
1
- agent0_sdk/__init__.py,sha256=whhlT0msNtRmUKzXq97m38li8tjT9LOsJh6qYArYIqY,919
2
- agent0_sdk/core/agent.py,sha256=NJo0pjigXznP0zDIrpryrL7pMj5bVvZIhfv4abKtUKk,45157
3
- agent0_sdk/core/contracts.py,sha256=AVho-sfIv1dBY3iF34OVXg-kORoTWpFYlcreR9PUuAo,22398
4
- agent0_sdk/core/endpoint_crawler.py,sha256=QBkFc3tBSQqHj6PtSTZ5D3_HVB00KJZJdxE3uYpI9po,13611
5
- agent0_sdk/core/feedback_manager.py,sha256=NmPHGvTdenANGgM4LQHW0kQUoeCN9UtNr7qGfQIQQsw,41115
6
- agent0_sdk/core/indexer.py,sha256=VJ5_vvmiwkgcj8xbGoyxS0KM_4Nmfofr1IxitZ3A4EQ,70548
7
- agent0_sdk/core/ipfs_client.py,sha256=17XXMpJgLWhcNUSkmduAZt409c8oJXlj9C_eTGVk-Io,14185
8
- agent0_sdk/core/models.py,sha256=lZ2VDDEYIdTJccySObaGJ39b1ocQyr5oOAQfhvp6xME,12160
9
- agent0_sdk/core/oasf_validator.py,sha256=ZOtYYzQd7cJj3eJegi7Ch5ydoapJEjaJSxMvwzKSp5o,2980
10
- agent0_sdk/core/sdk.py,sha256=8b4bMA57TczbFn2fGeDmW3W8zT6X73c1rV8tDUnNzBs,38241
11
- agent0_sdk/core/subgraph_client.py,sha256=vnxDtKC40TGVX_L6X_F-0k8S5reQtGj9zUqNocVC66U,29407
12
- agent0_sdk/core/value_encoding.py,sha256=ahcglBCIsWGQPjFsxFPieOFJ18kCgIU4oGe9UJajiyg,3272
13
- agent0_sdk/core/web3_client.py,sha256=h7s-Al3E1xfbb3QNcPvmQBotKJRg23Jm9xot4emr-hU,12283
14
- agent0_sdk/taxonomies/all_domains.json,sha256=buM8_6mpY8_AMbBIPzM-gtu14Tl30QDmhuQxxrlJU4c,74625
15
- agent0_sdk/taxonomies/all_skills.json,sha256=WVsutw3fqoj1jfDPru3CyWTr1kc1a5-EhBOWPfXnEi8,47483
16
- agent0_sdk-1.2.0.dist-info/licenses/LICENSE,sha256=rhZZbZm_Ovz4Oa9LNQ-ms8a1tA36wWh90ZkC0OR7WMw,1072
17
- agent0_sdk-1.2.0.dist-info/METADATA,sha256=S1yRxTmHYHqQpF1XEFnbRU7kfruzFFsT6ViEo3BERxE,14561
18
- agent0_sdk-1.2.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
19
- agent0_sdk-1.2.0.dist-info/top_level.txt,sha256=p4520WUKNfhU0lVWJgkrB_jdeUfvHSY3K18k4oYLNfI,11
20
- agent0_sdk-1.2.0.dist-info/RECORD,,