fix: delete agent 500 error + dynamic personality + deployment guide

- Fix delete agent 500: clean up FK records (agent_llm_logs, permissions,
  schedules, executions, team_members) and unbind goals/tasks before delete
- Remove hardcoded personality templates in Android, replace with dynamic
  system prompt generation from name + description
- Set promptSectionsEnabled=false to bypass PromptComposer for personality
- Add Tencent Cloud Linux deployment guide (Docker Compose)
- Accumulated backend service updates, frontend UI fixes, Android app changes

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-06-29 01:17:21 +08:00
parent 86b98865e3
commit beff3fac8d
1084 changed files with 117315 additions and 1281 deletions

View File

@@ -1,7 +1,7 @@
"""
工作流API
"""
from fastapi import APIRouter, Depends, HTTPException, status
from fastapi import APIRouter, Depends, HTTPException, status, Request, Query
from sqlalchemy.orm import Session
from pydantic import BaseModel
from typing import List, Optional, Dict, Any
@@ -142,12 +142,13 @@ async def get_workflows(
limit: int = 100,
search: Optional[str] = None,
status: Optional[str] = None,
workspace_id: Optional[str] = Query(None, description="工作区ID筛选"),
sort_by: Optional[str] = "created_at",
sort_order: Optional[str] = "desc",
db: Session = Depends(get_db),
current_user: User = Depends(get_current_user)
):
"""获取工作流列表(支持搜索、筛选、排序)"""
"""获取工作流列表(支持搜索、筛选、排序、工作区筛选"""
# 管理员可以看到所有工作流普通用户只能看到自己拥有的或有read权限的
if current_user.role == "admin":
query = db.query(Workflow)
@@ -155,10 +156,10 @@ async def get_workflows(
# 获取用户拥有或有read权限的工作流
from sqlalchemy import or_
from app.models.permission import WorkflowPermission
# 用户拥有的工作流
owned_workflows = db.query(Workflow.id).filter(Workflow.user_id == current_user.id).subquery()
# 用户有read权限的工作流通过用户ID或角色
user_permissions = db.query(WorkflowPermission.workflow_id).filter(
WorkflowPermission.permission_type == "read",
@@ -167,14 +168,18 @@ async def get_workflows(
WorkflowPermission.role_id.in_([r.id for r in current_user.roles])
)
).subquery()
query = db.query(Workflow).filter(
or_(
Workflow.id.in_(db.query(owned_workflows.c.id)),
Workflow.id.in_(db.query(user_permissions.c.workflow_id))
)
)
# 工作区筛选
if workspace_id:
query = query.filter(Workflow.workspace_id == workspace_id)
# 搜索:按名称或描述搜索
if search:
search_pattern = f"%{search}%"
@@ -211,25 +216,36 @@ async def get_workflows(
@router.post("", response_model=WorkflowResponse, status_code=status.HTTP_201_CREATED)
async def create_workflow(
workflow_data: WorkflowCreate,
request: Request,
db: Session = Depends(get_db),
current_user: User = Depends(get_current_user)
):
"""创建工作流"""
# 从 JWT 提取当前工作区 ID
from app.core.security import decode_access_token
ws_id = None
auth_header = request.headers.get("Authorization", "")
if auth_header.startswith("Bearer "):
payload = decode_access_token(auth_header[7:])
if payload:
ws_id = payload.get("ws") or None
# 验证工作流
validation_result = validate_workflow(workflow_data.nodes, workflow_data.edges)
if not validation_result["valid"]:
raise ValidationError(f"工作流验证失败: {', '.join(validation_result['errors'])}")
# 如果有警告,记录日志
if validation_result["warnings"]:
logger.warning(f"工作流创建警告: {', '.join(validation_result['warnings'])}")
workflow = Workflow(
name=workflow_data.name,
description=workflow_data.description,
nodes=workflow_data.nodes,
edges=workflow_data.edges,
user_id=current_user.id
user_id=current_user.id,
workspace_id=ws_id,
)
db.add(workflow)
db.commit()