chore: resolve conficts
This commit is contained in:
@ -18,6 +18,7 @@ package plugin
|
||||
|
||||
import (
|
||||
"context"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
@ -315,72 +316,6 @@ func (p *PluginApplicationService) validateDraftPluginAccess(ctx context.Context
|
||||
return plugin, nil
|
||||
}
|
||||
|
||||
func (p *PluginApplicationService) OauthAuthorizationCode(ctx context.Context, req *botOpenAPI.OauthAuthorizationCodeReq) (resp *botOpenAPI.OauthAuthorizationCodeResp, err error) {
|
||||
stateStr, err := url.QueryUnescape(req.State)
|
||||
if err != nil {
|
||||
return nil, errorx.WrapByCode(err, errno.ErrPluginOAuthFailed, errorx.KV(errno.PluginMsgKey, "invalid state"))
|
||||
}
|
||||
|
||||
secret := os.Getenv(encrypt.StateSecretEnv)
|
||||
if secret == "" {
|
||||
secret = encrypt.DefaultStateSecret
|
||||
}
|
||||
|
||||
stateBytes, err := encrypt.DecryptByAES(stateStr, secret)
|
||||
if err != nil {
|
||||
return nil, errorx.WrapByCode(err, errno.ErrPluginOAuthFailed, errorx.KV(errno.PluginMsgKey, "invalid state"))
|
||||
}
|
||||
|
||||
state := &entity.OAuthState{}
|
||||
err = json.Unmarshal(stateBytes, state)
|
||||
if err != nil {
|
||||
return nil, errorx.WrapByCode(err, errno.ErrPluginOAuthFailed, errorx.KV(errno.PluginMsgKey, "invalid state"))
|
||||
}
|
||||
|
||||
err = p.DomainSVC.OAuthCode(ctx, req.Code, state)
|
||||
if err != nil {
|
||||
return nil, errorx.WrapByCode(err, errno.ErrPluginOAuthFailed, errorx.KV(errno.PluginMsgKey, "authorize failed"))
|
||||
}
|
||||
|
||||
resp = &botOpenAPI.OauthAuthorizationCodeResp{}
|
||||
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
func (p *PluginApplicationService) GetQueriedOAuthPluginList(ctx context.Context, req *pluginAPI.GetQueriedOAuthPluginListRequest) (resp *pluginAPI.GetQueriedOAuthPluginListResponse, err error) {
|
||||
userID := ctxutil.GetUIDFromCtx(ctx)
|
||||
if userID == nil {
|
||||
return nil, errorx.New(errno.ErrPluginPermissionCode, errorx.KV(errno.PluginMsgKey, "session is required"))
|
||||
}
|
||||
|
||||
status, err := p.DomainSVC.GetAgentPluginsOAuthStatus(ctx, *userID, req.BotID)
|
||||
if err != nil {
|
||||
return nil, errorx.Wrapf(err, "GetAgentPluginsOAuthStatus failed, userID=%d, agentID=%d", *userID, req.BotID)
|
||||
}
|
||||
|
||||
if len(status) == 0 {
|
||||
return &pluginAPI.GetQueriedOAuthPluginListResponse{
|
||||
OauthPluginList: []*pluginAPI.OAuthPluginInfo{},
|
||||
}, nil
|
||||
}
|
||||
|
||||
oauthPluginList := make([]*pluginAPI.OAuthPluginInfo, 0, len(status))
|
||||
for _, s := range status {
|
||||
oauthPluginList = append(oauthPluginList, &pluginAPI.OAuthPluginInfo{
|
||||
PluginID: s.PluginID,
|
||||
Status: s.Status,
|
||||
Name: s.PluginName,
|
||||
PluginIcon: s.PluginIconURL,
|
||||
})
|
||||
}
|
||||
|
||||
resp = &pluginAPI.GetQueriedOAuthPluginListResponse{
|
||||
OauthPluginList: oauthPluginList,
|
||||
}
|
||||
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
// convertPluginToProductInfo converts a plugin entity to ProductInfo
|
||||
func convertPluginToProductInfo(plugin *entity.PluginInfo) *productAPI.ProductInfo {
|
||||
return &productAPI.ProductInfo{
|
||||
@ -580,7 +515,7 @@ func (t *PluginApplicationService) GetProductCallInfo(ctx context.Context, req *
|
||||
|
||||
// Build response data
|
||||
data := &productAPI.GetProductCallInfoData{
|
||||
McpJSON: "", // TODO: Set appropriate MCP JSON based on requirements
|
||||
McpJSON: "", // TODO: Set appropriate MCP JSON based on requirements
|
||||
UserLevel: productAPI.UserLevel_Free, // TODO: Map from userBenefit to appropriate UserLevel
|
||||
}
|
||||
|
||||
|
||||
@ -78,15 +78,6 @@ type CheckCanPublishPluginsResponse struct {
|
||||
InvalidPlugins []*PluginInfo
|
||||
}
|
||||
|
||||
type ToolInterruptEvent struct {
|
||||
Event InterruptEventType
|
||||
ToolNeedOAuth *ToolNeedOAuthInterruptEvent
|
||||
}
|
||||
|
||||
type ToolNeedOAuthInterruptEvent struct {
|
||||
Message string
|
||||
}
|
||||
|
||||
type ListPluginProductsRequest struct{}
|
||||
|
||||
type ListPluginProductsResponse struct {
|
||||
|
||||
@ -58,10 +58,10 @@ func (c *impl) buildSingleAgentStreamExecuteReq(ctx context.Context, agentRuntim
|
||||
) *model.ExecuteRequest {
|
||||
|
||||
return &model.ExecuteRequest{
|
||||
Identity: c.buildIdentity(agentRuntime),
|
||||
Input: agentRuntime.Input,
|
||||
History: agentRuntime.HistoryMsg,
|
||||
UserID: agentRuntime.UserID,
|
||||
Identity: c.buildIdentity(agentRuntime),
|
||||
Input: agentRuntime.Input,
|
||||
History: agentRuntime.HistoryMsg,
|
||||
UserID: agentRuntime.UserID,
|
||||
CustomVariables: agentRuntime.CustomVariables,
|
||||
PreCallTools: slices.Transform(agentRuntime.PreRetrieveTools, func(tool *agentrun.Tool) *agentrun.ToolsRetriever {
|
||||
return &agentrun.ToolsRetriever{
|
||||
|
||||
@ -43,8 +43,7 @@ type Config struct {
|
||||
ModelFactory chatmodel.Factory
|
||||
CPStore compose.CheckPointStore
|
||||
|
||||
CustomVariables map[string]string
|
||||
|
||||
CustomVariables map[string]string
|
||||
|
||||
ConversationID int64
|
||||
}
|
||||
@ -75,7 +74,7 @@ func BuildAgent(ctx context.Context, conf *Config) (r *AgentRunner, err error) {
|
||||
return nil, err
|
||||
}
|
||||
if conf.CustomVariables != nil {
|
||||
for k,v := range conf.CustomVariables {
|
||||
for k, v := range conf.CustomVariables {
|
||||
avs[k] = v
|
||||
}
|
||||
}
|
||||
|
||||
@ -82,11 +82,11 @@ func (art *AgentRuntime) ChatflowRun(ctx context.Context, imagex imagex.ImageX)
|
||||
"USER_INPUT": concatWfInput(art),
|
||||
}
|
||||
if art.GetRunMeta().ChatflowParameters != nil {
|
||||
for k,v := range art.GetRunMeta().ChatflowParameters {
|
||||
for k, v := range art.GetRunMeta().ChatflowParameters {
|
||||
chatInput[k] = v
|
||||
}
|
||||
}
|
||||
wfStreamer, err = crossworkflow.DefaultSVC().StreamExecute(ctx, executeConfig, chatInput)
|
||||
wfStreamer, err = crossworkflow.DefaultSVC().StreamExecute(ctx, executeConfig, chatInput)
|
||||
}
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
@ -110,19 +110,15 @@ type PluginCategoryItem struct {
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
|
||||
|
||||
type GetSaasPluginCallInfoRequest struct {
|
||||
PluginID int64 `json:"plugin_id"`
|
||||
}
|
||||
|
||||
type GetSaasPluginCallInfoResponse struct {
|
||||
Code int `json:"code"`
|
||||
Msg string `json:"msg"`
|
||||
Code int `json:"code"`
|
||||
Msg string `json:"msg"`
|
||||
Data *GetSaasPluginCallInfoData `json:"data"`
|
||||
}
|
||||
|
||||
type GetSaasPluginCallInfoData struct {
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -23,7 +23,8 @@ import (
|
||||
"strconv"
|
||||
|
||||
pluginCommon "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/crossdomain/contract/plugin/consts"
|
||||
"github.com/coze-dev/coze-studio/backend/crossdomain/contract/plugin/model"
|
||||
domainDto "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"
|
||||
@ -88,22 +89,22 @@ func convertSaasPluginItemToEntity(item *domainDto.SaasPluginItem) *entity.Plugi
|
||||
}
|
||||
|
||||
// 创建插件清单
|
||||
manifest := &dto.PluginManifest{
|
||||
manifest := &model.PluginManifest{
|
||||
SchemaVersion: "v1",
|
||||
NameForModel: metaInfo.Name,
|
||||
NameForHuman: metaInfo.Name,
|
||||
DescriptionForModel: metaInfo.Description,
|
||||
DescriptionForHuman: metaInfo.Description,
|
||||
LogoURL: metaInfo.IconURL,
|
||||
Auth: &dto.AuthV2{
|
||||
Type: dto.AuthzTypeOfNone,
|
||||
Auth: &model.AuthV2{
|
||||
Type: consts.AuthzTypeOfNone,
|
||||
},
|
||||
API: dto.APIDesc{
|
||||
API: model.APIDesc{
|
||||
Type: "openapi",
|
||||
},
|
||||
}
|
||||
|
||||
pluginInfo := &dto.PluginInfo{
|
||||
pluginInfo := &model.PluginInfo{
|
||||
ID: pluginID,
|
||||
PluginType: pluginCommon.PluginType_PLUGIN,
|
||||
SpaceID: 0,
|
||||
@ -127,22 +128,22 @@ func convertCozePluginToEntity(cozePlugin CozePlugin) *entity.PluginInfo {
|
||||
pluginID = int64(simpleHash(cozePlugin.ID))
|
||||
}
|
||||
|
||||
manifest := &dto.PluginManifest{
|
||||
manifest := &model.PluginManifest{
|
||||
SchemaVersion: "v1",
|
||||
NameForModel: cozePlugin.Name,
|
||||
NameForHuman: cozePlugin.Name,
|
||||
DescriptionForModel: cozePlugin.Description,
|
||||
DescriptionForHuman: cozePlugin.Description,
|
||||
LogoURL: cozePlugin.IconURL,
|
||||
Auth: &dto.AuthV2{
|
||||
Type: dto.AuthzTypeOfNone,
|
||||
Auth: &model.AuthV2{
|
||||
Type: consts.AuthzTypeOfNone,
|
||||
},
|
||||
API: dto.APIDesc{
|
||||
API: model.APIDesc{
|
||||
Type: "openapi",
|
||||
},
|
||||
}
|
||||
|
||||
pluginInfo := &dto.PluginInfo{
|
||||
pluginInfo := &model.PluginInfo{
|
||||
ID: pluginID,
|
||||
PluginType: pluginCommon.PluginType_PLUGIN,
|
||||
SpaceID: 0,
|
||||
|
||||
@ -84,7 +84,7 @@ type PluginService interface {
|
||||
GetSaasPluginInfo(ctx context.Context, pluginID int64) (plugin *entity.PluginInfo, err error)
|
||||
ListSaasPluginCategories(ctx context.Context, req *dto.ListPluginCategoriesRequest) (resp *dto.ListPluginCategoriesResponse, 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)
|
||||
OAuthCode(ctx context.Context, code string, state *dto.OAuthState) (err error)
|
||||
GetAccessToken(ctx context.Context, oa *dto.OAuthInfo) (accessToken string, err error)
|
||||
RevokeAccessToken(ctx context.Context, meta *dto.AuthorizationCodeMeta) (err error)
|
||||
}
|
||||
|
||||
@ -13,7 +13,7 @@ import (
|
||||
context "context"
|
||||
reflect "reflect"
|
||||
|
||||
dto "github.com/coze-dev/coze-studio/backend/crossdomain/contract/plugin/dto"
|
||||
"github.com/coze-dev/coze-studio/backend/crossdomain/contract/plugin/model"
|
||||
dto0 "github.com/coze-dev/coze-studio/backend/domain/plugin/dto"
|
||||
entity "github.com/coze-dev/coze-studio/backend/domain/plugin/entity"
|
||||
gomock "go.uber.org/mock/gomock"
|
||||
@ -189,14 +189,14 @@ func (mr *MockPluginServiceMockRecorder) DuplicateDraftAgentTools(ctx, fromAgent
|
||||
}
|
||||
|
||||
// ExecuteTool mocks base method.
|
||||
func (m *MockPluginService) ExecuteTool(ctx context.Context, req *dto.ExecuteToolRequest, opts ...entity.ExecuteToolOpt) (*dto.ExecuteToolResponse, error) {
|
||||
func (m *MockPluginService) ExecuteTool(ctx context.Context, req *model.ExecuteToolRequest, opts ...model.ExecuteToolOpt) (*model.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].(*dto.ExecuteToolResponse)
|
||||
ret0, _ := ret[0].(*model.ExecuteToolResponse)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
@ -450,7 +450,7 @@ func (mr *MockPluginServiceMockRecorder) ListSaasPluginProducts(ctx, req any) *g
|
||||
}
|
||||
|
||||
// MGetAgentTools mocks base method.
|
||||
func (m *MockPluginService) MGetAgentTools(ctx context.Context, req *dto.MGetAgentToolsRequest) ([]*entity.ToolInfo, error) {
|
||||
func (m *MockPluginService) MGetAgentTools(ctx context.Context, req *model.MGetAgentToolsRequest) ([]*entity.ToolInfo, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "MGetAgentTools", ctx, req)
|
||||
ret0, _ := ret[0].([]*entity.ToolInfo)
|
||||
@ -525,10 +525,10 @@ func (mr *MockPluginServiceMockRecorder) MGetOnlineTools(ctx, toolIDs any) *gomo
|
||||
}
|
||||
|
||||
// MGetPluginLatestVersion mocks base method.
|
||||
func (m *MockPluginService) MGetPluginLatestVersion(ctx context.Context, pluginIDs []int64) (*dto.MGetPluginLatestVersionResponse, error) {
|
||||
func (m *MockPluginService) MGetPluginLatestVersion(ctx context.Context, pluginIDs []int64) (*model.MGetPluginLatestVersionResponse, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "MGetPluginLatestVersion", ctx, pluginIDs)
|
||||
ret0, _ := ret[0].(*dto.MGetPluginLatestVersionResponse)
|
||||
ret0, _ := ret[0].(*model.MGetPluginLatestVersionResponse)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
@ -599,10 +599,10 @@ func (mr *MockPluginServiceMockRecorder) OAuthCode(ctx, code, state any) *gomock
|
||||
}
|
||||
|
||||
// PublishAPPPlugins mocks base method.
|
||||
func (m *MockPluginService) PublishAPPPlugins(ctx context.Context, req *dto.PublishAPPPluginsRequest) (*dto.PublishAPPPluginsResponse, error) {
|
||||
func (m *MockPluginService) PublishAPPPlugins(ctx context.Context, req *model.PublishAPPPluginsRequest) (*model.PublishAPPPluginsResponse, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "PublishAPPPlugins", ctx, req)
|
||||
ret0, _ := ret[0].(*dto.PublishAPPPluginsResponse)
|
||||
ret0, _ := ret[0].(*model.PublishAPPPluginsResponse)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
@ -628,7 +628,7 @@ func (mr *MockPluginServiceMockRecorder) PublishAgentTools(ctx, agentID, agentVe
|
||||
}
|
||||
|
||||
// PublishPlugin mocks base method.
|
||||
func (m *MockPluginService) PublishPlugin(ctx context.Context, req *dto.PublishPluginRequest) error {
|
||||
func (m *MockPluginService) PublishPlugin(ctx context.Context, req *model.PublishPluginRequest) error {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "PublishPlugin", ctx, req)
|
||||
ret0, _ := ret[0].(error)
|
||||
|
||||
Reference in New Issue
Block a user