mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-10-12 02:12:31 +00:00
Support aliases as connection identifiers (#7519)
* Support private app connections App selectors only accepted UUID connection identifiers, so apps=["github@private"] failed validation. Accept connection aliases and route them through Clipper like UUID identifiers. This supports private connections and future platform aliases without client releases. * chore: update tool specifications --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
This commit is contained in:
co-authored by
github-actions[bot]
parent
5990ead5ec
commit
64ab0112bd
+11
-7
@@ -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]
|
||||
|
||||
|
||||
@@ -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",
|
||||
{
|
||||
|
||||
@@ -17279,9 +17279,11 @@
|
||||
{
|
||||
"enum": [
|
||||
"none",
|
||||
"minimal",
|
||||
"low",
|
||||
"medium",
|
||||
"high"
|
||||
"high",
|
||||
"xhigh"
|
||||
],
|
||||
"type": "string"
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user