""" services/shipping_notice/chat_actions.py 用途:发货通知聊天只读状态适配。 依赖:state_machine(checkpoint 与内部状态迁移)、ui_state。 逻辑:Chat 不再拥有动作目录或写入口;仅输出 Gate 已裁决的只读 UI State。 """ from app.services.shipping_notice.state_machine import TaskTransition, apply_task_transition, checkpoint_for_task, resolve_task_ui_state, validate_registry from app.services.shipping_notice.ui_state import build_task_ui_state def build_chat_actions_payload(task) -> dict: """ 构建聊天气泡侧动作按钮兼容 payload。 核心逻辑:复用统一 UI State 读模型,抽取聊天侧 checkpoint/summary/process_gate; 业务动作只从 ui_state.actions 返回,Chat 不再暴露旧 action_buttons。 Args: task: ShippingNotice 模型实例。 Returns: 包含 task_no、checkpoint、process_gate、actions 与摘要的字典。 """ state = build_task_ui_state(task) return { "task_no": state.get("task_no"), "batch_no": state.get("batch_no"), "checkpoint": state.get("checkpoint"), "stage": state.get("stage"), "todo": state.get("todo"), "actions": state.get("actions"), "reason": state.get("reason"), "lifecycle_status": state.get("lifecycle_status"), "summary": state.get("summary"), "process_gate": state.get("process_gate"), "updated_at": state.get("updated_at"), } __all__ = [ "TaskTransition", "apply_task_transition", "build_chat_actions_payload", "checkpoint_for_task", "resolve_task_ui_state", "validate_registry", ]