""" services/shipping_notice/chat_actions.py 用途:发货通知状态机旧模块名的向后兼容 re-export 入口。 依赖:state_machine(ACTION_SPECS、CHECKPOINT_REGISTRY、apply_task_transition 等)、ui_state。 逻辑:历史代码 import chat_actions;新代码应直接引用 state_machine.py / ui_state.py,本模块仅保留兼容导出。 """ from app.services.shipping_notice.state_machine import ( ACTION_SPECS, ALL_ACTION_IDS, ALL_CHECKPOINT_IDS, CHECKPOINT_REGISTRY, CP_INVENTORY_SOURCE_REVIEW, TaskTransition, TaskUiState, action_buttons_for_checkpoint, apply_task_transition, build_action_buttons, build_checkpoint_catalog, checkpoint_for_task, human_options_for_checkpoint, human_options_for_task, human_options_for_task_or_checkpoint, inventory_source_action_buttons, resolve_task_ui_state, ui_state_for_checkpoint, upload_req_options_for_task, validate_registry, ) from app.services.shipping_notice.ui_state import build_task_ui_state # Legacy alias CHECKPOINT_OPTIONS = CHECKPOINT_REGISTRY def build_chat_actions_payload(task) -> dict: """ 构建聊天气泡侧动作按钮兼容 payload。 核心逻辑:复用统一 UI State 读模型,抽取聊天侧 checkpoint/summary/process_gate; action_buttons 已由 ui_state 在存在 ProcessExecution 时按 Gate 规则收缩(阻断清零)。 Args: task: ShippingNotice 模型实例。 Returns: 包含 task_no、checkpoint、process_gate、action_buttons 与摘要的字典。 """ state = build_task_ui_state(task) return { "task_no": state.get("task_no"), "batch_no": state.get("batch_no"), "checkpoint": state.get("checkpoint"), "process_status": state.get("process_status"), "review_status": state.get("review_status"), "pending_human_reason": state.get("pending_human_reason"), "match_status": state.get("match_status"), "current_step": state.get("current_step"), "summary": state.get("summary"), "process_gate": state.get("process_gate"), "action_buttons": state.get("action_buttons") or [], "updated_at": state.get("updated_at"), } __all__ = [ "ACTION_SPECS", "ALL_ACTION_IDS", "ALL_CHECKPOINT_IDS", "CHECKPOINT_OPTIONS", "CHECKPOINT_REGISTRY", "TaskTransition", "TaskUiState", "action_buttons_for_checkpoint", "apply_task_transition", "build_action_buttons", "build_chat_actions_payload", "build_checkpoint_catalog", "checkpoint_for_task", "human_options_for_checkpoint", "human_options_for_task", "human_options_for_task_or_checkpoint", "resolve_task_ui_state", "ui_state_for_checkpoint", "upload_req_options_for_task", "validate_registry", ]