refactor(workflow): Move the variable component in the Workflow package into the common crossdomain package (#738)
This commit is contained in:
parent
5d98e8ef93
commit
dce313b8e3
|
|
@ -80,11 +80,11 @@ import (
|
||||||
search "github.com/coze-dev/coze-studio/backend/domain/search/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"
|
||||||
"github.com/coze-dev/coze-studio/backend/domain/workflow/crossdomain/variable"
|
|
||||||
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"
|
||||||
"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/service"
|
"github.com/coze-dev/coze-studio/backend/domain/workflow/service"
|
||||||
|
"github.com/coze-dev/coze-studio/backend/domain/workflow/variable"
|
||||||
|
mockvar "github.com/coze-dev/coze-studio/backend/domain/workflow/variable/varmock"
|
||||||
"github.com/coze-dev/coze-studio/backend/infra/contract/coderunner"
|
"github.com/coze-dev/coze-studio/backend/infra/contract/coderunner"
|
||||||
"github.com/coze-dev/coze-studio/backend/infra/contract/modelmgr"
|
"github.com/coze-dev/coze-studio/backend/infra/contract/modelmgr"
|
||||||
"github.com/coze-dev/coze-studio/backend/infra/impl/cache/redis"
|
"github.com/coze-dev/coze-studio/backend/infra/impl/cache/redis"
|
||||||
|
|
|
||||||
|
|
@ -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"
|
||||||
"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"
|
||||||
variables "github.com/coze-dev/coze-studio/backend/domain/memory/variables/service"
|
variables "github.com/coze-dev/coze-studio/backend/domain/memory/variables/service"
|
||||||
|
|
@ -33,7 +32,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"
|
||||||
|
|
||||||
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"
|
||||||
"github.com/coze-dev/coze-studio/backend/infra/contract/cache"
|
"github.com/coze-dev/coze-studio/backend/infra/contract/cache"
|
||||||
|
|
@ -75,8 +73,7 @@ func InitService(ctx context.Context, components *ServiceComponents) (*Applicati
|
||||||
workflow.SetRepository(workflowRepo)
|
workflow.SetRepository(workflowRepo)
|
||||||
|
|
||||||
workflowDomainSVC := service.NewWorkflowService(workflowRepo)
|
workflowDomainSVC := service.NewWorkflowService(workflowRepo)
|
||||||
crossvariable.SetVariableHandler(variable.NewVariableHandler(components.VariablesDomainSVC))
|
|
||||||
crossvariable.SetVariablesMetaGetter(variable.NewVariablesMetaGetter(components.VariablesDomainSVC))
|
|
||||||
code.SetCodeRunner(components.CodeRunner)
|
code.SetCodeRunner(components.CodeRunner)
|
||||||
callbacks.AppendGlobalHandlers(workflowservice.GetTokenCallbackHandler())
|
callbacks.AppendGlobalHandlers(workflowservice.GetTokenCallbackHandler())
|
||||||
setEventBus(components.DomainNotifier)
|
setEventBus(components.DomainNotifier)
|
||||||
|
|
|
||||||
|
|
@ -21,12 +21,18 @@ import (
|
||||||
|
|
||||||
"github.com/coze-dev/coze-studio/backend/api/model/crossdomain/variables"
|
"github.com/coze-dev/coze-studio/backend/api/model/crossdomain/variables"
|
||||||
"github.com/coze-dev/coze-studio/backend/api/model/data/variable/kvmemory"
|
"github.com/coze-dev/coze-studio/backend/api/model/data/variable/kvmemory"
|
||||||
|
"github.com/coze-dev/coze-studio/backend/api/model/data/variable/project_memory"
|
||||||
|
"github.com/coze-dev/coze-studio/backend/domain/memory/variables/entity"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// TODO (@fanlv): Parameter references need to be modified.
|
||||||
type Variables interface {
|
type Variables interface {
|
||||||
GetVariableInstance(ctx context.Context, e *variables.UserVariableMeta, keywords []string) ([]*kvmemory.KVItem, error)
|
GetVariableInstance(ctx context.Context, e *variables.UserVariableMeta, keywords []string) ([]*kvmemory.KVItem, error)
|
||||||
SetVariableInstance(ctx context.Context, e *variables.UserVariableMeta, items []*kvmemory.KVItem) ([]string, error)
|
SetVariableInstance(ctx context.Context, e *variables.UserVariableMeta, items []*kvmemory.KVItem) ([]string, error)
|
||||||
DecryptSysUUIDKey(ctx context.Context, encryptSysUUIDKey string) *variables.UserVariableMeta
|
DecryptSysUUIDKey(ctx context.Context, encryptSysUUIDKey string) *variables.UserVariableMeta
|
||||||
|
GetVariableChannelInstance(ctx context.Context, e *variables.UserVariableMeta, keywords []string, varChannel *project_memory.VariableChannel) ([]*kvmemory.KVItem, error)
|
||||||
|
GetProjectVariablesMeta(ctx context.Context, projectID, version string) (*entity.VariablesMeta, error)
|
||||||
|
GetAgentVariableMeta(ctx context.Context, agentID int64, version string) (*entity.VariablesMeta, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
var defaultSVC Variables
|
var defaultSVC Variables
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ import (
|
||||||
|
|
||||||
model "github.com/coze-dev/coze-studio/backend/api/model/crossdomain/variables"
|
model "github.com/coze-dev/coze-studio/backend/api/model/crossdomain/variables"
|
||||||
"github.com/coze-dev/coze-studio/backend/api/model/data/variable/kvmemory"
|
"github.com/coze-dev/coze-studio/backend/api/model/data/variable/kvmemory"
|
||||||
|
"github.com/coze-dev/coze-studio/backend/api/model/data/variable/project_memory"
|
||||||
crossvariables "github.com/coze-dev/coze-studio/backend/crossdomain/contract/variables"
|
crossvariables "github.com/coze-dev/coze-studio/backend/crossdomain/contract/variables"
|
||||||
"github.com/coze-dev/coze-studio/backend/domain/memory/variables/entity"
|
"github.com/coze-dev/coze-studio/backend/domain/memory/variables/entity"
|
||||||
variables "github.com/coze-dev/coze-studio/backend/domain/memory/variables/service"
|
variables "github.com/coze-dev/coze-studio/backend/domain/memory/variables/service"
|
||||||
|
|
@ -65,3 +65,16 @@ func (s *impl) DecryptSysUUIDKey(ctx context.Context, encryptSysUUIDKey string)
|
||||||
ConnectorID: m.ConnectorID,
|
ConnectorID: m.ConnectorID,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *impl) GetVariableChannelInstance(ctx context.Context, e *model.UserVariableMeta, keywords []string, varChannel *project_memory.VariableChannel) ([]*kvmemory.KVItem, error) {
|
||||||
|
m := entity.NewUserVariableMeta(e)
|
||||||
|
return s.DomainSVC.GetVariableChannelInstance(ctx, m, keywords, varChannel)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *impl) GetProjectVariablesMeta(ctx context.Context, projectID string, version string) (*entity.VariablesMeta, error) {
|
||||||
|
return s.DomainSVC.GetProjectVariablesMeta(ctx, projectID, version)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *impl) GetAgentVariableMeta(ctx context.Context, agentID int64, version string) (*entity.VariablesMeta, error) {
|
||||||
|
return s.DomainSVC.GetAgentVariableMeta(ctx, agentID, version)
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -23,12 +23,12 @@ import (
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"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/variable"
|
|
||||||
"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/convert"
|
"github.com/coze-dev/coze-studio/backend/domain/workflow/internal/canvas/convert"
|
||||||
"github.com/coze-dev/coze-studio/backend/domain/workflow/internal/nodes"
|
"github.com/coze-dev/coze-studio/backend/domain/workflow/internal/nodes"
|
||||||
"github.com/coze-dev/coze-studio/backend/domain/workflow/internal/schema"
|
"github.com/coze-dev/coze-studio/backend/domain/workflow/internal/schema"
|
||||||
|
"github.com/coze-dev/coze-studio/backend/domain/workflow/variable"
|
||||||
"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"
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,6 @@ import (
|
||||||
|
|
||||||
workflowModel "github.com/coze-dev/coze-studio/backend/api/model/crossdomain/workflow"
|
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/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/execute"
|
"github.com/coze-dev/coze-studio/backend/domain/workflow/internal/execute"
|
||||||
|
|
@ -37,6 +36,7 @@ import (
|
||||||
"github.com/coze-dev/coze-studio/backend/domain/workflow/internal/nodes/qa"
|
"github.com/coze-dev/coze-studio/backend/domain/workflow/internal/nodes/qa"
|
||||||
"github.com/coze-dev/coze-studio/backend/domain/workflow/internal/nodes/receiver"
|
"github.com/coze-dev/coze-studio/backend/domain/workflow/internal/nodes/receiver"
|
||||||
schema2 "github.com/coze-dev/coze-studio/backend/domain/workflow/internal/schema"
|
schema2 "github.com/coze-dev/coze-studio/backend/domain/workflow/internal/schema"
|
||||||
|
"github.com/coze-dev/coze-studio/backend/domain/workflow/variable"
|
||||||
"github.com/coze-dev/coze-studio/backend/pkg/sonic"
|
"github.com/coze-dev/coze-studio/backend/pkg/sonic"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,11 +21,11 @@ import (
|
||||||
|
|
||||||
"github.com/cloudwego/eino/compose"
|
"github.com/cloudwego/eino/compose"
|
||||||
|
|
||||||
"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"
|
||||||
"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/nodes"
|
"github.com/coze-dev/coze-studio/backend/domain/workflow/internal/nodes"
|
||||||
"github.com/coze-dev/coze-studio/backend/domain/workflow/internal/schema"
|
"github.com/coze-dev/coze-studio/backend/domain/workflow/internal/schema"
|
||||||
|
"github.com/coze-dev/coze-studio/backend/domain/workflow/variable"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Break struct {
|
type Break struct {
|
||||||
|
|
|
||||||
|
|
@ -21,11 +21,10 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/coze-dev/coze-studio/backend/domain/workflow/crossdomain/variable"
|
|
||||||
|
|
||||||
"github.com/cloudwego/eino/compose"
|
"github.com/cloudwego/eino/compose"
|
||||||
|
|
||||||
"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/variable"
|
||||||
)
|
)
|
||||||
|
|
||||||
type ParentIntermediateStore struct {
|
type ParentIntermediateStore struct {
|
||||||
|
|
|
||||||
|
|
@ -24,13 +24,13 @@ import (
|
||||||
|
|
||||||
"github.com/cloudwego/eino/compose"
|
"github.com/cloudwego/eino/compose"
|
||||||
|
|
||||||
"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"
|
||||||
"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/convert"
|
"github.com/coze-dev/coze-studio/backend/domain/workflow/internal/canvas/convert"
|
||||||
"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"
|
||||||
"github.com/coze-dev/coze-studio/backend/domain/workflow/internal/schema"
|
"github.com/coze-dev/coze-studio/backend/domain/workflow/internal/schema"
|
||||||
|
"github.com/coze-dev/coze-studio/backend/domain/workflow/variable"
|
||||||
"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/types/errno"
|
"github.com/coze-dev/coze-studio/backend/types/errno"
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -22,12 +22,12 @@ import (
|
||||||
|
|
||||||
einoCompose "github.com/cloudwego/eino/compose"
|
einoCompose "github.com/cloudwego/eino/compose"
|
||||||
|
|
||||||
"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"
|
||||||
"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/convert"
|
"github.com/coze-dev/coze-studio/backend/domain/workflow/internal/canvas/convert"
|
||||||
"github.com/coze-dev/coze-studio/backend/domain/workflow/internal/nodes"
|
"github.com/coze-dev/coze-studio/backend/domain/workflow/internal/nodes"
|
||||||
"github.com/coze-dev/coze-studio/backend/domain/workflow/internal/schema"
|
"github.com/coze-dev/coze-studio/backend/domain/workflow/internal/schema"
|
||||||
|
"github.com/coze-dev/coze-studio/backend/domain/workflow/variable"
|
||||||
)
|
)
|
||||||
|
|
||||||
type InLoopConfig struct {
|
type InLoopConfig struct {
|
||||||
|
|
|
||||||
|
|
@ -23,10 +23,10 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
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/domain/workflow/crossdomain/variable"
|
|
||||||
"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"
|
||||||
"github.com/coze-dev/coze-studio/backend/domain/workflow/internal/canvas/validate"
|
"github.com/coze-dev/coze-studio/backend/domain/workflow/internal/canvas/validate"
|
||||||
|
"github.com/coze-dev/coze-studio/backend/domain/workflow/variable"
|
||||||
"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"
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -28,10 +28,7 @@ import (
|
||||||
var variableHandlerSingleton *Handler
|
var variableHandlerSingleton *Handler
|
||||||
|
|
||||||
func GetVariableHandler() *Handler {
|
func GetVariableHandler() *Handler {
|
||||||
return variableHandlerSingleton
|
return NewVariableHandler()
|
||||||
}
|
|
||||||
func SetVariableHandler(handler *Handler) {
|
|
||||||
variableHandlerSingleton = handler
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type Handler struct {
|
type Handler struct {
|
||||||
|
|
@ -111,11 +108,7 @@ type Store interface {
|
||||||
var variablesMetaGetterImpl VariablesMetaGetter
|
var variablesMetaGetterImpl VariablesMetaGetter
|
||||||
|
|
||||||
func GetVariablesMetaGetter() VariablesMetaGetter {
|
func GetVariablesMetaGetter() VariablesMetaGetter {
|
||||||
return variablesMetaGetterImpl
|
return NewVariablesMetaGetter()
|
||||||
}
|
|
||||||
|
|
||||||
func SetVariablesMetaGetter(v VariablesMetaGetter) {
|
|
||||||
variablesMetaGetterImpl = v
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type VariablesMetaGetter interface {
|
type VariablesMetaGetter interface {
|
||||||
|
|
@ -23,60 +23,53 @@ import (
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/bytedance/sonic"
|
"github.com/bytedance/sonic"
|
||||||
|
|
||||||
"github.com/cloudwego/eino/compose"
|
"github.com/cloudwego/eino/compose"
|
||||||
|
|
||||||
variablesModel "github.com/coze-dev/coze-studio/backend/api/model/crossdomain/variables"
|
variablesModel "github.com/coze-dev/coze-studio/backend/api/model/crossdomain/variables"
|
||||||
"github.com/coze-dev/coze-studio/backend/api/model/data/variable/kvmemory"
|
"github.com/coze-dev/coze-studio/backend/api/model/data/variable/kvmemory"
|
||||||
"github.com/coze-dev/coze-studio/backend/api/model/data/variable/project_memory"
|
"github.com/coze-dev/coze-studio/backend/api/model/data/variable/project_memory"
|
||||||
|
crossvariables "github.com/coze-dev/coze-studio/backend/crossdomain/contract/variables"
|
||||||
"github.com/coze-dev/coze-studio/backend/domain/memory/variables/entity"
|
"github.com/coze-dev/coze-studio/backend/domain/memory/variables/entity"
|
||||||
variables "github.com/coze-dev/coze-studio/backend/domain/memory/variables/service"
|
|
||||||
"github.com/coze-dev/coze-studio/backend/domain/workflow/crossdomain/variable"
|
|
||||||
"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/types/errno"
|
|
||||||
|
|
||||||
"github.com/coze-dev/coze-studio/backend/pkg/lang/ternary"
|
"github.com/coze-dev/coze-studio/backend/pkg/lang/ternary"
|
||||||
|
"github.com/coze-dev/coze-studio/backend/types/errno"
|
||||||
)
|
)
|
||||||
|
|
||||||
type varStore struct {
|
type varStore struct {
|
||||||
variableChannel project_memory.VariableChannel
|
variableChannel project_memory.VariableChannel
|
||||||
vs variables.Variables
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewVariableHandler(vs variables.Variables) *variable.Handler {
|
func NewVariableHandler() *Handler {
|
||||||
return &variable.Handler{
|
return &Handler{
|
||||||
UserVarStore: newUserVarStore(vs),
|
UserVarStore: newUserVarStore(),
|
||||||
AppVarStore: newAppVarStore(vs),
|
AppVarStore: newAppVarStore(),
|
||||||
SystemVarStore: newSystemVarStore(vs),
|
SystemVarStore: newSystemVarStore(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func newUserVarStore(vs variables.Variables) variable.Store {
|
func newUserVarStore() Store {
|
||||||
return &varStore{
|
return &varStore{
|
||||||
variableChannel: project_memory.VariableChannel_Custom,
|
variableChannel: project_memory.VariableChannel_Custom,
|
||||||
vs: vs,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func newAppVarStore(vs variables.Variables) variable.Store {
|
func newAppVarStore() Store {
|
||||||
return &varStore{
|
return &varStore{
|
||||||
variableChannel: project_memory.VariableChannel_APP,
|
variableChannel: project_memory.VariableChannel_APP,
|
||||||
vs: vs,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func newSystemVarStore(vs variables.Variables) variable.Store {
|
func newSystemVarStore() Store {
|
||||||
return &varStore{
|
return &varStore{
|
||||||
variableChannel: project_memory.VariableChannel_System,
|
variableChannel: project_memory.VariableChannel_System,
|
||||||
vs: vs,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *varStore) Init(ctx context.Context) {
|
func (v *varStore) Init(ctx context.Context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *varStore) Get(ctx context.Context, path compose.FieldPath, opts ...variable.OptionFn) (any, error) {
|
func (v *varStore) Get(ctx context.Context, path compose.FieldPath, opts ...OptionFn) (any, error) {
|
||||||
opt := &variable.StoreConfig{}
|
opt := &StoreConfig{}
|
||||||
for _, o := range opts {
|
for _, o := range opts {
|
||||||
o(opt)
|
o(opt)
|
||||||
}
|
}
|
||||||
|
|
@ -96,17 +89,17 @@ func (v *varStore) Get(ctx context.Context, path compose.FieldPath, opts ...vari
|
||||||
return nil, fmt.Errorf("there must be one of the App ID or Agent ID")
|
return nil, fmt.Errorf("there must be one of the App ID or Agent ID")
|
||||||
}
|
}
|
||||||
|
|
||||||
meta := entity.NewUserVariableMeta(&variablesModel.UserVariableMeta{
|
meta := &variablesModel.UserVariableMeta{
|
||||||
BizType: bizType,
|
BizType: bizType,
|
||||||
BizID: bizID,
|
BizID: bizID,
|
||||||
ConnectorID: opt.StoreInfo.ConnectorID,
|
ConnectorID: opt.StoreInfo.ConnectorID,
|
||||||
ConnectorUID: opt.StoreInfo.ConnectorUID,
|
ConnectorUID: opt.StoreInfo.ConnectorUID,
|
||||||
})
|
}
|
||||||
if len(path) == 0 {
|
if len(path) == 0 {
|
||||||
return nil, errors.New("field path is required")
|
return nil, errors.New("field path is required")
|
||||||
}
|
}
|
||||||
key := path[0]
|
key := path[0]
|
||||||
kvItems, err := v.vs.GetVariableChannelInstance(ctx, meta, []string{key}, project_memory.VariableChannelPtr(v.variableChannel))
|
kvItems, err := crossvariables.DefaultSVC().GetVariableChannelInstance(ctx, meta, []string{key}, project_memory.VariableChannelPtr(v.variableChannel))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
@ -194,8 +187,8 @@ func (v *varStore) Get(ctx context.Context, path compose.FieldPath, opts ...vari
|
||||||
return value, nil
|
return value, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *varStore) Set(ctx context.Context, path compose.FieldPath, value any, opts ...variable.OptionFn) (err error) {
|
func (v *varStore) Set(ctx context.Context, path compose.FieldPath, value any, opts ...OptionFn) (err error) {
|
||||||
opt := &variable.StoreConfig{}
|
opt := &StoreConfig{}
|
||||||
for _, o := range opts {
|
for _, o := range opts {
|
||||||
o(opt)
|
o(opt)
|
||||||
}
|
}
|
||||||
|
|
@ -215,12 +208,12 @@ func (v *varStore) Set(ctx context.Context, path compose.FieldPath, value any, o
|
||||||
return fmt.Errorf("there must be one of the App ID or Agent ID")
|
return fmt.Errorf("there must be one of the App ID or Agent ID")
|
||||||
}
|
}
|
||||||
|
|
||||||
meta := entity.NewUserVariableMeta(&variablesModel.UserVariableMeta{
|
meta := &variablesModel.UserVariableMeta{
|
||||||
BizType: bizType,
|
BizType: bizType,
|
||||||
BizID: bizID,
|
BizID: bizID,
|
||||||
ConnectorID: opt.StoreInfo.ConnectorID,
|
ConnectorID: opt.StoreInfo.ConnectorID,
|
||||||
ConnectorUID: opt.StoreInfo.ConnectorUID,
|
ConnectorUID: opt.StoreInfo.ConnectorUID,
|
||||||
})
|
}
|
||||||
|
|
||||||
if len(path) == 0 {
|
if len(path) == 0 {
|
||||||
return errors.New("field path is required")
|
return errors.New("field path is required")
|
||||||
|
|
@ -246,7 +239,7 @@ func (v *varStore) Set(ctx context.Context, path compose.FieldPath, value any, o
|
||||||
IsSystem: isSystem,
|
IsSystem: isSystem,
|
||||||
})
|
})
|
||||||
|
|
||||||
_, err = v.vs.SetVariableInstance(ctx, meta, kvItems)
|
_, err = crossvariables.DefaultSVC().SetVariableInstance(ctx, meta, kvItems)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
@ -255,18 +248,15 @@ func (v *varStore) Set(ctx context.Context, path compose.FieldPath, value any, o
|
||||||
}
|
}
|
||||||
|
|
||||||
type variablesMetaGetter struct {
|
type variablesMetaGetter struct {
|
||||||
vs variables.Variables
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewVariablesMetaGetter(vs variables.Variables) variable.VariablesMetaGetter {
|
func NewVariablesMetaGetter() VariablesMetaGetter {
|
||||||
return &variablesMetaGetter{
|
return &variablesMetaGetter{}
|
||||||
vs: vs,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v variablesMetaGetter) GetAppVariablesMeta(ctx context.Context, id, version string) (m map[string]*vo.TypeInfo, err error) {
|
func (v variablesMetaGetter) GetAppVariablesMeta(ctx context.Context, id, version string) (m map[string]*vo.TypeInfo, err error) {
|
||||||
var varMetas *entity.VariablesMeta
|
var varMetas *entity.VariablesMeta
|
||||||
varMetas, err = v.vs.GetProjectVariablesMeta(ctx, id, version)
|
varMetas, err = crossvariables.DefaultSVC().GetProjectVariablesMeta(ctx, id, version)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
@ -291,7 +281,7 @@ func (v variablesMetaGetter) GetAppVariablesMeta(ctx context.Context, id, versio
|
||||||
|
|
||||||
func (v variablesMetaGetter) GetAgentVariablesMeta(ctx context.Context, id int64, version string) (m map[string]*vo.TypeInfo, err error) {
|
func (v variablesMetaGetter) GetAgentVariablesMeta(ctx context.Context, id int64, version string) (m map[string]*vo.TypeInfo, err error) {
|
||||||
var varMetas *entity.VariablesMeta
|
var varMetas *entity.VariablesMeta
|
||||||
varMetas, err = v.vs.GetAgentVariableMeta(ctx, id, version)
|
varMetas, err = crossvariables.DefaultSVC().GetAgentVariableMeta(ctx, id, version)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
@ -1,19 +1,3 @@
|
||||||
/*
|
|
||||||
* 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.
|
// Code generated by MockGen. DO NOT EDIT.
|
||||||
// Source: variable.go
|
// Source: variable.go
|
||||||
//
|
//
|
||||||
|
|
@ -29,9 +13,9 @@ import (
|
||||||
context "context"
|
context "context"
|
||||||
reflect "reflect"
|
reflect "reflect"
|
||||||
|
|
||||||
variable "github.com/coze-dev/coze-studio/backend/domain/workflow/crossdomain/variable"
|
|
||||||
vo "github.com/coze-dev/coze-studio/backend/domain/workflow/entity/vo"
|
|
||||||
compose "github.com/cloudwego/eino/compose"
|
compose "github.com/cloudwego/eino/compose"
|
||||||
|
vo "github.com/coze-dev/coze-studio/backend/domain/workflow/entity/vo"
|
||||||
|
variable "github.com/coze-dev/coze-studio/backend/domain/workflow/variable"
|
||||||
gomock "go.uber.org/mock/gomock"
|
gomock "go.uber.org/mock/gomock"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -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="127.0.0.1:8888"
|
export LISTEN_ADDR=":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="127.0.0.1:8888"
|
export LISTEN_ADDR=":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}"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue