Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 44eafff757 |
@@ -3,6 +3,10 @@
|
|||||||
本文件对应技能市场 **「更新日志」** Tab。
|
本文件对应技能市场 **「更新日志」** Tab。
|
||||||
发布 CI 会按当前 tag 版本提取匹配的 `##` 小节。
|
发布 CI 会按当前 tag 版本提取匹配的 `##` 小节。
|
||||||
|
|
||||||
|
## 2.0.26
|
||||||
|
|
||||||
|
- 「打开浏览器」启动前写入 Profile「继续上次会话」,减轻独立 Profile 下 Session Cookie 关窗后丢失(科力普等站点更明显)
|
||||||
|
|
||||||
## 2.0.25
|
## 2.0.25
|
||||||
|
|
||||||
- 「账号租约」表新增行右键「强制释放租约」:仅状态为 active 时显示,确认后立刻释放,无需租约令牌
|
- 「账号租约」表新增行右键「强制释放租约」:仅状态为 active 时显示,确认后立刻释放,无需租约令牌
|
||||||
|
|||||||
2
SKILL.md
2
SKILL.md
@@ -1,7 +1,7 @@
|
|||||||
---
|
---
|
||||||
name: 账号与凭据管理
|
name: 账号与凭据管理
|
||||||
description: "通用账号 & 凭据 & 登录流程管理器。管理网页/RPA 账号、API Key/Token;支持 9 种登录策略(账密自动、扫码、2FA、SSO 等);提供加密本地存储(Fernet);提供 rpa_helpers 库供业务 skill 同进程调用 ensure_logged_in 完成多平台自动登录。涵盖物流、LLM、内容、开发、API 五类平台。"
|
description: "通用账号 & 凭据 & 登录流程管理器。管理网页/RPA 账号、API Key/Token;支持 9 种登录策略(账密自动、扫码、2FA、SSO 等);提供加密本地存储(Fernet);提供 rpa_helpers 库供业务 skill 同进程调用 ensure_logged_in 完成多平台自动登录。涵盖物流、LLM、内容、开发、API 五类平台。"
|
||||||
version: 2.0.25
|
version: 2.0.26
|
||||||
author: 深圳匠厂科技有限公司
|
author: 深圳匠厂科技有限公司
|
||||||
metadata:
|
metadata:
|
||||||
openclaw:
|
openclaw:
|
||||||
|
|||||||
@@ -59,4 +59,4 @@ description: "通用账号 & 凭据 & 登录流程管理器。管理网页/RPA
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
**作者**:深圳匠厂科技有限公司 · **版本**:2.0.25
|
**作者**:深圳匠厂科技有限公司 · **版本**:2.0.26
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import sys
|
|||||||
|
|
||||||
from db.connection import get_conn, init_db
|
from db.connection import get_conn, init_db
|
||||||
from db.accounts_repo import get_account_by_id, get_platform_from_db
|
from db.accounts_repo import get_account_by_id, get_platform_from_db
|
||||||
|
from service.chrome_profile_prefs import ensure_session_restore
|
||||||
from util.logging_config import get_skill_logger
|
from util.logging_config import get_skill_logger
|
||||||
from util.platforms import PLATFORMS
|
from util.platforms import PLATFORMS
|
||||||
|
|
||||||
@@ -225,6 +226,10 @@ def cmd_open(account_id):
|
|||||||
profile_abs = os.path.abspath(profile_dir)
|
profile_abs = os.path.abspath(profile_dir)
|
||||||
os.makedirs(profile_abs, exist_ok=True)
|
os.makedirs(profile_abs, exist_ok=True)
|
||||||
|
|
||||||
|
# 独立 Profile 默认不会「继续上次会话」,Session Cookie 关窗即丢;打开前写入 Preferences
|
||||||
|
prefs_result = ensure_session_restore(profile_abs)
|
||||||
|
log.info("browser_open_prefs %s", prefs_result)
|
||||||
|
|
||||||
conn = get_conn()
|
conn = get_conn()
|
||||||
try:
|
try:
|
||||||
url = resolve_account_browser_url(target, conn=conn)
|
url = resolve_account_browser_url(target, conn=conn)
|
||||||
@@ -235,11 +240,12 @@ def cmd_open(account_id):
|
|||||||
cmd = [browser_exe, *human_chrome_launch_args(profile_abs, url)]
|
cmd = [browser_exe, *human_chrome_launch_args(profile_abs, url)]
|
||||||
|
|
||||||
log.info(
|
log.info(
|
||||||
"browser_open_launch exe=%s profile_dir=%s url=%s platform=%s",
|
"browser_open_launch exe=%s profile_dir=%s url=%s platform=%s restore_on_startup=%s",
|
||||||
browser_exe,
|
browser_exe,
|
||||||
profile_abs,
|
profile_abs,
|
||||||
url,
|
url,
|
||||||
target.get("platform_key"),
|
target.get("platform_key"),
|
||||||
|
prefs_result.get("restore_after"),
|
||||||
)
|
)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@@ -289,6 +295,7 @@ def cmd_open(account_id):
|
|||||||
"profile_dir": profile_abs,
|
"profile_dir": profile_abs,
|
||||||
"url": url,
|
"url": url,
|
||||||
"pid": child.pid,
|
"pid": child.pid,
|
||||||
|
"session_restore_on_startup": prefs_result.get("restore_after"),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
ensure_ascii=False,
|
ensure_ascii=False,
|
||||||
|
|||||||
80
scripts/service/chrome_profile_prefs.py
Normal file
80
scripts/service/chrome_profile_prefs.py
Normal file
@@ -0,0 +1,80 @@
|
|||||||
|
"""Chrome/Edge 独立 Profile:启用「继续上次会话」,让 Session Cookie 可跨次打开保留。"""
|
||||||
|
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import json
|
||||||
|
import logging
|
||||||
|
import os
|
||||||
|
from typing import Any, Dict
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
RESTORE_CONTINUE_WHERE_LEFT_OFF = 1
|
||||||
|
|
||||||
|
|
||||||
|
def preferences_path(profile_dir: str) -> str:
|
||||||
|
return os.path.join(os.path.abspath(profile_dir), "Default", "Preferences")
|
||||||
|
|
||||||
|
|
||||||
|
def ensure_session_restore(profile_dir: str) -> Dict[str, Any]:
|
||||||
|
"""启动浏览器前写入 session.restore_on_startup=1;Crashed → Normal。"""
|
||||||
|
profile_abs = os.path.abspath(profile_dir)
|
||||||
|
prefs = preferences_path(profile_abs)
|
||||||
|
os.makedirs(os.path.dirname(prefs), exist_ok=True)
|
||||||
|
data: Dict[str, Any] = {}
|
||||||
|
existed = os.path.isfile(prefs)
|
||||||
|
if existed:
|
||||||
|
try:
|
||||||
|
with open(prefs, "r", encoding="utf-8") as fh:
|
||||||
|
data = json.load(fh)
|
||||||
|
except Exception:
|
||||||
|
logger.exception("chrome_prefs_read_failed path=%s", prefs)
|
||||||
|
data = {}
|
||||||
|
|
||||||
|
before = int((data.get("session") or {}).get("restore_on_startup") or 0)
|
||||||
|
exit_before = str((data.get("profile") or {}).get("exit_type") or "")
|
||||||
|
|
||||||
|
session = data.setdefault("session", {})
|
||||||
|
session["restore_on_startup"] = RESTORE_CONTINUE_WHERE_LEFT_OFF
|
||||||
|
|
||||||
|
profile = data.setdefault("profile", {})
|
||||||
|
if str(profile.get("exit_type") or "").lower() == "crashed":
|
||||||
|
profile["exit_type"] = "Normal"
|
||||||
|
|
||||||
|
try:
|
||||||
|
with open(prefs, "w", encoding="utf-8") as fh:
|
||||||
|
json.dump(data, fh, ensure_ascii=False, separators=(",", ":"))
|
||||||
|
except Exception as exc:
|
||||||
|
logger.warning("chrome_prefs_write_failed path=%s err=%s", prefs, exc)
|
||||||
|
return {
|
||||||
|
"ok": False,
|
||||||
|
"path": prefs,
|
||||||
|
"existed": existed,
|
||||||
|
"restore_before": before,
|
||||||
|
"restore_after": before,
|
||||||
|
"exit_type_before": exit_before,
|
||||||
|
"error": str(exc),
|
||||||
|
}
|
||||||
|
|
||||||
|
after = int((data.get("session") or {}).get("restore_on_startup") or 0)
|
||||||
|
exit_after = str((data.get("profile") or {}).get("exit_type") or "")
|
||||||
|
logger.info(
|
||||||
|
"chrome_session_restore_ensured profile_dir=%s prefs=%s existed=%s "
|
||||||
|
"restore_on_startup %s->%s exit_type %s->%s",
|
||||||
|
profile_abs,
|
||||||
|
prefs,
|
||||||
|
existed,
|
||||||
|
before,
|
||||||
|
after,
|
||||||
|
exit_before or "-",
|
||||||
|
exit_after or "-",
|
||||||
|
)
|
||||||
|
return {
|
||||||
|
"ok": True,
|
||||||
|
"path": prefs,
|
||||||
|
"existed": existed,
|
||||||
|
"restore_before": before,
|
||||||
|
"restore_after": after,
|
||||||
|
"exit_type_before": exit_before,
|
||||||
|
"exit_type_after": exit_after,
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user