mirror of
https://github.com/crewAIInc/crewAI.git
synced 2025-12-31 03:38:30 +00:00
Compare commits
5 Commits
gl/chore/a
...
devin/1752
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
352b213f7f | ||
|
|
07f4e47bb6 | ||
|
|
20cdc92142 | ||
|
|
a6e60a5d42 | ||
|
|
7b0f3aabd9 |
@@ -47,7 +47,7 @@ Documentation = "https://docs.crewai.com"
|
||||
Repository = "https://github.com/crewAIInc/crewAI"
|
||||
|
||||
[project.optional-dependencies]
|
||||
tools = ["crewai-tools~=0.49.0"]
|
||||
tools = ["crewai-tools~=0.51.0"]
|
||||
embeddings = [
|
||||
"tiktoken~=0.8.0"
|
||||
]
|
||||
|
||||
@@ -54,7 +54,7 @@ def _track_install_async():
|
||||
|
||||
_track_install_async()
|
||||
|
||||
__version__ = "0.140.0"
|
||||
__version__ = "0.141.0"
|
||||
__all__ = [
|
||||
"Agent",
|
||||
"Crew",
|
||||
|
||||
@@ -5,4 +5,4 @@ AUTH0_AUDIENCE = "https://crewai.us.auth0.com/api/v2/"
|
||||
|
||||
WORKOS_DOMAIN = "login.crewai.com"
|
||||
WORKOS_CLI_CONNECT_APP_ID = "client_01JYT06R59SP0NXYGD994NFXXX"
|
||||
WORKOS_ENVIRONMENT_ID = "client_01JNJQWB4HG8T5980R5VHP057C"
|
||||
WORKOS_ENVIRONMENT_ID = "client_01JNJQWBJ4SPFN3SWJM5T7BDG8"
|
||||
|
||||
@@ -30,6 +30,9 @@ def validate_jwt_token(
|
||||
jwk_client = PyJWKClient(jwks_url)
|
||||
signing_key = jwk_client.get_signing_key_from_jwt(jwt_token)
|
||||
|
||||
_unverified_decoded_token = jwt.decode(
|
||||
jwt_token, options={"verify_signature": False}
|
||||
)
|
||||
decoded_token = jwt.decode(
|
||||
jwt_token,
|
||||
signing_key.key,
|
||||
@@ -49,9 +52,15 @@ def validate_jwt_token(
|
||||
except jwt.ExpiredSignatureError:
|
||||
raise Exception("Token has expired.")
|
||||
except jwt.InvalidAudienceError:
|
||||
raise Exception(f"Invalid token audience. Expected: '{audience}'")
|
||||
actual_audience = _unverified_decoded_token.get("aud", "[no audience found]")
|
||||
raise Exception(
|
||||
f"Invalid token audience. Got: '{actual_audience}'. Expected: '{audience}'"
|
||||
)
|
||||
except jwt.InvalidIssuerError:
|
||||
raise Exception(f"Invalid token issuer. Expected: '{issuer}'")
|
||||
actual_issuer = _unverified_decoded_token.get("iss", "[no issuer found]")
|
||||
raise Exception(
|
||||
f"Invalid token issuer. Got: '{actual_issuer}'. Expected: '{issuer}'"
|
||||
)
|
||||
except jwt.MissingRequiredClaimError as e:
|
||||
raise Exception(f"Token is missing required claims: {str(e)}")
|
||||
except jwt.exceptions.PyJWKClientError as e:
|
||||
|
||||
@@ -5,7 +5,7 @@ description = "{{name}} using crewAI"
|
||||
authors = [{ name = "Your Name", email = "you@example.com" }]
|
||||
requires-python = ">=3.10,<3.14"
|
||||
dependencies = [
|
||||
"crewai[tools]>=0.140.0,<1.0.0"
|
||||
"crewai[tools]>=0.141.0,<1.0.0"
|
||||
]
|
||||
|
||||
[project.scripts]
|
||||
|
||||
@@ -5,7 +5,7 @@ description = "{{name}} using crewAI"
|
||||
authors = [{ name = "Your Name", email = "you@example.com" }]
|
||||
requires-python = ">=3.10,<3.14"
|
||||
dependencies = [
|
||||
"crewai[tools]>=0.140.0,<1.0.0",
|
||||
"crewai[tools]>=0.141.0,<1.0.0",
|
||||
]
|
||||
|
||||
[project.scripts]
|
||||
|
||||
@@ -5,7 +5,7 @@ description = "Power up your crews with {{folder_name}}"
|
||||
readme = "README.md"
|
||||
requires-python = ">=3.10,<3.14"
|
||||
dependencies = [
|
||||
"crewai[tools]>=0.140.0"
|
||||
"crewai[tools]>=0.141.0"
|
||||
]
|
||||
|
||||
[tool.crewai]
|
||||
|
||||
@@ -120,6 +120,7 @@ class EventListener(BaseEventListener):
|
||||
"completed",
|
||||
final_string_output,
|
||||
)
|
||||
self.formatter.stop_live()
|
||||
|
||||
@crewai_event_bus.on(CrewKickoffFailedEvent)
|
||||
def on_crew_failed(source, event: CrewKickoffFailedEvent):
|
||||
@@ -262,6 +263,7 @@ class EventListener(BaseEventListener):
|
||||
self.formatter.update_flow_status(
|
||||
self.formatter.current_flow_tree, event.flow_name, source.flow_id
|
||||
)
|
||||
self.formatter.stop_live()
|
||||
|
||||
@crewai_event_bus.on(MethodExecutionStartedEvent)
|
||||
def on_method_execution_started(source, event: MethodExecutionStartedEvent):
|
||||
|
||||
@@ -1753,3 +1753,9 @@ class ConsoleFormatter:
|
||||
Attempts=f"{retry_count + 1}",
|
||||
)
|
||||
self.print_panel(content, "🛡️ Guardrail Failed", "red")
|
||||
|
||||
def stop_live(self) -> None:
|
||||
"""Stop and clear any active Live session to restore normal terminal output."""
|
||||
if self._live:
|
||||
self._live.stop()
|
||||
self._live = None
|
||||
|
||||
@@ -27,7 +27,7 @@ class TestValidateToken(unittest.TestCase):
|
||||
audience="app_id_xxxx",
|
||||
)
|
||||
|
||||
mock_jwt.decode.assert_called_once_with(
|
||||
mock_jwt.decode.assert_called_with(
|
||||
"aaaaa.bbbbbb.cccccc",
|
||||
"mock_signing_key",
|
||||
algorithms=["RS256"],
|
||||
|
||||
54
tests/test_rich_live_cleanup.py
Normal file
54
tests/test_rich_live_cleanup.py
Normal file
@@ -0,0 +1,54 @@
|
||||
from unittest.mock import patch
|
||||
from rich.tree import Tree
|
||||
from crewai.utilities.events.utils.console_formatter import ConsoleFormatter
|
||||
from crewai.utilities.events.event_listener import EventListener
|
||||
|
||||
|
||||
class TestRichLiveCleanup:
|
||||
"""Test that Rich Live sessions are properly cleaned up after CrewAI operations."""
|
||||
|
||||
def test_logging_works_after_tree_rendering(self):
|
||||
"""Test that logging output appears after tree rendering with proper cleanup."""
|
||||
formatter = ConsoleFormatter()
|
||||
|
||||
tree = Tree("Test Flow")
|
||||
formatter.print(tree)
|
||||
|
||||
assert formatter._live is not None
|
||||
|
||||
formatter.stop_live()
|
||||
|
||||
assert formatter._live is None
|
||||
|
||||
with patch.object(formatter.console, 'print') as mock_print:
|
||||
formatter.print("This should appear immediately")
|
||||
mock_print.assert_called_once_with("This should appear immediately")
|
||||
|
||||
def test_event_listener_cleanup_integration(self):
|
||||
"""Test that EventListener properly cleans up Live sessions."""
|
||||
event_listener = EventListener()
|
||||
formatter = event_listener.formatter
|
||||
|
||||
tree = Tree("Test Crew")
|
||||
formatter.print(tree)
|
||||
assert formatter._live is not None
|
||||
|
||||
formatter.stop_live()
|
||||
assert formatter._live is None
|
||||
|
||||
def test_stop_live_restores_normal_output(self):
|
||||
"""Test that stop_live properly restores normal console output behavior."""
|
||||
formatter = ConsoleFormatter()
|
||||
|
||||
tree = Tree("Test Tree")
|
||||
formatter.print(tree)
|
||||
|
||||
assert formatter._live is not None
|
||||
|
||||
formatter.stop_live()
|
||||
|
||||
assert formatter._live is None
|
||||
|
||||
with patch.object(formatter.console, 'print') as mock_print:
|
||||
formatter.print("Normal output")
|
||||
mock_print.assert_called_once_with("Normal output")
|
||||
@@ -114,3 +114,38 @@ class TestConsoleFormatterPauseResume:
|
||||
|
||||
assert hasattr(formatter, '_live_paused')
|
||||
assert not formatter._live_paused
|
||||
|
||||
def test_stop_live_with_active_session(self):
|
||||
"""Test stopping Live session when one is active."""
|
||||
formatter = ConsoleFormatter()
|
||||
|
||||
mock_live = MagicMock(spec=Live)
|
||||
formatter._live = mock_live
|
||||
|
||||
formatter.stop_live()
|
||||
|
||||
mock_live.stop.assert_called_once()
|
||||
assert formatter._live is None
|
||||
|
||||
def test_stop_live_with_no_session(self):
|
||||
"""Test stopping Live session when none exists."""
|
||||
formatter = ConsoleFormatter()
|
||||
|
||||
formatter._live = None
|
||||
|
||||
formatter.stop_live()
|
||||
|
||||
assert formatter._live is None
|
||||
|
||||
def test_stop_live_multiple_calls(self):
|
||||
"""Test multiple calls to stop_live are safe."""
|
||||
formatter = ConsoleFormatter()
|
||||
|
||||
mock_live = MagicMock(spec=Live)
|
||||
formatter._live = mock_live
|
||||
|
||||
formatter.stop_live()
|
||||
formatter.stop_live()
|
||||
|
||||
mock_live.stop.assert_called_once()
|
||||
assert formatter._live is None
|
||||
|
||||
Reference in New Issue
Block a user