fix: resolve mypy errors after merge

- Re-export get_crewai_version explicitly so consumers stop getting
  attr-defined.
- Drop the telemetry call in TemplateCommand.add_template; the
  standalone CLI's BaseCommand intentionally has no _telemetry, matching
  the choice already made for DeployCommand.
- Add the user_identifier kwarg to crewai_cli's
  PlusAPI.login_to_tool_repository so tools.main.login keeps working
  and the surface matches crewai.plus_api.
- Update the lib/cli login tests for the new json={} payload.
This commit is contained in:
Greyson Lalonde
2026-05-05 03:50:09 +08:00
parent e8bf900008
commit 778130cfc7
4 changed files with 10 additions and 7 deletions

View File

@@ -48,8 +48,13 @@ class PlusAPI:
with httpx.Client(trust_env=False, verify=verify) as client:
return client.request(method, url, headers=self.headers, **kwargs)
def login_to_tool_repository(self) -> httpx.Response:
return self._make_request("POST", f"{self.TOOLS_RESOURCE}/login")
def login_to_tool_repository(
self, user_identifier: str | None = None
) -> httpx.Response:
payload = {}
if user_identifier:
payload["user_identifier"] = user_identifier
return self._make_request("POST", f"{self.TOOLS_RESOURCE}/login", json=payload)
def get_tool(self, handle: str) -> httpx.Response:
return self._make_request("GET", f"{self.TOOLS_RESOURCE}/{handle}")

View File

@@ -131,8 +131,6 @@ class TemplateCommand(BaseCommand):
zip_bytes = self._download_zip(repo_name)
self._extract_zip(zip_bytes, dest)
self._telemetry.template_installed_span(repo_name.removeprefix(TEMPLATE_PREFIX))
console.print(
f"\n [green]\u2713[/green] Installed template [bold white]{folder_name}[/bold white]"
f" [dim](source: github.com/{GITHUB_ORG}/{repo_name})[/dim]\n"

View File

@@ -10,7 +10,7 @@ from urllib import request
from urllib.error import URLError
import appdirs
from crewai.utilities.version import get_crewai_version
from crewai.utilities.version import get_crewai_version as get_crewai_version
from packaging.version import InvalidVersion, Version, parse

View File

@@ -28,7 +28,7 @@ class TestPlusAPI(unittest.TestCase):
response = self.api.login_to_tool_repository()
mock_make_request.assert_called_once_with(
"POST", "/crewai_plus/api/v1/tools/login"
"POST", "/crewai_plus/api/v1/tools/login", json={}
)
self.assertEqual(response, mock_response)
@@ -67,7 +67,7 @@ class TestPlusAPI(unittest.TestCase):
response = self.api.login_to_tool_repository()
self.assert_request_with_org_id(
mock_client_instance, "POST", "/crewai_plus/api/v1/tools/login"
mock_client_instance, "POST", "/crewai_plus/api/v1/tools/login", json={}
)
self.assertEqual(response, mock_response)