refactor: 重构 Agent 模块为 AgentScope,删除旧版 CrewAI/LiteLLM 实现

This commit is contained in:
qzl
2026-03-11 20:51:56 +08:00
parent 177ed616bf
commit 145e3dc615
149 changed files with 5120 additions and 11356 deletions
@@ -63,6 +63,12 @@ class ShareRepo:
return self._item
return None
async def get_subscription(self, item_id: UUID, subscriber_id: UUID) -> None:
return None
async def create_subscription(self, data: dict[str, object]) -> None:
return None
class AuthGatewayStub:
async def get_user_by_email(self, email: str) -> UserByEmailResponse:
@@ -74,6 +80,44 @@ class AuthGatewayStub:
)
class InboxRepoStub:
async def create(self, data: dict[str, object]) -> InboxMessage:
return InboxMessage(
id=uuid4(),
recipient_id=UUID("00000000-0000-0000-0000-000000000222"),
sender_id=UUID("00000000-0000-0000-0000-000000000001"),
message_type=InboxMessageType.CALENDAR,
schedule_item_id=uuid4(),
content='{"type": "invite", "permission": 1, "action": "pending"}',
created_by=UUID("00000000-0000-0000-0000-000000000001"),
)
async def get_by_id(
self, message_id: UUID, recipient_id: UUID
) -> InboxMessage | None:
return None
async def list_by_recipient(
self, recipient_id: UUID, is_read: bool | None = None
) -> list[InboxMessage]:
return []
async def mark_as_read(
self, message_id: UUID, recipient_id: UUID
) -> InboxMessage | None:
return None
async def get_pending_calendar_invite(
self, schedule_item_id: UUID, recipient_id: UUID
) -> InboxMessage | None:
return None
async def get_calendar_invite(
self, schedule_item_id: UUID, recipient_id: UUID
) -> InboxMessage | None:
return None
class AuthGatewayInvalidIdStub:
async def get_user_by_email(self, email: str) -> UserByEmailResponse:
return UserByEmailResponse(
@@ -97,6 +141,7 @@ async def test_share_forbidden_when_not_owner() -> None:
session=AsyncMock(),
current_user=CurrentUser(id=requester_id),
auth_gateway=AuthGatewayStub(),
inbox_repository=InboxRepoStub(),
)
with pytest.raises(HTTPException) as exc_info:
@@ -127,6 +172,7 @@ async def test_share_success_creates_calendar_invitation_message() -> None:
session=session,
current_user=CurrentUser(id=owner_id),
auth_gateway=AuthGatewayStub(),
inbox_repository=InboxRepoStub(),
)
result = await service.share(
@@ -146,7 +192,7 @@ async def test_share_success_creates_calendar_invitation_message() -> None:
assert message.sender_id == owner_id
assert message.schedule_item_id == item_id
assert message.message_type == InboxMessageType.CALENDAR
assert message.content == '{"permission": 5}'
assert message.content == '{"type": "invite", "permission": 5, "action": "pending"}'
session.commit.assert_awaited_once()
@@ -158,6 +204,7 @@ async def test_share_returns_not_found_when_item_missing() -> None:
session=AsyncMock(),
current_user=CurrentUser(id=requester_id),
auth_gateway=AuthGatewayStub(),
inbox_repository=InboxRepoStub(),
)
with pytest.raises(HTTPException) as exc_info:
@@ -187,6 +234,7 @@ async def test_share_invalid_auth_user_id_returns_503() -> None:
session=session,
current_user=CurrentUser(id=owner_id),
auth_gateway=AuthGatewayInvalidIdStub(),
inbox_repository=InboxRepoStub(),
)
with pytest.raises(HTTPException) as exc_info:
@@ -219,6 +267,7 @@ async def test_share_sqlalchemy_error_rolls_back() -> None:
session=session,
current_user=CurrentUser(id=owner_id),
auth_gateway=AuthGatewayStub(),
inbox_repository=InboxRepoStub(),
)
with pytest.raises(HTTPException) as exc_info: