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

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

View File

@@ -16,6 +16,10 @@
package vo
import (
model "github.com/coze-dev/coze-studio/backend/api/model/crossdomain/plugin"
)
type Page struct {
Size int32 `json:"size"`
Page int32 `json:"page"`
@@ -51,17 +55,9 @@ type QueryToolInfoOption struct {
IDs []int64
}
type Locator uint8
const (
FromDraft Locator = iota
FromSpecificVersion
FromLatestVersion
)
type GetPolicy struct {
ID int64
QType Locator
QType model.Locator
MetaOnly bool
Version string
CommitID string
@@ -76,7 +72,7 @@ type DeletePolicy struct {
type MGetPolicy struct {
MetaQuery
QType Locator
QType model.Locator
MetaOnly bool
Versions map[int64]string
}

View File

@@ -1,67 +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 vo
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"
)

View File

@@ -23,6 +23,7 @@ import (
"github.com/cloudwego/eino/compose"
"github.com/cloudwego/eino/schema"
"github.com/coze-dev/coze-studio/backend/api/model/crossdomain/plugin"
"github.com/coze-dev/coze-studio/backend/pkg/errorx"
"github.com/coze-dev/coze-studio/backend/pkg/sonic"
"github.com/coze-dev/coze-studio/backend/types/errno"
@@ -92,7 +93,7 @@ type wfErr struct {
func (w *wfErr) DebugURL() string {
if w.StatusError.Extra() == nil {
return fmt.Sprintf(DebugURLTpl, w.exeID, w.spaceID, w.workflowID)
return fmt.Sprintf(plugin.DebugURLTpl, w.exeID, w.spaceID, w.workflowID)
}
debugURL, ok := w.StatusError.Extra()["debug_url"]
@@ -100,7 +101,7 @@ func (w *wfErr) DebugURL() string {
return debugURL
}
return fmt.Sprintf(DebugURLTpl, w.exeID, w.spaceID, w.workflowID)
return fmt.Sprintf(plugin.DebugURLTpl, w.exeID, w.spaceID, w.workflowID)
}
func (w *wfErr) Level() ErrorLevel {
@@ -169,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 {
debugURL := fmt.Sprintf(DebugURLTpl, exeID, spaceID, workflowID)
debugURL := fmt.Sprintf(plugin.DebugURLTpl, exeID, spaceID, workflowID)
opts = append(opts, errorx.Extra("debug_url", debugURL))
return WrapError(code, err, opts...)
}

View File

@@ -1,43 +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 vo
type PluginEntity struct {
PluginID int64
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
}

View File

@@ -19,8 +19,8 @@ package entity
import (
"time"
model "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/domain/workflow/entity/vo"
)
type WorkflowExecuteStatus workflow.WorkflowExeStatus
@@ -31,7 +31,7 @@ type WorkflowExecution struct {
WorkflowID int64
Version string
SpaceID int64
vo.ExecuteConfig
model.ExecuteConfig
CreatedAt time.Time
LogID string
NodeCount int32