refactor(agent, shipping): 简化代理模型并完善订单抽取业务
- 移除 Agent 的 exposure_mode 与 internal_executor 相关逻辑,清理关联的过滤、序列化代码 - 删除废弃的 AgentRuntimeBinding 模型及其依赖 - 新增订单抽取上传批次、请求快照等数据库迁移与业务逻辑 - 修复附件完整性检测、订单抽取状态映射问题 - 更新多语言错误文案与前端单元测试配置 - 清理平台配置中不再使用的暴露模式配置
This commit is contained in:
1 parent
1f3ecb87b7
commit
61ac6403c4
159 files changed
+12883
-5099
No files matched your search
@@ -13,7 +13,6 @@ from typing import Any
|
||||
from app import db
|
||||
from app.core.errors import NotFoundError, ValidationError
|
||||
from app.models import Agent, PermissionRequest, User
|
||||
from app.services.agent_user_access import load_grantable_agents, require_user_application
|
||||
from app.services.wecom_notify import send_wecom_event_message
|
||||
|
||||
_BATCH_ACTION_LABELS = {'add': '新增', 'remove': '移除', 'set': '重置为'}
|
||||
@@ -33,7 +32,7 @@ def serialize_permission_request(req: PermissionRequest) -> dict:
|
||||
|
||||
def _load_users_and_agents(user_ids: list[Any], agent_ids: list[Any]) -> tuple[list[User], list[Agent]]:
|
||||
users = db.session.query(User).filter(User.id.in_(user_ids)).all()
|
||||
agents = load_grantable_agents(agent_ids)
|
||||
agents = db.session.query(Agent).filter(Agent.id.in_(agent_ids)).all()
|
||||
return users, agents
|
||||
|
||||
|
||||
@@ -105,18 +104,16 @@ def update_user_permissions(user_id: int, data: dict[str, Any]) -> dict:
|
||||
if not user:
|
||||
raise NotFoundError('Not found')
|
||||
agent_ids = data.get('agent_ids', [])
|
||||
agents = load_grantable_agents(agent_ids)
|
||||
agents = db.session.query(Agent).filter(Agent.id.in_(agent_ids)).all()
|
||||
user.agents = agents
|
||||
db.session.commit()
|
||||
return {'status': 'ok'}
|
||||
|
||||
|
||||
def list_permission_requests() -> list[dict]:
|
||||
"""返回 workspace 应用的权限申请;内部执行器申请仅保留数据库审计。"""
|
||||
"""返回全部权限申请(按 created_at 降序)。"""
|
||||
reqs = (
|
||||
db.session.query(PermissionRequest)
|
||||
.join(Agent, Agent.id == PermissionRequest.agent_id)
|
||||
.filter(Agent.exposure_mode == 'workspace')
|
||||
.order_by(PermissionRequest.created_at.desc())
|
||||
.all()
|
||||
)
|
||||
@@ -135,9 +132,6 @@ def approve_permission_request(request_id: int) -> dict:
|
||||
|
||||
user = db.session.get(User, req.user_id)
|
||||
agent = db.session.get(Agent, req.agent_id)
|
||||
if not user:
|
||||
raise NotFoundError('User not found')
|
||||
require_user_application(agent)
|
||||
req.status = 'approved'
|
||||
req.reviewed_at = datetime.utcnow()
|
||||
if user and agent and (agent not in user.agents):
|
||||
|
||||
Reference in new issue
Block a user