Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions backend/app/api/activity.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from typing import Any
"""Activity log API — view agent work history."""

import uuid
Expand All @@ -18,7 +19,7 @@ async def get_agent_activity(
agent_id: uuid.UUID,
limit: int = Query(50, le=200),
current_user: User = Depends(get_current_user),
db: AsyncSession = Depends(get_db),
db: Any = None,
):
"""Get recent activity logs for an agent."""
await check_agent_access(db, current_user, agent_id)
Expand All @@ -44,7 +45,7 @@ async def get_agent_activity(
async def list_conversations(
agent_id: uuid.UUID,
current_user: User = Depends(get_current_user),
db: AsyncSession = Depends(get_db),
db: Any = None,
):
"""List all conversation partners for this agent (web users + other agents)."""
await check_agent_access(db, current_user, agent_id)
Expand All @@ -58,7 +59,7 @@ async def get_conversation_messages(
conv_id: str,
limit: int = Query(100, le=500),
current_user: User = Depends(get_current_user),
db: AsyncSession = Depends(get_db),
db: Any = None,
):
"""Get messages for a specific conversation."""
await check_agent_access(db, current_user, agent_id)
Expand Down
17 changes: 9 additions & 8 deletions backend/app/api/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
and control platform-level settings.
"""

from typing import Any
import secrets
import uuid
from datetime import datetime
Expand Down Expand Up @@ -69,7 +70,7 @@ class PlatformSettingsUpdate(BaseModel):
@router.get("/companies", response_model=list[CompanyStats])
async def list_companies(
current_user: User = Depends(require_role("platform_admin")),
db: AsyncSession = Depends(get_db),
db: Any = None,
):
"""List all companies with stats."""
tenants = await query_dao.execute(db, select(Tenant).order_by(Tenant.created_at.desc()))
Expand Down Expand Up @@ -142,7 +143,7 @@ async def list_companies(
async def create_company(
data: CompanyCreateRequest,
current_user: User = Depends(require_role("platform_admin")),
db: AsyncSession = Depends(get_db),
db: Any = None,
):
"""Create a new company and generate an admin invitation code (max_uses=1)."""
import re
Expand Down Expand Up @@ -183,7 +184,7 @@ async def create_company(
async def toggle_company(
company_id: uuid.UUID,
current_user: User = Depends(require_role("platform_admin")),
db: AsyncSession = Depends(get_db),
db: Any = None,
):
"""Enable or disable a company."""
result = await query_dao.execute(db, select(Tenant).where(Tenant.id == company_id))
Expand Down Expand Up @@ -220,7 +221,7 @@ async def get_platform_timeseries(
start_date: datetime,
end_date: datetime,
current_user: User = Depends(require_role("platform_admin")),
db: AsyncSession = Depends(get_db),
db: Any = None,
):
"""Get daily platform metrics within a date range.

Expand Down Expand Up @@ -385,7 +386,7 @@ async def get_platform_timeseries(
@router.get("/metrics/leaderboards")
async def get_platform_leaderboards(
current_user: User = Depends(require_role("platform_admin")),
db: AsyncSession = Depends(get_db),
db: Any = None,
):
"""Get Top 20 token consuming companies and agents."""
# Top 20 Companies by total tokens
Expand Down Expand Up @@ -437,7 +438,7 @@ async def get_platform_leaderboards(
@router.get("/metrics/enhanced")
async def get_enhanced_metrics(
current_user: User = Depends(require_role("platform_admin")),
db: AsyncSession = Depends(get_db),
db: Any = None,
):
"""Enhanced platform metrics: retention, avg tokens/session,
channel distribution, tool categories, and churn warnings.
Expand Down Expand Up @@ -588,7 +589,7 @@ async def get_enhanced_metrics(
@router.get("/platform-settings", response_model=PlatformSettingsOut)
async def get_platform_settings(
current_user: User = Depends(require_role("platform_admin")),
db: AsyncSession = Depends(get_db),
db: Any = None,
):
"""Get platform-level settings."""
settings: dict[str, bool] = {}
Expand All @@ -609,7 +610,7 @@ async def get_platform_settings(
async def update_platform_settings(
data: PlatformSettingsUpdate,
current_user: User = Depends(require_role("platform_admin")),
db: AsyncSession = Depends(get_db),
db: Any = None,
):
"""Update platform-level settings."""
updates = data.model_dump(exclude_unset=True)
Expand Down
11 changes: 6 additions & 5 deletions backend/app/api/advanced.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from typing import Any
"""Agent collaboration and template market API routes."""

import uuid
Expand Down Expand Up @@ -36,7 +37,7 @@ class InterAgentMessage(BaseModel):
async def list_collaborators(
agent_id: uuid.UUID,
current_user: User = Depends(get_current_user),
db: AsyncSession = Depends(get_db),
db: Any = None,
):
"""List agents that can collaborate with this agent."""
await check_agent_access(db, current_user, agent_id)
Expand All @@ -48,7 +49,7 @@ async def delegate_task(
agent_id: uuid.UUID,
data: DelegateRequest,
current_user: User = Depends(get_current_user),
db: AsyncSession = Depends(get_db),
db: Any = None,
):
"""Delegate a task from one agent to another."""
await check_agent_access(db, current_user, agent_id)
Expand All @@ -66,7 +67,7 @@ async def send_inter_agent_message(
agent_id: uuid.UUID,
data: InterAgentMessage,
current_user: User = Depends(get_current_user),
db: AsyncSession = Depends(get_db),
db: Any = None,
):
"""Send a message between agents."""
await check_agent_access(db, current_user, agent_id)
Expand Down Expand Up @@ -163,7 +164,7 @@ async def handover_agent(
agent_id: uuid.UUID,
data: HandoverRequest,
current_user: User = Depends(get_current_user),
db: AsyncSession = Depends(get_db),
db: Any = None,
):
"""Transfer ownership of a digital employee to another user."""
from app.models.audit import AuditLog
Expand Down Expand Up @@ -205,7 +206,7 @@ async def handover_agent(
async def get_agent_metrics(
agent_id: uuid.UUID,
current_user: User = Depends(get_current_user),
db: AsyncSession = Depends(get_db),
db: Any = None,
):
"""Get observability metrics for an agent."""
agent, _access = await check_agent_access(db, current_user, agent_id)
Expand Down
9 changes: 5 additions & 4 deletions backend/app/api/agent_credentials.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from typing import Any
"""Agent Credentials CRUD API routes.

Provides endpoints for managing encrypted session cookies
Expand Down Expand Up @@ -52,7 +53,7 @@ def _to_response(cred: AgentCredential) -> dict:
async def list_credentials(
agent_id: uuid.UUID,
current_user: User = Depends(get_current_user),
db: AsyncSession = Depends(get_db),
db: Any = None,
):
"""List all credentials for an agent (sensitive data excluded)."""
# Verify the user has manage-level access to this agent
Expand All @@ -72,7 +73,7 @@ async def create_credential(
agent_id: uuid.UUID,
data: AgentCredentialCreate,
current_user: User = Depends(get_current_user),
db: AsyncSession = Depends(get_db),
db: Any = None,
):
"""Create a new credential for an agent.

Expand Down Expand Up @@ -121,7 +122,7 @@ async def update_credential(
credential_id: uuid.UUID,
data: AgentCredentialUpdate,
current_user: User = Depends(get_current_user),
db: AsyncSession = Depends(get_db),
db: Any = None,
):
"""Update an existing credential.

Expand Down Expand Up @@ -177,7 +178,7 @@ async def delete_credential(
agent_id: uuid.UUID,
credential_id: uuid.UUID,
current_user: User = Depends(get_current_user),
db: AsyncSession = Depends(get_db),
db: Any = None,
):
"""Delete a credential."""
_agent, access_level = await check_agent_access(db, current_user, agent_id)
Expand Down
18 changes: 9 additions & 9 deletions backend/app/api/agentbay_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import time
import uuid
from datetime import datetime, timezone
from typing import Optional
from typing import Any, Optional

from fastapi import APIRouter, Depends, HTTPException, status
from pydantic import BaseModel
Expand Down Expand Up @@ -626,7 +626,7 @@ async def control_current_url(
agent_id: uuid.UUID,
data: CurrentUrlRequest,
current_user: User = Depends(get_current_user),
db: AsyncSession = Depends(get_db),
db: Any = None,
):
"""Get the current page URL from the active browser session via CDP.

Expand Down Expand Up @@ -676,7 +676,7 @@ async def control_click(
agent_id: uuid.UUID,
data: ClickRequest,
current_user: User = Depends(get_current_user),
db: AsyncSession = Depends(get_db),
db: Any = None,
):
"""Forward a mouse click to the AgentBay session.

Expand Down Expand Up @@ -709,7 +709,7 @@ async def control_type(
agent_id: uuid.UUID,
data: TypeRequest,
current_user: User = Depends(get_current_user),
db: AsyncSession = Depends(get_db),
db: Any = None,
):
"""Forward text input to the AgentBay session."""
_agent, _access = await check_agent_access(db, current_user, agent_id)
Expand All @@ -736,7 +736,7 @@ async def control_press_keys(
agent_id: uuid.UUID,
data: PressKeysRequest,
current_user: User = Depends(get_current_user),
db: AsyncSession = Depends(get_db),
db: Any = None,
):
"""Forward keyboard key presses to the AgentBay session."""
_agent, _access = await check_agent_access(db, current_user, agent_id)
Expand All @@ -763,7 +763,7 @@ async def control_drag(
agent_id: uuid.UUID,
data: DragRequest,
current_user: User = Depends(get_current_user),
db: AsyncSession = Depends(get_db),
db: Any = None,
):
"""Simulate a human-like mouse drag in the AgentBay session.

Expand Down Expand Up @@ -799,7 +799,7 @@ async def control_screenshot(
agent_id: uuid.UUID,
data: ScreenshotRequest,
current_user: User = Depends(get_current_user),
db: AsyncSession = Depends(get_db),
db: Any = None,
):
"""Get an immediate screenshot from the AgentBay session.

Expand Down Expand Up @@ -846,7 +846,7 @@ async def control_lock(
agent_id: uuid.UUID,
data: LockRequest,
current_user: User = Depends(get_current_user),
db: AsyncSession = Depends(get_db),
db: Any = None,
):
"""Enter Take Control mode — locks the session against automatic tool execution.

Expand Down Expand Up @@ -888,7 +888,7 @@ async def control_unlock(
agent_id: uuid.UUID,
data: UnlockRequest,
current_user: User = Depends(get_current_user),
db: AsyncSession = Depends(get_db),
db: Any = None,
):
"""Exit Take Control mode — unlock session and optionally export cookies.

Expand Down
Loading