feat: deliver agent foundation day 1

This commit is contained in:
caoxiaozhu
2026-05-11 03:51:24 +00:00
parent f738b6cdd4
commit b2beeaa136
54 changed files with 6747 additions and 1724 deletions

View File

@@ -0,0 +1,115 @@
from __future__ import annotations
from datetime import datetime
from typing import Any
from pydantic import BaseModel, ConfigDict, Field
from app.core.agent_enums import (
AgentAssetContentType,
AgentAssetDomain,
AgentAssetStatus,
AgentAssetType,
AgentReviewStatus,
)
class AgentAssetCreate(BaseModel):
asset_type: AgentAssetType
code: str = Field(min_length=1, max_length=100)
name: str = Field(min_length=1, max_length=200)
description: str = ""
domain: AgentAssetDomain
scenario_json: list[Any] = Field(default_factory=list)
owner: str = Field(min_length=1, max_length=100)
reviewer: str | None = Field(default=None, max_length=100)
status: AgentAssetStatus = AgentAssetStatus.DRAFT
config_json: dict[str, Any] = Field(default_factory=dict)
class AgentAssetUpdate(BaseModel):
name: str | None = Field(default=None, min_length=1, max_length=200)
description: str | None = None
domain: AgentAssetDomain | None = None
scenario_json: list[Any] | None = None
owner: str | None = Field(default=None, min_length=1, max_length=100)
reviewer: str | None = Field(default=None, max_length=100)
status: AgentAssetStatus | None = None
current_version: str | None = Field(default=None, max_length=30)
config_json: dict[str, Any] | None = None
class AgentAssetVersionCreate(BaseModel):
version: str = Field(min_length=1, max_length=30)
content: Any
content_type: AgentAssetContentType
change_note: str | None = None
created_by: str = Field(min_length=1, max_length=100)
class RuleMarkdownUpdate(BaseModel):
version: str = Field(min_length=1, max_length=30)
content: str
change_note: str | None = None
created_by: str = Field(min_length=1, max_length=100)
class AgentAssetReviewCreate(BaseModel):
version: str = Field(min_length=1, max_length=30)
reviewer: str = Field(min_length=1, max_length=100)
review_status: AgentReviewStatus
review_note: str | None = None
class AgentAssetReviewRead(BaseModel):
model_config = ConfigDict(from_attributes=True)
id: str
asset_id: str
version: str
reviewer: str
review_status: str
review_note: str | None
reviewed_at: datetime | None
created_at: datetime
class AgentAssetVersionRead(BaseModel):
model_config = ConfigDict(from_attributes=True)
id: str
asset_id: str
version: str
content: Any
content_type: str
change_note: str | None
created_by: str
created_at: datetime
is_current: bool = False
class AgentAssetListItem(BaseModel):
model_config = ConfigDict(from_attributes=True)
id: str
asset_type: str
code: str
name: str
description: str
domain: str
scenario_json: list[Any]
owner: str
reviewer: str | None
status: str
current_version: str | None
config_json: dict[str, Any]
created_at: datetime
updated_at: datetime
class AgentAssetRead(AgentAssetListItem):
current_version_content: Any | None = None
current_version_content_type: str | None = None
current_version_change_note: str | None = None
recent_versions: list[AgentAssetVersionRead] = Field(default_factory=list)
latest_review: AgentAssetReviewRead | None = None

View File

@@ -0,0 +1,61 @@
from __future__ import annotations
from datetime import datetime
from typing import Any
from pydantic import BaseModel, ConfigDict, Field
class AgentToolCallRead(BaseModel):
model_config = ConfigDict(from_attributes=True)
id: str
run_id: str
tool_type: str
tool_name: str
request_json: dict[str, Any]
response_json: dict[str, Any]
status: str
duration_ms: int
error_message: str | None
created_at: datetime
class SemanticParseRead(BaseModel):
model_config = ConfigDict(from_attributes=True)
id: str
run_id: str
user_id: str | None
raw_query: str
scenario: str
intent: str
entities_json: list[Any]
time_range_json: dict[str, Any]
metrics_json: list[Any]
constraints_json: list[Any]
risk_flags_json: list[Any]
permission_json: dict[str, Any]
confidence: float
created_at: datetime
class AgentRunRead(BaseModel):
model_config = ConfigDict(from_attributes=True)
id: str
run_id: str
agent: str
source: str
user_id: str | None
task_id: str | None
ontology_json: dict[str, Any]
route_json: dict[str, Any]
permission_level: str
status: str
result_summary: str | None
error_message: str | None
started_at: datetime
finished_at: datetime | None
tool_calls: list[AgentToolCallRead] = Field(default_factory=list)
semantic_parse: SemanticParseRead | None = None

View File

@@ -0,0 +1,20 @@
from __future__ import annotations
from datetime import datetime
from typing import Any
from pydantic import BaseModel, ConfigDict
class AuditLogRead(BaseModel):
model_config = ConfigDict(from_attributes=True)
id: str
actor: str
action: str
resource_type: str
resource_id: str
before_json: dict[str, Any] | None
after_json: dict[str, Any] | None
request_id: str
created_at: datetime