diff --git a/SKILL.md b/SKILL.md index 3c0988d..79c8ff5 100644 --- a/SKILL.md +++ b/SKILL.md @@ -1,7 +1,7 @@ --- name: 账号管理 description: 多平台多账号管理。管理各平台账号与Chrome Profile的对应关系,供publisher类Skill调用获取账号信息。 -version: 1.0.5 +version: 1.0.6 author: 深圳匠厂科技有限公司 metadata: openclaw: @@ -53,14 +53,13 @@ python3 {baseDir}/scripts/main.py list all python3 {baseDir}/scripts/main.py list 搜狐号 ``` -### 跨技能:单行 JSON(get / list-json / pick-web);需会话有效时用 wait-login +### 跨技能:单行 JSON(get / list-json / pick-web) ```bash python3 {baseDir}/scripts/main.py get python3 {baseDir}/scripts/main.py list-json all --limit 50 python3 {baseDir}/scripts/main.py pick-web 搜狐号 -python3 {baseDir}/scripts/main.py wait-login ``` -约定与字段说明见 `references/INTEGRATION.md`;错误前缀见 `references/ERRORS.md`。 +约定与字段说明见 `references/INTEGRATION.md`;错误前缀见 `references/ERRORS.md`。是否已登录由调用方网页会话处理,本 skill 不做编排用预检。 ## 扩展文档(便于 AI 精确调用) diff --git a/references/CLI.md b/references/CLI.md index d5d50c4..b614e3d 100644 --- a/references/CLI.md +++ b/references/CLI.md @@ -81,16 +81,7 @@ python main.py login - 依赖 Playwright;超时与轮询间隔等见 [RUNTIME.md](RUNTIME.md)。 - **不**在库中持久化「是否已登录」;仅刷新 `updated_at` 供 `pick-web` 等排序参考。 - -### `wait-login` — 跨技能:**始终以本次 DOM 检测为准** - -```bash -python main.py wait-login -``` - -- 由**账号管理**打开浏览器并完成 DOM 检测;调用方只需 `subprocess` 等待本进程结束,成功时 stdout 含 `OK:WAIT_LOGIN`。 -- 会先打印若干行说明(含 `INFO:WAIT_LOGIN_BEGIN`),再进入检测;超时、关窗、启动失败等见 [ERRORS.md](ERRORS.md)。 -- 时间窗由 `JIANGCHANG_WAIT_LOGIN_TIMEOUT_SECONDS` 控制,见 [RUNTIME.md](RUNTIME.md)。 +- 跨技能编排(如 llm-manager 网页生成)**不再**通过本 skill 单独做「登录预检」;由业务侧在同一浏览器会话内处理未登录态。 ### `delete` — 删除库记录并尽量删除 profile 目录 diff --git a/references/ERRORS.md b/references/ERRORS.md index 3e4c24b..c56a9ca 100644 --- a/references/ERRORS.md +++ b/references/ERRORS.md @@ -14,7 +14,6 @@ | `ERROR:CLI_DELETE_BAD_MODE` | `delete` 第二段不是 `id`/`platform` | | `ERROR:CLI_LIST_JSON_MISSING_PLATFORM` | `list-json` 缺少平台参数 | | `ERROR:CLI_PICK_WEB_MISSING_ARGS` | `pick-web` 缺少平台 | -| `ERROR:CLI_WAIT_LOGIN_MISSING_ID` | `wait-login` 缺少 id | | `ERROR:CLI_UNKNOWN_OR_BAD_ARGS` | 无法识别的子命令或参数组合 | ## `ERROR:` — 业务与数据 @@ -39,19 +38,6 @@ | `ERROR:需要 playwright:pip install playwright && playwright install chromium` | 未安装 Playwright 或浏览器未安装 | | `ERROR:PROFILE_DIR_MISSING` | 账号记录中 `profile_dir` 为空 | -## `ERROR:` — `wait-login`(跨技能编排) - -| 前缀 | 含义 | -|------|------| -| `ERROR:WAIT_LOGIN_ABORTED` | 用户关闭浏览器,放弃登录 | -| `ERROR:WAIT_LOGIN_TIMEOUT` | 限时内未完成登录(默认由 `JIANGCHANG_WAIT_LOGIN_TIMEOUT_SECONDS` 控制,约 180s) | -| `ERROR:WAIT_LOGIN_LAUNCH_FAILED` | 无法启动浏览器或创建持久化上下文(端口/占用/安装问题等) | -| `ERROR:WAIT_LOGIN_PAGE_ERROR` | 打开登录页或轮询 DOM 时异常 | -| `ERROR:WAIT_LOGIN_CONFIG_ERROR` | 子进程配置异常 | -| `ERROR:WAIT_LOGIN_CHILD_CRASH` | 子进程异常退出且未写入有效结果文件 | - -编排技能(如 llm-manager)另可能打印 `ERROR:WAIT_LOGIN_OUTER_TIMEOUT`:等待本进程整体超过上限(登录窗口 + 子进程缓冲),已中止。 - ## 非前缀输出 - **成功添加账号**、**删除成功**等可能包含 `✅` 等人类可读行,**不宜**作为稳定协议解析。 diff --git a/references/INTEGRATION.md b/references/INTEGRATION.md index 2e3b372..e1f0b4a 100644 --- a/references/INTEGRATION.md +++ b/references/INTEGRATION.md @@ -24,12 +24,12 @@ 常见键名包括:`id`, `name`, `platform`, `phone`, `profile_dir`, `url`, `created_at`, `updated_at`;`extra_json` 列中的扁平扩展可能并入同一对象。 -**库中不再持久化「是否已登录」**;编排侧需登录时请调用 `wait-login `(始终以本次 Playwright DOM 检测为准)或在业务页内自行判断。 +**库中不再持久化「是否已登录」**;编排侧在网页自动化中自行处理登录(与 `pick-web` / `get` 返回的 `profile_dir` 同一浏览器会话)。 ## Publisher / 自动化流水线示例 1. `pick-web 搜狐号`(或目标平台)→ 解析 JSON → 取 `id`、`profile_dir`、`url`。 -2. 需要确保会话有效时:调用 `wait-login `,成功则 stdout 首行含 `OK:WAIT_LOGIN`。 +2. 使用 `profile_dir` 启动持久化浏览器上下文,在业务页面内完成或等待登录。 ## 退出码 diff --git a/scripts/cli/app.py b/scripts/cli/app.py index 0f68596..ae040cd 100644 --- a/scripts/cli/app.py +++ b/scripts/cli/app.py @@ -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 ") print(" python main.py open ") print(" python main.py login ") - print(" python main.py wait-login # 跨技能:限时内 DOM 检测登录(默认 180s)") print(" python main.py delete 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") diff --git a/scripts/service/account_service.py b/scripts/service/account_service.py index e9c058d..ec11674 100644 --- a/scripts/service/account_service.py +++ b/scripts/service/account_service.py @@ -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) diff --git a/scripts/service/browser_service.py b/scripts/service/browser_service.py index 684de89..5e71488 100644 --- a/scripts/service/browser_service.py +++ b/scripts/service/browser_service.py @@ -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:需要 playwright:pip 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:需要 playwright:pip 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)