"""
Action Card 协议 v1 Schema & 回调处理
"""
from __future__ import annotations
from pydantic import BaseModel


class ActionCardField(BaseModel):
    label: str
    value: str
    editable: bool = False


class ActionButton(BaseModel):
    key: str        # "confirm" | "cancel" | "edit"
    label: str      # "确认建单" | "取消"
    style: str = "primary"  # "primary" | "danger" | "default"


class ActionCardPayload(BaseModel):
    card_id: str                # 前端生成的唯一 ID
    card_type: str              # "create_order" | "create_customer" | "create_shipping" ...
    title: str
    summary: str
    fields: list[ActionCardField] = []
    actions: list[ActionButton] = []
    params: dict = {}           # 原始工具参数，回调时传回


class ActionCardCallback(BaseModel):
    """前端点击确认/取消后的回调请求"""
    card_id: str | None = None
    card_type: str
    action_key: str             # "confirm" | "cancel"
    params: dict = {}           # 可能被用户在卡片上修改过的参数
