refactor(workflow): Move the plugin component in the Workflow package into the common crossdomain package (#717)

This commit is contained in:
Ryo
2025-08-13 11:06:53 +08:00
committed by GitHub
parent b38ab95623
commit 99c759addc
47 changed files with 1330 additions and 1407 deletions

View File

@@ -35,6 +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"
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"
@@ -64,7 +65,7 @@ type WorkflowHandler struct {
nodeCount int32
requireCheckpoint bool
resumeEvent *entity.InterruptEvent
exeCfg vo.ExecuteConfig
exeCfg plugin.ExecuteConfig
rootTokenCollector *TokenCollector
}
@@ -74,7 +75,7 @@ type ToolHandler struct {
}
func NewRootWorkflowHandler(wb *entity.WorkflowBasic, executeID int64, requireCheckpoint bool,
ch chan<- *Event, resumedEvent *entity.InterruptEvent, exeCfg vo.ExecuteConfig, nodeCount int32,
ch chan<- *Event, resumedEvent *entity.InterruptEvent, exeCfg plugin.ExecuteConfig, nodeCount int32,
) callbacks.Handler {
return &WorkflowHandler{
ch: ch,

View File

@@ -28,6 +28,7 @@ import (
"github.com/cloudwego/eino/compose"
"github.com/coze-dev/coze-studio/backend/api/model/crossdomain/plugin"
"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"
@@ -58,7 +59,7 @@ type RootCtx struct {
RootWorkflowBasic *entity.WorkflowBasic
RootExecuteID int64
ResumeEvent *entity.InterruptEvent
ExeCfg vo.ExecuteConfig
ExeCfg plugin.ExecuteConfig
}
type SubWorkflowCtx struct {

View File

@@ -27,6 +27,7 @@ import (
"github.com/bytedance/sonic"
"github.com/cloudwego/eino/schema"
"github.com/coze-dev/coze-studio/backend/api/model/crossdomain/plugin"
"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"
@@ -63,7 +64,7 @@ func setRootWorkflowSuccess(ctx context.Context, event *Event, repo workflow.Rep
rootWkID := event.RootWorkflowBasic.ID
exeCfg := event.ExeCfg
if exeCfg.Mode == vo.ExecuteModeDebug {
if exeCfg.Mode == plugin.ExecuteModeDebug {
if err := repo.UpdateWorkflowDraftTestRunSuccess(ctx, rootWkID); err != nil {
return fmt.Errorf("failed to save workflow draft test run success: %v", err)
}
@@ -725,7 +726,7 @@ func HandleExecuteEvent(ctx context.Context,
timeoutFn context.CancelFunc,
repo workflow.Repository,
sw *schema.StreamWriter[*entity.Message],
exeCfg vo.ExecuteConfig,
exeCfg plugin.ExecuteConfig,
) (event *Event) {
var (
wfSuccessEvent *Event
@@ -760,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 == vo.ExecuteModeNodeDebug {
if lastNodeIsDone || exeCfg.Mode == plugin.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)

View File

@@ -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"
"github.com/coze-dev/coze-studio/backend/domain/workflow/entity"
"github.com/coze-dev/coze-studio/backend/domain/workflow/entity/vo"
)
type workflowToolOption struct {
resumeReq *entity.ResumeRequest
sw *schema.StreamWriter[*entity.Message]
exeCfg vo.ExecuteConfig
exeCfg plugin.ExecuteConfig
allInterruptEvents map[string]*entity.ToolInterruptEvent
parentTokenCollector *TokenCollector
}
@@ -46,7 +46,7 @@ func WithIntermediateStreamWriter(sw *schema.StreamWriter[*entity.Message]) tool
})
}
func WithExecuteConfig(cfg vo.ExecuteConfig) tool.Option {
func WithExecuteConfig(cfg plugin.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) vo.ExecuteConfig {
func GetExecuteConfig(opts ...tool.Option) plugin.ExecuteConfig {
opt := tool.GetImplSpecificOptions(&workflowToolOption{}, opts...)
return opt.exeCfg
}