feat: add secure agent and MCP extensions
This commit is contained in:
99
backend/apps/tools/schemas.py
Normal file
99
backend/apps/tools/schemas.py
Normal file
@@ -0,0 +1,99 @@
|
||||
from datetime import datetime
|
||||
from typing import Any
|
||||
from uuid import UUID
|
||||
|
||||
from ninja import Schema
|
||||
|
||||
|
||||
class ToolProviderIn(Schema):
|
||||
name: str
|
||||
provider_type: str = "mcp_http"
|
||||
base_url: str = ""
|
||||
token: str = ""
|
||||
enabled: bool = True
|
||||
timeout_seconds: int = 30
|
||||
|
||||
|
||||
class ToolProviderOut(Schema):
|
||||
id: int
|
||||
name: str
|
||||
provider_type: str
|
||||
base_url: str
|
||||
credential_set: bool
|
||||
enabled: bool
|
||||
timeout_seconds: int
|
||||
created_at: datetime
|
||||
updated_at: datetime
|
||||
|
||||
|
||||
class ToolProviderUpdateIn(Schema):
|
||||
name: str | None = None
|
||||
base_url: str | None = None
|
||||
token: str | None = None
|
||||
enabled: bool | None = None
|
||||
timeout_seconds: int | None = None
|
||||
|
||||
|
||||
class UnifiedToolOut(Schema):
|
||||
id: int
|
||||
code: str
|
||||
provider_id: int | None
|
||||
external_name: str
|
||||
name: str
|
||||
description: str
|
||||
input_schema: dict[str, Any]
|
||||
risk_level: str
|
||||
enabled: bool
|
||||
synced_at: datetime | None
|
||||
|
||||
|
||||
class UnifiedToolUpdateIn(Schema):
|
||||
name: str | None = None
|
||||
description: str | None = None
|
||||
risk_level: str | None = None
|
||||
enabled: bool | None = None
|
||||
|
||||
|
||||
class ToolAuthorizationIn(Schema):
|
||||
principal_type: str
|
||||
principal_id: int
|
||||
allowed: bool = True
|
||||
|
||||
|
||||
class ToolAuthorizationOut(Schema):
|
||||
id: int
|
||||
tool_id: int
|
||||
principal_type: str
|
||||
principal_id: int
|
||||
allowed: bool
|
||||
|
||||
|
||||
class ToolCallIn(Schema):
|
||||
tool_code: str
|
||||
input: dict[str, Any]
|
||||
agent_run_id: UUID | None = None
|
||||
idempotency_key: str = ""
|
||||
|
||||
|
||||
class ToolCallOut(Schema):
|
||||
public_id: UUID
|
||||
tool_code: str
|
||||
requested_by_id: int | None
|
||||
requested_by_name: str
|
||||
status: str
|
||||
input_payload: dict[str, Any]
|
||||
output_payload: Any | None
|
||||
authorization_snapshot: dict[str, Any]
|
||||
risk_snapshot: dict[str, Any]
|
||||
error_code: str
|
||||
error_message: str
|
||||
confirmation_status: str | None
|
||||
confirmation_reason: str
|
||||
created_at: datetime
|
||||
started_at: datetime | None
|
||||
finished_at: datetime | None
|
||||
|
||||
|
||||
class ToolConfirmationIn(Schema):
|
||||
decision: str
|
||||
reason: str = ""
|
||||
Reference in New Issue
Block a user