Files
kwcode/kaiwu/server/models.py
Val-sss ca55970ad8 release: v1.6.2 版本号统一 + README/CHANGELOG/STATUS更新
- 版本号统一到1.6.2(pyproject/__init__/formatters/telemetry/server)
- README: badge 1.6.2, License Apache-2.0, 更新日志加v1.6.2条目
- CHANGELOG: 完整v1.6.2变更记录
- STATUS: 当前版本更新到v1.6.2

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-05-07 14:42:21 +08:00

77 lines
1.9 KiB
Python

"""
Pydantic models for kwcode server API.
"""
from typing import Optional
from pydantic import BaseModel, Field
try:
from importlib.metadata import version as _pkg_version
_VERSION = _pkg_version("kwcode")
except Exception:
_VERSION = "1.6.2"
class TaskRequest(BaseModel):
"""Request to submit a task."""
input: str = Field(..., description="Task description")
project_root: str = Field(".", description="Project root directory")
no_search: bool = Field(False, description="Disable search augmentation")
image_paths: list[str] = Field(default_factory=list, description="Image paths for vision tasks")
class TaskResponse(BaseModel):
"""Response after submitting a task."""
task_id: str
status: str = "accepted"
class TaskResult(BaseModel):
"""Final result of a completed task."""
task_id: str
success: bool
error: Optional[str] = None
elapsed: float = 0.0
files_modified: list[str] = Field(default_factory=list)
summary: str = ""
class HealthResponse(BaseModel):
"""Health check response."""
status: str = "ok"
version: str = _VERSION
model: str = ""
project_root: str = ""
class StatusResponse(BaseModel):
"""Server status response."""
model: str = ""
project_root: str = ""
experts_loaded: int = 0
search_enabled: bool = False
uptime_seconds: float = 0.0
class FileTreeItem(BaseModel):
"""A file or directory in the file tree."""
name: str
path: str
is_dir: bool = False
children: list["FileTreeItem"] = Field(default_factory=list)
class FileContent(BaseModel):
"""File content response."""
path: str
content: str
language: str = ""
lines: int = 0
class ManifestResponse(BaseModel):
"""UpstreamManifest state response."""
signatures: dict[str, dict[str, str]] = Field(default_factory=dict)
constants: dict[str, dict[str, str]] = Field(default_factory=dict)
file_count: int = 0