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.py index 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: str action: str | None - connection_id: UUID | None + connection_id: UUID | str | None @classmethod def 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 | None app_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 = None if 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 = None return 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: str action: str - connection_id: UUID | None + connection_id: UUID | str | None description: str parameters: 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.py index 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.json index 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" },