refactor(workflow): Move domain resources events into the application layer (#729)
This commit is contained in:
parent
8c3ae99643
commit
5d98e8ef93
|
|
@ -52,6 +52,7 @@ import (
|
||||||
model "github.com/coze-dev/coze-studio/backend/api/model/crossdomain/modelmgr"
|
model "github.com/coze-dev/coze-studio/backend/api/model/crossdomain/modelmgr"
|
||||||
plugin2 "github.com/coze-dev/coze-studio/backend/api/model/crossdomain/plugin"
|
plugin2 "github.com/coze-dev/coze-studio/backend/api/model/crossdomain/plugin"
|
||||||
pluginmodel "github.com/coze-dev/coze-studio/backend/api/model/crossdomain/plugin"
|
pluginmodel "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/api/model/playground"
|
"github.com/coze-dev/coze-studio/backend/api/model/playground"
|
||||||
pluginAPI "github.com/coze-dev/coze-studio/backend/api/model/plugin_develop"
|
pluginAPI "github.com/coze-dev/coze-studio/backend/api/model/plugin_develop"
|
||||||
"github.com/coze-dev/coze-studio/backend/api/model/workflow"
|
"github.com/coze-dev/coze-studio/backend/api/model/workflow"
|
||||||
|
|
@ -76,10 +77,9 @@ import (
|
||||||
entity2 "github.com/coze-dev/coze-studio/backend/domain/openauth/openapiauth/entity"
|
entity2 "github.com/coze-dev/coze-studio/backend/domain/openauth/openapiauth/entity"
|
||||||
entity3 "github.com/coze-dev/coze-studio/backend/domain/plugin/entity"
|
entity3 "github.com/coze-dev/coze-studio/backend/domain/plugin/entity"
|
||||||
entity5 "github.com/coze-dev/coze-studio/backend/domain/plugin/entity"
|
entity5 "github.com/coze-dev/coze-studio/backend/domain/plugin/entity"
|
||||||
|
search "github.com/coze-dev/coze-studio/backend/domain/search/entity"
|
||||||
userentity "github.com/coze-dev/coze-studio/backend/domain/user/entity"
|
userentity "github.com/coze-dev/coze-studio/backend/domain/user/entity"
|
||||||
workflow2 "github.com/coze-dev/coze-studio/backend/domain/workflow"
|
workflow2 "github.com/coze-dev/coze-studio/backend/domain/workflow"
|
||||||
crosssearch "github.com/coze-dev/coze-studio/backend/domain/workflow/crossdomain/search"
|
|
||||||
"github.com/coze-dev/coze-studio/backend/domain/workflow/crossdomain/search/searchmock"
|
|
||||||
"github.com/coze-dev/coze-studio/backend/domain/workflow/crossdomain/variable"
|
"github.com/coze-dev/coze-studio/backend/domain/workflow/crossdomain/variable"
|
||||||
mockvar "github.com/coze-dev/coze-studio/backend/domain/workflow/crossdomain/variable/varmock"
|
mockvar "github.com/coze-dev/coze-studio/backend/domain/workflow/crossdomain/variable/varmock"
|
||||||
"github.com/coze-dev/coze-studio/backend/domain/workflow/entity"
|
"github.com/coze-dev/coze-studio/backend/domain/workflow/entity"
|
||||||
|
|
@ -116,7 +116,6 @@ type wfTestRunner struct {
|
||||||
h *server.Hertz
|
h *server.Hertz
|
||||||
ctrl *gomock.Controller
|
ctrl *gomock.Controller
|
||||||
idGen *mock.MockIDGenerator
|
idGen *mock.MockIDGenerator
|
||||||
search *searchmock.MockNotifier
|
|
||||||
appVarS *mockvar.MockStore
|
appVarS *mockvar.MockStore
|
||||||
userVarS *mockvar.MockStore
|
userVarS *mockvar.MockStore
|
||||||
varGetter *mockvar.MockVariablesMetaGetter
|
varGetter *mockvar.MockVariablesMetaGetter
|
||||||
|
|
@ -252,10 +251,7 @@ func newWfTestRunner(t *testing.T) *wfTestRunner {
|
||||||
workflowRepo := service.NewWorkflowRepository(mockIDGen, db, redisClient, mockTos, cpStore, utChatModel)
|
workflowRepo := service.NewWorkflowRepository(mockIDGen, db, redisClient, mockTos, cpStore, utChatModel)
|
||||||
mockey.Mock(appworkflow.GetWorkflowDomainSVC).Return(service.NewWorkflowService(workflowRepo)).Build()
|
mockey.Mock(appworkflow.GetWorkflowDomainSVC).Return(service.NewWorkflowService(workflowRepo)).Build()
|
||||||
mockey.Mock(workflow2.GetRepository).Return(workflowRepo).Build()
|
mockey.Mock(workflow2.GetRepository).Return(workflowRepo).Build()
|
||||||
|
mockey.Mock(appworkflow.PublishWorkflowResource).Return(nil).Build()
|
||||||
mockSearchNotify := searchmock.NewMockNotifier(ctrl)
|
|
||||||
mockey.Mock(crosssearch.GetNotifier).Return(mockSearchNotify).Build()
|
|
||||||
mockSearchNotify.EXPECT().PublishWorkflowResource(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).AnyTimes()
|
|
||||||
|
|
||||||
mockCU := mockCrossUser.NewMockUser(ctrl)
|
mockCU := mockCrossUser.NewMockUser(ctrl)
|
||||||
mockCU.EXPECT().GetUserSpaceList(gomock.Any(), gomock.Any()).Return([]*crossuser.EntitySpace{
|
mockCU.EXPECT().GetUserSpaceList(gomock.Any(), gomock.Any()).Return([]*crossuser.EntitySpace{
|
||||||
|
|
@ -320,7 +316,6 @@ func newWfTestRunner(t *testing.T) *wfTestRunner {
|
||||||
h: h,
|
h: h,
|
||||||
ctrl: ctrl,
|
ctrl: ctrl,
|
||||||
idGen: mockIDGen,
|
idGen: mockIDGen,
|
||||||
search: mockSearchNotify,
|
|
||||||
appVarS: mockGlobalAppVarStore,
|
appVarS: mockGlobalAppVarStore,
|
||||||
userVarS: mockGlobalUserVarStore,
|
userVarS: mockGlobalUserVarStore,
|
||||||
varGetter: mockVarGetter,
|
varGetter: mockVarGetter,
|
||||||
|
|
@ -3697,7 +3692,7 @@ func TestCopyWorkflow(t *testing.T) {
|
||||||
|
|
||||||
_, err := appworkflow.GetWorkflowDomainSVC().Get(context.Background(), &vo.GetPolicy{
|
_, err := appworkflow.GetWorkflowDomainSVC().Get(context.Background(), &vo.GetPolicy{
|
||||||
ID: wid,
|
ID: wid,
|
||||||
QType: plugin2.FromDraft,
|
QType: workflowModel.FromDraft,
|
||||||
CommitID: "",
|
CommitID: "",
|
||||||
})
|
})
|
||||||
assert.NotNil(t, err)
|
assert.NotNil(t, err)
|
||||||
|
|
@ -3759,7 +3754,7 @@ func TestReleaseApplicationWorkflows(t *testing.T) {
|
||||||
|
|
||||||
wf, err = appworkflow.GetWorkflowDomainSVC().Get(context.Background(), &vo.GetPolicy{
|
wf, err = appworkflow.GetWorkflowDomainSVC().Get(context.Background(), &vo.GetPolicy{
|
||||||
ID: 100100100100,
|
ID: 100100100100,
|
||||||
QType: plugin2.FromSpecificVersion,
|
QType: workflowModel.FromSpecificVersion,
|
||||||
Version: version,
|
Version: version,
|
||||||
})
|
})
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
|
|
@ -4039,7 +4034,7 @@ func TestCopyWorkflowAppToLibrary(t *testing.T) {
|
||||||
|
|
||||||
mockey.PatchConvey("copy with subworkflow, subworkflow with external resource ", t, func() {
|
mockey.PatchConvey("copy with subworkflow, subworkflow with external resource ", t, func() {
|
||||||
var copiedIDs = make([]int64, 0)
|
var copiedIDs = make([]int64, 0)
|
||||||
var mockPublishWorkflowResource func(ctx context.Context, OpType crosssearch.OpType, event *crosssearch.Resource) error
|
var mockPublishWorkflowResource func(ctx context.Context, workflowID int64, mode *int32, op search.OpType, r *search.ResourceDocument) error
|
||||||
var ignoreIDs = map[int64]bool{
|
var ignoreIDs = map[int64]bool{
|
||||||
7515027325977624576: true,
|
7515027325977624576: true,
|
||||||
7515027249628708864: true,
|
7515027249628708864: true,
|
||||||
|
|
@ -4047,15 +4042,15 @@ func TestCopyWorkflowAppToLibrary(t *testing.T) {
|
||||||
7515027150387281920: true,
|
7515027150387281920: true,
|
||||||
7515027091302121472: true,
|
7515027091302121472: true,
|
||||||
}
|
}
|
||||||
mockPublishWorkflowResource = func(ctx context.Context, OpType crosssearch.OpType, event *crosssearch.Resource) error {
|
mockPublishWorkflowResource = func(ctx context.Context, workflowID int64, mode *int32, op search.OpType, r *search.ResourceDocument) error {
|
||||||
if ignoreIDs[event.WorkflowID] {
|
if ignoreIDs[workflowID] {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
wf, err := appworkflow.GetWorkflowDomainSVC().Get(ctx, &vo.GetPolicy{
|
wf, err := appworkflow.GetWorkflowDomainSVC().Get(ctx, &vo.GetPolicy{
|
||||||
ID: event.WorkflowID,
|
ID: workflowID,
|
||||||
QType: plugin2.FromLatestVersion,
|
QType: workflowModel.FromLatestVersion,
|
||||||
})
|
})
|
||||||
copiedIDs = append(copiedIDs, event.WorkflowID)
|
copiedIDs = append(copiedIDs, workflowID)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.Equal(t, "v0.0.1", wf.Version)
|
assert.Equal(t, "v0.0.1", wf.Version)
|
||||||
canvas := &vo.Canvas{}
|
canvas := &vo.Canvas{}
|
||||||
|
|
@ -4095,7 +4090,7 @@ func TestCopyWorkflowAppToLibrary(t *testing.T) {
|
||||||
|
|
||||||
subWf, err := appworkflow.GetWorkflowDomainSVC().Get(ctx, &vo.GetPolicy{
|
subWf, err := appworkflow.GetWorkflowDomainSVC().Get(ctx, &vo.GetPolicy{
|
||||||
ID: wfId,
|
ID: wfId,
|
||||||
QType: plugin2.FromLatestVersion,
|
QType: workflowModel.FromLatestVersion,
|
||||||
})
|
})
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
subworkflowCanvas := &vo.Canvas{}
|
subworkflowCanvas := &vo.Canvas{}
|
||||||
|
|
@ -4144,7 +4139,7 @@ func TestCopyWorkflowAppToLibrary(t *testing.T) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
r.search.EXPECT().PublishWorkflowResource(gomock.Any(), gomock.Any(), gomock.Any()).DoAndReturn(mockPublishWorkflowResource).AnyTimes()
|
mockey.Mock(appworkflow.PublishWorkflowResource).To(mockPublishWorkflowResource).Build()
|
||||||
|
|
||||||
appID := "7513788954458456064"
|
appID := "7513788954458456064"
|
||||||
appIDInt64, _ := strconv.ParseInt(appID, 10, 64)
|
appIDInt64, _ := strconv.ParseInt(appID, 10, 64)
|
||||||
|
|
@ -4187,21 +4182,21 @@ func TestCopyWorkflowAppToLibrary(t *testing.T) {
|
||||||
|
|
||||||
mockey.PatchConvey("copy only with external resource", t, func() {
|
mockey.PatchConvey("copy only with external resource", t, func() {
|
||||||
var copiedIDs = make([]int64, 0)
|
var copiedIDs = make([]int64, 0)
|
||||||
var mockPublishWorkflowResource func(ctx context.Context, OpType crosssearch.OpType, event *crosssearch.Resource) error
|
var mockPublishWorkflowResource func(ctx context.Context, workflowID int64, mode *int32, op search.OpType, r *search.ResourceDocument) error
|
||||||
var ignoreIDs = map[int64]bool{
|
var ignoreIDs = map[int64]bool{
|
||||||
7516518409656336384: true,
|
7516518409656336384: true,
|
||||||
7516516198096306176: true,
|
7516516198096306176: true,
|
||||||
}
|
}
|
||||||
mockPublishWorkflowResource = func(ctx context.Context, OpType crosssearch.OpType, event *crosssearch.Resource) error {
|
mockPublishWorkflowResource = func(ctx context.Context, workflowID int64, mode *int32, op search.OpType, r *search.ResourceDocument) error {
|
||||||
if ignoreIDs[event.WorkflowID] {
|
if ignoreIDs[workflowID] {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
wf, err := appworkflow.GetWorkflowDomainSVC().Get(ctx, &vo.GetPolicy{
|
wf, err := appworkflow.GetWorkflowDomainSVC().Get(ctx, &vo.GetPolicy{
|
||||||
ID: event.WorkflowID,
|
ID: workflowID,
|
||||||
QType: plugin2.FromLatestVersion,
|
QType: workflowModel.FromLatestVersion,
|
||||||
})
|
})
|
||||||
|
|
||||||
copiedIDs = append(copiedIDs, event.WorkflowID)
|
copiedIDs = append(copiedIDs, workflowID)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.Equal(t, "v0.0.1", wf.Version)
|
assert.Equal(t, "v0.0.1", wf.Version)
|
||||||
canvas := &vo.Canvas{}
|
canvas := &vo.Canvas{}
|
||||||
|
|
@ -4255,8 +4250,7 @@ func TestCopyWorkflowAppToLibrary(t *testing.T) {
|
||||||
return nil
|
return nil
|
||||||
|
|
||||||
}
|
}
|
||||||
|
mockey.Mock(appworkflow.PublishWorkflowResource).To(mockPublishWorkflowResource).Build()
|
||||||
r.search.EXPECT().PublishWorkflowResource(gomock.Any(), gomock.Any(), gomock.Any()).DoAndReturn(mockPublishWorkflowResource).AnyTimes()
|
|
||||||
|
|
||||||
defer mockey.Mock((*appknowledge.KnowledgeApplicationService).CopyKnowledge).Return(&modelknowledge.CopyKnowledgeResponse{
|
defer mockey.Mock((*appknowledge.KnowledgeApplicationService).CopyKnowledge).Return(&modelknowledge.CopyKnowledgeResponse{
|
||||||
TargetKnowledgeID: 100100,
|
TargetKnowledgeID: 100100,
|
||||||
|
|
@ -4316,21 +4310,21 @@ func TestMoveWorkflowAppToLibrary(t *testing.T) {
|
||||||
r.varGetter.EXPECT().GetAppVariablesMeta(gomock.Any(), gomock.Any(), gomock.Any()).Return(vars, nil).AnyTimes()
|
r.varGetter.EXPECT().GetAppVariablesMeta(gomock.Any(), gomock.Any(), gomock.Any()).Return(vars, nil).AnyTimes()
|
||||||
t.Run("move workflow", func(t *testing.T) {
|
t.Run("move workflow", func(t *testing.T) {
|
||||||
|
|
||||||
var mockPublishWorkflowResource func(ctx context.Context, OpType crosssearch.OpType, event *crosssearch.Resource) error
|
var mockPublishWorkflowResource func(ctx context.Context, workflowID int64, mode *int32, op search.OpType, r *search.ResourceDocument) error
|
||||||
|
|
||||||
named2Idx := []string{"c1", "c2", "cc1", "main"}
|
named2Idx := []string{"c1", "c2", "cc1", "main"}
|
||||||
callCount := 0
|
callCount := 0
|
||||||
initialWf2ID := map[string]int64{}
|
initialWf2ID := map[string]int64{}
|
||||||
old2newID := map[int64]int64{}
|
old2newID := map[int64]int64{}
|
||||||
mockPublishWorkflowResource = func(ctx context.Context, OpType crosssearch.OpType, event *crosssearch.Resource) error {
|
mockPublishWorkflowResource = func(ctx context.Context, workflowID int64, mode *int32, op search.OpType, r *search.ResourceDocument) error {
|
||||||
if callCount <= 3 {
|
if callCount <= 3 {
|
||||||
initialWf2ID[named2Idx[callCount]] = event.WorkflowID
|
initialWf2ID[named2Idx[callCount]] = workflowID
|
||||||
callCount++
|
callCount++
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if OpType == crosssearch.Created {
|
if op == search.Created {
|
||||||
if oldID, ok := initialWf2ID[*event.Name]; ok {
|
if oldID, ok := initialWf2ID[*r.Name]; ok {
|
||||||
old2newID[oldID] = event.WorkflowID
|
old2newID[oldID] = workflowID
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -4338,7 +4332,7 @@ func TestMoveWorkflowAppToLibrary(t *testing.T) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
r.search.EXPECT().PublishWorkflowResource(gomock.Any(), gomock.Any(), gomock.Any()).DoAndReturn(mockPublishWorkflowResource).AnyTimes()
|
mockey.Mock(appworkflow.PublishWorkflowResource).To(mockPublishWorkflowResource).Build()
|
||||||
|
|
||||||
defer mockey.Mock((*appknowledge.KnowledgeApplicationService).MoveKnowledgeToLibrary).Return(nil).Build().UnPatch()
|
defer mockey.Mock((*appknowledge.KnowledgeApplicationService).MoveKnowledgeToLibrary).Return(nil).Build().UnPatch()
|
||||||
defer mockey.Mock((*appmemory.DatabaseApplicationService).MoveDatabaseToLibrary).Return(&appmemory.MoveDatabaseToLibraryResponse{}, nil).Build().UnPatch()
|
defer mockey.Mock((*appmemory.DatabaseApplicationService).MoveDatabaseToLibrary).Return(&appmemory.MoveDatabaseToLibraryResponse{}, nil).Build().UnPatch()
|
||||||
|
|
@ -4475,7 +4469,7 @@ func TestDuplicateWorkflowsByAppID(t *testing.T) {
|
||||||
|
|
||||||
r.varGetter.EXPECT().GetAppVariablesMeta(gomock.Any(), gomock.Any(), gomock.Any()).Return(vars, nil).AnyTimes()
|
r.varGetter.EXPECT().GetAppVariablesMeta(gomock.Any(), gomock.Any(), gomock.Any()).Return(vars, nil).AnyTimes()
|
||||||
var copiedIDs = make([]int64, 0)
|
var copiedIDs = make([]int64, 0)
|
||||||
var mockPublishWorkflowResource func(ctx context.Context, OpType crosssearch.OpType, event *crosssearch.Resource) error
|
var mockPublishWorkflowResource func(ctx context.Context, workflowID int64, mode *int32, op search.OpType, r *search.ResourceDocument) error
|
||||||
var ignoreIDs = map[int64]bool{
|
var ignoreIDs = map[int64]bool{
|
||||||
7515027325977624576: true,
|
7515027325977624576: true,
|
||||||
7515027249628708864: true,
|
7515027249628708864: true,
|
||||||
|
|
@ -4484,16 +4478,16 @@ func TestDuplicateWorkflowsByAppID(t *testing.T) {
|
||||||
7515027091302121472: true,
|
7515027091302121472: true,
|
||||||
7515027325977624579: true,
|
7515027325977624579: true,
|
||||||
}
|
}
|
||||||
mockPublishWorkflowResource = func(ctx context.Context, OpType crosssearch.OpType, event *crosssearch.Resource) error {
|
mockPublishWorkflowResource = func(ctx context.Context, workflowID int64, mode *int32, op search.OpType, r *search.ResourceDocument) error {
|
||||||
if ignoreIDs[event.WorkflowID] {
|
if ignoreIDs[workflowID] {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
copiedIDs = append(copiedIDs, event.WorkflowID)
|
copiedIDs = append(copiedIDs, workflowID)
|
||||||
return nil
|
return nil
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
r.search.EXPECT().PublishWorkflowResource(gomock.Any(), gomock.Any(), gomock.Any()).DoAndReturn(mockPublishWorkflowResource).AnyTimes()
|
mockey.Mock(appworkflow.PublishWorkflowResource).To(mockPublishWorkflowResource).Build()
|
||||||
|
|
||||||
appIDInt64 := int64(7513788954458456064)
|
appIDInt64 := int64(7513788954458456064)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -31,27 +31,6 @@ type PluginEntity struct {
|
||||||
PluginVersion *string // nil or "0" means draft, "" means latest/online version, otherwise is specific version
|
PluginVersion *string // nil or "0" means draft, "" means latest/online version, otherwise is specific version
|
||||||
}
|
}
|
||||||
|
|
||||||
type DependenceResource struct {
|
|
||||||
PluginIDs []int64
|
|
||||||
KnowledgeIDs []int64
|
|
||||||
DatabaseIDs []int64
|
|
||||||
}
|
|
||||||
|
|
||||||
type ExternalResourceRelated struct {
|
|
||||||
PluginMap map[int64]*PluginEntity
|
|
||||||
PluginToolMap map[int64]int64
|
|
||||||
|
|
||||||
KnowledgeMap map[int64]int64
|
|
||||||
DatabaseMap map[int64]int64
|
|
||||||
}
|
|
||||||
|
|
||||||
type CopyWorkflowPolicy struct {
|
|
||||||
TargetSpaceID *int64
|
|
||||||
TargetAppID *int64
|
|
||||||
ModifiedCanvasSchema *string
|
|
||||||
ShouldModifyWorkflowName bool
|
|
||||||
}
|
|
||||||
|
|
||||||
type ToolsInfoResponse struct {
|
type ToolsInfoResponse struct {
|
||||||
PluginID int64
|
PluginID int64
|
||||||
SpaceID int64
|
SpaceID int64
|
||||||
|
|
@ -94,61 +73,3 @@ type ToolsInvokableInfo struct {
|
||||||
RequestAPIParametersConfig WorkflowAPIParameters
|
RequestAPIParametersConfig WorkflowAPIParameters
|
||||||
ResponseAPIParametersConfig WorkflowAPIParameters
|
ResponseAPIParametersConfig WorkflowAPIParameters
|
||||||
}
|
}
|
||||||
|
|
||||||
type Locator uint8
|
|
||||||
|
|
||||||
const (
|
|
||||||
FromDraft Locator = iota
|
|
||||||
FromSpecificVersion
|
|
||||||
FromLatestVersion
|
|
||||||
)
|
|
||||||
|
|
||||||
type ExecuteConfig struct {
|
|
||||||
ID int64
|
|
||||||
From Locator
|
|
||||||
Version string
|
|
||||||
CommitID string
|
|
||||||
Operator int64
|
|
||||||
Mode ExecuteMode
|
|
||||||
AppID *int64
|
|
||||||
AgentID *int64
|
|
||||||
ConnectorID int64
|
|
||||||
ConnectorUID string
|
|
||||||
TaskType TaskType
|
|
||||||
SyncPattern SyncPattern
|
|
||||||
InputFailFast bool // whether to fail fast if input conversion has warnings
|
|
||||||
BizType BizType
|
|
||||||
Cancellable bool
|
|
||||||
}
|
|
||||||
|
|
||||||
type ExecuteMode string
|
|
||||||
|
|
||||||
const (
|
|
||||||
ExecuteModeDebug ExecuteMode = "debug"
|
|
||||||
ExecuteModeRelease ExecuteMode = "release"
|
|
||||||
ExecuteModeNodeDebug ExecuteMode = "node_debug"
|
|
||||||
)
|
|
||||||
|
|
||||||
type TaskType string
|
|
||||||
|
|
||||||
const (
|
|
||||||
TaskTypeForeground TaskType = "foreground"
|
|
||||||
TaskTypeBackground TaskType = "background"
|
|
||||||
)
|
|
||||||
|
|
||||||
type SyncPattern string
|
|
||||||
|
|
||||||
const (
|
|
||||||
SyncPatternSync SyncPattern = "sync"
|
|
||||||
SyncPatternAsync SyncPattern = "async"
|
|
||||||
SyncPatternStream SyncPattern = "stream"
|
|
||||||
)
|
|
||||||
|
|
||||||
var DebugURLTpl = "http://127.0.0.1:3000/work_flow?execute_id=%d&space_id=%d&workflow_id=%d&execute_mode=2"
|
|
||||||
|
|
||||||
type BizType string
|
|
||||||
|
|
||||||
const (
|
|
||||||
BizTypeAgent BizType = "agent"
|
|
||||||
BizTypeWorkflow BizType = "workflow"
|
|
||||||
)
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,75 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2025 coze-dev Authors
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package workflow
|
||||||
|
|
||||||
|
type Locator uint8
|
||||||
|
|
||||||
|
const (
|
||||||
|
FromDraft Locator = iota
|
||||||
|
FromSpecificVersion
|
||||||
|
FromLatestVersion
|
||||||
|
)
|
||||||
|
|
||||||
|
type ExecuteConfig struct {
|
||||||
|
ID int64
|
||||||
|
From Locator
|
||||||
|
Version string
|
||||||
|
CommitID string
|
||||||
|
Operator int64
|
||||||
|
Mode ExecuteMode
|
||||||
|
AppID *int64
|
||||||
|
AgentID *int64
|
||||||
|
ConnectorID int64
|
||||||
|
ConnectorUID string
|
||||||
|
TaskType TaskType
|
||||||
|
SyncPattern SyncPattern
|
||||||
|
InputFailFast bool // whether to fail fast if input conversion has warnings
|
||||||
|
BizType BizType
|
||||||
|
Cancellable bool
|
||||||
|
}
|
||||||
|
|
||||||
|
type ExecuteMode string
|
||||||
|
|
||||||
|
const (
|
||||||
|
ExecuteModeDebug ExecuteMode = "debug"
|
||||||
|
ExecuteModeRelease ExecuteMode = "release"
|
||||||
|
ExecuteModeNodeDebug ExecuteMode = "node_debug"
|
||||||
|
)
|
||||||
|
|
||||||
|
type TaskType string
|
||||||
|
|
||||||
|
const (
|
||||||
|
TaskTypeForeground TaskType = "foreground"
|
||||||
|
TaskTypeBackground TaskType = "background"
|
||||||
|
)
|
||||||
|
|
||||||
|
type SyncPattern string
|
||||||
|
|
||||||
|
const (
|
||||||
|
SyncPatternSync SyncPattern = "sync"
|
||||||
|
SyncPatternAsync SyncPattern = "async"
|
||||||
|
SyncPatternStream SyncPattern = "stream"
|
||||||
|
)
|
||||||
|
|
||||||
|
var DebugURLTpl = "http://127.0.0.1:3000/work_flow?execute_id=%d&space_id=%d&workflow_id=%d&execute_mode=2"
|
||||||
|
|
||||||
|
type BizType string
|
||||||
|
|
||||||
|
const (
|
||||||
|
BizTypeAgent BizType = "agent"
|
||||||
|
BizTypeWorkflow BizType = "workflow"
|
||||||
|
)
|
||||||
|
|
@ -25,6 +25,7 @@ import (
|
||||||
"github.com/coze-dev/coze-studio/backend/api/model/app/bot_common"
|
"github.com/coze-dev/coze-studio/backend/api/model/app/bot_common"
|
||||||
knowledgeModel "github.com/coze-dev/coze-studio/backend/api/model/crossdomain/knowledge"
|
knowledgeModel "github.com/coze-dev/coze-studio/backend/api/model/crossdomain/knowledge"
|
||||||
"github.com/coze-dev/coze-studio/backend/api/model/crossdomain/plugin"
|
"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/api/model/playground"
|
"github.com/coze-dev/coze-studio/backend/api/model/playground"
|
||||||
"github.com/coze-dev/coze-studio/backend/api/model/plugin_develop/common"
|
"github.com/coze-dev/coze-studio/backend/api/model/plugin_develop/common"
|
||||||
plugin_develop_common "github.com/coze-dev/coze-studio/backend/api/model/plugin_develop/common"
|
plugin_develop_common "github.com/coze-dev/coze-studio/backend/api/model/plugin_develop/common"
|
||||||
|
|
@ -240,7 +241,7 @@ func (s *SingleAgentApplicationService) fetchWorkflowDetails(ctx context.Context
|
||||||
return a.GetWorkflowId()
|
return a.GetWorkflowId()
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
QType: plugin.FromLatestVersion,
|
QType: workflowModel.FromLatestVersion,
|
||||||
}
|
}
|
||||||
ret, _, err := s.appContext.WorkflowDomainSVC.MGet(ctx, policy)
|
ret, _, err := s.appContext.WorkflowDomainSVC.MGet(ctx, policy)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,61 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2025 coze-dev Authors
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package workflow
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"github.com/coze-dev/coze-studio/backend/api/model/resource/common"
|
||||||
|
"github.com/coze-dev/coze-studio/backend/domain/search/entity"
|
||||||
|
search "github.com/coze-dev/coze-studio/backend/domain/search/entity"
|
||||||
|
"github.com/coze-dev/coze-studio/backend/domain/search/service"
|
||||||
|
)
|
||||||
|
|
||||||
|
var eventBus service.ResourceEventBus
|
||||||
|
|
||||||
|
func setEventBus(bus service.ResourceEventBus) {
|
||||||
|
eventBus = bus
|
||||||
|
}
|
||||||
|
|
||||||
|
func PublishWorkflowResource(ctx context.Context, workflowID int64, mode *int32, op search.OpType, r *search.ResourceDocument) error {
|
||||||
|
if r == nil {
|
||||||
|
r = &search.ResourceDocument{}
|
||||||
|
}
|
||||||
|
|
||||||
|
r.ResType = common.ResType_Workflow
|
||||||
|
r.ResID = workflowID
|
||||||
|
r.ResSubType = mode
|
||||||
|
|
||||||
|
event := &entity.ResourceDomainEvent{
|
||||||
|
OpType: entity.OpType(op),
|
||||||
|
Resource: r,
|
||||||
|
}
|
||||||
|
|
||||||
|
if op == search.Created {
|
||||||
|
event.Resource.CreateTimeMS = r.CreateTimeMS
|
||||||
|
event.Resource.UpdateTimeMS = r.UpdateTimeMS
|
||||||
|
} else if op == search.Updated {
|
||||||
|
event.Resource.UpdateTimeMS = r.UpdateTimeMS
|
||||||
|
}
|
||||||
|
|
||||||
|
err := eventBus.PublishResources(ctx, event)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
@ -25,7 +25,6 @@ import (
|
||||||
|
|
||||||
"github.com/coze-dev/coze-studio/backend/application/internal"
|
"github.com/coze-dev/coze-studio/backend/application/internal"
|
||||||
"github.com/coze-dev/coze-studio/backend/crossdomain/impl/code"
|
"github.com/coze-dev/coze-studio/backend/crossdomain/impl/code"
|
||||||
wfsearch "github.com/coze-dev/coze-studio/backend/crossdomain/workflow/search"
|
|
||||||
"github.com/coze-dev/coze-studio/backend/crossdomain/workflow/variable"
|
"github.com/coze-dev/coze-studio/backend/crossdomain/workflow/variable"
|
||||||
knowledge "github.com/coze-dev/coze-studio/backend/domain/knowledge/service"
|
knowledge "github.com/coze-dev/coze-studio/backend/domain/knowledge/service"
|
||||||
dbservice "github.com/coze-dev/coze-studio/backend/domain/memory/database/service"
|
dbservice "github.com/coze-dev/coze-studio/backend/domain/memory/database/service"
|
||||||
|
|
@ -34,7 +33,6 @@ import (
|
||||||
search "github.com/coze-dev/coze-studio/backend/domain/search/service"
|
search "github.com/coze-dev/coze-studio/backend/domain/search/service"
|
||||||
"github.com/coze-dev/coze-studio/backend/domain/workflow"
|
"github.com/coze-dev/coze-studio/backend/domain/workflow"
|
||||||
|
|
||||||
crosssearch "github.com/coze-dev/coze-studio/backend/domain/workflow/crossdomain/search"
|
|
||||||
crossvariable "github.com/coze-dev/coze-studio/backend/domain/workflow/crossdomain/variable"
|
crossvariable "github.com/coze-dev/coze-studio/backend/domain/workflow/crossdomain/variable"
|
||||||
"github.com/coze-dev/coze-studio/backend/domain/workflow/service"
|
"github.com/coze-dev/coze-studio/backend/domain/workflow/service"
|
||||||
workflowservice "github.com/coze-dev/coze-studio/backend/domain/workflow/service"
|
workflowservice "github.com/coze-dev/coze-studio/backend/domain/workflow/service"
|
||||||
|
|
@ -80,8 +78,8 @@ func InitService(ctx context.Context, components *ServiceComponents) (*Applicati
|
||||||
crossvariable.SetVariableHandler(variable.NewVariableHandler(components.VariablesDomainSVC))
|
crossvariable.SetVariableHandler(variable.NewVariableHandler(components.VariablesDomainSVC))
|
||||||
crossvariable.SetVariablesMetaGetter(variable.NewVariablesMetaGetter(components.VariablesDomainSVC))
|
crossvariable.SetVariablesMetaGetter(variable.NewVariablesMetaGetter(components.VariablesDomainSVC))
|
||||||
code.SetCodeRunner(components.CodeRunner)
|
code.SetCodeRunner(components.CodeRunner)
|
||||||
crosssearch.SetNotifier(wfsearch.NewNotify(components.DomainNotifier))
|
|
||||||
callbacks.AppendGlobalHandlers(workflowservice.GetTokenCallbackHandler())
|
callbacks.AppendGlobalHandlers(workflowservice.GetTokenCallbackHandler())
|
||||||
|
setEventBus(components.DomainNotifier)
|
||||||
|
|
||||||
SVC.DomainSVC = workflowDomainSVC
|
SVC.DomainSVC = workflowDomainSVC
|
||||||
SVC.ImageX = components.ImageX
|
SVC.ImageX = components.ImageX
|
||||||
|
|
|
||||||
|
|
@ -32,10 +32,12 @@ import (
|
||||||
model "github.com/coze-dev/coze-studio/backend/api/model/crossdomain/knowledge"
|
model "github.com/coze-dev/coze-studio/backend/api/model/crossdomain/knowledge"
|
||||||
"github.com/coze-dev/coze-studio/backend/api/model/crossdomain/plugin"
|
"github.com/coze-dev/coze-studio/backend/api/model/crossdomain/plugin"
|
||||||
pluginmodel "github.com/coze-dev/coze-studio/backend/api/model/crossdomain/plugin"
|
pluginmodel "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/api/model/data/database/table"
|
"github.com/coze-dev/coze-studio/backend/api/model/data/database/table"
|
||||||
"github.com/coze-dev/coze-studio/backend/api/model/playground"
|
"github.com/coze-dev/coze-studio/backend/api/model/playground"
|
||||||
pluginAPI "github.com/coze-dev/coze-studio/backend/api/model/plugin_develop"
|
pluginAPI "github.com/coze-dev/coze-studio/backend/api/model/plugin_develop"
|
||||||
common "github.com/coze-dev/coze-studio/backend/api/model/plugin_develop/common"
|
common "github.com/coze-dev/coze-studio/backend/api/model/plugin_develop/common"
|
||||||
|
resource "github.com/coze-dev/coze-studio/backend/api/model/resource/common"
|
||||||
"github.com/coze-dev/coze-studio/backend/api/model/workflow"
|
"github.com/coze-dev/coze-studio/backend/api/model/workflow"
|
||||||
"github.com/coze-dev/coze-studio/backend/application/base/ctxutil"
|
"github.com/coze-dev/coze-studio/backend/application/base/ctxutil"
|
||||||
appknowledge "github.com/coze-dev/coze-studio/backend/application/knowledge"
|
appknowledge "github.com/coze-dev/coze-studio/backend/application/knowledge"
|
||||||
|
|
@ -44,8 +46,8 @@ import (
|
||||||
"github.com/coze-dev/coze-studio/backend/application/user"
|
"github.com/coze-dev/coze-studio/backend/application/user"
|
||||||
crossknowledge "github.com/coze-dev/coze-studio/backend/crossdomain/contract/knowledge"
|
crossknowledge "github.com/coze-dev/coze-studio/backend/crossdomain/contract/knowledge"
|
||||||
crossplugin "github.com/coze-dev/coze-studio/backend/crossdomain/contract/plugin"
|
crossplugin "github.com/coze-dev/coze-studio/backend/crossdomain/contract/plugin"
|
||||||
|
|
||||||
crossuser "github.com/coze-dev/coze-studio/backend/crossdomain/contract/user"
|
crossuser "github.com/coze-dev/coze-studio/backend/crossdomain/contract/user"
|
||||||
|
search "github.com/coze-dev/coze-studio/backend/domain/search/entity"
|
||||||
domainWorkflow "github.com/coze-dev/coze-studio/backend/domain/workflow"
|
domainWorkflow "github.com/coze-dev/coze-studio/backend/domain/workflow"
|
||||||
workflowDomain "github.com/coze-dev/coze-studio/backend/domain/workflow"
|
workflowDomain "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"
|
||||||
|
|
@ -55,6 +57,7 @@ import (
|
||||||
"github.com/coze-dev/coze-studio/backend/infra/contract/storage"
|
"github.com/coze-dev/coze-studio/backend/infra/contract/storage"
|
||||||
"github.com/coze-dev/coze-studio/backend/pkg/errorx"
|
"github.com/coze-dev/coze-studio/backend/pkg/errorx"
|
||||||
"github.com/coze-dev/coze-studio/backend/pkg/i18n"
|
"github.com/coze-dev/coze-studio/backend/pkg/i18n"
|
||||||
|
"github.com/coze-dev/coze-studio/backend/pkg/lang/conv"
|
||||||
"github.com/coze-dev/coze-studio/backend/pkg/lang/maps"
|
"github.com/coze-dev/coze-studio/backend/pkg/lang/maps"
|
||||||
"github.com/coze-dev/coze-studio/backend/pkg/lang/ptr"
|
"github.com/coze-dev/coze-studio/backend/pkg/lang/ptr"
|
||||||
"github.com/coze-dev/coze-studio/backend/pkg/lang/slices"
|
"github.com/coze-dev/coze-studio/backend/pkg/lang/slices"
|
||||||
|
|
@ -183,6 +186,18 @@ func (w *ApplicationService) CreateWorkflow(ctx context.Context, req *workflow.C
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
err = PublishWorkflowResource(ctx, id, ptr.Of(int32(wf.Mode)), search.Created, &search.ResourceDocument{
|
||||||
|
Name: &wf.Name,
|
||||||
|
APPID: wf.AppID,
|
||||||
|
SpaceID: &wf.SpaceID,
|
||||||
|
OwnerID: &wf.CreatorID,
|
||||||
|
PublishStatus: ptr.Of(resource.PublishStatus_UnPublished),
|
||||||
|
CreateTimeMS: ptr.Of(time.Now().UnixMilli()),
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return nil, vo.WrapError(errno.ErrNotifyWorkflowResourceChangeErr, err)
|
||||||
|
}
|
||||||
|
|
||||||
return &workflow.CreateWorkflowResponse{
|
return &workflow.CreateWorkflowResponse{
|
||||||
Data: &workflow.CreateWorkflowData{
|
Data: &workflow.CreateWorkflowData{
|
||||||
WorkflowID: strconv.FormatInt(id, 10),
|
WorkflowID: strconv.FormatInt(id, 10),
|
||||||
|
|
@ -233,7 +248,8 @@ func (w *ApplicationService) UpdateWorkflowMeta(ctx context.Context, req *workfl
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
err = GetWorkflowDomainSVC().UpdateMeta(ctx, mustParseInt64(req.GetWorkflowID()), &vo.MetaUpdate{
|
workflowID := mustParseInt64(req.GetWorkflowID())
|
||||||
|
err = GetWorkflowDomainSVC().UpdateMeta(ctx, workflowID, &vo.MetaUpdate{
|
||||||
Name: req.Name,
|
Name: req.Name,
|
||||||
Desc: req.Desc,
|
Desc: req.Desc,
|
||||||
IconURI: req.IconURI,
|
IconURI: req.IconURI,
|
||||||
|
|
@ -241,33 +257,31 @@ func (w *ApplicationService) UpdateWorkflowMeta(ctx context.Context, req *workfl
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
safego.Go(ctx, func() {
|
||||||
|
err := PublishWorkflowResource(ctx, workflowID, nil, search.Updated, &search.ResourceDocument{
|
||||||
|
Name: req.Name,
|
||||||
|
UpdateTimeMS: ptr.Of(time.Now().UnixMilli()),
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
logs.CtxErrorf(ctx, "publish update workflow resource failed, workflowID: %d, err: %v", workflowID, err)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
return &workflow.UpdateWorkflowMetaResponse{}, nil
|
return &workflow.UpdateWorkflowMetaResponse{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *ApplicationService) DeleteWorkflow(ctx context.Context, req *workflow.DeleteWorkflowRequest) (
|
func (w *ApplicationService) DeleteWorkflow(ctx context.Context, req *workflow.DeleteWorkflowRequest) (
|
||||||
_ *workflow.DeleteWorkflowResponse, err error,
|
_ *workflow.DeleteWorkflowResponse, err error,
|
||||||
) {
|
) {
|
||||||
defer func() {
|
_, err = w.BatchDeleteWorkflow(ctx, &workflow.BatchDeleteWorkflowRequest{
|
||||||
if panicErr := recover(); panicErr != nil {
|
WorkflowIDList: []string{req.GetWorkflowID()},
|
||||||
err = safego.NewPanicErr(panicErr, debug.Stack())
|
SpaceID: req.SpaceID,
|
||||||
}
|
Action: req.Action,
|
||||||
|
})
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
err = vo.WrapIfNeeded(errno.ErrWorkflowOperationFail, err, errorx.KV("cause", vo.UnwrapRootErr(err).Error()))
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
|
|
||||||
if err := checkUserSpace(ctx, ctxutil.MustGetUIDFromCtx(ctx), mustParseInt64(req.GetSpaceID())); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
err = GetWorkflowDomainSVC().Delete(ctx, &vo.DeletePolicy{ID: ptr.Of(mustParseInt64(req.GetWorkflowID()))})
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return &workflow.DeleteWorkflowResponse{
|
return nil, err
|
||||||
Data: &workflow.DeleteWorkflowData{
|
|
||||||
Status: workflow.DeleteStatus_FAIL,
|
|
||||||
},
|
|
||||||
}, err
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return &workflow.DeleteWorkflowResponse{
|
return &workflow.DeleteWorkflowResponse{
|
||||||
|
|
@ -277,19 +291,25 @@ func (w *ApplicationService) DeleteWorkflow(ctx context.Context, req *workflow.D
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (w *ApplicationService) deleteWorkflowResource(ctx context.Context, policy *vo.DeletePolicy) error {
|
||||||
|
ids, err := w.DomainSVC.Delete(ctx, policy)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
safego.Go(ctx, func() {
|
||||||
|
for _, id := range ids {
|
||||||
|
if err = PublishWorkflowResource(ctx, id, nil, search.Deleted, &search.ResourceDocument{}); err != nil {
|
||||||
|
logs.CtxErrorf(ctx, "publish delete workflow event resource failed, workflowID: %d, err: %v", id, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func (w *ApplicationService) BatchDeleteWorkflow(ctx context.Context, req *workflow.BatchDeleteWorkflowRequest) (
|
func (w *ApplicationService) BatchDeleteWorkflow(ctx context.Context, req *workflow.BatchDeleteWorkflowRequest) (
|
||||||
_ *workflow.BatchDeleteWorkflowResponse, err error,
|
_ *workflow.BatchDeleteWorkflowResponse, err error) {
|
||||||
) {
|
|
||||||
defer func() {
|
|
||||||
if panicErr := recover(); panicErr != nil {
|
|
||||||
err = safego.NewPanicErr(panicErr, debug.Stack())
|
|
||||||
}
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
err = vo.WrapIfNeeded(errno.ErrWorkflowOperationFail, err, errorx.KV("cause", vo.UnwrapRootErr(err).Error()))
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
|
|
||||||
if err := checkUserSpace(ctx, ctxutil.MustGetUIDFromCtx(ctx), mustParseInt64(req.GetSpaceID())); err != nil {
|
if err := checkUserSpace(ctx, ctxutil.MustGetUIDFromCtx(ctx), mustParseInt64(req.GetSpaceID())); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
@ -301,7 +321,7 @@ func (w *ApplicationService) BatchDeleteWorkflow(ctx context.Context, req *workf
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
err = GetWorkflowDomainSVC().Delete(ctx, &vo.DeletePolicy{
|
err = w.deleteWorkflowResource(ctx, &vo.DeletePolicy{
|
||||||
IDs: ids,
|
IDs: ids,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -336,7 +356,7 @@ func (w *ApplicationService) GetCanvasInfo(ctx context.Context, req *workflow.Ge
|
||||||
|
|
||||||
wf, err := GetWorkflowDomainSVC().Get(ctx, &vo.GetPolicy{
|
wf, err := GetWorkflowDomainSVC().Get(ctx, &vo.GetPolicy{
|
||||||
ID: mustParseInt64(req.GetWorkflowID()),
|
ID: mustParseInt64(req.GetWorkflowID()),
|
||||||
QType: plugin.FromDraft,
|
QType: workflowModel.FromDraft,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
@ -432,19 +452,19 @@ func (w *ApplicationService) TestRun(ctx context.Context, req *workflow.WorkFlow
|
||||||
agentID = ptr.Of(mustParseInt64(req.GetBotID()))
|
agentID = ptr.Of(mustParseInt64(req.GetBotID()))
|
||||||
}
|
}
|
||||||
|
|
||||||
exeCfg := plugin.ExecuteConfig{
|
exeCfg := workflowModel.ExecuteConfig{
|
||||||
ID: mustParseInt64(req.GetWorkflowID()),
|
ID: mustParseInt64(req.GetWorkflowID()),
|
||||||
From: plugin.FromDraft,
|
From: workflowModel.FromDraft,
|
||||||
CommitID: req.GetCommitID(),
|
CommitID: req.GetCommitID(),
|
||||||
Operator: uID,
|
Operator: uID,
|
||||||
Mode: plugin.ExecuteModeDebug,
|
Mode: workflowModel.ExecuteModeDebug,
|
||||||
AppID: appID,
|
AppID: appID,
|
||||||
AgentID: agentID,
|
AgentID: agentID,
|
||||||
ConnectorID: consts.CozeConnectorID,
|
ConnectorID: consts.CozeConnectorID,
|
||||||
ConnectorUID: strconv.FormatInt(uID, 10),
|
ConnectorUID: strconv.FormatInt(uID, 10),
|
||||||
TaskType: plugin.TaskTypeForeground,
|
TaskType: workflowModel.TaskTypeForeground,
|
||||||
SyncPattern: plugin.SyncPatternAsync,
|
SyncPattern: workflowModel.SyncPatternAsync,
|
||||||
BizType: plugin.BizTypeWorkflow,
|
BizType: workflowModel.BizTypeWorkflow,
|
||||||
Cancellable: true,
|
Cancellable: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -504,18 +524,18 @@ func (w *ApplicationService) NodeDebug(ctx context.Context, req *workflow.Workfl
|
||||||
agentID = ptr.Of(mustParseInt64(req.GetBotID()))
|
agentID = ptr.Of(mustParseInt64(req.GetBotID()))
|
||||||
}
|
}
|
||||||
|
|
||||||
exeCfg := plugin.ExecuteConfig{
|
exeCfg := workflowModel.ExecuteConfig{
|
||||||
ID: mustParseInt64(req.GetWorkflowID()),
|
ID: mustParseInt64(req.GetWorkflowID()),
|
||||||
From: plugin.FromDraft,
|
From: workflowModel.FromDraft,
|
||||||
Operator: uID,
|
Operator: uID,
|
||||||
Mode: plugin.ExecuteModeNodeDebug,
|
Mode: workflowModel.ExecuteModeNodeDebug,
|
||||||
AppID: appID,
|
AppID: appID,
|
||||||
AgentID: agentID,
|
AgentID: agentID,
|
||||||
ConnectorID: consts.CozeConnectorID,
|
ConnectorID: consts.CozeConnectorID,
|
||||||
ConnectorUID: strconv.FormatInt(uID, 10),
|
ConnectorUID: strconv.FormatInt(uID, 10),
|
||||||
TaskType: plugin.TaskTypeForeground,
|
TaskType: workflowModel.TaskTypeForeground,
|
||||||
SyncPattern: plugin.SyncPatternAsync,
|
SyncPattern: workflowModel.SyncPatternAsync,
|
||||||
BizType: plugin.BizTypeWorkflow,
|
BizType: workflowModel.BizTypeWorkflow,
|
||||||
Cancellable: true,
|
Cancellable: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -833,17 +853,7 @@ func (w *ApplicationService) GetNodeExecuteHistory(ctx context.Context, req *wor
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *ApplicationService) DeleteWorkflowsByAppID(ctx context.Context, appID int64) (err error) {
|
func (w *ApplicationService) DeleteWorkflowsByAppID(ctx context.Context, appID int64) (err error) {
|
||||||
defer func() {
|
return w.deleteWorkflowResource(ctx, &vo.DeletePolicy{
|
||||||
if panicErr := recover(); panicErr != nil {
|
|
||||||
err = safego.NewPanicErr(panicErr, debug.Stack())
|
|
||||||
}
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
err = vo.WrapIfNeeded(errno.ErrWorkflowOperationFail, err, errorx.KV("cause", vo.UnwrapRootErr(err).Error()))
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
|
|
||||||
return GetWorkflowDomainSVC().Delete(ctx, &vo.DeletePolicy{
|
|
||||||
AppID: ptr.Of(appID),
|
AppID: ptr.Of(appID),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
@ -867,7 +877,7 @@ func (w *ApplicationService) CheckWorkflowsExistByAppID(ctx context.Context, app
|
||||||
Page: 0,
|
Page: 0,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
QType: plugin.FromDraft,
|
QType: workflowModel.FromDraft,
|
||||||
MetaOnly: true,
|
MetaOnly: true,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
@ -875,8 +885,7 @@ func (w *ApplicationService) CheckWorkflowsExistByAppID(ctx context.Context, app
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *ApplicationService) CopyWorkflowFromAppToLibrary(ctx context.Context, workflowID int64, spaceID, appID int64) (
|
func (w *ApplicationService) CopyWorkflowFromAppToLibrary(ctx context.Context, workflowID int64, spaceID, appID int64) (
|
||||||
_ int64, _ []*vo.ValidateIssue, err error,
|
_ int64, _ []*vo.ValidateIssue, err error) {
|
||||||
) {
|
|
||||||
defer func() {
|
defer func() {
|
||||||
if panicErr := recover(); panicErr != nil {
|
if panicErr := recover(); panicErr != nil {
|
||||||
err = safego.NewPanicErr(panicErr, debug.Stack())
|
err = safego.NewPanicErr(panicErr, debug.Stack())
|
||||||
|
|
@ -959,7 +968,7 @@ func (w *ApplicationService) CopyWorkflowFromAppToLibrary(ctx context.Context, w
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
relatedWorkflows, vIssues, err := GetWorkflowDomainSVC().CopyWorkflowFromAppToLibrary(ctx, workflowID, appID, plugin.ExternalResourceRelated{
|
relatedWorkflows, vIssues, err := w.copyWorkflowFromAppToLibrary(ctx, workflowID, appID, vo.ExternalResourceRelated{
|
||||||
PluginMap: pluginMap,
|
PluginMap: pluginMap,
|
||||||
PluginToolMap: pluginToolMap,
|
PluginToolMap: pluginToolMap,
|
||||||
KnowledgeMap: relatedKnowledgeMap,
|
KnowledgeMap: relatedKnowledgeMap,
|
||||||
|
|
@ -981,6 +990,32 @@ func (w *ApplicationService) CopyWorkflowFromAppToLibrary(ctx context.Context, w
|
||||||
return copiedWf.ID, vIssues, nil
|
return copiedWf.ID, vIssues, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (w *ApplicationService) copyWorkflowFromAppToLibrary(ctx context.Context, workflowID int64, appID int64, related vo.ExternalResourceRelated) (map[int64]entity.IDVersionPair, []*vo.ValidateIssue, error) {
|
||||||
|
resp, err := w.DomainSVC.CopyWorkflowFromAppToLibrary(ctx, workflowID, appID, related)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
for index := range resp.CopiedWorkflows {
|
||||||
|
wf := resp.CopiedWorkflows[index]
|
||||||
|
|
||||||
|
err = PublishWorkflowResource(ctx, wf.ID, ptr.Of(int32(wf.Meta.Mode)), search.Created, &search.ResourceDocument{
|
||||||
|
Name: &wf.Name,
|
||||||
|
SpaceID: &wf.SpaceID,
|
||||||
|
OwnerID: &wf.CreatorID,
|
||||||
|
|
||||||
|
PublishStatus: ptr.Of(resource.PublishStatus_UnPublished),
|
||||||
|
CreateTimeMS: ptr.Of(time.Now().UnixMilli()),
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
logs.CtxErrorf(ctx, "failed to publish workflow resource, workflow id=%d, err=%v", wf.ID, err)
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return resp.WorkflowIDVersionMap, resp.ValidateIssues, nil
|
||||||
|
}
|
||||||
|
|
||||||
type ExternalResource struct {
|
type ExternalResource struct {
|
||||||
PluginMap map[int64]int64
|
PluginMap map[int64]int64
|
||||||
PluginToolMap map[int64]int64
|
PluginToolMap map[int64]int64
|
||||||
|
|
@ -1005,14 +1040,36 @@ func (w *ApplicationService) DuplicateWorkflowsByAppID(ctx context.Context, sour
|
||||||
PluginID: n,
|
PluginID: n,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
externalResourceRelated := plugin.ExternalResourceRelated{
|
externalResourceRelated := vo.ExternalResourceRelated{
|
||||||
PluginMap: pluginMap,
|
PluginMap: pluginMap,
|
||||||
PluginToolMap: externalResource.PluginToolMap,
|
PluginToolMap: externalResource.PluginToolMap,
|
||||||
KnowledgeMap: externalResource.KnowledgeMap,
|
KnowledgeMap: externalResource.KnowledgeMap,
|
||||||
DatabaseMap: externalResource.DatabaseMap,
|
DatabaseMap: externalResource.DatabaseMap,
|
||||||
}
|
}
|
||||||
|
|
||||||
return GetWorkflowDomainSVC().DuplicateWorkflowsByAppID(ctx, sourceAppID, targetAppID, externalResourceRelated)
|
copiedWorkflowArray, err := GetWorkflowDomainSVC().DuplicateWorkflowsByAppID(ctx, sourceAppID, targetAppID, externalResourceRelated)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
logs.CtxInfof(ctx, "[DuplicateWorkflowsByAppID] %s", conv.DebugJsonToStr(copiedWorkflowArray))
|
||||||
|
|
||||||
|
for index := range copiedWorkflowArray {
|
||||||
|
wf := copiedWorkflowArray[index]
|
||||||
|
err = PublishWorkflowResource(ctx, wf.ID, ptr.Of(int32(wf.Meta.Mode)), search.Created, &search.ResourceDocument{
|
||||||
|
Name: &wf.Name,
|
||||||
|
SpaceID: &wf.SpaceID,
|
||||||
|
OwnerID: &wf.CreatorID,
|
||||||
|
APPID: &targetAppID,
|
||||||
|
PublishStatus: ptr.Of(resource.PublishStatus_UnPublished),
|
||||||
|
CreateTimeMS: ptr.Of(time.Now().UnixMilli()),
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
logs.CtxErrorf(ctx, "failed to publish workflow resource, workflow id=%d, err=%v", wf.ID, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *ApplicationService) CopyWorkflowFromLibraryToApp(ctx context.Context, workflowID int64, appID int64) (
|
func (w *ApplicationService) CopyWorkflowFromLibraryToApp(ctx context.Context, workflowID int64, appID int64) (
|
||||||
|
|
@ -1028,7 +1085,7 @@ func (w *ApplicationService) CopyWorkflowFromLibraryToApp(ctx context.Context, w
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
wf, err := GetWorkflowDomainSVC().CopyWorkflow(ctx, workflowID, plugin.CopyWorkflowPolicy{
|
wf, err := w.copyWorkflow(ctx, workflowID, vo.CopyWorkflowPolicy{
|
||||||
TargetAppID: &appID,
|
TargetAppID: &appID,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -1038,6 +1095,28 @@ func (w *ApplicationService) CopyWorkflowFromLibraryToApp(ctx context.Context, w
|
||||||
return wf.ID, nil
|
return wf.ID, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (w *ApplicationService) copyWorkflow(ctx context.Context, workflowID int64, policy vo.CopyWorkflowPolicy) (*entity.Workflow, error) {
|
||||||
|
wf, err := w.DomainSVC.CopyWorkflow(ctx, workflowID, policy)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
err = PublishWorkflowResource(ctx, wf.ID, ptr.Of(int32(wf.Meta.Mode)), search.Created, &search.ResourceDocument{
|
||||||
|
Name: &wf.Name,
|
||||||
|
APPID: wf.AppID,
|
||||||
|
SpaceID: &wf.SpaceID,
|
||||||
|
OwnerID: &wf.CreatorID,
|
||||||
|
PublishStatus: ptr.Of(resource.PublishStatus_UnPublished),
|
||||||
|
CreateTimeMS: ptr.Of(time.Now().UnixMilli()),
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
logs.CtxErrorf(ctx, "public copy workflow event failed, workflowID=%d, err=%v", wf.ID, err)
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return wf, nil
|
||||||
|
}
|
||||||
|
|
||||||
func (w *ApplicationService) MoveWorkflowFromAppToLibrary(ctx context.Context, workflowID int64, spaceID, /*not used for now*/
|
func (w *ApplicationService) MoveWorkflowFromAppToLibrary(ctx context.Context, workflowID int64, spaceID, /*not used for now*/
|
||||||
appID int64) (_ int64, _ []*vo.ValidateIssue, err error) {
|
appID int64) (_ int64, _ []*vo.ValidateIssue, err error) {
|
||||||
defer func() {
|
defer func() {
|
||||||
|
|
@ -1092,7 +1171,7 @@ func (w *ApplicationService) MoveWorkflowFromAppToLibrary(ctx context.Context, w
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
relatedWorkflows, vIssues, err := GetWorkflowDomainSVC().CopyWorkflowFromAppToLibrary(ctx, workflowID, appID, plugin.ExternalResourceRelated{
|
relatedWorkflows, vIssues, err := w.copyWorkflowFromAppToLibrary(ctx, workflowID, appID, vo.ExternalResourceRelated{
|
||||||
PluginMap: pluginMap,
|
PluginMap: pluginMap,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -1102,7 +1181,7 @@ func (w *ApplicationService) MoveWorkflowFromAppToLibrary(ctx context.Context, w
|
||||||
return 0, vIssues, nil
|
return 0, vIssues, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
err = GetWorkflowDomainSVC().SyncRelatedWorkflowResources(ctx, appID, relatedWorkflows, plugin.ExternalResourceRelated{
|
err = GetWorkflowDomainSVC().SyncRelatedWorkflowResources(ctx, appID, relatedWorkflows, vo.ExternalResourceRelated{
|
||||||
PluginMap: pluginMap,
|
PluginMap: pluginMap,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -1110,7 +1189,7 @@ func (w *ApplicationService) MoveWorkflowFromAppToLibrary(ctx context.Context, w
|
||||||
}
|
}
|
||||||
|
|
||||||
deleteWorkflowIDs := xmaps.Keys(relatedWorkflows)
|
deleteWorkflowIDs := xmaps.Keys(relatedWorkflows)
|
||||||
err = GetWorkflowDomainSVC().Delete(ctx, &vo.DeletePolicy{
|
err = w.deleteWorkflowResource(ctx, &vo.DeletePolicy{
|
||||||
IDs: deleteWorkflowIDs,
|
IDs: deleteWorkflowIDs,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -1251,7 +1330,7 @@ func convertStreamRunEvent(workflowID int64) func(msg *entity.Message) (res *wor
|
||||||
return &workflow.OpenAPIStreamRunFlowResponse{
|
return &workflow.OpenAPIStreamRunFlowResponse{
|
||||||
ID: strconv.Itoa(messageID),
|
ID: strconv.Itoa(messageID),
|
||||||
Event: string(DoneEvent),
|
Event: string(DoneEvent),
|
||||||
DebugUrl: ptr.Of(fmt.Sprintf(plugin.DebugURLTpl, executeID, spaceID, workflowID)),
|
DebugUrl: ptr.Of(fmt.Sprintf(workflowModel.DebugURLTpl, executeID, spaceID, workflowID)),
|
||||||
}, nil
|
}, nil
|
||||||
case entity.WorkflowFailed, entity.WorkflowCancel:
|
case entity.WorkflowFailed, entity.WorkflowCancel:
|
||||||
var wfe vo.WorkflowError
|
var wfe vo.WorkflowError
|
||||||
|
|
@ -1261,7 +1340,7 @@ func convertStreamRunEvent(workflowID int64) func(msg *entity.Message) (res *wor
|
||||||
return &workflow.OpenAPIStreamRunFlowResponse{
|
return &workflow.OpenAPIStreamRunFlowResponse{
|
||||||
ID: strconv.Itoa(messageID),
|
ID: strconv.Itoa(messageID),
|
||||||
Event: string(ErrEvent),
|
Event: string(ErrEvent),
|
||||||
DebugUrl: ptr.Of(fmt.Sprintf(plugin.DebugURLTpl, executeID, spaceID, workflowID)),
|
DebugUrl: ptr.Of(fmt.Sprintf(workflowModel.DebugURLTpl, executeID, spaceID, workflowID)),
|
||||||
ErrorCode: ptr.Of(int64(wfe.Code())),
|
ErrorCode: ptr.Of(int64(wfe.Code())),
|
||||||
ErrorMessage: ptr.Of(wfe.Msg()),
|
ErrorMessage: ptr.Of(wfe.Msg()),
|
||||||
}, nil
|
}, nil
|
||||||
|
|
@ -1270,7 +1349,7 @@ func convertStreamRunEvent(workflowID int64) func(msg *entity.Message) (res *wor
|
||||||
return &workflow.OpenAPIStreamRunFlowResponse{
|
return &workflow.OpenAPIStreamRunFlowResponse{
|
||||||
ID: strconv.Itoa(messageID),
|
ID: strconv.Itoa(messageID),
|
||||||
Event: string(InterruptEvent),
|
Event: string(InterruptEvent),
|
||||||
DebugUrl: ptr.Of(fmt.Sprintf(plugin.DebugURLTpl, executeID, spaceID, workflowID)),
|
DebugUrl: ptr.Of(fmt.Sprintf(workflowModel.DebugURLTpl, executeID, spaceID, workflowID)),
|
||||||
InterruptData: &workflow.Interrupt{
|
InterruptData: &workflow.Interrupt{
|
||||||
EventID: fmt.Sprintf("%d/%d", executeID, msg.InterruptEvent.ID),
|
EventID: fmt.Sprintf("%d/%d", executeID, msg.InterruptEvent.ID),
|
||||||
Type: workflow.InterruptType(msg.InterruptEvent.EventType),
|
Type: workflow.InterruptType(msg.InterruptEvent.EventType),
|
||||||
|
|
@ -1282,7 +1361,7 @@ func convertStreamRunEvent(workflowID int64) func(msg *entity.Message) (res *wor
|
||||||
return &workflow.OpenAPIStreamRunFlowResponse{
|
return &workflow.OpenAPIStreamRunFlowResponse{
|
||||||
ID: strconv.Itoa(messageID),
|
ID: strconv.Itoa(messageID),
|
||||||
Event: string(InterruptEvent),
|
Event: string(InterruptEvent),
|
||||||
DebugUrl: ptr.Of(fmt.Sprintf(plugin.DebugURLTpl, executeID, spaceID, workflowID)),
|
DebugUrl: ptr.Of(fmt.Sprintf(workflowModel.DebugURLTpl, executeID, spaceID, workflowID)),
|
||||||
InterruptData: &workflow.Interrupt{
|
InterruptData: &workflow.Interrupt{
|
||||||
EventID: fmt.Sprintf("%d/%d", executeID, msg.InterruptEvent.ID),
|
EventID: fmt.Sprintf("%d/%d", executeID, msg.InterruptEvent.ID),
|
||||||
Type: workflow.InterruptType(msg.InterruptEvent.ToolInterruptEvent.EventType),
|
Type: workflow.InterruptType(msg.InterruptEvent.ToolInterruptEvent.EventType),
|
||||||
|
|
@ -1398,20 +1477,20 @@ func (w *ApplicationService) OpenAPIStreamRun(ctx context.Context, req *workflow
|
||||||
connectorID = apiKeyInfo.ConnectorID
|
connectorID = apiKeyInfo.ConnectorID
|
||||||
}
|
}
|
||||||
|
|
||||||
exeCfg := plugin.ExecuteConfig{
|
exeCfg := workflowModel.ExecuteConfig{
|
||||||
ID: meta.ID,
|
ID: meta.ID,
|
||||||
From: plugin.FromSpecificVersion,
|
From: workflowModel.FromSpecificVersion,
|
||||||
Version: *meta.LatestPublishedVersion,
|
Version: *meta.LatestPublishedVersion,
|
||||||
Operator: userID,
|
Operator: userID,
|
||||||
Mode: plugin.ExecuteModeRelease,
|
Mode: workflowModel.ExecuteModeRelease,
|
||||||
AppID: appID,
|
AppID: appID,
|
||||||
AgentID: agentID,
|
AgentID: agentID,
|
||||||
ConnectorID: connectorID,
|
ConnectorID: connectorID,
|
||||||
ConnectorUID: strconv.FormatInt(userID, 10),
|
ConnectorUID: strconv.FormatInt(userID, 10),
|
||||||
TaskType: plugin.TaskTypeForeground,
|
TaskType: workflowModel.TaskTypeForeground,
|
||||||
SyncPattern: plugin.SyncPatternStream,
|
SyncPattern: workflowModel.SyncPatternStream,
|
||||||
InputFailFast: true,
|
InputFailFast: true,
|
||||||
BizType: plugin.BizTypeWorkflow,
|
BizType: workflowModel.BizTypeWorkflow,
|
||||||
}
|
}
|
||||||
|
|
||||||
if exeCfg.AppID != nil && exeCfg.AgentID != nil {
|
if exeCfg.AppID != nil && exeCfg.AgentID != nil {
|
||||||
|
|
@ -1472,12 +1551,12 @@ func (w *ApplicationService) OpenAPIStreamResume(ctx context.Context, req *workf
|
||||||
connectorID = mustParseInt64(req.GetConnectorID())
|
connectorID = mustParseInt64(req.GetConnectorID())
|
||||||
}
|
}
|
||||||
|
|
||||||
sr, err := GetWorkflowDomainSVC().StreamResume(ctx, resumeReq, plugin.ExecuteConfig{
|
sr, err := GetWorkflowDomainSVC().StreamResume(ctx, resumeReq, workflowModel.ExecuteConfig{
|
||||||
Operator: userID,
|
Operator: userID,
|
||||||
Mode: plugin.ExecuteModeRelease,
|
Mode: workflowModel.ExecuteModeRelease,
|
||||||
ConnectorID: connectorID,
|
ConnectorID: connectorID,
|
||||||
ConnectorUID: strconv.FormatInt(userID, 10),
|
ConnectorUID: strconv.FormatInt(userID, 10),
|
||||||
BizType: plugin.BizTypeWorkflow,
|
BizType: workflowModel.BizTypeWorkflow,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
@ -1547,18 +1626,18 @@ func (w *ApplicationService) OpenAPIRun(ctx context.Context, req *workflow.OpenA
|
||||||
connectorID = apiKeyInfo.ConnectorID
|
connectorID = apiKeyInfo.ConnectorID
|
||||||
}
|
}
|
||||||
|
|
||||||
exeCfg := plugin.ExecuteConfig{
|
exeCfg := workflowModel.ExecuteConfig{
|
||||||
ID: meta.ID,
|
ID: meta.ID,
|
||||||
From: plugin.FromSpecificVersion,
|
From: workflowModel.FromSpecificVersion,
|
||||||
Version: *meta.LatestPublishedVersion,
|
Version: *meta.LatestPublishedVersion,
|
||||||
Operator: userID,
|
Operator: userID,
|
||||||
Mode: plugin.ExecuteModeRelease,
|
Mode: workflowModel.ExecuteModeRelease,
|
||||||
AppID: appID,
|
AppID: appID,
|
||||||
AgentID: agentID,
|
AgentID: agentID,
|
||||||
ConnectorID: connectorID,
|
ConnectorID: connectorID,
|
||||||
ConnectorUID: strconv.FormatInt(userID, 10),
|
ConnectorUID: strconv.FormatInt(userID, 10),
|
||||||
InputFailFast: true,
|
InputFailFast: true,
|
||||||
BizType: plugin.BizTypeWorkflow,
|
BizType: workflowModel.BizTypeWorkflow,
|
||||||
}
|
}
|
||||||
|
|
||||||
if exeCfg.AppID != nil && exeCfg.AgentID != nil {
|
if exeCfg.AppID != nil && exeCfg.AgentID != nil {
|
||||||
|
|
@ -1566,8 +1645,8 @@ func (w *ApplicationService) OpenAPIRun(ctx context.Context, req *workflow.OpenA
|
||||||
}
|
}
|
||||||
|
|
||||||
if req.GetIsAsync() {
|
if req.GetIsAsync() {
|
||||||
exeCfg.SyncPattern = plugin.SyncPatternAsync
|
exeCfg.SyncPattern = workflowModel.SyncPatternAsync
|
||||||
exeCfg.TaskType = plugin.TaskTypeBackground
|
exeCfg.TaskType = workflowModel.TaskTypeBackground
|
||||||
exeID, err := GetWorkflowDomainSVC().AsyncExecute(ctx, exeCfg, parameters)
|
exeID, err := GetWorkflowDomainSVC().AsyncExecute(ctx, exeCfg, parameters)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
@ -1575,12 +1654,12 @@ func (w *ApplicationService) OpenAPIRun(ctx context.Context, req *workflow.OpenA
|
||||||
|
|
||||||
return &workflow.OpenAPIRunFlowResponse{
|
return &workflow.OpenAPIRunFlowResponse{
|
||||||
ExecuteID: ptr.Of(strconv.FormatInt(exeID, 10)),
|
ExecuteID: ptr.Of(strconv.FormatInt(exeID, 10)),
|
||||||
DebugUrl: ptr.Of(fmt.Sprintf(plugin.DebugURLTpl, exeID, meta.SpaceID, meta.ID)),
|
DebugUrl: ptr.Of(fmt.Sprintf(workflowModel.DebugURLTpl, exeID, meta.SpaceID, meta.ID)),
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
exeCfg.SyncPattern = plugin.SyncPatternSync
|
exeCfg.SyncPattern = workflowModel.SyncPatternSync
|
||||||
exeCfg.TaskType = plugin.TaskTypeForeground
|
exeCfg.TaskType = workflowModel.TaskTypeForeground
|
||||||
wfExe, tPlan, err := GetWorkflowDomainSVC().SyncExecute(ctx, exeCfg, parameters)
|
wfExe, tPlan, err := GetWorkflowDomainSVC().SyncExecute(ctx, exeCfg, parameters)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
@ -1611,7 +1690,7 @@ func (w *ApplicationService) OpenAPIRun(ctx context.Context, req *workflow.OpenA
|
||||||
return &workflow.OpenAPIRunFlowResponse{
|
return &workflow.OpenAPIRunFlowResponse{
|
||||||
Data: data,
|
Data: data,
|
||||||
ExecuteID: ptr.Of(strconv.FormatInt(wfExe.ID, 10)),
|
ExecuteID: ptr.Of(strconv.FormatInt(wfExe.ID, 10)),
|
||||||
DebugUrl: ptr.Of(fmt.Sprintf(plugin.DebugURLTpl, wfExe.ID, wfExe.SpaceID, meta.ID)),
|
DebugUrl: ptr.Of(fmt.Sprintf(workflowModel.DebugURLTpl, wfExe.ID, wfExe.SpaceID, meta.ID)),
|
||||||
Token: ptr.Of(wfExe.TokenInfo.InputTokens + wfExe.TokenInfo.OutputTokens),
|
Token: ptr.Of(wfExe.TokenInfo.InputTokens + wfExe.TokenInfo.OutputTokens),
|
||||||
Cost: ptr.Of("0.00000"),
|
Cost: ptr.Of("0.00000"),
|
||||||
}, nil
|
}, nil
|
||||||
|
|
@ -1651,11 +1730,11 @@ func (w *ApplicationService) OpenAPIGetWorkflowRunHistory(ctx context.Context, r
|
||||||
|
|
||||||
var runMode *workflow.WorkflowRunMode
|
var runMode *workflow.WorkflowRunMode
|
||||||
switch exe.SyncPattern {
|
switch exe.SyncPattern {
|
||||||
case plugin.SyncPatternSync:
|
case workflowModel.SyncPatternSync:
|
||||||
runMode = ptr.Of(workflow.WorkflowRunMode_Sync)
|
runMode = ptr.Of(workflow.WorkflowRunMode_Sync)
|
||||||
case plugin.SyncPatternAsync:
|
case workflowModel.SyncPatternAsync:
|
||||||
runMode = ptr.Of(workflow.WorkflowRunMode_Async)
|
runMode = ptr.Of(workflow.WorkflowRunMode_Async)
|
||||||
case plugin.SyncPatternStream:
|
case workflowModel.SyncPatternStream:
|
||||||
runMode = ptr.Of(workflow.WorkflowRunMode_Stream)
|
runMode = ptr.Of(workflow.WorkflowRunMode_Stream)
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
|
|
@ -1672,7 +1751,7 @@ func (w *ApplicationService) OpenAPIGetWorkflowRunHistory(ctx context.Context, r
|
||||||
LogID: ptr.Of(exe.LogID),
|
LogID: ptr.Of(exe.LogID),
|
||||||
CreateTime: ptr.Of(exe.CreatedAt.Unix()),
|
CreateTime: ptr.Of(exe.CreatedAt.Unix()),
|
||||||
UpdateTime: updateTime,
|
UpdateTime: updateTime,
|
||||||
DebugUrl: ptr.Of(fmt.Sprintf(plugin.DebugURLTpl, exe.ID, exe.SpaceID, exe.WorkflowID)),
|
DebugUrl: ptr.Of(fmt.Sprintf(workflowModel.DebugURLTpl, exe.ID, exe.SpaceID, exe.WorkflowID)),
|
||||||
Input: exe.Input,
|
Input: exe.Input,
|
||||||
Output: exe.Output,
|
Output: exe.Output,
|
||||||
Token: ptr.Of(exe.TokenInfo.InputTokens + exe.TokenInfo.OutputTokens),
|
Token: ptr.Of(exe.TokenInfo.InputTokens + exe.TokenInfo.OutputTokens),
|
||||||
|
|
@ -1806,10 +1885,10 @@ func (w *ApplicationService) TestResume(ctx context.Context, req *workflow.Workf
|
||||||
EventID: mustParseInt64(req.GetEventID()),
|
EventID: mustParseInt64(req.GetEventID()),
|
||||||
ResumeData: req.GetData(),
|
ResumeData: req.GetData(),
|
||||||
}
|
}
|
||||||
err = GetWorkflowDomainSVC().AsyncResume(ctx, resumeReq, plugin.ExecuteConfig{
|
err = GetWorkflowDomainSVC().AsyncResume(ctx, resumeReq, workflowModel.ExecuteConfig{
|
||||||
Operator: ptr.FromOrDefault(ctxutil.GetUIDFromCtx(ctx), 0),
|
Operator: ptr.FromOrDefault(ctxutil.GetUIDFromCtx(ctx), 0),
|
||||||
Mode: plugin.ExecuteModeDebug, // at this stage it could be debug or node debug, we will decide it within AsyncResume
|
Mode: workflowModel.ExecuteModeDebug, // at this stage it could be debug or node debug, we will decide it within AsyncResume
|
||||||
BizType: plugin.BizTypeWorkflow,
|
BizType: workflowModel.BizTypeWorkflow,
|
||||||
Cancellable: true,
|
Cancellable: true,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -1949,7 +2028,7 @@ func (w *ApplicationService) PublishWorkflow(ctx context.Context, req *workflow.
|
||||||
Force: req.GetForce(),
|
Force: req.GetForce(),
|
||||||
}
|
}
|
||||||
|
|
||||||
err = GetWorkflowDomainSVC().Publish(ctx, info)
|
err = w.publishWorkflowResource(ctx, info)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
@ -2004,13 +2083,13 @@ func (w *ApplicationService) ListWorkflow(ctx context.Context, req *workflow.Get
|
||||||
}
|
}
|
||||||
|
|
||||||
status := req.GetStatus()
|
status := req.GetStatus()
|
||||||
var qType plugin.Locator
|
var qType workflowModel.Locator
|
||||||
if status == workflow.WorkFlowListStatus_UnPublished {
|
if status == workflow.WorkFlowListStatus_UnPublished {
|
||||||
option.PublishStatus = ptr.Of(vo.UnPublished)
|
option.PublishStatus = ptr.Of(vo.UnPublished)
|
||||||
qType = plugin.FromDraft
|
qType = workflowModel.FromDraft
|
||||||
} else if status == workflow.WorkFlowListStatus_HadPublished {
|
} else if status == workflow.WorkFlowListStatus_HadPublished {
|
||||||
option.PublishStatus = ptr.Of(vo.HasPublished)
|
option.PublishStatus = ptr.Of(vo.HasPublished)
|
||||||
qType = plugin.FromLatestVersion
|
qType = workflowModel.FromLatestVersion
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(req.GetName()) > 0 {
|
if len(req.GetName()) > 0 {
|
||||||
|
|
@ -2078,9 +2157,9 @@ func (w *ApplicationService) ListWorkflow(ctx context.Context, req *workflow.Get
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
if qType == plugin.FromDraft {
|
if qType == workflowModel.FromDraft {
|
||||||
ww.UpdateTime = w.DraftMeta.Timestamp.Unix()
|
ww.UpdateTime = w.DraftMeta.Timestamp.Unix()
|
||||||
} else if qType == plugin.FromLatestVersion || qType == plugin.FromSpecificVersion {
|
} else if qType == workflowModel.FromLatestVersion || qType == workflowModel.FromSpecificVersion {
|
||||||
ww.UpdateTime = w.VersionMeta.VersionCreatedAt.Unix()
|
ww.UpdateTime = w.VersionMeta.VersionCreatedAt.Unix()
|
||||||
} else if w.UpdatedAt != nil {
|
} else if w.UpdatedAt != nil {
|
||||||
ww.UpdateTime = w.UpdatedAt.Unix()
|
ww.UpdateTime = w.UpdatedAt.Unix()
|
||||||
|
|
@ -2165,7 +2244,7 @@ func (w *ApplicationService) GetWorkflowDetail(ctx context.Context, req *workflo
|
||||||
MetaQuery: vo.MetaQuery{
|
MetaQuery: vo.MetaQuery{
|
||||||
IDs: ids,
|
IDs: ids,
|
||||||
},
|
},
|
||||||
QType: plugin.FromDraft,
|
QType: workflowModel.FromDraft,
|
||||||
MetaOnly: false,
|
MetaOnly: false,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -2271,7 +2350,7 @@ func (w *ApplicationService) GetWorkflowDetailInfo(ctx context.Context, req *wor
|
||||||
MetaQuery: vo.MetaQuery{
|
MetaQuery: vo.MetaQuery{
|
||||||
IDs: draftIDs,
|
IDs: draftIDs,
|
||||||
},
|
},
|
||||||
QType: plugin.FromDraft,
|
QType: workflowModel.FromDraft,
|
||||||
MetaOnly: false,
|
MetaOnly: false,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -2284,7 +2363,7 @@ func (w *ApplicationService) GetWorkflowDetailInfo(ctx context.Context, req *wor
|
||||||
MetaQuery: vo.MetaQuery{
|
MetaQuery: vo.MetaQuery{
|
||||||
IDs: versionIDs,
|
IDs: versionIDs,
|
||||||
},
|
},
|
||||||
QType: plugin.FromSpecificVersion,
|
QType: workflowModel.FromSpecificVersion,
|
||||||
MetaOnly: false,
|
MetaOnly: false,
|
||||||
Versions: id2Version,
|
Versions: id2Version,
|
||||||
})
|
})
|
||||||
|
|
@ -2657,7 +2736,7 @@ func (w *ApplicationService) GetLLMNodeFCSettingDetail(ctx context.Context, req
|
||||||
MetaQuery: vo.MetaQuery{
|
MetaQuery: vo.MetaQuery{
|
||||||
IDs: draftIDs,
|
IDs: draftIDs,
|
||||||
},
|
},
|
||||||
QType: plugin.FromDraft,
|
QType: workflowModel.FromDraft,
|
||||||
MetaOnly: false,
|
MetaOnly: false,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -2670,7 +2749,7 @@ func (w *ApplicationService) GetLLMNodeFCSettingDetail(ctx context.Context, req
|
||||||
MetaQuery: vo.MetaQuery{
|
MetaQuery: vo.MetaQuery{
|
||||||
IDs: versionIDs,
|
IDs: versionIDs,
|
||||||
},
|
},
|
||||||
QType: plugin.FromSpecificVersion,
|
QType: workflowModel.FromSpecificVersion,
|
||||||
MetaOnly: false,
|
MetaOnly: false,
|
||||||
Versions: id2Version,
|
Versions: id2Version,
|
||||||
})
|
})
|
||||||
|
|
@ -2817,7 +2896,7 @@ func (w *ApplicationService) GetLLMNodeFCSettingsMerged(ctx context.Context, req
|
||||||
|
|
||||||
policy := &vo.GetPolicy{
|
policy := &vo.GetPolicy{
|
||||||
ID: wID,
|
ID: wID,
|
||||||
QType: ternary.IFElse(len(setting.WorkflowVersion) == 0, plugin.FromDraft, plugin.FromSpecificVersion),
|
QType: ternary.IFElse(len(setting.WorkflowVersion) == 0, workflowModel.FromDraft, workflowModel.FromSpecificVersion),
|
||||||
Version: setting.WorkflowVersion,
|
Version: setting.WorkflowVersion,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2892,7 +2971,7 @@ func (w *ApplicationService) GetPlaygroundPluginList(ctx context.Context, req *p
|
||||||
SpaceID: ptr.Of(req.GetSpaceID()),
|
SpaceID: ptr.Of(req.GetSpaceID()),
|
||||||
PublishStatus: ptr.Of(vo.HasPublished),
|
PublishStatus: ptr.Of(vo.HasPublished),
|
||||||
},
|
},
|
||||||
QType: plugin.FromLatestVersion,
|
QType: workflowModel.FromLatestVersion,
|
||||||
})
|
})
|
||||||
} else if req.GetPage() > 0 && req.GetSize() > 0 {
|
} else if req.GetPage() > 0 && req.GetSize() > 0 {
|
||||||
wfs, _, err = GetWorkflowDomainSVC().MGet(ctx, &vo.MGetPolicy{
|
wfs, _, err = GetWorkflowDomainSVC().MGet(ctx, &vo.MGetPolicy{
|
||||||
|
|
@ -2904,7 +2983,7 @@ func (w *ApplicationService) GetPlaygroundPluginList(ctx context.Context, req *p
|
||||||
SpaceID: ptr.Of(req.GetSpaceID()),
|
SpaceID: ptr.Of(req.GetSpaceID()),
|
||||||
PublishStatus: ptr.Of(vo.HasPublished),
|
PublishStatus: ptr.Of(vo.HasPublished),
|
||||||
},
|
},
|
||||||
QType: plugin.FromLatestVersion,
|
QType: workflowModel.FromLatestVersion,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2978,7 +3057,7 @@ func (w *ApplicationService) CopyWorkflow(ctx context.Context, req *workflow.Cop
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
wf, err := GetWorkflowDomainSVC().CopyWorkflow(ctx, workflowID, plugin.CopyWorkflowPolicy{
|
wf, err := w.copyWorkflow(ctx, workflowID, vo.CopyWorkflowPolicy{
|
||||||
ShouldModifyWorkflowName: true,
|
ShouldModifyWorkflowName: true,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -3044,7 +3123,7 @@ func (w *ApplicationService) GetHistorySchema(ctx context.Context, req *workflow
|
||||||
// get the workflow entity for that workflowID and commitID
|
// get the workflow entity for that workflowID and commitID
|
||||||
policy := &vo.GetPolicy{
|
policy := &vo.GetPolicy{
|
||||||
ID: workflowID,
|
ID: workflowID,
|
||||||
QType: ternary.IFElse(len(exe.Version) > 0, plugin.FromSpecificVersion, plugin.FromDraft),
|
QType: ternary.IFElse(len(exe.Version) > 0, workflowModel.FromSpecificVersion, workflowModel.FromDraft),
|
||||||
Version: exe.Version,
|
Version: exe.Version,
|
||||||
CommitID: exe.CommitID,
|
CommitID: exe.CommitID,
|
||||||
}
|
}
|
||||||
|
|
@ -3102,7 +3181,7 @@ func (w *ApplicationService) GetExampleWorkFlowList(ctx context.Context, req *wo
|
||||||
|
|
||||||
wfs, _, err := GetWorkflowDomainSVC().MGet(ctx, &vo.MGetPolicy{
|
wfs, _, err := GetWorkflowDomainSVC().MGet(ctx, &vo.MGetPolicy{
|
||||||
MetaQuery: option,
|
MetaQuery: option,
|
||||||
QType: plugin.FromDraft,
|
QType: workflowModel.FromDraft,
|
||||||
MetaOnly: false,
|
MetaOnly: false,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -3181,7 +3260,7 @@ func (w *ApplicationService) CopyWkTemplateApi(ctx context.Context, req *workflo
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
wf, err := GetWorkflowDomainSVC().CopyWorkflow(ctx, wid, plugin.CopyWorkflowPolicy{
|
wf, err := w.copyWorkflow(ctx, wid, vo.CopyWorkflowPolicy{
|
||||||
ShouldModifyWorkflowName: true,
|
ShouldModifyWorkflowName: true,
|
||||||
TargetSpaceID: ptr.Of(req.GetTargetSpaceID()),
|
TargetSpaceID: ptr.Of(req.GetTargetSpaceID()),
|
||||||
TargetAppID: ptr.Of(int64(0)),
|
TargetAppID: ptr.Of(int64(0)),
|
||||||
|
|
@ -3190,7 +3269,7 @@ func (w *ApplicationService) CopyWkTemplateApi(ctx context.Context, req *workflo
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
err = GetWorkflowDomainSVC().Publish(ctx, &vo.PublishPolicy{
|
err = w.publishWorkflowResource(ctx, &vo.PublishPolicy{
|
||||||
ID: wf.ID,
|
ID: wf.ID,
|
||||||
Version: "v0.0.0",
|
Version: "v0.0.0",
|
||||||
CommitID: wf.CommitID,
|
CommitID: wf.CommitID,
|
||||||
|
|
@ -3271,6 +3350,26 @@ func (w *ApplicationService) CopyWkTemplateApi(ctx context.Context, req *workflo
|
||||||
return resp, err
|
return resp, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (w *ApplicationService) publishWorkflowResource(ctx context.Context, policy *vo.PublishPolicy) error {
|
||||||
|
err := w.DomainSVC.Publish(ctx, policy)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
safego.Go(ctx, func() {
|
||||||
|
now := time.Now().UnixMilli()
|
||||||
|
if err := PublishWorkflowResource(ctx, policy.ID, nil, search.Updated, &search.ResourceDocument{
|
||||||
|
PublishStatus: ptr.Of(resource.PublishStatus_Published),
|
||||||
|
UpdateTimeMS: ptr.Of(now),
|
||||||
|
PublishTimeMS: ptr.Of(now),
|
||||||
|
}); err != nil {
|
||||||
|
logs.CtxErrorf(ctx, "publish workflow resource failed workflowID = %d, err: %v", policy.ID, err)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func mustParseInt64(s string) int64 {
|
func mustParseInt64(s string) int64 {
|
||||||
i, err := strconv.ParseInt(s, 10, 64)
|
i, err := strconv.ParseInt(s, 10, 64)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
|
|
@ -22,8 +22,10 @@ import (
|
||||||
"github.com/cloudwego/eino/schema"
|
"github.com/cloudwego/eino/schema"
|
||||||
|
|
||||||
model "github.com/coze-dev/coze-studio/backend/api/model/crossdomain/plugin"
|
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 {
|
type PluginService interface {
|
||||||
MGetVersionPlugins(ctx context.Context, versionPlugins []model.VersionPlugin) (plugins []*model.PluginInfo, err error)
|
MGetVersionPlugins(ctx context.Context, versionPlugins []model.VersionPlugin) (plugins []*model.PluginInfo, err error)
|
||||||
MGetPluginLatestVersion(ctx context.Context, pluginIDs []int64) (resp *model.MGetPluginLatestVersionResponse, 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)
|
MGetVersionTools(ctx context.Context, versionTools []model.VersionTool) (tools []*model.ToolInfo, err error)
|
||||||
GetPluginToolsInfo(ctx context.Context, req *model.ToolsInfoRequest) (*model.ToolsInfoResponse, error)
|
GetPluginToolsInfo(ctx context.Context, req *model.ToolsInfoRequest) (*model.ToolsInfoResponse, error)
|
||||||
GetPluginInvokableTools(ctx context.Context, req *model.ToolsInvokableRequest) (map[int64]InvokableTool, 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 {
|
type InvokableTool interface {
|
||||||
Info(ctx context.Context) (*schema.ToolInfo, error)
|
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
|
var defaultSVC PluginService
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@ import (
|
||||||
|
|
||||||
schema "github.com/cloudwego/eino/schema"
|
schema "github.com/cloudwego/eino/schema"
|
||||||
plugin "github.com/coze-dev/coze-studio/backend/api/model/crossdomain/plugin"
|
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"
|
plugin0 "github.com/coze-dev/coze-studio/backend/crossdomain/contract/plugin"
|
||||||
gomock "go.uber.org/mock/gomock"
|
gomock "go.uber.org/mock/gomock"
|
||||||
)
|
)
|
||||||
|
|
@ -86,7 +87,7 @@ func (mr *MockPluginServiceMockRecorder) DuplicateDraftAgentTools(ctx, fromAgent
|
||||||
}
|
}
|
||||||
|
|
||||||
// ExecutePlugin mocks base method.
|
// 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()
|
m.ctrl.T.Helper()
|
||||||
ret := m.ctrl.Call(m, "ExecutePlugin", ctx, input, pe, toolID, cfg)
|
ret := m.ctrl.Call(m, "ExecutePlugin", ctx, input, pe, toolID, cfg)
|
||||||
ret0, _ := ret[0].(map[string]any)
|
ret0, _ := ret[0].(map[string]any)
|
||||||
|
|
@ -308,7 +309,7 @@ func (mr *MockInvokableToolMockRecorder) Info(ctx any) *gomock.Call {
|
||||||
}
|
}
|
||||||
|
|
||||||
// PluginInvoke mocks base method.
|
// 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()
|
m.ctrl.T.Helper()
|
||||||
ret := m.ctrl.Call(m, "PluginInvoke", ctx, argumentsInJSON, cfg)
|
ret := m.ctrl.Call(m, "PluginInvoke", ctx, argumentsInJSON, cfg)
|
||||||
ret0, _ := ret[0].(string)
|
ret0, _ := ret[0].(string)
|
||||||
|
|
|
||||||
|
|
@ -23,29 +23,28 @@ import (
|
||||||
einoCompose "github.com/cloudwego/eino/compose"
|
einoCompose "github.com/cloudwego/eino/compose"
|
||||||
"github.com/cloudwego/eino/schema"
|
"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"
|
||||||
"github.com/coze-dev/coze-studio/backend/domain/workflow/entity"
|
"github.com/coze-dev/coze-studio/backend/domain/workflow/entity"
|
||||||
workflowEntity "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"
|
"github.com/coze-dev/coze-studio/backend/domain/workflow/entity/vo"
|
||||||
)
|
)
|
||||||
|
|
||||||
// TODO (@fanlv): Parameter references need to be modified.
|
// TODO (@fanlv): Parameter references need to be modified.
|
||||||
type Workflow interface {
|
type Workflow interface {
|
||||||
WorkflowAsModelTool(ctx context.Context, policies []*vo.GetPolicy) ([]workflow.ToolFromWorkflow, error)
|
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,
|
WithResumeToolWorkflow(resumingEvent *workflowEntity.ToolInterruptEvent, resumeData string,
|
||||||
allInterruptEvents map[string]*workflowEntity.ToolInterruptEvent) einoCompose.Option
|
allInterruptEvents map[string]*workflowEntity.ToolInterruptEvent) einoCompose.Option
|
||||||
ReleaseApplicationWorkflows(ctx context.Context, appID int64, config *ReleaseWorkflowConfig) ([]*vo.ValidateIssue, error)
|
ReleaseApplicationWorkflows(ctx context.Context, appID int64, config *ReleaseWorkflowConfig) ([]*vo.ValidateIssue, error)
|
||||||
GetWorkflowIDsByAppID(ctx context.Context, appID int64) ([]int64, 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)
|
SyncExecuteWorkflow(ctx context.Context, config workflowModel.ExecuteConfig, input map[string]any) (*workflowEntity.WorkflowExecution, vo.TerminatePlan, error)
|
||||||
WithExecuteConfig(cfg model.ExecuteConfig) einoCompose.Option
|
WithExecuteConfig(cfg workflowModel.ExecuteConfig) einoCompose.Option
|
||||||
WithMessagePipe() (compose.Option, *schema.StreamReader[*entity.Message])
|
WithMessagePipe() (compose.Option, *schema.StreamReader[*entity.Message])
|
||||||
}
|
}
|
||||||
|
|
||||||
type ExecuteConfig = model.ExecuteConfig
|
type ExecuteConfig = workflowModel.ExecuteConfig
|
||||||
type ExecuteMode = model.ExecuteMode
|
type ExecuteMode = workflowModel.ExecuteMode
|
||||||
type NodeType = entity.NodeType
|
type NodeType = entity.NodeType
|
||||||
|
|
||||||
type WorkflowMessage = entity.Message
|
type WorkflowMessage = entity.Message
|
||||||
|
|
@ -60,14 +59,14 @@ const (
|
||||||
ExecuteModeNodeDebug ExecuteMode = "node_debug"
|
ExecuteModeNodeDebug ExecuteMode = "node_debug"
|
||||||
)
|
)
|
||||||
|
|
||||||
type TaskType = model.TaskType
|
type TaskType = workflowModel.TaskType
|
||||||
|
|
||||||
const (
|
const (
|
||||||
TaskTypeForeground TaskType = "foreground"
|
TaskTypeForeground TaskType = "foreground"
|
||||||
TaskTypeBackground TaskType = "background"
|
TaskTypeBackground TaskType = "background"
|
||||||
)
|
)
|
||||||
|
|
||||||
type BizType = model.BizType
|
type BizType = workflowModel.BizType
|
||||||
|
|
||||||
const (
|
const (
|
||||||
BizTypeAgent BizType = "agent"
|
BizTypeAgent BizType = "agent"
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,7 @@ import (
|
||||||
"golang.org/x/exp/maps"
|
"golang.org/x/exp/maps"
|
||||||
|
|
||||||
model "github.com/coze-dev/coze-studio/backend/api/model/crossdomain/plugin"
|
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/api/model/plugin_develop/common"
|
"github.com/coze-dev/coze-studio/backend/api/model/plugin_develop/common"
|
||||||
workflow3 "github.com/coze-dev/coze-studio/backend/api/model/workflow"
|
workflow3 "github.com/coze-dev/coze-studio/backend/api/model/workflow"
|
||||||
"github.com/coze-dev/coze-studio/backend/application/base/pluginutil"
|
"github.com/coze-dev/coze-studio/backend/application/base/pluginutil"
|
||||||
|
|
@ -341,7 +342,7 @@ func (s *impl) GetPluginInvokableTools(ctx context.Context, req *model.ToolsInvo
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *impl) ExecutePlugin(ctx context.Context, input map[string]any, pe *model.PluginEntity,
|
func (s *impl) ExecutePlugin(ctx context.Context, input map[string]any, pe *model.PluginEntity,
|
||||||
toolID int64, cfg model.ExecuteConfig) (map[string]any, error) {
|
toolID int64, cfg workflowModel.ExecuteConfig) (map[string]any, error) {
|
||||||
args, err := sonic.MarshalString(input)
|
args, err := sonic.MarshalString(input)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, vo.WrapError(errno.ErrSerializationDeserializationFail, err)
|
return nil, vo.WrapError(errno.ErrSerializationDeserializationFail, err)
|
||||||
|
|
@ -447,7 +448,7 @@ func (p *pluginInvokeTool) Info(ctx context.Context) (_ *schema.ToolInfo, err er
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *pluginInvokeTool) PluginInvoke(ctx context.Context, argumentsInJSON string, cfg model.ExecuteConfig) (string, error) {
|
func (p *pluginInvokeTool) PluginInvoke(ctx context.Context, argumentsInJSON string, cfg workflowModel.ExecuteConfig) (string, error) {
|
||||||
req := &service.ExecuteToolRequest{
|
req := &service.ExecuteToolRequest{
|
||||||
UserID: conv.Int64ToStr(cfg.Operator),
|
UserID: conv.Int64ToStr(cfg.Operator),
|
||||||
PluginID: p.pluginEntity.PluginID,
|
PluginID: p.pluginEntity.PluginID,
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ import (
|
||||||
einoCompose "github.com/cloudwego/eino/compose"
|
einoCompose "github.com/cloudwego/eino/compose"
|
||||||
"github.com/cloudwego/eino/schema"
|
"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"
|
||||||
crossworkflow "github.com/coze-dev/coze-studio/backend/crossdomain/contract/workflow"
|
crossworkflow "github.com/coze-dev/coze-studio/backend/crossdomain/contract/workflow"
|
||||||
"github.com/coze-dev/coze-studio/backend/domain/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"
|
||||||
|
|
@ -51,16 +51,6 @@ func (i *impl) WorkflowAsModelTool(ctx context.Context, policies []*vo.GetPolicy
|
||||||
return i.DomainSVC.WorkflowAsModelTool(ctx, policies)
|
return i.DomainSVC.WorkflowAsModelTool(ctx, policies)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i *impl) PublishWorkflow(ctx context.Context, info *vo.PublishPolicy) (err error) {
|
|
||||||
return i.DomainSVC.Publish(ctx, info)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (i *impl) DeleteWorkflow(ctx context.Context, id int64) error {
|
|
||||||
return i.DomainSVC.Delete(ctx, &vo.DeletePolicy{
|
|
||||||
ID: ptr.Of(id),
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
func (i *impl) ReleaseApplicationWorkflows(ctx context.Context, appID int64, config *vo.ReleaseWorkflowConfig) ([]*vo.ValidateIssue, error) {
|
func (i *impl) ReleaseApplicationWorkflows(ctx context.Context, appID int64, config *vo.ReleaseWorkflowConfig) ([]*vo.ValidateIssue, error) {
|
||||||
return i.DomainSVC.ReleaseApplicationWorkflows(ctx, appID, config)
|
return i.DomainSVC.ReleaseApplicationWorkflows(ctx, appID, config)
|
||||||
}
|
}
|
||||||
|
|
@ -68,11 +58,11 @@ func (i *impl) ReleaseApplicationWorkflows(ctx context.Context, appID int64, con
|
||||||
func (i *impl) WithResumeToolWorkflow(resumingEvent *workflowEntity.ToolInterruptEvent, resumeData string, allInterruptEvents map[string]*workflowEntity.ToolInterruptEvent) einoCompose.Option {
|
func (i *impl) WithResumeToolWorkflow(resumingEvent *workflowEntity.ToolInterruptEvent, resumeData string, allInterruptEvents map[string]*workflowEntity.ToolInterruptEvent) einoCompose.Option {
|
||||||
return i.DomainSVC.WithResumeToolWorkflow(resumingEvent, resumeData, allInterruptEvents)
|
return i.DomainSVC.WithResumeToolWorkflow(resumingEvent, resumeData, allInterruptEvents)
|
||||||
}
|
}
|
||||||
func (i *impl) SyncExecuteWorkflow(ctx context.Context, config model.ExecuteConfig, input map[string]any) (*workflowEntity.WorkflowExecution, vo.TerminatePlan, error) {
|
func (i *impl) SyncExecuteWorkflow(ctx context.Context, config workflowModel.ExecuteConfig, input map[string]any) (*workflowEntity.WorkflowExecution, vo.TerminatePlan, error) {
|
||||||
return i.DomainSVC.SyncExecute(ctx, config, input)
|
return i.DomainSVC.SyncExecute(ctx, config, input)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i *impl) WithExecuteConfig(cfg model.ExecuteConfig) einoCompose.Option {
|
func (i *impl) WithExecuteConfig(cfg workflowModel.ExecuteConfig) einoCompose.Option {
|
||||||
return i.DomainSVC.WithExecuteConfig(cfg)
|
return i.DomainSVC.WithExecuteConfig(cfg)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,74 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright 2025 coze-dev Authors
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package search
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
|
|
||||||
"github.com/coze-dev/coze-studio/backend/api/model/resource/common"
|
|
||||||
"github.com/coze-dev/coze-studio/backend/domain/search/entity"
|
|
||||||
search "github.com/coze-dev/coze-studio/backend/domain/search/service"
|
|
||||||
crosssearch "github.com/coze-dev/coze-studio/backend/domain/workflow/crossdomain/search"
|
|
||||||
"github.com/coze-dev/coze-studio/backend/pkg/lang/ptr"
|
|
||||||
)
|
|
||||||
|
|
||||||
type Notifier interface {
|
|
||||||
PublishWorkflowResource(ctx context.Context, OpType crosssearch.OpType, event *crosssearch.Resource) error
|
|
||||||
}
|
|
||||||
|
|
||||||
type Notify struct {
|
|
||||||
client search.ResourceEventBus
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewNotify(client search.ResourceEventBus) *Notify {
|
|
||||||
return &Notify{client: client}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (n *Notify) PublishWorkflowResource(ctx context.Context, op crosssearch.OpType, r *crosssearch.Resource) error {
|
|
||||||
entityResource := &entity.ResourceDocument{
|
|
||||||
ResType: common.ResType_Workflow,
|
|
||||||
ResID: r.WorkflowID,
|
|
||||||
ResSubType: r.Mode,
|
|
||||||
Name: r.Name,
|
|
||||||
SpaceID: r.SpaceID,
|
|
||||||
OwnerID: r.OwnerID,
|
|
||||||
APPID: r.APPID,
|
|
||||||
}
|
|
||||||
if r.PublishStatus != nil {
|
|
||||||
publishStatus := *r.PublishStatus
|
|
||||||
entityResource.PublishStatus = ptr.Of(common.PublishStatus(publishStatus))
|
|
||||||
entityResource.PublishTimeMS = r.PublishedAt
|
|
||||||
}
|
|
||||||
|
|
||||||
resource := &entity.ResourceDomainEvent{
|
|
||||||
OpType: entity.OpType(op),
|
|
||||||
Resource: entityResource,
|
|
||||||
}
|
|
||||||
if op == crosssearch.Created {
|
|
||||||
resource.Resource.CreateTimeMS = r.CreatedAt
|
|
||||||
resource.Resource.UpdateTimeMS = r.UpdatedAt
|
|
||||||
} else if op == crosssearch.Updated {
|
|
||||||
resource.Resource.UpdateTimeMS = r.UpdatedAt
|
|
||||||
}
|
|
||||||
|
|
||||||
err := n.client.PublishResources(ctx, resource)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
@ -26,6 +26,7 @@ import (
|
||||||
|
|
||||||
"github.com/coze-dev/coze-studio/backend/api/model/crossdomain/agentrun"
|
"github.com/coze-dev/coze-studio/backend/api/model/crossdomain/agentrun"
|
||||||
"github.com/coze-dev/coze-studio/backend/api/model/crossdomain/plugin"
|
"github.com/coze-dev/coze-studio/backend/api/model/crossdomain/plugin"
|
||||||
|
workflowModel "github.com/coze-dev/coze-studio/backend/api/model/crossdomain/workflow"
|
||||||
crossplugin "github.com/coze-dev/coze-studio/backend/crossdomain/contract/plugin"
|
crossplugin "github.com/coze-dev/coze-studio/backend/crossdomain/contract/plugin"
|
||||||
crossworkflow "github.com/coze-dev/coze-studio/backend/crossdomain/contract/workflow"
|
crossworkflow "github.com/coze-dev/coze-studio/backend/crossdomain/contract/workflow"
|
||||||
pluginEntity "github.com/coze-dev/coze-studio/backend/domain/plugin/entity"
|
pluginEntity "github.com/coze-dev/coze-studio/backend/domain/plugin/entity"
|
||||||
|
|
@ -88,7 +89,7 @@ func (pr *toolPreCallConf) toolPreRetrieve(ctx context.Context, ar *AgentRequest
|
||||||
logs.CtxErrorf(ctx, "Failed to unmarshal json arguments: %s", item.Arguments)
|
logs.CtxErrorf(ctx, "Failed to unmarshal json arguments: %s", item.Arguments)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
execResp, _, err := crossworkflow.DefaultSVC().SyncExecuteWorkflow(ctx, plugin.ExecuteConfig{
|
execResp, _, err := crossworkflow.DefaultSVC().SyncExecuteWorkflow(ctx, workflowModel.ExecuteConfig{
|
||||||
ID: item.PluginID,
|
ID: item.PluginID,
|
||||||
ConnectorID: ar.Identity.ConnectorID,
|
ConnectorID: ar.Identity.ConnectorID,
|
||||||
ConnectorUID: ar.UserID,
|
ConnectorUID: ar.UserID,
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/coze-dev/coze-studio/backend/api/model/app/bot_common"
|
"github.com/coze-dev/coze-studio/backend/api/model/app/bot_common"
|
||||||
"github.com/coze-dev/coze-studio/backend/api/model/crossdomain/plugin"
|
workflowModel "github.com/coze-dev/coze-studio/backend/api/model/crossdomain/workflow"
|
||||||
crossworkflow "github.com/coze-dev/coze-studio/backend/crossdomain/contract/workflow"
|
crossworkflow "github.com/coze-dev/coze-studio/backend/crossdomain/contract/workflow"
|
||||||
"github.com/coze-dev/coze-studio/backend/domain/workflow"
|
"github.com/coze-dev/coze-studio/backend/domain/workflow"
|
||||||
"github.com/coze-dev/coze-studio/backend/domain/workflow/entity/vo"
|
"github.com/coze-dev/coze-studio/backend/domain/workflow/entity/vo"
|
||||||
|
|
@ -37,7 +37,7 @@ func newWorkflowTools(ctx context.Context, conf *workflowConfig) ([]workflow.Too
|
||||||
id := info.GetWorkflowId()
|
id := info.GetWorkflowId()
|
||||||
policies = append(policies, &vo.GetPolicy{
|
policies = append(policies, &vo.GetPolicy{
|
||||||
ID: id,
|
ID: id,
|
||||||
QType: plugin.FromLatestVersion,
|
QType: workflowModel.FromLatestVersion,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -23,18 +23,18 @@ import (
|
||||||
"github.com/cloudwego/eino/compose"
|
"github.com/cloudwego/eino/compose"
|
||||||
"github.com/cloudwego/eino/schema"
|
"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"
|
"github.com/coze-dev/coze-studio/backend/domain/workflow/entity"
|
||||||
"github.com/coze-dev/coze-studio/backend/domain/workflow/entity/vo"
|
"github.com/coze-dev/coze-studio/backend/domain/workflow/entity/vo"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Executable interface {
|
type Executable interface {
|
||||||
SyncExecute(ctx context.Context, config plugin.ExecuteConfig, input map[string]any) (*entity.WorkflowExecution, vo.TerminatePlan, error)
|
SyncExecute(ctx context.Context, config workflowModel.ExecuteConfig, input map[string]any) (*entity.WorkflowExecution, vo.TerminatePlan, error)
|
||||||
AsyncExecute(ctx context.Context, config plugin.ExecuteConfig, input map[string]any) (int64, error)
|
AsyncExecute(ctx context.Context, config workflowModel.ExecuteConfig, input map[string]any) (int64, error)
|
||||||
AsyncExecuteNode(ctx context.Context, nodeID string, config plugin.ExecuteConfig, input map[string]any) (int64, error)
|
AsyncExecuteNode(ctx context.Context, nodeID string, config workflowModel.ExecuteConfig, input map[string]any) (int64, error)
|
||||||
AsyncResume(ctx context.Context, req *entity.ResumeRequest, config plugin.ExecuteConfig) error
|
AsyncResume(ctx context.Context, req *entity.ResumeRequest, config workflowModel.ExecuteConfig) error
|
||||||
StreamExecute(ctx context.Context, config plugin.ExecuteConfig, input map[string]any) (*schema.StreamReader[*entity.Message], error)
|
StreamExecute(ctx context.Context, config workflowModel.ExecuteConfig, input map[string]any) (*schema.StreamReader[*entity.Message], error)
|
||||||
StreamResume(ctx context.Context, req *entity.ResumeRequest, config plugin.ExecuteConfig) (
|
StreamResume(ctx context.Context, req *entity.ResumeRequest, config workflowModel.ExecuteConfig) (
|
||||||
*schema.StreamReader[*entity.Message], error)
|
*schema.StreamReader[*entity.Message], error)
|
||||||
|
|
||||||
GetExecution(ctx context.Context, wfExe *entity.WorkflowExecution, includeNodes bool) (*entity.WorkflowExecution, error)
|
GetExecution(ctx context.Context, wfExe *entity.WorkflowExecution, includeNodes bool) (*entity.WorkflowExecution, error)
|
||||||
|
|
@ -49,7 +49,7 @@ type Executable interface {
|
||||||
type AsTool interface {
|
type AsTool interface {
|
||||||
WorkflowAsModelTool(ctx context.Context, policies []*vo.GetPolicy) ([]ToolFromWorkflow, error)
|
WorkflowAsModelTool(ctx context.Context, policies []*vo.GetPolicy) ([]ToolFromWorkflow, error)
|
||||||
WithMessagePipe() (compose.Option, *schema.StreamReader[*entity.Message])
|
WithMessagePipe() (compose.Option, *schema.StreamReader[*entity.Message])
|
||||||
WithExecuteConfig(cfg plugin.ExecuteConfig) compose.Option
|
WithExecuteConfig(cfg workflowModel.ExecuteConfig) compose.Option
|
||||||
WithResumeToolWorkflow(resumingEvent *entity.ToolInterruptEvent, resumeData string,
|
WithResumeToolWorkflow(resumingEvent *entity.ToolInterruptEvent, resumeData string,
|
||||||
allInterruptEvents map[string]*entity.ToolInterruptEvent) compose.Option
|
allInterruptEvents map[string]*entity.ToolInterruptEvent) compose.Option
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,66 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright 2025 coze-dev Authors
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package search
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
)
|
|
||||||
|
|
||||||
type OpType string
|
|
||||||
|
|
||||||
const (
|
|
||||||
Created OpType = "created"
|
|
||||||
Updated OpType = "updated"
|
|
||||||
Deleted OpType = "deleted"
|
|
||||||
)
|
|
||||||
|
|
||||||
type PublishStatus int64
|
|
||||||
|
|
||||||
const (
|
|
||||||
UnPublished PublishStatus = 1
|
|
||||||
Published PublishStatus = 2
|
|
||||||
)
|
|
||||||
|
|
||||||
type Resource struct {
|
|
||||||
WorkflowID int64
|
|
||||||
Name *string
|
|
||||||
URI *string
|
|
||||||
Desc *string
|
|
||||||
APPID *int64
|
|
||||||
SpaceID *int64
|
|
||||||
OwnerID *int64
|
|
||||||
PublishStatus *PublishStatus
|
|
||||||
Mode *int32 // 0 workflow 3 chat_workflow
|
|
||||||
CreatedAt *int64
|
|
||||||
UpdatedAt *int64
|
|
||||||
PublishedAt *int64
|
|
||||||
}
|
|
||||||
|
|
||||||
func SetNotifier(n Notifier) {
|
|
||||||
notifierImpl = n
|
|
||||||
}
|
|
||||||
|
|
||||||
func GetNotifier() Notifier {
|
|
||||||
return notifierImpl
|
|
||||||
}
|
|
||||||
|
|
||||||
var notifierImpl Notifier
|
|
||||||
|
|
||||||
//go:generate mockgen -destination searchmock/search_mock.go --package searchmock -source search.go
|
|
||||||
type Notifier interface {
|
|
||||||
PublishWorkflowResource(ctx context.Context, OpType OpType, event *Resource) error
|
|
||||||
}
|
|
||||||
|
|
@ -1,72 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright 2025 coze-dev Authors
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Code generated by MockGen. DO NOT EDIT.
|
|
||||||
// Source: search.go
|
|
||||||
//
|
|
||||||
// Generated by this command:
|
|
||||||
//
|
|
||||||
// mockgen -destination searchmock/search_mock.go --package searchmock -source search.go
|
|
||||||
//
|
|
||||||
|
|
||||||
// Package searchmock is a generated GoMock package.
|
|
||||||
package searchmock
|
|
||||||
|
|
||||||
import (
|
|
||||||
context "context"
|
|
||||||
reflect "reflect"
|
|
||||||
|
|
||||||
search "github.com/coze-dev/coze-studio/backend/domain/workflow/crossdomain/search"
|
|
||||||
gomock "go.uber.org/mock/gomock"
|
|
||||||
)
|
|
||||||
|
|
||||||
// MockNotifier is a mock of Notifier interface.
|
|
||||||
type MockNotifier struct {
|
|
||||||
ctrl *gomock.Controller
|
|
||||||
recorder *MockNotifierMockRecorder
|
|
||||||
isgomock struct{}
|
|
||||||
}
|
|
||||||
|
|
||||||
// MockNotifierMockRecorder is the mock recorder for MockNotifier.
|
|
||||||
type MockNotifierMockRecorder struct {
|
|
||||||
mock *MockNotifier
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewMockNotifier creates a new mock instance.
|
|
||||||
func NewMockNotifier(ctrl *gomock.Controller) *MockNotifier {
|
|
||||||
mock := &MockNotifier{ctrl: ctrl}
|
|
||||||
mock.recorder = &MockNotifierMockRecorder{mock}
|
|
||||||
return mock
|
|
||||||
}
|
|
||||||
|
|
||||||
// EXPECT returns an object that allows the caller to indicate expected use.
|
|
||||||
func (m *MockNotifier) EXPECT() *MockNotifierMockRecorder {
|
|
||||||
return m.recorder
|
|
||||||
}
|
|
||||||
|
|
||||||
// PublishWorkflowResource mocks base method.
|
|
||||||
func (m *MockNotifier) PublishWorkflowResource(ctx context.Context, OpType search.OpType, event *search.Resource) error {
|
|
||||||
m.ctrl.T.Helper()
|
|
||||||
ret := m.ctrl.Call(m, "PublishWorkflowResource", ctx, OpType, event)
|
|
||||||
ret0, _ := ret[0].(error)
|
|
||||||
return ret0
|
|
||||||
}
|
|
||||||
|
|
||||||
// PublishWorkflowResource indicates an expected call of PublishWorkflowResource.
|
|
||||||
func (mr *MockNotifierMockRecorder) PublishWorkflowResource(ctx, OpType, event any) *gomock.Call {
|
|
||||||
mr.mock.ctrl.T.Helper()
|
|
||||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PublishWorkflowResource", reflect.TypeOf((*MockNotifier)(nil).PublishWorkflowResource), ctx, OpType, event)
|
|
||||||
}
|
|
||||||
|
|
@ -17,7 +17,7 @@
|
||||||
package vo
|
package vo
|
||||||
|
|
||||||
import (
|
import (
|
||||||
model "github.com/coze-dev/coze-studio/backend/api/model/crossdomain/plugin"
|
model "github.com/coze-dev/coze-studio/backend/api/model/crossdomain/workflow"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Page struct {
|
type Page struct {
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ import (
|
||||||
"github.com/cloudwego/eino/compose"
|
"github.com/cloudwego/eino/compose"
|
||||||
"github.com/cloudwego/eino/schema"
|
"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/pkg/errorx"
|
"github.com/coze-dev/coze-studio/backend/pkg/errorx"
|
||||||
"github.com/coze-dev/coze-studio/backend/pkg/sonic"
|
"github.com/coze-dev/coze-studio/backend/pkg/sonic"
|
||||||
"github.com/coze-dev/coze-studio/backend/types/errno"
|
"github.com/coze-dev/coze-studio/backend/types/errno"
|
||||||
|
|
@ -93,7 +93,7 @@ type wfErr struct {
|
||||||
|
|
||||||
func (w *wfErr) DebugURL() string {
|
func (w *wfErr) DebugURL() string {
|
||||||
if w.StatusError.Extra() == nil {
|
if w.StatusError.Extra() == nil {
|
||||||
return fmt.Sprintf(plugin.DebugURLTpl, w.exeID, w.spaceID, w.workflowID)
|
return fmt.Sprintf(workflowModel.DebugURLTpl, w.exeID, w.spaceID, w.workflowID)
|
||||||
}
|
}
|
||||||
|
|
||||||
debugURL, ok := w.StatusError.Extra()["debug_url"]
|
debugURL, ok := w.StatusError.Extra()["debug_url"]
|
||||||
|
|
@ -101,7 +101,7 @@ func (w *wfErr) DebugURL() string {
|
||||||
return debugURL
|
return debugURL
|
||||||
}
|
}
|
||||||
|
|
||||||
return fmt.Sprintf(plugin.DebugURLTpl, w.exeID, w.spaceID, w.workflowID)
|
return fmt.Sprintf(workflowModel.DebugURLTpl, w.exeID, w.spaceID, w.workflowID)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *wfErr) Level() ErrorLevel {
|
func (w *wfErr) Level() ErrorLevel {
|
||||||
|
|
@ -170,7 +170,7 @@ func WrapError(code int, err error, opts ...errorx.Option) WorkflowError {
|
||||||
}
|
}
|
||||||
|
|
||||||
func WrapWithDebug(code int, err error, exeID, spaceID, workflowID int64, opts ...errorx.Option) WorkflowError {
|
func WrapWithDebug(code int, err error, exeID, spaceID, workflowID int64, opts ...errorx.Option) WorkflowError {
|
||||||
debugURL := fmt.Sprintf(plugin.DebugURLTpl, exeID, spaceID, workflowID)
|
debugURL := fmt.Sprintf(workflowModel.DebugURLTpl, exeID, spaceID, workflowID)
|
||||||
opts = append(opts, errorx.Extra("debug_url", debugURL))
|
opts = append(opts, errorx.Extra("debug_url", debugURL))
|
||||||
return WrapError(code, err, opts...)
|
return WrapError(code, err, opts...)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,42 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2025 coze-dev Authors
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package vo
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/coze-dev/coze-studio/backend/api/model/crossdomain/plugin"
|
||||||
|
)
|
||||||
|
|
||||||
|
type ExternalResourceRelated struct {
|
||||||
|
PluginMap map[int64]*plugin.PluginEntity
|
||||||
|
PluginToolMap map[int64]int64
|
||||||
|
|
||||||
|
KnowledgeMap map[int64]int64
|
||||||
|
DatabaseMap map[int64]int64
|
||||||
|
}
|
||||||
|
|
||||||
|
type CopyWorkflowPolicy struct {
|
||||||
|
TargetSpaceID *int64
|
||||||
|
TargetAppID *int64
|
||||||
|
ModifiedCanvasSchema *string
|
||||||
|
ShouldModifyWorkflowName bool
|
||||||
|
}
|
||||||
|
|
||||||
|
type DependenceResource struct {
|
||||||
|
PluginIDs []int64
|
||||||
|
KnowledgeIDs []int64
|
||||||
|
DatabaseIDs []int64
|
||||||
|
}
|
||||||
|
|
@ -76,3 +76,9 @@ type WorkflowBasic struct {
|
||||||
AppID *int64
|
AppID *int64
|
||||||
CommitID string
|
CommitID string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type CopyWorkflowFromAppToLibraryResult struct {
|
||||||
|
WorkflowIDVersionMap map[int64]IDVersionPair
|
||||||
|
ValidateIssues []*vo.ValidateIssue
|
||||||
|
CopiedWorkflows []*Workflow
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ package entity
|
||||||
import (
|
import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
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/api/model/workflow"
|
"github.com/coze-dev/coze-studio/backend/api/model/workflow"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -31,7 +31,7 @@ type WorkflowExecution struct {
|
||||||
WorkflowID int64
|
WorkflowID int64
|
||||||
Version string
|
Version string
|
||||||
SpaceID int64
|
SpaceID int64
|
||||||
model.ExecuteConfig
|
workflowModel.ExecuteConfig
|
||||||
CreatedAt time.Time
|
CreatedAt time.Time
|
||||||
LogID string
|
LogID string
|
||||||
NodeCount int32
|
NodeCount int32
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,6 @@ import (
|
||||||
"github.com/cloudwego/eino/components/model"
|
"github.com/cloudwego/eino/components/model"
|
||||||
"github.com/cloudwego/eino/compose"
|
"github.com/cloudwego/eino/compose"
|
||||||
|
|
||||||
"github.com/coze-dev/coze-studio/backend/api/model/crossdomain/plugin"
|
|
||||||
"github.com/coze-dev/coze-studio/backend/api/model/workflow"
|
"github.com/coze-dev/coze-studio/backend/api/model/workflow"
|
||||||
"github.com/coze-dev/coze-studio/backend/domain/workflow/entity"
|
"github.com/coze-dev/coze-studio/backend/domain/workflow/entity"
|
||||||
"github.com/coze-dev/coze-studio/backend/domain/workflow/entity/vo"
|
"github.com/coze-dev/coze-studio/backend/domain/workflow/entity/vo"
|
||||||
|
|
@ -36,10 +35,10 @@ type Service interface {
|
||||||
Save(ctx context.Context, id int64, schema string) error
|
Save(ctx context.Context, id int64, schema string) error
|
||||||
Get(ctx context.Context, policy *vo.GetPolicy) (*entity.Workflow, error)
|
Get(ctx context.Context, policy *vo.GetPolicy) (*entity.Workflow, error)
|
||||||
MGet(ctx context.Context, policy *vo.MGetPolicy) ([]*entity.Workflow, int64, error)
|
MGet(ctx context.Context, policy *vo.MGetPolicy) ([]*entity.Workflow, int64, error)
|
||||||
Delete(ctx context.Context, policy *vo.DeletePolicy) (err error)
|
Delete(ctx context.Context, policy *vo.DeletePolicy) (ids []int64, err error)
|
||||||
Publish(ctx context.Context, policy *vo.PublishPolicy) (err error)
|
Publish(ctx context.Context, policy *vo.PublishPolicy) (err error)
|
||||||
UpdateMeta(ctx context.Context, id int64, metaUpdate *vo.MetaUpdate) (err error)
|
UpdateMeta(ctx context.Context, id int64, metaUpdate *vo.MetaUpdate) (err error)
|
||||||
CopyWorkflow(ctx context.Context, workflowID int64, policy plugin.CopyWorkflowPolicy) (*entity.Workflow, error)
|
CopyWorkflow(ctx context.Context, workflowID int64, policy vo.CopyWorkflowPolicy) (*entity.Workflow, error)
|
||||||
|
|
||||||
QueryNodeProperties(ctx context.Context, id int64) (map[string]*vo.NodeProperty, error) // only draft
|
QueryNodeProperties(ctx context.Context, id int64) (map[string]*vo.NodeProperty, error) // only draft
|
||||||
ValidateTree(ctx context.Context, id int64, validateConfig vo.ValidateTreeConfig) ([]*workflow.ValidateTreeInfo, error)
|
ValidateTree(ctx context.Context, id int64, validateConfig vo.ValidateTreeConfig) ([]*workflow.ValidateTreeInfo, error)
|
||||||
|
|
@ -50,10 +49,10 @@ type Service interface {
|
||||||
AsTool
|
AsTool
|
||||||
|
|
||||||
ReleaseApplicationWorkflows(ctx context.Context, appID int64, config *vo.ReleaseWorkflowConfig) ([]*vo.ValidateIssue, error)
|
ReleaseApplicationWorkflows(ctx context.Context, appID int64, config *vo.ReleaseWorkflowConfig) ([]*vo.ValidateIssue, error)
|
||||||
CopyWorkflowFromAppToLibrary(ctx context.Context, workflowID int64, appID int64, related plugin.ExternalResourceRelated) (map[int64]entity.IDVersionPair, []*vo.ValidateIssue, error)
|
CopyWorkflowFromAppToLibrary(ctx context.Context, workflowID int64, appID int64, related vo.ExternalResourceRelated) (*entity.CopyWorkflowFromAppToLibraryResult, error)
|
||||||
DuplicateWorkflowsByAppID(ctx context.Context, sourceAPPID, targetAppID int64, related plugin.ExternalResourceRelated) error
|
DuplicateWorkflowsByAppID(ctx context.Context, sourceAPPID, targetAppID int64, related vo.ExternalResourceRelated) ([]*entity.Workflow, error)
|
||||||
GetWorkflowDependenceResource(ctx context.Context, workflowID int64) (*plugin.DependenceResource, error)
|
GetWorkflowDependenceResource(ctx context.Context, workflowID int64) (*vo.DependenceResource, error)
|
||||||
SyncRelatedWorkflowResources(ctx context.Context, appID int64, relatedWorkflows map[int64]entity.IDVersionPair, related plugin.ExternalResourceRelated) error
|
SyncRelatedWorkflowResources(ctx context.Context, appID int64, relatedWorkflows map[int64]entity.IDVersionPair, related vo.ExternalResourceRelated) error
|
||||||
}
|
}
|
||||||
|
|
||||||
type Repository interface {
|
type Repository interface {
|
||||||
|
|
@ -88,7 +87,7 @@ type Repository interface {
|
||||||
|
|
||||||
WorkflowAsTool(ctx context.Context, policy vo.GetPolicy, wfToolConfig vo.WorkflowToolConfig) (ToolFromWorkflow, error)
|
WorkflowAsTool(ctx context.Context, policy vo.GetPolicy, wfToolConfig vo.WorkflowToolConfig) (ToolFromWorkflow, error)
|
||||||
|
|
||||||
CopyWorkflow(ctx context.Context, workflowID int64, policy plugin.CopyWorkflowPolicy) (*entity.Workflow, error)
|
CopyWorkflow(ctx context.Context, workflowID int64, policy vo.CopyWorkflowPolicy) (*entity.Workflow, error)
|
||||||
|
|
||||||
GetDraftWorkflowsByAppID(ctx context.Context, AppID int64) (map[int64]*vo.DraftInfo, map[int64]string, error)
|
GetDraftWorkflowsByAppID(ctx context.Context, AppID int64) (map[int64]*vo.DraftInfo, map[int64]string, error)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ import (
|
||||||
|
|
||||||
crossmodel "github.com/coze-dev/coze-studio/backend/api/model/crossdomain/database"
|
crossmodel "github.com/coze-dev/coze-studio/backend/api/model/crossdomain/database"
|
||||||
"github.com/coze-dev/coze-studio/backend/api/model/crossdomain/knowledge"
|
"github.com/coze-dev/coze-studio/backend/api/model/crossdomain/knowledge"
|
||||||
"github.com/coze-dev/coze-studio/backend/api/model/crossdomain/plugin"
|
workflowModel "github.com/coze-dev/coze-studio/backend/api/model/crossdomain/workflow"
|
||||||
crossdatabase "github.com/coze-dev/coze-studio/backend/crossdomain/contract/database"
|
crossdatabase "github.com/coze-dev/coze-studio/backend/crossdomain/contract/database"
|
||||||
"github.com/coze-dev/coze-studio/backend/crossdomain/contract/database/databasemock"
|
"github.com/coze-dev/coze-studio/backend/crossdomain/contract/database/databasemock"
|
||||||
crossknowledge "github.com/coze-dev/coze-studio/backend/crossdomain/contract/knowledge"
|
crossknowledge "github.com/coze-dev/coze-studio/backend/crossdomain/contract/knowledge"
|
||||||
|
|
@ -77,10 +77,10 @@ func TestIntentDetectorAndDatabase(t *testing.T) {
|
||||||
|
|
||||||
mockey.Mock(execute.GetExeCtx).Return(&execute.Context{
|
mockey.Mock(execute.GetExeCtx).Return(&execute.Context{
|
||||||
RootCtx: execute.RootCtx{
|
RootCtx: execute.RootCtx{
|
||||||
ExeCfg: plugin.ExecuteConfig{
|
ExeCfg: workflowModel.ExecuteConfig{
|
||||||
Mode: plugin.ExecuteModeDebug,
|
Mode: workflowModel.ExecuteModeDebug,
|
||||||
Operator: 123,
|
Operator: 123,
|
||||||
BizType: plugin.BizTypeWorkflow,
|
BizType: workflowModel.BizTypeWorkflow,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}).Build()
|
}).Build()
|
||||||
|
|
@ -237,10 +237,10 @@ func TestDatabaseCURD(t *testing.T) {
|
||||||
|
|
||||||
mockey.Mock(execute.GetExeCtx).Return(&execute.Context{
|
mockey.Mock(execute.GetExeCtx).Return(&execute.Context{
|
||||||
RootCtx: execute.RootCtx{
|
RootCtx: execute.RootCtx{
|
||||||
ExeCfg: plugin.ExecuteConfig{
|
ExeCfg: workflowModel.ExecuteConfig{
|
||||||
Mode: plugin.ExecuteModeDebug,
|
Mode: workflowModel.ExecuteModeDebug,
|
||||||
Operator: 123,
|
Operator: 123,
|
||||||
BizType: plugin.BizTypeWorkflow,
|
BizType: workflowModel.BizTypeWorkflow,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}).Build()
|
}).Build()
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ import (
|
||||||
|
|
||||||
einoCompose "github.com/cloudwego/eino/compose"
|
einoCompose "github.com/cloudwego/eino/compose"
|
||||||
|
|
||||||
model "github.com/coze-dev/coze-studio/backend/api/model/crossdomain/plugin"
|
model "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"
|
||||||
"github.com/coze-dev/coze-studio/backend/domain/workflow/entity"
|
"github.com/coze-dev/coze-studio/backend/domain/workflow/entity"
|
||||||
"github.com/coze-dev/coze-studio/backend/domain/workflow/entity/vo"
|
"github.com/coze-dev/coze-studio/backend/domain/workflow/entity/vo"
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,8 @@ import (
|
||||||
einoCompose "github.com/cloudwego/eino/compose"
|
einoCompose "github.com/cloudwego/eino/compose"
|
||||||
"github.com/cloudwego/eino/schema"
|
"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/plugin"
|
||||||
|
model "github.com/coze-dev/coze-studio/backend/api/model/crossdomain/workflow"
|
||||||
crossplugin "github.com/coze-dev/coze-studio/backend/crossdomain/contract/plugin"
|
crossplugin "github.com/coze-dev/coze-studio/backend/crossdomain/contract/plugin"
|
||||||
workflow2 "github.com/coze-dev/coze-studio/backend/domain/workflow"
|
workflow2 "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"
|
||||||
|
|
@ -291,8 +292,8 @@ func llmToolCallbackOptions(ctx context.Context, ns *schema2.NodeSchema, eventCh
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
toolInfoResponse, err := crossplugin.DefaultSVC().GetPluginToolsInfo(ctx, &model.ToolsInfoRequest{
|
toolInfoResponse, err := crossplugin.DefaultSVC().GetPluginToolsInfo(ctx, &plugin.ToolsInfoRequest{
|
||||||
PluginEntity: model.PluginEntity{
|
PluginEntity: plugin.PluginEntity{
|
||||||
PluginID: pluginID,
|
PluginID: pluginID,
|
||||||
PluginVersion: ptr.Of(p.PluginVersion),
|
PluginVersion: ptr.Of(p.PluginVersion),
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ import (
|
||||||
"github.com/cloudwego/eino/compose"
|
"github.com/cloudwego/eino/compose"
|
||||||
"github.com/cloudwego/eino/schema"
|
"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"
|
||||||
workflow2 "github.com/coze-dev/coze-studio/backend/api/model/workflow"
|
workflow2 "github.com/coze-dev/coze-studio/backend/api/model/workflow"
|
||||||
"github.com/coze-dev/coze-studio/backend/domain/workflow/crossdomain/variable"
|
"github.com/coze-dev/coze-studio/backend/domain/workflow/crossdomain/variable"
|
||||||
"github.com/coze-dev/coze-studio/backend/domain/workflow/entity"
|
"github.com/coze-dev/coze-studio/backend/domain/workflow/entity"
|
||||||
|
|
@ -80,12 +80,12 @@ func init() {
|
||||||
_ = compose.RegisterSerializableType[*entity.WorkflowBasic]("workflow_basic")
|
_ = compose.RegisterSerializableType[*entity.WorkflowBasic]("workflow_basic")
|
||||||
_ = compose.RegisterSerializableType[vo.TerminatePlan]("terminate_plan")
|
_ = compose.RegisterSerializableType[vo.TerminatePlan]("terminate_plan")
|
||||||
_ = compose.RegisterSerializableType[*entity.ToolInterruptEvent]("tool_interrupt_event")
|
_ = compose.RegisterSerializableType[*entity.ToolInterruptEvent]("tool_interrupt_event")
|
||||||
_ = compose.RegisterSerializableType[plugin.ExecuteConfig]("execute_config")
|
_ = compose.RegisterSerializableType[workflowModel.ExecuteConfig]("execute_config")
|
||||||
_ = compose.RegisterSerializableType[plugin.ExecuteMode]("execute_mode")
|
_ = compose.RegisterSerializableType[workflowModel.ExecuteMode]("execute_mode")
|
||||||
_ = compose.RegisterSerializableType[plugin.TaskType]("task_type")
|
_ = compose.RegisterSerializableType[workflowModel.TaskType]("task_type")
|
||||||
_ = compose.RegisterSerializableType[plugin.SyncPattern]("sync_pattern")
|
_ = compose.RegisterSerializableType[workflowModel.SyncPattern]("sync_pattern")
|
||||||
_ = compose.RegisterSerializableType[plugin.Locator]("wf_locator")
|
_ = compose.RegisterSerializableType[workflowModel.Locator]("wf_locator")
|
||||||
_ = compose.RegisterSerializableType[plugin.BizType]("biz_type")
|
_ = compose.RegisterSerializableType[workflowModel.BizType]("biz_type")
|
||||||
_ = compose.RegisterSerializableType[*execute.AppVariables]("app_variables")
|
_ = compose.RegisterSerializableType[*execute.AppVariables]("app_variables")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -906,12 +906,12 @@ func streamStatePostHandlerForVars(s *schema2.NodeSchema) compose.StreamStatePos
|
||||||
func GenStateModifierByEventType(e entity.InterruptEventType,
|
func GenStateModifierByEventType(e entity.InterruptEventType,
|
||||||
nodeKey vo.NodeKey,
|
nodeKey vo.NodeKey,
|
||||||
resumeData string,
|
resumeData string,
|
||||||
exeCfg plugin.ExecuteConfig) (stateModifier compose.StateModifier) {
|
exeCfg workflowModel.ExecuteConfig) (stateModifier compose.StateModifier) {
|
||||||
// TODO: can we unify them all to a map[NodeKey]resumeData?
|
// TODO: can we unify them all to a map[NodeKey]resumeData?
|
||||||
switch e {
|
switch e {
|
||||||
case entity.InterruptEventInput:
|
case entity.InterruptEventInput:
|
||||||
stateModifier = func(ctx context.Context, path compose.NodePath, state any) (err error) {
|
stateModifier = func(ctx context.Context, path compose.NodePath, state any) (err error) {
|
||||||
if exeCfg.BizType == plugin.BizTypeAgent {
|
if exeCfg.BizType == workflowModel.BizTypeAgent {
|
||||||
m := make(map[string]any)
|
m := make(map[string]any)
|
||||||
sList := strings.Split(resumeData, "\n")
|
sList := strings.Split(resumeData, "\n")
|
||||||
for _, s := range sList {
|
for _, s := range sList {
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ import (
|
||||||
einoCompose "github.com/cloudwego/eino/compose"
|
einoCompose "github.com/cloudwego/eino/compose"
|
||||||
"github.com/cloudwego/eino/schema"
|
"github.com/cloudwego/eino/schema"
|
||||||
|
|
||||||
model "github.com/coze-dev/coze-studio/backend/api/model/crossdomain/plugin"
|
model "github.com/coze-dev/coze-studio/backend/api/model/crossdomain/workflow"
|
||||||
wf "github.com/coze-dev/coze-studio/backend/domain/workflow"
|
wf "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"
|
||||||
"github.com/coze-dev/coze-studio/backend/domain/workflow/entity/vo"
|
"github.com/coze-dev/coze-studio/backend/domain/workflow/entity/vo"
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ import (
|
||||||
"github.com/cloudwego/eino/schema"
|
"github.com/cloudwego/eino/schema"
|
||||||
callbacks2 "github.com/cloudwego/eino/utils/callbacks"
|
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"
|
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"
|
||||||
"github.com/coze-dev/coze-studio/backend/domain/workflow/entity"
|
"github.com/coze-dev/coze-studio/backend/domain/workflow/entity"
|
||||||
|
|
@ -65,7 +65,7 @@ type WorkflowHandler struct {
|
||||||
nodeCount int32
|
nodeCount int32
|
||||||
requireCheckpoint bool
|
requireCheckpoint bool
|
||||||
resumeEvent *entity.InterruptEvent
|
resumeEvent *entity.InterruptEvent
|
||||||
exeCfg plugin.ExecuteConfig
|
exeCfg workflowModel.ExecuteConfig
|
||||||
rootTokenCollector *TokenCollector
|
rootTokenCollector *TokenCollector
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -75,7 +75,7 @@ type ToolHandler struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewRootWorkflowHandler(wb *entity.WorkflowBasic, executeID int64, requireCheckpoint bool,
|
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 {
|
) callbacks.Handler {
|
||||||
return &WorkflowHandler{
|
return &WorkflowHandler{
|
||||||
ch: ch,
|
ch: ch,
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ import (
|
||||||
|
|
||||||
"github.com/cloudwego/eino/compose"
|
"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"
|
||||||
"github.com/coze-dev/coze-studio/backend/domain/workflow/entity"
|
"github.com/coze-dev/coze-studio/backend/domain/workflow/entity"
|
||||||
"github.com/coze-dev/coze-studio/backend/domain/workflow/entity/vo"
|
"github.com/coze-dev/coze-studio/backend/domain/workflow/entity/vo"
|
||||||
|
|
@ -59,7 +59,7 @@ type RootCtx struct {
|
||||||
RootWorkflowBasic *entity.WorkflowBasic
|
RootWorkflowBasic *entity.WorkflowBasic
|
||||||
RootExecuteID int64
|
RootExecuteID int64
|
||||||
ResumeEvent *entity.InterruptEvent
|
ResumeEvent *entity.InterruptEvent
|
||||||
ExeCfg plugin.ExecuteConfig
|
ExeCfg workflowModel.ExecuteConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
type SubWorkflowCtx struct {
|
type SubWorkflowCtx struct {
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ import (
|
||||||
"github.com/bytedance/sonic"
|
"github.com/bytedance/sonic"
|
||||||
"github.com/cloudwego/eino/schema"
|
"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"
|
||||||
"github.com/coze-dev/coze-studio/backend/domain/workflow/entity"
|
"github.com/coze-dev/coze-studio/backend/domain/workflow/entity"
|
||||||
"github.com/coze-dev/coze-studio/backend/domain/workflow/entity/vo"
|
"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
|
rootWkID := event.RootWorkflowBasic.ID
|
||||||
exeCfg := event.ExeCfg
|
exeCfg := event.ExeCfg
|
||||||
if exeCfg.Mode == plugin.ExecuteModeDebug {
|
if exeCfg.Mode == workflowModel.ExecuteModeDebug {
|
||||||
if err := repo.UpdateWorkflowDraftTestRunSuccess(ctx, rootWkID); err != nil {
|
if err := repo.UpdateWorkflowDraftTestRunSuccess(ctx, rootWkID); err != nil {
|
||||||
return fmt.Errorf("failed to save workflow draft test run success: %v", err)
|
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,
|
timeoutFn context.CancelFunc,
|
||||||
repo workflow.Repository,
|
repo workflow.Repository,
|
||||||
sw *schema.StreamWriter[*entity.Message],
|
sw *schema.StreamWriter[*entity.Message],
|
||||||
exeCfg plugin.ExecuteConfig,
|
exeCfg workflowModel.ExecuteConfig,
|
||||||
) (event *Event) {
|
) (event *Event) {
|
||||||
var (
|
var (
|
||||||
wfSuccessEvent *Event
|
wfSuccessEvent *Event
|
||||||
|
|
@ -761,7 +761,7 @@ func HandleExecuteEvent(ctx context.Context,
|
||||||
return event
|
return event
|
||||||
case workflowSuccess: // workflow success, wait for exit node to be done
|
case workflowSuccess: // workflow success, wait for exit node to be done
|
||||||
wfSuccessEvent = event
|
wfSuccessEvent = event
|
||||||
if lastNodeIsDone || exeCfg.Mode == plugin.ExecuteModeNodeDebug {
|
if lastNodeIsDone || exeCfg.Mode == workflowModel.ExecuteModeNodeDebug {
|
||||||
if err = setRootWorkflowSuccess(ctx, wfSuccessEvent, repo, sw); err != nil {
|
if err = setRootWorkflowSuccess(ctx, wfSuccessEvent, repo, sw); err != nil {
|
||||||
logs.CtxErrorf(ctx, "failed to set root workflow success for workflow %d: %v",
|
logs.CtxErrorf(ctx, "failed to set root workflow success for workflow %d: %v",
|
||||||
wfSuccessEvent.RootWorkflowBasic.ID, err)
|
wfSuccessEvent.RootWorkflowBasic.ID, err)
|
||||||
|
|
|
||||||
|
|
@ -21,14 +21,14 @@ import (
|
||||||
"github.com/cloudwego/eino/compose"
|
"github.com/cloudwego/eino/compose"
|
||||||
"github.com/cloudwego/eino/schema"
|
"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"
|
"github.com/coze-dev/coze-studio/backend/domain/workflow/entity"
|
||||||
)
|
)
|
||||||
|
|
||||||
type workflowToolOption struct {
|
type workflowToolOption struct {
|
||||||
resumeReq *entity.ResumeRequest
|
resumeReq *entity.ResumeRequest
|
||||||
sw *schema.StreamWriter[*entity.Message]
|
sw *schema.StreamWriter[*entity.Message]
|
||||||
exeCfg plugin.ExecuteConfig
|
exeCfg workflowModel.ExecuteConfig
|
||||||
allInterruptEvents map[string]*entity.ToolInterruptEvent
|
allInterruptEvents map[string]*entity.ToolInterruptEvent
|
||||||
parentTokenCollector *TokenCollector
|
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) {
|
return tool.WrapImplSpecificOptFn(func(opts *workflowToolOption) {
|
||||||
opts.exeCfg = cfg
|
opts.exeCfg = cfg
|
||||||
})
|
})
|
||||||
|
|
@ -62,7 +62,7 @@ func GetIntermediateStreamWriter(opts ...tool.Option) *schema.StreamWriter[*enti
|
||||||
return opt.sw
|
return opt.sw
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetExecuteConfig(opts ...tool.Option) plugin.ExecuteConfig {
|
func GetExecuteConfig(opts ...tool.Option) workflowModel.ExecuteConfig {
|
||||||
opt := tool.GetImplSpecificOptions(&workflowToolOption{}, opts...)
|
opt := tool.GetImplSpecificOptions(&workflowToolOption{}, opts...)
|
||||||
return opt.exeCfg
|
return opt.exeCfg
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ import (
|
||||||
"github.com/cloudwego/eino/compose"
|
"github.com/cloudwego/eino/compose"
|
||||||
|
|
||||||
"github.com/coze-dev/coze-studio/backend/api/model/crossdomain/database"
|
"github.com/coze-dev/coze-studio/backend/api/model/crossdomain/database"
|
||||||
"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/vo"
|
"github.com/coze-dev/coze-studio/backend/domain/workflow/entity/vo"
|
||||||
"github.com/coze-dev/coze-studio/backend/domain/workflow/internal/execute"
|
"github.com/coze-dev/coze-studio/backend/domain/workflow/internal/execute"
|
||||||
"github.com/coze-dev/coze-studio/backend/domain/workflow/internal/nodes"
|
"github.com/coze-dev/coze-studio/backend/domain/workflow/internal/nodes"
|
||||||
|
|
@ -413,7 +413,7 @@ func isDebugExecute(ctx context.Context) bool {
|
||||||
if execCtx == nil {
|
if execCtx == nil {
|
||||||
panic(fmt.Errorf("unable to get exe context"))
|
panic(fmt.Errorf("unable to get exe context"))
|
||||||
}
|
}
|
||||||
return execCtx.RootCtx.ExeCfg.Mode == plugin.ExecuteModeDebug || execCtx.RootCtx.ExeCfg.Mode == plugin.ExecuteModeNodeDebug
|
return execCtx.RootCtx.ExeCfg.Mode == workflowModel.ExecuteModeDebug || execCtx.RootCtx.ExeCfg.Mode == workflowModel.ExecuteModeNodeDebug
|
||||||
}
|
}
|
||||||
|
|
||||||
func getExecUserID(ctx context.Context) string {
|
func getExecUserID(ctx context.Context) string {
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ import (
|
||||||
"go.uber.org/mock/gomock"
|
"go.uber.org/mock/gomock"
|
||||||
|
|
||||||
"github.com/coze-dev/coze-studio/backend/api/model/crossdomain/database"
|
"github.com/coze-dev/coze-studio/backend/api/model/crossdomain/database"
|
||||||
"github.com/coze-dev/coze-studio/backend/api/model/crossdomain/plugin"
|
workflowModel "github.com/coze-dev/coze-studio/backend/api/model/crossdomain/workflow"
|
||||||
crossdatabase "github.com/coze-dev/coze-studio/backend/crossdomain/contract/database"
|
crossdatabase "github.com/coze-dev/coze-studio/backend/crossdomain/contract/database"
|
||||||
"github.com/coze-dev/coze-studio/backend/crossdomain/contract/database/databasemock"
|
"github.com/coze-dev/coze-studio/backend/crossdomain/contract/database/databasemock"
|
||||||
"github.com/coze-dev/coze-studio/backend/domain/workflow/entity/vo"
|
"github.com/coze-dev/coze-studio/backend/domain/workflow/entity/vo"
|
||||||
|
|
@ -72,10 +72,10 @@ func TestCustomSQL_Execute(t *testing.T) {
|
||||||
|
|
||||||
defer mockey.Mock(execute.GetExeCtx).Return(&execute.Context{
|
defer mockey.Mock(execute.GetExeCtx).Return(&execute.Context{
|
||||||
RootCtx: execute.RootCtx{
|
RootCtx: execute.RootCtx{
|
||||||
ExeCfg: plugin.ExecuteConfig{
|
ExeCfg: workflowModel.ExecuteConfig{
|
||||||
Mode: plugin.ExecuteModeDebug,
|
Mode: workflowModel.ExecuteModeDebug,
|
||||||
Operator: 123,
|
Operator: 123,
|
||||||
BizType: plugin.BizTypeWorkflow,
|
BizType: workflowModel.BizTypeWorkflow,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}).Build().UnPatch()
|
}).Build().UnPatch()
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ import (
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
|
|
||||||
"github.com/coze-dev/coze-studio/backend/api/model/crossdomain/database"
|
"github.com/coze-dev/coze-studio/backend/api/model/crossdomain/database"
|
||||||
"github.com/coze-dev/coze-studio/backend/api/model/crossdomain/plugin"
|
workflowModel "github.com/coze-dev/coze-studio/backend/api/model/crossdomain/workflow"
|
||||||
crossdatabase "github.com/coze-dev/coze-studio/backend/crossdomain/contract/database"
|
crossdatabase "github.com/coze-dev/coze-studio/backend/crossdomain/contract/database"
|
||||||
"github.com/coze-dev/coze-studio/backend/crossdomain/contract/database/databasemock"
|
"github.com/coze-dev/coze-studio/backend/crossdomain/contract/database/databasemock"
|
||||||
"github.com/coze-dev/coze-studio/backend/domain/workflow/entity/vo"
|
"github.com/coze-dev/coze-studio/backend/domain/workflow/entity/vo"
|
||||||
|
|
@ -57,10 +57,10 @@ func (m *mockDsSelect) Query() func(ctx context.Context, request *database.Query
|
||||||
func TestDataset_Query(t *testing.T) {
|
func TestDataset_Query(t *testing.T) {
|
||||||
defer mockey.Mock(execute.GetExeCtx).Return(&execute.Context{
|
defer mockey.Mock(execute.GetExeCtx).Return(&execute.Context{
|
||||||
RootCtx: execute.RootCtx{
|
RootCtx: execute.RootCtx{
|
||||||
ExeCfg: plugin.ExecuteConfig{
|
ExeCfg: workflowModel.ExecuteConfig{
|
||||||
Mode: plugin.ExecuteModeDebug,
|
Mode: workflowModel.ExecuteModeDebug,
|
||||||
Operator: 123,
|
Operator: 123,
|
||||||
BizType: plugin.BizTypeWorkflow,
|
BizType: workflowModel.BizTypeWorkflow,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}).Build().UnPatch()
|
}).Build().UnPatch()
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,7 @@ import (
|
||||||
"github.com/coze-dev/coze-studio/backend/api/model/crossdomain/knowledge"
|
"github.com/coze-dev/coze-studio/backend/api/model/crossdomain/knowledge"
|
||||||
crossmodel "github.com/coze-dev/coze-studio/backend/api/model/crossdomain/modelmgr"
|
crossmodel "github.com/coze-dev/coze-studio/backend/api/model/crossdomain/modelmgr"
|
||||||
"github.com/coze-dev/coze-studio/backend/api/model/crossdomain/plugin"
|
"github.com/coze-dev/coze-studio/backend/api/model/crossdomain/plugin"
|
||||||
|
workflowModel "github.com/coze-dev/coze-studio/backend/api/model/crossdomain/workflow"
|
||||||
workflow3 "github.com/coze-dev/coze-studio/backend/api/model/workflow"
|
workflow3 "github.com/coze-dev/coze-studio/backend/api/model/workflow"
|
||||||
crossknowledge "github.com/coze-dev/coze-studio/backend/crossdomain/contract/knowledge"
|
crossknowledge "github.com/coze-dev/coze-studio/backend/crossdomain/contract/knowledge"
|
||||||
crossmodelmgr "github.com/coze-dev/coze-studio/backend/crossdomain/contract/modelmgr"
|
crossmodelmgr "github.com/coze-dev/coze-studio/backend/crossdomain/contract/modelmgr"
|
||||||
|
|
@ -401,9 +402,9 @@ func (c *Config) Build(ctx context.Context, ns *schema2.NodeSchema, _ ...schema2
|
||||||
workflowToolConfig.OutputParametersConfig = wf.FCSetting.ResponseParameters
|
workflowToolConfig.OutputParametersConfig = wf.FCSetting.ResponseParameters
|
||||||
}
|
}
|
||||||
|
|
||||||
locator := plugin.FromDraft
|
locator := workflowModel.FromDraft
|
||||||
if wf.WorkflowVersion != "" {
|
if wf.WorkflowVersion != "" {
|
||||||
locator = plugin.FromSpecificVersion
|
locator = workflowModel.FromSpecificVersion
|
||||||
}
|
}
|
||||||
|
|
||||||
wfTool, err := workflow.GetRepository().WorkflowAsTool(ctx, vo.GetPolicy{
|
wfTool, err := workflow.GetRepository().WorkflowAsTool(ctx, vo.GetPolicy{
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,7 @@ import (
|
||||||
"github.com/cloudwego/eino/compose"
|
"github.com/cloudwego/eino/compose"
|
||||||
|
|
||||||
model "github.com/coze-dev/coze-studio/backend/api/model/crossdomain/plugin"
|
model "github.com/coze-dev/coze-studio/backend/api/model/crossdomain/plugin"
|
||||||
|
workflowModel "github.com/coze-dev/coze-studio/backend/api/model/crossdomain/workflow"
|
||||||
crossplugin "github.com/coze-dev/coze-studio/backend/crossdomain/contract/plugin"
|
crossplugin "github.com/coze-dev/coze-studio/backend/crossdomain/contract/plugin"
|
||||||
"github.com/coze-dev/coze-studio/backend/domain/workflow/entity"
|
"github.com/coze-dev/coze-studio/backend/domain/workflow/entity"
|
||||||
"github.com/coze-dev/coze-studio/backend/domain/workflow/entity/vo"
|
"github.com/coze-dev/coze-studio/backend/domain/workflow/entity/vo"
|
||||||
|
|
@ -111,7 +112,7 @@ type Plugin struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Plugin) Invoke(ctx context.Context, parameters map[string]any) (ret map[string]any, err error) {
|
func (p *Plugin) Invoke(ctx context.Context, parameters map[string]any) (ret map[string]any, err error) {
|
||||||
var exeCfg model.ExecuteConfig
|
var exeCfg workflowModel.ExecuteConfig
|
||||||
if ctxExeCfg := execute.GetExeCtx(ctx); ctxExeCfg != nil {
|
if ctxExeCfg := execute.GetExeCtx(ctx); ctxExeCfg != nil {
|
||||||
exeCfg = ctxExeCfg.ExeCfg
|
exeCfg = ctxExeCfg.ExeCfg
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ import (
|
||||||
|
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
|
|
||||||
"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"
|
"github.com/coze-dev/coze-studio/backend/domain/workflow/entity"
|
||||||
"github.com/coze-dev/coze-studio/backend/domain/workflow/entity/vo"
|
"github.com/coze-dev/coze-studio/backend/domain/workflow/entity/vo"
|
||||||
"github.com/coze-dev/coze-studio/backend/domain/workflow/internal/repo/dal/model"
|
"github.com/coze-dev/coze-studio/backend/domain/workflow/internal/repo/dal/model"
|
||||||
|
|
@ -52,21 +52,21 @@ func (e *executeHistoryStoreImpl) CreateWorkflowExecution(ctx context.Context, e
|
||||||
}()
|
}()
|
||||||
|
|
||||||
var mode int32
|
var mode int32
|
||||||
if execution.Mode == plugin.ExecuteModeDebug {
|
if execution.Mode == workflowModel.ExecuteModeDebug {
|
||||||
mode = 1
|
mode = 1
|
||||||
} else if execution.Mode == plugin.ExecuteModeRelease {
|
} else if execution.Mode == workflowModel.ExecuteModeRelease {
|
||||||
mode = 2
|
mode = 2
|
||||||
} else if execution.Mode == plugin.ExecuteModeNodeDebug {
|
} else if execution.Mode == workflowModel.ExecuteModeNodeDebug {
|
||||||
mode = 3
|
mode = 3
|
||||||
}
|
}
|
||||||
|
|
||||||
var syncPattern int32
|
var syncPattern int32
|
||||||
switch execution.SyncPattern {
|
switch execution.SyncPattern {
|
||||||
case plugin.SyncPatternSync:
|
case workflowModel.SyncPatternSync:
|
||||||
syncPattern = 1
|
syncPattern = 1
|
||||||
case plugin.SyncPatternAsync:
|
case workflowModel.SyncPatternAsync:
|
||||||
syncPattern = 2
|
syncPattern = 2
|
||||||
case plugin.SyncPatternStream:
|
case workflowModel.SyncPatternStream:
|
||||||
syncPattern = 3
|
syncPattern = 3
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
|
|
@ -212,23 +212,23 @@ func (e *executeHistoryStoreImpl) GetWorkflowExecution(ctx context.Context, id i
|
||||||
}
|
}
|
||||||
|
|
||||||
rootExe := rootExes[0]
|
rootExe := rootExes[0]
|
||||||
var exeMode plugin.ExecuteMode
|
var exeMode workflowModel.ExecuteMode
|
||||||
if rootExe.Mode == 1 {
|
if rootExe.Mode == 1 {
|
||||||
exeMode = plugin.ExecuteModeDebug
|
exeMode = workflowModel.ExecuteModeDebug
|
||||||
} else if rootExe.Mode == 2 {
|
} else if rootExe.Mode == 2 {
|
||||||
exeMode = plugin.ExecuteModeRelease
|
exeMode = workflowModel.ExecuteModeRelease
|
||||||
} else {
|
} else {
|
||||||
exeMode = plugin.ExecuteModeNodeDebug
|
exeMode = workflowModel.ExecuteModeNodeDebug
|
||||||
}
|
}
|
||||||
|
|
||||||
var syncPattern plugin.SyncPattern
|
var syncPattern workflowModel.SyncPattern
|
||||||
switch rootExe.SyncPattern {
|
switch rootExe.SyncPattern {
|
||||||
case 1:
|
case 1:
|
||||||
syncPattern = plugin.SyncPatternSync
|
syncPattern = workflowModel.SyncPatternSync
|
||||||
case 2:
|
case 2:
|
||||||
syncPattern = plugin.SyncPatternAsync
|
syncPattern = workflowModel.SyncPatternAsync
|
||||||
case 3:
|
case 3:
|
||||||
syncPattern = plugin.SyncPatternStream
|
syncPattern = workflowModel.SyncPatternStream
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -237,7 +237,7 @@ func (e *executeHistoryStoreImpl) GetWorkflowExecution(ctx context.Context, id i
|
||||||
WorkflowID: rootExe.WorkflowID,
|
WorkflowID: rootExe.WorkflowID,
|
||||||
Version: rootExe.Version,
|
Version: rootExe.Version,
|
||||||
SpaceID: rootExe.SpaceID,
|
SpaceID: rootExe.SpaceID,
|
||||||
ExecuteConfig: plugin.ExecuteConfig{
|
ExecuteConfig: workflowModel.ExecuteConfig{
|
||||||
Operator: rootExe.OperatorID,
|
Operator: rootExe.OperatorID,
|
||||||
Mode: exeMode,
|
Mode: exeMode,
|
||||||
AppID: ternary.IFElse(rootExe.AppID > 0, ptr.Of(rootExe.AppID), nil),
|
AppID: ternary.IFElse(rootExe.AppID > 0, ptr.Of(rootExe.AppID), nil),
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ import (
|
||||||
"gorm.io/gen/field"
|
"gorm.io/gen/field"
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
|
|
||||||
"github.com/coze-dev/coze-studio/backend/api/model/crossdomain/plugin"
|
workflowModel "github.com/coze-dev/coze-studio/backend/api/model/crossdomain/workflow"
|
||||||
workflow3 "github.com/coze-dev/coze-studio/backend/api/model/workflow"
|
workflow3 "github.com/coze-dev/coze-studio/backend/api/model/workflow"
|
||||||
"github.com/coze-dev/coze-studio/backend/application/base/ctxutil"
|
"github.com/coze-dev/coze-studio/backend/application/base/ctxutil"
|
||||||
"github.com/coze-dev/coze-studio/backend/domain/workflow"
|
"github.com/coze-dev/coze-studio/backend/domain/workflow"
|
||||||
|
|
@ -537,7 +537,7 @@ func (r *RepositoryImpl) GetEntity(ctx context.Context, policy *vo.GetPolicy) (_
|
||||||
commitID string
|
commitID string
|
||||||
)
|
)
|
||||||
switch policy.QType {
|
switch policy.QType {
|
||||||
case plugin.FromDraft:
|
case workflowModel.FromDraft:
|
||||||
draft, err := r.DraftV2(ctx, policy.ID, policy.CommitID)
|
draft, err := r.DraftV2(ctx, policy.ID, policy.CommitID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
@ -548,7 +548,7 @@ func (r *RepositoryImpl) GetEntity(ctx context.Context, policy *vo.GetPolicy) (_
|
||||||
outputParams = draft.OutputParamsStr
|
outputParams = draft.OutputParamsStr
|
||||||
draftMeta = draft.DraftMeta
|
draftMeta = draft.DraftMeta
|
||||||
commitID = draft.CommitID
|
commitID = draft.CommitID
|
||||||
case plugin.FromSpecificVersion:
|
case workflowModel.FromSpecificVersion:
|
||||||
v, err := r.GetVersion(ctx, policy.ID, policy.Version)
|
v, err := r.GetVersion(ctx, policy.ID, policy.Version)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
@ -558,7 +558,7 @@ func (r *RepositoryImpl) GetEntity(ctx context.Context, policy *vo.GetPolicy) (_
|
||||||
outputParams = v.OutputParamsStr
|
outputParams = v.OutputParamsStr
|
||||||
versionMeta = v.VersionMeta
|
versionMeta = v.VersionMeta
|
||||||
commitID = v.CommitID
|
commitID = v.CommitID
|
||||||
case plugin.FromLatestVersion:
|
case workflowModel.FromLatestVersion:
|
||||||
v, err := r.GetLatestVersion(ctx, policy.ID)
|
v, err := r.GetLatestVersion(ctx, policy.ID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
@ -1411,7 +1411,7 @@ func (r *RepositoryImpl) WorkflowAsTool(ctx context.Context, policy vo.GetPolicy
|
||||||
), nil
|
), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *RepositoryImpl) CopyWorkflow(ctx context.Context, workflowID int64, policy plugin.CopyWorkflowPolicy) (
|
func (r *RepositoryImpl) CopyWorkflow(ctx context.Context, workflowID int64, policy vo.CopyWorkflowPolicy) (
|
||||||
_ *entity.Workflow, err error) {
|
_ *entity.Workflow, err error) {
|
||||||
const (
|
const (
|
||||||
copyWorkflowRedisKeyPrefix = "copy_workflow_redis_key_prefix"
|
copyWorkflowRedisKeyPrefix = "copy_workflow_redis_key_prefix"
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ import (
|
||||||
einoCompose "github.com/cloudwego/eino/compose"
|
einoCompose "github.com/cloudwego/eino/compose"
|
||||||
"github.com/cloudwego/eino/schema"
|
"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"
|
||||||
"github.com/coze-dev/coze-studio/backend/domain/workflow/entity"
|
"github.com/coze-dev/coze-studio/backend/domain/workflow/entity"
|
||||||
"github.com/coze-dev/coze-studio/backend/domain/workflow/entity/vo"
|
"github.com/coze-dev/coze-studio/backend/domain/workflow/entity/vo"
|
||||||
|
|
@ -37,7 +37,7 @@ func (a *asToolImpl) WithMessagePipe() (einoCompose.Option, *schema.StreamReader
|
||||||
return execute.WithMessagePipe()
|
return execute.WithMessagePipe()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *asToolImpl) WithExecuteConfig(cfg plugin.ExecuteConfig) einoCompose.Option {
|
func (a *asToolImpl) WithExecuteConfig(cfg workflowModel.ExecuteConfig) einoCompose.Option {
|
||||||
return einoCompose.WithToolsNodeOption(einoCompose.WithToolOption(execute.WithExecuteConfig(cfg)))
|
return einoCompose.WithToolsNodeOption(einoCompose.WithToolOption(execute.WithExecuteConfig(cfg)))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -25,8 +25,7 @@ import (
|
||||||
einoCompose "github.com/cloudwego/eino/compose"
|
einoCompose "github.com/cloudwego/eino/compose"
|
||||||
"github.com/cloudwego/eino/schema"
|
"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"
|
||||||
model "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"
|
||||||
"github.com/coze-dev/coze-studio/backend/domain/workflow/entity"
|
"github.com/coze-dev/coze-studio/backend/domain/workflow/entity"
|
||||||
"github.com/coze-dev/coze-studio/backend/domain/workflow/entity/vo"
|
"github.com/coze-dev/coze-studio/backend/domain/workflow/entity/vo"
|
||||||
|
|
@ -46,7 +45,7 @@ type executableImpl struct {
|
||||||
repo workflow.Repository
|
repo workflow.Repository
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i *impl) SyncExecute(ctx context.Context, config model.ExecuteConfig, input map[string]any) (*entity.WorkflowExecution, vo.TerminatePlan, error) {
|
func (i *impl) SyncExecute(ctx context.Context, config workflowModel.ExecuteConfig, input map[string]any) (*entity.WorkflowExecution, vo.TerminatePlan, error) {
|
||||||
var (
|
var (
|
||||||
err error
|
err error
|
||||||
wfEntity *entity.Workflow
|
wfEntity *entity.Workflow
|
||||||
|
|
@ -64,7 +63,7 @@ func (i *impl) SyncExecute(ctx context.Context, config model.ExecuteConfig, inpu
|
||||||
}
|
}
|
||||||
|
|
||||||
isApplicationWorkflow := wfEntity.AppID != nil
|
isApplicationWorkflow := wfEntity.AppID != nil
|
||||||
if isApplicationWorkflow && config.Mode == model.ExecuteModeRelease {
|
if isApplicationWorkflow && config.Mode == workflowModel.ExecuteModeRelease {
|
||||||
err = i.checkApplicationWorkflowReleaseVersion(ctx, *wfEntity.AppID, config.ConnectorID, config.ID, config.Version)
|
err = i.checkApplicationWorkflowReleaseVersion(ctx, *wfEntity.AppID, config.ConnectorID, config.ID, config.Version)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, "", err
|
return nil, "", err
|
||||||
|
|
@ -191,7 +190,7 @@ func (i *impl) SyncExecute(ctx context.Context, config model.ExecuteConfig, inpu
|
||||||
// AsyncExecute executes the specified workflow asynchronously, returning the execution ID.
|
// AsyncExecute executes the specified workflow asynchronously, returning the execution ID.
|
||||||
// Intermediate results are not emitted on the fly.
|
// Intermediate results are not emitted on the fly.
|
||||||
// The caller is expected to poll the execution status using the GetExecution method and the returned execution ID.
|
// The caller is expected to poll the execution status using the GetExecution method and the returned execution ID.
|
||||||
func (i *impl) AsyncExecute(ctx context.Context, config plugin.ExecuteConfig, input map[string]any) (int64, error) {
|
func (i *impl) AsyncExecute(ctx context.Context, config workflowModel.ExecuteConfig, input map[string]any) (int64, error) {
|
||||||
var (
|
var (
|
||||||
err error
|
err error
|
||||||
wfEntity *entity.Workflow
|
wfEntity *entity.Workflow
|
||||||
|
|
@ -209,7 +208,7 @@ func (i *impl) AsyncExecute(ctx context.Context, config plugin.ExecuteConfig, in
|
||||||
}
|
}
|
||||||
|
|
||||||
isApplicationWorkflow := wfEntity.AppID != nil
|
isApplicationWorkflow := wfEntity.AppID != nil
|
||||||
if isApplicationWorkflow && config.Mode == plugin.ExecuteModeRelease {
|
if isApplicationWorkflow && config.Mode == workflowModel.ExecuteModeRelease {
|
||||||
err = i.checkApplicationWorkflowReleaseVersion(ctx, *wfEntity.AppID, config.ConnectorID, config.ID, config.Version)
|
err = i.checkApplicationWorkflowReleaseVersion(ctx, *wfEntity.AppID, config.ConnectorID, config.ID, config.Version)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
|
|
@ -266,7 +265,7 @@ func (i *impl) AsyncExecute(ctx context.Context, config plugin.ExecuteConfig, in
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if config.Mode == plugin.ExecuteModeDebug {
|
if config.Mode == workflowModel.ExecuteModeDebug {
|
||||||
if err = i.repo.SetTestRunLatestExeID(ctx, wfEntity.ID, config.Operator, executeID); err != nil {
|
if err = i.repo.SetTestRunLatestExeID(ctx, wfEntity.ID, config.Operator, executeID); err != nil {
|
||||||
logs.CtxErrorf(ctx, "failed to set test run latest exe id: %v", err)
|
logs.CtxErrorf(ctx, "failed to set test run latest exe id: %v", err)
|
||||||
}
|
}
|
||||||
|
|
@ -277,7 +276,7 @@ func (i *impl) AsyncExecute(ctx context.Context, config plugin.ExecuteConfig, in
|
||||||
return executeID, nil
|
return executeID, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i *impl) AsyncExecuteNode(ctx context.Context, nodeID string, config plugin.ExecuteConfig, input map[string]any) (int64, error) {
|
func (i *impl) AsyncExecuteNode(ctx context.Context, nodeID string, config workflowModel.ExecuteConfig, input map[string]any) (int64, error) {
|
||||||
var (
|
var (
|
||||||
err error
|
err error
|
||||||
wfEntity *entity.Workflow
|
wfEntity *entity.Workflow
|
||||||
|
|
@ -294,7 +293,7 @@ func (i *impl) AsyncExecuteNode(ctx context.Context, nodeID string, config plugi
|
||||||
}
|
}
|
||||||
|
|
||||||
isApplicationWorkflow := wfEntity.AppID != nil
|
isApplicationWorkflow := wfEntity.AppID != nil
|
||||||
if isApplicationWorkflow && config.Mode == plugin.ExecuteModeRelease {
|
if isApplicationWorkflow && config.Mode == workflowModel.ExecuteModeRelease {
|
||||||
err = i.checkApplicationWorkflowReleaseVersion(ctx, *wfEntity.AppID, config.ConnectorID, config.ID, config.Version)
|
err = i.checkApplicationWorkflowReleaseVersion(ctx, *wfEntity.AppID, config.ConnectorID, config.ID, config.Version)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
|
|
@ -345,7 +344,7 @@ func (i *impl) AsyncExecuteNode(ctx context.Context, nodeID string, config plugi
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if config.Mode == plugin.ExecuteModeNodeDebug {
|
if config.Mode == workflowModel.ExecuteModeNodeDebug {
|
||||||
if err = i.repo.SetNodeDebugLatestExeID(ctx, wfEntity.ID, nodeID, config.Operator, executeID); err != nil {
|
if err = i.repo.SetNodeDebugLatestExeID(ctx, wfEntity.ID, nodeID, config.Operator, executeID); err != nil {
|
||||||
logs.CtxErrorf(ctx, "failed to set node debug latest exe id: %v", err)
|
logs.CtxErrorf(ctx, "failed to set node debug latest exe id: %v", err)
|
||||||
}
|
}
|
||||||
|
|
@ -358,7 +357,7 @@ func (i *impl) AsyncExecuteNode(ctx context.Context, nodeID string, config plugi
|
||||||
|
|
||||||
// StreamExecute executes the specified workflow, returning a stream of execution events.
|
// StreamExecute executes the specified workflow, returning a stream of execution events.
|
||||||
// The caller is expected to receive from the returned stream immediately.
|
// The caller is expected to receive from the returned stream immediately.
|
||||||
func (i *impl) StreamExecute(ctx context.Context, config plugin.ExecuteConfig, input map[string]any) (*schema.StreamReader[*entity.Message], error) {
|
func (i *impl) StreamExecute(ctx context.Context, config workflowModel.ExecuteConfig, input map[string]any) (*schema.StreamReader[*entity.Message], error) {
|
||||||
var (
|
var (
|
||||||
err error
|
err error
|
||||||
wfEntity *entity.Workflow
|
wfEntity *entity.Workflow
|
||||||
|
|
@ -377,7 +376,7 @@ func (i *impl) StreamExecute(ctx context.Context, config plugin.ExecuteConfig, i
|
||||||
}
|
}
|
||||||
|
|
||||||
isApplicationWorkflow := wfEntity.AppID != nil
|
isApplicationWorkflow := wfEntity.AppID != nil
|
||||||
if isApplicationWorkflow && config.Mode == plugin.ExecuteModeRelease {
|
if isApplicationWorkflow && config.Mode == workflowModel.ExecuteModeRelease {
|
||||||
err = i.checkApplicationWorkflowReleaseVersion(ctx, *wfEntity.AppID, config.ConnectorID, config.ID, config.Version)
|
err = i.checkApplicationWorkflowReleaseVersion(ctx, *wfEntity.AppID, config.ConnectorID, config.ID, config.Version)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
@ -547,7 +546,7 @@ func (i *impl) GetNodeExecution(ctx context.Context, exeID int64, nodeID string)
|
||||||
return nil, nil, fmt.Errorf("try getting workflow exe for exeID : %d, but not found", exeID)
|
return nil, nil, fmt.Errorf("try getting workflow exe for exeID : %d, but not found", exeID)
|
||||||
}
|
}
|
||||||
|
|
||||||
if wfExe.Mode != plugin.ExecuteModeNodeDebug {
|
if wfExe.Mode != workflowModel.ExecuteModeNodeDebug {
|
||||||
return nodeExe, nil, nil
|
return nodeExe, nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -673,7 +672,7 @@ func mergeCompositeInnerNodes(nodeExes map[int]*entity.NodeExecution, maxIndex i
|
||||||
// AsyncResume resumes a workflow execution asynchronously, using the passed in executionID and eventID.
|
// AsyncResume resumes a workflow execution asynchronously, using the passed in executionID and eventID.
|
||||||
// Intermediate results during the resuming run are not emitted on the fly.
|
// Intermediate results during the resuming run are not emitted on the fly.
|
||||||
// Caller is expected to poll the execution status using the GetExecution method.
|
// Caller is expected to poll the execution status using the GetExecution method.
|
||||||
func (i *impl) AsyncResume(ctx context.Context, req *entity.ResumeRequest, config plugin.ExecuteConfig) error {
|
func (i *impl) AsyncResume(ctx context.Context, req *entity.ResumeRequest, config workflowModel.ExecuteConfig) error {
|
||||||
wfExe, found, err := i.repo.GetWorkflowExecution(ctx, req.ExecuteID)
|
wfExe, found, err := i.repo.GetWorkflowExecution(ctx, req.ExecuteID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
@ -691,11 +690,11 @@ func (i *impl) AsyncResume(ctx context.Context, req *entity.ResumeRequest, confi
|
||||||
return fmt.Errorf("workflow execution %d is not interrupted, status is %v, cannot resume", req.ExecuteID, wfExe.Status)
|
return fmt.Errorf("workflow execution %d is not interrupted, status is %v, cannot resume", req.ExecuteID, wfExe.Status)
|
||||||
}
|
}
|
||||||
|
|
||||||
var from plugin.Locator
|
var from workflowModel.Locator
|
||||||
if wfExe.Version == "" {
|
if wfExe.Version == "" {
|
||||||
from = plugin.FromDraft
|
from = workflowModel.FromDraft
|
||||||
} else {
|
} else {
|
||||||
from = plugin.FromSpecificVersion
|
from = workflowModel.FromSpecificVersion
|
||||||
}
|
}
|
||||||
|
|
||||||
wfEntity, err := i.Get(ctx, &vo.GetPolicy{
|
wfEntity, err := i.Get(ctx, &vo.GetPolicy{
|
||||||
|
|
@ -724,7 +723,7 @@ func (i *impl) AsyncResume(ctx context.Context, req *entity.ResumeRequest, confi
|
||||||
config.ConnectorID = wfExe.ConnectorID
|
config.ConnectorID = wfExe.ConnectorID
|
||||||
}
|
}
|
||||||
|
|
||||||
if wfExe.Mode == plugin.ExecuteModeNodeDebug {
|
if wfExe.Mode == workflowModel.ExecuteModeNodeDebug {
|
||||||
nodeExes, err := i.repo.GetNodeExecutionsByWfExeID(ctx, wfExe.ID)
|
nodeExes, err := i.repo.GetNodeExecutionsByWfExeID(ctx, wfExe.ID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
@ -753,7 +752,7 @@ func (i *impl) AsyncResume(ctx context.Context, req *entity.ResumeRequest, confi
|
||||||
return fmt.Errorf("failed to create workflow: %w", err)
|
return fmt.Errorf("failed to create workflow: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
config.Mode = plugin.ExecuteModeNodeDebug
|
config.Mode = workflowModel.ExecuteModeNodeDebug
|
||||||
|
|
||||||
cancelCtx, _, opts, _, err := compose.NewWorkflowRunner(
|
cancelCtx, _, opts, _, err := compose.NewWorkflowRunner(
|
||||||
wfEntity.GetBasic(), workflowSC, config, compose.WithResumeReq(req)).Prepare(ctx)
|
wfEntity.GetBasic(), workflowSC, config, compose.WithResumeReq(req)).Prepare(ctx)
|
||||||
|
|
@ -795,7 +794,7 @@ func (i *impl) AsyncResume(ctx context.Context, req *entity.ResumeRequest, confi
|
||||||
// StreamResume resumes a workflow execution, using the passed in executionID and eventID.
|
// StreamResume resumes a workflow execution, using the passed in executionID and eventID.
|
||||||
// Intermediate results during the resuming run are emitted using the returned StreamReader.
|
// Intermediate results during the resuming run are emitted using the returned StreamReader.
|
||||||
// Caller is expected to poll the execution status using the GetExecution method.
|
// Caller is expected to poll the execution status using the GetExecution method.
|
||||||
func (i *impl) StreamResume(ctx context.Context, req *entity.ResumeRequest, config plugin.ExecuteConfig) (
|
func (i *impl) StreamResume(ctx context.Context, req *entity.ResumeRequest, config workflowModel.ExecuteConfig) (
|
||||||
*schema.StreamReader[*entity.Message], error) {
|
*schema.StreamReader[*entity.Message], error) {
|
||||||
// must get the interrupt event
|
// must get the interrupt event
|
||||||
// generate the state modifier
|
// generate the state modifier
|
||||||
|
|
@ -816,11 +815,11 @@ func (i *impl) StreamResume(ctx context.Context, req *entity.ResumeRequest, conf
|
||||||
return nil, fmt.Errorf("workflow execution %d is not interrupted, status is %v, cannot resume", req.ExecuteID, wfExe.Status)
|
return nil, fmt.Errorf("workflow execution %d is not interrupted, status is %v, cannot resume", req.ExecuteID, wfExe.Status)
|
||||||
}
|
}
|
||||||
|
|
||||||
var from plugin.Locator
|
var from workflowModel.Locator
|
||||||
if wfExe.Version == "" {
|
if wfExe.Version == "" {
|
||||||
from = plugin.FromDraft
|
from = workflowModel.FromDraft
|
||||||
} else {
|
} else {
|
||||||
from = plugin.FromSpecificVersion
|
from = workflowModel.FromSpecificVersion
|
||||||
}
|
}
|
||||||
|
|
||||||
wfEntity, err := i.Get(ctx, &vo.GetPolicy{
|
wfEntity, err := i.Get(ctx, &vo.GetPolicy{
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,6 @@ import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"strconv"
|
"strconv"
|
||||||
"time"
|
|
||||||
|
|
||||||
einoCompose "github.com/cloudwego/eino/compose"
|
einoCompose "github.com/cloudwego/eino/compose"
|
||||||
|
|
||||||
|
|
@ -31,10 +30,10 @@ import (
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
|
|
||||||
"github.com/coze-dev/coze-studio/backend/api/model/crossdomain/plugin"
|
"github.com/coze-dev/coze-studio/backend/api/model/crossdomain/plugin"
|
||||||
|
workflowModel "github.com/coze-dev/coze-studio/backend/api/model/crossdomain/workflow"
|
||||||
cloudworkflow "github.com/coze-dev/coze-studio/backend/api/model/workflow"
|
cloudworkflow "github.com/coze-dev/coze-studio/backend/api/model/workflow"
|
||||||
"github.com/coze-dev/coze-studio/backend/application/base/ctxutil"
|
"github.com/coze-dev/coze-studio/backend/application/base/ctxutil"
|
||||||
"github.com/coze-dev/coze-studio/backend/domain/workflow"
|
"github.com/coze-dev/coze-studio/backend/domain/workflow"
|
||||||
"github.com/coze-dev/coze-studio/backend/domain/workflow/crossdomain/search"
|
|
||||||
"github.com/coze-dev/coze-studio/backend/domain/workflow/entity"
|
"github.com/coze-dev/coze-studio/backend/domain/workflow/entity"
|
||||||
"github.com/coze-dev/coze-studio/backend/domain/workflow/entity/vo"
|
"github.com/coze-dev/coze-studio/backend/domain/workflow/entity/vo"
|
||||||
"github.com/coze-dev/coze-studio/backend/domain/workflow/internal/canvas/adaptor"
|
"github.com/coze-dev/coze-studio/backend/domain/workflow/internal/canvas/adaptor"
|
||||||
|
|
@ -124,21 +123,6 @@ func (i *impl) Create(ctx context.Context, meta *vo.MetaCreate) (int64, error) {
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
|
||||||
err = search.GetNotifier().PublishWorkflowResource(ctx, search.Created, &search.Resource{
|
|
||||||
WorkflowID: id,
|
|
||||||
URI: &meta.IconURI,
|
|
||||||
Name: &meta.Name,
|
|
||||||
Desc: &meta.Desc,
|
|
||||||
APPID: meta.AppID,
|
|
||||||
SpaceID: &meta.SpaceID,
|
|
||||||
OwnerID: &meta.CreatorID,
|
|
||||||
Mode: ptr.Of(int32(meta.Mode)),
|
|
||||||
PublishStatus: ptr.Of(search.UnPublished),
|
|
||||||
CreatedAt: ptr.Of(time.Now().UnixMilli()),
|
|
||||||
})
|
|
||||||
if err != nil {
|
|
||||||
return 0, vo.WrapError(errno.ErrNotifyWorkflowResourceChangeErr, err)
|
|
||||||
}
|
|
||||||
return id, nil
|
return id, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -234,7 +218,7 @@ func extractInputsAndOutputsNamedInfoList(c *vo.Canvas) (inputs []*vo.NamedTypeI
|
||||||
return inputs, outputs
|
return inputs, outputs
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i *impl) Delete(ctx context.Context, policy *vo.DeletePolicy) (err error) {
|
func (i *impl) Delete(ctx context.Context, policy *vo.DeletePolicy) (ids []int64, err error) {
|
||||||
if policy.ID != nil || len(policy.IDs) == 1 {
|
if policy.ID != nil || len(policy.IDs) == 1 {
|
||||||
var id int64
|
var id int64
|
||||||
if policy.ID != nil {
|
if policy.ID != nil {
|
||||||
|
|
@ -244,48 +228,28 @@ func (i *impl) Delete(ctx context.Context, policy *vo.DeletePolicy) (err error)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err = i.repo.Delete(ctx, id); err != nil {
|
if err = i.repo.Delete(ctx, id); err != nil {
|
||||||
return err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err = search.GetNotifier().PublishWorkflowResource(ctx, search.Deleted, &search.Resource{
|
return []int64{id}, nil
|
||||||
WorkflowID: id,
|
|
||||||
}); err != nil {
|
|
||||||
return vo.WrapError(errno.ErrNotifyWorkflowResourceChangeErr, err)
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ids := policy.IDs
|
ids = policy.IDs
|
||||||
if policy.AppID != nil {
|
if policy.AppID != nil {
|
||||||
metas, _, err := i.repo.MGetMetas(ctx, &vo.MetaQuery{
|
metas, _, err := i.repo.MGetMetas(ctx, &vo.MetaQuery{
|
||||||
AppID: policy.AppID,
|
AppID: policy.AppID,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return nil, err
|
||||||
}
|
}
|
||||||
ids = maps.Keys(metas)
|
ids = maps.Keys(metas)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err = i.repo.MDelete(ctx, ids); err != nil {
|
if err = i.repo.MDelete(ctx, ids); err != nil {
|
||||||
return err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
g := errgroup.Group{}
|
return ids, nil
|
||||||
for i := range ids {
|
|
||||||
wid := ids[i]
|
|
||||||
g.Go(func() error {
|
|
||||||
return search.GetNotifier().PublishWorkflowResource(ctx, search.Deleted, &search.Resource{
|
|
||||||
WorkflowID: wid,
|
|
||||||
})
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
if err = g.Wait(); err != nil {
|
|
||||||
return vo.WrapError(errno.ErrNotifyWorkflowResourceChangeErr, err)
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i *impl) Get(ctx context.Context, policy *vo.GetPolicy) (*entity.Workflow, error) {
|
func (i *impl) Get(ctx context.Context, policy *vo.GetPolicy) (*entity.Workflow, error) {
|
||||||
|
|
@ -387,7 +351,7 @@ func (i *impl) ValidateTree(ctx context.Context, id int64, validateConfig vo.Val
|
||||||
MetaQuery: vo.MetaQuery{
|
MetaQuery: vo.MetaQuery{
|
||||||
IDs: ids,
|
IDs: ids,
|
||||||
},
|
},
|
||||||
QType: plugin.FromDraft,
|
QType: workflowModel.FromDraft,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
@ -687,16 +651,6 @@ func (i *impl) Publish(ctx context.Context, policy *vo.PublishPolicy) (err error
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
now := time.Now().UnixMilli()
|
|
||||||
if err = search.GetNotifier().PublishWorkflowResource(ctx, search.Updated, &search.Resource{
|
|
||||||
WorkflowID: policy.ID,
|
|
||||||
PublishStatus: ptr.Of(search.Published),
|
|
||||||
UpdatedAt: ptr.Of(now),
|
|
||||||
PublishedAt: ptr.Of(now),
|
|
||||||
}); err != nil {
|
|
||||||
return vo.WrapError(errno.ErrNotifyWorkflowResourceChangeErr, err)
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -706,42 +660,15 @@ func (i *impl) UpdateMeta(ctx context.Context, id int64, metaUpdate *vo.MetaUpda
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
err = search.GetNotifier().PublishWorkflowResource(ctx, search.Updated, &search.Resource{
|
|
||||||
WorkflowID: id,
|
|
||||||
URI: metaUpdate.IconURI,
|
|
||||||
Name: metaUpdate.Name,
|
|
||||||
Desc: metaUpdate.Desc,
|
|
||||||
UpdatedAt: ptr.Of(time.Now().UnixMilli()),
|
|
||||||
})
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i *impl) CopyWorkflow(ctx context.Context, workflowID int64, policy plugin.CopyWorkflowPolicy) (*entity.Workflow, error) {
|
func (i *impl) CopyWorkflow(ctx context.Context, workflowID int64, policy vo.CopyWorkflowPolicy) (*entity.Workflow, error) {
|
||||||
wf, err := i.repo.CopyWorkflow(ctx, workflowID, policy)
|
wf, err := i.repo.CopyWorkflow(ctx, workflowID, policy)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO(zhuangjie): publish workflow resource logic should move to application
|
|
||||||
err = search.GetNotifier().PublishWorkflowResource(ctx, search.Created, &search.Resource{
|
|
||||||
WorkflowID: wf.ID,
|
|
||||||
URI: &wf.IconURI,
|
|
||||||
Name: &wf.Name,
|
|
||||||
Desc: &wf.Desc,
|
|
||||||
APPID: wf.AppID,
|
|
||||||
SpaceID: &wf.SpaceID,
|
|
||||||
OwnerID: &wf.CreatorID,
|
|
||||||
PublishStatus: ptr.Of(search.UnPublished),
|
|
||||||
CreatedAt: ptr.Of(time.Now().UnixMilli()),
|
|
||||||
})
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return wf, nil
|
return wf, nil
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -755,7 +682,7 @@ func (i *impl) ReleaseApplicationWorkflows(ctx context.Context, appID int64, con
|
||||||
MetaQuery: vo.MetaQuery{
|
MetaQuery: vo.MetaQuery{
|
||||||
AppID: &appID,
|
AppID: &appID,
|
||||||
},
|
},
|
||||||
QType: plugin.FromDraft,
|
QType: workflowModel.FromDraft,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
@ -804,7 +731,7 @@ func (i *impl) ReleaseApplicationWorkflows(ctx context.Context, appID int64, con
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
err = replaceRelatedWorkflowOrExternalResourceInWorkflowNodes(c.Nodes, relatedWorkflow, plugin.ExternalResourceRelated{
|
err = replaceRelatedWorkflowOrExternalResourceInWorkflowNodes(c.Nodes, relatedWorkflow, vo.ExternalResourceRelated{
|
||||||
PluginMap: relatedPlugins,
|
PluginMap: relatedPlugins,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
@ -871,8 +798,7 @@ func (i *impl) ReleaseApplicationWorkflows(ctx context.Context, appID int64, con
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i *impl) CopyWorkflowFromAppToLibrary(ctx context.Context, workflowID int64, appID int64, related plugin.ExternalResourceRelated) (map[int64]entity.IDVersionPair, []*vo.ValidateIssue, error) {
|
func (i *impl) CopyWorkflowFromAppToLibrary(ctx context.Context, workflowID int64, appID int64, related vo.ExternalResourceRelated) (*entity.CopyWorkflowFromAppToLibraryResult, error) {
|
||||||
|
|
||||||
type copiedWorkflow struct {
|
type copiedWorkflow struct {
|
||||||
id int64
|
id int64
|
||||||
draftInfo *vo.DraftInfo
|
draftInfo *vo.DraftInfo
|
||||||
|
|
@ -887,7 +813,7 @@ func (i *impl) CopyWorkflowFromAppToLibrary(ctx context.Context, workflowID int6
|
||||||
|
|
||||||
draftVersion, err = i.repo.DraftV2(ctx, workflowID, "")
|
draftVersion, err = i.repo.DraftV2(ctx, workflowID, "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
issues, err := validateWorkflowTree(ctx, vo.ValidateTreeConfig{
|
issues, err := validateWorkflowTree(ctx, vo.ValidateTreeConfig{
|
||||||
|
|
@ -895,12 +821,12 @@ func (i *impl) CopyWorkflowFromAppToLibrary(ctx context.Context, workflowID int6
|
||||||
AppID: ptr.Of(appID),
|
AppID: ptr.Of(appID),
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
draftWorkflows, wid2Named, err := i.repo.GetDraftWorkflowsByAppID(ctx, appID)
|
draftWorkflows, wid2Named, err := i.repo.GetDraftWorkflowsByAppID(ctx, appID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(issues) > 0 {
|
if len(issues) > 0 {
|
||||||
|
|
@ -1039,22 +965,24 @@ func (i *impl) CopyWorkflowFromAppToLibrary(ctx context.Context, workflowID int6
|
||||||
draftCanvas := &vo.Canvas{}
|
draftCanvas := &vo.Canvas{}
|
||||||
err = sonic.UnmarshalString(draftVersion.Canvas, &draftCanvas)
|
err = sonic.UnmarshalString(draftVersion.Canvas, &draftCanvas)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
err = validateAndBuildWorkflowReference(draftCanvas.Nodes, copiedWf)
|
err = validateAndBuildWorkflowReference(draftCanvas.Nodes, copiedWf)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(vIssues) > 0 {
|
if len(vIssues) > 0 {
|
||||||
return nil, vIssues, nil
|
return &entity.CopyWorkflowFromAppToLibraryResult{
|
||||||
|
ValidateIssues: vIssues,
|
||||||
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
var copyAndPublishWorkflowProcess func(wf *copiedWorkflow) error
|
var copyAndPublishWorkflowProcess func(wf *copiedWorkflow) error
|
||||||
|
|
||||||
hasPublishedWorkflows := make(map[int64]entity.IDVersionPair)
|
hasPublishedWorkflows := make(map[int64]entity.IDVersionPair)
|
||||||
|
copiedWorkflowArray := make([]*entity.Workflow, 0)
|
||||||
copyAndPublishWorkflowProcess = func(wf *copiedWorkflow) error {
|
copyAndPublishWorkflowProcess = func(wf *copiedWorkflow) error {
|
||||||
for _, refWorkflow := range wf.refWfs {
|
for _, refWorkflow := range wf.refWfs {
|
||||||
err := copyAndPublishWorkflowProcess(refWorkflow)
|
err := copyAndPublishWorkflowProcess(refWorkflow)
|
||||||
|
|
@ -1085,7 +1013,7 @@ func (i *impl) CopyWorkflowFromAppToLibrary(ctx context.Context, workflowID int6
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
cwf, err := i.repo.CopyWorkflow(ctx, wf.id, plugin.CopyWorkflowPolicy{
|
cwf, err := i.repo.CopyWorkflow(ctx, wf.id, vo.CopyWorkflowPolicy{
|
||||||
TargetAppID: ptr.Of(int64(0)),
|
TargetAppID: ptr.Of(int64(0)),
|
||||||
ModifiedCanvasSchema: ptr.Of(modifiedCanvasString),
|
ModifiedCanvasSchema: ptr.Of(modifiedCanvasString),
|
||||||
})
|
})
|
||||||
|
|
@ -1114,19 +1042,7 @@ func (i *impl) CopyWorkflowFromAppToLibrary(ctx context.Context, workflowID int6
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
err = search.GetNotifier().PublishWorkflowResource(ctx, search.Created, &search.Resource{
|
copiedWorkflowArray = append(copiedWorkflowArray, cwf)
|
||||||
WorkflowID: cwf.ID,
|
|
||||||
URI: &cwf.IconURI,
|
|
||||||
Name: &cwf.Name,
|
|
||||||
Desc: &cwf.Desc,
|
|
||||||
SpaceID: &cwf.SpaceID,
|
|
||||||
OwnerID: &cwf.CreatorID,
|
|
||||||
PublishStatus: ptr.Of(search.Published),
|
|
||||||
CreatedAt: ptr.Of(time.Now().UnixMilli()),
|
|
||||||
})
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
hasPublishedWorkflows[wf.id] = entity.IDVersionPair{
|
hasPublishedWorkflows[wf.id] = entity.IDVersionPair{
|
||||||
ID: cwf.ID,
|
ID: cwf.ID,
|
||||||
|
|
@ -1138,14 +1054,17 @@ func (i *impl) CopyWorkflowFromAppToLibrary(ctx context.Context, workflowID int6
|
||||||
|
|
||||||
err = copyAndPublishWorkflowProcess(copiedWf)
|
err = copyAndPublishWorkflowProcess(copiedWf)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return hasPublishedWorkflows, nil, nil
|
return &entity.CopyWorkflowFromAppToLibraryResult{
|
||||||
|
WorkflowIDVersionMap: hasPublishedWorkflows,
|
||||||
|
CopiedWorkflows: copiedWorkflowArray,
|
||||||
|
}, nil
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i *impl) DuplicateWorkflowsByAppID(ctx context.Context, sourceAppID, targetAppID int64, related plugin.ExternalResourceRelated) error {
|
func (i *impl) DuplicateWorkflowsByAppID(ctx context.Context, sourceAppID, targetAppID int64, related vo.ExternalResourceRelated) ([]*entity.Workflow, error) {
|
||||||
|
|
||||||
type copiedWorkflow struct {
|
type copiedWorkflow struct {
|
||||||
id int64
|
id int64
|
||||||
|
|
@ -1157,7 +1076,7 @@ func (i *impl) DuplicateWorkflowsByAppID(ctx context.Context, sourceAppID, targe
|
||||||
|
|
||||||
draftWorkflows, _, err := i.repo.GetDraftWorkflowsByAppID(ctx, sourceAppID)
|
draftWorkflows, _, err := i.repo.GetDraftWorkflowsByAppID(ctx, sourceAppID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
var duplicateWorkflowProcess func(workflowID int64, info *vo.DraftInfo) error
|
var duplicateWorkflowProcess func(workflowID int64, info *vo.DraftInfo) error
|
||||||
|
|
@ -1252,6 +1171,8 @@ func (i *impl) DuplicateWorkflowsByAppID(ctx context.Context, sourceAppID, targe
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
copiedWorkflowArray := make([]*entity.Workflow, 0)
|
||||||
var duplicateWorkflow func(wf *copiedWorkflow) error
|
var duplicateWorkflow func(wf *copiedWorkflow) error
|
||||||
duplicateWorkflow = func(wf *copiedWorkflow) error {
|
duplicateWorkflow = func(wf *copiedWorkflow) error {
|
||||||
for _, refWorkflow := range wf.refWfs {
|
for _, refWorkflow := range wf.refWfs {
|
||||||
|
|
@ -1277,7 +1198,7 @@ func (i *impl) DuplicateWorkflowsByAppID(ctx context.Context, sourceAppID, targe
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
cwf, err := i.CopyWorkflow(ctx, wf.id, plugin.CopyWorkflowPolicy{
|
cwf, err := i.CopyWorkflow(ctx, wf.id, vo.CopyWorkflowPolicy{
|
||||||
TargetAppID: ptr.Of(targetAppID),
|
TargetAppID: ptr.Of(targetAppID),
|
||||||
ModifiedCanvasSchema: ptr.Of(modifiedCanvasString),
|
ModifiedCanvasSchema: ptr.Of(modifiedCanvasString),
|
||||||
})
|
})
|
||||||
|
|
@ -1285,9 +1206,7 @@ func (i *impl) DuplicateWorkflowsByAppID(ctx context.Context, sourceAppID, targe
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err != nil {
|
copiedWorkflowArray = append(copiedWorkflowArray, cwf)
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
hasCopiedWorkflows[wf.id] = entity.IDVersionPair{
|
hasCopiedWorkflows[wf.id] = entity.IDVersionPair{
|
||||||
ID: cwf.ID,
|
ID: cwf.ID,
|
||||||
|
|
@ -1324,15 +1243,15 @@ func (i *impl) DuplicateWorkflowsByAppID(ctx context.Context, sourceAppID, targe
|
||||||
}
|
}
|
||||||
err = duplicateWorkflowProcess(workflowID, draftVersion)
|
err = duplicateWorkflowProcess(workflowID, draftVersion)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return copiedWorkflowArray, nil
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i *impl) SyncRelatedWorkflowResources(ctx context.Context, appID int64, relatedWorkflows map[int64]entity.IDVersionPair, related plugin.ExternalResourceRelated) error {
|
func (i *impl) SyncRelatedWorkflowResources(ctx context.Context, appID int64, relatedWorkflows map[int64]entity.IDVersionPair, related vo.ExternalResourceRelated) error {
|
||||||
draftVersions, _, err := i.repo.GetDraftWorkflowsByAppID(ctx, appID)
|
draftVersions, _, err := i.repo.GetDraftWorkflowsByAppID(ctx, appID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
@ -1381,10 +1300,10 @@ func (i *impl) SyncRelatedWorkflowResources(ctx context.Context, appID int64, re
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i *impl) GetWorkflowDependenceResource(ctx context.Context, workflowID int64) (*plugin.DependenceResource, error) {
|
func (i *impl) GetWorkflowDependenceResource(ctx context.Context, workflowID int64) (*vo.DependenceResource, error) {
|
||||||
wf, err := i.Get(ctx, &vo.GetPolicy{
|
wf, err := i.Get(ctx, &vo.GetPolicy{
|
||||||
ID: workflowID,
|
ID: workflowID,
|
||||||
QType: plugin.FromDraft,
|
QType: workflowModel.FromDraft,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
@ -1395,7 +1314,7 @@ func (i *impl) GetWorkflowDependenceResource(ctx context.Context, workflowID int
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
ds := &plugin.DependenceResource{
|
ds := &vo.DependenceResource{
|
||||||
PluginIDs: make([]int64, 0),
|
PluginIDs: make([]int64, 0),
|
||||||
KnowledgeIDs: make([]int64, 0),
|
KnowledgeIDs: make([]int64, 0),
|
||||||
DatabaseIDs: make([]int64, 0),
|
DatabaseIDs: make([]int64, 0),
|
||||||
|
|
@ -1486,7 +1405,7 @@ func (i *impl) GetWorkflowDependenceResource(ctx context.Context, workflowID int
|
||||||
|
|
||||||
wfe, err := i.repo.GetEntity(ctx, &vo.GetPolicy{
|
wfe, err := i.repo.GetEntity(ctx, &vo.GetPolicy{
|
||||||
ID: wID,
|
ID: wID,
|
||||||
QType: plugin.FromDraft,
|
QType: workflowModel.FromDraft,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
@ -1517,7 +1436,7 @@ func (i *impl) GetWorkflowDependenceResource(ctx context.Context, workflowID int
|
||||||
|
|
||||||
subWorkflow, err := i.repo.GetEntity(ctx, &vo.GetPolicy{
|
subWorkflow, err := i.repo.GetEntity(ctx, &vo.GetPolicy{
|
||||||
ID: wfID,
|
ID: wfID,
|
||||||
QType: plugin.FromDraft,
|
QType: workflowModel.FromDraft,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
@ -1593,9 +1512,9 @@ func (i *impl) MGet(ctx context.Context, policy *vo.MGetPolicy) ([]*entity.Workf
|
||||||
}
|
}
|
||||||
|
|
||||||
switch policy.QType {
|
switch policy.QType {
|
||||||
case plugin.FromDraft:
|
case workflowModel.FromDraft:
|
||||||
return i.repo.MGetDrafts(ctx, policy)
|
return i.repo.MGetDrafts(ctx, policy)
|
||||||
case plugin.FromSpecificVersion:
|
case workflowModel.FromSpecificVersion:
|
||||||
if len(policy.IDs) == 0 || len(policy.Versions) != len(policy.IDs) {
|
if len(policy.IDs) == 0 || len(policy.Versions) != len(policy.IDs) {
|
||||||
return nil, 0, fmt.Errorf("ids and versions are required when MGet from specific versions")
|
return nil, 0, fmt.Errorf("ids and versions are required when MGet from specific versions")
|
||||||
}
|
}
|
||||||
|
|
@ -1637,7 +1556,7 @@ func (i *impl) MGet(ctx context.Context, policy *vo.MGetPolicy) ([]*entity.Workf
|
||||||
}
|
}
|
||||||
|
|
||||||
return result, total, nil
|
return result, total, nil
|
||||||
case plugin.FromLatestVersion:
|
case workflowModel.FromLatestVersion:
|
||||||
return i.repo.MGetLatestVersion(ctx, policy)
|
return i.repo.MGetLatestVersion(ctx, policy)
|
||||||
default:
|
default:
|
||||||
panic("not implemented")
|
panic("not implemented")
|
||||||
|
|
@ -1672,7 +1591,7 @@ func (i *impl) calculateTestRunSuccess(ctx context.Context, c *vo.Canvas, wid in
|
||||||
return existedDraft.TestRunSuccess, nil // inherit previous draft snapshot's test run success flag
|
return existedDraft.TestRunSuccess, nil // inherit previous draft snapshot's test run success flag
|
||||||
}
|
}
|
||||||
|
|
||||||
func replaceRelatedWorkflowOrExternalResourceInWorkflowNodes(nodes []*vo.Node, relatedWorkflows map[int64]entity.IDVersionPair, related plugin.ExternalResourceRelated) error {
|
func replaceRelatedWorkflowOrExternalResourceInWorkflowNodes(nodes []*vo.Node, relatedWorkflows map[int64]entity.IDVersionPair, related vo.ExternalResourceRelated) error {
|
||||||
var (
|
var (
|
||||||
hasWorkflowRelated = len(relatedWorkflows) > 0
|
hasWorkflowRelated = len(relatedWorkflows) > 0
|
||||||
hasPluginRelated = len(related.PluginMap) > 0
|
hasPluginRelated = len(related.PluginMap) > 0
|
||||||
|
|
|
||||||
|
|
@ -16,9 +16,9 @@ import (
|
||||||
model "github.com/cloudwego/eino/components/model"
|
model "github.com/cloudwego/eino/components/model"
|
||||||
compose "github.com/cloudwego/eino/compose"
|
compose "github.com/cloudwego/eino/compose"
|
||||||
schema "github.com/cloudwego/eino/schema"
|
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"
|
||||||
workflow "github.com/coze-dev/coze-studio/backend/api/model/workflow"
|
workflow0 "github.com/coze-dev/coze-studio/backend/api/model/workflow"
|
||||||
workflow0 "github.com/coze-dev/coze-studio/backend/domain/workflow"
|
workflow1 "github.com/coze-dev/coze-studio/backend/domain/workflow"
|
||||||
entity "github.com/coze-dev/coze-studio/backend/domain/workflow/entity"
|
entity "github.com/coze-dev/coze-studio/backend/domain/workflow/entity"
|
||||||
vo "github.com/coze-dev/coze-studio/backend/domain/workflow/entity/vo"
|
vo "github.com/coze-dev/coze-studio/backend/domain/workflow/entity/vo"
|
||||||
gomock "go.uber.org/mock/gomock"
|
gomock "go.uber.org/mock/gomock"
|
||||||
|
|
@ -49,7 +49,7 @@ func (m *MockService) EXPECT() *MockServiceMockRecorder {
|
||||||
}
|
}
|
||||||
|
|
||||||
// AsyncExecute mocks base method.
|
// AsyncExecute mocks base method.
|
||||||
func (m *MockService) AsyncExecute(ctx context.Context, config plugin.ExecuteConfig, input map[string]any) (int64, error) {
|
func (m *MockService) AsyncExecute(ctx context.Context, config workflow.ExecuteConfig, input map[string]any) (int64, error) {
|
||||||
m.ctrl.T.Helper()
|
m.ctrl.T.Helper()
|
||||||
ret := m.ctrl.Call(m, "AsyncExecute", ctx, config, input)
|
ret := m.ctrl.Call(m, "AsyncExecute", ctx, config, input)
|
||||||
ret0, _ := ret[0].(int64)
|
ret0, _ := ret[0].(int64)
|
||||||
|
|
@ -64,7 +64,7 @@ func (mr *MockServiceMockRecorder) AsyncExecute(ctx, config, input any) *gomock.
|
||||||
}
|
}
|
||||||
|
|
||||||
// AsyncExecuteNode mocks base method.
|
// AsyncExecuteNode mocks base method.
|
||||||
func (m *MockService) AsyncExecuteNode(ctx context.Context, nodeID string, config plugin.ExecuteConfig, input map[string]any) (int64, error) {
|
func (m *MockService) AsyncExecuteNode(ctx context.Context, nodeID string, config workflow.ExecuteConfig, input map[string]any) (int64, error) {
|
||||||
m.ctrl.T.Helper()
|
m.ctrl.T.Helper()
|
||||||
ret := m.ctrl.Call(m, "AsyncExecuteNode", ctx, nodeID, config, input)
|
ret := m.ctrl.Call(m, "AsyncExecuteNode", ctx, nodeID, config, input)
|
||||||
ret0, _ := ret[0].(int64)
|
ret0, _ := ret[0].(int64)
|
||||||
|
|
@ -79,7 +79,7 @@ func (mr *MockServiceMockRecorder) AsyncExecuteNode(ctx, nodeID, config, input a
|
||||||
}
|
}
|
||||||
|
|
||||||
// AsyncResume mocks base method.
|
// AsyncResume mocks base method.
|
||||||
func (m *MockService) AsyncResume(ctx context.Context, req *entity.ResumeRequest, config plugin.ExecuteConfig) error {
|
func (m *MockService) AsyncResume(ctx context.Context, req *entity.ResumeRequest, config workflow.ExecuteConfig) error {
|
||||||
m.ctrl.T.Helper()
|
m.ctrl.T.Helper()
|
||||||
ret := m.ctrl.Call(m, "AsyncResume", ctx, req, config)
|
ret := m.ctrl.Call(m, "AsyncResume", ctx, req, config)
|
||||||
ret0, _ := ret[0].(error)
|
ret0, _ := ret[0].(error)
|
||||||
|
|
@ -107,7 +107,7 @@ func (mr *MockServiceMockRecorder) Cancel(ctx, wfExeID, wfID, spaceID any) *gomo
|
||||||
}
|
}
|
||||||
|
|
||||||
// CopyWorkflow mocks base method.
|
// CopyWorkflow mocks base method.
|
||||||
func (m *MockService) CopyWorkflow(ctx context.Context, workflowID int64, policy plugin.CopyWorkflowPolicy) (*entity.Workflow, error) {
|
func (m *MockService) CopyWorkflow(ctx context.Context, workflowID int64, policy vo.CopyWorkflowPolicy) (*entity.Workflow, error) {
|
||||||
m.ctrl.T.Helper()
|
m.ctrl.T.Helper()
|
||||||
ret := m.ctrl.Call(m, "CopyWorkflow", ctx, workflowID, policy)
|
ret := m.ctrl.Call(m, "CopyWorkflow", ctx, workflowID, policy)
|
||||||
ret0, _ := ret[0].(*entity.Workflow)
|
ret0, _ := ret[0].(*entity.Workflow)
|
||||||
|
|
@ -122,13 +122,12 @@ func (mr *MockServiceMockRecorder) CopyWorkflow(ctx, workflowID, policy any) *go
|
||||||
}
|
}
|
||||||
|
|
||||||
// CopyWorkflowFromAppToLibrary mocks base method.
|
// CopyWorkflowFromAppToLibrary mocks base method.
|
||||||
func (m *MockService) CopyWorkflowFromAppToLibrary(ctx context.Context, workflowID, appID int64, related plugin.ExternalResourceRelated) (map[int64]entity.IDVersionPair, []*vo.ValidateIssue, error) {
|
func (m *MockService) CopyWorkflowFromAppToLibrary(ctx context.Context, workflowID, appID int64, related vo.ExternalResourceRelated) (*entity.CopyWorkflowFromAppToLibraryResult, error) {
|
||||||
m.ctrl.T.Helper()
|
m.ctrl.T.Helper()
|
||||||
ret := m.ctrl.Call(m, "CopyWorkflowFromAppToLibrary", ctx, workflowID, appID, related)
|
ret := m.ctrl.Call(m, "CopyWorkflowFromAppToLibrary", ctx, workflowID, appID, related)
|
||||||
ret0, _ := ret[0].(map[int64]entity.IDVersionPair)
|
ret0, _ := ret[0].(*entity.CopyWorkflowFromAppToLibraryResult)
|
||||||
ret1, _ := ret[1].([]*vo.ValidateIssue)
|
ret1, _ := ret[1].(error)
|
||||||
ret2, _ := ret[2].(error)
|
return ret0, ret1
|
||||||
return ret0, ret1, ret2
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// CopyWorkflowFromAppToLibrary indicates an expected call of CopyWorkflowFromAppToLibrary.
|
// CopyWorkflowFromAppToLibrary indicates an expected call of CopyWorkflowFromAppToLibrary.
|
||||||
|
|
@ -153,11 +152,12 @@ func (mr *MockServiceMockRecorder) Create(ctx, meta any) *gomock.Call {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delete mocks base method.
|
// Delete mocks base method.
|
||||||
func (m *MockService) Delete(ctx context.Context, policy *vo.DeletePolicy) error {
|
func (m *MockService) Delete(ctx context.Context, policy *vo.DeletePolicy) ([]int64, error) {
|
||||||
m.ctrl.T.Helper()
|
m.ctrl.T.Helper()
|
||||||
ret := m.ctrl.Call(m, "Delete", ctx, policy)
|
ret := m.ctrl.Call(m, "Delete", ctx, policy)
|
||||||
ret0, _ := ret[0].(error)
|
ret0, _ := ret[0].([]int64)
|
||||||
return ret0
|
ret1, _ := ret[1].(error)
|
||||||
|
return ret0, ret1
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delete indicates an expected call of Delete.
|
// Delete indicates an expected call of Delete.
|
||||||
|
|
@ -167,11 +167,12 @@ func (mr *MockServiceMockRecorder) Delete(ctx, policy any) *gomock.Call {
|
||||||
}
|
}
|
||||||
|
|
||||||
// DuplicateWorkflowsByAppID mocks base method.
|
// DuplicateWorkflowsByAppID mocks base method.
|
||||||
func (m *MockService) DuplicateWorkflowsByAppID(ctx context.Context, sourceAPPID, targetAppID int64, related plugin.ExternalResourceRelated) error {
|
func (m *MockService) DuplicateWorkflowsByAppID(ctx context.Context, sourceAPPID, targetAppID int64, related vo.ExternalResourceRelated) ([]*entity.Workflow, error) {
|
||||||
m.ctrl.T.Helper()
|
m.ctrl.T.Helper()
|
||||||
ret := m.ctrl.Call(m, "DuplicateWorkflowsByAppID", ctx, sourceAPPID, targetAppID, related)
|
ret := m.ctrl.Call(m, "DuplicateWorkflowsByAppID", ctx, sourceAPPID, targetAppID, related)
|
||||||
ret0, _ := ret[0].(error)
|
ret0, _ := ret[0].([]*entity.Workflow)
|
||||||
return ret0
|
ret1, _ := ret[1].(error)
|
||||||
|
return ret0, ret1
|
||||||
}
|
}
|
||||||
|
|
||||||
// DuplicateWorkflowsByAppID indicates an expected call of DuplicateWorkflowsByAppID.
|
// DuplicateWorkflowsByAppID indicates an expected call of DuplicateWorkflowsByAppID.
|
||||||
|
|
@ -260,10 +261,10 @@ func (mr *MockServiceMockRecorder) GetNodeExecution(ctx, exeID, nodeID any) *gom
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetWorkflowDependenceResource mocks base method.
|
// GetWorkflowDependenceResource mocks base method.
|
||||||
func (m *MockService) GetWorkflowDependenceResource(ctx context.Context, workflowID int64) (*plugin.DependenceResource, error) {
|
func (m *MockService) GetWorkflowDependenceResource(ctx context.Context, workflowID int64) (*vo.DependenceResource, error) {
|
||||||
m.ctrl.T.Helper()
|
m.ctrl.T.Helper()
|
||||||
ret := m.ctrl.Call(m, "GetWorkflowDependenceResource", ctx, workflowID)
|
ret := m.ctrl.Call(m, "GetWorkflowDependenceResource", ctx, workflowID)
|
||||||
ret0, _ := ret[0].(*plugin.DependenceResource)
|
ret0, _ := ret[0].(*vo.DependenceResource)
|
||||||
ret1, _ := ret[1].(error)
|
ret1, _ := ret[1].(error)
|
||||||
return ret0, ret1
|
return ret0, ret1
|
||||||
}
|
}
|
||||||
|
|
@ -380,7 +381,7 @@ func (mr *MockServiceMockRecorder) Save(ctx, id, arg2 any) *gomock.Call {
|
||||||
}
|
}
|
||||||
|
|
||||||
// StreamExecute mocks base method.
|
// StreamExecute mocks base method.
|
||||||
func (m *MockService) StreamExecute(ctx context.Context, config plugin.ExecuteConfig, input map[string]any) (*schema.StreamReader[*entity.Message], error) {
|
func (m *MockService) StreamExecute(ctx context.Context, config workflow.ExecuteConfig, input map[string]any) (*schema.StreamReader[*entity.Message], error) {
|
||||||
m.ctrl.T.Helper()
|
m.ctrl.T.Helper()
|
||||||
ret := m.ctrl.Call(m, "StreamExecute", ctx, config, input)
|
ret := m.ctrl.Call(m, "StreamExecute", ctx, config, input)
|
||||||
ret0, _ := ret[0].(*schema.StreamReader[*entity.Message])
|
ret0, _ := ret[0].(*schema.StreamReader[*entity.Message])
|
||||||
|
|
@ -395,7 +396,7 @@ func (mr *MockServiceMockRecorder) StreamExecute(ctx, config, input any) *gomock
|
||||||
}
|
}
|
||||||
|
|
||||||
// StreamResume mocks base method.
|
// StreamResume mocks base method.
|
||||||
func (m *MockService) StreamResume(ctx context.Context, req *entity.ResumeRequest, config plugin.ExecuteConfig) (*schema.StreamReader[*entity.Message], error) {
|
func (m *MockService) StreamResume(ctx context.Context, req *entity.ResumeRequest, config workflow.ExecuteConfig) (*schema.StreamReader[*entity.Message], error) {
|
||||||
m.ctrl.T.Helper()
|
m.ctrl.T.Helper()
|
||||||
ret := m.ctrl.Call(m, "StreamResume", ctx, req, config)
|
ret := m.ctrl.Call(m, "StreamResume", ctx, req, config)
|
||||||
ret0, _ := ret[0].(*schema.StreamReader[*entity.Message])
|
ret0, _ := ret[0].(*schema.StreamReader[*entity.Message])
|
||||||
|
|
@ -410,7 +411,7 @@ func (mr *MockServiceMockRecorder) StreamResume(ctx, req, config any) *gomock.Ca
|
||||||
}
|
}
|
||||||
|
|
||||||
// SyncExecute mocks base method.
|
// SyncExecute mocks base method.
|
||||||
func (m *MockService) SyncExecute(ctx context.Context, config plugin.ExecuteConfig, input map[string]any) (*entity.WorkflowExecution, vo.TerminatePlan, error) {
|
func (m *MockService) SyncExecute(ctx context.Context, config workflow.ExecuteConfig, input map[string]any) (*entity.WorkflowExecution, vo.TerminatePlan, error) {
|
||||||
m.ctrl.T.Helper()
|
m.ctrl.T.Helper()
|
||||||
ret := m.ctrl.Call(m, "SyncExecute", ctx, config, input)
|
ret := m.ctrl.Call(m, "SyncExecute", ctx, config, input)
|
||||||
ret0, _ := ret[0].(*entity.WorkflowExecution)
|
ret0, _ := ret[0].(*entity.WorkflowExecution)
|
||||||
|
|
@ -426,7 +427,7 @@ func (mr *MockServiceMockRecorder) SyncExecute(ctx, config, input any) *gomock.C
|
||||||
}
|
}
|
||||||
|
|
||||||
// SyncRelatedWorkflowResources mocks base method.
|
// SyncRelatedWorkflowResources mocks base method.
|
||||||
func (m *MockService) SyncRelatedWorkflowResources(ctx context.Context, appID int64, relatedWorkflows map[int64]entity.IDVersionPair, related plugin.ExternalResourceRelated) error {
|
func (m *MockService) SyncRelatedWorkflowResources(ctx context.Context, appID int64, relatedWorkflows map[int64]entity.IDVersionPair, related vo.ExternalResourceRelated) error {
|
||||||
m.ctrl.T.Helper()
|
m.ctrl.T.Helper()
|
||||||
ret := m.ctrl.Call(m, "SyncRelatedWorkflowResources", ctx, appID, relatedWorkflows, related)
|
ret := m.ctrl.Call(m, "SyncRelatedWorkflowResources", ctx, appID, relatedWorkflows, related)
|
||||||
ret0, _ := ret[0].(error)
|
ret0, _ := ret[0].(error)
|
||||||
|
|
@ -454,10 +455,10 @@ func (mr *MockServiceMockRecorder) UpdateMeta(ctx, id, metaUpdate any) *gomock.C
|
||||||
}
|
}
|
||||||
|
|
||||||
// ValidateTree mocks base method.
|
// ValidateTree mocks base method.
|
||||||
func (m *MockService) ValidateTree(ctx context.Context, id int64, validateConfig vo.ValidateTreeConfig) ([]*workflow.ValidateTreeInfo, error) {
|
func (m *MockService) ValidateTree(ctx context.Context, id int64, validateConfig vo.ValidateTreeConfig) ([]*workflow0.ValidateTreeInfo, error) {
|
||||||
m.ctrl.T.Helper()
|
m.ctrl.T.Helper()
|
||||||
ret := m.ctrl.Call(m, "ValidateTree", ctx, id, validateConfig)
|
ret := m.ctrl.Call(m, "ValidateTree", ctx, id, validateConfig)
|
||||||
ret0, _ := ret[0].([]*workflow.ValidateTreeInfo)
|
ret0, _ := ret[0].([]*workflow0.ValidateTreeInfo)
|
||||||
ret1, _ := ret[1].(error)
|
ret1, _ := ret[1].(error)
|
||||||
return ret0, ret1
|
return ret0, ret1
|
||||||
}
|
}
|
||||||
|
|
@ -469,7 +470,7 @@ func (mr *MockServiceMockRecorder) ValidateTree(ctx, id, validateConfig any) *go
|
||||||
}
|
}
|
||||||
|
|
||||||
// WithExecuteConfig mocks base method.
|
// WithExecuteConfig mocks base method.
|
||||||
func (m *MockService) WithExecuteConfig(cfg plugin.ExecuteConfig) compose.Option {
|
func (m *MockService) WithExecuteConfig(cfg workflow.ExecuteConfig) compose.Option {
|
||||||
m.ctrl.T.Helper()
|
m.ctrl.T.Helper()
|
||||||
ret := m.ctrl.Call(m, "WithExecuteConfig", cfg)
|
ret := m.ctrl.Call(m, "WithExecuteConfig", cfg)
|
||||||
ret0, _ := ret[0].(compose.Option)
|
ret0, _ := ret[0].(compose.Option)
|
||||||
|
|
@ -512,10 +513,10 @@ func (mr *MockServiceMockRecorder) WithResumeToolWorkflow(resumingEvent, resumeD
|
||||||
}
|
}
|
||||||
|
|
||||||
// WorkflowAsModelTool mocks base method.
|
// WorkflowAsModelTool mocks base method.
|
||||||
func (m *MockService) WorkflowAsModelTool(ctx context.Context, policies []*vo.GetPolicy) ([]workflow0.ToolFromWorkflow, error) {
|
func (m *MockService) WorkflowAsModelTool(ctx context.Context, policies []*vo.GetPolicy) ([]workflow1.ToolFromWorkflow, error) {
|
||||||
m.ctrl.T.Helper()
|
m.ctrl.T.Helper()
|
||||||
ret := m.ctrl.Call(m, "WorkflowAsModelTool", ctx, policies)
|
ret := m.ctrl.Call(m, "WorkflowAsModelTool", ctx, policies)
|
||||||
ret0, _ := ret[0].([]workflow0.ToolFromWorkflow)
|
ret0, _ := ret[0].([]workflow1.ToolFromWorkflow)
|
||||||
ret1, _ := ret[1].(error)
|
ret1, _ := ret[1].(error)
|
||||||
return ret0, ret1
|
return ret0, ret1
|
||||||
}
|
}
|
||||||
|
|
@ -579,7 +580,7 @@ func (mr *MockRepositoryMockRecorder) CancelAllRunningNodes(ctx, wfExeID any) *g
|
||||||
}
|
}
|
||||||
|
|
||||||
// CopyWorkflow mocks base method.
|
// CopyWorkflow mocks base method.
|
||||||
func (m *MockRepository) CopyWorkflow(ctx context.Context, workflowID int64, policy plugin.CopyWorkflowPolicy) (*entity.Workflow, error) {
|
func (m *MockRepository) CopyWorkflow(ctx context.Context, workflowID int64, policy vo.CopyWorkflowPolicy) (*entity.Workflow, error) {
|
||||||
m.ctrl.T.Helper()
|
m.ctrl.T.Helper()
|
||||||
ret := m.ctrl.Call(m, "CopyWorkflow", ctx, workflowID, policy)
|
ret := m.ctrl.Call(m, "CopyWorkflow", ctx, workflowID, policy)
|
||||||
ret0, _ := ret[0].(*entity.Workflow)
|
ret0, _ := ret[0].(*entity.Workflow)
|
||||||
|
|
@ -1262,10 +1263,10 @@ func (mr *MockRepositoryMockRecorder) UpdateWorkflowExecution(ctx, execution, al
|
||||||
}
|
}
|
||||||
|
|
||||||
// WorkflowAsTool mocks base method.
|
// WorkflowAsTool mocks base method.
|
||||||
func (m *MockRepository) WorkflowAsTool(ctx context.Context, policy vo.GetPolicy, wfToolConfig vo.WorkflowToolConfig) (workflow0.ToolFromWorkflow, error) {
|
func (m *MockRepository) WorkflowAsTool(ctx context.Context, policy vo.GetPolicy, wfToolConfig vo.WorkflowToolConfig) (workflow1.ToolFromWorkflow, error) {
|
||||||
m.ctrl.T.Helper()
|
m.ctrl.T.Helper()
|
||||||
ret := m.ctrl.Call(m, "WorkflowAsTool", ctx, policy, wfToolConfig)
|
ret := m.ctrl.Call(m, "WorkflowAsTool", ctx, policy, wfToolConfig)
|
||||||
ret0, _ := ret[0].(workflow0.ToolFromWorkflow)
|
ret0, _ := ret[0].(workflow1.ToolFromWorkflow)
|
||||||
ret1, _ := ret[1].(error)
|
ret1, _ := ret[1].(error)
|
||||||
return ret0, ret1
|
return ret0, ret1
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
export RUN_MODE="debug" # Currently supports debug mode. When set to debug, it helps developers print raw error messages during development and debugging, such as agent debugging.
|
export RUN_MODE="debug" # Currently supports debug mode. When set to debug, it helps developers print raw error messages during development and debugging, such as agent debugging.
|
||||||
|
|
||||||
# Server
|
# Server
|
||||||
export LISTEN_ADDR=":8888"
|
export LISTEN_ADDR="127.0.0.1:8888"
|
||||||
export LOG_LEVEL="debug"
|
export LOG_LEVEL="debug"
|
||||||
export MAX_REQUEST_BODY_SIZE=1073741824
|
export MAX_REQUEST_BODY_SIZE=1073741824
|
||||||
export SERVER_HOST="http://localhost${LISTEN_ADDR}"
|
export SERVER_HOST="http://localhost${LISTEN_ADDR}"
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
# Server
|
# Server
|
||||||
export LISTEN_ADDR=":8888"
|
export LISTEN_ADDR="127.0.0.1:8888"
|
||||||
export LOG_LEVEL="debug"
|
export LOG_LEVEL="debug"
|
||||||
export MAX_REQUEST_BODY_SIZE=1073741824
|
export MAX_REQUEST_BODY_SIZE=1073741824
|
||||||
export SERVER_HOST="http://localhost${LISTEN_ADDR}"
|
export SERVER_HOST="http://localhost${LISTEN_ADDR}"
|
||||||
|
|
|
||||||
|
|
@ -225,8 +225,8 @@ services:
|
||||||
- ETCD_QUOTA_BACKEND_BYTES=4294967296
|
- ETCD_QUOTA_BACKEND_BYTES=4294967296
|
||||||
- ALLOW_NONE_AUTHENTICATION=yes
|
- ALLOW_NONE_AUTHENTICATION=yes
|
||||||
ports:
|
ports:
|
||||||
- 2379:2379
|
- '2379'
|
||||||
- 2380:2380
|
- '2380'
|
||||||
volumes:
|
volumes:
|
||||||
- ./data/bitnami/etcd:/bitnami/etcd:rw,Z
|
- ./data/bitnami/etcd:/bitnami/etcd:rw,Z
|
||||||
- ./volumes/etcd/etcd.conf.yml:/opt/bitnami/etcd/conf/etcd.conf.yml:ro,Z
|
- ./volumes/etcd/etcd.conf.yml:/opt/bitnami/etcd/conf/etcd.conf.yml:ro,Z
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue