chore: auto release commit (2026-05-30 19:51:46)
All checks were successful
技能自动化发布 / release (push) Successful in 5s

This commit is contained in:
2026-05-30 19:51:46 +08:00
parent a7bd6ff9d8
commit cb980704bf
3 changed files with 163 additions and 11 deletions

View File

@@ -763,6 +763,49 @@ def get_active_lease_by_token(conn, lease_token: str) -> Optional[dict[str, Any]
}
def upsert_platform(
conn,
key: str,
display_name: str,
domain: str = "generic",
provider_code: str | None = None,
default_url: str = "",
aliases_json: str = "[]",
capabilities_json: str = '{"web": true, "api_key": false, "rpa": true}',
default_auth_strategy: str | None = None,
) -> None:
"""幂等地注册或更新平台到 DB。"""
now = int(time.time())
if provider_code is None:
provider_code = key
conn.execute(
"""
INSERT INTO platforms (
platform_key, display_name, domain, provider_code,
default_url, aliases_json, capabilities_json,
enabled, default_auth_strategy, created_at, updated_at
) VALUES (?, ?, ?, ?, ?, ?, ?, 1, ?, ?, ?)
ON CONFLICT(platform_key) DO UPDATE SET
display_name = excluded.display_name,
domain = excluded.domain,
provider_code = excluded.provider_code,
default_url = excluded.default_url,
aliases_json = excluded.aliases_json,
capabilities_json = excluded.capabilities_json,
enabled = 1,
default_auth_strategy = COALESCE(excluded.default_auth_strategy,
platforms.default_auth_strategy),
updated_at = excluded.updated_at
""",
(
key, display_name, domain, provider_code,
default_url, aliases_json, capabilities_json,
default_auth_strategy, now, now,
),
)
conn.commit()
# ============================================================================
# Internal helpers
# ============================================================================