feat(shipping-notice): 增强订单抽取功能,添加进度事件和诊断运行管理,优化数据模型和访问控制
This commit is contained in:
1 parent
ce26d6d0c4
commit
c4095b08da
175 files changed
+13064
-1814
No files matched your search
@@ -70,8 +70,34 @@
|
||||
|
||||
- Catalog 只声明稳定能力编码及允许的 Provider 类型,不保存具体 Agent/App ID。
|
||||
- 管理员先创建 `exposure_mode=internal` 的 Provider Agent,再在入口 Agent 表单显式选择绑定;运行时只查数据库外键,不按名称匹配、不写死 ID、不使用环境变量静默回退。
|
||||
- 入口 Agent 注册后,Catalog 声明的必需能力天然生效;表单只指定执行器 Provider 和超时/重试参数,不再提供“启用订单抽取服务”勾选。后端旧 `enabled` 字段保留用于历史 API 和运维停用。
|
||||
- 内部 Provider 复用 `agents` 表保存 Dify App ID、Base URL 和 API Key,但不出现在用户工作台、权限分配或普通 Agent 列表中。
|
||||
- 订单抽取能力当前只允许 `runtime_provider=dify + dify_app_type=workflow + exposure_mode=internal`。绑定可配置超时和最大尝试次数。
|
||||
- 订单抽取能力的 Provider 技术约束由入口 Agent Catalog 的 `required_runtime_capabilities` 声明;具体用途由 `AgentRuntimeBinding.capability_code` 与管理员选择的执行器共同确定。
|
||||
|
||||
### 2.2 effective_role(兼容派生字段)
|
||||
|
||||
`effective_role` 是只读运行时派生值,不新增数据库列:`exposure_mode=internal` 时为
|
||||
`internal_executor`,其他情况为 `user_agent`。旧 `conversation_mode`、`exposure_mode`、
|
||||
`type` 和 `extra_config` 字段继续按原 API 契约返回;历史内部 Provider 即使仍保存旧的
|
||||
`conversation_mode`,该值也不参与聊天呈现。只有 `user_agent` 使用 `conversation_mode`,
|
||||
内部执行器的表单应隐藏对话形态等聊天配置。
|
||||
|
||||
`exposure_mode=internal` 是内部执行器注册入口的固定属性,不提供编辑切换;内部执行器不能转为工作台应用。
|
||||
|
||||
管理端采用两个独立页签:`应用` 页仅管理 `exposure_mode=workspace` 的用户入口,`内部执行器`
|
||||
页仅管理 `exposure_mode=internal` 的后台 Provider。两个页签分别提供“新建应用”和“新建内部执行器”入口,
|
||||
后端列表通过 `GET /api/admin/agents?scope=applications|executors` 隔离;不传 `scope` 仅用于旧客户端兼容。
|
||||
两类资源创建后禁止互相转换。
|
||||
|
||||
用户侧采用强隔离策略:所有用户授权、公开列表、工作台、收藏、默认应用、常用问题、新手指南、
|
||||
Agent 详情及普通 Chat API 只接受 `exposure_mode=workspace`。该约束同样适用于管理员通过用户入口访问;
|
||||
内部执行器只能在管理页配置,并由后台 Runtime Binding 调用。后端写入口必须拒绝 internal ID,读取入口
|
||||
仍需防御性过滤历史脏关系;数据迁移清理用户授权、收藏与默认应用,并将内部执行器待审批申请置为拒绝。
|
||||
|
||||
内部执行器注册时不登记业务服务编码。执行器只保存 Dify Workflow 的技术连接信息;业务用途
|
||||
由应用侧 `AgentRuntimeBinding.capability_code + provider_agent_id` 表达。当前暂不实现绑定级契约认证,
|
||||
管理员可从所有启用的内部 Dify Workflow 中选择具体执行器。
|
||||
- Run 冻结 Provider App ID/Base URL 和运行参数以保证执行身份稳定;API Key 不进入 Run 快照,以支持密钥轮换。
|
||||
|
||||
### 2.1 conversation_mode
|
||||
|
||||
@@ -258,7 +258,7 @@ flask db upgrade
|
||||
| --- | --- | --- | --- |
|
||||
| `agent_code` | `String(64)` | `'generic'` | 非 UNIQUE |
|
||||
| `runtime_provider` | `String(32)` | `'dify'` | dify \| builtin \| hybrid \| iframe |
|
||||
| `conversation_mode` | `String(32)` | `'chat'` | chat \| task_chat \| embedded |
|
||||
| `conversation_mode` | `String(32)` | `'chat'` | chat \| task_chat \| embedded;internal Provider 历史保留但运行时忽略 |
|
||||
| `dify_app_type` | `String(20)` | `'chatflow'` | chatflow \| workflow |
|
||||
| `iframe_url` | `String(500)` | NULL | |
|
||||
| `category` | `String(64)` | NULL | |
|
||||
@@ -318,6 +318,9 @@ def resolve_runtime_provider(agent) -> str:
|
||||
def resolve_conversation_mode(agent) -> str:
|
||||
"""只读 agents.conversation_mode 列;缺省 chat。"""
|
||||
|
||||
def resolve_effective_role(agent) -> str:
|
||||
"""exposure_mode=internal 时返回 internal_executor,否则返回 user_agent。"""
|
||||
|
||||
def resolve_capabilities(agent) -> dict:
|
||||
"""只读 agents.capabilities 列;NULL 时 DEFAULT_CAPABILITIES。"""
|
||||
|
||||
@@ -626,6 +629,25 @@ Intent Router **不**替代 `runtime_provider`;仅在 `completions` 内先于
|
||||
|
||||
### 8.4 迁移退出(代码已完成,环境待 backfill)
|
||||
|
||||
### 8.5 内部执行器历史兼容
|
||||
|
||||
- 旧客户端仍可读写 `conversation_mode`、`exposure_mode`、`type`、`extra_config` 和 Runtime Binding `enabled`;结构化列优先,`extra_config` 不参与运行时兜底。
|
||||
- 历史 `exposure_mode=internal` Provider 的 `conversation_mode` 原值保留,但运行时忽略;不得批量改为 `workspace`。
|
||||
- 新建 internal 记录强制为 `dify + workflow`;历史非法组合允许读取和编辑,但不能新建绑定或执行新 Run。
|
||||
- 迁移只允许先 dry-run 诊断,再由管理员逐项修正;不得按名称猜测订单抽取 Provider,也不得自动切换已有绑定。
|
||||
- 历史 Run 继续使用冻结的 Provider 身份;API Key 不冻结,允许轮换。App ID、Base URL 或协议漂移继续触发执行身份门禁。
|
||||
- 内部执行器不持久化业务服务编码;业务能力用途以 Runtime Binding 的 `capability_code` 为权威来源。
|
||||
|
||||
### 8.6 管理端双页签
|
||||
|
||||
- `应用` 页签调用 `/api/admin/agents?scope=applications`,只展示 workspace 用户入口。
|
||||
- `内部执行器` 页签调用 `/api/admin/agents?scope=executors`,只展示 internal Provider。
|
||||
- 应用表单不显示内部服务类型;内部执行器表单不显示应用类型、对话形态、应用可见性、用户权限及聊天配置。
|
||||
- `exposure_mode` 由创建入口固定,已有资源禁止在两种角色之间转换。
|
||||
- 用户管理、权限矩阵、常用问题、热点和应用资料选择器显式请求 `scope=applications`;旧客户端无 scope 返回全部仅用于管理兼容,不得用于用户授权。
|
||||
- 后端统一通过 `agent_user_access` 策略阻断 internal ID:授权写入明确失败,公开/工作台/详情/指南/收藏/快捷问题/普通 Chat 防御性过滤或拒绝,管理员用户入口不例外。
|
||||
- 迁移 `a62b3c4d5e6f` 清理内部执行器的用户授权、收藏、首页默认关系及 `users.default_agent_id`,并拒绝尚未处理的内部执行器权限申请;历史内容与已审批记录保留用于审计。
|
||||
|
||||
**代码变更(已合入)**:
|
||||
|
||||
| 步骤 | 文件 | 状态 |
|
||||
|
||||
Reference in new issue
Block a user