51 lines
2.8 KiB
Python
51 lines
2.8 KiB
Python
|
|
"""状态域模型:bridge 状态响应。"""
|
|||
|
|
|
|||
|
|
from __future__ import annotations
|
|||
|
|
|
|||
|
|
from typing import Optional
|
|||
|
|
|
|||
|
|
from pydantic import BaseModel, Field
|
|||
|
|
|
|||
|
|
from woc_bridge.models.login import LoginState
|
|||
|
|
|
|||
|
|
|
|||
|
|
# ---------------------------------------------------------------------------
|
|||
|
|
# 状态接口(GET /api/status)
|
|||
|
|
# ---------------------------------------------------------------------------
|
|||
|
|
class StatusResponse(BaseModel):
|
|||
|
|
"""bridge 状态响应。
|
|||
|
|
|
|||
|
|
新增字段(1.1.0):
|
|||
|
|
- db_error_code:DB 不可达时的具体原因(encrypted / not_found / unreadable),
|
|||
|
|
db_accessible=true 时为 None
|
|||
|
|
- send_queue_pending:发送队列当前积压任务数,客户端据此决定是否退避
|
|||
|
|
- media_supported:图片/文件发送是否已实现真实传输(与 BRIDGE_CAPABILITIES
|
|||
|
|
中 image_send/file_send 同步)
|
|||
|
|
- bridge_capabilities:当前 bridge 支持的能力集合,客户端据此协商
|
|||
|
|
"""
|
|||
|
|
|
|||
|
|
bridge_version: str = Field(description="bridge 版本号")
|
|||
|
|
wechat_running: bool = Field(description="微信进程是否运行")
|
|||
|
|
wechat_window_found: bool = Field(description="是否找到微信窗口")
|
|||
|
|
login_state: LoginState = Field(description="登录态")
|
|||
|
|
db_accessible: bool = Field(description="微信本地 DB 是否可读")
|
|||
|
|
db_error_code: Optional[str] = Field(
|
|||
|
|
default=None,
|
|||
|
|
description="DB 不可达原因:not_found / unreadable / encrypted_no_key / encrypted_key_ok / key_extract_failed / need_init / init_in_progress / key_invalid;db_accessible=true 时为 None",
|
|||
|
|
)
|
|||
|
|
init_in_progress: bool = Field(default=False, description="是否正在进行后台 DB 初始化(密钥提取/预解密)")
|
|||
|
|
init_progress_pct: Optional[float] = Field(default=None, description="初始化进度百分比 0-100")
|
|||
|
|
init_message: Optional[str] = Field(default=None, description="初始化阶段描述")
|
|||
|
|
current_wxid: str = Field(default="", description="当前登录 wxid,未登录时为空")
|
|||
|
|
current_nickname: str = Field(default="", description="当前登录昵称,未登录时为空")
|
|||
|
|
uptime_seconds: float = Field(description="bridge 已运行秒数")
|
|||
|
|
display: str = Field(description="当前 DISPLAY 环境变量值")
|
|||
|
|
max_batch_size: int = Field(default=50, description="客户端单次拉取建议上限")
|
|||
|
|
poll_interval_ms: int = Field(default=2000, description="客户端轮询建议间隔(毫秒)")
|
|||
|
|
send_queue_pending: int = Field(default=0, description="发送队列积压任务数")
|
|||
|
|
media_supported: bool = Field(default=False, description="图片/文件真实传输是否已实现")
|
|||
|
|
bridge_capabilities: list[str] = Field(
|
|||
|
|
default_factory=list,
|
|||
|
|
description="bridge 支持的能力集合,如 ['text_send','image_send','long_poll']",
|
|||
|
|
)
|