refactor(workflow): Move domain resources events into the application layer (#729)

This commit is contained in:
Ryo
2025-08-13 21:06:56 +08:00
committed by GitHub
parent 8c3ae99643
commit 5d98e8ef93
47 changed files with 661 additions and 761 deletions

View File

@@ -22,8 +22,10 @@ import (
"github.com/cloudwego/eino/schema"
model "github.com/coze-dev/coze-studio/backend/api/model/crossdomain/plugin"
"github.com/coze-dev/coze-studio/backend/api/model/crossdomain/workflow"
)
//go:generate mockgen -destination pluginmock/plugin_mock.go --package pluginmock -source plugin.go
type PluginService interface {
MGetVersionPlugins(ctx context.Context, versionPlugins []model.VersionPlugin) (plugins []*model.PluginInfo, err error)
MGetPluginLatestVersion(ctx context.Context, pluginIDs []int64) (resp *model.MGetPluginLatestVersionResponse, err error)
@@ -39,12 +41,12 @@ type PluginService interface {
MGetVersionTools(ctx context.Context, versionTools []model.VersionTool) (tools []*model.ToolInfo, err error)
GetPluginToolsInfo(ctx context.Context, req *model.ToolsInfoRequest) (*model.ToolsInfoResponse, error)
GetPluginInvokableTools(ctx context.Context, req *model.ToolsInvokableRequest) (map[int64]InvokableTool, error)
ExecutePlugin(ctx context.Context, input map[string]any, pe *model.PluginEntity, toolID int64, cfg model.ExecuteConfig) (map[string]any, error)
ExecutePlugin(ctx context.Context, input map[string]any, pe *model.PluginEntity, toolID int64, cfg workflow.ExecuteConfig) (map[string]any, error)
}
type InvokableTool interface {
Info(ctx context.Context) (*schema.ToolInfo, error)
PluginInvoke(ctx context.Context, argumentsInJSON string, cfg model.ExecuteConfig) (string, error)
PluginInvoke(ctx context.Context, argumentsInJSON string, cfg workflow.ExecuteConfig) (string, error)
}
var defaultSVC PluginService

View File

@@ -15,6 +15,7 @@ import (
schema "github.com/cloudwego/eino/schema"
plugin "github.com/coze-dev/coze-studio/backend/api/model/crossdomain/plugin"
workflow "github.com/coze-dev/coze-studio/backend/api/model/crossdomain/workflow"
plugin0 "github.com/coze-dev/coze-studio/backend/crossdomain/contract/plugin"
gomock "go.uber.org/mock/gomock"
)
@@ -86,7 +87,7 @@ func (mr *MockPluginServiceMockRecorder) DuplicateDraftAgentTools(ctx, fromAgent
}
// ExecutePlugin mocks base method.
func (m *MockPluginService) ExecutePlugin(ctx context.Context, input map[string]any, pe *plugin.PluginEntity, toolID int64, cfg plugin.ExecuteConfig) (map[string]any, error) {
func (m *MockPluginService) ExecutePlugin(ctx context.Context, input map[string]any, pe *plugin.PluginEntity, toolID int64, cfg workflow.ExecuteConfig) (map[string]any, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "ExecutePlugin", ctx, input, pe, toolID, cfg)
ret0, _ := ret[0].(map[string]any)
@@ -308,7 +309,7 @@ func (mr *MockInvokableToolMockRecorder) Info(ctx any) *gomock.Call {
}
// PluginInvoke mocks base method.
func (m *MockInvokableTool) PluginInvoke(ctx context.Context, argumentsInJSON string, cfg plugin.ExecuteConfig) (string, error) {
func (m *MockInvokableTool) PluginInvoke(ctx context.Context, argumentsInJSON string, cfg workflow.ExecuteConfig) (string, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "PluginInvoke", ctx, argumentsInJSON, cfg)
ret0, _ := ret[0].(string)

View File

@@ -23,29 +23,28 @@ import (
einoCompose "github.com/cloudwego/eino/compose"
"github.com/cloudwego/eino/schema"
model "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"
workflowEntity "github.com/coze-dev/coze-studio/backend/domain/workflow/entity"
"github.com/coze-dev/coze-studio/backend/domain/workflow/entity/vo"
)
// TODO (@fanlv): Parameter references need to be modified.
type Workflow interface {
WorkflowAsModelTool(ctx context.Context, policies []*vo.GetPolicy) ([]workflow.ToolFromWorkflow, error)
DeleteWorkflow(ctx context.Context, id int64) error
PublishWorkflow(ctx context.Context, info *vo.PublishPolicy) (err error)
WithResumeToolWorkflow(resumingEvent *workflowEntity.ToolInterruptEvent, resumeData string,
allInterruptEvents map[string]*workflowEntity.ToolInterruptEvent) einoCompose.Option
ReleaseApplicationWorkflows(ctx context.Context, appID int64, config *ReleaseWorkflowConfig) ([]*vo.ValidateIssue, error)
GetWorkflowIDsByAppID(ctx context.Context, appID int64) ([]int64, error)
SyncExecuteWorkflow(ctx context.Context, config model.ExecuteConfig, input map[string]any) (*workflowEntity.WorkflowExecution, vo.TerminatePlan, error)
WithExecuteConfig(cfg model.ExecuteConfig) einoCompose.Option
SyncExecuteWorkflow(ctx context.Context, config workflowModel.ExecuteConfig, input map[string]any) (*workflowEntity.WorkflowExecution, vo.TerminatePlan, error)
WithExecuteConfig(cfg workflowModel.ExecuteConfig) einoCompose.Option
WithMessagePipe() (compose.Option, *schema.StreamReader[*entity.Message])
}
type ExecuteConfig = model.ExecuteConfig
type ExecuteMode = model.ExecuteMode
type ExecuteConfig = workflowModel.ExecuteConfig
type ExecuteMode = workflowModel.ExecuteMode
type NodeType = entity.NodeType
type WorkflowMessage = entity.Message
@@ -60,14 +59,14 @@ const (
ExecuteModeNodeDebug ExecuteMode = "node_debug"
)
type TaskType = model.TaskType
type TaskType = workflowModel.TaskType
const (
TaskTypeForeground TaskType = "foreground"
TaskTypeBackground TaskType = "background"
)
type BizType = model.BizType
type BizType = workflowModel.BizType
const (
BizTypeAgent BizType = "agent"