Files
ss-tools/backend/src/schemas/agent.py,cover
busya f75c15dbc6 test: massive coverage expansion — 15 new test modules + assistant tool fixes + orthogonal testing
- 10 translate plugin test files (100% coverage on 12 modules)
- assistant/handler tools: 85+ tests covering dispatch, registry, resolvers, routes, llm_planner, 13 tool handlers
- clean release: artifact_catalog_loader, mappers, approval, publication tests
- API routes: translate_helpers, validation_service extensions, datasets to 100%
- notifications: providers/service tests
- services: profile_preference_service
- docs/orthogonal-test-report.md — full speckit.tests audit
- Fixes: 3 git_base async mock failures, 4 assistant handler permission-check patches
- .gitignore: coverage artifacts
2026-06-15 15:38:59 +03:00

107 lines
3.5 KiB
Plaintext

# backend/src/schemas/agent.py
# #region Schemas.Agent [C:1] [TYPE Module] [SEMANTICS agent,schema,api]
# @BRIEF Pydantic schemas for agent conversation API. Must match frontend/src/types/agent.ts exactly.
> from datetime import datetime
> from pydantic import BaseModel, Field
# #region Schemas.Agent.ConversationItem [C:1] [TYPE Class] [SEMANTICS agent,schema,conversation]
# @ingroup Schemas
> class ConversationItem(BaseModel):
> id: str
> title: str
> updated_at: datetime
> message_count: int
# #endregion Schemas.Agent.ConversationItem
# #region Schemas.Agent.ConversationListResponse [C:1] [TYPE Class] [SEMANTICS agent,schema,conversation]
# @ingroup Schemas
> class ConversationListResponse(BaseModel):
> items: list[ConversationItem]
> has_next: bool = False
> active_total: int = 0
> archived_total: int = 0
# #endregion Schemas.Agent.ConversationListResponse
# #region Schemas.Agent.ToolCall [C:1] [TYPE Class] [SEMANTICS agent,schema,tool-call]
# @ingroup Schemas
> class ToolCall(BaseModel):
> tool: str
> input: dict = Field(default_factory=dict)
> output: dict | None = None
> error: str | None = None
> status: str = "executing" # executing | completed | failed
# #endregion Schemas.Agent.ToolCall
# #region Schemas.Agent.AttachmentMeta [C:1] [TYPE Class] [SEMANTICS agent,schema,attachment]
# @ingroup Schemas
> class AttachmentMeta(BaseModel):
> name: str
> type: str # pdf | xlsx | json | csv | txt | png | jpeg
> size: int
> preview_url: str | None = None
# #endregion Schemas.Agent.AttachmentMeta
# #region Schemas.Agent.MessageItem [C:1] [TYPE Class] [SEMANTICS agent,schema,message]
# @ingroup Schemas
> class MessageItem(BaseModel):
> id: str
> conversation_id: str
> role: str # user | assistant | tool | system
> text: str | None = None
> state: str | None = None
> tool_calls: list[ToolCall] | None = None
> attachments: list[AttachmentMeta] | None = None
> created_at: datetime
# #endregion Schemas.Agent.MessageItem
# #region Schemas.Agent.HistoryResponse [C:1] [TYPE Class] [SEMANTICS agent,schema,history]
# @ingroup Schemas
> class HistoryResponse(BaseModel):
> items: list[MessageItem]
> has_next: bool = False
> conversation_id: str | None = None
# #endregion Schemas.Agent.HistoryResponse
# #region Schemas.Agent.DeleteResponse [C:1] [TYPE Class] [SEMANTICS agent,schema,delete]
# @ingroup Schemas
> class DeleteResponse(BaseModel):
> deleted: bool = True
# #endregion Schemas.Agent.DeleteResponse
# #region Schemas.Agent.ServiceTokenRequest [C:1] [TYPE Class] [SEMANTICS agent,schema,auth]
# @ingroup Schemas
> class ServiceTokenRequest(BaseModel):
> service_secret: str
# #endregion Schemas.Agent.ServiceTokenRequest
# #region Schemas.Agent.ServiceTokenResponse [C:1] [TYPE Class] [SEMANTICS agent,schema,auth]
# @ingroup Schemas
> class ServiceTokenResponse(BaseModel):
> access_token: str
> token_type: str = "bearer"
> expires_in: int = 86400
> role: str = "agent"
# #endregion Schemas.Agent.ServiceTokenResponse
# #region Schemas.Agent.SaveConversationRequest [C:1] [TYPE Class] [SEMANTICS agent,schema,save]
# @ingroup Schemas
> class SaveConversationRequest(BaseModel):
> conversation_id: str
> title: str = ""
> user_id: str = "admin"
> messages: list[dict] = []
# #endregion Schemas.Agent.SaveConversationRequest
# #endregion Schemas.Agent