chore: auto release commit (2026-09-15 01:20:35)
Some checks failed
技能自动化发布 / release (push) Failing after 7s
Some checks failed
技能自动化发布 / release (push) Failing after 7s
This commit is contained in:
@@ -2,6 +2,15 @@
|
|||||||
|
|
||||||
本文件对应技能市场 **「更新日志」** Tab。
|
本文件对应技能市场 **「更新日志」** Tab。
|
||||||
|
|
||||||
|
## 1.1.25
|
||||||
|
|
||||||
|
- **按用户要求修正登录页等待逻辑**:
|
||||||
|
- 有数据(账号密码已存在)→ 自动点登录按钮(`_try_auto_sign_in`)
|
||||||
|
- **无数据 → 等待用户输入完成(最多 180 秒)→ 等 URL 跳离登录页**(按钮交给用户自己点,脚本不抢按钮)
|
||||||
|
- `_wait_for_login_inputs_filled` 重写为「**等待模式**」:不再自动点 Sign in / 登录按钮;只轮询 input 值 + URL,每 15 秒提示「请点登录按钮」或「等待输入」
|
||||||
|
- 根域登录 + SPA 二级登录页统一使用同一套行为
|
||||||
|
- 新增测试 `wait_login_inputs_filled_no_auto_click_v1_24` 验证不抢按钮,合计 63/63
|
||||||
|
|
||||||
## 1.1.24
|
## 1.1.24
|
||||||
|
|
||||||
- **修复 `/industries/campus/smartcampus/login` 等待过久问题**:sandbox 在用户首次登录后可能把人踢回 SPA 二级登录页(按钮中文「登录」),之前根域自动登录代码不识别这个 URL + 中文按钮,导致脚本卡死等用户输入
|
- **修复 `/industries/campus/smartcampus/login` 等待过久问题**:sandbox 在用户首次登录后可能把人踢回 SPA 二级登录页(按钮中文「登录」),之前根域自动登录代码不识别这个 URL + 中文按钮,导致脚本卡死等用户输入
|
||||||
|
|||||||
2
SKILL.md
2
SKILL.md
@@ -1,7 +1,7 @@
|
|||||||
---
|
---
|
||||||
name: 合同到期智能预警与续聘辅助
|
name: 合同到期智能预警与续聘辅助
|
||||||
description: "当用户说要扫描即将到期的合同、查 90/60/30 天预警名单、给某位教师生成续聘任务书、下发单位版续聘清单、从 SmartCampus HR 平台抓合同数据、解析续聘材料 PDF/Word、查看本月合同到期人员清单时,加载本技能。支持定时扫描(每日凌晨)+ 数据管理 + Agent 三入口,覆盖合同到期智能预警与续聘辅助全流程。"
|
description: "当用户说要扫描即将到期的合同、查 90/60/30 天预警名单、给某位教师生成续聘任务书、下发单位版续聘清单、从 SmartCampus HR 平台抓合同数据、解析续聘材料 PDF/Word、查看本月合同到期人员清单时,加载本技能。支持定时扫描(每日凌晨)+ 数据管理 + Agent 三入口,覆盖合同到期智能预警与续聘辅助全流程。"
|
||||||
version: 1.1.24
|
version: 1.1.25
|
||||||
author: 深圳匠厂科技有限公司
|
author: 深圳匠厂科技有限公司
|
||||||
metadata:
|
metadata:
|
||||||
openclaw:
|
openclaw:
|
||||||
|
|||||||
@@ -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:
|
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 是否有值
|
- 每 HUMAN_POLL_INTERVAL 秒检查 #jc-user / #jc-pass 是否有值(仅做状态日志)
|
||||||
- 两个都有值 → 自动点 Sign in → return True
|
- URL 已离开登录页 → return True(用户可能自己点登录完成)
|
||||||
- 超时未填完 → return False
|
- input 有值 → 提示「请点登录按钮」(**脚本不抢按钮**)
|
||||||
|
- 超时未跳离登录页 → return False
|
||||||
"""
|
"""
|
||||||
deadline = time.monotonic() + wait_sec
|
deadline = time.monotonic() + wait_sec
|
||||||
last_prompt_at = time.monotonic()
|
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:
|
while time.monotonic() < deadline:
|
||||||
cur_url = page.url
|
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):
|
if not _is_login_page_url_for_user(cur_url):
|
||||||
logger.info(
|
logger.info(
|
||||||
"platform_collector: URL 已离开登录页(%s),停止等输入", cur_url,
|
"platform_collector: URL 已离开登录页(%s),登录完成", cur_url,
|
||||||
)
|
)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
if user_input.count() > 0 and pass_input.count() > 0:
|
# 探测 input 是否就绪 + 是否已有值(仅做日志,不主动 click)
|
||||||
user_val = (user_input.input_value() or "").strip()
|
for sel in ("#jc-user", "input[type='tel']", "input[autocomplete='username']"):
|
||||||
pass_val = (pass_input.input_value() or "").strip()
|
loc = page.locator(sel).first
|
||||||
now = time.monotonic()
|
if loc.count() > 0:
|
||||||
if now - last_state_log >= HUMAN_PROMPT_INTERVAL:
|
user_val = (loc.input_value() or "").strip()
|
||||||
last_state_log = now
|
break
|
||||||
logger.info(
|
else:
|
||||||
"platform_collector: input 状态 user=%r pass=%r",
|
user_val = ""
|
||||||
bool(user_val), bool(pass_val),
|
for sel in ("#jc-pass", "input[type='password']", "input[autocomplete='current-password']"):
|
||||||
)
|
loc = page.locator(sel).first
|
||||||
if user_val and pass_val:
|
if loc.count() > 0:
|
||||||
logger.info(
|
pass_val = (loc.input_value() or "").strip()
|
||||||
"platform_collector: ✅ 用户输入完成(user=%r),自动点 Sign in",
|
break
|
||||||
user_val,
|
else:
|
||||||
)
|
pass_val = ""
|
||||||
btn = page.locator('button[type="submit"]:has-text("Sign in")').first
|
|
||||||
if btn.count() > 0:
|
|
||||||
btn.click()
|
|
||||||
return True
|
|
||||||
|
|
||||||
# 提醒用户
|
|
||||||
now = time.monotonic()
|
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:
|
if now - last_prompt_at >= HUMAN_PROMPT_INTERVAL:
|
||||||
last_prompt_at = now
|
last_prompt_at = now
|
||||||
remaining = int(deadline - 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)
|
time.sleep(HUMAN_POLL_INTERVAL)
|
||||||
|
|
||||||
logger.warning(
|
logger.warning(
|
||||||
"platform_collector: %ds 内用户未完成输入", wait_sec,
|
"platform_collector: %ds 内用户未跳转(最后 URL=%s)", wait_sec, page.url,
|
||||||
)
|
)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@@ -681,22 +693,22 @@ def collect_all(
|
|||||||
else:
|
else:
|
||||||
# 2. 等 #jc-user / #jc-pass 出现(最多 2 秒)
|
# 2. 等 #jc-user / #jc-pass 出现(最多 2 秒)
|
||||||
# 若 sandbox 已预填 demo/123456 → 自动点 Sign in
|
# 若 sandbox 已预填 demo/123456 → 自动点 Sign in
|
||||||
# 若 input 为空 → 等用户输入完成后再自动点 Sign in
|
# 若 input 为空 → 等用户输入(**v1.1.24 用户自己点登录按钮**)
|
||||||
auto_clicked = _try_auto_sign_in(page, wait_input_sec=2)
|
auto_clicked = _try_auto_sign_in(page, wait_input_sec=2)
|
||||||
if auto_clicked:
|
if auto_clicked:
|
||||||
logger.info(
|
logger.info(
|
||||||
"platform_collector: ✅ 自动登录成功(预填 demo),等 URL 跳到 /app/"
|
"platform_collector: ✅ 自动登录成功(预填 demo),等 URL 跳到 /app/"
|
||||||
)
|
)
|
||||||
elif not headless:
|
elif not headless:
|
||||||
# 3. input 为空:等用户输入 → 自动点 Sign in
|
# 3. input 为空:等用户输入 → **用户自己点 Sign in**(脚本不抢按钮)
|
||||||
if _wait_for_login_inputs_filled(page, wait_sec=human_wait_timeout):
|
if _wait_for_login_inputs_filled(page, wait_sec=human_wait_timeout):
|
||||||
logger.info(
|
logger.info(
|
||||||
"platform_collector: ✅ 用户输入完成并点击,等 URL 跳到 /app/"
|
"platform_collector: ✅ 用户完成输入并跳转,等 URL 跳到 /app/"
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
# 超时未输入 → fallback 到原来的多信号等待
|
# 超时未跳转 → fallback 到原来的多信号等待
|
||||||
logger.warning(
|
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)
|
_wait_for_manual_login(page, wait_sec=human_wait_timeout)
|
||||||
else:
|
else:
|
||||||
@@ -719,7 +731,7 @@ def collect_all(
|
|||||||
# (/industries/campus/smartcampus/login)。如果 URL 落在
|
# (/industries/campus/smartcampus/login)。如果 URL 落在
|
||||||
# 这个二级登录页,再走一次 _try_auto_sign_in(已经扩展支持
|
# 这个二级登录页,再走一次 _try_auto_sign_in(已经扩展支持
|
||||||
# 中文「登录」按钮);若 SPA 登录页 input 有预填账号 → 自动点;
|
# 中文「登录」按钮);若 SPA 登录页 input 有预填账号 → 自动点;
|
||||||
# 若 input 空 → 走 _wait_for_login_inputs_filled 等用户输入。
|
# 若 input 空 → 等用户输入并**自己点登录**(脚本不抢按钮)。
|
||||||
cur_url_after_stable = page.url.lower()
|
cur_url_after_stable = page.url.lower()
|
||||||
if "/login" in cur_url_after_stable or "/signin" in cur_url_after_stable:
|
if "/login" in cur_url_after_stable or "/signin" in cur_url_after_stable:
|
||||||
logger.warning(
|
logger.warning(
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
SKILL_SLUG = "alert-contract-expiring-hr"
|
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"
|
LOG_LOGGER_NAME = "openclaw.skill.alert_contract_expiring_hr"
|
||||||
PLATFORM_KIT_MIN_VERSION = "1.2.11"
|
PLATFORM_KIT_MIN_VERSION = "1.2.11"
|
||||||
|
|
||||||
|
|||||||
@@ -1279,6 +1279,8 @@ class _FakePage:
|
|||||||
|
|
||||||
- .url: 字符串
|
- .url: 字符串
|
||||||
- 支持外部修改 .url 模拟用户登录跳转
|
- 支持外部修改 .url 模拟用户登录跳转
|
||||||
|
- v1.1.24:新增 .locator() 返回 _FakeLocatorNoOp,让
|
||||||
|
_wait_for_login_inputs_filled 的 selector 探测不抛 AttributeError
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, initial_url: str = "about:blank") -> None:
|
def __init__(self, initial_url: str = "about:blank") -> None:
|
||||||
@@ -1287,6 +1289,10 @@ class _FakePage:
|
|||||||
self.reload_calls: int = 0
|
self.reload_calls: int = 0
|
||||||
self.click_calls: int = 0
|
self.click_calls: int = 0
|
||||||
|
|
||||||
|
def locator(self, selector: str): # noqa: ARG002
|
||||||
|
"""v1.1.24 扩展:测试 _wait_for_login_inputs_filled 用,返回空 locator。"""
|
||||||
|
return _FakeLocator(count=0)
|
||||||
|
|
||||||
|
|
||||||
def test_wait_for_url_stable_immediate_match() -> tuple[bool, str]:
|
def test_wait_for_url_stable_immediate_match() -> tuple[bool, str]:
|
||||||
"""_wait_for_url_stable: URL 已含目标 + 稳定 → 立即返回 True。"""
|
"""_wait_for_url_stable: URL 已含目标 + 稳定 → 立即返回 True。"""
|
||||||
@@ -1413,6 +1419,12 @@ class _FakeLocatorRouter:
|
|||||||
self._selectors = selectors
|
self._selectors = selectors
|
||||||
self._page = page
|
self._page = page
|
||||||
|
|
||||||
|
def __call__(self, sel: str):
|
||||||
|
"""page.locator(sel) 形式调用。"""
|
||||||
|
if sel in self._selectors:
|
||||||
|
return self._selectors[sel]
|
||||||
|
return _FakeLocator(count=0)
|
||||||
|
|
||||||
def __getattr__(self, sel: str):
|
def __getattr__(self, sel: str):
|
||||||
# loc.page 已存在则按 selector 路由
|
# loc.page 已存在则按 selector 路由
|
||||||
if sel in self._selectors:
|
if sel in self._selectors:
|
||||||
@@ -1540,6 +1552,51 @@ def test_try_auto_sign_in_selector_timeout_returns_false() -> tuple[bool, str]:
|
|||||||
return True, "无登录 input 超时返回 False OK"
|
return True, "无登录 input 超时返回 False OK"
|
||||||
|
|
||||||
|
|
||||||
|
def test_wait_for_login_inputs_filled_no_auto_click_v1_24() -> tuple[bool, str]:
|
||||||
|
"""v1.1.24:`_wait_for_login_inputs_filled` **不再自动点登录按钮**——
|
||||||
|
用户输入完成(input 有值)后等 URL 跳离登录页,**按钮交给用户自己点**。
|
||||||
|
"""
|
||||||
|
import threading
|
||||||
|
import time as _time
|
||||||
|
|
||||||
|
from service import platform_collector as pc
|
||||||
|
|
||||||
|
# 缩短轮询周期:HUMAN_POLL_INTERVAL 默认 5s,太长测试慢
|
||||||
|
orig_poll = pc.HUMAN_POLL_INTERVAL
|
||||||
|
orig_prompt = pc.HUMAN_PROMPT_INTERVAL
|
||||||
|
pc.HUMAN_POLL_INTERVAL = 0.2
|
||||||
|
pc.HUMAN_PROMPT_INTERVAL = 0.2
|
||||||
|
try:
|
||||||
|
page = _FakePage(
|
||||||
|
"https://sandbox.jc2009.com/industries/campus/smartcampus/login",
|
||||||
|
)
|
||||||
|
|
||||||
|
# 0.6s 后 URL 跳到 /app/(模拟用户点登录按钮后跳转)
|
||||||
|
def fake_user_jump():
|
||||||
|
_time.sleep(0.6)
|
||||||
|
page.url = "https://sandbox.jc2009.com/industries/campus/smartcampus/app/home"
|
||||||
|
|
||||||
|
threading.Thread(target=fake_user_jump, daemon=True).start()
|
||||||
|
|
||||||
|
result = pc._wait_for_login_inputs_filled(page, wait_sec=5)
|
||||||
|
if not result:
|
||||||
|
return False, "URL 已跳到 /app/ 应返回 True"
|
||||||
|
|
||||||
|
if page.goto_calls:
|
||||||
|
return False, f"等待期间不应 goto: {page.goto_calls}"
|
||||||
|
if page.reload_calls:
|
||||||
|
return False, f"等待期间不应 reload: {page.reload_calls}"
|
||||||
|
if page.click_calls:
|
||||||
|
return False, (
|
||||||
|
f"v1.1.24 修复:等用户输入期间**不应自动点登录**按钮,"
|
||||||
|
f"但 click_calls={page.click_calls}"
|
||||||
|
)
|
||||||
|
return True, "v1.1.24 等用户跳离登录页(不抢按钮)OK"
|
||||||
|
finally:
|
||||||
|
pc.HUMAN_POLL_INTERVAL = orig_poll
|
||||||
|
pc.HUMAN_PROMPT_INTERVAL = orig_prompt
|
||||||
|
|
||||||
|
|
||||||
# ---------- v1.1.18: show-config / logs-list ----------
|
# ---------- v1.1.18: show-config / logs-list ----------
|
||||||
|
|
||||||
|
|
||||||
@@ -1813,6 +1870,11 @@ def main() -> int:
|
|||||||
_run("login_flow/wait_url_stable_transition", test_wait_for_url_stable_transition)
|
_run("login_flow/wait_url_stable_transition", test_wait_for_url_stable_transition)
|
||||||
_run("login_flow/wait_url_stable_timeout", test_wait_for_url_stable_timeout)
|
_run("login_flow/wait_url_stable_timeout", test_wait_for_url_stable_timeout)
|
||||||
_run("login_flow/wait_manual_login_no_goto", test_wait_for_manual_login_no_goto)
|
_run("login_flow/wait_manual_login_no_goto", test_wait_for_manual_login_no_goto)
|
||||||
|
_run("login_flow/auto_sign_in_spa_chinese_button", test_try_auto_sign_in_spa_login_chinese_button)
|
||||||
|
_run("login_flow/auto_sign_in_root_english_button", test_try_auto_sign_in_root_sign_in_english_button)
|
||||||
|
_run("login_flow/auto_sign_in_no_input_returns_false", test_try_auto_sign_in_no_input_returns_false)
|
||||||
|
_run("login_flow/auto_sign_in_selector_timeout_returns_false", test_try_auto_sign_in_selector_timeout_returns_false)
|
||||||
|
_run("login_flow/wait_login_inputs_filled_no_auto_click_v1_24", test_wait_for_login_inputs_filled_no_auto_click_v1_24)
|
||||||
_run("show_config/masks_tokens", test_show_config_masks_tokens)
|
_run("show_config/masks_tokens", test_show_config_masks_tokens)
|
||||||
_run("show_config/skips_empty", test_show_config_skips_empty)
|
_run("show_config/skips_empty", test_show_config_skips_empty)
|
||||||
_run("show_config/skips_comments", test_show_config_skips_comments)
|
_run("show_config/skips_comments", test_show_config_skips_comments)
|
||||||
|
|||||||
Reference in New Issue
Block a user