Framework for orchestrating role-playing, autonomous AI agents. By fostering collaborative intelligence, CrewAI empowers agents to work together seamlessly, tackling complex tasks.
Support aliases as connection identifiers (#7519)
Vinicius Brasil64ab0112bd3e
diff --git a/lib/crewai-tools/src/crewai_tools/tools/crewai_platform_tools/integrations_client.py b/lib/crewai-tools/src/crewai_tools/tools/crewai_platform_tools/integrations_client.pyindex 3d96c2540..af6e78adc 100644--- a/lib/crewai-tools/src/crewai_tools/tools/crewai_platform_tools/integrations_client.py+++ b/lib/crewai-tools/src/crewai_tools/tools/crewai_platform_tools/integrations_client.py@@ -23,11 +23,11 @@ class ApplicationSelector:app: straction: str | None- connection_id: UUID | None+ connection_id: UUID | str | None@classmethoddef from_string(cls, value: str) -> ApplicationSelector:- """Parse the ``application[/action][@connection_uuid]`` syntax.+ """Parse the ``application[/action][@connection_uuid|private]`` syntax.Raises:ValueError: If the selector does not follow the supported syntax.@@ -40,6 +40,7 @@ class ApplicationSelector:"connection ID must be the last segment")+ connection_id: UUID | str | Noneapp_and_action, connection_separator, connection_id = value.partition("@")app, action_separator, action = app_and_action.partition("/")@@ -56,20 +57,23 @@ class ApplicationSelector:f"Invalid application selector {value!r}: connection ID cannot be empty")- parsed_connection_id = Noneif connection_id:+ is_alias = connection_id.isascii() and connection_id.isalpha()try:- parsed_connection_id = UUID(connection_id)+ if not is_alias:+ connection_id = UUID(connection_id)except ValueError as error:raise ValueError(f"Invalid application selector {value!r}: "- "connection ID must be a valid UUID"+ "connection ID must be a valid UUID or a valid alias (e.g. private)") from error+ else:+ connection_id = Nonereturn cls(app=app,action=action if action_separator else None,- connection_id=parsed_connection_id,+ connection_id=connection_id,)@@ -79,7 +83,7 @@ class ToolInfo:app: straction: str- connection_id: UUID | None+ connection_id: UUID | str | Nonedescription: strparameters: dict[str, Any]diff --git a/lib/crewai-tools/tests/tools/crewai_platform_tools/test_crewai_platform_tools.py b/lib/crewai-tools/tests/tools/crewai_platform_tools/test_crewai_platform_tools.pyindex f3013675f..7961f106e 100644--- a/lib/crewai-tools/tests/tools/crewai_platform_tools/test_crewai_platform_tools.py+++ b/lib/crewai-tools/tests/tools/crewai_platform_tools/test_crewai_platform_tools.py@@ -262,6 +262,31 @@ class TestCrewaiPlatformTools(unittest.TestCase):}assert result == '{\n "issue": 42\n}'+ @patch.dict(+ "os.environ",+ {+ "CREWAI_PLATFORM_INTEGRATION_TOKEN": "test_token",+ "CREWAI_PLUS_URL": "https://platform.example.test/",+ },+ clear=True,+ )+ @patch(+ "crewai_tools.tools.crewai_platform_tools.integrations_client.requests.get"+ )+ def test_private_connection_selects_clipper_api(self, mock_get):+ response = Mock()+ response.raise_for_status.return_value = None+ response.json.return_value = {"data": []}+ mock_get.return_value = response++ tools = CrewaiPlatformTools(apps=["github@private"])++ assert tools == []+ assert mock_get.call_args.args[0].endswith(+ "/clipper/v1/applications/github/tools"+ )+ assert mock_get.call_args.kwargs["params"] == {"connection_id": "private"}+@patch.dict("os.environ",{diff --git a/lib/crewai-tools/tool.specs.json b/lib/crewai-tools/tool.specs.jsonindex c82d71a65..88d3f6e08 100644--- a/lib/crewai-tools/tool.specs.json+++ b/lib/crewai-tools/tool.specs.json@@ -17279,9 +17279,11 @@{"enum": ["none",+ "minimal","low","medium",- "high"+ "high",+ "xhigh"],"type": "string"},