feat: 增加会员服务与估价模版智能体

会员服务改为固定栏目,首页在线服务不再进入报告审核。估价模版智能体可多会话制作模版并下载,下载过程显示加载状态。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
wuzilongandCursor committed 2026-11-23 13:36:19 +08:00
1 parent 55b5a87482
commit 2074a45681
63 files changed
+6428 -461

No files matched your search

+20 -2
View File
@@ -10,7 +10,7 @@ from sqlalchemy.exc import IntegrityError
from sqlalchemy.orm import Mapped, mapped_column
from app.db import Base
from app.models.rbac import AdminRole, AdminUser, AdminUserRole
from app.models.rbac import AdminRole, AdminUser, AdminUserRole, bump_admin_credentials
AGENT_ADMIN_ROLE_CODE = "R_AGENT_ADMIN"
AGENT_ADMIN_ROLE_NAME = "智能体管理员"
@@ -275,6 +275,7 @@ def update_agent_record(
admin.status = status_text
if password_hash:
admin.password_hash = password_hash
bump_admin_credentials(admin)
admin.updated_at = datetime.now(timezone.utc)
db.commit()
db.refresh(admin)
@@ -347,7 +348,17 @@ def staff_can_manage(db, user_id: int) -> bool:
return found is not None
def load_agent_actor(db, subject: str) -> AgentActor:
def presented_credential_version(principal: dict) -> int:
raw = principal.get("ver") if isinstance(principal, dict) else None
if raw is None:
return 0
try:
return int(raw)
except (TypeError, ValueError):
return -1
def load_agent_actor(db, subject: str, *, credential_version: int = 0) -> AgentActor:
if subject.startswith("s:"):
try:
user_id = int(subject[2:])
@@ -356,6 +367,11 @@ def load_agent_actor(db, subject: str) -> AgentActor:
user = db.get(AdminUser, user_id)
if user is None or user.status != "active":
raise LookupError("登录已失效")
if int(user.credential_epoch or 0) != int(credential_version):
raise LookupError("登录已失效")
linked = linked_admin_user(db)
if linked is not None and linked.id == user.id and not admin_agent_enabled(db):
raise LookupError("登录已失效")
return AgentActor(
key=subject,
username=user.username,
@@ -372,6 +388,8 @@ def load_agent_actor(db, subject: str) -> AgentActor:
row = get_member_by_id(db, user_id)
if row is None or row.status != "active" or not row.agent_enabled:
raise LookupError("登录已失效")
if int(row.credential_epoch or 0) != int(credential_version):
raise LookupError("登录已失效")
return AgentActor(
key=subject,
username=row.email,