Skip to content
This repository was archived by the owner on Nov 10, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 27 additions & 4 deletions crewai_tools/adapters/enterprise_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
import json
from crewai.tools import BaseTool


# DEFAULTS
ENTERPRISE_ACTION_KIT_PROJECT_ID = "dd525517-df22-49d2-a69e-6a0eed211166"
ENTERPRISE_ACTION_KIT_PROJECT_URL = "https://worker-actionkit.tools.crewai.com/projects"


class EnterpriseActionTool(BaseTool):
Expand All @@ -18,6 +19,12 @@ class EnterpriseActionTool(BaseTool):
action_schema: Dict[str, Any] = Field(
default={}, description="The schema of the action"
)
enterprise_action_kit_project_id: str = Field(
default=ENTERPRISE_ACTION_KIT_PROJECT_ID, description="The project id"
)
enterprise_action_kit_project_url: str = Field(
default=ENTERPRISE_ACTION_KIT_PROJECT_URL, description="The project url"
)

def __init__(
self,
Expand All @@ -26,6 +33,8 @@ def __init__(
enterprise_action_token: str,
action_name: str,
action_schema: Dict[str, Any],
enterprise_action_kit_project_url: str = ENTERPRISE_ACTION_KIT_PROJECT_URL,
enterprise_action_kit_project_id: str = ENTERPRISE_ACTION_KIT_PROJECT_ID,
):
schema_props = (
action_schema.get("function", {})
Expand Down Expand Up @@ -74,12 +83,17 @@ def __init__(
self.action_name = action_name
self.action_schema = action_schema

if enterprise_action_kit_project_id is not None:
self.enterprise_action_kit_project_id = enterprise_action_kit_project_id
if enterprise_action_kit_project_url is not None:
self.enterprise_action_kit_project_url = enterprise_action_kit_project_url

def _run(self, **kwargs) -> str:
"""Execute the specific enterprise action with validated parameters."""
try:
params = {k: v for k, v in kwargs.items() if v is not None}

api_url = f"https://worker-actionkit.tools.crewai.com/projects/{ENTERPRISE_ACTION_KIT_PROJECT_ID}/actions"
api_url = f"{self.enterprise_action_kit_project_url}/{self.enterprise_action_kit_project_id}/actions"
headers = {
"Authorization": f"Bearer {self.enterprise_action_token}",
"Content-Type": "application/json",
Expand All @@ -104,14 +118,21 @@ def _run(self, **kwargs) -> str:
class EnterpriseActionKitToolAdapter:
"""Adapter that creates BaseTool instances for enterprise actions."""

def __init__(self, enterprise_action_token: str):
def __init__(
self,
enterprise_action_token: str,
enterprise_action_kit_project_url: str = ENTERPRISE_ACTION_KIT_PROJECT_URL,
enterprise_action_kit_project_id: str = ENTERPRISE_ACTION_KIT_PROJECT_ID,
):
"""Initialize the adapter with an enterprise action token."""
if not enterprise_action_token:
raise ValueError("enterprise_action_token is required")

self.enterprise_action_token = enterprise_action_token
self._actions_schema = {}
self._tools = None
self.enterprise_action_kit_project_id = enterprise_action_kit_project_id
self.enterprise_action_kit_project_url = enterprise_action_kit_project_url

def tools(self) -> List[BaseTool]:
"""Get the list of tools created from enterprise actions.
Expand All @@ -127,7 +148,7 @@ def tools(self) -> List[BaseTool]:
def _fetch_actions(self):
"""Fetch available actions from the API."""
try:
actions_url = f"https://worker-actionkit.tools.crewai.com/projects/{ENTERPRISE_ACTION_KIT_PROJECT_ID}/actions"
actions_url = f"{self.enterprise_action_kit_project_url}/{self.enterprise_action_kit_project_id}/actions"
headers = {"Authorization": f"Bearer {self.enterprise_action_token}"}
params = {"format": "json_schema"}

Expand Down Expand Up @@ -189,6 +210,8 @@ def _create_tools(self):
action_name=action_name,
action_schema=action_schema,
enterprise_action_token=self.enterprise_action_token,
enterprise_action_kit_project_id=self.enterprise_action_kit_project_id,
enterprise_action_kit_project_url=self.enterprise_action_kit_project_url,
)

tools.append(tool)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@

def CrewaiEnterpriseTools(
enterprise_token: t.Optional[str] = None,
actions_list: t.Optional[t.List[str]] = None
actions_list: t.Optional[t.List[str]] = None,
enterprise_action_kit_project_id: t.Optional[str] = None,
enterprise_action_kit_project_url: t.Optional[str] = None,
) -> t.List[BaseTool]:
"""Factory function that returns crewai enterprise tools.

Expand All @@ -30,7 +32,18 @@ def CrewaiEnterpriseTools(
"No enterprise token provided. Please provide a token or set the CREWAI_ENTEPRISE_TOOLS_TOKEN environment variable."
)

adapter = EnterpriseActionKitToolAdapter(enterprise_token)
adapter_kwargs = {"enterprise_action_token": enterprise_token}

if enterprise_action_kit_project_id is not None:
adapter_kwargs["enterprise_action_kit_project_id"] = (
enterprise_action_kit_project_id
)
if enterprise_action_kit_project_url is not None:
adapter_kwargs["enterprise_action_kit_project_url"] = (
enterprise_action_kit_project_url
)

adapter = EnterpriseActionKitToolAdapter(**adapter_kwargs)
all_tools = adapter.tools()

if actions_list is None:
Expand Down
Loading