chore(plugin): move interface request to dto pkg (#2242)
This commit is contained in:
@ -56,8 +56,6 @@ import (
|
||||
modelknowledge "github.com/coze-dev/coze-studio/backend/api/model/crossdomain/knowledge"
|
||||
"github.com/coze-dev/coze-studio/backend/api/model/crossdomain/message"
|
||||
model "github.com/coze-dev/coze-studio/backend/api/model/crossdomain/modelmgr"
|
||||
plugin2 "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"
|
||||
pluginAPI "github.com/coze-dev/coze-studio/backend/api/model/plugin_develop"
|
||||
@ -81,6 +79,7 @@ import (
|
||||
crossmodelmgr "github.com/coze-dev/coze-studio/backend/crossdomain/contract/modelmgr"
|
||||
mockmodel "github.com/coze-dev/coze-studio/backend/crossdomain/contract/modelmgr/modelmock"
|
||||
crossplugin "github.com/coze-dev/coze-studio/backend/crossdomain/contract/plugin"
|
||||
pluginmodel "github.com/coze-dev/coze-studio/backend/crossdomain/contract/plugin/dto"
|
||||
"github.com/coze-dev/coze-studio/backend/crossdomain/contract/plugin/pluginmock"
|
||||
crossuser "github.com/coze-dev/coze-studio/backend/crossdomain/contract/user"
|
||||
"github.com/coze-dev/coze-studio/backend/crossdomain/impl/code"
|
||||
@ -90,6 +89,7 @@ import (
|
||||
msgentity "github.com/coze-dev/coze-studio/backend/domain/conversation/message/entity"
|
||||
entity4 "github.com/coze-dev/coze-studio/backend/domain/memory/database/entity"
|
||||
entity2 "github.com/coze-dev/coze-studio/backend/domain/openauth/openapiauth/entity"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/plugin/dto"
|
||||
entity3 "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"
|
||||
@ -2961,16 +2961,16 @@ func TestLLMWithSkills(t *testing.T) {
|
||||
}
|
||||
r.modelManage.EXPECT().GetModel(gomock.Any(), gomock.Any()).Return(utChatModel, nil, nil).AnyTimes()
|
||||
|
||||
r.plugin.EXPECT().ExecuteTool(gomock.Any(), gomock.Any(), gomock.Any()).Return(&plugin2.ExecuteToolResponse{
|
||||
r.plugin.EXPECT().ExecuteTool(gomock.Any(), gomock.Any(), gomock.Any()).Return(&pluginmodel.ExecuteToolResponse{
|
||||
TrimmedResp: `{"data":"ok","err_msg":"error","data_structural":{"content":"ok","title":"title","weburl":"weburl"}}`,
|
||||
}, nil).AnyTimes()
|
||||
|
||||
r.plugin.EXPECT().MGetOnlinePlugins(gomock.Any(), gomock.Any()).Return([]*entity3.PluginInfo{
|
||||
{PluginInfo: &plugin2.PluginInfo{ID: 7509353177339133952}},
|
||||
{PluginInfo: &pluginmodel.PluginInfo{ID: 7509353177339133952}},
|
||||
}, nil).AnyTimes()
|
||||
|
||||
r.plugin.EXPECT().MGetDraftPlugins(gomock.Any(), gomock.Any()).Return([]*entity3.PluginInfo{{
|
||||
PluginInfo: &plugin2.PluginInfo{ID: 7509353177339133952},
|
||||
PluginInfo: &pluginmodel.PluginInfo{ID: 7509353177339133952},
|
||||
}}, nil).AnyTimes()
|
||||
|
||||
operationString := `{
|
||||
@ -3041,7 +3041,7 @@ func TestLLMWithSkills(t *testing.T) {
|
||||
}
|
||||
}`
|
||||
|
||||
operation := &plugin2.Openapi3Operation{}
|
||||
operation := &pluginmodel.Openapi3Operation{}
|
||||
_ = sonic.UnmarshalString(operationString, operation)
|
||||
|
||||
r.plugin.EXPECT().MGetOnlineTools(gomock.Any(), gomock.Any()).Return([]*entity3.ToolInfo{
|
||||
@ -3569,7 +3569,7 @@ func TestGetLLMNodeFCSettingsDetailAndMerged(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}`
|
||||
operation := &plugin2.Openapi3Operation{}
|
||||
operation := &pluginmodel.Openapi3Operation{}
|
||||
_ = sonic.UnmarshalString(operationString, operation)
|
||||
|
||||
r := newWfTestRunner(t)
|
||||
@ -3577,11 +3577,11 @@ func TestGetLLMNodeFCSettingsDetailAndMerged(t *testing.T) {
|
||||
|
||||
r.plugin.EXPECT().MGetOnlinePlugins(gomock.Any(), gomock.Any()).Return([]*entity3.PluginInfo{
|
||||
{
|
||||
PluginInfo: &plugin2.PluginInfo{
|
||||
PluginInfo: &pluginmodel.PluginInfo{
|
||||
ID: 123,
|
||||
SpaceID: 123,
|
||||
Version: ptr.Of("v0.0.1"),
|
||||
Manifest: &plugin2.PluginManifest{NameForHuman: "p1", DescriptionForHuman: "desc"},
|
||||
Manifest: &pluginmodel.PluginManifest{NameForHuman: "p1", DescriptionForHuman: "desc"},
|
||||
},
|
||||
},
|
||||
}, nil).AnyTimes()
|
||||
@ -3687,18 +3687,18 @@ func TestGetLLMNodeFCSettingsDetailAndMerged(t *testing.T) {
|
||||
}
|
||||
}`
|
||||
|
||||
operation := &plugin2.Openapi3Operation{}
|
||||
operation := &pluginmodel.Openapi3Operation{}
|
||||
_ = sonic.UnmarshalString(operationString, operation)
|
||||
r := newWfTestRunner(t)
|
||||
defer r.closeFn()
|
||||
|
||||
r.plugin.EXPECT().MGetOnlinePlugins(gomock.Any(), gomock.Any()).Return([]*entity3.PluginInfo{
|
||||
{
|
||||
PluginInfo: &plugin2.PluginInfo{
|
||||
PluginInfo: &pluginmodel.PluginInfo{
|
||||
ID: 123,
|
||||
SpaceID: 123,
|
||||
Version: ptr.Of("v0.0.1"),
|
||||
Manifest: &plugin2.PluginManifest{NameForHuman: "p1", DescriptionForHuman: "desc"},
|
||||
Manifest: &pluginmodel.PluginManifest{NameForHuman: "p1", DescriptionForHuman: "desc"},
|
||||
},
|
||||
},
|
||||
}, nil).AnyTimes()
|
||||
@ -4347,7 +4347,7 @@ func TestCopyWorkflowAppToLibrary(t *testing.T) {
|
||||
|
||||
defer mockey.Mock((*appmemory.DatabaseApplicationService).CopyDatabase).To(mockCopyDatabase).Build().UnPatch()
|
||||
|
||||
defer mockey.Mock((*appplugin.PluginApplicationService).CopyPlugin).Return(&appplugin.CopyPluginResponse{
|
||||
defer mockey.Mock((*appplugin.PluginApplicationService).CopyPlugin).Return(&dto.CopyPluginResponse{
|
||||
Plugin: &entity5.PluginInfo{
|
||||
PluginInfo: &pluginmodel.PluginInfo{
|
||||
ID: 100100,
|
||||
@ -4450,7 +4450,7 @@ func TestCopyWorkflowAppToLibrary(t *testing.T) {
|
||||
|
||||
defer mockey.Mock((*appmemory.DatabaseApplicationService).CopyDatabase).To(mockCopyDatabase).Build().UnPatch()
|
||||
|
||||
defer mockey.Mock((*appplugin.PluginApplicationService).CopyPlugin).Return(&appplugin.CopyPluginResponse{
|
||||
defer mockey.Mock((*appplugin.PluginApplicationService).CopyPlugin).Return(&dto.CopyPluginResponse{
|
||||
Plugin: &entity5.PluginInfo{
|
||||
PluginInfo: &pluginmodel.PluginInfo{
|
||||
ID: time.Now().Unix(),
|
||||
|
||||
@ -22,7 +22,7 @@ import (
|
||||
|
||||
"github.com/coze-dev/coze-studio/backend/api/model/app/bot_common"
|
||||
"github.com/coze-dev/coze-studio/backend/api/model/crossdomain/agentrun"
|
||||
"github.com/coze-dev/coze-studio/backend/api/model/crossdomain/plugin"
|
||||
plugindto "github.com/coze-dev/coze-studio/backend/crossdomain/contract/plugin/dto"
|
||||
crossworkflow "github.com/coze-dev/coze-studio/backend/crossdomain/contract/workflow"
|
||||
)
|
||||
|
||||
@ -95,7 +95,7 @@ const (
|
||||
)
|
||||
|
||||
type InterruptInfo struct {
|
||||
AllToolInterruptData map[string]*plugin.ToolInterruptEvent
|
||||
AllToolInterruptData map[string]*plugindto.ToolInterruptEvent
|
||||
AllWfInterruptData map[string]*crossworkflow.ToolInterruptEvent
|
||||
ToolCallID string
|
||||
InterruptType InterruptEventType
|
||||
|
||||
@ -34,7 +34,6 @@ import (
|
||||
taskAPI "github.com/coze-dev/coze-studio/backend/api/model/app/intelligence/task"
|
||||
connectorModel "github.com/coze-dev/coze-studio/backend/api/model/crossdomain/connector"
|
||||
knowledgeModel "github.com/coze-dev/coze-studio/backend/api/model/crossdomain/knowledge"
|
||||
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/data/variable/project_memory"
|
||||
"github.com/coze-dev/coze-studio/backend/api/model/playground"
|
||||
@ -46,11 +45,13 @@ import (
|
||||
"github.com/coze-dev/coze-studio/backend/application/memory"
|
||||
"github.com/coze-dev/coze-studio/backend/application/plugin"
|
||||
"github.com/coze-dev/coze-studio/backend/application/workflow"
|
||||
pluginModel "github.com/coze-dev/coze-studio/backend/crossdomain/contract/plugin/dto"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/app/entity"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/app/repository"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/app/service"
|
||||
connector "github.com/coze-dev/coze-studio/backend/domain/connector/service"
|
||||
variables "github.com/coze-dev/coze-studio/backend/domain/memory/variables/service"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/plugin/dto"
|
||||
searchEntity "github.com/coze-dev/coze-studio/backend/domain/search/entity"
|
||||
search "github.com/coze-dev/coze-studio/backend/domain/search/service"
|
||||
user "github.com/coze-dev/coze-studio/backend/domain/user/service"
|
||||
@ -790,7 +791,7 @@ func pluginCopyDispatchHandler(ctx context.Context, metaInfo *copyMetaInfo, res
|
||||
}
|
||||
}
|
||||
|
||||
func copyPlugin(ctx context.Context, metaInfo *copyMetaInfo, res *entity.Resource) (resp *plugin.CopyPluginResponse, err error) {
|
||||
func copyPlugin(ctx context.Context, metaInfo *copyMetaInfo, res *entity.Resource) (resp *dto.CopyPluginResponse, err error) {
|
||||
var copyScene pluginModel.CopyScene
|
||||
switch metaInfo.scene {
|
||||
case resourceCommon.ResourceCopyScene_CopyProjectResource:
|
||||
@ -805,7 +806,7 @@ func copyPlugin(ctx context.Context, metaInfo *copyMetaInfo, res *entity.Resourc
|
||||
return nil, fmt.Errorf("unsupported copy scene '%s'", metaInfo.scene)
|
||||
}
|
||||
|
||||
resp, err = plugin.PluginApplicationSVC.CopyPlugin(ctx, &plugin.CopyPluginRequest{
|
||||
resp, err = plugin.PluginApplicationSVC.CopyPlugin(ctx, &dto.CopyPluginRequest{
|
||||
CopyScene: copyScene,
|
||||
PluginID: res.ResID,
|
||||
UserID: metaInfo.userID,
|
||||
|
||||
@ -24,8 +24,8 @@ import (
|
||||
|
||||
"github.com/coze-dev/coze-studio/backend/domain/plugin/entity"
|
||||
|
||||
"github.com/coze-dev/coze-studio/backend/api/model/crossdomain/plugin"
|
||||
common "github.com/coze-dev/coze-studio/backend/api/model/plugin_develop/common"
|
||||
plugin "github.com/coze-dev/coze-studio/backend/crossdomain/contract/plugin/dto"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/errorx"
|
||||
"github.com/coze-dev/coze-studio/backend/types/errno"
|
||||
)
|
||||
|
||||
@ -34,8 +34,6 @@ import (
|
||||
"gopkg.in/yaml.v3"
|
||||
|
||||
botOpenAPI "github.com/coze-dev/coze-studio/backend/api/model/app/bot_open_api"
|
||||
model "github.com/coze-dev/coze-studio/backend/api/model/crossdomain/plugin"
|
||||
searchModel "github.com/coze-dev/coze-studio/backend/api/model/crossdomain/search"
|
||||
productCommon "github.com/coze-dev/coze-studio/backend/api/model/marketplace/product_common"
|
||||
productAPI "github.com/coze-dev/coze-studio/backend/api/model/marketplace/product_public_api"
|
||||
pluginAPI "github.com/coze-dev/coze-studio/backend/api/model/plugin_develop"
|
||||
@ -43,8 +41,9 @@ import (
|
||||
resCommon "github.com/coze-dev/coze-studio/backend/api/model/resource/common"
|
||||
"github.com/coze-dev/coze-studio/backend/application/base/ctxutil"
|
||||
"github.com/coze-dev/coze-studio/backend/application/base/pluginutil"
|
||||
crosssearch "github.com/coze-dev/coze-studio/backend/crossdomain/contract/search"
|
||||
model "github.com/coze-dev/coze-studio/backend/crossdomain/contract/plugin/dto"
|
||||
pluginConf "github.com/coze-dev/coze-studio/backend/domain/plugin/conf"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/plugin/dto"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/plugin/encrypt"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/plugin/entity"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/plugin/repository"
|
||||
@ -91,6 +90,10 @@ func (p *PluginApplicationService) GetPlaygroundPluginList(ctx context.Context,
|
||||
plugins, total, err = p.getPlaygroundPluginList(ctx, req)
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
return nil, errorx.Wrapf(err, "getPlaygroundPluginList failed, req=%v", req)
|
||||
}
|
||||
|
||||
pluginList := make([]*common.PluginInfoForPlayground, 0, len(plugins))
|
||||
for _, pl := range plugins {
|
||||
tools, err := p.toolRepo.GetPluginAllOnlineTools(ctx, pl.ID)
|
||||
@ -257,7 +260,7 @@ func (p *PluginApplicationService) RegisterPluginMeta(ctx context.Context, req *
|
||||
}
|
||||
}
|
||||
|
||||
r := &service.CreateDraftPluginRequest{
|
||||
r := &dto.CreateDraftPluginRequest{
|
||||
PluginType: req.GetPluginType(),
|
||||
SpaceID: req.GetSpaceID(),
|
||||
DeveloperID: *userID,
|
||||
@ -267,7 +270,7 @@ func (p *PluginApplicationService) RegisterPluginMeta(ctx context.Context, req *
|
||||
Desc: req.GetDesc(),
|
||||
ServerURL: req.GetURL(),
|
||||
CommonParams: req.CommonParams,
|
||||
AuthInfo: &service.PluginAuthInfo{
|
||||
AuthInfo: &dto.PluginAuthInfo{
|
||||
AuthzType: authType,
|
||||
Location: ptr.Of(loc),
|
||||
Key: req.Key,
|
||||
@ -326,7 +329,7 @@ func (p *PluginApplicationService) RegisterPlugin(ctx context.Context, req *plug
|
||||
return nil, errorx.New(errno.ErrPluginInvalidOpenapi3Doc, errorx.KV(errno.PluginMsgKey, err.Error()))
|
||||
}
|
||||
|
||||
res, err := p.DomainSVC.CreateDraftPluginWithCode(ctx, &service.CreateDraftPluginWithCodeRequest{
|
||||
res, err := p.DomainSVC.CreateDraftPluginWithCode(ctx, &dto.CreateDraftPluginWithCodeRequest{
|
||||
SpaceID: req.GetSpaceID(),
|
||||
DeveloperID: *userID,
|
||||
ProjectID: req.ProjectID,
|
||||
@ -823,7 +826,7 @@ func (p *PluginApplicationService) UpdateAPI(ctx context.Context, req *pluginAPI
|
||||
method = &m
|
||||
}
|
||||
|
||||
updateReq := &service.UpdateDraftToolRequest{
|
||||
updateReq := &dto.UpdateDraftToolRequest{
|
||||
PluginID: req.PluginID,
|
||||
ToolID: req.APIID,
|
||||
Name: req.Name,
|
||||
@ -882,7 +885,7 @@ func (p *PluginApplicationService) UpdatePlugin(ctx context.Context, req *plugin
|
||||
return nil, errorx.New(errno.ErrPluginInvalidManifest, errorx.KV(errno.PluginMsgKey, err.Error()))
|
||||
}
|
||||
|
||||
err = p.DomainSVC.UpdateDraftPluginWithCode(ctx, &service.UpdateDraftPluginWithCodeRequest{
|
||||
err = p.DomainSVC.UpdateDraftPluginWithCode(ctx, &dto.UpdateDraftPluginWithCodeRequest{
|
||||
UserID: *userID,
|
||||
PluginID: req.PluginID,
|
||||
OpenapiDoc: doc,
|
||||
@ -964,7 +967,7 @@ func (p *PluginApplicationService) PublishPlugin(ctx context.Context, req *plugi
|
||||
return nil, errorx.Wrapf(err, "validatePublishPluginRequest failed")
|
||||
}
|
||||
|
||||
err = p.DomainSVC.PublishPlugin(ctx, &service.PublishPluginRequest{
|
||||
err = p.DomainSVC.PublishPlugin(ctx, &model.PublishPluginRequest{
|
||||
PluginID: req.PluginID,
|
||||
Version: req.VersionName,
|
||||
VersionDesc: req.VersionDesc,
|
||||
@ -1002,7 +1005,7 @@ func (p *PluginApplicationService) UpdatePluginMeta(ctx context.Context, req *pl
|
||||
return nil, err
|
||||
}
|
||||
|
||||
updateReq := &service.UpdateDraftPluginRequest{
|
||||
updateReq := &dto.UpdateDraftPluginRequest{
|
||||
PluginID: req.PluginID,
|
||||
Name: req.Name,
|
||||
Desc: req.Desc,
|
||||
@ -1034,7 +1037,7 @@ func (p *PluginApplicationService) UpdatePluginMeta(ctx context.Context, req *pl
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
func getUpdateAuthInfo(ctx context.Context, req *pluginAPI.UpdatePluginMetaRequest) (authInfo *service.PluginAuthInfo, err error) {
|
||||
func getUpdateAuthInfo(ctx context.Context, req *pluginAPI.UpdatePluginMetaRequest) (authInfo *dto.PluginAuthInfo, err error) {
|
||||
if req.AuthType == nil {
|
||||
return nil, nil
|
||||
}
|
||||
@ -1065,7 +1068,7 @@ func getUpdateAuthInfo(ctx context.Context, req *pluginAPI.UpdatePluginMetaReque
|
||||
}
|
||||
}
|
||||
|
||||
authInfo = &service.PluginAuthInfo{
|
||||
authInfo = &dto.PluginAuthInfo{
|
||||
AuthzType: authType,
|
||||
Location: location,
|
||||
Key: req.Key,
|
||||
@ -1115,7 +1118,7 @@ func (p *PluginApplicationService) UpdateBotDefaultParams(ctx context.Context, r
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err = p.DomainSVC.UpdateBotDefaultParams(ctx, &service.UpdateBotDefaultParamsRequest{
|
||||
err = p.DomainSVC.UpdateBotDefaultParams(ctx, &dto.UpdateBotDefaultParamsRequest{
|
||||
PluginID: req.PluginID,
|
||||
ToolName: req.APIName,
|
||||
AgentID: req.BotID,
|
||||
@ -1162,7 +1165,7 @@ func (p *PluginApplicationService) DebugAPI(ctx context.Context, req *pluginAPI.
|
||||
)
|
||||
}
|
||||
|
||||
res, err := p.DomainSVC.ExecuteTool(ctx, &service.ExecuteToolRequest{
|
||||
res, err := p.DomainSVC.ExecuteTool(ctx, &model.ExecuteToolRequest{
|
||||
UserID: conv.Int64ToStr(*userID),
|
||||
PluginID: req.PluginID,
|
||||
ToolID: req.APIID,
|
||||
@ -1215,7 +1218,7 @@ func (p *PluginApplicationService) UnlockPluginEdit(ctx context.Context, req *pl
|
||||
}
|
||||
|
||||
func (p *PluginApplicationService) PublicGetProductList(ctx context.Context, req *productAPI.GetProductListRequest) (resp *productAPI.GetProductListResponse, err error) {
|
||||
res, err := p.DomainSVC.ListPluginProducts(ctx, &service.ListPluginProductsRequest{})
|
||||
res, err := p.DomainSVC.ListPluginProducts(ctx, &dto.ListPluginProductsRequest{})
|
||||
if err != nil {
|
||||
return nil, errorx.Wrapf(err, "ListPluginProducts failed")
|
||||
}
|
||||
@ -1416,7 +1419,7 @@ func (p *PluginApplicationService) GetDevPluginList(ctx context.Context, req *pl
|
||||
pageInfo.SortBy = ptr.Of(entity.SortByCreatedAt)
|
||||
}
|
||||
|
||||
res, err := p.DomainSVC.ListDraftPlugins(ctx, &service.ListDraftPluginsRequest{
|
||||
res, err := p.DomainSVC.ListDraftPlugins(ctx, &dto.ListDraftPluginsRequest{
|
||||
SpaceID: req.SpaceID,
|
||||
APPID: req.ProjectID,
|
||||
PageInfo: pageInfo,
|
||||
@ -1449,59 +1452,6 @@ func (p *PluginApplicationService) GetDevPluginList(ctx context.Context, req *pl
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
func (p *PluginApplicationService) getDevPluginListByName(ctx context.Context, req *pluginAPI.GetDevPluginListRequest) (pluginList []*common.PluginInfoForPlayground, total int64, err error) {
|
||||
limit := req.GetSize()
|
||||
if limit == 0 {
|
||||
limit = 10
|
||||
}
|
||||
|
||||
res, err := crosssearch.DefaultSVC().SearchResources(ctx, &searchModel.SearchResourcesRequest{
|
||||
SpaceID: req.SpaceID,
|
||||
APPID: req.ProjectID,
|
||||
Name: req.GetName(),
|
||||
OrderAsc: false,
|
||||
ResTypeFilter: []resCommon.ResType{
|
||||
resCommon.ResType_Plugin,
|
||||
},
|
||||
Page: req.Page,
|
||||
Limit: limit,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, 0, errorx.Wrapf(err, "SearchResources failed, spaceID=%d, appID=%d", req.SpaceID, req.ProjectID)
|
||||
}
|
||||
|
||||
pluginList = make([]*common.PluginInfoForPlayground, 0, len(res.Data))
|
||||
for _, pl := range res.Data {
|
||||
draftPlugin, exist, err := p.pluginRepo.GetDraftPlugin(ctx, pl.ResID)
|
||||
if err != nil {
|
||||
return nil, 0, errorx.Wrapf(err, "GetDraftPlugin failed, pluginID=%d", pl.ResID)
|
||||
}
|
||||
if !exist {
|
||||
logs.CtxWarnf(ctx, "plugin not exist, pluginID=%d", pl.ResID)
|
||||
continue
|
||||
}
|
||||
|
||||
tools, err := p.toolRepo.GetPluginAllDraftTools(ctx, draftPlugin.ID)
|
||||
if err != nil {
|
||||
return nil, 0, errorx.Wrapf(err, "GetPluginAllDraftTools failed, pluginID=%d", draftPlugin.ID)
|
||||
}
|
||||
|
||||
pluginInfo, err := p.toPluginInfoForPlayground(ctx, draftPlugin, tools)
|
||||
if err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
|
||||
pluginInfo.VersionTs = "0" // when you get the plugin information in the project, version ts is set to 0 by default
|
||||
pluginList = append(pluginList, pluginInfo)
|
||||
}
|
||||
|
||||
if res.TotalHits != nil {
|
||||
total = *res.TotalHits
|
||||
}
|
||||
|
||||
return pluginList, total, nil
|
||||
}
|
||||
|
||||
func (p *PluginApplicationService) DeleteAPPAllPlugins(ctx context.Context, appID int64) (err error) {
|
||||
pluginIDs, err := p.DomainSVC.DeleteAPPAllPlugins(ctx, appID)
|
||||
if err != nil {
|
||||
@ -1525,7 +1475,7 @@ func (p *PluginApplicationService) DeleteAPPAllPlugins(ctx context.Context, appI
|
||||
}
|
||||
|
||||
func (p *PluginApplicationService) Convert2OpenAPI(ctx context.Context, req *pluginAPI.Convert2OpenAPIRequest) (resp *pluginAPI.Convert2OpenAPIResponse, err error) {
|
||||
res := p.DomainSVC.ConvertToOpenapi3Doc(ctx, &service.ConvertToOpenapi3DocRequest{
|
||||
res := p.DomainSVC.ConvertToOpenapi3Doc(ctx, &dto.ConvertToOpenapi3DocRequest{
|
||||
RawInput: req.Data,
|
||||
PluginServerURL: req.PluginURL,
|
||||
})
|
||||
@ -1570,7 +1520,7 @@ func (p *PluginApplicationService) BatchCreateAPI(ctx context.Context, req *plug
|
||||
return nil, errorx.New(errno.ErrPluginInvalidOpenapi3Doc, errorx.KV(errno.PluginMsgKey, err.Error()))
|
||||
}
|
||||
|
||||
res, err := p.DomainSVC.CreateDraftToolsWithCode(ctx, &service.CreateDraftToolsWithCodeRequest{
|
||||
res, err := p.DomainSVC.CreateDraftToolsWithCode(ctx, &dto.CreateDraftToolsWithCodeRequest{
|
||||
PluginID: req.PluginID,
|
||||
OpenapiDoc: ptr.Of(model.Openapi3T(*doc)),
|
||||
ConflictAndUpdate: req.ReplaceSamePaths,
|
||||
@ -1618,8 +1568,8 @@ func (p *PluginApplicationService) RevokeAuthToken(ctx context.Context, req *plu
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
func (p *PluginApplicationService) CopyPlugin(ctx context.Context, req *CopyPluginRequest) (resp *CopyPluginResponse, err error) {
|
||||
res, err := p.DomainSVC.CopyPlugin(ctx, &service.CopyPluginRequest{
|
||||
func (p *PluginApplicationService) CopyPlugin(ctx context.Context, req *dto.CopyPluginRequest) (resp *dto.CopyPluginResponse, err error) {
|
||||
res, err := p.DomainSVC.CopyPlugin(ctx, &dto.CopyPluginRequest{
|
||||
UserID: req.UserID,
|
||||
PluginID: req.PluginID,
|
||||
CopyScene: req.CopyScene,
|
||||
@ -1656,7 +1606,7 @@ func (p *PluginApplicationService) CopyPlugin(ctx context.Context, req *CopyPlug
|
||||
return nil, errorx.Wrapf(err, "publish resource '%d' failed", plugin.ID)
|
||||
}
|
||||
|
||||
resp = &CopyPluginResponse{
|
||||
resp = &dto.CopyPluginResponse{
|
||||
Plugin: res.Plugin,
|
||||
Tools: res.Tools,
|
||||
}
|
||||
|
||||
@ -24,16 +24,15 @@ import (
|
||||
|
||||
"github.com/coze-dev/coze-studio/backend/api/model/app/bot_common"
|
||||
knowledgeModel "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"
|
||||
"github.com/coze-dev/coze-studio/backend/api/model/playground"
|
||||
"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"
|
||||
"github.com/coze-dev/coze-studio/backend/api/model/workflow"
|
||||
plugindto "github.com/coze-dev/coze-studio/backend/crossdomain/contract/plugin/dto"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/agent/singleagent/entity"
|
||||
knowledge "github.com/coze-dev/coze-studio/backend/domain/knowledge/service"
|
||||
pluginEntity "github.com/coze-dev/coze-studio/backend/domain/plugin/entity"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/plugin/service"
|
||||
shortcutCMDEntity "github.com/coze-dev/coze-studio/backend/domain/shortcutcmd/entity"
|
||||
workflowEntity "github.com/coze-dev/coze-studio/backend/domain/workflow/entity"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/workflow/entity/vo"
|
||||
@ -201,7 +200,7 @@ func (s *SingleAgentApplicationService) fetchKnowledgeDetails(ctx context.Contex
|
||||
}
|
||||
|
||||
func (s *SingleAgentApplicationService) fetchToolDetails(ctx context.Context, agentInfo *entity.SingleAgent, req *playground.GetDraftBotInfoAgwRequest) ([]*pluginEntity.ToolInfo, error) {
|
||||
return s.appContext.PluginDomainSVC.MGetAgentTools(ctx, &service.MGetAgentToolsRequest{
|
||||
return s.appContext.PluginDomainSVC.MGetAgentTools(ctx, &plugindto.MGetAgentToolsRequest{
|
||||
SpaceID: agentInfo.SpaceID,
|
||||
AgentID: req.GetBotID(),
|
||||
IsDraft: true,
|
||||
@ -331,7 +330,7 @@ func (s *SingleAgentApplicationService) pluginInfoDo2Vo(ctx context.Context, plu
|
||||
})
|
||||
}
|
||||
|
||||
func parametersDo2Vo(op *plugin.Openapi3Operation) []*playground.PluginParameter {
|
||||
func parametersDo2Vo(op *plugindto.Openapi3Operation) []*playground.PluginParameter {
|
||||
var convertReqBody func(paramName string, isRequired bool, sc *openapi3.Schema) *playground.PluginParameter
|
||||
convertReqBody = func(paramName string, isRequired bool, sc *openapi3.Schema) *playground.PluginParameter {
|
||||
if disabledParam(sc) {
|
||||
@ -339,7 +338,7 @@ func parametersDo2Vo(op *plugin.Openapi3Operation) []*playground.PluginParameter
|
||||
}
|
||||
|
||||
var assistType *int64
|
||||
if v, ok := sc.Extensions[plugin.APISchemaExtendAssistType]; ok {
|
||||
if v, ok := sc.Extensions[plugindto.APISchemaExtendAssistType]; ok {
|
||||
if _v, ok := v.(string); ok {
|
||||
assistType = toParameterAssistType(_v)
|
||||
}
|
||||
@ -410,7 +409,7 @@ func parametersDo2Vo(op *plugin.Openapi3Operation) []*playground.PluginParameter
|
||||
}
|
||||
|
||||
var assistType *int64
|
||||
if v, ok := schemaVal.Extensions[plugin.APISchemaExtendAssistType]; ok {
|
||||
if v, ok := schemaVal.Extensions[plugindto.APISchemaExtendAssistType]; ok {
|
||||
if _v, ok := v.(string); ok {
|
||||
assistType = toParameterAssistType(_v)
|
||||
}
|
||||
@ -456,26 +455,26 @@ func toParameterAssistType(assistType string) *int64 {
|
||||
if assistType == "" {
|
||||
return nil
|
||||
}
|
||||
switch plugin.APIFileAssistType(assistType) {
|
||||
case plugin.AssistTypeFile:
|
||||
switch plugindto.APIFileAssistType(assistType) {
|
||||
case plugindto.AssistTypeFile:
|
||||
return ptr.Of(int64(plugin_develop_common.AssistParameterType_CODE))
|
||||
case plugin.AssistTypeImage:
|
||||
case plugindto.AssistTypeImage:
|
||||
return ptr.Of(int64(plugin_develop_common.AssistParameterType_IMAGE))
|
||||
case plugin.AssistTypeDoc:
|
||||
case plugindto.AssistTypeDoc:
|
||||
return ptr.Of(int64(plugin_develop_common.AssistParameterType_DOC))
|
||||
case plugin.AssistTypePPT:
|
||||
case plugindto.AssistTypePPT:
|
||||
return ptr.Of(int64(plugin_develop_common.AssistParameterType_PPT))
|
||||
case plugin.AssistTypeCode:
|
||||
case plugindto.AssistTypeCode:
|
||||
return ptr.Of(int64(plugin_develop_common.AssistParameterType_CODE))
|
||||
case plugin.AssistTypeExcel:
|
||||
case plugindto.AssistTypeExcel:
|
||||
return ptr.Of(int64(plugin_develop_common.AssistParameterType_EXCEL))
|
||||
case plugin.AssistTypeZIP:
|
||||
case plugindto.AssistTypeZIP:
|
||||
return ptr.Of(int64(plugin_develop_common.AssistParameterType_ZIP))
|
||||
case plugin.AssistTypeVideo:
|
||||
case plugindto.AssistTypeVideo:
|
||||
return ptr.Of(int64(plugin_develop_common.AssistParameterType_VIDEO))
|
||||
case plugin.AssistTypeAudio:
|
||||
case plugindto.AssistTypeAudio:
|
||||
return ptr.Of(int64(plugin_develop_common.AssistParameterType_AUDIO))
|
||||
case plugin.AssistTypeTXT:
|
||||
case plugindto.AssistTypeTXT:
|
||||
return ptr.Of(int64(plugin_develop_common.AssistParameterType_TXT))
|
||||
default:
|
||||
return nil
|
||||
|
||||
@ -34,12 +34,12 @@ import (
|
||||
"github.com/coze-dev/coze-studio/backend/api/model/app/developer_api"
|
||||
intelligence "github.com/coze-dev/coze-studio/backend/api/model/app/intelligence/common"
|
||||
"github.com/coze-dev/coze-studio/backend/api/model/crossdomain/database"
|
||||
"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"
|
||||
"github.com/coze-dev/coze-studio/backend/application/base/ctxutil"
|
||||
"github.com/coze-dev/coze-studio/backend/crossdomain/contract/agent"
|
||||
crossdatabase "github.com/coze-dev/coze-studio/backend/crossdomain/contract/database"
|
||||
plugin "github.com/coze-dev/coze-studio/backend/crossdomain/contract/plugin/dto"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/agent/singleagent/entity"
|
||||
singleagent "github.com/coze-dev/coze-studio/backend/domain/agent/singleagent/service"
|
||||
variableEntity "github.com/coze-dev/coze-studio/backend/domain/memory/variables/entity"
|
||||
|
||||
@ -32,8 +32,6 @@ 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"
|
||||
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/playground"
|
||||
@ -48,7 +46,9 @@ import (
|
||||
"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"
|
||||
plugindto "github.com/coze-dev/coze-studio/backend/crossdomain/contract/plugin/dto"
|
||||
crossuser "github.com/coze-dev/coze-studio/backend/crossdomain/contract/user"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/plugin/dto"
|
||||
search "github.com/coze-dev/coze-studio/backend/domain/search/entity"
|
||||
domainWorkflow "github.com/coze-dev/coze-studio/backend/domain/workflow"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/workflow/entity"
|
||||
@ -976,22 +976,22 @@ func (w *ApplicationService) CopyWorkflowFromAppToLibrary(ctx context.Context, w
|
||||
return 0, nil, err
|
||||
}
|
||||
|
||||
pluginMap := make(map[int64]*plugin.PluginEntity)
|
||||
pluginMap := make(map[int64]*plugindto.PluginEntity)
|
||||
pluginToolMap := make(map[int64]int64)
|
||||
|
||||
if len(ds.PluginIDs) > 0 {
|
||||
for idx := range ds.PluginIDs {
|
||||
id := ds.PluginIDs[idx]
|
||||
response, err := appplugin.PluginApplicationSVC.CopyPlugin(ctx, &appplugin.CopyPluginRequest{
|
||||
response, err := appplugin.PluginApplicationSVC.CopyPlugin(ctx, &dto.CopyPluginRequest{
|
||||
PluginID: id,
|
||||
UserID: ctxutil.MustGetUIDFromCtx(ctx),
|
||||
CopyScene: pluginmodel.CopySceneOfToLibrary,
|
||||
CopyScene: plugindto.CopySceneOfToLibrary,
|
||||
})
|
||||
if err != nil {
|
||||
return 0, nil, err
|
||||
}
|
||||
pInfo := response.Plugin
|
||||
pluginMap[id] = &plugin.PluginEntity{
|
||||
pluginMap[id] = &plugindto.PluginEntity{
|
||||
PluginID: pInfo.ID,
|
||||
PluginVersion: pInfo.Version,
|
||||
}
|
||||
@ -1109,9 +1109,9 @@ func (w *ApplicationService) DuplicateWorkflowsByAppID(ctx context.Context, sour
|
||||
}
|
||||
}()
|
||||
|
||||
pluginMap := make(map[int64]*plugin.PluginEntity)
|
||||
pluginMap := make(map[int64]*plugindto.PluginEntity)
|
||||
for o, n := range externalResource.PluginMap {
|
||||
pluginMap[o] = &plugin.PluginEntity{
|
||||
pluginMap[o] = &plugindto.PluginEntity{
|
||||
PluginID: n,
|
||||
}
|
||||
}
|
||||
@ -1209,7 +1209,7 @@ func (w *ApplicationService) MoveWorkflowFromAppToLibrary(ctx context.Context, w
|
||||
return 0, nil, err
|
||||
}
|
||||
|
||||
pluginMap := make(map[int64]*plugin.PluginEntity)
|
||||
pluginMap := make(map[int64]*plugindto.PluginEntity)
|
||||
if len(ds.PluginIDs) > 0 {
|
||||
for idx := range ds.PluginIDs {
|
||||
id := ds.PluginIDs[idx]
|
||||
@ -1217,7 +1217,7 @@ func (w *ApplicationService) MoveWorkflowFromAppToLibrary(ctx context.Context, w
|
||||
if err != nil {
|
||||
return 0, nil, err
|
||||
}
|
||||
pluginMap[id] = &plugin.PluginEntity{
|
||||
pluginMap[id] = &plugindto.PluginEntity{
|
||||
PluginID: pInfo.ID,
|
||||
PluginVersion: pInfo.Version,
|
||||
}
|
||||
@ -2650,8 +2650,8 @@ func (w *ApplicationService) GetApiDetail(ctx context.Context, req *workflow.Get
|
||||
return nil, err
|
||||
}
|
||||
|
||||
toolInfoResponse, err := crossplugin.DefaultSVC().GetPluginToolsInfo(ctx, &plugin.ToolsInfoRequest{
|
||||
PluginEntity: plugin.PluginEntity{
|
||||
toolInfoResponse, err := crossplugin.DefaultSVC().GetPluginToolsInfo(ctx, &plugindto.ToolsInfoRequest{
|
||||
PluginEntity: plugindto.PluginEntity{
|
||||
PluginID: pluginID,
|
||||
PluginVersion: req.PluginVersion,
|
||||
},
|
||||
@ -2718,7 +2718,7 @@ func (w *ApplicationService) GetLLMNodeFCSettingDetail(ctx context.Context, req
|
||||
|
||||
var (
|
||||
pluginSvc = crossplugin.DefaultSVC()
|
||||
pluginToolsInfoReqs = make(map[int64]*plugin.ToolsInfoRequest)
|
||||
pluginToolsInfoReqs = make(map[int64]*plugindto.ToolsInfoRequest)
|
||||
pluginDetailMap = make(map[string]*workflow.PluginDetail)
|
||||
toolsDetailInfo = make(map[string]*workflow.APIDetail)
|
||||
workflowDetailMap = make(map[string]*workflow.WorkflowDetail)
|
||||
@ -2740,8 +2740,8 @@ func (w *ApplicationService) GetLLMNodeFCSettingDetail(ctx context.Context, req
|
||||
if r, ok := pluginToolsInfoReqs[pluginID]; ok {
|
||||
r.ToolIDs = append(r.ToolIDs, toolID)
|
||||
} else {
|
||||
pluginToolsInfoReqs[pluginID] = &plugin.ToolsInfoRequest{
|
||||
PluginEntity: plugin.PluginEntity{
|
||||
pluginToolsInfoReqs[pluginID] = &plugindto.ToolsInfoRequest{
|
||||
PluginEntity: plugindto.PluginEntity{
|
||||
PluginID: pluginID,
|
||||
PluginVersion: pl.PluginVersion,
|
||||
},
|
||||
@ -2940,8 +2940,8 @@ func (w *ApplicationService) GetLLMNodeFCSettingsMerged(ctx context.Context, req
|
||||
return nil, err
|
||||
}
|
||||
|
||||
pluginReq := &plugin.ToolsInfoRequest{
|
||||
PluginEntity: plugin.PluginEntity{
|
||||
pluginReq := &plugindto.ToolsInfoRequest{
|
||||
PluginEntity: plugindto.PluginEntity{
|
||||
PluginID: pluginID,
|
||||
},
|
||||
ToolIDs: []int64{toolID},
|
||||
|
||||
@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package plugin
|
||||
package dto
|
||||
|
||||
import "github.com/getkin/kin-openapi/openapi3"
|
||||
|
||||
@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package plugin
|
||||
package dto
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package plugin
|
||||
package dto
|
||||
|
||||
import (
|
||||
"context"
|
||||
@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package plugin
|
||||
package dto
|
||||
|
||||
type ExecuteToolOption struct {
|
||||
ProjectInfo *ProjectInfo
|
||||
@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package plugin
|
||||
package dto
|
||||
|
||||
import (
|
||||
"github.com/getkin/kin-openapi/openapi3"
|
||||
@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package plugin
|
||||
package dto
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package plugin
|
||||
package dto
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@ -22,12 +22,13 @@ import (
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/getkin/kin-openapi/openapi3"
|
||||
gonanoid "github.com/matoous/go-nanoid"
|
||||
|
||||
productAPI "github.com/coze-dev/coze-studio/backend/api/model/marketplace/product_public_api"
|
||||
"github.com/coze-dev/coze-studio/backend/api/model/plugin_develop/common"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/lang/ptr"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/lang/slices"
|
||||
"github.com/getkin/kin-openapi/openapi3"
|
||||
gonanoid "github.com/matoous/go-nanoid"
|
||||
)
|
||||
|
||||
type ToolInfo struct {
|
||||
@ -397,7 +398,7 @@ func (t ToolInfo) ToPluginParameters() ([]*common.PluginParameter, error) {
|
||||
continue
|
||||
}
|
||||
f, ok := AssistTypeToThriftFormat(APIFileAssistType(_v))
|
||||
if ok {
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("the assist type '%s' of field '%s' is invalid", _v, paramVal.Name)
|
||||
}
|
||||
assistType = ptr.Of(f)
|
||||
@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package plugin
|
||||
package dto
|
||||
|
||||
import (
|
||||
"github.com/coze-dev/coze-studio/backend/api/model/workflow"
|
||||
@ -21,8 +21,8 @@ import (
|
||||
|
||||
"github.com/cloudwego/eino/schema"
|
||||
|
||||
model "github.com/coze-dev/coze-studio/backend/api/model/crossdomain/plugin"
|
||||
"github.com/coze-dev/coze-studio/backend/api/model/crossdomain/workflow"
|
||||
model "github.com/coze-dev/coze-studio/backend/crossdomain/contract/plugin/dto"
|
||||
)
|
||||
|
||||
//go:generate mockgen -destination pluginmock/plugin_mock.go --package pluginmock -source plugin.go
|
||||
|
||||
@ -14,9 +14,9 @@ import (
|
||||
reflect "reflect"
|
||||
|
||||
schema "github.com/cloudwego/eino/schema"
|
||||
plugin "github.com/coze-dev/coze-studio/backend/api/model/crossdomain/plugin"
|
||||
workflow "github.com/coze-dev/coze-studio/backend/api/model/crossdomain/workflow"
|
||||
plugin0 "github.com/coze-dev/coze-studio/backend/crossdomain/contract/plugin"
|
||||
plugin "github.com/coze-dev/coze-studio/backend/crossdomain/contract/plugin/dto"
|
||||
gomock "go.uber.org/mock/gomock"
|
||||
)
|
||||
|
||||
|
||||
@ -26,12 +26,12 @@ import (
|
||||
"github.com/getkin/kin-openapi/openapi3"
|
||||
"golang.org/x/exp/maps"
|
||||
|
||||
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"
|
||||
workflow3 "github.com/coze-dev/coze-studio/backend/api/model/workflow"
|
||||
"github.com/coze-dev/coze-studio/backend/application/base/pluginutil"
|
||||
crossplugin "github.com/coze-dev/coze-studio/backend/crossdomain/contract/plugin"
|
||||
model "github.com/coze-dev/coze-studio/backend/crossdomain/contract/plugin/dto"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/plugin/entity"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/plugin/service"
|
||||
plugin "github.com/coze-dev/coze-studio/backend/domain/plugin/service"
|
||||
@ -355,7 +355,7 @@ func (s *impl) ExecutePlugin(ctx context.Context, input map[string]any, pe *mode
|
||||
uID = conv.Int64ToStr(cfg.Operator)
|
||||
}
|
||||
|
||||
req := &service.ExecuteToolRequest{
|
||||
req := &model.ExecuteToolRequest{
|
||||
UserID: uID,
|
||||
PluginID: pe.PluginID,
|
||||
ToolID: toolID,
|
||||
@ -449,7 +449,7 @@ func (p *pluginInvokeTool) Info(ctx context.Context) (_ *schema.ToolInfo, err er
|
||||
}
|
||||
|
||||
func (p *pluginInvokeTool) PluginInvoke(ctx context.Context, argumentsInJSON string, cfg workflowModel.ExecuteConfig) (string, error) {
|
||||
req := &service.ExecuteToolRequest{
|
||||
req := &model.ExecuteToolRequest{
|
||||
UserID: conv.Int64ToStr(cfg.Operator),
|
||||
PluginID: p.pluginEntity.PluginID,
|
||||
ToolID: p.toolInfo.ID,
|
||||
|
||||
@ -29,8 +29,8 @@ 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/api/model/crossdomain/singleagent"
|
||||
plugin "github.com/coze-dev/coze-studio/backend/crossdomain/contract/plugin/dto"
|
||||
crossworkflow "github.com/coze-dev/coze-studio/backend/crossdomain/contract/workflow"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/agent/singleagent/entity"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/lang/conv"
|
||||
|
||||
@ -16,20 +16,19 @@
|
||||
|
||||
package agentflow
|
||||
|
||||
// TODO(fanlv): remove pluginEntity
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/cloudwego/eino/components/tool"
|
||||
"github.com/cloudwego/eino/schema"
|
||||
|
||||
"github.com/coze-dev/coze-studio/backend/domain/agent/singleagent/entity"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/lang/ptr"
|
||||
|
||||
"github.com/coze-dev/coze-studio/backend/api/model/app/bot_common"
|
||||
"github.com/coze-dev/coze-studio/backend/api/model/crossdomain/plugin"
|
||||
crossplugin "github.com/coze-dev/coze-studio/backend/crossdomain/contract/plugin"
|
||||
model "github.com/coze-dev/coze-studio/backend/crossdomain/contract/plugin/dto"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/agent/singleagent/entity"
|
||||
pluginEntity "github.com/coze-dev/coze-studio/backend/domain/plugin/entity"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/plugin/service"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/lang/ptr"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/lang/slices"
|
||||
)
|
||||
|
||||
@ -43,7 +42,7 @@ type toolConfig struct {
|
||||
}
|
||||
|
||||
func newPluginTools(ctx context.Context, conf *toolConfig) ([]tool.InvokableTool, error) {
|
||||
req := &service.MGetAgentToolsRequest{
|
||||
req := &model.MGetAgentToolsRequest{
|
||||
SpaceID: conf.spaceID,
|
||||
AgentID: conf.agentIdentity.AgentID,
|
||||
IsDraft: conf.agentIdentity.IsDraft,
|
||||
@ -59,9 +58,9 @@ func newPluginTools(ctx context.Context, conf *toolConfig) ([]tool.InvokableTool
|
||||
return nil, err
|
||||
}
|
||||
|
||||
projectInfo := &plugin.ProjectInfo{
|
||||
projectInfo := &model.ProjectInfo{
|
||||
ProjectID: conf.agentIdentity.AgentID,
|
||||
ProjectType: plugin.ProjectTypeOfAgent,
|
||||
ProjectType: model.ProjectTypeOfAgent,
|
||||
ProjectVersion: ptr.Of(conf.agentIdentity.Version),
|
||||
ConnectorID: conf.agentIdentity.ConnectorID,
|
||||
}
|
||||
@ -85,7 +84,7 @@ type pluginInvokableTool struct {
|
||||
userID string
|
||||
isDraft bool
|
||||
toolInfo *pluginEntity.ToolInfo
|
||||
projectInfo *plugin.ProjectInfo
|
||||
projectInfo *model.ProjectInfo
|
||||
|
||||
conversationID int64
|
||||
}
|
||||
@ -112,25 +111,25 @@ func (p *pluginInvokableTool) Info(ctx context.Context) (*schema.ToolInfo, error
|
||||
}
|
||||
|
||||
func (p *pluginInvokableTool) InvokableRun(ctx context.Context, argumentsInJSON string, _ ...tool.Option) (string, error) {
|
||||
req := &service.ExecuteToolRequest{
|
||||
req := &model.ExecuteToolRequest{
|
||||
UserID: p.userID,
|
||||
PluginID: p.toolInfo.PluginID,
|
||||
ToolID: p.toolInfo.ID,
|
||||
ExecDraftTool: false,
|
||||
ArgumentsInJson: argumentsInJSON,
|
||||
ExecScene: func() plugin.ExecuteScene {
|
||||
ExecScene: func() model.ExecuteScene {
|
||||
if p.isDraft {
|
||||
return plugin.ExecSceneOfDraftAgent
|
||||
return model.ExecSceneOfDraftAgent
|
||||
}
|
||||
return plugin.ExecSceneOfOnlineAgent
|
||||
return model.ExecSceneOfOnlineAgent
|
||||
}(),
|
||||
}
|
||||
|
||||
opts := []pluginEntity.ExecuteToolOpt{
|
||||
plugin.WithInvalidRespProcessStrategy(plugin.InvalidResponseProcessStrategyOfReturnDefault),
|
||||
plugin.WithToolVersion(p.toolInfo.GetVersion()),
|
||||
plugin.WithProjectInfo(p.projectInfo),
|
||||
plugin.WithPluginHTTPHeader(p.conversationID),
|
||||
model.WithInvalidRespProcessStrategy(model.InvalidResponseProcessStrategyOfReturnDefault),
|
||||
model.WithToolVersion(p.toolInfo.GetVersion()),
|
||||
model.WithProjectInfo(p.projectInfo),
|
||||
model.WithPluginHTTPHeader(p.conversationID),
|
||||
}
|
||||
|
||||
resp, err := crossplugin.DefaultSVC().ExecuteTool(ctx, req, opts...)
|
||||
|
||||
@ -20,17 +20,15 @@ import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
|
||||
"github.com/cloudwego/eino/schema"
|
||||
"github.com/google/uuid"
|
||||
|
||||
"github.com/cloudwego/eino/schema"
|
||||
|
||||
"github.com/coze-dev/coze-studio/backend/api/model/crossdomain/agentrun"
|
||||
"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"
|
||||
model "github.com/coze-dev/coze-studio/backend/crossdomain/contract/plugin/dto"
|
||||
crossworkflow "github.com/coze-dev/coze-studio/backend/crossdomain/contract/workflow"
|
||||
pluginEntity "github.com/coze-dev/coze-studio/backend/domain/plugin/entity"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/plugin/service"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/lang/ptr"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/logs"
|
||||
)
|
||||
@ -53,26 +51,26 @@ func (pr *toolPreCallConf) toolPreRetrieve(ctx context.Context, ar *AgentRequest
|
||||
switch item.Type {
|
||||
case agentrun.ToolTypePlugin:
|
||||
|
||||
etr := &service.ExecuteToolRequest{
|
||||
etr := &model.ExecuteToolRequest{
|
||||
UserID: ar.UserID,
|
||||
ExecDraftTool: false,
|
||||
PluginID: item.PluginID,
|
||||
ToolID: item.ToolID,
|
||||
ArgumentsInJson: item.Arguments,
|
||||
ExecScene: func(isDraft bool) plugin.ExecuteScene {
|
||||
ExecScene: func(isDraft bool) model.ExecuteScene {
|
||||
if isDraft {
|
||||
return plugin.ExecSceneOfDraftAgent
|
||||
return model.ExecSceneOfDraftAgent
|
||||
} else {
|
||||
return plugin.ExecSceneOfOnlineAgent
|
||||
return model.ExecSceneOfOnlineAgent
|
||||
}
|
||||
}(ar.Identity.IsDraft),
|
||||
}
|
||||
|
||||
opts := []pluginEntity.ExecuteToolOpt{
|
||||
plugin.WithInvalidRespProcessStrategy(plugin.InvalidResponseProcessStrategyOfReturnDefault),
|
||||
plugin.WithProjectInfo(&plugin.ProjectInfo{
|
||||
model.WithInvalidRespProcessStrategy(model.InvalidResponseProcessStrategyOfReturnDefault),
|
||||
model.WithProjectInfo(&model.ProjectInfo{
|
||||
ProjectID: ar.Identity.AgentID,
|
||||
ProjectType: plugin.ProjectTypeOfAgent,
|
||||
ProjectType: model.ProjectTypeOfAgent,
|
||||
ProjectVersion: ptr.Of(ar.Identity.Version),
|
||||
}),
|
||||
}
|
||||
|
||||
@ -20,9 +20,9 @@ import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"github.com/coze-dev/coze-studio/backend/api/model/crossdomain/plugin"
|
||||
resourceCommon "github.com/coze-dev/coze-studio/backend/api/model/resource/common"
|
||||
crossplugin "github.com/coze-dev/coze-studio/backend/crossdomain/contract/plugin"
|
||||
plugin "github.com/coze-dev/coze-studio/backend/crossdomain/contract/plugin/dto"
|
||||
crossworkflow "github.com/coze-dev/coze-studio/backend/crossdomain/contract/workflow"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/app/entity"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/app/repository"
|
||||
|
||||
@ -28,8 +28,8 @@ import (
|
||||
"golang.org/x/mod/semver"
|
||||
"gopkg.in/yaml.v3"
|
||||
|
||||
model "github.com/coze-dev/coze-studio/backend/api/model/crossdomain/plugin"
|
||||
common "github.com/coze-dev/coze-studio/backend/api/model/plugin_develop/common"
|
||||
model "github.com/coze-dev/coze-studio/backend/crossdomain/contract/plugin/dto"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/plugin/entity"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/lang/ptr"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/logs"
|
||||
|
||||
@ -14,21 +14,30 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package plugin
|
||||
package dto
|
||||
|
||||
import (
|
||||
model "github.com/coze-dev/coze-studio/backend/api/model/crossdomain/plugin"
|
||||
"github.com/coze-dev/coze-studio/backend/api/model/plugin_develop/common"
|
||||
model "github.com/coze-dev/coze-studio/backend/crossdomain/contract/plugin/dto"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/plugin/entity"
|
||||
)
|
||||
|
||||
type CopyPluginRequest struct {
|
||||
PluginID int64
|
||||
UserID int64
|
||||
CopyScene model.CopyScene
|
||||
TargetAPPID *int64
|
||||
type GetOAuthStatusResponse struct {
|
||||
IsOauth bool
|
||||
Status common.OAuthStatus
|
||||
OAuthURL string
|
||||
}
|
||||
|
||||
type CopyPluginResponse struct {
|
||||
Plugin *entity.PluginInfo
|
||||
Tools map[int64]*entity.ToolInfo // old tool id -> new tool id
|
||||
type AgentPluginOAuthStatus struct {
|
||||
PluginID int64
|
||||
PluginName string
|
||||
PluginIconURL string
|
||||
Status common.OAuthStatus
|
||||
}
|
||||
|
||||
type GetAccessTokenRequest struct {
|
||||
UserID string
|
||||
PluginID *int64
|
||||
Mode model.AuthzSubType
|
||||
OAuthInfo *entity.OAuthInfo
|
||||
}
|
||||
97
backend/domain/plugin/dto/plugin.go
Normal file
97
backend/domain/plugin/dto/plugin.go
Normal file
@ -0,0 +1,97 @@
|
||||
/*
|
||||
* 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 dto
|
||||
|
||||
import (
|
||||
"github.com/coze-dev/coze-studio/backend/api/model/plugin_develop/common"
|
||||
model "github.com/coze-dev/coze-studio/backend/crossdomain/contract/plugin/dto"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/plugin/entity"
|
||||
)
|
||||
|
||||
type CreateDraftPluginRequest struct {
|
||||
PluginType common.PluginType
|
||||
IconURI string
|
||||
SpaceID int64
|
||||
DeveloperID int64
|
||||
ProjectID *int64
|
||||
Name string
|
||||
Desc string
|
||||
ServerURL string
|
||||
CommonParams map[common.ParameterLocation][]*common.CommonParamSchema
|
||||
AuthInfo *PluginAuthInfo
|
||||
}
|
||||
|
||||
type UpdateDraftPluginWithCodeRequest struct {
|
||||
UserID int64
|
||||
PluginID int64
|
||||
OpenapiDoc *model.Openapi3T
|
||||
Manifest *entity.PluginManifest
|
||||
}
|
||||
|
||||
type UpdateDraftPluginRequest struct {
|
||||
PluginID int64
|
||||
Name *string
|
||||
Desc *string
|
||||
URL *string
|
||||
Icon *common.PluginIcon
|
||||
CommonParams map[common.ParameterLocation][]*common.CommonParamSchema
|
||||
AuthInfo *PluginAuthInfo
|
||||
}
|
||||
|
||||
type ListDraftPluginsRequest struct {
|
||||
SpaceID int64
|
||||
APPID int64
|
||||
PageInfo entity.PageInfo
|
||||
}
|
||||
|
||||
type ListDraftPluginsResponse struct {
|
||||
Plugins []*entity.PluginInfo
|
||||
Total int64
|
||||
}
|
||||
|
||||
type CreateDraftPluginWithCodeRequest struct {
|
||||
SpaceID int64
|
||||
DeveloperID int64
|
||||
ProjectID *int64
|
||||
Manifest *entity.PluginManifest
|
||||
OpenapiDoc *model.Openapi3T
|
||||
}
|
||||
|
||||
type CreateDraftPluginWithCodeResponse struct {
|
||||
Plugin *entity.PluginInfo
|
||||
Tools []*entity.ToolInfo
|
||||
}
|
||||
|
||||
type ListPluginProductsRequest struct{}
|
||||
|
||||
type ListPluginProductsResponse struct {
|
||||
Plugins []*entity.PluginInfo
|
||||
Total int64
|
||||
}
|
||||
|
||||
type CopyPluginRequest struct {
|
||||
UserID int64
|
||||
PluginID int64
|
||||
CopyScene model.CopyScene
|
||||
|
||||
TargetAPPID *int64
|
||||
}
|
||||
|
||||
type CopyPluginResponse struct {
|
||||
Plugin *entity.PluginInfo
|
||||
Tools map[int64]*entity.ToolInfo // old tool id -> new tool
|
||||
}
|
||||
176
backend/domain/plugin/dto/plugin_author.go
Normal file
176
backend/domain/plugin/dto/plugin_author.go
Normal file
@ -0,0 +1,176 @@
|
||||
/*
|
||||
* 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 dto
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
model "github.com/coze-dev/coze-studio/backend/crossdomain/contract/plugin/dto"
|
||||
"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"
|
||||
)
|
||||
|
||||
type PluginAuthInfo struct {
|
||||
AuthzType *model.AuthzType
|
||||
Location *model.HTTPParamLocation
|
||||
Key *string
|
||||
ServiceToken *string
|
||||
OAuthInfo *string
|
||||
AuthzSubType *model.AuthzSubType
|
||||
AuthzPayload *string
|
||||
}
|
||||
|
||||
// TODO(@fanlv): change to DTO + Service
|
||||
func (p PluginAuthInfo) ToAuthV2() (*model.AuthV2, error) {
|
||||
if p.AuthzType == nil {
|
||||
return nil, errorx.New(errno.ErrPluginInvalidManifest, errorx.KV(errno.PluginMsgKey, "auth type is required"))
|
||||
}
|
||||
|
||||
switch *p.AuthzType {
|
||||
case model.AuthzTypeOfNone:
|
||||
return &model.AuthV2{
|
||||
Type: model.AuthzTypeOfNone,
|
||||
}, nil
|
||||
|
||||
case model.AuthzTypeOfOAuth:
|
||||
m, err := p.authOfOAuthToAuthV2()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
|
||||
case model.AuthzTypeOfService:
|
||||
m, err := p.authOfServiceToAuthV2()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
|
||||
default:
|
||||
return nil, errorx.New(errno.ErrPluginInvalidManifest, errorx.KVf(errno.PluginMsgKey,
|
||||
"the type '%s' of auth is invalid", *p.AuthzType))
|
||||
}
|
||||
}
|
||||
|
||||
func (p PluginAuthInfo) authOfOAuthToAuthV2() (*model.AuthV2, error) {
|
||||
if p.AuthzSubType == nil {
|
||||
return nil, errorx.New(errno.ErrPluginInvalidManifest, errorx.KV(errno.PluginMsgKey, "sub-auth type is required"))
|
||||
}
|
||||
|
||||
if p.OAuthInfo == nil || *p.OAuthInfo == "" {
|
||||
return nil, errorx.New(errno.ErrPluginInvalidManifest, errorx.KV(errno.PluginMsgKey, "oauth info is required"))
|
||||
}
|
||||
|
||||
oauthInfo := make(map[string]string)
|
||||
err := sonic.Unmarshal([]byte(*p.OAuthInfo), &oauthInfo)
|
||||
if err != nil {
|
||||
return nil, errorx.WrapByCode(err, errno.ErrPluginInvalidManifest, errorx.KV(errno.PluginMsgKey, "invalid oauth info"))
|
||||
}
|
||||
|
||||
if *p.AuthzSubType == model.AuthzSubTypeOfOAuthClientCredentials {
|
||||
_oauthInfo := &model.OAuthClientCredentialsConfig{
|
||||
ClientID: oauthInfo["client_id"],
|
||||
ClientSecret: oauthInfo["client_secret"],
|
||||
TokenURL: oauthInfo["token_url"],
|
||||
}
|
||||
|
||||
str, err := sonic.MarshalString(_oauthInfo)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("marshal oauth info failed, err=%v", err)
|
||||
}
|
||||
|
||||
return &model.AuthV2{
|
||||
Type: model.AuthzTypeOfOAuth,
|
||||
SubType: model.AuthzSubTypeOfOAuthClientCredentials,
|
||||
Payload: str,
|
||||
AuthOfOAuthClientCredentials: _oauthInfo,
|
||||
}, nil
|
||||
}
|
||||
|
||||
if *p.AuthzSubType == model.AuthzSubTypeOfOAuthAuthorizationCode {
|
||||
contentType := oauthInfo["authorization_content_type"]
|
||||
if contentType != model.MediaTypeJson { // only support application/json
|
||||
return nil, errorx.New(errno.ErrPluginInvalidManifest, errorx.KVf(errno.PluginMsgKey,
|
||||
"the type '%s' of authorization content is invalid", contentType))
|
||||
}
|
||||
|
||||
_oauthInfo := &model.OAuthAuthorizationCodeConfig{
|
||||
ClientID: oauthInfo["client_id"],
|
||||
ClientSecret: oauthInfo["client_secret"],
|
||||
ClientURL: oauthInfo["client_url"],
|
||||
Scope: oauthInfo["scope"],
|
||||
AuthorizationURL: oauthInfo["authorization_url"],
|
||||
AuthorizationContentType: contentType,
|
||||
}
|
||||
|
||||
str, err := sonic.MarshalString(_oauthInfo)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("marshal oauth info failed, err=%v", err)
|
||||
}
|
||||
|
||||
return &model.AuthV2{
|
||||
Type: model.AuthzTypeOfOAuth,
|
||||
SubType: model.AuthzSubTypeOfOAuthAuthorizationCode,
|
||||
Payload: str,
|
||||
AuthOfOAuthAuthorizationCode: _oauthInfo,
|
||||
}, nil
|
||||
}
|
||||
|
||||
return nil, errorx.New(errno.ErrPluginInvalidManifest, errorx.KVf(errno.PluginMsgKey,
|
||||
"the type '%s' of sub-auth is invalid", *p.AuthzSubType))
|
||||
}
|
||||
|
||||
func (p PluginAuthInfo) authOfServiceToAuthV2() (*model.AuthV2, error) {
|
||||
if p.AuthzSubType == nil {
|
||||
return nil, fmt.Errorf("sub-auth type is required")
|
||||
}
|
||||
|
||||
if *p.AuthzSubType == model.AuthzSubTypeOfServiceAPIToken {
|
||||
if p.Location == nil {
|
||||
return nil, fmt.Errorf("'Location' of sub-auth is required")
|
||||
}
|
||||
if p.ServiceToken == nil {
|
||||
return nil, fmt.Errorf("'ServiceToken' of sub-auth is required")
|
||||
}
|
||||
if p.Key == nil {
|
||||
return nil, fmt.Errorf("'Key' of sub-auth is required")
|
||||
}
|
||||
|
||||
tokenAuth := &model.AuthOfAPIToken{
|
||||
ServiceToken: *p.ServiceToken,
|
||||
Location: model.HTTPParamLocation(strings.ToLower(string(*p.Location))),
|
||||
Key: *p.Key,
|
||||
}
|
||||
|
||||
str, err := sonic.MarshalString(tokenAuth)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("marshal token auth failed, err=%v", err)
|
||||
}
|
||||
|
||||
return &model.AuthV2{
|
||||
Type: model.AuthzTypeOfService,
|
||||
SubType: model.AuthzSubTypeOfServiceAPIToken,
|
||||
Payload: str,
|
||||
AuthOfAPIToken: tokenAuth,
|
||||
}, nil
|
||||
}
|
||||
|
||||
return nil, errorx.New(errno.ErrPluginInvalidManifest, errorx.KVf(errno.PluginMsgKey,
|
||||
"the type '%s' of sub-auth is invalid", *p.AuthzSubType))
|
||||
}
|
||||
73
backend/domain/plugin/dto/tool.go
Normal file
73
backend/domain/plugin/dto/tool.go
Normal file
@ -0,0 +1,73 @@
|
||||
/*
|
||||
* 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 dto
|
||||
|
||||
import (
|
||||
"github.com/getkin/kin-openapi/openapi3"
|
||||
|
||||
"github.com/coze-dev/coze-studio/backend/api/model/plugin_develop/common"
|
||||
model "github.com/coze-dev/coze-studio/backend/crossdomain/contract/plugin/dto"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/plugin/entity"
|
||||
)
|
||||
|
||||
type CreateDraftToolsWithCodeRequest struct {
|
||||
PluginID int64
|
||||
OpenapiDoc *model.Openapi3T
|
||||
|
||||
ConflictAndUpdate bool
|
||||
}
|
||||
|
||||
type CreateDraftToolsWithCodeResponse struct {
|
||||
DuplicatedTools []entity.UniqueToolAPI
|
||||
}
|
||||
|
||||
type UpdateDraftToolRequest struct {
|
||||
PluginID int64
|
||||
ToolID int64
|
||||
Name *string
|
||||
Desc *string
|
||||
SubURL *string
|
||||
Method *string
|
||||
Parameters openapi3.Parameters
|
||||
RequestBody *openapi3.RequestBodyRef
|
||||
Responses openapi3.Responses
|
||||
Disabled *bool
|
||||
SaveExample *bool
|
||||
DebugExample *common.DebugExample
|
||||
APIExtend *common.APIExtend
|
||||
}
|
||||
|
||||
type ConvertToOpenapi3DocRequest struct {
|
||||
RawInput string
|
||||
PluginServerURL *string
|
||||
}
|
||||
|
||||
type ConvertToOpenapi3DocResponse struct {
|
||||
OpenapiDoc *model.Openapi3T
|
||||
Manifest *entity.PluginManifest
|
||||
Format common.PluginDataFormat
|
||||
ErrMsg string
|
||||
}
|
||||
|
||||
type UpdateBotDefaultParamsRequest struct {
|
||||
PluginID int64
|
||||
AgentID int64
|
||||
ToolName string
|
||||
Parameters openapi3.Parameters
|
||||
RequestBody *openapi3.RequestBodyRef
|
||||
Responses openapi3.Responses
|
||||
}
|
||||
@ -17,7 +17,7 @@
|
||||
package entity
|
||||
|
||||
import (
|
||||
model "github.com/coze-dev/coze-studio/backend/api/model/crossdomain/plugin"
|
||||
model "github.com/coze-dev/coze-studio/backend/crossdomain/contract/plugin/dto"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/lang/ptr"
|
||||
)
|
||||
|
||||
|
||||
@ -24,8 +24,8 @@ import (
|
||||
"github.com/bytedance/sonic"
|
||||
"github.com/getkin/kin-openapi/openapi3"
|
||||
|
||||
model "github.com/coze-dev/coze-studio/backend/api/model/crossdomain/plugin"
|
||||
"github.com/coze-dev/coze-studio/backend/api/model/plugin_develop/common"
|
||||
model "github.com/coze-dev/coze-studio/backend/crossdomain/contract/plugin/dto"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/lang/ptr"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/logs"
|
||||
)
|
||||
|
||||
@ -4,22 +4,22 @@
|
||||
|
||||
package model
|
||||
|
||||
import "github.com/coze-dev/coze-studio/backend/api/model/crossdomain/plugin"
|
||||
import "github.com/coze-dev/coze-studio/backend/crossdomain/contract/plugin/dto"
|
||||
|
||||
const TableNameAgentToolDraft = "agent_tool_draft"
|
||||
|
||||
// AgentToolDraft Draft Agent Tool
|
||||
type AgentToolDraft struct {
|
||||
ID int64 `gorm:"column:id;primaryKey;comment:Primary Key ID" json:"id"` // Primary Key ID
|
||||
AgentID int64 `gorm:"column:agent_id;not null;comment:Agent ID" json:"agent_id"` // Agent ID
|
||||
PluginID int64 `gorm:"column:plugin_id;not null;comment:Plugin ID" json:"plugin_id"` // Plugin ID
|
||||
ToolID int64 `gorm:"column:tool_id;not null;comment:Tool ID" json:"tool_id"` // Tool ID
|
||||
CreatedAt int64 `gorm:"column:created_at;not null;autoCreateTime:milli;comment:Create Time in Milliseconds" json:"created_at"` // Create Time in Milliseconds
|
||||
SubURL string `gorm:"column:sub_url;not null;comment:Sub URL Path" json:"sub_url"` // Sub URL Path
|
||||
Method string `gorm:"column:method;not null;comment:HTTP Request Method" json:"method"` // HTTP Request Method
|
||||
ToolName string `gorm:"column:tool_name;not null;comment:Tool Name" json:"tool_name"` // Tool Name
|
||||
ToolVersion string `gorm:"column:tool_version;not null;comment:Tool Version, e.g. v1.0.0" json:"tool_version"` // Tool Version, e.g. v1.0.0
|
||||
Operation *plugin.Openapi3Operation `gorm:"column:operation;comment:Tool Openapi Operation Schema;serializer:json" json:"operation"` // Tool Openapi Operation Schema
|
||||
ID int64 `gorm:"column:id;primaryKey;comment:Primary Key ID" json:"id"` // Primary Key ID
|
||||
AgentID int64 `gorm:"column:agent_id;not null;comment:Agent ID" json:"agent_id"` // Agent ID
|
||||
PluginID int64 `gorm:"column:plugin_id;not null;comment:Plugin ID" json:"plugin_id"` // Plugin ID
|
||||
ToolID int64 `gorm:"column:tool_id;not null;comment:Tool ID" json:"tool_id"` // Tool ID
|
||||
CreatedAt int64 `gorm:"column:created_at;not null;autoCreateTime:milli;comment:Create Time in Milliseconds" json:"created_at"` // Create Time in Milliseconds
|
||||
SubURL string `gorm:"column:sub_url;not null;comment:Sub URL Path" json:"sub_url"` // Sub URL Path
|
||||
Method string `gorm:"column:method;not null;comment:HTTP Request Method" json:"method"` // HTTP Request Method
|
||||
ToolName string `gorm:"column:tool_name;not null;comment:Tool Name" json:"tool_name"` // Tool Name
|
||||
ToolVersion string `gorm:"column:tool_version;not null;comment:Tool Version, e.g. v1.0.0" json:"tool_version"` // Tool Version, e.g. v1.0.0
|
||||
Operation *dto.Openapi3Operation `gorm:"column:operation;comment:Tool Openapi Operation Schema;serializer:json" json:"operation"` // Tool Openapi Operation Schema
|
||||
}
|
||||
|
||||
// TableName AgentToolDraft's table name
|
||||
|
||||
@ -4,23 +4,23 @@
|
||||
|
||||
package model
|
||||
|
||||
import "github.com/coze-dev/coze-studio/backend/api/model/crossdomain/plugin"
|
||||
import "github.com/coze-dev/coze-studio/backend/crossdomain/contract/plugin/dto"
|
||||
|
||||
const TableNameAgentToolVersion = "agent_tool_version"
|
||||
|
||||
// AgentToolVersion Agent Tool Version
|
||||
type AgentToolVersion struct {
|
||||
ID int64 `gorm:"column:id;primaryKey;comment:Primary Key ID" json:"id"` // Primary Key ID
|
||||
AgentID int64 `gorm:"column:agent_id;not null;comment:Agent ID" json:"agent_id"` // Agent ID
|
||||
PluginID int64 `gorm:"column:plugin_id;not null;comment:Plugin ID" json:"plugin_id"` // Plugin ID
|
||||
ToolID int64 `gorm:"column:tool_id;not null;comment:Tool ID" json:"tool_id"` // Tool ID
|
||||
AgentVersion string `gorm:"column:agent_version;not null;comment:Agent Tool Version" json:"agent_version"` // Agent Tool Version
|
||||
ToolName string `gorm:"column:tool_name;not null;comment:Tool Name" json:"tool_name"` // Tool Name
|
||||
ToolVersion string `gorm:"column:tool_version;not null;comment:Tool Version, e.g. v1.0.0" json:"tool_version"` // Tool Version, e.g. v1.0.0
|
||||
SubURL string `gorm:"column:sub_url;not null;comment:Sub URL Path" json:"sub_url"` // Sub URL Path
|
||||
Method string `gorm:"column:method;not null;comment:HTTP Request Method" json:"method"` // HTTP Request Method
|
||||
Operation *plugin.Openapi3Operation `gorm:"column:operation;comment:Tool Openapi Operation Schema;serializer:json" json:"operation"` // Tool Openapi Operation Schema
|
||||
CreatedAt int64 `gorm:"column:created_at;not null;autoCreateTime:milli;comment:Create Time in Milliseconds" json:"created_at"` // Create Time in Milliseconds
|
||||
ID int64 `gorm:"column:id;primaryKey;comment:Primary Key ID" json:"id"` // Primary Key ID
|
||||
AgentID int64 `gorm:"column:agent_id;not null;comment:Agent ID" json:"agent_id"` // Agent ID
|
||||
PluginID int64 `gorm:"column:plugin_id;not null;comment:Plugin ID" json:"plugin_id"` // Plugin ID
|
||||
ToolID int64 `gorm:"column:tool_id;not null;comment:Tool ID" json:"tool_id"` // Tool ID
|
||||
AgentVersion string `gorm:"column:agent_version;not null;comment:Agent Tool Version" json:"agent_version"` // Agent Tool Version
|
||||
ToolName string `gorm:"column:tool_name;not null;comment:Tool Name" json:"tool_name"` // Tool Name
|
||||
ToolVersion string `gorm:"column:tool_version;not null;comment:Tool Version, e.g. v1.0.0" json:"tool_version"` // Tool Version, e.g. v1.0.0
|
||||
SubURL string `gorm:"column:sub_url;not null;comment:Sub URL Path" json:"sub_url"` // Sub URL Path
|
||||
Method string `gorm:"column:method;not null;comment:HTTP Request Method" json:"method"` // HTTP Request Method
|
||||
Operation *dto.Openapi3Operation `gorm:"column:operation;comment:Tool Openapi Operation Schema;serializer:json" json:"operation"` // Tool Openapi Operation Schema
|
||||
CreatedAt int64 `gorm:"column:created_at;not null;autoCreateTime:milli;comment:Create Time in Milliseconds" json:"created_at"` // Create Time in Milliseconds
|
||||
}
|
||||
|
||||
// TableName AgentToolVersion's table name
|
||||
|
||||
@ -4,25 +4,25 @@
|
||||
|
||||
package model
|
||||
|
||||
import "github.com/coze-dev/coze-studio/backend/api/model/crossdomain/plugin"
|
||||
import "github.com/coze-dev/coze-studio/backend/crossdomain/contract/plugin/dto"
|
||||
|
||||
const TableNamePlugin = "plugin"
|
||||
|
||||
// Plugin Latest Plugin
|
||||
type Plugin struct {
|
||||
ID int64 `gorm:"column:id;primaryKey;comment:Plugin ID" json:"id"` // Plugin ID
|
||||
SpaceID int64 `gorm:"column:space_id;not null;comment:Space ID" json:"space_id"` // Space ID
|
||||
DeveloperID int64 `gorm:"column:developer_id;not null;comment:Developer ID" json:"developer_id"` // Developer ID
|
||||
AppID int64 `gorm:"column:app_id;not null;comment:Application ID" json:"app_id"` // Application ID
|
||||
IconURI string `gorm:"column:icon_uri;not null;comment:Icon URI" json:"icon_uri"` // Icon URI
|
||||
ServerURL string `gorm:"column:server_url;not null;comment:Server URL" json:"server_url"` // Server URL
|
||||
PluginType int32 `gorm:"column:plugin_type;not null;comment:Plugin Type, 1:http, 6:local" json:"plugin_type"` // Plugin Type, 1:http, 6:local
|
||||
CreatedAt int64 `gorm:"column:created_at;not null;autoCreateTime:milli;comment:Create Time in Milliseconds" json:"created_at"` // Create Time in Milliseconds
|
||||
UpdatedAt int64 `gorm:"column:updated_at;not null;autoUpdateTime:milli;comment:Update Time in Milliseconds" json:"updated_at"` // Update Time in Milliseconds
|
||||
Version string `gorm:"column:version;not null;comment:Plugin Version, e.g. v1.0.0" json:"version"` // Plugin Version, e.g. v1.0.0
|
||||
VersionDesc string `gorm:"column:version_desc;comment:Plugin Version Description" json:"version_desc"` // Plugin Version Description
|
||||
Manifest *plugin.PluginManifest `gorm:"column:manifest;comment:Plugin Manifest;serializer:json" json:"manifest"` // Plugin Manifest
|
||||
OpenapiDoc *plugin.Openapi3T `gorm:"column:openapi_doc;comment:OpenAPI Document, only stores the root;serializer:json" json:"openapi_doc"` // OpenAPI Document, only stores the root
|
||||
ID int64 `gorm:"column:id;primaryKey;comment:Plugin ID" json:"id"` // Plugin ID
|
||||
SpaceID int64 `gorm:"column:space_id;not null;comment:Space ID" json:"space_id"` // Space ID
|
||||
DeveloperID int64 `gorm:"column:developer_id;not null;comment:Developer ID" json:"developer_id"` // Developer ID
|
||||
AppID int64 `gorm:"column:app_id;not null;comment:Application ID" json:"app_id"` // Application ID
|
||||
IconURI string `gorm:"column:icon_uri;not null;comment:Icon URI" json:"icon_uri"` // Icon URI
|
||||
ServerURL string `gorm:"column:server_url;not null;comment:Server URL" json:"server_url"` // Server URL
|
||||
PluginType int32 `gorm:"column:plugin_type;not null;comment:Plugin Type, 1:http, 6:local" json:"plugin_type"` // Plugin Type, 1:http, 6:local
|
||||
CreatedAt int64 `gorm:"column:created_at;not null;autoCreateTime:milli;comment:Create Time in Milliseconds" json:"created_at"` // Create Time in Milliseconds
|
||||
UpdatedAt int64 `gorm:"column:updated_at;not null;autoUpdateTime:milli;comment:Update Time in Milliseconds" json:"updated_at"` // Update Time in Milliseconds
|
||||
Version string `gorm:"column:version;not null;comment:Plugin Version, e.g. v1.0.0" json:"version"` // Plugin Version, e.g. v1.0.0
|
||||
VersionDesc string `gorm:"column:version_desc;comment:Plugin Version Description" json:"version_desc"` // Plugin Version Description
|
||||
Manifest *dto.PluginManifest `gorm:"column:manifest;comment:Plugin Manifest;serializer:json" json:"manifest"` // Plugin Manifest
|
||||
OpenapiDoc *dto.Openapi3T `gorm:"column:openapi_doc;comment:OpenAPI Document, only stores the root;serializer:json" json:"openapi_doc"` // OpenAPI Document, only stores the root
|
||||
}
|
||||
|
||||
// TableName Plugin's table name
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"github.com/coze-dev/coze-studio/backend/api/model/crossdomain/plugin"
|
||||
"github.com/coze-dev/coze-studio/backend/crossdomain/contract/plugin/dto"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
@ -13,18 +13,18 @@ const TableNamePluginDraft = "plugin_draft"
|
||||
|
||||
// PluginDraft Draft Plugin
|
||||
type PluginDraft struct {
|
||||
ID int64 `gorm:"column:id;primaryKey;comment:Plugin ID" json:"id"` // Plugin ID
|
||||
SpaceID int64 `gorm:"column:space_id;not null;comment:Space ID" json:"space_id"` // Space ID
|
||||
DeveloperID int64 `gorm:"column:developer_id;not null;comment:Developer ID" json:"developer_id"` // Developer ID
|
||||
AppID int64 `gorm:"column:app_id;not null;comment:Application ID" json:"app_id"` // Application ID
|
||||
IconURI string `gorm:"column:icon_uri;not null;comment:Icon URI" json:"icon_uri"` // Icon URI
|
||||
ServerURL string `gorm:"column:server_url;not null;comment:Server URL" json:"server_url"` // Server URL
|
||||
PluginType int32 `gorm:"column:plugin_type;not null;comment:Plugin Type, 1:http, 6:local" json:"plugin_type"` // Plugin Type, 1:http, 6:local
|
||||
CreatedAt int64 `gorm:"column:created_at;not null;autoCreateTime:milli;comment:Create Time in Milliseconds" json:"created_at"` // Create Time in Milliseconds
|
||||
UpdatedAt int64 `gorm:"column:updated_at;not null;autoUpdateTime:milli;comment:Update Time in Milliseconds" json:"updated_at"` // Update Time in Milliseconds
|
||||
DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;comment:Delete Time" json:"deleted_at"` // Delete Time
|
||||
Manifest *plugin.PluginManifest `gorm:"column:manifest;comment:Plugin Manifest;serializer:json" json:"manifest"` // Plugin Manifest
|
||||
OpenapiDoc *plugin.Openapi3T `gorm:"column:openapi_doc;comment:OpenAPI Document, only stores the root;serializer:json" json:"openapi_doc"` // OpenAPI Document, only stores the root
|
||||
ID int64 `gorm:"column:id;primaryKey;comment:Plugin ID" json:"id"` // Plugin ID
|
||||
SpaceID int64 `gorm:"column:space_id;not null;comment:Space ID" json:"space_id"` // Space ID
|
||||
DeveloperID int64 `gorm:"column:developer_id;not null;comment:Developer ID" json:"developer_id"` // Developer ID
|
||||
AppID int64 `gorm:"column:app_id;not null;comment:Application ID" json:"app_id"` // Application ID
|
||||
IconURI string `gorm:"column:icon_uri;not null;comment:Icon URI" json:"icon_uri"` // Icon URI
|
||||
ServerURL string `gorm:"column:server_url;not null;comment:Server URL" json:"server_url"` // Server URL
|
||||
PluginType int32 `gorm:"column:plugin_type;not null;comment:Plugin Type, 1:http, 6:local" json:"plugin_type"` // Plugin Type, 1:http, 6:local
|
||||
CreatedAt int64 `gorm:"column:created_at;not null;autoCreateTime:milli;comment:Create Time in Milliseconds" json:"created_at"` // Create Time in Milliseconds
|
||||
UpdatedAt int64 `gorm:"column:updated_at;not null;autoUpdateTime:milli;comment:Update Time in Milliseconds" json:"updated_at"` // Update Time in Milliseconds
|
||||
DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;comment:Delete Time" json:"deleted_at"` // Delete Time
|
||||
Manifest *dto.PluginManifest `gorm:"column:manifest;comment:Plugin Manifest;serializer:json" json:"manifest"` // Plugin Manifest
|
||||
OpenapiDoc *dto.Openapi3T `gorm:"column:openapi_doc;comment:OpenAPI Document, only stores the root;serializer:json" json:"openapi_doc"` // OpenAPI Document, only stores the root
|
||||
}
|
||||
|
||||
// TableName PluginDraft's table name
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
|
||||
package model
|
||||
|
||||
import "github.com/coze-dev/coze-studio/backend/api/model/crossdomain/plugin"
|
||||
import plugin "github.com/coze-dev/coze-studio/backend/crossdomain/contract/plugin/dto"
|
||||
|
||||
const TableNamePluginOauthAuth = "plugin_oauth_auth"
|
||||
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"github.com/coze-dev/coze-studio/backend/api/model/crossdomain/plugin"
|
||||
"github.com/coze-dev/coze-studio/backend/crossdomain/contract/plugin/dto"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
@ -13,20 +13,20 @@ const TableNamePluginVersion = "plugin_version"
|
||||
|
||||
// PluginVersion Plugin Version
|
||||
type PluginVersion struct {
|
||||
ID int64 `gorm:"column:id;primaryKey;comment:Primary Key ID" json:"id"` // Primary Key ID
|
||||
SpaceID int64 `gorm:"column:space_id;not null;comment:Space ID" json:"space_id"` // Space ID
|
||||
DeveloperID int64 `gorm:"column:developer_id;not null;comment:Developer ID" json:"developer_id"` // Developer ID
|
||||
PluginID int64 `gorm:"column:plugin_id;not null;comment:Plugin ID" json:"plugin_id"` // Plugin ID
|
||||
AppID int64 `gorm:"column:app_id;not null;comment:Application ID" json:"app_id"` // Application ID
|
||||
IconURI string `gorm:"column:icon_uri;not null;comment:Icon URI" json:"icon_uri"` // Icon URI
|
||||
ServerURL string `gorm:"column:server_url;not null;comment:Server URL" json:"server_url"` // Server URL
|
||||
PluginType int32 `gorm:"column:plugin_type;not null;comment:Plugin Type, 1:http, 6:local" json:"plugin_type"` // Plugin Type, 1:http, 6:local
|
||||
Version string `gorm:"column:version;not null;comment:Plugin Version, e.g. v1.0.0" json:"version"` // Plugin Version, e.g. v1.0.0
|
||||
VersionDesc string `gorm:"column:version_desc;comment:Plugin Version Description" json:"version_desc"` // Plugin Version Description
|
||||
Manifest *plugin.PluginManifest `gorm:"column:manifest;comment:Plugin Manifest;serializer:json" json:"manifest"` // Plugin Manifest
|
||||
OpenapiDoc *plugin.Openapi3T `gorm:"column:openapi_doc;comment:OpenAPI Document, only stores the root;serializer:json" json:"openapi_doc"` // OpenAPI Document, only stores the root
|
||||
CreatedAt int64 `gorm:"column:created_at;not null;autoCreateTime:milli;comment:Create Time in Milliseconds" json:"created_at"` // Create Time in Milliseconds
|
||||
DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;comment:Delete Time" json:"deleted_at"` // Delete Time
|
||||
ID int64 `gorm:"column:id;primaryKey;comment:Primary Key ID" json:"id"` // Primary Key ID
|
||||
SpaceID int64 `gorm:"column:space_id;not null;comment:Space ID" json:"space_id"` // Space ID
|
||||
DeveloperID int64 `gorm:"column:developer_id;not null;comment:Developer ID" json:"developer_id"` // Developer ID
|
||||
PluginID int64 `gorm:"column:plugin_id;not null;comment:Plugin ID" json:"plugin_id"` // Plugin ID
|
||||
AppID int64 `gorm:"column:app_id;not null;comment:Application ID" json:"app_id"` // Application ID
|
||||
IconURI string `gorm:"column:icon_uri;not null;comment:Icon URI" json:"icon_uri"` // Icon URI
|
||||
ServerURL string `gorm:"column:server_url;not null;comment:Server URL" json:"server_url"` // Server URL
|
||||
PluginType int32 `gorm:"column:plugin_type;not null;comment:Plugin Type, 1:http, 6:local" json:"plugin_type"` // Plugin Type, 1:http, 6:local
|
||||
Version string `gorm:"column:version;not null;comment:Plugin Version, e.g. v1.0.0" json:"version"` // Plugin Version, e.g. v1.0.0
|
||||
VersionDesc string `gorm:"column:version_desc;comment:Plugin Version Description" json:"version_desc"` // Plugin Version Description
|
||||
Manifest *dto.PluginManifest `gorm:"column:manifest;comment:Plugin Manifest;serializer:json" json:"manifest"` // Plugin Manifest
|
||||
OpenapiDoc *dto.Openapi3T `gorm:"column:openapi_doc;comment:OpenAPI Document, only stores the root;serializer:json" json:"openapi_doc"` // OpenAPI Document, only stores the root
|
||||
CreatedAt int64 `gorm:"column:created_at;not null;autoCreateTime:milli;comment:Create Time in Milliseconds" json:"created_at"` // Create Time in Milliseconds
|
||||
DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;comment:Delete Time" json:"deleted_at"` // Delete Time
|
||||
}
|
||||
|
||||
// TableName PluginVersion's table name
|
||||
|
||||
@ -4,21 +4,21 @@
|
||||
|
||||
package model
|
||||
|
||||
import "github.com/coze-dev/coze-studio/backend/api/model/crossdomain/plugin"
|
||||
import "github.com/coze-dev/coze-studio/backend/crossdomain/contract/plugin/dto"
|
||||
|
||||
const TableNameTool = "tool"
|
||||
|
||||
// Tool Latest Tool
|
||||
type Tool struct {
|
||||
ID int64 `gorm:"column:id;primaryKey;comment:Tool ID" json:"id"` // Tool ID
|
||||
PluginID int64 `gorm:"column:plugin_id;not null;comment:Plugin ID" json:"plugin_id"` // Plugin ID
|
||||
CreatedAt int64 `gorm:"column:created_at;not null;autoCreateTime:milli;comment:Create Time in Milliseconds" json:"created_at"` // Create Time in Milliseconds
|
||||
UpdatedAt int64 `gorm:"column:updated_at;not null;autoUpdateTime:milli;comment:Update Time in Milliseconds" json:"updated_at"` // Update Time in Milliseconds
|
||||
Version string `gorm:"column:version;not null;comment:Tool Version, e.g. v1.0.0" json:"version"` // Tool Version, e.g. v1.0.0
|
||||
SubURL string `gorm:"column:sub_url;not null;comment:Sub URL Path" json:"sub_url"` // Sub URL Path
|
||||
Method string `gorm:"column:method;not null;comment:HTTP Request Method" json:"method"` // HTTP Request Method
|
||||
Operation *plugin.Openapi3Operation `gorm:"column:operation;comment:Tool Openapi Operation Schema;serializer:json" json:"operation"` // Tool Openapi Operation Schema
|
||||
ActivatedStatus int32 `gorm:"column:activated_status;not null;comment:0:activated; 1:deactivated" json:"activated_status"` // 0:activated; 1:deactivated
|
||||
ID int64 `gorm:"column:id;primaryKey;comment:Tool ID" json:"id"` // Tool ID
|
||||
PluginID int64 `gorm:"column:plugin_id;not null;comment:Plugin ID" json:"plugin_id"` // Plugin ID
|
||||
CreatedAt int64 `gorm:"column:created_at;not null;autoCreateTime:milli;comment:Create Time in Milliseconds" json:"created_at"` // Create Time in Milliseconds
|
||||
UpdatedAt int64 `gorm:"column:updated_at;not null;autoUpdateTime:milli;comment:Update Time in Milliseconds" json:"updated_at"` // Update Time in Milliseconds
|
||||
Version string `gorm:"column:version;not null;comment:Tool Version, e.g. v1.0.0" json:"version"` // Tool Version, e.g. v1.0.0
|
||||
SubURL string `gorm:"column:sub_url;not null;comment:Sub URL Path" json:"sub_url"` // Sub URL Path
|
||||
Method string `gorm:"column:method;not null;comment:HTTP Request Method" json:"method"` // HTTP Request Method
|
||||
Operation *dto.Openapi3Operation `gorm:"column:operation;comment:Tool Openapi Operation Schema;serializer:json" json:"operation"` // Tool Openapi Operation Schema
|
||||
ActivatedStatus int32 `gorm:"column:activated_status;not null;comment:0:activated; 1:deactivated" json:"activated_status"` // 0:activated; 1:deactivated
|
||||
}
|
||||
|
||||
// TableName Tool's table name
|
||||
|
||||
@ -4,21 +4,21 @@
|
||||
|
||||
package model
|
||||
|
||||
import "github.com/coze-dev/coze-studio/backend/api/model/crossdomain/plugin"
|
||||
import "github.com/coze-dev/coze-studio/backend/crossdomain/contract/plugin/dto"
|
||||
|
||||
const TableNameToolDraft = "tool_draft"
|
||||
|
||||
// ToolDraft Draft Tool
|
||||
type ToolDraft struct {
|
||||
ID int64 `gorm:"column:id;primaryKey;comment:Tool ID" json:"id"` // Tool ID
|
||||
PluginID int64 `gorm:"column:plugin_id;not null;comment:Plugin ID" json:"plugin_id"` // Plugin ID
|
||||
CreatedAt int64 `gorm:"column:created_at;not null;autoCreateTime:milli;comment:Create Time in Milliseconds" json:"created_at"` // Create Time in Milliseconds
|
||||
UpdatedAt int64 `gorm:"column:updated_at;not null;autoUpdateTime:milli;comment:Update Time in Milliseconds" json:"updated_at"` // Update Time in Milliseconds
|
||||
SubURL string `gorm:"column:sub_url;not null;comment:Sub URL Path" json:"sub_url"` // Sub URL Path
|
||||
Method string `gorm:"column:method;not null;comment:HTTP Request Method" json:"method"` // HTTP Request Method
|
||||
Operation *plugin.Openapi3Operation `gorm:"column:operation;comment:Tool Openapi Operation Schema;serializer:json" json:"operation"` // Tool Openapi Operation Schema
|
||||
DebugStatus int32 `gorm:"column:debug_status;not null;comment:0:not pass; 1:pass" json:"debug_status"` // 0:not pass; 1:pass
|
||||
ActivatedStatus int32 `gorm:"column:activated_status;not null;comment:0:activated; 1:deactivated" json:"activated_status"` // 0:activated; 1:deactivated
|
||||
ID int64 `gorm:"column:id;primaryKey;comment:Tool ID" json:"id"` // Tool ID
|
||||
PluginID int64 `gorm:"column:plugin_id;not null;comment:Plugin ID" json:"plugin_id"` // Plugin ID
|
||||
CreatedAt int64 `gorm:"column:created_at;not null;autoCreateTime:milli;comment:Create Time in Milliseconds" json:"created_at"` // Create Time in Milliseconds
|
||||
UpdatedAt int64 `gorm:"column:updated_at;not null;autoUpdateTime:milli;comment:Update Time in Milliseconds" json:"updated_at"` // Update Time in Milliseconds
|
||||
SubURL string `gorm:"column:sub_url;not null;comment:Sub URL Path" json:"sub_url"` // Sub URL Path
|
||||
Method string `gorm:"column:method;not null;comment:HTTP Request Method" json:"method"` // HTTP Request Method
|
||||
Operation *dto.Openapi3Operation `gorm:"column:operation;comment:Tool Openapi Operation Schema;serializer:json" json:"operation"` // Tool Openapi Operation Schema
|
||||
DebugStatus int32 `gorm:"column:debug_status;not null;comment:0:not pass; 1:pass" json:"debug_status"` // 0:not pass; 1:pass
|
||||
ActivatedStatus int32 `gorm:"column:activated_status;not null;comment:0:activated; 1:deactivated" json:"activated_status"` // 0:activated; 1:deactivated
|
||||
}
|
||||
|
||||
// TableName ToolDraft's table name
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"github.com/coze-dev/coze-studio/backend/api/model/crossdomain/plugin"
|
||||
"github.com/coze-dev/coze-studio/backend/crossdomain/contract/plugin/dto"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
@ -13,15 +13,15 @@ const TableNameToolVersion = "tool_version"
|
||||
|
||||
// ToolVersion Tool Version
|
||||
type ToolVersion struct {
|
||||
ID int64 `gorm:"column:id;primaryKey;comment:Primary Key ID" json:"id"` // Primary Key ID
|
||||
ToolID int64 `gorm:"column:tool_id;not null;comment:Tool ID" json:"tool_id"` // Tool ID
|
||||
PluginID int64 `gorm:"column:plugin_id;not null;comment:Plugin ID" json:"plugin_id"` // Plugin ID
|
||||
Version string `gorm:"column:version;not null;comment:Tool Version, e.g. v1.0.0" json:"version"` // Tool Version, e.g. v1.0.0
|
||||
SubURL string `gorm:"column:sub_url;not null;comment:Sub URL Path" json:"sub_url"` // Sub URL Path
|
||||
Method string `gorm:"column:method;not null;comment:HTTP Request Method" json:"method"` // HTTP Request Method
|
||||
Operation *plugin.Openapi3Operation `gorm:"column:operation;comment:Tool Openapi Operation Schema;serializer:json" json:"operation"` // Tool Openapi Operation Schema
|
||||
CreatedAt int64 `gorm:"column:created_at;not null;autoCreateTime:milli;comment:Create Time in Milliseconds" json:"created_at"` // Create Time in Milliseconds
|
||||
DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;comment:Delete Time" json:"deleted_at"` // Delete Time
|
||||
ID int64 `gorm:"column:id;primaryKey;comment:Primary Key ID" json:"id"` // Primary Key ID
|
||||
ToolID int64 `gorm:"column:tool_id;not null;comment:Tool ID" json:"tool_id"` // Tool ID
|
||||
PluginID int64 `gorm:"column:plugin_id;not null;comment:Plugin ID" json:"plugin_id"` // Plugin ID
|
||||
Version string `gorm:"column:version;not null;comment:Tool Version, e.g. v1.0.0" json:"version"` // Tool Version, e.g. v1.0.0
|
||||
SubURL string `gorm:"column:sub_url;not null;comment:Sub URL Path" json:"sub_url"` // Sub URL Path
|
||||
Method string `gorm:"column:method;not null;comment:HTTP Request Method" json:"method"` // HTTP Request Method
|
||||
Operation *dto.Openapi3Operation `gorm:"column:operation;comment:Tool Openapi Operation Schema;serializer:json" json:"operation"` // Tool Openapi Operation Schema
|
||||
CreatedAt int64 `gorm:"column:created_at;not null;autoCreateTime:milli;comment:Create Time in Milliseconds" json:"created_at"` // Create Time in Milliseconds
|
||||
DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;comment:Delete Time" json:"deleted_at"` // Delete Time
|
||||
}
|
||||
|
||||
// TableName ToolVersion's table name
|
||||
|
||||
@ -25,8 +25,8 @@ import (
|
||||
"gorm.io/gen/field"
|
||||
"gorm.io/gorm"
|
||||
|
||||
"github.com/coze-dev/coze-studio/backend/api/model/crossdomain/plugin"
|
||||
plugin_develop_common "github.com/coze-dev/coze-studio/backend/api/model/plugin_develop/common"
|
||||
plugindto "github.com/coze-dev/coze-studio/backend/crossdomain/contract/plugin/dto"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/plugin/entity"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/plugin/internal/dal/model"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/plugin/internal/dal/query"
|
||||
@ -49,7 +49,7 @@ type PluginDAO struct {
|
||||
type pluginPO model.Plugin
|
||||
|
||||
func (p pluginPO) ToDO() *entity.PluginInfo {
|
||||
return entity.NewPluginInfo(&plugin.PluginInfo{
|
||||
return entity.NewPluginInfo(&plugindto.PluginInfo{
|
||||
ID: p.ID,
|
||||
SpaceID: p.SpaceID,
|
||||
DeveloperID: p.DeveloperID,
|
||||
@ -174,56 +174,56 @@ func (p *PluginDAO) List(ctx context.Context, spaceID int64, pageInfo entity.Pag
|
||||
return plugins, total, nil
|
||||
}
|
||||
|
||||
func (p *PluginDAO) UpsertWithTX(ctx context.Context, tx *query.QueryTx, plugin *entity.PluginInfo) (err error) {
|
||||
func (p *PluginDAO) UpsertWithTX(ctx context.Context, tx *query.QueryTx, pluginInfo *entity.PluginInfo) (err error) {
|
||||
table := tx.Plugin
|
||||
_, err = table.WithContext(ctx).Select(table.ID).Where(table.ID.Eq(plugin.ID)).First()
|
||||
_, err = table.WithContext(ctx).Select(table.ID).Where(table.ID.Eq(pluginInfo.ID)).First()
|
||||
if err != nil {
|
||||
if !errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return err
|
||||
}
|
||||
|
||||
m := &model.Plugin{
|
||||
ID: plugin.ID,
|
||||
SpaceID: plugin.SpaceID,
|
||||
DeveloperID: plugin.DeveloperID,
|
||||
AppID: plugin.GetAPPID(),
|
||||
Manifest: plugin.Manifest,
|
||||
OpenapiDoc: plugin.OpenapiDoc,
|
||||
PluginType: int32(plugin.PluginType),
|
||||
IconURI: plugin.GetIconURI(),
|
||||
ServerURL: plugin.GetServerURL(),
|
||||
Version: plugin.GetVersion(),
|
||||
VersionDesc: plugin.GetVersionDesc(),
|
||||
ID: pluginInfo.ID,
|
||||
SpaceID: pluginInfo.SpaceID,
|
||||
DeveloperID: pluginInfo.DeveloperID,
|
||||
AppID: pluginInfo.GetAPPID(),
|
||||
Manifest: pluginInfo.Manifest,
|
||||
OpenapiDoc: pluginInfo.OpenapiDoc,
|
||||
PluginType: int32(pluginInfo.PluginType),
|
||||
IconURI: pluginInfo.GetIconURI(),
|
||||
ServerURL: pluginInfo.GetServerURL(),
|
||||
Version: pluginInfo.GetVersion(),
|
||||
VersionDesc: pluginInfo.GetVersionDesc(),
|
||||
}
|
||||
|
||||
return table.WithContext(ctx).Create(m)
|
||||
}
|
||||
|
||||
updateMap := map[string]any{}
|
||||
if plugin.APPID != nil {
|
||||
updateMap[table.AppID.ColumnName().String()] = *plugin.APPID
|
||||
if pluginInfo.APPID != nil {
|
||||
updateMap[table.AppID.ColumnName().String()] = *pluginInfo.APPID
|
||||
}
|
||||
if plugin.IconURI != nil {
|
||||
updateMap[table.IconURI.ColumnName().String()] = *plugin.IconURI
|
||||
if pluginInfo.IconURI != nil {
|
||||
updateMap[table.IconURI.ColumnName().String()] = *pluginInfo.IconURI
|
||||
}
|
||||
if plugin.Version != nil {
|
||||
updateMap[table.Version.ColumnName().String()] = *plugin.Version
|
||||
if pluginInfo.Version != nil {
|
||||
updateMap[table.Version.ColumnName().String()] = *pluginInfo.Version
|
||||
}
|
||||
if plugin.VersionDesc != nil {
|
||||
updateMap[table.VersionDesc.ColumnName().String()] = *plugin.VersionDesc
|
||||
if pluginInfo.VersionDesc != nil {
|
||||
updateMap[table.VersionDesc.ColumnName().String()] = *pluginInfo.VersionDesc
|
||||
}
|
||||
if plugin.ServerURL != nil {
|
||||
updateMap[table.ServerURL.ColumnName().String()] = *plugin.ServerURL
|
||||
if pluginInfo.ServerURL != nil {
|
||||
updateMap[table.ServerURL.ColumnName().String()] = *pluginInfo.ServerURL
|
||||
}
|
||||
if plugin.Manifest != nil {
|
||||
b, err := json.Marshal(plugin.Manifest)
|
||||
if pluginInfo.Manifest != nil {
|
||||
b, err := json.Marshal(pluginInfo.Manifest)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
updateMap[table.Manifest.ColumnName().String()] = b
|
||||
}
|
||||
if plugin.OpenapiDoc != nil {
|
||||
b, err := json.Marshal(plugin.OpenapiDoc)
|
||||
if pluginInfo.OpenapiDoc != nil {
|
||||
b, err := json.Marshal(pluginInfo.OpenapiDoc)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -231,7 +231,7 @@ func (p *PluginDAO) UpsertWithTX(ctx context.Context, tx *query.QueryTx, plugin
|
||||
}
|
||||
|
||||
_, err = table.WithContext(ctx).
|
||||
Where(table.ID.Eq(plugin.ID)).
|
||||
Where(table.ID.Eq(pluginInfo.ID)).
|
||||
Updates(updateMap)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
@ -25,8 +25,8 @@ import (
|
||||
"gorm.io/gen/field"
|
||||
"gorm.io/gorm"
|
||||
|
||||
pluginModel "github.com/coze-dev/coze-studio/backend/api/model/crossdomain/plugin"
|
||||
plugin_develop_common "github.com/coze-dev/coze-studio/backend/api/model/plugin_develop/common"
|
||||
pluginModel "github.com/coze-dev/coze-studio/backend/crossdomain/contract/plugin/dto"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/plugin/conf"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/plugin/entity"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/plugin/internal/dal/model"
|
||||
|
||||
@ -24,8 +24,8 @@ import (
|
||||
"gorm.io/gen/field"
|
||||
"gorm.io/gorm"
|
||||
|
||||
"github.com/coze-dev/coze-studio/backend/api/model/crossdomain/plugin"
|
||||
plugin_develop_common "github.com/coze-dev/coze-studio/backend/api/model/plugin_develop/common"
|
||||
"github.com/coze-dev/coze-studio/backend/crossdomain/contract/plugin/dto"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/plugin/entity"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/plugin/internal/dal/model"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/plugin/internal/dal/query"
|
||||
@ -48,7 +48,7 @@ type PluginVersionDAO struct {
|
||||
type pluginVersionPO model.PluginVersion
|
||||
|
||||
func (p pluginVersionPO) ToDO() *entity.PluginInfo {
|
||||
return entity.NewPluginInfo(&plugin.PluginInfo{
|
||||
return entity.NewPluginInfo(&dto.PluginInfo{
|
||||
ID: p.PluginID,
|
||||
SpaceID: p.SpaceID,
|
||||
APPID: &p.AppID,
|
||||
|
||||
@ -24,7 +24,7 @@ import (
|
||||
"gorm.io/gen/field"
|
||||
"gorm.io/gorm"
|
||||
|
||||
"github.com/coze-dev/coze-studio/backend/api/model/crossdomain/plugin"
|
||||
plugindto "github.com/coze-dev/coze-studio/backend/crossdomain/contract/plugin/dto"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/plugin/entity"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/plugin/internal/dal/model"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/plugin/internal/dal/query"
|
||||
@ -57,7 +57,7 @@ func (t toolPO) ToDO() *entity.ToolInfo {
|
||||
SubURL: &t.SubURL,
|
||||
Method: ptr.Of(t.Method),
|
||||
Operation: t.Operation,
|
||||
ActivatedStatus: ptr.Of(plugin.ActivatedStatus(t.ActivatedStatus)),
|
||||
ActivatedStatus: ptr.Of(plugindto.ActivatedStatus(t.ActivatedStatus)),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -25,8 +25,8 @@ import (
|
||||
"gorm.io/gen/field"
|
||||
"gorm.io/gorm"
|
||||
|
||||
"github.com/coze-dev/coze-studio/backend/api/model/crossdomain/plugin"
|
||||
common "github.com/coze-dev/coze-studio/backend/api/model/plugin_develop/common"
|
||||
plugindto "github.com/coze-dev/coze-studio/backend/crossdomain/contract/plugin/dto"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/plugin/conf"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/plugin/entity"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/plugin/internal/dal/model"
|
||||
@ -60,7 +60,7 @@ func (t toolDraftPO) ToDO() *entity.ToolInfo {
|
||||
Method: ptr.Of(t.Method),
|
||||
Operation: t.Operation,
|
||||
DebugStatus: ptr.Of(common.APIDebugStatus(t.DebugStatus)),
|
||||
ActivatedStatus: ptr.Of(plugin.ActivatedStatus(t.ActivatedStatus)),
|
||||
ActivatedStatus: ptr.Of(plugindto.ActivatedStatus(t.ActivatedStatus)),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -27,7 +27,7 @@ import (
|
||||
"github.com/shopspring/decimal"
|
||||
"gopkg.in/yaml.v3"
|
||||
|
||||
"github.com/coze-dev/coze-studio/backend/api/model/crossdomain/plugin"
|
||||
plugin "github.com/coze-dev/coze-studio/backend/crossdomain/contract/plugin/dto"
|
||||
)
|
||||
|
||||
func EncodeBodyWithContentType(contentType string, body map[string]any) ([]byte, error) {
|
||||
|
||||
@ -34,7 +34,7 @@ import (
|
||||
postman "github.com/rbretecher/go-postman-collection"
|
||||
"gopkg.in/yaml.v3"
|
||||
|
||||
model "github.com/coze-dev/coze-studio/backend/api/model/crossdomain/plugin"
|
||||
model "github.com/coze-dev/coze-studio/backend/crossdomain/contract/plugin/dto"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/plugin/entity"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/errorx"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/lang/ptr"
|
||||
|
||||
@ -25,8 +25,8 @@ import (
|
||||
"github.com/jinzhu/copier"
|
||||
"gorm.io/gorm"
|
||||
|
||||
model "github.com/coze-dev/coze-studio/backend/api/model/crossdomain/plugin"
|
||||
common "github.com/coze-dev/coze-studio/backend/api/model/plugin_develop/common"
|
||||
model "github.com/coze-dev/coze-studio/backend/crossdomain/contract/plugin/dto"
|
||||
pluginConf "github.com/coze-dev/coze-studio/backend/domain/plugin/conf"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/plugin/entity"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/plugin/internal/dal"
|
||||
|
||||
@ -19,7 +19,7 @@ package repository
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/coze-dev/coze-studio/backend/api/model/crossdomain/plugin"
|
||||
plugin "github.com/coze-dev/coze-studio/backend/crossdomain/contract/plugin/dto"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/plugin/entity"
|
||||
)
|
||||
|
||||
|
||||
@ -24,7 +24,8 @@ import (
|
||||
|
||||
"github.com/getkin/kin-openapi/openapi3"
|
||||
|
||||
model "github.com/coze-dev/coze-studio/backend/api/model/crossdomain/plugin"
|
||||
model "github.com/coze-dev/coze-studio/backend/crossdomain/contract/plugin/dto"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/plugin/dto"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/plugin/entity"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/plugin/repository"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/errorx"
|
||||
@ -64,7 +65,7 @@ func (p *pluginServiceImpl) GetDraftAgentToolByName(ctx context.Context, agentID
|
||||
return draftAgentTool, nil
|
||||
}
|
||||
|
||||
func (p *pluginServiceImpl) MGetAgentTools(ctx context.Context, req *MGetAgentToolsRequest) (tools []*entity.ToolInfo, err error) {
|
||||
func (p *pluginServiceImpl) MGetAgentTools(ctx context.Context, req *model.MGetAgentToolsRequest) (tools []*entity.ToolInfo, err error) {
|
||||
toolIDs := make([]int64, 0, len(req.VersionAgentTools))
|
||||
for _, v := range req.VersionAgentTools {
|
||||
toolIDs = append(toolIDs, v.ToolID)
|
||||
@ -129,7 +130,7 @@ func (p *pluginServiceImpl) PublishAgentTools(ctx context.Context, agentID int64
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *pluginServiceImpl) UpdateBotDefaultParams(ctx context.Context, req *UpdateBotDefaultParamsRequest) (err error) {
|
||||
func (p *pluginServiceImpl) UpdateBotDefaultParams(ctx context.Context, req *dto.UpdateBotDefaultParamsRequest) (err error) {
|
||||
_, exist, err := p.pluginRepo.GetOnlinePlugin(ctx, req.PluginID, repository.WithPluginID())
|
||||
if err != nil {
|
||||
return errorx.Wrapf(err, "GetOnlinePlugin failed, pluginID=%d", req.PluginID)
|
||||
|
||||
@ -28,8 +28,8 @@ import (
|
||||
"github.com/bytedance/sonic"
|
||||
"github.com/getkin/kin-openapi/openapi3"
|
||||
|
||||
model "github.com/coze-dev/coze-studio/backend/api/model/crossdomain/plugin"
|
||||
common "github.com/coze-dev/coze-studio/backend/api/model/plugin_develop/common"
|
||||
model "github.com/coze-dev/coze-studio/backend/crossdomain/contract/plugin/dto"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/plugin/entity"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/plugin/service/tool"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/storage"
|
||||
@ -39,7 +39,7 @@ import (
|
||||
"github.com/coze-dev/coze-studio/backend/types/errno"
|
||||
)
|
||||
|
||||
func (p *pluginServiceImpl) ExecuteTool(ctx context.Context, req *ExecuteToolRequest, opts ...entity.ExecuteToolOpt) (resp *ExecuteToolResponse, err error) {
|
||||
func (p *pluginServiceImpl) ExecuteTool(ctx context.Context, req *model.ExecuteToolRequest, opts ...entity.ExecuteToolOpt) (resp *model.ExecuteToolResponse, err error) {
|
||||
opt := &model.ExecuteToolOption{}
|
||||
for _, fn := range opts {
|
||||
fn(opt)
|
||||
@ -79,7 +79,7 @@ func (p *pluginServiceImpl) ExecuteTool(ctx context.Context, req *ExecuteToolReq
|
||||
}
|
||||
}
|
||||
|
||||
resp = &ExecuteToolResponse{
|
||||
resp = &model.ExecuteToolResponse{
|
||||
Tool: executor.tool,
|
||||
Request: result.Request,
|
||||
RawResp: result.RawResp,
|
||||
@ -90,7 +90,7 @@ func (p *pluginServiceImpl) ExecuteTool(ctx context.Context, req *ExecuteToolReq
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
func (p *pluginServiceImpl) acquireAccessTokenIfNeed(ctx context.Context, req *ExecuteToolRequest, authInfo *model.AuthV2,
|
||||
func (p *pluginServiceImpl) acquireAccessTokenIfNeed(ctx context.Context, req *model.ExecuteToolRequest, authInfo *model.AuthV2,
|
||||
schema *model.Openapi3Operation) (accessToken string, authURL string, err error) {
|
||||
if authInfo.Type == model.AuthzTypeOfNone {
|
||||
return "", "", nil
|
||||
@ -132,7 +132,7 @@ func (p *pluginServiceImpl) acquireAccessTokenIfNeed(ctx context.Context, req *E
|
||||
return accessToken, authURL, nil
|
||||
}
|
||||
|
||||
func (p *pluginServiceImpl) buildToolExecutor(ctx context.Context, req *ExecuteToolRequest, opt *model.ExecuteToolOption) (impl *toolExecutor, err error) {
|
||||
func (p *pluginServiceImpl) buildToolExecutor(ctx context.Context, req *model.ExecuteToolRequest, opt *model.ExecuteToolOption) (impl *toolExecutor, err error) {
|
||||
if req.UserID == "" {
|
||||
return nil, errorx.New(errno.ErrPluginExecuteToolFailed, errorx.KV(errno.PluginMsgKey, "userID is required"))
|
||||
}
|
||||
@ -175,7 +175,7 @@ func (p *pluginServiceImpl) buildToolExecutor(ctx context.Context, req *ExecuteT
|
||||
return impl, nil
|
||||
}
|
||||
|
||||
func (p *pluginServiceImpl) getDraftAgentPluginInfo(ctx context.Context, req *ExecuteToolRequest,
|
||||
func (p *pluginServiceImpl) getDraftAgentPluginInfo(ctx context.Context, req *model.ExecuteToolRequest,
|
||||
execOpt *model.ExecuteToolOption) (onlinePlugin *entity.PluginInfo, onlineTool *entity.ToolInfo, err error) {
|
||||
|
||||
if req.ExecDraftTool {
|
||||
@ -227,7 +227,7 @@ func (p *pluginServiceImpl) getDraftAgentPluginInfo(ctx context.Context, req *Ex
|
||||
return onlinePlugin, onlineTool, nil
|
||||
}
|
||||
|
||||
func (p *pluginServiceImpl) getOnlineAgentPluginInfo(ctx context.Context, req *ExecuteToolRequest,
|
||||
func (p *pluginServiceImpl) getOnlineAgentPluginInfo(ctx context.Context, req *model.ExecuteToolRequest,
|
||||
execOpt *model.ExecuteToolOption) (onlinePlugin *entity.PluginInfo, onlineTool *entity.ToolInfo, err error) {
|
||||
|
||||
if req.ExecDraftTool {
|
||||
@ -283,7 +283,7 @@ func (p *pluginServiceImpl) getOnlineAgentPluginInfo(ctx context.Context, req *E
|
||||
return onlinePlugin, onlineTool, nil
|
||||
}
|
||||
|
||||
func (p *pluginServiceImpl) getWorkflowPluginInfo(ctx context.Context, req *ExecuteToolRequest,
|
||||
func (p *pluginServiceImpl) getWorkflowPluginInfo(ctx context.Context, req *model.ExecuteToolRequest,
|
||||
execOpt *model.ExecuteToolOption) (pl *entity.PluginInfo, tl *entity.ToolInfo, err error) {
|
||||
|
||||
if req.ExecDraftTool {
|
||||
@ -351,7 +351,7 @@ func (p *pluginServiceImpl) getWorkflowPluginInfo(ctx context.Context, req *Exec
|
||||
return pl, tl, nil
|
||||
}
|
||||
|
||||
func (p *pluginServiceImpl) getToolDebugPluginInfo(ctx context.Context, req *ExecuteToolRequest,
|
||||
func (p *pluginServiceImpl) getToolDebugPluginInfo(ctx context.Context, req *model.ExecuteToolRequest,
|
||||
_ *model.ExecuteToolOption) (pl *entity.PluginInfo, tl *entity.ToolInfo, err error) {
|
||||
|
||||
if req.ExecDraftTool {
|
||||
|
||||
@ -27,7 +27,7 @@ import (
|
||||
"github.com/getkin/kin-openapi/openapi3"
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
||||
model "github.com/coze-dev/coze-studio/backend/api/model/crossdomain/plugin"
|
||||
model "github.com/coze-dev/coze-studio/backend/crossdomain/contract/plugin/dto"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/errorx"
|
||||
)
|
||||
|
||||
|
||||
@ -28,12 +28,13 @@ import (
|
||||
"github.com/getkin/kin-openapi/openapi3"
|
||||
"gopkg.in/yaml.v3"
|
||||
|
||||
model "github.com/coze-dev/coze-studio/backend/api/model/crossdomain/plugin"
|
||||
searchModel "github.com/coze-dev/coze-studio/backend/api/model/crossdomain/search"
|
||||
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"
|
||||
resCommon "github.com/coze-dev/coze-studio/backend/api/model/resource/common"
|
||||
model "github.com/coze-dev/coze-studio/backend/crossdomain/contract/plugin/dto"
|
||||
crosssearch "github.com/coze-dev/coze-studio/backend/crossdomain/contract/search"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/plugin/dto"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/plugin/entity"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/plugin/internal/openapi"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/plugin/repository"
|
||||
@ -44,7 +45,7 @@ import (
|
||||
"github.com/coze-dev/coze-studio/backend/types/errno"
|
||||
)
|
||||
|
||||
func (p *pluginServiceImpl) CreateDraftPlugin(ctx context.Context, req *CreateDraftPluginRequest) (pluginID int64, err error) {
|
||||
func (p *pluginServiceImpl) CreateDraftPlugin(ctx context.Context, req *dto.CreateDraftPluginRequest) (pluginID int64, err error) {
|
||||
mf := entity.NewDefaultPluginManifest()
|
||||
mf.CommonParams = map[model.HTTPParamLocation][]*plugin_develop_common.CommonParamSchema{}
|
||||
mf.NameForHuman = req.Name
|
||||
@ -54,7 +55,7 @@ func (p *pluginServiceImpl) CreateDraftPlugin(ctx context.Context, req *CreateDr
|
||||
mf.API.Type, _ = model.ToPluginType(req.PluginType)
|
||||
mf.LogoURL = req.IconURI
|
||||
|
||||
authV2, err := req.AuthInfo.toAuthV2()
|
||||
authV2, err := req.AuthInfo.ToAuthV2()
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
@ -130,7 +131,7 @@ func (p *pluginServiceImpl) MGetDraftPlugins(ctx context.Context, pluginIDs []in
|
||||
return plugins, nil
|
||||
}
|
||||
|
||||
func (p *pluginServiceImpl) ListDraftPlugins(ctx context.Context, req *ListDraftPluginsRequest) (resp *ListDraftPluginsResponse, err error) {
|
||||
func (p *pluginServiceImpl) ListDraftPlugins(ctx context.Context, req *dto.ListDraftPluginsRequest) (resp *dto.ListDraftPluginsResponse, err error) {
|
||||
if req.PageInfo.Name == nil || *req.PageInfo.Name == "" {
|
||||
res, err := p.pluginRepo.ListDraftPlugins(ctx, &repository.ListDraftPluginsRequest{
|
||||
SpaceID: req.SpaceID,
|
||||
@ -141,7 +142,7 @@ func (p *pluginServiceImpl) ListDraftPlugins(ctx context.Context, req *ListDraft
|
||||
return nil, errorx.Wrapf(err, "ListDraftPlugins failed, spaceID=%d, appID=%d", req.SpaceID, req.APPID)
|
||||
}
|
||||
|
||||
return &ListDraftPluginsResponse{
|
||||
return &dto.ListDraftPluginsResponse{
|
||||
Plugins: res.Plugins,
|
||||
Total: res.Total,
|
||||
}, nil
|
||||
@ -186,13 +187,13 @@ func (p *pluginServiceImpl) ListDraftPlugins(ctx context.Context, req *ListDraft
|
||||
total = *res.TotalHits
|
||||
}
|
||||
|
||||
return &ListDraftPluginsResponse{
|
||||
return &dto.ListDraftPluginsResponse{
|
||||
Plugins: plugins,
|
||||
Total: total,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (p *pluginServiceImpl) CreateDraftPluginWithCode(ctx context.Context, req *CreateDraftPluginWithCodeRequest) (resp *CreateDraftPluginWithCodeResponse, err error) {
|
||||
func (p *pluginServiceImpl) CreateDraftPluginWithCode(ctx context.Context, req *dto.CreateDraftPluginWithCodeRequest) (resp *dto.CreateDraftPluginWithCodeResponse, err error) {
|
||||
err = req.OpenapiDoc.Validate(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -213,7 +214,7 @@ func (p *pluginServiceImpl) CreateDraftPluginWithCode(ctx context.Context, req *
|
||||
return nil, errorx.Wrapf(err, "CreateDraftPluginWithCode failed")
|
||||
}
|
||||
|
||||
resp = &CreateDraftPluginWithCodeResponse{
|
||||
resp = &dto.CreateDraftPluginWithCodeResponse{
|
||||
Plugin: res.Plugin,
|
||||
Tools: res.Tools,
|
||||
}
|
||||
@ -221,7 +222,7 @@ func (p *pluginServiceImpl) CreateDraftPluginWithCode(ctx context.Context, req *
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
func (p *pluginServiceImpl) UpdateDraftPluginWithCode(ctx context.Context, req *UpdateDraftPluginWithCodeRequest) (err error) {
|
||||
func (p *pluginServiceImpl) UpdateDraftPluginWithCode(ctx context.Context, req *dto.UpdateDraftPluginWithCodeRequest) (err error) {
|
||||
doc := req.OpenapiDoc
|
||||
mf := req.Manifest
|
||||
|
||||
@ -451,7 +452,7 @@ func isJsonSchemaEqual(nsc, osc *openapi3.Schema) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func (p *pluginServiceImpl) UpdateDraftPlugin(ctx context.Context, req *UpdateDraftPluginRequest) (err error) {
|
||||
func (p *pluginServiceImpl) UpdateDraftPlugin(ctx context.Context, req *dto.UpdateDraftPluginRequest) (err error) {
|
||||
oldPlugin, exist, err := p.pluginRepo.GetDraftPlugin(ctx, req.PluginID)
|
||||
if err != nil {
|
||||
return errorx.Wrapf(err, "GetDraftPlugin failed, pluginID=%d", req.PluginID)
|
||||
@ -494,7 +495,7 @@ func (p *pluginServiceImpl) UpdateDraftPlugin(ctx context.Context, req *UpdateDr
|
||||
return nil
|
||||
}
|
||||
|
||||
func updatePluginOpenapiDoc(_ context.Context, doc *model.Openapi3T, req *UpdateDraftPluginRequest) (*model.Openapi3T, error) {
|
||||
func updatePluginOpenapiDoc(_ context.Context, doc *model.Openapi3T, req *dto.UpdateDraftPluginRequest) (*model.Openapi3T, error) {
|
||||
if req.Name != nil {
|
||||
doc.Info.Title = *req.Name
|
||||
}
|
||||
@ -518,7 +519,7 @@ func updatePluginOpenapiDoc(_ context.Context, doc *model.Openapi3T, req *Update
|
||||
return doc, nil
|
||||
}
|
||||
|
||||
func updatePluginManifest(_ context.Context, mf *entity.PluginManifest, req *UpdateDraftPluginRequest) (*entity.PluginManifest, error) {
|
||||
func updatePluginManifest(_ context.Context, mf *entity.PluginManifest, req *dto.UpdateDraftPluginRequest) (*entity.PluginManifest, error) {
|
||||
if req.Name != nil {
|
||||
mf.NameForHuman = *req.Name
|
||||
mf.NameForModel = *req.Name
|
||||
@ -554,7 +555,7 @@ func updatePluginManifest(_ context.Context, mf *entity.PluginManifest, req *Upd
|
||||
}
|
||||
|
||||
if req.AuthInfo != nil {
|
||||
authV2, err := req.AuthInfo.toAuthV2()
|
||||
authV2, err := req.AuthInfo.ToAuthV2()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -578,7 +579,7 @@ func (p *pluginServiceImpl) MGetDraftTools(ctx context.Context, toolIDs []int64)
|
||||
return tools, nil
|
||||
}
|
||||
|
||||
func (p *pluginServiceImpl) UpdateDraftTool(ctx context.Context, req *UpdateDraftToolRequest) (err error) {
|
||||
func (p *pluginServiceImpl) UpdateDraftTool(ctx context.Context, req *dto.UpdateDraftToolRequest) (err error) {
|
||||
draftPlugin, exist, err := p.pluginRepo.GetDraftPlugin(ctx, req.PluginID)
|
||||
if err != nil {
|
||||
return errorx.Wrapf(err, "GetDraftPlugin failed, pluginID=%d", req.PluginID)
|
||||
@ -602,7 +603,7 @@ func (p *pluginServiceImpl) UpdateDraftTool(ctx context.Context, req *UpdateDraf
|
||||
return p.updateDraftTool(ctx, req, draftTool)
|
||||
}
|
||||
|
||||
func (p *pluginServiceImpl) updateDraftTool(ctx context.Context, req *UpdateDraftToolRequest, draftTool *entity.ToolInfo) (err error) {
|
||||
func (p *pluginServiceImpl) updateDraftTool(ctx context.Context, req *dto.UpdateDraftToolRequest, draftTool *entity.ToolInfo) (err error) {
|
||||
if req.Method != nil && req.SubURL != nil {
|
||||
api := entity.UniqueToolAPI{
|
||||
SubURL: ptr.FromOrDefault(req.SubURL, ""),
|
||||
@ -778,7 +779,7 @@ func (p *pluginServiceImpl) updateDraftToolDebugExample(ctx context.Context, dra
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *pluginServiceImpl) ConvertToOpenapi3Doc(ctx context.Context, req *ConvertToOpenapi3DocRequest) (resp *ConvertToOpenapi3DocResponse) {
|
||||
func (p *pluginServiceImpl) ConvertToOpenapi3Doc(ctx context.Context, req *dto.ConvertToOpenapi3DocRequest) (resp *dto.ConvertToOpenapi3DocResponse) {
|
||||
var err error
|
||||
defer func() {
|
||||
if err != nil {
|
||||
@ -793,7 +794,7 @@ func (p *pluginServiceImpl) ConvertToOpenapi3Doc(ctx context.Context, req *Conve
|
||||
}
|
||||
}()
|
||||
|
||||
resp = &ConvertToOpenapi3DocResponse{}
|
||||
resp = &dto.ConvertToOpenapi3DocResponse{}
|
||||
|
||||
cvt, format, err := getConvertFunc(ctx, req.RawInput)
|
||||
if err != nil {
|
||||
@ -813,7 +814,7 @@ func (p *pluginServiceImpl) ConvertToOpenapi3Doc(ctx context.Context, req *Conve
|
||||
return resp
|
||||
}
|
||||
|
||||
return &ConvertToOpenapi3DocResponse{
|
||||
return &dto.ConvertToOpenapi3DocResponse{
|
||||
OpenapiDoc: doc,
|
||||
Manifest: mf,
|
||||
Format: format,
|
||||
@ -856,7 +857,7 @@ func getConvertFunc(ctx context.Context, rawInput string) (convertFunc, common.P
|
||||
return nil, 0, fmt.Errorf("invalid schema")
|
||||
}
|
||||
|
||||
func validateConvertResult(ctx context.Context, req *ConvertToOpenapi3DocRequest, doc *model.Openapi3T, mf *entity.PluginManifest) error {
|
||||
func validateConvertResult(ctx context.Context, req *dto.ConvertToOpenapi3DocRequest, doc *model.Openapi3T, mf *entity.PluginManifest) error {
|
||||
if req.PluginServerURL != nil {
|
||||
if doc.Servers[0].URL != *req.PluginServerURL {
|
||||
return errorx.New(errno.ErrPluginConvertProtocolFailed, errorx.KV(errno.PluginMsgKey, "inconsistent API URL prefix"))
|
||||
@ -876,7 +877,7 @@ func validateConvertResult(ctx context.Context, req *ConvertToOpenapi3DocRequest
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *pluginServiceImpl) CreateDraftToolsWithCode(ctx context.Context, req *CreateDraftToolsWithCodeRequest) (resp *CreateDraftToolsWithCodeResponse, err error) {
|
||||
func (p *pluginServiceImpl) CreateDraftToolsWithCode(ctx context.Context, req *dto.CreateDraftToolsWithCodeRequest) (resp *dto.CreateDraftToolsWithCodeResponse, err error) {
|
||||
err = req.OpenapiDoc.Validate(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -908,7 +909,7 @@ func (p *pluginServiceImpl) CreateDraftToolsWithCode(ctx context.Context, req *C
|
||||
}
|
||||
|
||||
if !req.ConflictAndUpdate && len(duplicatedTools) > 0 {
|
||||
return &CreateDraftToolsWithCodeResponse{
|
||||
return &dto.CreateDraftToolsWithCodeResponse{
|
||||
DuplicatedTools: duplicatedTools,
|
||||
}, nil
|
||||
}
|
||||
@ -932,7 +933,7 @@ func (p *pluginServiceImpl) CreateDraftToolsWithCode(ctx context.Context, req *C
|
||||
return nil, errorx.Wrapf(err, "UpsertDraftTools failed, pluginID=%d", req.PluginID)
|
||||
}
|
||||
|
||||
resp = &CreateDraftToolsWithCodeResponse{}
|
||||
resp = &dto.CreateDraftToolsWithCodeResponse{}
|
||||
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
@ -27,9 +27,10 @@ import (
|
||||
|
||||
"golang.org/x/oauth2"
|
||||
|
||||
model "github.com/coze-dev/coze-studio/backend/api/model/crossdomain/plugin"
|
||||
common "github.com/coze-dev/coze-studio/backend/api/model/plugin_develop/common"
|
||||
model "github.com/coze-dev/coze-studio/backend/crossdomain/contract/plugin/dto"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/plugin/conf"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/plugin/dto"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/plugin/encrypt"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/plugin/entity"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/errorx"
|
||||
@ -363,7 +364,7 @@ func (p *pluginServiceImpl) RevokeAccessToken(ctx context.Context, meta *entity.
|
||||
return p.oauthRepo.DeleteAuthorizationCode(ctx, meta)
|
||||
}
|
||||
|
||||
func (p *pluginServiceImpl) GetOAuthStatus(ctx context.Context, userID, pluginID int64) (resp *GetOAuthStatusResponse, err error) {
|
||||
func (p *pluginServiceImpl) GetOAuthStatus(ctx context.Context, userID, pluginID int64) (resp *dto.GetOAuthStatusResponse, err error) {
|
||||
pl, exist, err := p.pluginRepo.GetDraftPlugin(ctx, pluginID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -374,7 +375,7 @@ func (p *pluginServiceImpl) GetOAuthStatus(ctx context.Context, userID, pluginID
|
||||
|
||||
authInfo := pl.GetAuthInfo()
|
||||
if authInfo.Type == model.AuthzTypeOfNone || authInfo.Type == model.AuthzTypeOfService {
|
||||
return &GetOAuthStatusResponse{
|
||||
return &dto.GetOAuthStatusResponse{
|
||||
IsOauth: false,
|
||||
}, nil
|
||||
}
|
||||
@ -389,7 +390,7 @@ func (p *pluginServiceImpl) GetOAuthStatus(ctx context.Context, userID, pluginID
|
||||
status = common.OAuthStatus_Unauthorized
|
||||
}
|
||||
|
||||
resp = &GetOAuthStatusResponse{
|
||||
resp = &dto.GetOAuthStatusResponse{
|
||||
IsOauth: true,
|
||||
Status: status,
|
||||
OAuthURL: authURL,
|
||||
@ -480,7 +481,7 @@ func getStanderOAuthConfig(config *model.OAuthAuthorizationCodeConfig) *oauth2.C
|
||||
}
|
||||
}
|
||||
|
||||
func (p *pluginServiceImpl) GetAgentPluginsOAuthStatus(ctx context.Context, userID, agentID int64) (status []*AgentPluginOAuthStatus, err error) {
|
||||
func (p *pluginServiceImpl) GetAgentPluginsOAuthStatus(ctx context.Context, userID, agentID int64) (status []*dto.AgentPluginOAuthStatus, err error) {
|
||||
pluginIDs, err := p.toolRepo.GetAgentPluginIDs(ctx, agentID)
|
||||
if err != nil {
|
||||
return nil, errorx.Wrapf(err, "GetAgentPluginIDs failed, agentID=%d", agentID)
|
||||
@ -517,7 +518,7 @@ func (p *pluginServiceImpl) GetAgentPluginsOAuthStatus(ctx context.Context, user
|
||||
authStatus = common.OAuthStatus_Unauthorized
|
||||
}
|
||||
|
||||
status = append(status, &AgentPluginOAuthStatus{
|
||||
status = append(status, &dto.AgentPluginOAuthStatus{
|
||||
PluginID: plugin.ID,
|
||||
PluginName: plugin.GetName(),
|
||||
PluginIconURL: iconURL,
|
||||
|
||||
@ -21,12 +21,13 @@ import (
|
||||
"fmt"
|
||||
"sort"
|
||||
|
||||
model "github.com/coze-dev/coze-studio/backend/api/model/crossdomain/plugin"
|
||||
searchModel "github.com/coze-dev/coze-studio/backend/api/model/crossdomain/search"
|
||||
pluginCommon "github.com/coze-dev/coze-studio/backend/api/model/plugin_develop/common"
|
||||
resCommon "github.com/coze-dev/coze-studio/backend/api/model/resource/common"
|
||||
model "github.com/coze-dev/coze-studio/backend/crossdomain/contract/plugin/dto"
|
||||
crosssearch "github.com/coze-dev/coze-studio/backend/crossdomain/contract/search"
|
||||
pluginConf "github.com/coze-dev/coze-studio/backend/domain/plugin/conf"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/plugin/dto"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/plugin/entity"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/plugin/repository"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/errorx"
|
||||
@ -92,7 +93,7 @@ func (p *pluginServiceImpl) MGetVersionTools(ctx context.Context, versionTools [
|
||||
return tools, nil
|
||||
}
|
||||
|
||||
func (p *pluginServiceImpl) ListPluginProducts(ctx context.Context, req *ListPluginProductsRequest) (resp *ListPluginProductsResponse, err error) {
|
||||
func (p *pluginServiceImpl) ListPluginProducts(ctx context.Context, req *dto.ListPluginProductsRequest) (resp *dto.ListPluginProductsResponse, err error) {
|
||||
plugins := slices.Transform(pluginConf.GetAllPluginProducts(), func(p *pluginConf.PluginInfo) *entity.PluginInfo {
|
||||
return entity.NewPluginInfo(p.Info)
|
||||
})
|
||||
@ -100,7 +101,7 @@ func (p *pluginServiceImpl) ListPluginProducts(ctx context.Context, req *ListPlu
|
||||
return plugins[i].GetRefProductID() < plugins[j].GetRefProductID()
|
||||
})
|
||||
|
||||
return &ListPluginProductsResponse{
|
||||
return &dto.ListPluginProductsResponse{
|
||||
Plugins: plugins,
|
||||
Total: int64(len(plugins)),
|
||||
}, nil
|
||||
@ -186,7 +187,7 @@ func (p *pluginServiceImpl) ListCustomOnlinePlugins(ctx context.Context, spaceID
|
||||
return plugins, total, nil
|
||||
}
|
||||
|
||||
func (p *pluginServiceImpl) MGetPluginLatestVersion(ctx context.Context, pluginIDs []int64) (resp *MGetPluginLatestVersionResponse, err error) {
|
||||
func (p *pluginServiceImpl) MGetPluginLatestVersion(ctx context.Context, pluginIDs []int64) (resp *model.MGetPluginLatestVersionResponse, err error) {
|
||||
plugins, err := p.pluginRepo.MGetOnlinePlugins(ctx, pluginIDs,
|
||||
repository.WithPluginID(),
|
||||
repository.WithPluginVersion())
|
||||
@ -199,14 +200,14 @@ func (p *pluginServiceImpl) MGetPluginLatestVersion(ctx context.Context, pluginI
|
||||
versions[pl.ID] = pl.GetVersion()
|
||||
}
|
||||
|
||||
resp = &MGetPluginLatestVersionResponse{
|
||||
resp = &model.MGetPluginLatestVersionResponse{
|
||||
Versions: versions,
|
||||
}
|
||||
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
func (p *pluginServiceImpl) CopyPlugin(ctx context.Context, req *CopyPluginRequest) (resp *CopyPluginResponse, err error) {
|
||||
func (p *pluginServiceImpl) CopyPlugin(ctx context.Context, req *dto.CopyPluginRequest) (resp *dto.CopyPluginResponse, err error) {
|
||||
err = p.checkCanCopyPlugin(ctx, req.PluginID, req.CopyScene)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -232,7 +233,7 @@ func (p *pluginServiceImpl) CopyPlugin(ctx context.Context, req *CopyPluginReque
|
||||
return nil, errorx.Wrapf(err, "CopyPlugin failed, pluginID=%d", req.PluginID)
|
||||
}
|
||||
|
||||
resp = &CopyPluginResponse{
|
||||
resp = &dto.CopyPluginResponse{
|
||||
Plugin: plugin,
|
||||
Tools: toolMap,
|
||||
}
|
||||
@ -240,7 +241,7 @@ func (p *pluginServiceImpl) CopyPlugin(ctx context.Context, req *CopyPluginReque
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
func (p *pluginServiceImpl) changePluginAndToolsInfoForCopy(req *CopyPluginRequest, plugin *entity.PluginInfo, tools []*entity.ToolInfo) {
|
||||
func (p *pluginServiceImpl) changePluginAndToolsInfoForCopy(req *dto.CopyPluginRequest, plugin *entity.PluginInfo, tools []*entity.ToolInfo) {
|
||||
plugin.Version = nil
|
||||
plugin.VersionDesc = nil
|
||||
|
||||
|
||||
@ -24,8 +24,8 @@ import (
|
||||
|
||||
"golang.org/x/mod/semver"
|
||||
|
||||
model "github.com/coze-dev/coze-studio/backend/api/model/crossdomain/plugin"
|
||||
common "github.com/coze-dev/coze-studio/backend/api/model/plugin_develop/common"
|
||||
model "github.com/coze-dev/coze-studio/backend/crossdomain/contract/plugin/dto"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/plugin/entity"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/plugin/repository"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/errorx"
|
||||
@ -64,7 +64,7 @@ func (p *pluginServiceImpl) GetPluginNextVersion(ctx context.Context, pluginID i
|
||||
return nextVersion, nil
|
||||
}
|
||||
|
||||
func (p *pluginServiceImpl) PublishPlugin(ctx context.Context, req *PublishPluginRequest) (err error) {
|
||||
func (p *pluginServiceImpl) PublishPlugin(ctx context.Context, req *model.PublishPluginRequest) (err error) {
|
||||
draftPlugin, exist, err := p.pluginRepo.GetDraftPlugin(ctx, req.PluginID)
|
||||
if err != nil {
|
||||
return errorx.Wrapf(err, "GetDraftPlugin failed, pluginID=%d", req.PluginID)
|
||||
@ -101,8 +101,8 @@ func (p *pluginServiceImpl) PublishPlugin(ctx context.Context, req *PublishPlugi
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *pluginServiceImpl) PublishAPPPlugins(ctx context.Context, req *PublishAPPPluginsRequest) (resp *PublishAPPPluginsResponse, err error) {
|
||||
resp = &PublishAPPPluginsResponse{}
|
||||
func (p *pluginServiceImpl) PublishAPPPlugins(ctx context.Context, req *model.PublishAPPPluginsRequest) (resp *model.PublishAPPPluginsResponse, err error) {
|
||||
resp = &model.PublishAPPPluginsResponse{}
|
||||
|
||||
draftPlugins, err := p.pluginRepo.GetAPPAllDraftPlugins(ctx, req.APPID)
|
||||
if err != nil {
|
||||
|
||||
@ -18,383 +18,68 @@ package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/bytedance/sonic"
|
||||
"github.com/getkin/kin-openapi/openapi3"
|
||||
|
||||
model "github.com/coze-dev/coze-studio/backend/api/model/crossdomain/plugin"
|
||||
common "github.com/coze-dev/coze-studio/backend/api/model/plugin_develop/common"
|
||||
model "github.com/coze-dev/coze-studio/backend/crossdomain/contract/plugin/dto"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/plugin/dto"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/plugin/entity"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/errorx"
|
||||
"github.com/coze-dev/coze-studio/backend/types/errno"
|
||||
)
|
||||
|
||||
//go:generate mockgen -destination ../../../internal/mock/domain/plugin/interface.go --package mockPlugin -source service.go
|
||||
type PluginService interface {
|
||||
// Draft Plugin
|
||||
CreateDraftPlugin(ctx context.Context, req *CreateDraftPluginRequest) (pluginID int64, err error)
|
||||
CreateDraftPluginWithCode(ctx context.Context, req *CreateDraftPluginWithCodeRequest) (resp *CreateDraftPluginWithCodeResponse, err error)
|
||||
CreateDraftPlugin(ctx context.Context, req *dto.CreateDraftPluginRequest) (pluginID int64, err error)
|
||||
CreateDraftPluginWithCode(ctx context.Context, req *dto.CreateDraftPluginWithCodeRequest) (resp *dto.CreateDraftPluginWithCodeResponse, err error)
|
||||
GetDraftPlugin(ctx context.Context, pluginID int64) (plugin *entity.PluginInfo, err error)
|
||||
MGetDraftPlugins(ctx context.Context, pluginIDs []int64) (plugins []*entity.PluginInfo, err error)
|
||||
ListDraftPlugins(ctx context.Context, req *ListDraftPluginsRequest) (resp *ListDraftPluginsResponse, err error)
|
||||
UpdateDraftPlugin(ctx context.Context, plugin *UpdateDraftPluginRequest) (err error)
|
||||
UpdateDraftPluginWithCode(ctx context.Context, req *UpdateDraftPluginWithCodeRequest) (err error)
|
||||
ListDraftPlugins(ctx context.Context, req *dto.ListDraftPluginsRequest) (resp *dto.ListDraftPluginsResponse, err error)
|
||||
UpdateDraftPlugin(ctx context.Context, plugin *dto.UpdateDraftPluginRequest) (err error)
|
||||
UpdateDraftPluginWithCode(ctx context.Context, req *dto.UpdateDraftPluginWithCodeRequest) (err error)
|
||||
DeleteDraftPlugin(ctx context.Context, pluginID int64) (err error)
|
||||
DeleteAPPAllPlugins(ctx context.Context, appID int64) (pluginIDs []int64, err error)
|
||||
GetAPPAllPlugins(ctx context.Context, appID int64) (plugins []*entity.PluginInfo, err error)
|
||||
|
||||
// Online Plugin
|
||||
PublishPlugin(ctx context.Context, req *PublishPluginRequest) (err error)
|
||||
PublishAPPPlugins(ctx context.Context, req *PublishAPPPluginsRequest) (resp *PublishAPPPluginsResponse, err error)
|
||||
PublishPlugin(ctx context.Context, req *model.PublishPluginRequest) (err error)
|
||||
PublishAPPPlugins(ctx context.Context, req *model.PublishAPPPluginsRequest) (resp *model.PublishAPPPluginsResponse, err error)
|
||||
GetOnlinePlugin(ctx context.Context, pluginID int64) (plugin *entity.PluginInfo, err error)
|
||||
MGetOnlinePlugins(ctx context.Context, pluginIDs []int64) (plugins []*entity.PluginInfo, err error)
|
||||
MGetPluginLatestVersion(ctx context.Context, pluginIDs []int64) (resp *MGetPluginLatestVersionResponse, err error)
|
||||
MGetPluginLatestVersion(ctx context.Context, pluginIDs []int64) (resp *model.MGetPluginLatestVersionResponse, err error)
|
||||
GetPluginNextVersion(ctx context.Context, pluginID int64) (version string, err error)
|
||||
MGetVersionPlugins(ctx context.Context, versionPlugins []entity.VersionPlugin) (plugins []*entity.PluginInfo, err error)
|
||||
ListCustomOnlinePlugins(ctx context.Context, spaceID int64, pageInfo entity.PageInfo) (plugins []*entity.PluginInfo, total int64, err error)
|
||||
|
||||
// Draft Tool
|
||||
MGetDraftTools(ctx context.Context, toolIDs []int64) (tools []*entity.ToolInfo, err error)
|
||||
UpdateDraftTool(ctx context.Context, req *UpdateDraftToolRequest) (err error)
|
||||
ConvertToOpenapi3Doc(ctx context.Context, req *ConvertToOpenapi3DocRequest) (resp *ConvertToOpenapi3DocResponse)
|
||||
CreateDraftToolsWithCode(ctx context.Context, req *CreateDraftToolsWithCodeRequest) (resp *CreateDraftToolsWithCodeResponse, err error)
|
||||
UpdateDraftTool(ctx context.Context, req *dto.UpdateDraftToolRequest) (err error)
|
||||
ConvertToOpenapi3Doc(ctx context.Context, req *dto.ConvertToOpenapi3DocRequest) (resp *dto.ConvertToOpenapi3DocResponse)
|
||||
CreateDraftToolsWithCode(ctx context.Context, req *dto.CreateDraftToolsWithCodeRequest) (resp *dto.CreateDraftToolsWithCodeResponse, err error)
|
||||
CheckPluginToolsDebugStatus(ctx context.Context, pluginID int64) (err error)
|
||||
|
||||
// Online Tool
|
||||
GetOnlineTool(ctx context.Context, toolID int64) (tool *entity.ToolInfo, err error)
|
||||
MGetOnlineTools(ctx context.Context, toolIDs []int64) (tools []*entity.ToolInfo, err error)
|
||||
MGetVersionTools(ctx context.Context, versionTools []entity.VersionTool) (tools []*entity.ToolInfo, err error)
|
||||
CopyPlugin(ctx context.Context, req *CopyPluginRequest) (resp *CopyPluginResponse, err error)
|
||||
CopyPlugin(ctx context.Context, req *dto.CopyPluginRequest) (resp *dto.CopyPluginResponse, err error)
|
||||
MoveAPPPluginToLibrary(ctx context.Context, pluginID int64) (plugin *entity.PluginInfo, err error)
|
||||
|
||||
// Agent Tool
|
||||
BindAgentTools(ctx context.Context, agentID int64, toolIDs []int64) (err error)
|
||||
DuplicateDraftAgentTools(ctx context.Context, fromAgentID, toAgentID int64) (err error)
|
||||
GetDraftAgentToolByName(ctx context.Context, agentID int64, toolName string) (tool *entity.ToolInfo, err error)
|
||||
MGetAgentTools(ctx context.Context, req *MGetAgentToolsRequest) (tools []*entity.ToolInfo, err error)
|
||||
UpdateBotDefaultParams(ctx context.Context, req *UpdateBotDefaultParamsRequest) (err error)
|
||||
MGetAgentTools(ctx context.Context, req *model.MGetAgentToolsRequest) (tools []*entity.ToolInfo, err error)
|
||||
UpdateBotDefaultParams(ctx context.Context, req *dto.UpdateBotDefaultParamsRequest) (err error)
|
||||
|
||||
PublishAgentTools(ctx context.Context, agentID int64, agentVersion string) (err error)
|
||||
|
||||
ExecuteTool(ctx context.Context, req *ExecuteToolRequest, opts ...entity.ExecuteToolOpt) (resp *ExecuteToolResponse, err error)
|
||||
ExecuteTool(ctx context.Context, req *model.ExecuteToolRequest, opts ...entity.ExecuteToolOpt) (resp *model.ExecuteToolResponse, err error)
|
||||
|
||||
// Product
|
||||
ListPluginProducts(ctx context.Context, req *ListPluginProductsRequest) (resp *ListPluginProductsResponse, err error)
|
||||
ListPluginProducts(ctx context.Context, req *dto.ListPluginProductsRequest) (resp *dto.ListPluginProductsResponse, err error)
|
||||
GetPluginProductAllTools(ctx context.Context, pluginID int64) (tools []*entity.ToolInfo, err error)
|
||||
|
||||
GetOAuthStatus(ctx context.Context, userID, pluginID int64) (resp *GetOAuthStatusResponse, err error)
|
||||
GetAgentPluginsOAuthStatus(ctx context.Context, userID, agentID int64) (status []*AgentPluginOAuthStatus, err error)
|
||||
GetOAuthStatus(ctx context.Context, userID, pluginID int64) (resp *dto.GetOAuthStatusResponse, err error)
|
||||
GetAgentPluginsOAuthStatus(ctx context.Context, userID, agentID int64) (status []*dto.AgentPluginOAuthStatus, err error)
|
||||
OAuthCode(ctx context.Context, code string, state *entity.OAuthState) (err error)
|
||||
GetAccessToken(ctx context.Context, oa *entity.OAuthInfo) (accessToken string, err error)
|
||||
RevokeAccessToken(ctx context.Context, meta *entity.AuthorizationCodeMeta) (err error)
|
||||
}
|
||||
|
||||
type CreateDraftPluginRequest struct {
|
||||
PluginType common.PluginType
|
||||
IconURI string
|
||||
SpaceID int64
|
||||
DeveloperID int64
|
||||
ProjectID *int64
|
||||
Name string
|
||||
Desc string
|
||||
ServerURL string
|
||||
CommonParams map[common.ParameterLocation][]*common.CommonParamSchema
|
||||
AuthInfo *PluginAuthInfo
|
||||
}
|
||||
|
||||
type UpdateDraftPluginWithCodeRequest struct {
|
||||
UserID int64
|
||||
PluginID int64
|
||||
OpenapiDoc *model.Openapi3T
|
||||
Manifest *entity.PluginManifest
|
||||
}
|
||||
|
||||
type UpdateDraftPluginRequest struct {
|
||||
PluginID int64
|
||||
Name *string
|
||||
Desc *string
|
||||
URL *string
|
||||
Icon *common.PluginIcon
|
||||
CommonParams map[common.ParameterLocation][]*common.CommonParamSchema
|
||||
AuthInfo *PluginAuthInfo
|
||||
}
|
||||
|
||||
type ListDraftPluginsRequest struct {
|
||||
SpaceID int64
|
||||
APPID int64
|
||||
PageInfo entity.PageInfo
|
||||
}
|
||||
|
||||
type ListDraftPluginsResponse struct {
|
||||
Plugins []*entity.PluginInfo
|
||||
Total int64
|
||||
}
|
||||
|
||||
type CreateDraftPluginWithCodeRequest struct {
|
||||
SpaceID int64
|
||||
DeveloperID int64
|
||||
ProjectID *int64
|
||||
Manifest *entity.PluginManifest
|
||||
OpenapiDoc *model.Openapi3T
|
||||
}
|
||||
|
||||
type CreateDraftPluginWithCodeResponse struct {
|
||||
Plugin *entity.PluginInfo
|
||||
Tools []*entity.ToolInfo
|
||||
}
|
||||
|
||||
type CreateDraftToolsWithCodeRequest struct {
|
||||
PluginID int64
|
||||
OpenapiDoc *model.Openapi3T
|
||||
|
||||
ConflictAndUpdate bool
|
||||
}
|
||||
|
||||
type CreateDraftToolsWithCodeResponse struct {
|
||||
DuplicatedTools []entity.UniqueToolAPI
|
||||
}
|
||||
|
||||
type PluginAuthInfo struct {
|
||||
AuthzType *model.AuthzType
|
||||
Location *model.HTTPParamLocation
|
||||
Key *string
|
||||
ServiceToken *string
|
||||
OAuthInfo *string
|
||||
AuthzSubType *model.AuthzSubType
|
||||
AuthzPayload *string
|
||||
}
|
||||
|
||||
func (p PluginAuthInfo) toAuthV2() (*model.AuthV2, error) {
|
||||
if p.AuthzType == nil {
|
||||
return nil, errorx.New(errno.ErrPluginInvalidManifest, errorx.KV(errno.PluginMsgKey, "auth type is required"))
|
||||
}
|
||||
|
||||
switch *p.AuthzType {
|
||||
case model.AuthzTypeOfNone:
|
||||
return &model.AuthV2{
|
||||
Type: model.AuthzTypeOfNone,
|
||||
}, nil
|
||||
|
||||
case model.AuthzTypeOfOAuth:
|
||||
m, err := p.authOfOAuthToAuthV2()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
|
||||
case model.AuthzTypeOfService:
|
||||
m, err := p.authOfServiceToAuthV2()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
|
||||
default:
|
||||
return nil, errorx.New(errno.ErrPluginInvalidManifest, errorx.KVf(errno.PluginMsgKey,
|
||||
"the type '%s' of auth is invalid", *p.AuthzType))
|
||||
}
|
||||
}
|
||||
|
||||
func (p PluginAuthInfo) authOfOAuthToAuthV2() (*model.AuthV2, error) {
|
||||
if p.AuthzSubType == nil {
|
||||
return nil, errorx.New(errno.ErrPluginInvalidManifest, errorx.KV(errno.PluginMsgKey, "sub-auth type is required"))
|
||||
}
|
||||
|
||||
if p.OAuthInfo == nil || *p.OAuthInfo == "" {
|
||||
return nil, errorx.New(errno.ErrPluginInvalidManifest, errorx.KV(errno.PluginMsgKey, "oauth info is required"))
|
||||
}
|
||||
|
||||
oauthInfo := make(map[string]string)
|
||||
err := sonic.Unmarshal([]byte(*p.OAuthInfo), &oauthInfo)
|
||||
if err != nil {
|
||||
return nil, errorx.WrapByCode(err, errno.ErrPluginInvalidManifest, errorx.KV(errno.PluginMsgKey, "invalid oauth info"))
|
||||
}
|
||||
|
||||
if *p.AuthzSubType == model.AuthzSubTypeOfOAuthClientCredentials {
|
||||
_oauthInfo := &model.OAuthClientCredentialsConfig{
|
||||
ClientID: oauthInfo["client_id"],
|
||||
ClientSecret: oauthInfo["client_secret"],
|
||||
TokenURL: oauthInfo["token_url"],
|
||||
}
|
||||
|
||||
str, err := sonic.MarshalString(_oauthInfo)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("marshal oauth info failed, err=%v", err)
|
||||
}
|
||||
|
||||
return &model.AuthV2{
|
||||
Type: model.AuthzTypeOfOAuth,
|
||||
SubType: model.AuthzSubTypeOfOAuthClientCredentials,
|
||||
Payload: str,
|
||||
AuthOfOAuthClientCredentials: _oauthInfo,
|
||||
}, nil
|
||||
}
|
||||
|
||||
if *p.AuthzSubType == model.AuthzSubTypeOfOAuthAuthorizationCode {
|
||||
contentType := oauthInfo["authorization_content_type"]
|
||||
if contentType != model.MediaTypeJson { // only support application/json
|
||||
return nil, errorx.New(errno.ErrPluginInvalidManifest, errorx.KVf(errno.PluginMsgKey,
|
||||
"the type '%s' of authorization content is invalid", contentType))
|
||||
}
|
||||
|
||||
_oauthInfo := &model.OAuthAuthorizationCodeConfig{
|
||||
ClientID: oauthInfo["client_id"],
|
||||
ClientSecret: oauthInfo["client_secret"],
|
||||
ClientURL: oauthInfo["client_url"],
|
||||
Scope: oauthInfo["scope"],
|
||||
AuthorizationURL: oauthInfo["authorization_url"],
|
||||
AuthorizationContentType: contentType,
|
||||
}
|
||||
|
||||
str, err := sonic.MarshalString(_oauthInfo)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("marshal oauth info failed, err=%v", err)
|
||||
}
|
||||
|
||||
return &model.AuthV2{
|
||||
Type: model.AuthzTypeOfOAuth,
|
||||
SubType: model.AuthzSubTypeOfOAuthAuthorizationCode,
|
||||
Payload: str,
|
||||
AuthOfOAuthAuthorizationCode: _oauthInfo,
|
||||
}, nil
|
||||
}
|
||||
|
||||
return nil, errorx.New(errno.ErrPluginInvalidManifest, errorx.KVf(errno.PluginMsgKey,
|
||||
"the type '%s' of sub-auth is invalid", *p.AuthzSubType))
|
||||
}
|
||||
|
||||
func (p PluginAuthInfo) authOfServiceToAuthV2() (*model.AuthV2, error) {
|
||||
if p.AuthzSubType == nil {
|
||||
return nil, fmt.Errorf("sub-auth type is required")
|
||||
}
|
||||
|
||||
if *p.AuthzSubType == model.AuthzSubTypeOfServiceAPIToken {
|
||||
if p.Location == nil {
|
||||
return nil, fmt.Errorf("'Location' of sub-auth is required")
|
||||
}
|
||||
if p.ServiceToken == nil {
|
||||
return nil, fmt.Errorf("'ServiceToken' of sub-auth is required")
|
||||
}
|
||||
if p.Key == nil {
|
||||
return nil, fmt.Errorf("'Key' of sub-auth is required")
|
||||
}
|
||||
|
||||
tokenAuth := &model.AuthOfAPIToken{
|
||||
ServiceToken: *p.ServiceToken,
|
||||
Location: model.HTTPParamLocation(strings.ToLower(string(*p.Location))),
|
||||
Key: *p.Key,
|
||||
}
|
||||
|
||||
str, err := sonic.MarshalString(tokenAuth)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("marshal token auth failed, err=%v", err)
|
||||
}
|
||||
|
||||
return &model.AuthV2{
|
||||
Type: model.AuthzTypeOfService,
|
||||
SubType: model.AuthzSubTypeOfServiceAPIToken,
|
||||
Payload: str,
|
||||
AuthOfAPIToken: tokenAuth,
|
||||
}, nil
|
||||
}
|
||||
|
||||
return nil, errorx.New(errno.ErrPluginInvalidManifest, errorx.KVf(errno.PluginMsgKey,
|
||||
"the type '%s' of sub-auth is invalid", *p.AuthzSubType))
|
||||
}
|
||||
|
||||
type PublishPluginRequest = model.PublishPluginRequest
|
||||
|
||||
type PublishAPPPluginsRequest = model.PublishAPPPluginsRequest
|
||||
|
||||
type PublishAPPPluginsResponse = model.PublishAPPPluginsResponse
|
||||
|
||||
type MGetPluginLatestVersionResponse = model.MGetPluginLatestVersionResponse
|
||||
|
||||
type UpdateDraftToolRequest struct {
|
||||
PluginID int64
|
||||
ToolID int64
|
||||
Name *string
|
||||
Desc *string
|
||||
SubURL *string
|
||||
Method *string
|
||||
Parameters openapi3.Parameters
|
||||
RequestBody *openapi3.RequestBodyRef
|
||||
Responses openapi3.Responses
|
||||
Disabled *bool
|
||||
SaveExample *bool
|
||||
DebugExample *common.DebugExample
|
||||
APIExtend *common.APIExtend
|
||||
}
|
||||
|
||||
type MGetAgentToolsRequest = model.MGetAgentToolsRequest
|
||||
|
||||
type UpdateBotDefaultParamsRequest struct {
|
||||
PluginID int64
|
||||
AgentID int64
|
||||
ToolName string
|
||||
Parameters openapi3.Parameters
|
||||
RequestBody *openapi3.RequestBodyRef
|
||||
Responses openapi3.Responses
|
||||
}
|
||||
|
||||
type ExecuteToolRequest = model.ExecuteToolRequest
|
||||
|
||||
type ExecuteToolResponse = model.ExecuteToolResponse
|
||||
|
||||
type ListPluginProductsRequest struct{}
|
||||
|
||||
type ListPluginProductsResponse struct {
|
||||
Plugins []*entity.PluginInfo
|
||||
Total int64
|
||||
}
|
||||
|
||||
type ConvertToOpenapi3DocRequest struct {
|
||||
RawInput string
|
||||
PluginServerURL *string
|
||||
}
|
||||
|
||||
type ConvertToOpenapi3DocResponse struct {
|
||||
OpenapiDoc *model.Openapi3T
|
||||
Manifest *entity.PluginManifest
|
||||
Format common.PluginDataFormat
|
||||
ErrMsg string
|
||||
}
|
||||
|
||||
type GetOAuthStatusResponse struct {
|
||||
IsOauth bool
|
||||
Status common.OAuthStatus
|
||||
OAuthURL string
|
||||
}
|
||||
|
||||
type AgentPluginOAuthStatus struct {
|
||||
PluginID int64
|
||||
PluginName string
|
||||
PluginIconURL string
|
||||
Status common.OAuthStatus
|
||||
}
|
||||
|
||||
type CopyPluginRequest struct {
|
||||
UserID int64
|
||||
PluginID int64
|
||||
CopyScene model.CopyScene
|
||||
|
||||
TargetAPPID *int64
|
||||
}
|
||||
|
||||
type CopyPluginResponse struct {
|
||||
Plugin *entity.PluginInfo
|
||||
Tools map[int64]*entity.ToolInfo // old tool id -> new tool
|
||||
}
|
||||
|
||||
type MoveAPPPluginToLibRequest struct {
|
||||
PluginID int64
|
||||
}
|
||||
|
||||
type GetAccessTokenRequest struct {
|
||||
UserID string
|
||||
PluginID *int64
|
||||
Mode model.AuthzSubType
|
||||
OAuthInfo *entity.OAuthInfo
|
||||
}
|
||||
|
||||
@ -26,10 +26,10 @@ import (
|
||||
"github.com/bytedance/sonic"
|
||||
"github.com/getkin/kin-openapi/openapi3"
|
||||
|
||||
model "github.com/coze-dev/coze-studio/backend/api/model/crossdomain/plugin"
|
||||
"github.com/coze-dev/coze-studio/backend/api/model/crossdomain/variables"
|
||||
"github.com/coze-dev/coze-studio/backend/api/model/data/variable/project_memory"
|
||||
api "github.com/coze-dev/coze-studio/backend/api/model/plugin_develop/common"
|
||||
model "github.com/coze-dev/coze-studio/backend/crossdomain/contract/plugin/dto"
|
||||
crossvariables "github.com/coze-dev/coze-studio/backend/crossdomain/contract/variables"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/plugin/entity"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/storage"
|
||||
|
||||
@ -31,7 +31,7 @@ import (
|
||||
"github.com/go-resty/resty/v2"
|
||||
"github.com/tidwall/sjson"
|
||||
|
||||
model "github.com/coze-dev/coze-studio/backend/api/model/crossdomain/plugin"
|
||||
model "github.com/coze-dev/coze-studio/backend/crossdomain/contract/plugin/dto"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/plugin/internal/encoder"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/errorx"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/i18n"
|
||||
|
||||
@ -17,7 +17,7 @@
|
||||
package vo
|
||||
|
||||
import (
|
||||
"github.com/coze-dev/coze-studio/backend/api/model/crossdomain/plugin"
|
||||
plugin "github.com/coze-dev/coze-studio/backend/crossdomain/contract/plugin/dto"
|
||||
)
|
||||
|
||||
type ExternalResourceRelated struct {
|
||||
|
||||
@ -24,9 +24,9 @@ import (
|
||||
|
||||
einoCompose "github.com/cloudwego/eino/compose"
|
||||
|
||||
"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"
|
||||
plugin "github.com/coze-dev/coze-studio/backend/crossdomain/contract/plugin/dto"
|
||||
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/vo"
|
||||
|
||||
@ -36,13 +36,13 @@ import (
|
||||
|
||||
"github.com/coze-dev/coze-studio/backend/api/model/crossdomain/knowledge"
|
||||
crossmodel "github.com/coze-dev/coze-studio/backend/api/model/crossdomain/modelmgr"
|
||||
"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"
|
||||
crossknowledge "github.com/coze-dev/coze-studio/backend/crossdomain/contract/knowledge"
|
||||
crossmessage "github.com/coze-dev/coze-studio/backend/crossdomain/contract/message"
|
||||
crossmodelmgr "github.com/coze-dev/coze-studio/backend/crossdomain/contract/modelmgr"
|
||||
crossplugin "github.com/coze-dev/coze-studio/backend/crossdomain/contract/plugin"
|
||||
plugin "github.com/coze-dev/coze-studio/backend/crossdomain/contract/plugin/dto"
|
||||
"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/vo"
|
||||
|
||||
@ -23,9 +23,9 @@ import (
|
||||
|
||||
"github.com/cloudwego/eino/compose"
|
||||
|
||||
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"
|
||||
model "github.com/coze-dev/coze-studio/backend/crossdomain/contract/plugin/dto"
|
||||
"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/internal/canvas/convert"
|
||||
|
||||
@ -30,10 +30,10 @@ import (
|
||||
|
||||
einoCompose "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"
|
||||
cloudworkflow "github.com/coze-dev/coze-studio/backend/api/model/workflow"
|
||||
"github.com/coze-dev/coze-studio/backend/application/base/ctxutil"
|
||||
plugin "github.com/coze-dev/coze-studio/backend/crossdomain/contract/plugin/dto"
|
||||
"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/vo"
|
||||
|
||||
@ -234,14 +234,10 @@ github.com/cloudwego/eino-ext/components/model/gemini v0.1.2 h1:bt9xftOQhP0Nuh1P
|
||||
github.com/cloudwego/eino-ext/components/model/gemini v0.1.2/go.mod h1:1tv89uZ9hR/4AyQ+9yxFWLn52GaJDKtPXdEY7WZdyZc=
|
||||
github.com/cloudwego/eino-ext/components/model/ollama v0.1.0 h1:FW067iMfg3EZbUaZIo8v3i2ILBAZDzY23/9pbprvE0M=
|
||||
github.com/cloudwego/eino-ext/components/model/ollama v0.1.0/go.mod h1:+qA5kkUCM0mIrXGSNzxLcjxh6K1AghPNigtEyyMdkOc=
|
||||
github.com/cloudwego/eino-ext/components/model/openai v0.0.0-20250715055739-0d0e28441a2f h1:ovS39vuN2JW+C/O9jtEmOUuLEY4fw0yYh8//yhMfJNM=
|
||||
github.com/cloudwego/eino-ext/components/model/openai v0.0.0-20250715055739-0d0e28441a2f/go.mod h1:2mFQQnlhJrNgbW6YX1MOUUfXkGSbTz9Ylx37fbR0xBo=
|
||||
github.com/cloudwego/eino-ext/components/model/openai v0.1.1 h1:VRdUDcnfi/T8F0jcuovhdADU9Io/oMqiKpY2ZJTBc1o=
|
||||
github.com/cloudwego/eino-ext/components/model/openai v0.1.1/go.mod h1:VwAXEY1ik2K9KFPZvymnkfBQQKgLHbpg90yg+7hrTt8=
|
||||
github.com/cloudwego/eino-ext/components/model/qwen v0.0.0-20250612061754-5a3deb091dc5 h1:4zAZiNo/PkeVc0Gw8YLpzpbR8zDzccL7H5PLqTuGhv4=
|
||||
github.com/cloudwego/eino-ext/components/model/qwen v0.0.0-20250612061754-5a3deb091dc5/go.mod h1:vgQ3m0LtrdQbnganW9y3j3aTJpVgJnCLp9y80tTM9hA=
|
||||
github.com/cloudwego/eino-ext/libs/acl/openai v0.0.0-20250626133421-3c142631c961 h1:fGE3RFHaAsrLjA+2fkE0YMsPrkFI6pEKKZmbhD42L7E=
|
||||
github.com/cloudwego/eino-ext/libs/acl/openai v0.0.0-20250626133421-3c142631c961/go.mod h1:iB0W8l+OqKNL5LtJQ9JaGYXekhsxVxrDMfnfD9L+5gc=
|
||||
github.com/cloudwego/eino-ext/libs/acl/openai v0.0.0-20250918130948-16e3a249e721 h1:5Hd8GxNEmu+ppTGCRBU6kLKfCQNXPMwi31xA83PzEqo=
|
||||
github.com/cloudwego/eino-ext/libs/acl/openai v0.0.0-20250918130948-16e3a249e721/go.mod h1:fHn/6OqPPY1iLLx9wzz+MEVT5Dl9gwuZte1oLEnCoYw=
|
||||
github.com/cloudwego/gopkg v0.1.4 h1:EoQiCG4sTonTPHxOGE0VlQs+sQR+Hsi2uN0qqwu8O50=
|
||||
@ -798,8 +794,6 @@ github.com/mattn/go-sqlite3 v1.14.15/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S
|
||||
github.com/mattn/goveralls v0.0.2/go.mod h1:8d1ZMHsd7fW6IRPKQh46F2WRpyib5/X4FOpevwGNQEw=
|
||||
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
|
||||
github.com/mediocregopher/radix/v3 v3.4.2/go.mod h1:8FL3F6UQRXHXIBSPUs5h0RybMF8i4n7wVopoX3x7Bv8=
|
||||
github.com/meguminnnnnnnnn/go-openai v0.0.0-20250620092828-0d508a1dcdde h1:pq2I0uxUR4lfr4OmqvE8QdHj9UML9b1jZu8L3dI2eu8=
|
||||
github.com/meguminnnnnnnnn/go-openai v0.0.0-20250620092828-0d508a1dcdde/go.mod h1:CqSFsV6AkkL2fixd25WYjRAolns+gQrY1x/Cz9c30v8=
|
||||
github.com/meguminnnnnnnnn/go-openai v0.0.0-20250821095446-07791bea23a0 h1:nIohpHs1ViKR0SVgW/cbBstHjmnqFZDM9RqgX9m9Xu8=
|
||||
github.com/meguminnnnnnnnn/go-openai v0.0.0-20250821095446-07791bea23a0/go.mod h1:qs96ysDmxhE4BZoU45I43zcyfnaYxU3X+aRzLko/htY=
|
||||
github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b h1:j7+1HpAFS1zy5+Q4qx1fWh90gTKwiN4QCGoY9TWyyO4=
|
||||
|
||||
@ -13,8 +13,9 @@ import (
|
||||
context "context"
|
||||
reflect "reflect"
|
||||
|
||||
plugin "github.com/coze-dev/coze-studio/backend/crossdomain/contract/plugin/dto"
|
||||
dto "github.com/coze-dev/coze-studio/backend/domain/plugin/dto"
|
||||
entity "github.com/coze-dev/coze-studio/backend/domain/plugin/entity"
|
||||
service "github.com/coze-dev/coze-studio/backend/domain/plugin/service"
|
||||
gomock "go.uber.org/mock/gomock"
|
||||
)
|
||||
|
||||
@ -22,6 +23,7 @@ import (
|
||||
type MockPluginService struct {
|
||||
ctrl *gomock.Controller
|
||||
recorder *MockPluginServiceMockRecorder
|
||||
isgomock struct{}
|
||||
}
|
||||
|
||||
// MockPluginServiceMockRecorder is the mock recorder for MockPluginService.
|
||||
@ -70,10 +72,10 @@ func (mr *MockPluginServiceMockRecorder) CheckPluginToolsDebugStatus(ctx, plugin
|
||||
}
|
||||
|
||||
// ConvertToOpenapi3Doc mocks base method.
|
||||
func (m *MockPluginService) ConvertToOpenapi3Doc(ctx context.Context, req *service.ConvertToOpenapi3DocRequest) *service.ConvertToOpenapi3DocResponse {
|
||||
func (m *MockPluginService) ConvertToOpenapi3Doc(ctx context.Context, req *dto.ConvertToOpenapi3DocRequest) *dto.ConvertToOpenapi3DocResponse {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "ConvertToOpenapi3Doc", ctx, req)
|
||||
ret0, _ := ret[0].(*service.ConvertToOpenapi3DocResponse)
|
||||
ret0, _ := ret[0].(*dto.ConvertToOpenapi3DocResponse)
|
||||
return ret0
|
||||
}
|
||||
|
||||
@ -84,10 +86,10 @@ func (mr *MockPluginServiceMockRecorder) ConvertToOpenapi3Doc(ctx, req any) *gom
|
||||
}
|
||||
|
||||
// CopyPlugin mocks base method.
|
||||
func (m *MockPluginService) CopyPlugin(ctx context.Context, req *service.CopyPluginRequest) (*service.CopyPluginResponse, error) {
|
||||
func (m *MockPluginService) CopyPlugin(ctx context.Context, req *dto.CopyPluginRequest) (*dto.CopyPluginResponse, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "CopyPlugin", ctx, req)
|
||||
ret0, _ := ret[0].(*service.CopyPluginResponse)
|
||||
ret0, _ := ret[0].(*dto.CopyPluginResponse)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
@ -99,7 +101,7 @@ func (mr *MockPluginServiceMockRecorder) CopyPlugin(ctx, req any) *gomock.Call {
|
||||
}
|
||||
|
||||
// CreateDraftPlugin mocks base method.
|
||||
func (m *MockPluginService) CreateDraftPlugin(ctx context.Context, req *service.CreateDraftPluginRequest) (int64, error) {
|
||||
func (m *MockPluginService) CreateDraftPlugin(ctx context.Context, req *dto.CreateDraftPluginRequest) (int64, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "CreateDraftPlugin", ctx, req)
|
||||
ret0, _ := ret[0].(int64)
|
||||
@ -114,10 +116,10 @@ func (mr *MockPluginServiceMockRecorder) CreateDraftPlugin(ctx, req any) *gomock
|
||||
}
|
||||
|
||||
// CreateDraftPluginWithCode mocks base method.
|
||||
func (m *MockPluginService) CreateDraftPluginWithCode(ctx context.Context, req *service.CreateDraftPluginWithCodeRequest) (*service.CreateDraftPluginWithCodeResponse, error) {
|
||||
func (m *MockPluginService) CreateDraftPluginWithCode(ctx context.Context, req *dto.CreateDraftPluginWithCodeRequest) (*dto.CreateDraftPluginWithCodeResponse, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "CreateDraftPluginWithCode", ctx, req)
|
||||
ret0, _ := ret[0].(*service.CreateDraftPluginWithCodeResponse)
|
||||
ret0, _ := ret[0].(*dto.CreateDraftPluginWithCodeResponse)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
@ -129,10 +131,10 @@ func (mr *MockPluginServiceMockRecorder) CreateDraftPluginWithCode(ctx, req any)
|
||||
}
|
||||
|
||||
// CreateDraftToolsWithCode mocks base method.
|
||||
func (m *MockPluginService) CreateDraftToolsWithCode(ctx context.Context, req *service.CreateDraftToolsWithCodeRequest) (*service.CreateDraftToolsWithCodeResponse, error) {
|
||||
func (m *MockPluginService) CreateDraftToolsWithCode(ctx context.Context, req *dto.CreateDraftToolsWithCodeRequest) (*dto.CreateDraftToolsWithCodeResponse, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "CreateDraftToolsWithCode", ctx, req)
|
||||
ret0, _ := ret[0].(*service.CreateDraftToolsWithCodeResponse)
|
||||
ret0, _ := ret[0].(*dto.CreateDraftToolsWithCodeResponse)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
@ -187,14 +189,14 @@ func (mr *MockPluginServiceMockRecorder) DuplicateDraftAgentTools(ctx, fromAgent
|
||||
}
|
||||
|
||||
// ExecuteTool mocks base method.
|
||||
func (m *MockPluginService) ExecuteTool(ctx context.Context, req *service.ExecuteToolRequest, opts ...entity.ExecuteToolOpt) (*service.ExecuteToolResponse, error) {
|
||||
func (m *MockPluginService) ExecuteTool(ctx context.Context, req *plugin.ExecuteToolRequest, opts ...entity.ExecuteToolOpt) (*plugin.ExecuteToolResponse, error) {
|
||||
m.ctrl.T.Helper()
|
||||
varargs := []any{ctx, req}
|
||||
for _, a := range opts {
|
||||
varargs = append(varargs, a)
|
||||
}
|
||||
ret := m.ctrl.Call(m, "ExecuteTool", varargs...)
|
||||
ret0, _ := ret[0].(*service.ExecuteToolResponse)
|
||||
ret0, _ := ret[0].(*plugin.ExecuteToolResponse)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
@ -237,10 +239,10 @@ func (mr *MockPluginServiceMockRecorder) GetAccessToken(ctx, oa any) *gomock.Cal
|
||||
}
|
||||
|
||||
// GetAgentPluginsOAuthStatus mocks base method.
|
||||
func (m *MockPluginService) GetAgentPluginsOAuthStatus(ctx context.Context, userID, agentID int64) ([]*service.AgentPluginOAuthStatus, error) {
|
||||
func (m *MockPluginService) GetAgentPluginsOAuthStatus(ctx context.Context, userID, agentID int64) ([]*dto.AgentPluginOAuthStatus, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "GetAgentPluginsOAuthStatus", ctx, userID, agentID)
|
||||
ret0, _ := ret[0].([]*service.AgentPluginOAuthStatus)
|
||||
ret0, _ := ret[0].([]*dto.AgentPluginOAuthStatus)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
@ -282,10 +284,10 @@ func (mr *MockPluginServiceMockRecorder) GetDraftPlugin(ctx, pluginID any) *gomo
|
||||
}
|
||||
|
||||
// GetOAuthStatus mocks base method.
|
||||
func (m *MockPluginService) GetOAuthStatus(ctx context.Context, userID, pluginID int64) (*service.GetOAuthStatusResponse, error) {
|
||||
func (m *MockPluginService) GetOAuthStatus(ctx context.Context, userID, pluginID int64) (*dto.GetOAuthStatusResponse, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "GetOAuthStatus", ctx, userID, pluginID)
|
||||
ret0, _ := ret[0].(*service.GetOAuthStatusResponse)
|
||||
ret0, _ := ret[0].(*dto.GetOAuthStatusResponse)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
@ -373,10 +375,10 @@ func (mr *MockPluginServiceMockRecorder) ListCustomOnlinePlugins(ctx, spaceID, p
|
||||
}
|
||||
|
||||
// ListDraftPlugins mocks base method.
|
||||
func (m *MockPluginService) ListDraftPlugins(ctx context.Context, req *service.ListDraftPluginsRequest) (*service.ListDraftPluginsResponse, error) {
|
||||
func (m *MockPluginService) ListDraftPlugins(ctx context.Context, req *dto.ListDraftPluginsRequest) (*dto.ListDraftPluginsResponse, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "ListDraftPlugins", ctx, req)
|
||||
ret0, _ := ret[0].(*service.ListDraftPluginsResponse)
|
||||
ret0, _ := ret[0].(*dto.ListDraftPluginsResponse)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
@ -388,10 +390,10 @@ func (mr *MockPluginServiceMockRecorder) ListDraftPlugins(ctx, req any) *gomock.
|
||||
}
|
||||
|
||||
// ListPluginProducts mocks base method.
|
||||
func (m *MockPluginService) ListPluginProducts(ctx context.Context, req *service.ListPluginProductsRequest) (*service.ListPluginProductsResponse, error) {
|
||||
func (m *MockPluginService) ListPluginProducts(ctx context.Context, req *dto.ListPluginProductsRequest) (*dto.ListPluginProductsResponse, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "ListPluginProducts", ctx, req)
|
||||
ret0, _ := ret[0].(*service.ListPluginProductsResponse)
|
||||
ret0, _ := ret[0].(*dto.ListPluginProductsResponse)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
@ -403,7 +405,7 @@ func (mr *MockPluginServiceMockRecorder) ListPluginProducts(ctx, req any) *gomoc
|
||||
}
|
||||
|
||||
// MGetAgentTools mocks base method.
|
||||
func (m *MockPluginService) MGetAgentTools(ctx context.Context, req *service.MGetAgentToolsRequest) ([]*entity.ToolInfo, error) {
|
||||
func (m *MockPluginService) MGetAgentTools(ctx context.Context, req *plugin.MGetAgentToolsRequest) ([]*entity.ToolInfo, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "MGetAgentTools", ctx, req)
|
||||
ret0, _ := ret[0].([]*entity.ToolInfo)
|
||||
@ -478,10 +480,10 @@ func (mr *MockPluginServiceMockRecorder) MGetOnlineTools(ctx, toolIDs any) *gomo
|
||||
}
|
||||
|
||||
// MGetPluginLatestVersion mocks base method.
|
||||
func (m *MockPluginService) MGetPluginLatestVersion(ctx context.Context, pluginIDs []int64) (*service.MGetPluginLatestVersionResponse, error) {
|
||||
func (m *MockPluginService) MGetPluginLatestVersion(ctx context.Context, pluginIDs []int64) (*plugin.MGetPluginLatestVersionResponse, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "MGetPluginLatestVersion", ctx, pluginIDs)
|
||||
ret0, _ := ret[0].(*service.MGetPluginLatestVersionResponse)
|
||||
ret0, _ := ret[0].(*plugin.MGetPluginLatestVersionResponse)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
@ -552,10 +554,10 @@ func (mr *MockPluginServiceMockRecorder) OAuthCode(ctx, code, state any) *gomock
|
||||
}
|
||||
|
||||
// PublishAPPPlugins mocks base method.
|
||||
func (m *MockPluginService) PublishAPPPlugins(ctx context.Context, req *service.PublishAPPPluginsRequest) (*service.PublishAPPPluginsResponse, error) {
|
||||
func (m *MockPluginService) PublishAPPPlugins(ctx context.Context, req *plugin.PublishAPPPluginsRequest) (*plugin.PublishAPPPluginsResponse, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "PublishAPPPlugins", ctx, req)
|
||||
ret0, _ := ret[0].(*service.PublishAPPPluginsResponse)
|
||||
ret0, _ := ret[0].(*plugin.PublishAPPPluginsResponse)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
@ -581,7 +583,7 @@ func (mr *MockPluginServiceMockRecorder) PublishAgentTools(ctx, agentID, agentVe
|
||||
}
|
||||
|
||||
// PublishPlugin mocks base method.
|
||||
func (m *MockPluginService) PublishPlugin(ctx context.Context, req *service.PublishPluginRequest) error {
|
||||
func (m *MockPluginService) PublishPlugin(ctx context.Context, req *plugin.PublishPluginRequest) error {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "PublishPlugin", ctx, req)
|
||||
ret0, _ := ret[0].(error)
|
||||
@ -609,7 +611,7 @@ func (mr *MockPluginServiceMockRecorder) RevokeAccessToken(ctx, meta any) *gomoc
|
||||
}
|
||||
|
||||
// UpdateBotDefaultParams mocks base method.
|
||||
func (m *MockPluginService) UpdateBotDefaultParams(ctx context.Context, req *service.UpdateBotDefaultParamsRequest) error {
|
||||
func (m *MockPluginService) UpdateBotDefaultParams(ctx context.Context, req *dto.UpdateBotDefaultParamsRequest) error {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "UpdateBotDefaultParams", ctx, req)
|
||||
ret0, _ := ret[0].(error)
|
||||
@ -623,21 +625,21 @@ func (mr *MockPluginServiceMockRecorder) UpdateBotDefaultParams(ctx, req any) *g
|
||||
}
|
||||
|
||||
// UpdateDraftPlugin mocks base method.
|
||||
func (m *MockPluginService) UpdateDraftPlugin(ctx context.Context, plugin *service.UpdateDraftPluginRequest) error {
|
||||
func (m *MockPluginService) UpdateDraftPlugin(ctx context.Context, arg1 *dto.UpdateDraftPluginRequest) error {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "UpdateDraftPlugin", ctx, plugin)
|
||||
ret := m.ctrl.Call(m, "UpdateDraftPlugin", ctx, arg1)
|
||||
ret0, _ := ret[0].(error)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// UpdateDraftPlugin indicates an expected call of UpdateDraftPlugin.
|
||||
func (mr *MockPluginServiceMockRecorder) UpdateDraftPlugin(ctx, plugin any) *gomock.Call {
|
||||
func (mr *MockPluginServiceMockRecorder) UpdateDraftPlugin(ctx, arg1 any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateDraftPlugin", reflect.TypeOf((*MockPluginService)(nil).UpdateDraftPlugin), ctx, plugin)
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateDraftPlugin", reflect.TypeOf((*MockPluginService)(nil).UpdateDraftPlugin), ctx, arg1)
|
||||
}
|
||||
|
||||
// UpdateDraftPluginWithCode mocks base method.
|
||||
func (m *MockPluginService) UpdateDraftPluginWithCode(ctx context.Context, req *service.UpdateDraftPluginWithCodeRequest) error {
|
||||
func (m *MockPluginService) UpdateDraftPluginWithCode(ctx context.Context, req *dto.UpdateDraftPluginWithCodeRequest) error {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "UpdateDraftPluginWithCode", ctx, req)
|
||||
ret0, _ := ret[0].(error)
|
||||
@ -651,7 +653,7 @@ func (mr *MockPluginServiceMockRecorder) UpdateDraftPluginWithCode(ctx, req any)
|
||||
}
|
||||
|
||||
// UpdateDraftTool mocks base method.
|
||||
func (m *MockPluginService) UpdateDraftTool(ctx context.Context, req *service.UpdateDraftToolRequest) error {
|
||||
func (m *MockPluginService) UpdateDraftTool(ctx context.Context, req *dto.UpdateDraftToolRequest) error {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "UpdateDraftTool", ctx, req)
|
||||
ret0, _ := ret[0].(error)
|
||||
|
||||
@ -33,8 +33,8 @@ import (
|
||||
"github.com/coze-dev/coze-studio/backend/api/model/app/bot_common"
|
||||
"github.com/coze-dev/coze-studio/backend/api/model/crossdomain/agentrun"
|
||||
"github.com/coze-dev/coze-studio/backend/api/model/crossdomain/database"
|
||||
"github.com/coze-dev/coze-studio/backend/api/model/crossdomain/plugin"
|
||||
"github.com/coze-dev/coze-studio/backend/api/model/playground"
|
||||
plugin "github.com/coze-dev/coze-studio/backend/crossdomain/contract/plugin/dto"
|
||||
appEntity "github.com/coze-dev/coze-studio/backend/domain/app/entity"
|
||||
variableEntity "github.com/coze-dev/coze-studio/backend/domain/memory/variables/entity"
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user