|
|
|
|
@@ -30,6 +30,7 @@ import (
|
|
|
|
|
|
|
|
|
|
"github.com/coze-dev/coze-studio/backend/api/model/app/bot_common"
|
|
|
|
|
model "github.com/coze-dev/coze-studio/backend/api/model/crossdomain/knowledge"
|
|
|
|
|
"github.com/coze-dev/coze-studio/backend/api/model/crossdomain/plugin"
|
|
|
|
|
pluginmodel "github.com/coze-dev/coze-studio/backend/api/model/crossdomain/plugin"
|
|
|
|
|
"github.com/coze-dev/coze-studio/backend/api/model/data/database/table"
|
|
|
|
|
"github.com/coze-dev/coze-studio/backend/api/model/playground"
|
|
|
|
|
@@ -42,10 +43,11 @@ import (
|
|
|
|
|
appplugin "github.com/coze-dev/coze-studio/backend/application/plugin"
|
|
|
|
|
"github.com/coze-dev/coze-studio/backend/application/user"
|
|
|
|
|
crossknowledge "github.com/coze-dev/coze-studio/backend/crossdomain/contract/knowledge"
|
|
|
|
|
crossplugin "github.com/coze-dev/coze-studio/backend/crossdomain/contract/plugin"
|
|
|
|
|
|
|
|
|
|
crossuser "github.com/coze-dev/coze-studio/backend/crossdomain/contract/user"
|
|
|
|
|
domainWorkflow "github.com/coze-dev/coze-studio/backend/domain/workflow"
|
|
|
|
|
workflowDomain "github.com/coze-dev/coze-studio/backend/domain/workflow"
|
|
|
|
|
crossplugin "github.com/coze-dev/coze-studio/backend/domain/workflow/crossdomain/plugin"
|
|
|
|
|
"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/infra/contract/idgen"
|
|
|
|
|
@@ -334,7 +336,7 @@ func (w *ApplicationService) GetCanvasInfo(ctx context.Context, req *workflow.Ge
|
|
|
|
|
|
|
|
|
|
wf, err := GetWorkflowDomainSVC().Get(ctx, &vo.GetPolicy{
|
|
|
|
|
ID: mustParseInt64(req.GetWorkflowID()),
|
|
|
|
|
QType: vo.FromDraft,
|
|
|
|
|
QType: plugin.FromDraft,
|
|
|
|
|
})
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
|
@@ -430,19 +432,19 @@ func (w *ApplicationService) TestRun(ctx context.Context, req *workflow.WorkFlow
|
|
|
|
|
agentID = ptr.Of(mustParseInt64(req.GetBotID()))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
exeCfg := vo.ExecuteConfig{
|
|
|
|
|
exeCfg := plugin.ExecuteConfig{
|
|
|
|
|
ID: mustParseInt64(req.GetWorkflowID()),
|
|
|
|
|
From: vo.FromDraft,
|
|
|
|
|
From: plugin.FromDraft,
|
|
|
|
|
CommitID: req.GetCommitID(),
|
|
|
|
|
Operator: uID,
|
|
|
|
|
Mode: vo.ExecuteModeDebug,
|
|
|
|
|
Mode: plugin.ExecuteModeDebug,
|
|
|
|
|
AppID: appID,
|
|
|
|
|
AgentID: agentID,
|
|
|
|
|
ConnectorID: consts.CozeConnectorID,
|
|
|
|
|
ConnectorUID: strconv.FormatInt(uID, 10),
|
|
|
|
|
TaskType: vo.TaskTypeForeground,
|
|
|
|
|
SyncPattern: vo.SyncPatternAsync,
|
|
|
|
|
BizType: vo.BizTypeWorkflow,
|
|
|
|
|
TaskType: plugin.TaskTypeForeground,
|
|
|
|
|
SyncPattern: plugin.SyncPatternAsync,
|
|
|
|
|
BizType: plugin.BizTypeWorkflow,
|
|
|
|
|
Cancellable: true,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -502,18 +504,18 @@ func (w *ApplicationService) NodeDebug(ctx context.Context, req *workflow.Workfl
|
|
|
|
|
agentID = ptr.Of(mustParseInt64(req.GetBotID()))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
exeCfg := vo.ExecuteConfig{
|
|
|
|
|
exeCfg := plugin.ExecuteConfig{
|
|
|
|
|
ID: mustParseInt64(req.GetWorkflowID()),
|
|
|
|
|
From: vo.FromDraft,
|
|
|
|
|
From: plugin.FromDraft,
|
|
|
|
|
Operator: uID,
|
|
|
|
|
Mode: vo.ExecuteModeNodeDebug,
|
|
|
|
|
Mode: plugin.ExecuteModeNodeDebug,
|
|
|
|
|
AppID: appID,
|
|
|
|
|
AgentID: agentID,
|
|
|
|
|
ConnectorID: consts.CozeConnectorID,
|
|
|
|
|
ConnectorUID: strconv.FormatInt(uID, 10),
|
|
|
|
|
TaskType: vo.TaskTypeForeground,
|
|
|
|
|
SyncPattern: vo.SyncPatternAsync,
|
|
|
|
|
BizType: vo.BizTypeWorkflow,
|
|
|
|
|
TaskType: plugin.TaskTypeForeground,
|
|
|
|
|
SyncPattern: plugin.SyncPatternAsync,
|
|
|
|
|
BizType: plugin.BizTypeWorkflow,
|
|
|
|
|
Cancellable: true,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -865,7 +867,7 @@ func (w *ApplicationService) CheckWorkflowsExistByAppID(ctx context.Context, app
|
|
|
|
|
Page: 0,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
QType: vo.FromDraft,
|
|
|
|
|
QType: plugin.FromDraft,
|
|
|
|
|
MetaOnly: true,
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
@@ -890,7 +892,7 @@ func (w *ApplicationService) CopyWorkflowFromAppToLibrary(ctx context.Context, w
|
|
|
|
|
return 0, nil, err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pluginMap := make(map[int64]*vo.PluginEntity)
|
|
|
|
|
pluginMap := make(map[int64]*plugin.PluginEntity)
|
|
|
|
|
pluginToolMap := make(map[int64]int64)
|
|
|
|
|
|
|
|
|
|
if len(ds.PluginIDs) > 0 {
|
|
|
|
|
@@ -905,7 +907,7 @@ func (w *ApplicationService) CopyWorkflowFromAppToLibrary(ctx context.Context, w
|
|
|
|
|
return 0, nil, err
|
|
|
|
|
}
|
|
|
|
|
pInfo := response.Plugin
|
|
|
|
|
pluginMap[id] = &vo.PluginEntity{
|
|
|
|
|
pluginMap[id] = &plugin.PluginEntity{
|
|
|
|
|
PluginID: pInfo.ID,
|
|
|
|
|
PluginVersion: pInfo.Version,
|
|
|
|
|
}
|
|
|
|
|
@@ -957,7 +959,7 @@ func (w *ApplicationService) CopyWorkflowFromAppToLibrary(ctx context.Context, w
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
relatedWorkflows, vIssues, err := GetWorkflowDomainSVC().CopyWorkflowFromAppToLibrary(ctx, workflowID, appID, vo.ExternalResourceRelated{
|
|
|
|
|
relatedWorkflows, vIssues, err := GetWorkflowDomainSVC().CopyWorkflowFromAppToLibrary(ctx, workflowID, appID, plugin.ExternalResourceRelated{
|
|
|
|
|
PluginMap: pluginMap,
|
|
|
|
|
PluginToolMap: pluginToolMap,
|
|
|
|
|
KnowledgeMap: relatedKnowledgeMap,
|
|
|
|
|
@@ -997,13 +999,13 @@ func (w *ApplicationService) DuplicateWorkflowsByAppID(ctx context.Context, sour
|
|
|
|
|
}
|
|
|
|
|
}()
|
|
|
|
|
|
|
|
|
|
pluginMap := make(map[int64]*vo.PluginEntity)
|
|
|
|
|
pluginMap := make(map[int64]*plugin.PluginEntity)
|
|
|
|
|
for o, n := range externalResource.PluginMap {
|
|
|
|
|
pluginMap[o] = &vo.PluginEntity{
|
|
|
|
|
pluginMap[o] = &plugin.PluginEntity{
|
|
|
|
|
PluginID: n,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
externalResourceRelated := vo.ExternalResourceRelated{
|
|
|
|
|
externalResourceRelated := plugin.ExternalResourceRelated{
|
|
|
|
|
PluginMap: pluginMap,
|
|
|
|
|
PluginToolMap: externalResource.PluginToolMap,
|
|
|
|
|
KnowledgeMap: externalResource.KnowledgeMap,
|
|
|
|
|
@@ -1026,7 +1028,7 @@ func (w *ApplicationService) CopyWorkflowFromLibraryToApp(ctx context.Context, w
|
|
|
|
|
}
|
|
|
|
|
}()
|
|
|
|
|
|
|
|
|
|
wf, err := GetWorkflowDomainSVC().CopyWorkflow(ctx, workflowID, vo.CopyWorkflowPolicy{
|
|
|
|
|
wf, err := GetWorkflowDomainSVC().CopyWorkflow(ctx, workflowID, plugin.CopyWorkflowPolicy{
|
|
|
|
|
TargetAppID: &appID,
|
|
|
|
|
})
|
|
|
|
|
if err != nil {
|
|
|
|
|
@@ -1053,7 +1055,7 @@ func (w *ApplicationService) MoveWorkflowFromAppToLibrary(ctx context.Context, w
|
|
|
|
|
return 0, nil, err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pluginMap := make(map[int64]*vo.PluginEntity)
|
|
|
|
|
pluginMap := make(map[int64]*plugin.PluginEntity)
|
|
|
|
|
if len(ds.PluginIDs) > 0 {
|
|
|
|
|
for idx := range ds.PluginIDs {
|
|
|
|
|
id := ds.PluginIDs[idx]
|
|
|
|
|
@@ -1061,7 +1063,7 @@ func (w *ApplicationService) MoveWorkflowFromAppToLibrary(ctx context.Context, w
|
|
|
|
|
if err != nil {
|
|
|
|
|
return 0, nil, err
|
|
|
|
|
}
|
|
|
|
|
pluginMap[id] = &vo.PluginEntity{
|
|
|
|
|
pluginMap[id] = &plugin.PluginEntity{
|
|
|
|
|
PluginID: pInfo.ID,
|
|
|
|
|
PluginVersion: pInfo.Version,
|
|
|
|
|
}
|
|
|
|
|
@@ -1090,7 +1092,7 @@ func (w *ApplicationService) MoveWorkflowFromAppToLibrary(ctx context.Context, w
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
relatedWorkflows, vIssues, err := GetWorkflowDomainSVC().CopyWorkflowFromAppToLibrary(ctx, workflowID, appID, vo.ExternalResourceRelated{
|
|
|
|
|
relatedWorkflows, vIssues, err := GetWorkflowDomainSVC().CopyWorkflowFromAppToLibrary(ctx, workflowID, appID, plugin.ExternalResourceRelated{
|
|
|
|
|
PluginMap: pluginMap,
|
|
|
|
|
})
|
|
|
|
|
if err != nil {
|
|
|
|
|
@@ -1100,7 +1102,7 @@ func (w *ApplicationService) MoveWorkflowFromAppToLibrary(ctx context.Context, w
|
|
|
|
|
return 0, vIssues, nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
err = GetWorkflowDomainSVC().SyncRelatedWorkflowResources(ctx, appID, relatedWorkflows, vo.ExternalResourceRelated{
|
|
|
|
|
err = GetWorkflowDomainSVC().SyncRelatedWorkflowResources(ctx, appID, relatedWorkflows, plugin.ExternalResourceRelated{
|
|
|
|
|
PluginMap: pluginMap,
|
|
|
|
|
})
|
|
|
|
|
if err != nil {
|
|
|
|
|
@@ -1249,7 +1251,7 @@ func convertStreamRunEvent(workflowID int64) func(msg *entity.Message) (res *wor
|
|
|
|
|
return &workflow.OpenAPIStreamRunFlowResponse{
|
|
|
|
|
ID: strconv.Itoa(messageID),
|
|
|
|
|
Event: string(DoneEvent),
|
|
|
|
|
DebugUrl: ptr.Of(fmt.Sprintf(vo.DebugURLTpl, executeID, spaceID, workflowID)),
|
|
|
|
|
DebugUrl: ptr.Of(fmt.Sprintf(plugin.DebugURLTpl, executeID, spaceID, workflowID)),
|
|
|
|
|
}, nil
|
|
|
|
|
case entity.WorkflowFailed, entity.WorkflowCancel:
|
|
|
|
|
var wfe vo.WorkflowError
|
|
|
|
|
@@ -1259,7 +1261,7 @@ func convertStreamRunEvent(workflowID int64) func(msg *entity.Message) (res *wor
|
|
|
|
|
return &workflow.OpenAPIStreamRunFlowResponse{
|
|
|
|
|
ID: strconv.Itoa(messageID),
|
|
|
|
|
Event: string(ErrEvent),
|
|
|
|
|
DebugUrl: ptr.Of(fmt.Sprintf(vo.DebugURLTpl, executeID, spaceID, workflowID)),
|
|
|
|
|
DebugUrl: ptr.Of(fmt.Sprintf(plugin.DebugURLTpl, executeID, spaceID, workflowID)),
|
|
|
|
|
ErrorCode: ptr.Of(int64(wfe.Code())),
|
|
|
|
|
ErrorMessage: ptr.Of(wfe.Msg()),
|
|
|
|
|
}, nil
|
|
|
|
|
@@ -1268,7 +1270,7 @@ func convertStreamRunEvent(workflowID int64) func(msg *entity.Message) (res *wor
|
|
|
|
|
return &workflow.OpenAPIStreamRunFlowResponse{
|
|
|
|
|
ID: strconv.Itoa(messageID),
|
|
|
|
|
Event: string(InterruptEvent),
|
|
|
|
|
DebugUrl: ptr.Of(fmt.Sprintf(vo.DebugURLTpl, executeID, spaceID, workflowID)),
|
|
|
|
|
DebugUrl: ptr.Of(fmt.Sprintf(plugin.DebugURLTpl, executeID, spaceID, workflowID)),
|
|
|
|
|
InterruptData: &workflow.Interrupt{
|
|
|
|
|
EventID: fmt.Sprintf("%d/%d", executeID, msg.InterruptEvent.ID),
|
|
|
|
|
Type: workflow.InterruptType(msg.InterruptEvent.EventType),
|
|
|
|
|
@@ -1280,7 +1282,7 @@ func convertStreamRunEvent(workflowID int64) func(msg *entity.Message) (res *wor
|
|
|
|
|
return &workflow.OpenAPIStreamRunFlowResponse{
|
|
|
|
|
ID: strconv.Itoa(messageID),
|
|
|
|
|
Event: string(InterruptEvent),
|
|
|
|
|
DebugUrl: ptr.Of(fmt.Sprintf(vo.DebugURLTpl, executeID, spaceID, workflowID)),
|
|
|
|
|
DebugUrl: ptr.Of(fmt.Sprintf(plugin.DebugURLTpl, executeID, spaceID, workflowID)),
|
|
|
|
|
InterruptData: &workflow.Interrupt{
|
|
|
|
|
EventID: fmt.Sprintf("%d/%d", executeID, msg.InterruptEvent.ID),
|
|
|
|
|
Type: workflow.InterruptType(msg.InterruptEvent.ToolInterruptEvent.EventType),
|
|
|
|
|
@@ -1396,20 +1398,20 @@ func (w *ApplicationService) OpenAPIStreamRun(ctx context.Context, req *workflow
|
|
|
|
|
connectorID = apiKeyInfo.ConnectorID
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
exeCfg := vo.ExecuteConfig{
|
|
|
|
|
exeCfg := plugin.ExecuteConfig{
|
|
|
|
|
ID: meta.ID,
|
|
|
|
|
From: vo.FromSpecificVersion,
|
|
|
|
|
From: plugin.FromSpecificVersion,
|
|
|
|
|
Version: *meta.LatestPublishedVersion,
|
|
|
|
|
Operator: userID,
|
|
|
|
|
Mode: vo.ExecuteModeRelease,
|
|
|
|
|
Mode: plugin.ExecuteModeRelease,
|
|
|
|
|
AppID: appID,
|
|
|
|
|
AgentID: agentID,
|
|
|
|
|
ConnectorID: connectorID,
|
|
|
|
|
ConnectorUID: strconv.FormatInt(userID, 10),
|
|
|
|
|
TaskType: vo.TaskTypeForeground,
|
|
|
|
|
SyncPattern: vo.SyncPatternStream,
|
|
|
|
|
TaskType: plugin.TaskTypeForeground,
|
|
|
|
|
SyncPattern: plugin.SyncPatternStream,
|
|
|
|
|
InputFailFast: true,
|
|
|
|
|
BizType: vo.BizTypeWorkflow,
|
|
|
|
|
BizType: plugin.BizTypeWorkflow,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if exeCfg.AppID != nil && exeCfg.AgentID != nil {
|
|
|
|
|
@@ -1470,12 +1472,12 @@ func (w *ApplicationService) OpenAPIStreamResume(ctx context.Context, req *workf
|
|
|
|
|
connectorID = mustParseInt64(req.GetConnectorID())
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
sr, err := GetWorkflowDomainSVC().StreamResume(ctx, resumeReq, vo.ExecuteConfig{
|
|
|
|
|
sr, err := GetWorkflowDomainSVC().StreamResume(ctx, resumeReq, plugin.ExecuteConfig{
|
|
|
|
|
Operator: userID,
|
|
|
|
|
Mode: vo.ExecuteModeRelease,
|
|
|
|
|
Mode: plugin.ExecuteModeRelease,
|
|
|
|
|
ConnectorID: connectorID,
|
|
|
|
|
ConnectorUID: strconv.FormatInt(userID, 10),
|
|
|
|
|
BizType: vo.BizTypeWorkflow,
|
|
|
|
|
BizType: plugin.BizTypeWorkflow,
|
|
|
|
|
})
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
|
@@ -1545,18 +1547,18 @@ func (w *ApplicationService) OpenAPIRun(ctx context.Context, req *workflow.OpenA
|
|
|
|
|
connectorID = apiKeyInfo.ConnectorID
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
exeCfg := vo.ExecuteConfig{
|
|
|
|
|
exeCfg := plugin.ExecuteConfig{
|
|
|
|
|
ID: meta.ID,
|
|
|
|
|
From: vo.FromSpecificVersion,
|
|
|
|
|
From: plugin.FromSpecificVersion,
|
|
|
|
|
Version: *meta.LatestPublishedVersion,
|
|
|
|
|
Operator: userID,
|
|
|
|
|
Mode: vo.ExecuteModeRelease,
|
|
|
|
|
Mode: plugin.ExecuteModeRelease,
|
|
|
|
|
AppID: appID,
|
|
|
|
|
AgentID: agentID,
|
|
|
|
|
ConnectorID: connectorID,
|
|
|
|
|
ConnectorUID: strconv.FormatInt(userID, 10),
|
|
|
|
|
InputFailFast: true,
|
|
|
|
|
BizType: vo.BizTypeWorkflow,
|
|
|
|
|
BizType: plugin.BizTypeWorkflow,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if exeCfg.AppID != nil && exeCfg.AgentID != nil {
|
|
|
|
|
@@ -1564,8 +1566,8 @@ func (w *ApplicationService) OpenAPIRun(ctx context.Context, req *workflow.OpenA
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if req.GetIsAsync() {
|
|
|
|
|
exeCfg.SyncPattern = vo.SyncPatternAsync
|
|
|
|
|
exeCfg.TaskType = vo.TaskTypeBackground
|
|
|
|
|
exeCfg.SyncPattern = plugin.SyncPatternAsync
|
|
|
|
|
exeCfg.TaskType = plugin.TaskTypeBackground
|
|
|
|
|
exeID, err := GetWorkflowDomainSVC().AsyncExecute(ctx, exeCfg, parameters)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
|
@@ -1573,12 +1575,12 @@ func (w *ApplicationService) OpenAPIRun(ctx context.Context, req *workflow.OpenA
|
|
|
|
|
|
|
|
|
|
return &workflow.OpenAPIRunFlowResponse{
|
|
|
|
|
ExecuteID: ptr.Of(strconv.FormatInt(exeID, 10)),
|
|
|
|
|
DebugUrl: ptr.Of(fmt.Sprintf(vo.DebugURLTpl, exeID, meta.SpaceID, meta.ID)),
|
|
|
|
|
DebugUrl: ptr.Of(fmt.Sprintf(plugin.DebugURLTpl, exeID, meta.SpaceID, meta.ID)),
|
|
|
|
|
}, nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
exeCfg.SyncPattern = vo.SyncPatternSync
|
|
|
|
|
exeCfg.TaskType = vo.TaskTypeForeground
|
|
|
|
|
exeCfg.SyncPattern = plugin.SyncPatternSync
|
|
|
|
|
exeCfg.TaskType = plugin.TaskTypeForeground
|
|
|
|
|
wfExe, tPlan, err := GetWorkflowDomainSVC().SyncExecute(ctx, exeCfg, parameters)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
|
@@ -1609,7 +1611,7 @@ func (w *ApplicationService) OpenAPIRun(ctx context.Context, req *workflow.OpenA
|
|
|
|
|
return &workflow.OpenAPIRunFlowResponse{
|
|
|
|
|
Data: data,
|
|
|
|
|
ExecuteID: ptr.Of(strconv.FormatInt(wfExe.ID, 10)),
|
|
|
|
|
DebugUrl: ptr.Of(fmt.Sprintf(vo.DebugURLTpl, wfExe.ID, wfExe.SpaceID, meta.ID)),
|
|
|
|
|
DebugUrl: ptr.Of(fmt.Sprintf(plugin.DebugURLTpl, wfExe.ID, wfExe.SpaceID, meta.ID)),
|
|
|
|
|
Token: ptr.Of(wfExe.TokenInfo.InputTokens + wfExe.TokenInfo.OutputTokens),
|
|
|
|
|
Cost: ptr.Of("0.00000"),
|
|
|
|
|
}, nil
|
|
|
|
|
@@ -1649,11 +1651,11 @@ func (w *ApplicationService) OpenAPIGetWorkflowRunHistory(ctx context.Context, r
|
|
|
|
|
|
|
|
|
|
var runMode *workflow.WorkflowRunMode
|
|
|
|
|
switch exe.SyncPattern {
|
|
|
|
|
case vo.SyncPatternSync:
|
|
|
|
|
case plugin.SyncPatternSync:
|
|
|
|
|
runMode = ptr.Of(workflow.WorkflowRunMode_Sync)
|
|
|
|
|
case vo.SyncPatternAsync:
|
|
|
|
|
case plugin.SyncPatternAsync:
|
|
|
|
|
runMode = ptr.Of(workflow.WorkflowRunMode_Async)
|
|
|
|
|
case vo.SyncPatternStream:
|
|
|
|
|
case plugin.SyncPatternStream:
|
|
|
|
|
runMode = ptr.Of(workflow.WorkflowRunMode_Stream)
|
|
|
|
|
default:
|
|
|
|
|
}
|
|
|
|
|
@@ -1670,7 +1672,7 @@ func (w *ApplicationService) OpenAPIGetWorkflowRunHistory(ctx context.Context, r
|
|
|
|
|
LogID: ptr.Of(exe.LogID),
|
|
|
|
|
CreateTime: ptr.Of(exe.CreatedAt.Unix()),
|
|
|
|
|
UpdateTime: updateTime,
|
|
|
|
|
DebugUrl: ptr.Of(fmt.Sprintf(vo.DebugURLTpl, exe.ID, exe.SpaceID, exe.WorkflowID)),
|
|
|
|
|
DebugUrl: ptr.Of(fmt.Sprintf(plugin.DebugURLTpl, exe.ID, exe.SpaceID, exe.WorkflowID)),
|
|
|
|
|
Input: exe.Input,
|
|
|
|
|
Output: exe.Output,
|
|
|
|
|
Token: ptr.Of(exe.TokenInfo.InputTokens + exe.TokenInfo.OutputTokens),
|
|
|
|
|
@@ -1804,10 +1806,10 @@ func (w *ApplicationService) TestResume(ctx context.Context, req *workflow.Workf
|
|
|
|
|
EventID: mustParseInt64(req.GetEventID()),
|
|
|
|
|
ResumeData: req.GetData(),
|
|
|
|
|
}
|
|
|
|
|
err = GetWorkflowDomainSVC().AsyncResume(ctx, resumeReq, vo.ExecuteConfig{
|
|
|
|
|
err = GetWorkflowDomainSVC().AsyncResume(ctx, resumeReq, plugin.ExecuteConfig{
|
|
|
|
|
Operator: ptr.FromOrDefault(ctxutil.GetUIDFromCtx(ctx), 0),
|
|
|
|
|
Mode: vo.ExecuteModeDebug, // at this stage it could be debug or node debug, we will decide it within AsyncResume
|
|
|
|
|
BizType: vo.BizTypeWorkflow,
|
|
|
|
|
Mode: plugin.ExecuteModeDebug, // at this stage it could be debug or node debug, we will decide it within AsyncResume
|
|
|
|
|
BizType: plugin.BizTypeWorkflow,
|
|
|
|
|
Cancellable: true,
|
|
|
|
|
})
|
|
|
|
|
if err != nil {
|
|
|
|
|
@@ -2002,13 +2004,13 @@ func (w *ApplicationService) ListWorkflow(ctx context.Context, req *workflow.Get
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
status := req.GetStatus()
|
|
|
|
|
var qType vo.Locator
|
|
|
|
|
var qType plugin.Locator
|
|
|
|
|
if status == workflow.WorkFlowListStatus_UnPublished {
|
|
|
|
|
option.PublishStatus = ptr.Of(vo.UnPublished)
|
|
|
|
|
qType = vo.FromDraft
|
|
|
|
|
qType = plugin.FromDraft
|
|
|
|
|
} else if status == workflow.WorkFlowListStatus_HadPublished {
|
|
|
|
|
option.PublishStatus = ptr.Of(vo.HasPublished)
|
|
|
|
|
qType = vo.FromLatestVersion
|
|
|
|
|
qType = plugin.FromLatestVersion
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if len(req.GetName()) > 0 {
|
|
|
|
|
@@ -2076,9 +2078,9 @@ func (w *ApplicationService) ListWorkflow(ctx context.Context, req *workflow.Get
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if qType == vo.FromDraft {
|
|
|
|
|
if qType == plugin.FromDraft {
|
|
|
|
|
ww.UpdateTime = w.DraftMeta.Timestamp.Unix()
|
|
|
|
|
} else if qType == vo.FromLatestVersion || qType == vo.FromSpecificVersion {
|
|
|
|
|
} else if qType == plugin.FromLatestVersion || qType == plugin.FromSpecificVersion {
|
|
|
|
|
ww.UpdateTime = w.VersionMeta.VersionCreatedAt.Unix()
|
|
|
|
|
} else if w.UpdatedAt != nil {
|
|
|
|
|
ww.UpdateTime = w.UpdatedAt.Unix()
|
|
|
|
|
@@ -2163,7 +2165,7 @@ func (w *ApplicationService) GetWorkflowDetail(ctx context.Context, req *workflo
|
|
|
|
|
MetaQuery: vo.MetaQuery{
|
|
|
|
|
IDs: ids,
|
|
|
|
|
},
|
|
|
|
|
QType: vo.FromDraft,
|
|
|
|
|
QType: plugin.FromDraft,
|
|
|
|
|
MetaOnly: false,
|
|
|
|
|
})
|
|
|
|
|
if err != nil {
|
|
|
|
|
@@ -2269,7 +2271,7 @@ func (w *ApplicationService) GetWorkflowDetailInfo(ctx context.Context, req *wor
|
|
|
|
|
MetaQuery: vo.MetaQuery{
|
|
|
|
|
IDs: draftIDs,
|
|
|
|
|
},
|
|
|
|
|
QType: vo.FromDraft,
|
|
|
|
|
QType: plugin.FromDraft,
|
|
|
|
|
MetaOnly: false,
|
|
|
|
|
})
|
|
|
|
|
if err != nil {
|
|
|
|
|
@@ -2282,7 +2284,7 @@ func (w *ApplicationService) GetWorkflowDetailInfo(ctx context.Context, req *wor
|
|
|
|
|
MetaQuery: vo.MetaQuery{
|
|
|
|
|
IDs: versionIDs,
|
|
|
|
|
},
|
|
|
|
|
QType: vo.FromSpecificVersion,
|
|
|
|
|
QType: plugin.FromSpecificVersion,
|
|
|
|
|
MetaOnly: false,
|
|
|
|
|
Versions: id2Version,
|
|
|
|
|
})
|
|
|
|
|
@@ -2483,8 +2485,8 @@ func (w *ApplicationService) GetApiDetail(ctx context.Context, req *workflow.Get
|
|
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
toolInfoResponse, err := crossplugin.GetPluginService().GetPluginToolsInfo(ctx, &crossplugin.ToolsInfoRequest{
|
|
|
|
|
PluginEntity: crossplugin.Entity{
|
|
|
|
|
toolInfoResponse, err := crossplugin.DefaultSVC().GetPluginToolsInfo(ctx, &plugin.ToolsInfoRequest{
|
|
|
|
|
PluginEntity: plugin.PluginEntity{
|
|
|
|
|
PluginID: pluginID,
|
|
|
|
|
PluginVersion: req.PluginVersion,
|
|
|
|
|
},
|
|
|
|
|
@@ -2550,8 +2552,8 @@ func (w *ApplicationService) GetLLMNodeFCSettingDetail(ctx context.Context, req
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var (
|
|
|
|
|
pluginSvc = crossplugin.GetPluginService()
|
|
|
|
|
pluginToolsInfoReqs = make(map[int64]*crossplugin.ToolsInfoRequest)
|
|
|
|
|
pluginSvc = crossplugin.DefaultSVC()
|
|
|
|
|
pluginToolsInfoReqs = make(map[int64]*plugin.ToolsInfoRequest)
|
|
|
|
|
pluginDetailMap = make(map[string]*workflow.PluginDetail)
|
|
|
|
|
toolsDetailInfo = make(map[string]*workflow.APIDetail)
|
|
|
|
|
workflowDetailMap = make(map[string]*workflow.WorkflowDetail)
|
|
|
|
|
@@ -2573,8 +2575,8 @@ func (w *ApplicationService) GetLLMNodeFCSettingDetail(ctx context.Context, req
|
|
|
|
|
if r, ok := pluginToolsInfoReqs[pluginID]; ok {
|
|
|
|
|
r.ToolIDs = append(r.ToolIDs, toolID)
|
|
|
|
|
} else {
|
|
|
|
|
pluginToolsInfoReqs[pluginID] = &crossplugin.ToolsInfoRequest{
|
|
|
|
|
PluginEntity: crossplugin.Entity{
|
|
|
|
|
pluginToolsInfoReqs[pluginID] = &plugin.ToolsInfoRequest{
|
|
|
|
|
PluginEntity: plugin.PluginEntity{
|
|
|
|
|
PluginID: pluginID,
|
|
|
|
|
PluginVersion: pl.PluginVersion,
|
|
|
|
|
},
|
|
|
|
|
@@ -2655,7 +2657,7 @@ func (w *ApplicationService) GetLLMNodeFCSettingDetail(ctx context.Context, req
|
|
|
|
|
MetaQuery: vo.MetaQuery{
|
|
|
|
|
IDs: draftIDs,
|
|
|
|
|
},
|
|
|
|
|
QType: vo.FromDraft,
|
|
|
|
|
QType: plugin.FromDraft,
|
|
|
|
|
MetaOnly: false,
|
|
|
|
|
})
|
|
|
|
|
if err != nil {
|
|
|
|
|
@@ -2668,7 +2670,7 @@ func (w *ApplicationService) GetLLMNodeFCSettingDetail(ctx context.Context, req
|
|
|
|
|
MetaQuery: vo.MetaQuery{
|
|
|
|
|
IDs: versionIDs,
|
|
|
|
|
},
|
|
|
|
|
QType: vo.FromSpecificVersion,
|
|
|
|
|
QType: plugin.FromSpecificVersion,
|
|
|
|
|
MetaOnly: false,
|
|
|
|
|
Versions: id2Version,
|
|
|
|
|
})
|
|
|
|
|
@@ -2758,7 +2760,7 @@ func (w *ApplicationService) GetLLMNodeFCSettingsMerged(ctx context.Context, req
|
|
|
|
|
var fcPluginSetting *workflow.FCPluginSetting
|
|
|
|
|
if req.GetPluginFcSetting() != nil {
|
|
|
|
|
var (
|
|
|
|
|
pluginSvc = crossplugin.GetPluginService()
|
|
|
|
|
pluginSvc = crossplugin.DefaultSVC()
|
|
|
|
|
pluginFcSetting = req.GetPluginFcSetting()
|
|
|
|
|
isDraft = pluginFcSetting.GetIsDraft()
|
|
|
|
|
)
|
|
|
|
|
@@ -2773,8 +2775,8 @@ func (w *ApplicationService) GetLLMNodeFCSettingsMerged(ctx context.Context, req
|
|
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pluginReq := &crossplugin.ToolsInfoRequest{
|
|
|
|
|
PluginEntity: vo.PluginEntity{
|
|
|
|
|
pluginReq := &plugin.ToolsInfoRequest{
|
|
|
|
|
PluginEntity: plugin.PluginEntity{
|
|
|
|
|
PluginID: pluginID,
|
|
|
|
|
},
|
|
|
|
|
ToolIDs: []int64{toolID},
|
|
|
|
|
@@ -2815,7 +2817,7 @@ func (w *ApplicationService) GetLLMNodeFCSettingsMerged(ctx context.Context, req
|
|
|
|
|
|
|
|
|
|
policy := &vo.GetPolicy{
|
|
|
|
|
ID: wID,
|
|
|
|
|
QType: ternary.IFElse(len(setting.WorkflowVersion) == 0, vo.FromDraft, vo.FromSpecificVersion),
|
|
|
|
|
QType: ternary.IFElse(len(setting.WorkflowVersion) == 0, plugin.FromDraft, plugin.FromSpecificVersion),
|
|
|
|
|
Version: setting.WorkflowVersion,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -2890,7 +2892,7 @@ func (w *ApplicationService) GetPlaygroundPluginList(ctx context.Context, req *p
|
|
|
|
|
SpaceID: ptr.Of(req.GetSpaceID()),
|
|
|
|
|
PublishStatus: ptr.Of(vo.HasPublished),
|
|
|
|
|
},
|
|
|
|
|
QType: vo.FromLatestVersion,
|
|
|
|
|
QType: plugin.FromLatestVersion,
|
|
|
|
|
})
|
|
|
|
|
} else if req.GetPage() > 0 && req.GetSize() > 0 {
|
|
|
|
|
wfs, _, err = GetWorkflowDomainSVC().MGet(ctx, &vo.MGetPolicy{
|
|
|
|
|
@@ -2902,7 +2904,7 @@ func (w *ApplicationService) GetPlaygroundPluginList(ctx context.Context, req *p
|
|
|
|
|
SpaceID: ptr.Of(req.GetSpaceID()),
|
|
|
|
|
PublishStatus: ptr.Of(vo.HasPublished),
|
|
|
|
|
},
|
|
|
|
|
QType: vo.FromLatestVersion,
|
|
|
|
|
QType: plugin.FromLatestVersion,
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -2976,7 +2978,7 @@ func (w *ApplicationService) CopyWorkflow(ctx context.Context, req *workflow.Cop
|
|
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
wf, err := GetWorkflowDomainSVC().CopyWorkflow(ctx, workflowID, vo.CopyWorkflowPolicy{
|
|
|
|
|
wf, err := GetWorkflowDomainSVC().CopyWorkflow(ctx, workflowID, plugin.CopyWorkflowPolicy{
|
|
|
|
|
ShouldModifyWorkflowName: true,
|
|
|
|
|
})
|
|
|
|
|
if err != nil {
|
|
|
|
|
@@ -3042,7 +3044,7 @@ func (w *ApplicationService) GetHistorySchema(ctx context.Context, req *workflow
|
|
|
|
|
// get the workflow entity for that workflowID and commitID
|
|
|
|
|
policy := &vo.GetPolicy{
|
|
|
|
|
ID: workflowID,
|
|
|
|
|
QType: ternary.IFElse(len(exe.Version) > 0, vo.FromSpecificVersion, vo.FromDraft),
|
|
|
|
|
QType: ternary.IFElse(len(exe.Version) > 0, plugin.FromSpecificVersion, plugin.FromDraft),
|
|
|
|
|
Version: exe.Version,
|
|
|
|
|
CommitID: exe.CommitID,
|
|
|
|
|
}
|
|
|
|
|
@@ -3100,7 +3102,7 @@ func (w *ApplicationService) GetExampleWorkFlowList(ctx context.Context, req *wo
|
|
|
|
|
|
|
|
|
|
wfs, _, err := GetWorkflowDomainSVC().MGet(ctx, &vo.MGetPolicy{
|
|
|
|
|
MetaQuery: option,
|
|
|
|
|
QType: vo.FromDraft,
|
|
|
|
|
QType: plugin.FromDraft,
|
|
|
|
|
MetaOnly: false,
|
|
|
|
|
})
|
|
|
|
|
if err != nil {
|
|
|
|
|
@@ -3179,7 +3181,7 @@ func (w *ApplicationService) CopyWkTemplateApi(ctx context.Context, req *workflo
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
|
wf, err := GetWorkflowDomainSVC().CopyWorkflow(ctx, wid, vo.CopyWorkflowPolicy{
|
|
|
|
|
wf, err := GetWorkflowDomainSVC().CopyWorkflow(ctx, wid, plugin.CopyWorkflowPolicy{
|
|
|
|
|
ShouldModifyWorkflowName: true,
|
|
|
|
|
TargetSpaceID: ptr.Of(req.GetTargetSpaceID()),
|
|
|
|
|
TargetAppID: ptr.Of(int64(0)),
|
|
|
|
|
|