chore: auto release commit (2026-09-15 01:20:35)
Some checks failed
技能自动化发布 / release (push) Failing after 7s

This commit is contained in:
2026-09-15 01:20:35 +08:00
parent aa9bf262fe
commit 0157fde0f1
5 changed files with 121 additions and 38 deletions

View File

@@ -263,11 +263,14 @@ def _try_auto_sign_in(page, wait_input_sec: int = 2) -> bool:
def _wait_for_login_inputs_filled(page, wait_sec: int = HUMAN_WAIT_TIMEOUT) -> bool:
"""v1.1.21:等用户输入完账号密码,然后自动点 Sign in。
"""v1.1.21:等用户输入完账号密码。
v1.1.24:**不再自动点 Sign in**——按用户要求:「等待用户输入信息后跳转页面」,
按钮交给用户自己点。脚本只负责等 URL 跳离登录页。
- 每 HUMAN_POLL_INTERVAL 秒检查 #jc-user / #jc-pass 是否有值
- 两个都有值 → 自动点 Sign in → return True
- 超时未填完 → return False
- 每 HUMAN_POLL_INTERVAL 秒检查 #jc-user / #jc-pass 是否有值(仅做状态日志)
- URL 已离开登录页 → return True(用户可能自己点登录完成)
- input 有值 → 提示「请点登录按钮」(**脚本不抢按钮**)
- 超时未跳离登录页 → return False
"""
deadline = time.monotonic() + wait_sec
last_prompt_at = time.monotonic()
@@ -275,47 +278,56 @@ def _wait_for_login_inputs_filled(page, wait_sec: int = HUMAN_WAIT_TIMEOUT) -> b
while time.monotonic() < deadline:
cur_url = page.url
user_input = page.locator("#jc-user").first
pass_input = page.locator("#jc-pass").first
# 已不在登录页(用户可能手动点了别的)
# 已不在登录页(用户可能已点登录完成跳转)
if not _is_login_page_url_for_user(cur_url):
logger.info(
"platform_collector: URL 已离开登录页(%s),停止等输入", cur_url,
"platform_collector: URL 已离开登录页(%s),登录完成", cur_url,
)
return True
if user_input.count() > 0 and pass_input.count() > 0:
user_val = (user_input.input_value() or "").strip()
pass_val = (pass_input.input_value() or "").strip()
now = time.monotonic()
if now - last_state_log >= HUMAN_PROMPT_INTERVAL:
last_state_log = now
logger.info(
"platform_collector: input 状态 user=%r pass=%r",
bool(user_val), bool(pass_val),
)
if user_val and pass_val:
logger.info(
"platform_collector: ✅ 用户输入完成(user=%r),自动点 Sign in",
user_val,
)
btn = page.locator('button[type="submit"]:has-text("Sign in")').first
if btn.count() > 0:
btn.click()
return True
# 探测 input 是否就绪 + 是否已有值(仅做日志,不主动 click)
for sel in ("#jc-user", "input[type='tel']", "input[autocomplete='username']"):
loc = page.locator(sel).first
if loc.count() > 0:
user_val = (loc.input_value() or "").strip()
break
else:
user_val = ""
for sel in ("#jc-pass", "input[type='password']", "input[autocomplete='current-password']"):
loc = page.locator(sel).first
if loc.count() > 0:
pass_val = (loc.input_value() or "").strip()
break
else:
pass_val = ""
# 提醒用户
now = time.monotonic()
if now - last_state_log >= HUMAN_PROMPT_INTERVAL:
last_state_log = now
logger.info(
"platform_collector: 等待用户输入 user=%r pass=%r (URL=%s)",
bool(user_val), bool(pass_val), cur_url,
)
# 提醒用户:input 有值时明确告诉用户「点登录按钮」
if now - last_prompt_at >= HUMAN_PROMPT_INTERVAL:
last_prompt_at = now
remaining = int(deadline - now)
print(f"[登录] 等待用户输入账号密码... 剩余 {remaining}s")
if user_val and pass_val:
print(
f"[登录] ✅ 账号密码已填好(user={user_val[:3]}***),"
f"请点「登录」按钮,剩余 {remaining}s..."
)
else:
print(
f"[登录] 等待用户输入账号密码... 剩余 {remaining}s"
)
time.sleep(HUMAN_POLL_INTERVAL)
logger.warning(
"platform_collector: %ds 内用户未完成输入", wait_sec,
"platform_collector: %ds 内用户未跳转(最后 URL=%s)", wait_sec, page.url,
)
return False
@@ -681,22 +693,22 @@ def collect_all(
else:
# 2. 等 #jc-user / #jc-pass 出现(最多 2 秒)
# 若 sandbox 已预填 demo/123456 → 自动点 Sign in
# 若 input 为空 → 等用户输入完成后再自动点 Sign in
# 若 input 为空 → 等用户输入(**v1.1.24 用户自己点登录按钮**)
auto_clicked = _try_auto_sign_in(page, wait_input_sec=2)
if auto_clicked:
logger.info(
"platform_collector: ✅ 自动登录成功(预填 demo),等 URL 跳到 /app/"
)
elif not headless:
# 3. input 为空:等用户输入 → 自动点 Sign in
# 3. input 为空:等用户输入 → **用户自己点 Sign in**(脚本不抢按钮)
if _wait_for_login_inputs_filled(page, wait_sec=human_wait_timeout):
logger.info(
"platform_collector: ✅ 用户输入完成并点击,等 URL 跳到 /app/"
"platform_collector: ✅ 用户完成输入并跳转,等 URL 跳到 /app/"
)
else:
# 超时未输入 → fallback 到原来的多信号等待
# 超时未跳转 → fallback 到原来的多信号等待
logger.warning(
"platform_collector: 用户未输入完成,fallback 到 _wait_for_manual_login"
"platform_collector: 用户未跳转,fallback 到 _wait_for_manual_login"
)
_wait_for_manual_login(page, wait_sec=human_wait_timeout)
else:
@@ -719,7 +731,7 @@ def collect_all(
# (/industries/campus/smartcampus/login)。如果 URL 落在
# 这个二级登录页,再走一次 _try_auto_sign_in(已经扩展支持
# 中文「登录」按钮);若 SPA 登录页 input 有预填账号 → 自动点;
# 若 input 空 → 走 _wait_for_login_inputs_filled 等用户输入。
# 若 input 空 → 等用户输入并**自己点登录**(脚本不抢按钮)。
cur_url_after_stable = page.url.lower()
if "/login" in cur_url_after_stable or "/signin" in cur_url_after_stable:
logger.warning(

View File

@@ -6,7 +6,7 @@
"""
SKILL_SLUG = "alert-contract-expiring-hr"
SKILL_VERSION = "1.1.24"
SKILL_VERSION = "1.1.25"
LOG_LOGGER_NAME = "openclaw.skill.alert_contract_expiring_hr"
PLATFORM_KIT_MIN_VERSION = "1.2.11"