feat(rpa): ensure_profile_free for same-profile browser release (1.2.13)
All checks were successful
Publish Python Package to Gitea / publish (push) Successful in 25s

Add precise Chrome/Edge quit by user-data-dir and stale SingletonLock cleanup so publish RPAs can free account-manager windows before launch without killing the default browser.
This commit is contained in:
2026-10-21 09:07:27 +08:00
parent 28abd3509a
commit 6c75ade463
7 changed files with 564 additions and 1 deletions

View File

@@ -282,6 +282,8 @@ print(runtime_diagnostics_dict(diag)) # 可 JSON 序列化
自 **1.2.11** 起,`runtime_diagnostics_dict` 额外包含只读字段 `machine_power`(AC 供电 / 可选 nvidia-smi 限频信息)。探不到则 `probed=false`,**不会**因此把 health 标为 fatal。
自 **1.2.13** 起,提供按 Profile 精准关闭:`ensure_profile_free` / `force_quit_profile_browsers`(只杀命令行含该 `user-data-dir` 的 Chrome/Edge,不碰系统默认浏览器),并可选清理崩溃残留 `SingletonLock`。
### RPA 有界就绪等待与启动超时(1.2.11+)
```python
@@ -298,6 +300,20 @@ if result.timed_out:
# 或环境变量 OPENCLAW_BROWSER_LAUNCH_TIMEOUT_MS=60000
```
### RPA Profile 占用释放(1.2.13+)
```python
from jiangchang_skill_core.rpa import ensure_profile_free, launch_persistent_browser
from jiangchang_skill_core.rpa.errors import ERR_PROFILE_IN_USE
# 发布前:关掉账号管理「打开浏览器」占用的同一 Profile,再启动
result = ensure_profile_free(profile_dir)
# result.pids_before / killed_ops / stale_lock_cleared / freed
# 或在统一启动封装上打开开关(默认 False,保持旧行为)
# context = await launch_persistent_browser(pw, profile_dir=..., ensure_free=True)
```
薄错误码(技能自行决定是否 fatal / retryable):
- `ERROR:UI_NOT_READY`