feat: remove wait-login; pick-web only; docs sync
All checks were successful
技能自动化发布 / release (push) Successful in 33s

This commit is contained in:
2026-04-07 11:58:27 +08:00
parent 96e5b9ea14
commit e2eafb7407
7 changed files with 9 additions and 154 deletions

View File

@@ -11,7 +11,7 @@ from service.account_service import (
cmd_list_json,
cmd_pick_web,
)
from service.browser_service import cmd_login, cmd_open, cmd_wait_login
from service.browser_service import cmd_login, cmd_open
from util.constants import LOG_LOGGER_NAME, SKILL_SLUG
from util.logging_config import get_skill_logger, setup_skill_logging
from util.platforms import _platform_list_cn_for_help, resolve_platform_key
@@ -28,7 +28,6 @@ def _cli_print_full_usage() -> None:
print(" python main.py get <id>")
print(" python main.py open <id>")
print(" python main.py login <id>")
print(" python main.py wait-login <id> # 跨技能:限时内 DOM 检测登录(默认 180s")
print(" python main.py delete id <id>")
print(" python main.py delete platform <平台>")
print(" python main.py delete platform <平台> <手机号>")
@@ -126,7 +125,7 @@ def main() -> None:
if len(sys.argv) < 3:
print("ERROR:CLI_PICK_WEB_MISSING_ARGS")
print("用法python main.py pick-web <平台中文名或英文键>")
print("说明:按 updated_at 选一条账号;是否已登录由 wait-login / 页面检测决定")
print("说明:按 updated_at 选一条账号;是否已登录由调用方网页会话自行处理")
sys.exit(1)
cmd_pick_web(sys.argv[2])
elif cmd == "open":
@@ -134,14 +133,6 @@ def main() -> None:
_cli_fail_need_account_id("open")
sys.exit(1)
cmd_open(sys.argv[2])
elif cmd == "wait-login":
av = [a for a in sys.argv[2:] if a]
if len(av) < 1:
print("ERROR:CLI_WAIT_LOGIN_MISSING_ID")
print("用法python main.py wait-login <账号 id>")
print("说明:始终以本次 DOM 检测为准;供 llm-manager / 搜狐发布等编排。")
sys.exit(1)
sys.exit(cmd_wait_login(av[0]))
elif cmd == "login":
if len(sys.argv) < 3:
_cli_fail_need_account_id("login")

View File

@@ -138,7 +138,7 @@ def cmd_list_json(platform_input: str, limit: int = 200) -> None:
def cmd_pick_web(platform_input: str):
"""
供 llm-manager 等:取该平台用于网页自动化的账号候选。
按 updated_at、created_at 倒序选一条,与库内「登录态」无关;实际是否已登录由 wait-login / 页面 DOM 判定
按 updated_at、created_at 倒序选一条;是否已登录由调用方(如网页自动化)在同一会话内处理
成功stdout 仅一行 JSON与 get 一致);失败:首行 ERROR:。
"""
get_skill_logger().info("pick_web platform_input=%r", platform_input)

View File

@@ -99,14 +99,6 @@ def _login_dom_grace_seconds() -> float:
return 4.0
def _wait_login_timeout_seconds() -> int:
"""供 wait-login / llm 编排:默认 180 秒JIANGCHANG_WAIT_LOGIN_TIMEOUT_SECONDS。"""
try:
return max(30, min(600, int((os.getenv("JIANGCHANG_WAIT_LOGIN_TIMEOUT_SECONDS") or "180").strip())))
except ValueError:
return 180
def _login_out_bundle_for(platform_key: str) -> dict:
"""传给子进程anchor + 未登录可见的选择器列表。"""
spec = PLATFORMS.get(platform_key, {}) if platform_key else {}
@@ -346,110 +338,6 @@ def cmd_login(account_id):
print(f" 详细轮询日志见:{log_file}(可将 JIANGCHANG_LOG_LEVEL=DEBUG 打开更细粒度)")
def cmd_wait_login(account_id) -> int:
"""
跨技能编排:始终以本次 Playwright DOM 检测为准;限时内打开浏览器并等待用户完成登录。
返回 0本次检测判定已登录1失败超时 / 用户关浏览器 / 其它)。
stdout 含 OK:WAIT_LOGIN 或 ERROR:WAIT_LOGIN_*。
"""
log = get_skill_logger()
log.info("wait_login_command account_id=%r", account_id)
target = get_account_by_id(account_id)
if not target:
log.warning("wait_login_aborted account_not_found account_id=%r", account_id)
print("ERROR:ACCOUNT_NOT_FOUND")
return 1
if not resolve_chromium_channel():
_print_browser_install_hint()
return 1
try:
import playwright # noqa: F401
except ImportError:
print("ERROR:需要 playwrightpip install playwright && playwright install chromium")
return 1
if not (target.get("profile_dir") or "").strip():
print("ERROR:PROFILE_DIR_MISSING 库中 profile_dir 为空。")
return 1
sec = _wait_login_timeout_seconds()
log.info(
"wait_login_orchestration account_id=%s name=%r timeout_sec=%s",
target.get("id"),
target.get("name"),
sec,
)
print("INFO:WAIT_LOGIN_BEGIN", flush=True)
print(
f"账号管理account-manager正在为本账号执行登录检测将打开浏览器请在 {sec} 秒内在窗口中完成登录。",
flush=True,
)
print(
"说明:调用方/编排技能只需等待本进程结束;打开浏览器与 DOM 检测均由账号管理负责。",
flush=True,
)
print(
"· 超时未登录成功 → 本进程报错退出,请中止后续业务。",
flush=True,
)
print(
"· 提前关闭浏览器 → 视为放弃登录,本进程立即报错退出。",
flush=True,
)
ok, end_reason = _run_login_browser_session(target, sec, verbose_ui=False)
if ok:
print("OK:WAIT_LOGIN")
return 0
if end_reason == "user_closed":
print("ERROR:WAIT_LOGIN_ABORTED 已关闭浏览器,未完成登录。")
return 1
if end_reason == "timeout":
print("ERROR:WAIT_LOGIN_TIMEOUT 限时内未完成登录。")
return 1
if end_reason == "playwright_missing":
print("ERROR:需要 playwrightpip install playwright && playwright install chromium")
return 1
if end_reason == "profile_missing":
print("ERROR:PROFILE_DIR_MISSING 库中 profile_dir 为空。")
return 1
if end_reason == "no_channel":
_print_browser_install_hint()
return 1
if end_reason == "launch_failed":
print(
"ERROR:WAIT_LOGIN_LAUNCH_FAILED 无法启动浏览器或创建用户数据上下文,请确认本机 Chrome/Edge 可用、profile 目录未被占用,详见统一日志。"
)
return 1
if end_reason == "page_error":
print(
"ERROR:WAIT_LOGIN_PAGE_ERROR 打开登录页或轮询过程异常,请查看上方 stderr 与统一日志。"
)
return 1
if end_reason == "config_error":
print("ERROR:WAIT_LOGIN_CONFIG_ERROR 登录子进程配置异常。")
return 1
if end_reason == "child_crash":
print("ERROR:WAIT_LOGIN_CHILD_CRASH 登录检测子进程异常退出且未写入有效结果。")
return 1
if end_reason == "profile_dir_unusable":
print(
"ERROR:WAIT_LOGIN_PROFILE_DIR 用户数据目录不可用或无法访问(权限/路径等),详见统一日志中的 login_child_result_detail / stderr。"
)
return 1
if end_reason == "logging_import_failed":
print(
"ERROR:WAIT_LOGIN_INTERNAL 登录子进程无法加载日志模块,请检查 account-manager 安装是否完整。"
)
return 1
if end_reason == "child_fatal":
print(
"ERROR:WAIT_LOGIN_CHILD_FATAL 登录子进程异常,详见统一日志 login_child_result_detail 或 login_child_stderr。"
)
return 1
print(f"ERROR:WAIT_LOGIN_FAILED end_reason={end_reason}")
return 1
def cmd_open(account_id):
"""打开该账号的持久化浏览器,仅用于肉眼确认是否已登录;不写数据库。"""
get_skill_logger().info("open account_id=%r", account_id)