1+ import inspect
2+ import json
3+ import os
4+ from pathlib import Path
5+
16from typing import Literal
27from agentex .lib .sdk .fastacp .base .base_acp_server import BaseACPServer
38from agentex .lib .sdk .fastacp .impl .agentic_base_acp import AgenticBaseACP
813 BaseACPConfig ,
914 SyncACPConfig ,
1015)
16+ from agentex .lib .utils .logging import make_logger
1117
1218# Add new mappings between ACP types and configs here
1319# Add new mappings between ACP types and implementations here
1622 "base" : AgenticBaseACP ,
1723}
1824
25+ logger = make_logger (__name__ )
1926
2027class FastACP :
2128 """Factory for creating FastACP instances
@@ -51,6 +58,22 @@ def create_agentic_acp(config: AgenticACPConfig, **kwargs) -> BaseACPServer:
5158 else :
5259 return implementation_class .create (** kwargs )
5360
61+ @staticmethod
62+ def maybe_get_build_info () -> None :
63+ """If a build-info.json file is present, load it and set the AGENT_COMMIT and AGENT_CODE_URL environment variables"""
64+ acp_root = Path (inspect .stack ()[1 ].filename ).resolve ().parents [0 ]
65+ build_info_path = acp_root / "build-info.json"
66+ if build_info_path .exists ():
67+ try :
68+ with open (build_info_path , "r" ) as f :
69+ build_info = json .load (f )
70+ if build_info .get ("agent_commit" ):
71+ os .environ ["AGENT_COMMIT" ] = build_info .get ("agent_commit" )
72+ if build_info .get ("agent_repo" ) and build_info .get ("agent_path" ):
73+ os .environ ["AGENT_CODE_URL" ] = build_info .get ("agent_repo" ) + "/" + build_info .get ("agent_path" )
74+ except Exception as e :
75+ logger .error (f"Error loading build info: { e } " )
76+
5477 @staticmethod
5578 def create (
5679 acp_type : Literal ["sync" , "agentic" ], config : BaseACPConfig | None = None , ** kwargs
@@ -63,6 +86,8 @@ def create(
6386 **kwargs: Additional configuration parameters
6487 """
6588
89+ FastACP .maybe_get_build_info ()
90+
6691 if acp_type == "sync" :
6792 sync_config = config if isinstance (config , SyncACPConfig ) else None
6893 return FastACP .create_sync_acp (sync_config , ** kwargs )
0 commit comments