uagents-core 0.3.0__py3-none-any.whl → 0.3.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.
@@ -70,7 +70,7 @@ class VerifiableModel(BaseModel):
70
70
  class AgentRegistrationAttestation(VerifiableModel):
71
71
  protocols: list[str]
72
72
  endpoints: list[AgentEndpoint]
73
- metadata: dict[str, str | dict[str, str]] | None = None
73
+ metadata: dict[str, str | list[str] | dict[str, str]] | None = None
74
74
 
75
75
 
76
76
  # Agentverse related models
@@ -107,3 +107,9 @@ class AgentUpdates(BaseModel):
107
107
  avatar_url: str | None = Field(default=None, max_length=4000)
108
108
  short_description: str | None = Field(default=None, max_length=300)
109
109
  agent_type: AgentType | None = "custom"
110
+
111
+
112
+ class AgentStatusUpdate(VerifiableModel):
113
+ is_active: bool = Field(
114
+ ..., description="Indicates whether the agent is currently active"
115
+ )
uagents_core/storage.py CHANGED
@@ -56,13 +56,13 @@ class ExternalStorage:
56
56
  raise RuntimeError("No identity or API token available for authentication")
57
57
 
58
58
  def upload(
59
- self, asset_id: str, asset_content: str, mime_type: str = "text/plain"
59
+ self, asset_id: str, content: bytes, mime_type: str = "text/plain"
60
60
  ) -> dict:
61
61
  url = f"{self.storage_url}/assets/{asset_id}/contents/"
62
62
  headers = self._get_auth_header()
63
63
  headers["Content-Type"] = "application/json"
64
64
  payload = {
65
- "contents": base64.b64encode(asset_content.encode()).decode(),
65
+ "contents": base64.b64encode(content).decode(),
66
66
  "mime_type": mime_type,
67
67
  }
68
68
  response = requests.put(url, json=payload, headers=headers)
@@ -88,7 +88,7 @@ class ExternalStorage:
88
88
  def create_asset(
89
89
  self,
90
90
  name: str,
91
- content: str,
91
+ content: bytes,
92
92
  mime_type: str = "text/plain",
93
93
  lifetime_hours: int = 24,
94
94
  ) -> str:
@@ -100,7 +100,7 @@ class ExternalStorage:
100
100
  payload = {
101
101
  "name": name,
102
102
  "mime_type": mime_type,
103
- "contents": base64.b64encode(content.encode()).decode(),
103
+ "contents": base64.b64encode(content).decode(),
104
104
  "lifetime_hours": lifetime_hours,
105
105
  }
106
106
 
@@ -19,6 +19,7 @@ from uagents_core.logger import get_logger
19
19
  from uagents_core.protocol import is_valid_protocol_digest
20
20
  from uagents_core.registration import (
21
21
  AgentRegistrationAttestation,
22
+ AgentStatusUpdate,
22
23
  AgentUpdates,
23
24
  AgentverseConnectRequest,
24
25
  ChallengeRequest,
@@ -66,7 +67,7 @@ def register_in_almanac(
66
67
  identity: Identity,
67
68
  endpoints: list[str],
68
69
  protocol_digests: list[str],
69
- metadata: dict[str, str | dict[str, str]] | None = None,
70
+ metadata: dict[str, str | list[str] | dict[str, str]] | None = None,
70
71
  *,
71
72
  agentverse_config: AgentverseConfig | None = None,
72
73
  timeout: int = DEFAULT_REQUEST_TIMEOUT,
@@ -269,3 +270,37 @@ def register_in_agentverse(
269
270
  exc_info=e,
270
271
  )
271
272
  return False
273
+
274
+
275
+ def update_agent_status(active: bool, identity: Identity):
276
+ """
277
+ Update the agent's active/inactive status in the Almanac API.
278
+
279
+ Args:
280
+ active (bool): The status of the agent.
281
+ identity (Identity): The identity of the agent.
282
+ """
283
+ almanac_api = AgentverseConfig().url + DEFAULT_ALMANAC_API_PATH
284
+
285
+ status_update = AgentStatusUpdate(
286
+ agent_identifier=identity.address, is_active=active
287
+ )
288
+ status_update.sign(identity)
289
+
290
+ logger.debug(
291
+ msg="Updating agent status in Almanac API",
292
+ extra=status_update.model_dump(),
293
+ )
294
+
295
+ status, _ = _send_post_request(
296
+ url=f"{almanac_api}/agents/{identity.address}/status",
297
+ data=status_update,
298
+ )
299
+
300
+ if status:
301
+ logger.info(
302
+ msg=f"Agent status updated to {'active' if active else 'inactive'}",
303
+ extra={"agent_address": identity.address},
304
+ )
305
+
306
+ return status
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: uagents-core
3
- Version: 0.3.0
3
+ Version: 0.3.2
4
4
  Summary: Core components for agent based systems
5
5
  License: Apache 2.0
6
6
  Author: Ed FitzGerald
@@ -10,13 +10,13 @@ uagents_core/identity.py,sha256=YHI3rromJ27DGF3X102MGkuvBIZ6usAaMutlDLdVaL0,6185
10
10
  uagents_core/logger.py,sha256=5XLs3-XpKDeoSwtAE5pEM9h6x3pUPNbb0T0J7KvFmG0,877
11
11
  uagents_core/models.py,sha256=fxsFjRochkJUdgPltT1HWgBl-9K-HVQWl8sSMVgeJFY,1066
12
12
  uagents_core/protocol.py,sha256=T9jasOkltne33E16Y7VrqcB2moWVsv-Qh4XLZotyz8g,5428
13
- uagents_core/registration.py,sha256=h7ha58H7XbLQ__qOHMKVnHShzMlWfd2xrK9fRdgfb9w,2953
14
- uagents_core/storage.py,sha256=A7s2jJhdbDI0aNKAcjJpL5oxcYrb2FnHhXGwlAt3RY4,4506
13
+ uagents_core/registration.py,sha256=HPV-bYNEfWxOwjbJqFZoMUTGu8H1CcwSLmN-vVBOTnc,3119
14
+ uagents_core/storage.py,sha256=Nb_vvckp5FV48bcewFmYUoLFHAsWxwaiIv_-idFpGqQ,4480
15
15
  uagents_core/types.py,sha256=_W3EN1wEIRFxuhhBxyZxQH_dA_3AtoPPReIzrgcTUHc,1167
16
16
  uagents_core/utils/__init__.py,sha256=v0MaxDYCTtQlwbblEHCfLtbeTnA2hCmKKJk7mlcE20U,135
17
17
  uagents_core/utils/messages.py,sha256=5o3ahVaeGwzWMAxDs0fl2pC1duDq2VS_-czoVtZpkOc,5066
18
- uagents_core/utils/registration.py,sha256=HaA0J2yisx0bwVs1LbpJ4UP3-maeeAf37yziI-U07l8,9067
18
+ uagents_core/utils/registration.py,sha256=zBJVCJwcjVnTb4PqVFfxCS1kVxeEvD9IC9-_Q4Coz_s,10022
19
19
  uagents_core/utils/resolver.py,sha256=X18oe-WPU_6pfTc6x_Oa69kZQYCMidkaSeCs68Poaik,2169
20
- uagents_core-0.3.0.dist-info/METADATA,sha256=SpfzcsoEMP44pjC4tRmjq0kx8UHr-KPSZ4kZGG6jp8A,1009
21
- uagents_core-0.3.0.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
22
- uagents_core-0.3.0.dist-info/RECORD,,
20
+ uagents_core-0.3.2.dist-info/METADATA,sha256=ijRPc3gtEpjViaklW6Wy5rs2EfNjrrlvSRx8XW5Xqs0,1009
21
+ uagents_core-0.3.2.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
22
+ uagents_core-0.3.2.dist-info/RECORD,,