feat(in-transit-transfer): 实现在途仓自动调拨Agent一期完整功能

包含后端服务层、任务处理器与消费Worker、前端聊天组件、数据库模型与迁移脚本、测试用例,同时新增外部系统连接器框架基础能力并更新相关文档。
This commit is contained in:
hugo committed 2026-08-28 17:16:06 +08:00
1 parent f3050164d0
commit 6b53b563e7
177 files changed
+17260 -36

No files matched your search

@@ -12,4 +12,5 @@ from __future__ import annotations
RUNTIME_HANDLER_BINDINGS: dict[str, str] = {
'shipping_notice': 'shipping_notice',
'file_check': 'file_check',
'in_transit_transfer': 'in_transit_transfer',
}
@@ -129,3 +129,35 @@ agent_types:
file_upload: true
human_confirm: false
handler_config_schema: {}
in_transit_transfer:
label: 在途仓自动调拨
conversation_mode_default: task_chat
runtime_provider_default: hybrid
models:
- TransferRun
- TransferPrecheck
- TransferInvoiceItem
required_fields: []
default_capabilities:
task_progress: true
human_confirm: true
forced_capabilities:
human_confirm: true
progress_contract:
enabled: true
data_source:
type: domain_state
domain: in_transit_transfer
update:
transport: sse
event: transfer_ui_state
binding:
type: conversation_context
keys:
- run_no
- precheck_id
requires_schedule_task: false
presentation:
layout: card
visualization: stepper
handler_config_schema: {}
@@ -30,10 +30,12 @@ def load_handlers() -> None:
import importlib
import app.services.agent_registry.handlers.file_check as file_check_mod
import app.services.agent_registry.handlers.in_transit_transfer as in_transit_transfer_mod
import app.services.agent_registry.handlers.shipping_notice as shipping_mod
importlib.reload(file_check_mod)
importlib.reload(shipping_mod)
importlib.reload(in_transit_transfer_mod)
logger.info('Agent handlers loaded: %s', sorted(HANDLER_REGISTRY.keys()))
_handlers_loaded = True
@@ -0,0 +1,34 @@
"""
用途:在途仓自动调拨 Hybrid Handler。
依赖:agent_registry.handlers.base/registry。
逻辑:在途调拨的进度与结果卡由 Chat Action(transfer.precheck / transfer.execute)
输出结构化 message.completed 卡片,并经 Run API 恢复;本 Handler 负责 hybrid
运行时的上下文钩子与领域 UI State 扩展位(transfer_ui_state),暂不注入
Dify Chatflow 生命周期。
"""
from __future__ import annotations
from typing import Any
from app.services.agent_registry.handlers.base import AgentHandler, ChatStreamContext
from app.services.agent_registry.handlers.registry import register_handler
@register_handler('in_transit_transfer')
class InTransitTransferHandler(AgentHandler):
"""
在途仓自动调拨业务 Handler。
核心逻辑:预检/执行/结果卡不进入普通 Dify 生命周期(后台 Run 持久化 + 卡片消息
+ Run API 恢复);prepare_stream / build_ui_state_event 预留领域扩展位。
"""
def prepare_stream(self, ctx: ChatStreamContext) -> ChatStreamContext:
"""Dify 流开始前:校验领域上下文(预留 run_no/precheck_id 锚点)。"""
return ctx
def build_ui_state_event(self, ctx: ChatStreamContext) -> dict[str, Any] | None:
"""构造 transfer_ui_state SSE 事件(预留;进度由卡片消息 + Run API 提供)。"""
return None