refactor(workflow): Move domain resources events into the application layer (#729)
This commit is contained in:
@@ -35,7 +35,7 @@ import (
|
||||
"github.com/cloudwego/eino/schema"
|
||||
callbacks2 "github.com/cloudwego/eino/utils/callbacks"
|
||||
|
||||
"github.com/coze-dev/coze-studio/backend/api/model/crossdomain/plugin"
|
||||
workflowModel "github.com/coze-dev/coze-studio/backend/api/model/crossdomain/workflow"
|
||||
workflow2 "github.com/coze-dev/coze-studio/backend/api/model/workflow"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/workflow"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/workflow/entity"
|
||||
@@ -65,7 +65,7 @@ type WorkflowHandler struct {
|
||||
nodeCount int32
|
||||
requireCheckpoint bool
|
||||
resumeEvent *entity.InterruptEvent
|
||||
exeCfg plugin.ExecuteConfig
|
||||
exeCfg workflowModel.ExecuteConfig
|
||||
rootTokenCollector *TokenCollector
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ type ToolHandler struct {
|
||||
}
|
||||
|
||||
func NewRootWorkflowHandler(wb *entity.WorkflowBasic, executeID int64, requireCheckpoint bool,
|
||||
ch chan<- *Event, resumedEvent *entity.InterruptEvent, exeCfg plugin.ExecuteConfig, nodeCount int32,
|
||||
ch chan<- *Event, resumedEvent *entity.InterruptEvent, exeCfg workflowModel.ExecuteConfig, nodeCount int32,
|
||||
) callbacks.Handler {
|
||||
return &WorkflowHandler{
|
||||
ch: ch,
|
||||
|
||||
@@ -28,7 +28,7 @@ import (
|
||||
|
||||
"github.com/cloudwego/eino/compose"
|
||||
|
||||
"github.com/coze-dev/coze-studio/backend/api/model/crossdomain/plugin"
|
||||
workflowModel "github.com/coze-dev/coze-studio/backend/api/model/crossdomain/workflow"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/workflow"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/workflow/entity"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/workflow/entity/vo"
|
||||
@@ -59,7 +59,7 @@ type RootCtx struct {
|
||||
RootWorkflowBasic *entity.WorkflowBasic
|
||||
RootExecuteID int64
|
||||
ResumeEvent *entity.InterruptEvent
|
||||
ExeCfg plugin.ExecuteConfig
|
||||
ExeCfg workflowModel.ExecuteConfig
|
||||
}
|
||||
|
||||
type SubWorkflowCtx struct {
|
||||
|
||||
@@ -27,7 +27,7 @@ import (
|
||||
"github.com/bytedance/sonic"
|
||||
"github.com/cloudwego/eino/schema"
|
||||
|
||||
"github.com/coze-dev/coze-studio/backend/api/model/crossdomain/plugin"
|
||||
workflowModel "github.com/coze-dev/coze-studio/backend/api/model/crossdomain/workflow"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/workflow"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/workflow/entity"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/workflow/entity/vo"
|
||||
@@ -64,7 +64,7 @@ func setRootWorkflowSuccess(ctx context.Context, event *Event, repo workflow.Rep
|
||||
|
||||
rootWkID := event.RootWorkflowBasic.ID
|
||||
exeCfg := event.ExeCfg
|
||||
if exeCfg.Mode == plugin.ExecuteModeDebug {
|
||||
if exeCfg.Mode == workflowModel.ExecuteModeDebug {
|
||||
if err := repo.UpdateWorkflowDraftTestRunSuccess(ctx, rootWkID); err != nil {
|
||||
return fmt.Errorf("failed to save workflow draft test run success: %v", err)
|
||||
}
|
||||
@@ -726,7 +726,7 @@ func HandleExecuteEvent(ctx context.Context,
|
||||
timeoutFn context.CancelFunc,
|
||||
repo workflow.Repository,
|
||||
sw *schema.StreamWriter[*entity.Message],
|
||||
exeCfg plugin.ExecuteConfig,
|
||||
exeCfg workflowModel.ExecuteConfig,
|
||||
) (event *Event) {
|
||||
var (
|
||||
wfSuccessEvent *Event
|
||||
@@ -761,7 +761,7 @@ func HandleExecuteEvent(ctx context.Context,
|
||||
return event
|
||||
case workflowSuccess: // workflow success, wait for exit node to be done
|
||||
wfSuccessEvent = event
|
||||
if lastNodeIsDone || exeCfg.Mode == plugin.ExecuteModeNodeDebug {
|
||||
if lastNodeIsDone || exeCfg.Mode == workflowModel.ExecuteModeNodeDebug {
|
||||
if err = setRootWorkflowSuccess(ctx, wfSuccessEvent, repo, sw); err != nil {
|
||||
logs.CtxErrorf(ctx, "failed to set root workflow success for workflow %d: %v",
|
||||
wfSuccessEvent.RootWorkflowBasic.ID, err)
|
||||
|
||||
@@ -21,14 +21,14 @@ import (
|
||||
"github.com/cloudwego/eino/compose"
|
||||
"github.com/cloudwego/eino/schema"
|
||||
|
||||
"github.com/coze-dev/coze-studio/backend/api/model/crossdomain/plugin"
|
||||
workflowModel "github.com/coze-dev/coze-studio/backend/api/model/crossdomain/workflow"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/workflow/entity"
|
||||
)
|
||||
|
||||
type workflowToolOption struct {
|
||||
resumeReq *entity.ResumeRequest
|
||||
sw *schema.StreamWriter[*entity.Message]
|
||||
exeCfg plugin.ExecuteConfig
|
||||
exeCfg workflowModel.ExecuteConfig
|
||||
allInterruptEvents map[string]*entity.ToolInterruptEvent
|
||||
parentTokenCollector *TokenCollector
|
||||
}
|
||||
@@ -46,7 +46,7 @@ func WithIntermediateStreamWriter(sw *schema.StreamWriter[*entity.Message]) tool
|
||||
})
|
||||
}
|
||||
|
||||
func WithExecuteConfig(cfg plugin.ExecuteConfig) tool.Option {
|
||||
func WithExecuteConfig(cfg workflowModel.ExecuteConfig) tool.Option {
|
||||
return tool.WrapImplSpecificOptFn(func(opts *workflowToolOption) {
|
||||
opts.exeCfg = cfg
|
||||
})
|
||||
@@ -62,7 +62,7 @@ func GetIntermediateStreamWriter(opts ...tool.Option) *schema.StreamWriter[*enti
|
||||
return opt.sw
|
||||
}
|
||||
|
||||
func GetExecuteConfig(opts ...tool.Option) plugin.ExecuteConfig {
|
||||
func GetExecuteConfig(opts ...tool.Option) workflowModel.ExecuteConfig {
|
||||
opt := tool.GetImplSpecificOptions(&workflowToolOption{}, opts...)
|
||||
return opt.exeCfg
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user