44import json
55from crewai .tools import BaseTool
66
7-
7+ # DEFAULTS
88ENTERPRISE_ACTION_KIT_PROJECT_ID = "dd525517-df22-49d2-a69e-6a0eed211166"
9+ ENTERPRISE_ACTION_KIT_PROJECT_URL = "https://worker-actionkit.tools.crewai.com/projects"
910
1011
1112class EnterpriseActionTool (BaseTool ):
@@ -18,6 +19,12 @@ class EnterpriseActionTool(BaseTool):
1819 action_schema : Dict [str , Any ] = Field (
1920 default = {}, description = "The schema of the action"
2021 )
22+ enterprise_action_kit_project_id : str = Field (
23+ default = ENTERPRISE_ACTION_KIT_PROJECT_ID , description = "The project id"
24+ )
25+ enterprise_action_kit_project_url : str = Field (
26+ default = ENTERPRISE_ACTION_KIT_PROJECT_URL , description = "The project url"
27+ )
2128
2229 def __init__ (
2330 self ,
@@ -26,6 +33,8 @@ def __init__(
2633 enterprise_action_token : str ,
2734 action_name : str ,
2835 action_schema : Dict [str , Any ],
36+ enterprise_action_kit_project_url : str = ENTERPRISE_ACTION_KIT_PROJECT_URL ,
37+ enterprise_action_kit_project_id : str = ENTERPRISE_ACTION_KIT_PROJECT_ID ,
2938 ):
3039 schema_props = (
3140 action_schema .get ("function" , {})
@@ -74,12 +83,17 @@ def __init__(
7483 self .action_name = action_name
7584 self .action_schema = action_schema
7685
86+ if enterprise_action_kit_project_id is not None :
87+ self .enterprise_action_kit_project_id = enterprise_action_kit_project_id
88+ if enterprise_action_kit_project_url is not None :
89+ self .enterprise_action_kit_project_url = enterprise_action_kit_project_url
90+
7791 def _run (self , ** kwargs ) -> str :
7892 """Execute the specific enterprise action with validated parameters."""
7993 try :
8094 params = {k : v for k , v in kwargs .items () if v is not None }
8195
82- api_url = f"https://worker-actionkit.tools.crewai.com/projects/ { ENTERPRISE_ACTION_KIT_PROJECT_ID } /actions"
96+ api_url = f"{ self . enterprise_action_kit_project_url } / { self . enterprise_action_kit_project_id } /actions"
8397 headers = {
8498 "Authorization" : f"Bearer { self .enterprise_action_token } " ,
8599 "Content-Type" : "application/json" ,
@@ -104,14 +118,21 @@ def _run(self, **kwargs) -> str:
104118class EnterpriseActionKitToolAdapter :
105119 """Adapter that creates BaseTool instances for enterprise actions."""
106120
107- def __init__ (self , enterprise_action_token : str ):
121+ def __init__ (
122+ self ,
123+ enterprise_action_token : str ,
124+ enterprise_action_kit_project_url : str = ENTERPRISE_ACTION_KIT_PROJECT_URL ,
125+ enterprise_action_kit_project_id : str = ENTERPRISE_ACTION_KIT_PROJECT_ID ,
126+ ):
108127 """Initialize the adapter with an enterprise action token."""
109128 if not enterprise_action_token :
110129 raise ValueError ("enterprise_action_token is required" )
111130
112131 self .enterprise_action_token = enterprise_action_token
113132 self ._actions_schema = {}
114133 self ._tools = None
134+ self .enterprise_action_kit_project_id = enterprise_action_kit_project_id
135+ self .enterprise_action_kit_project_url = enterprise_action_kit_project_url
115136
116137 def tools (self ) -> List [BaseTool ]:
117138 """Get the list of tools created from enterprise actions.
@@ -127,7 +148,7 @@ def tools(self) -> List[BaseTool]:
127148 def _fetch_actions (self ):
128149 """Fetch available actions from the API."""
129150 try :
130- actions_url = f"https://worker-actionkit.tools.crewai.com/projects/ { ENTERPRISE_ACTION_KIT_PROJECT_ID } /actions"
151+ actions_url = f"{ self . enterprise_action_kit_project_url } / { self . enterprise_action_kit_project_id } /actions"
131152 headers = {"Authorization" : f"Bearer { self .enterprise_action_token } " }
132153 params = {"format" : "json_schema" }
133154
@@ -189,6 +210,8 @@ def _create_tools(self):
189210 action_name = action_name ,
190211 action_schema = action_schema ,
191212 enterprise_action_token = self .enterprise_action_token ,
213+ enterprise_action_kit_project_id = self .enterprise_action_kit_project_id ,
214+ enterprise_action_kit_project_url = self .enterprise_action_kit_project_url ,
192215 )
193216
194217 tools .append (tool )
0 commit comments