feat: 新增主动拉取与多类型回调功能

- 新增 ActivePull 实体、DAO、DTO 及 Service,支持主动拉取任务管理
- 新增 ComposeCallback、VideoCallback、HttpNodeCallback 多类型回调接口
- FlowExecution 增加 NodeGroupId 和 TotalTokens 字段,支持节点组追踪与 Token 统计
- ExecutedNodes 结构由字符串列表改为包含执行状态的节点对象列表
- 重构回调通知机制,统一 Notify 函数调用
- 优化输出项类型判断逻辑,新增文件类型标识
This commit is contained in:
2026-06-10 14:23:55 +08:00
parent ab3a2d967e
commit 03c95c3601
33 changed files with 3207 additions and 615 deletions

View File

@@ -2,13 +2,14 @@ package flow
import (
"ai-agent/workflow/consts/flow"
"ai-agent/workflow/consts/node"
flowDao "ai-agent/workflow/dao/flow"
flowDto "ai-agent/workflow/model/dto/flow"
"ai-agent/workflow/model/entity"
"ai-agent/workflow/service"
"context"
"gitea.com/red-future/common/beans"
commonHttp "gitea.com/red-future/common/http"
"gitea.com/red-future/common/utils"
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/util/gconv"
@@ -18,25 +19,8 @@ var FlowUserService = &flowUserService{}
type flowUserService struct{}
// IsAdmin 调用admin-go服务检查是否是管理员
func IsAdmin(ctx context.Context) (res bool, err error) {
headers := make(map[string]string)
if r := g.RequestFromCtx(ctx); r != nil {
for k, v := range r.Request.Header {
if len(v) > 0 {
headers[k] = v[0]
}
}
}
var r = make(map[string]bool)
if err = commonHttp.Get(ctx, "admin-go/api/v1/system/user/checkIsSuperAdmin", headers, &r); err != nil {
return false, err
}
return r["isSuperAdmin"], err
}
func (s *flowUserService) Create(ctx context.Context, req *flowDto.CreateFlowUserReq) (res *flowDto.CreateFlowUserRes, err error) {
admin, err := IsAdmin(ctx)
admin, err := service.UtilService.IsAdmin(ctx)
if err != nil {
return
}
@@ -57,7 +41,7 @@ func (s *flowUserService) Create(ctx context.Context, req *flowDto.CreateFlowUse
}
func (s *flowUserService) Update(ctx context.Context, req *flowDto.UpdateFlowUserReq) (err error) {
admin, err := IsAdmin(ctx)
admin, err := service.UtilService.IsAdmin(ctx)
if err != nil {
return
}
@@ -97,6 +81,26 @@ func (s *flowUserService) Update(ctx context.Context, req *flowDto.UpdateFlowUse
}
func ExtractFlowNodeFrom(flowContent *entity.FlowInfo) []*entity.FlowNode {
// 构建每个节点的上游节点映射
upstreamMap := make(map[string][]string)
for _, edge := range flowContent.Edges {
upstreamMap[edge.To] = append(upstreamMap[edge.To], edge.From)
}
// 同时更新 flowContent.Nodes 中的 DataMerge 节点
for i := range flowContent.Nodes {
n := &flowContent.Nodes[i]
// 对于 DataMerge 节点,自动根据边关系填充 InputSource
if n.NodeCode == node.NodeTypeDataMerge {
n.InputSource = nil
for _, fromId := range upstreamMap[n.Id] {
n.InputSource = append(n.InputSource, entity.FlowNodeInputSource{
NodeId: fromId,
})
}
}
}
var flowNodes []*entity.FlowNode
for _, item := range flowContent.Nodes {
flowNodes = append(flowNodes, &item)
@@ -105,7 +109,7 @@ func ExtractFlowNodeFrom(flowContent *entity.FlowInfo) []*entity.FlowNode {
}
func (s *flowUserService) Delete(ctx context.Context, req *flowDto.DeleteFlowUserReq) (err error) {
admin, err := IsAdmin(ctx)
admin, err := service.UtilService.IsAdmin(ctx)
if err != nil {
return
}
@@ -146,7 +150,7 @@ func (s *flowUserService) Get(ctx context.Context, req *flowDto.GetFlowUserReq)
}
func (s *flowUserService) List(ctx context.Context, req *flowDto.ListFlowUserReq) (res *flowDto.ListFlowRes, err error) {
admin, err := IsAdmin(ctx)
admin, err := service.UtilService.IsAdmin(ctx)
if err != nil {
return
}