1919# -------------------------------------------------------------
2020"""Source dode to download and run agent from the repos."""
2121import hashlib
22+ import json
2223import os
2324import platform
2425import shutil
@@ -40,6 +41,7 @@ class AgentRelease:
4041 owner : str
4142 repo : str
4243 release : str
44+ is_aea : bool
4345
4446 @property
4547 def release_url (self ) -> str :
@@ -62,25 +64,10 @@ def get_url_and_hash(self, asset_name: str) -> tuple[str, str]:
6264 return file_url , file_hash
6365
6466
65- # list of agents releases supported
66- AGENTS_SUPPORTED = {
67- "valory/trader" : AgentRelease (
68- owner = "valory-xyz" , repo = "trader" , release = "v0.0.101"
69- ),
70- "valory/optimus" : AgentRelease (
71- owner = "valory-xyz" , repo = "optimus" , release = "v0.0.103"
72- ),
73- "dvilela/memeooorr" : AgentRelease (
74- owner = "valory-xyz" , repo = "meme-ooorr" , release = "v0.0.101"
75- ),
76- }
77-
78-
7967class AgentRunnerManager :
8068 """Agent Runner Manager."""
8169
8270 logger = setup_logger (name = "operate.agent_runner_manager" )
83- AGENTS = AGENTS_SUPPORTED
8471
8572 @staticmethod
8673 def get_agent_runner_executable_name () -> str :
@@ -131,14 +118,19 @@ def download_file(cls, url: str, save_path: Path) -> None:
131118 raise
132119
133120 @classmethod
134- def get_agent_release_by_public_id (cls , agent_public_id_str : str ) -> AgentRelease :
121+ def get_agent_release_from_service_dir (cls , service_dir : Path ) -> AgentRelease :
135122 """Get agent release object according to public id."""
136- agent_author , agent_name = cls .parse_agent (public_id_str = agent_public_id_str )
137-
138- agent_name = f"{ agent_author } /{ agent_name } "
139- agent_release = cls .AGENTS .get (agent_name , None )
140- if agent_release is None :
141- raise ValueError (f"{ agent_name } is not supported!" )
123+ service_config_file = service_dir / "config.json"
124+ service_config = json .loads (service_config_file .read_text ())
125+ if "agent_release" not in service_config :
126+ raise ValueError (f"Agent release details are not found in { service_config } " )
127+ agent_release_data = service_config ["agent_release" ]
128+ agent_release = AgentRelease (
129+ is_aea = agent_release_data ["is_aea" ],
130+ owner = agent_release_data ["repo_owner" ],
131+ repo = agent_release_data ["repo_name" ],
132+ release = agent_release_data ["version" ],
133+ )
142134 return agent_release
143135
144136 @staticmethod
@@ -187,13 +179,11 @@ def update_agent_runner(
187179 raise
188180
189181 @classmethod
190- def get_agent_runner_path (cls , service_dir : Path , agent_public_id_str : str ) -> str :
182+ def get_agent_runner_path (cls , service_dir : Path ) -> str :
191183 """Get path to the agent runner bin palced."""
192184 agent_runner_name = cls .get_agent_runner_executable_name ()
193185 agent_runner_path : Path = service_dir / agent_runner_name
194- agent_release = cls .get_agent_release_by_public_id (
195- agent_public_id_str = agent_public_id_str
196- )
186+ agent_release = cls .get_agent_release_from_service_dir (service_dir = service_dir )
197187
198188 cls .update_agent_runner (
199189 target_path = agent_runner_path ,
@@ -203,8 +193,8 @@ def get_agent_runner_path(cls, service_dir: Path, agent_public_id_str: str) -> s
203193 return str (agent_runner_path )
204194
205195
206- def get_agent_runner_path (service_dir : Path , agent_public_id_str : str ) -> str :
196+ def get_agent_runner_path (service_dir : Path ) -> str :
207197 """Get path to the agent runner bin placed."""
208198 return AgentRunnerManager .get_agent_runner_path (
209- service_dir = service_dir , agent_public_id_str = agent_public_id_str
199+ service_dir = service_dir ,
210200 )
0 commit comments