deerflow-code/offline-backend-20260512/backend/app/report_collaboration/contracts/commands.py
2026-09-07 18:24:55 +08:00

47 lines
1.5 KiB
Python

"""User commands and the intent-router decision object."""
from __future__ import annotations
from pydantic import BaseModel, ConfigDict, Field
from app.report_collaboration.contracts.enums import CommandIntent, CommandScope, CommandStatus, ReportCostLevel
from app.report_collaboration.contracts.requirements import ReportRequirementSnapshot
class IntentDecision(BaseModel):
"""Pydantic-constrained output of IntentRouterAgent. It never dispatches work."""
model_config = ConfigDict(extra="forbid")
intent: CommandIntent
confidence: float = Field(ge=0, le=1)
normalized_instruction: str
scope: CommandScope
requested_target_ids: list[str] = Field(default_factory=list)
requirement_patch: ReportRequirementSnapshot | None = None
requires_confirmation: bool = False
cost_level: ReportCostLevel = "low"
reason: str
class CollaborationCommand(BaseModel):
model_config = ConfigDict(extra="forbid")
command_id: str
idempotency_key: str
text: str
intent: CommandIntent | None = None
confidence: float | None = Field(default=None, ge=0, le=1)
target_type: str | None = None
target_ids: list[str] = Field(default_factory=list)
normalized_instruction: str | None = None
requires_confirmation: bool = False
cost_level: ReportCostLevel | None = None
reason: str | None = None
impact_nodes: list[str] = Field(default_factory=list)
status: CommandStatus
expected_revision: int | None = None
error: str | None = None
created_at: str
updated_at: str | None = None