diff --git a/.github/scripts/check-file-size.sh b/.github/scripts/check-file-size.sh index e2ce0887f..f966b8dd1 100644 --- a/.github/scripts/check-file-size.sh +++ b/.github/scripts/check-file-size.sh @@ -39,7 +39,8 @@ EXCLUDE_PATTERNS=( '**/e2e/**' 'common/changes/**' 'apps/fornax/**', - "packages/arch/semi-theme-hand01" + "packages/arch/semi-theme-hand01", + "frontend/packages/arch/resources/studio-i18n-resource/src/**" ) for pattern in "${EXCLUDE_PATTERNS[@]}"; do diff --git a/backend/api/handler/coze/conversation_service_test.go b/backend/api/handler/coze/conversation_service_test.go deleted file mode 100644 index 6cc067888..000000000 --- a/backend/api/handler/coze/conversation_service_test.go +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright 2025 coze-dev Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package coze - -import ( - "bytes" - "context" - "net/http" - "testing" - - "github.com/bytedance/sonic" - "github.com/cloudwego/hertz/pkg/app/server" - "github.com/cloudwego/hertz/pkg/common/ut" - "github.com/stretchr/testify/assert" - - "github.com/coze-dev/coze-studio/backend/api/model/conversation/common" - "github.com/coze-dev/coze-studio/backend/api/model/conversation/conversation" - "github.com/coze-dev/coze-studio/backend/application" - "github.com/coze-dev/coze-studio/backend/pkg/lang/ptr" -) - -func TestClearConversationCtx(t *testing.T) { - h := server.Default() - err := application.Init(context.Background()) - - t.Logf("application init err: %v", err) - h.POST("/api/conversation/create_section", ClearConversationCtx) - - req := &conversation.ClearConversationCtxRequest{ - ConversationID: 7496795464885338112, - Scene: ptr.Of(common.Scene_Playground), - } - m, err := sonic.Marshal(req) - assert.Nil(t, err) - - w := ut.PerformRequest(h.Engine, "POST", "/api/conversation/create_section", &ut.Body{Body: bytes.NewBuffer(m), Len: len(m)}, ut.Header{Key: "Content-Type", Value: "application/json"}) - res := w.Result() - t.Logf("clear conversation ctx: %s", res.Body()) - assert.Equal(t, http.StatusInternalServerError, res.StatusCode()) -} - -func TestClearConversationHistory(t *testing.T) { - h := server.Default() - err := application.Init(context.Background()) - t.Logf("application init err: %v", err) - h.POST("/api/conversation/clear_message", ClearConversationHistory) - req := &conversation.ClearConversationHistoryRequest{ - ConversationID: 7496795464885338113, - Scene: ptr.Of(common.Scene_Playground), - BotID: ptr.Of(int64(7366055842027922437)), - } - m, err := sonic.Marshal(req) - assert.Nil(t, err) - w := ut.PerformRequest(h.Engine, "POST", "/api/conversation/clear_message", &ut.Body{Body: bytes.NewBuffer(m), Len: len(m)}, ut.Header{Key: "Content-Type", Value: "application/json"}) - res := w.Result() - t.Logf("clear conversation history: %s", res.Body()) - assert.Equal(t, http.StatusInternalServerError, res.StatusCode()) -} diff --git a/backend/api/handler/coze/public_product_service.go b/backend/api/handler/coze/public_product_service.go index 169f3a251..faf8f45c9 100644 --- a/backend/api/handler/coze/public_product_service.go +++ b/backend/api/handler/coze/public_product_service.go @@ -20,7 +20,9 @@ package coze import ( "context" + "fmt" "strconv" + "strings" product_public_api "github.com/coze-dev/coze-studio/backend/api/model/marketplace/product_public_api" "github.com/coze-dev/coze-studio/backend/api/model/workflow" @@ -40,6 +42,7 @@ import ( "github.com/coze-dev/coze-studio/backend/application/search" "github.com/coze-dev/coze-studio/backend/application/singleagent" "github.com/coze-dev/coze-studio/backend/application/template" + "github.com/coze-dev/coze-studio/backend/pkg/logs" ) // PublicGetProductList . @@ -68,6 +71,12 @@ func PublicGetProductList(ctx context.Context, c *app.RequestContext) { internalServerErrorResponse(ctx, c, err) return } + case product_common.ProductEntityType_SaasPlugin: + resp, err = plugin.PluginApplicationSVC.GetCozeSaasPluginList(ctx, &req) + if err != nil { + internalServerErrorResponse(ctx, c, err) + return + } } c.JSON(consts.StatusOK, resp) @@ -267,3 +276,145 @@ func PublicDuplicateProduct(ctx context.Context, c *app.RequestContext) { c.JSON(consts.StatusOK, resp) } + +// PublicSearchProduct . +// @router /api/marketplace/product/search [GET] +func PublicSearchProduct(ctx context.Context, c *app.RequestContext) { + var err error + var req product_public_api.SearchProductRequest + + var categoryIDs []int64 + if categoryIDsStr := string(c.Query("category_ids")); categoryIDsStr != "" { + categoryIDs, err = handlerCategoryIDs(c, &req) + if err != nil { + invalidParamRequestResponse(c, err.Error()) + return + } + c.Request.URI().QueryArgs().Del("category_ids") + } + + err = c.BindAndValidate(&req) + if err != nil { + invalidParamRequestResponse(c, err.Error()) + return + } + + if len(categoryIDs) > 0 { + req.CategoryIDs = categoryIDs + } + // Call plugin application service + resp, err := plugin.PluginApplicationSVC.PublicSearchProduct(ctx, &req) + if err != nil { + logs.CtxErrorf(ctx, "PublicSearchProduct failed: %v", err) + internalServerErrorResponse(ctx, c, err) + return + } + + c.JSON(consts.StatusOK, resp) +} + +func handlerCategoryIDs(c *app.RequestContext, req *product_public_api.SearchProductRequest) ([]int64, error) { + var categoryIDs []int64 + if categoryIDsStr := string(c.Query("category_ids")); categoryIDsStr != "" { + categoryIDStrs := strings.Split(categoryIDsStr, ",") + categoryIDs = make([]int64, 0, len(categoryIDStrs)) + for _, idStr := range categoryIDStrs { + idStr = strings.TrimSpace(idStr) + if idStr != "" { + // Validate that it's a valid integer + if categoryID, parseErr := strconv.ParseInt(idStr, 10, 64); parseErr == nil { + categoryIDs = append(categoryIDs, categoryID) + } else { + return nil, fmt.Errorf("invalid category_id: %s", idStr) + } + } + } + } + return categoryIDs, nil +} + +// PublicSearchSuggest . +// @router /api/marketplace/product/search/suggest [GET] +func PublicSearchSuggest(ctx context.Context, c *app.RequestContext) { + var err error + var req product_public_api.SearchSuggestRequest + err = c.BindAndValidate(&req) + if err != nil { + invalidParamRequestResponse(c, err.Error()) + return + } + + // Call plugin application service + resp, err := plugin.PluginApplicationSVC.PublicSearchSuggest(ctx, &req) + if err != nil { + logs.CtxErrorf(ctx, "PublicSearchSuggest failed: %v", err) + internalServerErrorResponse(ctx, c, err) + return + } + + c.JSON(consts.StatusOK, resp) +} + +// PublicGetProductCategoryList . +// @router /api/marketplace/product/category/list [GET] +func PublicGetProductCategoryList(ctx context.Context, c *app.RequestContext) { + var err error + var req product_public_api.GetProductCategoryListRequest + err = c.BindAndValidate(&req) + if err != nil { + invalidParamRequestResponse(c, err.Error()) + return + } + + var resp *product_public_api.GetProductCategoryListResponse + req.EntityType = product_common.ProductEntityType_SaasPlugin + switch req.GetEntityType() { + case product_common.ProductEntityType_SaasPlugin: + resp, err = plugin.PluginApplicationSVC.GetSaasProductCategoryList(ctx, &req) + if err != nil { + internalServerErrorResponse(ctx, c, err) + return + } + } + c.JSON(consts.StatusOK, resp) +} + +// PublicGetProductCallInfo . +// @router /api/marketplace/product/call_info [GET] +func PublicGetProductCallInfo(ctx context.Context, c *app.RequestContext) { + var err error + var req product_public_api.GetProductCallInfoRequest + err = c.BindAndValidate(&req) + if err != nil { + invalidParamRequestResponse(c, err.Error()) + return + } + + resp, err := plugin.PluginApplicationSVC.GetProductCallInfo(ctx, &req) + if err != nil { + internalServerErrorResponse(ctx, c, err) + return + } + + c.JSON(consts.StatusOK, resp) +} + +// PublicGetMarketPluginConfig . +// @router /api/marketplace/product/config [GET] +func PublicGetMarketPluginConfig(ctx context.Context, c *app.RequestContext) { + var err error + var req product_public_api.GetMarketPluginConfigRequest + err = c.BindAndValidate(&req) + if err != nil { + invalidParamRequestResponse(c, err.Error()) + return + } + + resp, err := plugin.PluginApplicationSVC.GetMarketPluginConfig(ctx, &req) + if err != nil { + internalServerErrorResponse(ctx, c, err) + return + } + + c.JSON(consts.StatusOK, resp) +} diff --git a/backend/api/model/app/bot_common/bot_common.go b/backend/api/model/app/bot_common/bot_common.go index 5a291807b..99201b3cd 100644 --- a/backend/api/model/app/bot_common/bot_common.go +++ b/backend/api/model/app/bot_common/bot_common.go @@ -14,7 +14,7 @@ * limitations under the License. */ -// Code generated by thriftgo (0.4.2). DO NOT EDIT. +// Code generated by thriftgo (0.4.1). DO NOT EDIT. package bot_common @@ -22,7 +22,6 @@ import ( "database/sql" "database/sql/driver" "fmt" - "github.com/apache/thrift/lib/go/thrift" ) @@ -363,6 +362,48 @@ func (p *ModelFuncConfigStatus) Value() (driver.Value, error) { return int64(*p), nil } +type PluginFrom int64 + +const ( + PluginFrom_Default PluginFrom = 0 + PluginFrom_FromSaas PluginFrom = 1 +) + +func (p PluginFrom) String() string { + switch p { + case PluginFrom_Default: + return "Default" + case PluginFrom_FromSaas: + return "FromSaas" + } + return "" +} + +func PluginFromFromString(s string) (PluginFrom, error) { + switch s { + case "Default": + return PluginFrom_Default, nil + case "FromSaas": + return PluginFrom_FromSaas, nil + } + return PluginFrom(0), fmt.Errorf("not a valid PluginFrom string") +} + +func PluginFromPtr(v PluginFrom) *PluginFrom { return &v } +func (p *PluginFrom) Scan(value interface{}) (err error) { + var result sql.NullInt64 + err = result.Scan(value) + *p = PluginFrom(result.Int64) + return +} + +func (p *PluginFrom) Value() (driver.Value, error) { + if p == nil { + return nil, nil + } + return int64(*p), nil +} + type WorkflowMode int64 const ( @@ -3501,7 +3542,8 @@ type PluginInfo struct { // api Id ApiId *int64 `thrift:"ApiId,2,optional" form:"api_id" json:"api_id,string,omitempty"` // API name O project - ApiName *string `thrift:"ApiName,3,optional" form:"api_name" json:"api_name,omitempty"` + ApiName *string `thrift:"ApiName,3,optional" form:"api_name" json:"api_name,omitempty"` + PluginFrom *PluginFrom `thrift:"PluginFrom,99,optional" form:"plugin_from" json:"plugin_from,omitempty"` // api version ApiVersionMs *int64 `thrift:"ApiVersionMs,100,optional" form:"api_version_ms" json:"api_version_ms,string,omitempty"` } @@ -3540,6 +3582,15 @@ func (p *PluginInfo) GetApiName() (v string) { return *p.ApiName } +var PluginInfo_PluginFrom_DEFAULT PluginFrom + +func (p *PluginInfo) GetPluginFrom() (v PluginFrom) { + if !p.IsSetPluginFrom() { + return PluginInfo_PluginFrom_DEFAULT + } + return *p.PluginFrom +} + var PluginInfo_ApiVersionMs_DEFAULT int64 func (p *PluginInfo) GetApiVersionMs() (v int64) { @@ -3553,6 +3604,7 @@ var fieldIDToName_PluginInfo = map[int16]string{ 1: "PluginId", 2: "ApiId", 3: "ApiName", + 99: "PluginFrom", 100: "ApiVersionMs", } @@ -3568,6 +3620,10 @@ func (p *PluginInfo) IsSetApiName() bool { return p.ApiName != nil } +func (p *PluginInfo) IsSetPluginFrom() bool { + return p.PluginFrom != nil +} + func (p *PluginInfo) IsSetApiVersionMs() bool { return p.ApiVersionMs != nil } @@ -3614,6 +3670,14 @@ func (p *PluginInfo) Read(iprot thrift.TProtocol) (err error) { } else if err = iprot.Skip(fieldTypeId); err != nil { goto SkipFieldError } + case 99: + if fieldTypeId == thrift.I32 { + if err = p.ReadField99(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } case 100: if fieldTypeId == thrift.I64 { if err = p.ReadField100(iprot); err != nil { @@ -3684,6 +3748,18 @@ func (p *PluginInfo) ReadField3(iprot thrift.TProtocol) error { p.ApiName = _field return nil } +func (p *PluginInfo) ReadField99(iprot thrift.TProtocol) error { + + var _field *PluginFrom + if v, err := iprot.ReadI32(); err != nil { + return err + } else { + tmp := PluginFrom(v) + _field = &tmp + } + p.PluginFrom = _field + return nil +} func (p *PluginInfo) ReadField100(iprot thrift.TProtocol) error { var _field *int64 @@ -3714,6 +3790,10 @@ func (p *PluginInfo) Write(oprot thrift.TProtocol) (err error) { fieldId = 3 goto WriteFieldError } + if err = p.writeField99(oprot); err != nil { + fieldId = 99 + goto WriteFieldError + } if err = p.writeField100(oprot); err != nil { fieldId = 100 goto WriteFieldError @@ -3790,6 +3870,24 @@ WriteFieldBeginError: WriteFieldEndError: return thrift.PrependError(fmt.Sprintf("%T write field 3 end error: ", p), err) } +func (p *PluginInfo) writeField99(oprot thrift.TProtocol) (err error) { + if p.IsSetPluginFrom() { + if err = oprot.WriteFieldBegin("PluginFrom", thrift.I32, 99); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteI32(int32(*p.PluginFrom)); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 99 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 99 end error: ", p), err) +} func (p *PluginInfo) writeField100(oprot thrift.TProtocol) (err error) { if p.IsSetApiVersionMs() { if err = oprot.WriteFieldBegin("ApiVersionMs", thrift.I64, 100); err != nil { diff --git a/backend/api/model/app/bot_open_api/bot_open_api.go b/backend/api/model/app/bot_open_api/bot_open_api.go index c2d2faf4c..b8bf0e1db 100644 --- a/backend/api/model/app/bot_open_api/bot_open_api.go +++ b/backend/api/model/app/bot_open_api/bot_open_api.go @@ -21,7 +21,6 @@ package bot_open_api import ( "context" "fmt" - "github.com/apache/thrift/lib/go/thrift" "github.com/coze-dev/coze-studio/backend/api/model/app/bot_common" "github.com/coze-dev/coze-studio/backend/api/model/base" diff --git a/backend/api/model/app/intelligence/common/common_struct.go b/backend/api/model/app/intelligence/common/common_struct.go index e2641d474..49cfef32e 100644 --- a/backend/api/model/app/intelligence/common/common_struct.go +++ b/backend/api/model/app/intelligence/common/common_struct.go @@ -22,7 +22,6 @@ import ( "database/sql" "database/sql/driver" "fmt" - "github.com/apache/thrift/lib/go/thrift" ) diff --git a/backend/api/model/app/intelligence/intelligence.go b/backend/api/model/app/intelligence/intelligence.go index 0dc7167a1..9c0b07ab8 100644 --- a/backend/api/model/app/intelligence/intelligence.go +++ b/backend/api/model/app/intelligence/intelligence.go @@ -21,7 +21,6 @@ package intelligence import ( "context" "fmt" - "github.com/apache/thrift/lib/go/thrift" "github.com/coze-dev/coze-studio/backend/api/model/app/intelligence/project" "github.com/coze-dev/coze-studio/backend/api/model/app/intelligence/publish" diff --git a/backend/api/model/app/intelligence/project/project.go b/backend/api/model/app/intelligence/project/project.go index ac95a361a..ea04cb6eb 100644 --- a/backend/api/model/app/intelligence/project/project.go +++ b/backend/api/model/app/intelligence/project/project.go @@ -20,7 +20,6 @@ package project import ( "fmt" - "github.com/apache/thrift/lib/go/thrift" "github.com/coze-dev/coze-studio/backend/api/model/app/intelligence/common" "github.com/coze-dev/coze-studio/backend/api/model/base" diff --git a/backend/api/model/conversation/agentrun/agentrun_service.go b/backend/api/model/conversation/agentrun/agentrun_service.go index 90fc978ff..6060ac96e 100644 --- a/backend/api/model/conversation/agentrun/agentrun_service.go +++ b/backend/api/model/conversation/agentrun/agentrun_service.go @@ -21,7 +21,6 @@ package agentrun import ( "context" "fmt" - "github.com/apache/thrift/lib/go/thrift" "github.com/coze-dev/coze-studio/backend/api/model/conversation/run" ) diff --git a/backend/api/model/conversation/conversation/conversation.go b/backend/api/model/conversation/conversation/conversation.go index eecb2fc2d..0c87f381b 100644 --- a/backend/api/model/conversation/conversation/conversation.go +++ b/backend/api/model/conversation/conversation/conversation.go @@ -20,7 +20,6 @@ package conversation import ( "fmt" - "github.com/apache/thrift/lib/go/thrift" "github.com/coze-dev/coze-studio/backend/api/model/base" "github.com/coze-dev/coze-studio/backend/api/model/conversation/common" diff --git a/backend/api/model/conversation/conversation/conversation_service.go b/backend/api/model/conversation/conversation/conversation_service.go index 303743fd6..065baa737 100644 --- a/backend/api/model/conversation/conversation/conversation_service.go +++ b/backend/api/model/conversation/conversation/conversation_service.go @@ -21,7 +21,6 @@ package conversation import ( "context" "fmt" - "github.com/apache/thrift/lib/go/thrift" ) diff --git a/backend/api/model/conversation/message/message.go b/backend/api/model/conversation/message/message.go index 29d9ff3c1..5864df87a 100644 --- a/backend/api/model/conversation/message/message.go +++ b/backend/api/model/conversation/message/message.go @@ -22,7 +22,6 @@ import ( "database/sql" "database/sql/driver" "fmt" - "github.com/apache/thrift/lib/go/thrift" "github.com/coze-dev/coze-studio/backend/api/model/base" "github.com/coze-dev/coze-studio/backend/api/model/conversation/common" diff --git a/backend/api/model/conversation/run/run.go b/backend/api/model/conversation/run/run.go index 9a52759b1..b71e9fab9 100644 --- a/backend/api/model/conversation/run/run.go +++ b/backend/api/model/conversation/run/run.go @@ -14,7 +14,7 @@ * limitations under the License. */ -// Code generated by thriftgo (0.4.2). DO NOT EDIT. +// Code generated by thriftgo (0.4.1). DO NOT EDIT. package run diff --git a/backend/api/model/crossdomain/agentrun/agent_run.go b/backend/api/model/crossdomain/agentrun/agent_run.go index 58aeaf4b0..e17389e29 100644 --- a/backend/api/model/crossdomain/agentrun/agent_run.go +++ b/backend/api/model/crossdomain/agentrun/agent_run.go @@ -16,12 +16,15 @@ package agentrun +import "github.com/coze-dev/coze-studio/backend/api/model/app/bot_common" + type Tool struct { PluginID int64 `json:"plugin_id"` ToolID int64 `json:"tool_id"` Arguments string `json:"arguments"` ToolName string `json:"tool_name"` Type ToolType `json:"type"` + PluginFrom *bot_common.PluginFrom `json:"plugin_from"` } type ToolType int32 @@ -37,6 +40,7 @@ type ToolsRetriever struct { ToolID int64 Arguments string Type ToolType + PluginFrom *bot_common.PluginFrom `json:"plugin_from"` } type Usage struct { diff --git a/backend/api/model/marketplace/marketplace_common/marketplace_common.go b/backend/api/model/marketplace/marketplace_common/marketplace_common.go index fa28cc083..f0e2b2210 100644 --- a/backend/api/model/marketplace/marketplace_common/marketplace_common.go +++ b/backend/api/model/marketplace/marketplace_common/marketplace_common.go @@ -1,3 +1,19 @@ +/* + * Copyright 2025 coze-dev Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + // Code generated by thriftgo (0.4.1). DO NOT EDIT. package marketplace_common diff --git a/backend/api/model/marketplace/product_common/product_common.go b/backend/api/model/marketplace/product_common/product_common.go index 88e62987b..ca8b008d6 100644 --- a/backend/api/model/marketplace/product_common/product_common.go +++ b/backend/api/model/marketplace/product_common/product_common.go @@ -1,3 +1,19 @@ +/* + * Copyright 2025 coze-dev Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + // Code generated by thriftgo (0.4.1). DO NOT EDIT. package product_common @@ -10,6 +26,110 @@ import ( "github.com/coze-dev/coze-studio/backend/api/model/marketplace/marketplace_common" ) +type BotModType int64 + +const ( + BotModType_SingleAgent BotModType = 1 + BotModType_MultiAgent BotModType = 2 +) + +func (p BotModType) String() string { + switch p { + case BotModType_SingleAgent: + return "SingleAgent" + case BotModType_MultiAgent: + return "MultiAgent" + } + return "" +} + +func BotModTypeFromString(s string) (BotModType, error) { + switch s { + case "SingleAgent": + return BotModType_SingleAgent, nil + case "MultiAgent": + return BotModType_MultiAgent, nil + } + return BotModType(0), fmt.Errorf("not a valid BotModType string") +} + +func BotModTypePtr(v BotModType) *BotModType { return &v } +func (p *BotModType) Scan(value interface{}) (err error) { + var result sql.NullInt64 + err = result.Scan(value) + *p = BotModType(result.Int64) + return +} + +func (p *BotModType) Value() (driver.Value, error) { + if p == nil { + return nil, nil + } + return int64(*p), nil +} + +type Component int64 + +const ( + Component_UsePlugin Component = 1 + Component_UseWorkFlow Component = 2 + Component_UseKnowledge Component = 3 + Component_UseVoice Component = 4 + Component_UseCard Component = 5 + Component_UseImageWorkflow Component = 6 +) + +func (p Component) String() string { + switch p { + case Component_UsePlugin: + return "UsePlugin" + case Component_UseWorkFlow: + return "UseWorkFlow" + case Component_UseKnowledge: + return "UseKnowledge" + case Component_UseVoice: + return "UseVoice" + case Component_UseCard: + return "UseCard" + case Component_UseImageWorkflow: + return "UseImageWorkflow" + } + return "" +} + +func ComponentFromString(s string) (Component, error) { + switch s { + case "UsePlugin": + return Component_UsePlugin, nil + case "UseWorkFlow": + return Component_UseWorkFlow, nil + case "UseKnowledge": + return Component_UseKnowledge, nil + case "UseVoice": + return Component_UseVoice, nil + case "UseCard": + return Component_UseCard, nil + case "UseImageWorkflow": + return Component_UseImageWorkflow, nil + } + return Component(0), fmt.Errorf("not a valid Component string") +} + +func ComponentPtr(v Component) *Component { return &v } +func (p *Component) Scan(value interface{}) (err error) { + var result sql.NullInt64 + err = result.Scan(value) + *p = Component(result.Int64) + return +} + +func (p *Component) Value() (driver.Value, error) { + if p == nil { + return nil, nil + } + return int64(*p), nil +} + type ProductEntityType int64 const ( @@ -41,6 +161,8 @@ const ( ProductEntityType_Common ProductEntityType = 99 // Special Topics (Compatible with previous designs) ProductEntityType_Topic ProductEntityType = 101 + // Saas plugin,the plugins from coze saas + ProductEntityType_SaasPlugin ProductEntityType = 901 ) func (p ProductEntityType) String() string { @@ -77,6 +199,8 @@ func (p ProductEntityType) String() string { return "Common" case ProductEntityType_Topic: return "Topic" + case ProductEntityType_SaasPlugin: + return "SaasPlugin" } return "" } @@ -115,6 +239,8 @@ func ProductEntityTypeFromString(s string) (ProductEntityType, error) { return ProductEntityType_Common, nil case "Topic": return ProductEntityType_Topic, nil + case "SaasPlugin": + return ProductEntityType_SaasPlugin, nil } return ProductEntityType(0), fmt.Errorf("not a valid ProductEntityType string") } diff --git a/backend/api/model/marketplace/product_public_api/public_api.go b/backend/api/model/marketplace/product_public_api/public_api.go index c17d36011..35800866f 100644 --- a/backend/api/model/marketplace/product_public_api/public_api.go +++ b/backend/api/model/marketplace/product_public_api/public_api.go @@ -1,3 +1,19 @@ +/* + * Copyright 2025 coze-dev Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + // Code generated by thriftgo (0.4.1). DO NOT EDIT. package product_public_api @@ -24,6 +40,8 @@ const ( PluginAuthMode_Configured PluginAuthMode = 2 // Authorization is required, but the authorization configuration may be user-level and can be configured by the user himself PluginAuthMode_Supported PluginAuthMode = 3 + // the third-party of coze saas plugin needs to be installed in the saas before it can be used. + PluginAuthMode_NeedInstalled PluginAuthMode = 9 ) func (p PluginAuthMode) String() string { @@ -36,6 +54,8 @@ func (p PluginAuthMode) String() string { return "Configured" case PluginAuthMode_Supported: return "Supported" + case PluginAuthMode_NeedInstalled: + return "NeedInstalled" } return "" } @@ -50,6 +70,8 @@ func PluginAuthModeFromString(s string) (PluginAuthMode, error) { return PluginAuthMode_Configured, nil case "Supported": return PluginAuthMode_Supported, nil + case "NeedInstalled": + return PluginAuthMode_NeedInstalled, nil } return PluginAuthMode(0), fmt.Errorf("not a valid PluginAuthMode string") } @@ -252,6 +274,3462 @@ func (p *TriggerEnable) Value() (driver.Value, error) { return int64(*p), nil } +type UserLevel int64 + +const ( + // Free version + UserLevel_Free UserLevel = 0 + // Overseas + UserLevel_PremiumLite UserLevel = 10 + // Premium + UserLevel_Premium UserLevel = 15 + UserLevel_PremiumPlus UserLevel = 20 + // Domestic + UserLevel_V1ProInstance UserLevel = 100 + // Personal flagship edition + UserLevel_ProPersonal UserLevel = 110 + // Team edition + UserLevel_Team UserLevel = 120 + // Enterprise edition + UserLevel_Enterprise UserLevel = 130 +) + +func (p UserLevel) String() string { + switch p { + case UserLevel_Free: + return "Free" + case UserLevel_PremiumLite: + return "PremiumLite" + case UserLevel_Premium: + return "Premium" + case UserLevel_PremiumPlus: + return "PremiumPlus" + case UserLevel_V1ProInstance: + return "V1ProInstance" + case UserLevel_ProPersonal: + return "ProPersonal" + case UserLevel_Team: + return "Team" + case UserLevel_Enterprise: + return "Enterprise" + } + return "" +} + +func UserLevelFromString(s string) (UserLevel, error) { + switch s { + case "Free": + return UserLevel_Free, nil + case "PremiumLite": + return UserLevel_PremiumLite, nil + case "Premium": + return UserLevel_Premium, nil + case "PremiumPlus": + return UserLevel_PremiumPlus, nil + case "V1ProInstance": + return UserLevel_V1ProInstance, nil + case "ProPersonal": + return UserLevel_ProPersonal, nil + case "Team": + return UserLevel_Team, nil + case "Enterprise": + return UserLevel_Enterprise, nil + } + return UserLevel(0), fmt.Errorf("not a valid UserLevel string") +} + +func UserLevelPtr(v UserLevel) *UserLevel { return &v } +func (p *UserLevel) Scan(value interface{}) (err error) { + var result sql.NullInt64 + err = result.Scan(value) + *p = UserLevel(result.Int64) + return +} + +func (p *UserLevel) Value() (driver.Value, error) { + if p == nil { + return nil, nil + } + return int64(*p), nil +} + +type GetMarketPluginConfigRequest struct { +} + +func NewGetMarketPluginConfigRequest() *GetMarketPluginConfigRequest { + return &GetMarketPluginConfigRequest{} +} + +func (p *GetMarketPluginConfigRequest) InitDefault() { +} + +var fieldIDToName_GetMarketPluginConfigRequest = map[int16]string{} + +func (p *GetMarketPluginConfigRequest) Read(iprot thrift.TProtocol) (err error) { + var fieldTypeId thrift.TType + var fieldId int16 + + if _, err = iprot.ReadStructBegin(); err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldTypeError + } + if err = iprot.ReadFieldEnd(); err != nil { + goto ReadFieldEndError + } + } + if err = iprot.ReadStructEnd(); err != nil { + goto ReadStructEndError + } + + return nil +ReadStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +SkipFieldTypeError: + return thrift.PrependError(fmt.Sprintf("%T skip field type %d error", p, fieldTypeId), err) + +ReadFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *GetMarketPluginConfigRequest) Write(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteStructBegin("GetMarketPluginConfigRequest"); err != nil { + goto WriteStructBeginError + } + if p != nil { + } + if err = oprot.WriteFieldStop(); err != nil { + goto WriteFieldStopError + } + if err = oprot.WriteStructEnd(); err != nil { + goto WriteStructEndError + } + return nil +WriteStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) +WriteFieldStopError: + return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) +WriteStructEndError: + return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) +} + +func (p *GetMarketPluginConfigRequest) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("GetMarketPluginConfigRequest(%+v)", *p) + +} + +type GetMarketPluginConfigResponse struct { + Code int32 `thrift:"Code,1,required" form:"code,required" json:"code,required"` + Message string `thrift:"Message,2,required" form:"message,required" json:"message,required"` + Data *Configuration `thrift:"Data,3,optional" form:"data" json:"data,omitempty"` + BaseResp *base.BaseResp `thrift:"BaseResp,255,optional" form:"BaseResp" json:"BaseResp,omitempty" query:"BaseResp"` +} + +func NewGetMarketPluginConfigResponse() *GetMarketPluginConfigResponse { + return &GetMarketPluginConfigResponse{} +} + +func (p *GetMarketPluginConfigResponse) InitDefault() { +} + +func (p *GetMarketPluginConfigResponse) GetCode() (v int32) { + return p.Code +} + +func (p *GetMarketPluginConfigResponse) GetMessage() (v string) { + return p.Message +} + +var GetMarketPluginConfigResponse_Data_DEFAULT *Configuration + +func (p *GetMarketPluginConfigResponse) GetData() (v *Configuration) { + if !p.IsSetData() { + return GetMarketPluginConfigResponse_Data_DEFAULT + } + return p.Data +} + +var GetMarketPluginConfigResponse_BaseResp_DEFAULT *base.BaseResp + +func (p *GetMarketPluginConfigResponse) GetBaseResp() (v *base.BaseResp) { + if !p.IsSetBaseResp() { + return GetMarketPluginConfigResponse_BaseResp_DEFAULT + } + return p.BaseResp +} + +var fieldIDToName_GetMarketPluginConfigResponse = map[int16]string{ + 1: "Code", + 2: "Message", + 3: "Data", + 255: "BaseResp", +} + +func (p *GetMarketPluginConfigResponse) IsSetData() bool { + return p.Data != nil +} + +func (p *GetMarketPluginConfigResponse) IsSetBaseResp() bool { + return p.BaseResp != nil +} + +func (p *GetMarketPluginConfigResponse) Read(iprot thrift.TProtocol) (err error) { + var fieldTypeId thrift.TType + var fieldId int16 + var issetCode bool = false + var issetMessage bool = false + + if _, err = iprot.ReadStructBegin(); err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + + switch fieldId { + case 1: + if fieldTypeId == thrift.I32 { + if err = p.ReadField1(iprot); err != nil { + goto ReadFieldError + } + issetCode = true + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + case 2: + if fieldTypeId == thrift.STRING { + if err = p.ReadField2(iprot); err != nil { + goto ReadFieldError + } + issetMessage = true + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + case 3: + if fieldTypeId == thrift.STRUCT { + if err = p.ReadField3(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + case 255: + if fieldTypeId == thrift.STRUCT { + if err = p.ReadField255(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + default: + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + } + if err = iprot.ReadFieldEnd(); err != nil { + goto ReadFieldEndError + } + } + if err = iprot.ReadStructEnd(); err != nil { + goto ReadStructEndError + } + + if !issetCode { + fieldId = 1 + goto RequiredFieldNotSetError + } + + if !issetMessage { + fieldId = 2 + goto RequiredFieldNotSetError + } + return nil +ReadStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_GetMarketPluginConfigResponse[fieldId]), err) +SkipFieldError: + return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) + +ReadFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +RequiredFieldNotSetError: + return thrift.NewTProtocolExceptionWithType(thrift.INVALID_DATA, fmt.Errorf("required field %s is not set", fieldIDToName_GetMarketPluginConfigResponse[fieldId])) +} + +func (p *GetMarketPluginConfigResponse) ReadField1(iprot thrift.TProtocol) error { + + var _field int32 + if v, err := iprot.ReadI32(); err != nil { + return err + } else { + _field = v + } + p.Code = _field + return nil +} +func (p *GetMarketPluginConfigResponse) ReadField2(iprot thrift.TProtocol) error { + + var _field string + if v, err := iprot.ReadString(); err != nil { + return err + } else { + _field = v + } + p.Message = _field + return nil +} +func (p *GetMarketPluginConfigResponse) ReadField3(iprot thrift.TProtocol) error { + _field := NewConfiguration() + if err := _field.Read(iprot); err != nil { + return err + } + p.Data = _field + return nil +} +func (p *GetMarketPluginConfigResponse) ReadField255(iprot thrift.TProtocol) error { + _field := base.NewBaseResp() + if err := _field.Read(iprot); err != nil { + return err + } + p.BaseResp = _field + return nil +} + +func (p *GetMarketPluginConfigResponse) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("GetMarketPluginConfigResponse"); err != nil { + goto WriteStructBeginError + } + if p != nil { + if err = p.writeField1(oprot); err != nil { + fieldId = 1 + goto WriteFieldError + } + if err = p.writeField2(oprot); err != nil { + fieldId = 2 + goto WriteFieldError + } + if err = p.writeField3(oprot); err != nil { + fieldId = 3 + goto WriteFieldError + } + if err = p.writeField255(oprot); err != nil { + fieldId = 255 + goto WriteFieldError + } + } + if err = oprot.WriteFieldStop(); err != nil { + goto WriteFieldStopError + } + if err = oprot.WriteStructEnd(); err != nil { + goto WriteStructEndError + } + return nil +WriteStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) +WriteFieldError: + return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) +WriteFieldStopError: + return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) +WriteStructEndError: + return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) +} + +func (p *GetMarketPluginConfigResponse) writeField1(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("Code", thrift.I32, 1); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteI32(p.Code); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) +} +func (p *GetMarketPluginConfigResponse) writeField2(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("Message", thrift.STRING, 2); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteString(p.Message); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 2 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 2 end error: ", p), err) +} +func (p *GetMarketPluginConfigResponse) writeField3(oprot thrift.TProtocol) (err error) { + if p.IsSetData() { + if err = oprot.WriteFieldBegin("Data", thrift.STRUCT, 3); err != nil { + goto WriteFieldBeginError + } + if err := p.Data.Write(oprot); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 3 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 3 end error: ", p), err) +} +func (p *GetMarketPluginConfigResponse) writeField255(oprot thrift.TProtocol) (err error) { + if p.IsSetBaseResp() { + if err = oprot.WriteFieldBegin("BaseResp", thrift.STRUCT, 255); err != nil { + goto WriteFieldBeginError + } + if err := p.BaseResp.Write(oprot); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 255 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 255 end error: ", p), err) +} + +func (p *GetMarketPluginConfigResponse) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("GetMarketPluginConfigResponse(%+v)", *p) + +} + +type Configuration struct { + EnableSaasPlugin *bool `thrift:"enable_saas_plugin,1,optional" form:"enable_saas_plugin" json:"enable_saas_plugin,omitempty" query:"enable_saas_plugin"` +} + +func NewConfiguration() *Configuration { + return &Configuration{} +} + +func (p *Configuration) InitDefault() { +} + +var Configuration_EnableSaasPlugin_DEFAULT bool + +func (p *Configuration) GetEnableSaasPlugin() (v bool) { + if !p.IsSetEnableSaasPlugin() { + return Configuration_EnableSaasPlugin_DEFAULT + } + return *p.EnableSaasPlugin +} + +var fieldIDToName_Configuration = map[int16]string{ + 1: "enable_saas_plugin", +} + +func (p *Configuration) IsSetEnableSaasPlugin() bool { + return p.EnableSaasPlugin != nil +} + +func (p *Configuration) Read(iprot thrift.TProtocol) (err error) { + var fieldTypeId thrift.TType + var fieldId int16 + + if _, err = iprot.ReadStructBegin(); err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + + switch fieldId { + case 1: + if fieldTypeId == thrift.BOOL { + if err = p.ReadField1(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + default: + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + } + if err = iprot.ReadFieldEnd(); err != nil { + goto ReadFieldEndError + } + } + if err = iprot.ReadStructEnd(); err != nil { + goto ReadStructEndError + } + + return nil +ReadStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_Configuration[fieldId]), err) +SkipFieldError: + return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) + +ReadFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *Configuration) ReadField1(iprot thrift.TProtocol) error { + + var _field *bool + if v, err := iprot.ReadBool(); err != nil { + return err + } else { + _field = &v + } + p.EnableSaasPlugin = _field + return nil +} + +func (p *Configuration) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("Configuration"); err != nil { + goto WriteStructBeginError + } + if p != nil { + if err = p.writeField1(oprot); err != nil { + fieldId = 1 + goto WriteFieldError + } + } + if err = oprot.WriteFieldStop(); err != nil { + goto WriteFieldStopError + } + if err = oprot.WriteStructEnd(); err != nil { + goto WriteStructEndError + } + return nil +WriteStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) +WriteFieldError: + return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) +WriteFieldStopError: + return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) +WriteStructEndError: + return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) +} + +func (p *Configuration) writeField1(oprot thrift.TProtocol) (err error) { + if p.IsSetEnableSaasPlugin() { + if err = oprot.WriteFieldBegin("enable_saas_plugin", thrift.BOOL, 1); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteBool(*p.EnableSaasPlugin); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) +} + +func (p *Configuration) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("Configuration(%+v)", *p) + +} + +type SearchProductRequest struct { + Keyword string `thrift:"Keyword,1,required" json:"Keyword,required" query:"keyword,required"` + PageNum int32 `thrift:"PageNum,2,required" json:"PageNum,required" query:"page_num,required"` + PageSize int32 `thrift:"PageSize,3,required" json:"PageSize,required" query:"page_size,required"` + EntityType *product_common.ProductEntityType `thrift:"EntityType,4,optional" form:"EntityType" json:"EntityType,omitempty" query:"EntityType"` + SortType *product_common.SortType `thrift:"SortType,5,optional" json:"SortType,omitempty" query:"sort_type"` + // Open/closed source + PublishMode *product_common.ProductPublishMode `thrift:"PublishMode,11,optional" form:"PublishMode" json:"PublishMode,omitempty" query:"PublishMode"` + // Models used + ModelIDs []int64 `thrift:"ModelIDs,12,optional" json:"ModelIDs,omitempty" query:"model_ids"` + // Multimodal type + BotModType *product_common.BotModType `thrift:"BotModType,13,optional" form:"BotModType" json:"BotModType,omitempty" query:"BotModType"` + // Sub-attributes + Components []product_common.Component `thrift:"Components,14,optional" form:"Components" json:"Components,omitempty" query:"Components"` + // Publish platform IDs + PublishPlatformIDs []int64 `thrift:"PublishPlatformIDs,15,optional" json:"PublishPlatformIDs,omitempty" query:"publish_platform_ids"` + // Product category IDs + CategoryIDs []int64 `thrift:"CategoryIDs,16,optional" json:"CategoryIDs,omitempty" query:"category_ids"` + // Is official + IsOfficial *bool `thrift:"IsOfficial,17,optional" json:"IsOfficial,omitempty" query:"is_official"` + // Is recommended + IsRecommend *bool `thrift:"IsRecommend,18,optional" json:"IsRecommend,omitempty" query:"is_recommend"` + // Product type list, use this parameter first, then EntityType + EntityTypes *string `thrift:"EntityTypes,19,optional" json:"EntityTypes,omitempty" query:"entity_types"` + // Plugin type + PluginType *product_common.PluginType `thrift:"PluginType,20,optional" form:"PluginType" json:"PluginType,omitempty" query:"PluginType"` + // Product paid type + ProductPaidType *product_common.ProductPaidType `thrift:"ProductPaidType,21,optional" form:"ProductPaidType" json:"ProductPaidType,omitempty" query:"ProductPaidType"` + Base *base.Base `thrift:"Base,255,optional" form:"Base" json:"Base,omitempty" query:"Base"` +} + +func NewSearchProductRequest() *SearchProductRequest { + return &SearchProductRequest{} +} + +func (p *SearchProductRequest) InitDefault() { +} + +func (p *SearchProductRequest) GetKeyword() (v string) { + return p.Keyword +} + +func (p *SearchProductRequest) GetPageNum() (v int32) { + return p.PageNum +} + +func (p *SearchProductRequest) GetPageSize() (v int32) { + return p.PageSize +} + +var SearchProductRequest_EntityType_DEFAULT product_common.ProductEntityType + +func (p *SearchProductRequest) GetEntityType() (v product_common.ProductEntityType) { + if !p.IsSetEntityType() { + return SearchProductRequest_EntityType_DEFAULT + } + return *p.EntityType +} + +var SearchProductRequest_SortType_DEFAULT product_common.SortType + +func (p *SearchProductRequest) GetSortType() (v product_common.SortType) { + if !p.IsSetSortType() { + return SearchProductRequest_SortType_DEFAULT + } + return *p.SortType +} + +var SearchProductRequest_PublishMode_DEFAULT product_common.ProductPublishMode + +func (p *SearchProductRequest) GetPublishMode() (v product_common.ProductPublishMode) { + if !p.IsSetPublishMode() { + return SearchProductRequest_PublishMode_DEFAULT + } + return *p.PublishMode +} + +var SearchProductRequest_ModelIDs_DEFAULT []int64 + +func (p *SearchProductRequest) GetModelIDs() (v []int64) { + if !p.IsSetModelIDs() { + return SearchProductRequest_ModelIDs_DEFAULT + } + return p.ModelIDs +} + +var SearchProductRequest_BotModType_DEFAULT product_common.BotModType + +func (p *SearchProductRequest) GetBotModType() (v product_common.BotModType) { + if !p.IsSetBotModType() { + return SearchProductRequest_BotModType_DEFAULT + } + return *p.BotModType +} + +var SearchProductRequest_Components_DEFAULT []product_common.Component + +func (p *SearchProductRequest) GetComponents() (v []product_common.Component) { + if !p.IsSetComponents() { + return SearchProductRequest_Components_DEFAULT + } + return p.Components +} + +var SearchProductRequest_PublishPlatformIDs_DEFAULT []int64 + +func (p *SearchProductRequest) GetPublishPlatformIDs() (v []int64) { + if !p.IsSetPublishPlatformIDs() { + return SearchProductRequest_PublishPlatformIDs_DEFAULT + } + return p.PublishPlatformIDs +} + +var SearchProductRequest_CategoryIDs_DEFAULT []int64 + +func (p *SearchProductRequest) GetCategoryIDs() (v []int64) { + if !p.IsSetCategoryIDs() { + return SearchProductRequest_CategoryIDs_DEFAULT + } + return p.CategoryIDs +} + +var SearchProductRequest_IsOfficial_DEFAULT bool + +func (p *SearchProductRequest) GetIsOfficial() (v bool) { + if !p.IsSetIsOfficial() { + return SearchProductRequest_IsOfficial_DEFAULT + } + return *p.IsOfficial +} + +var SearchProductRequest_IsRecommend_DEFAULT bool + +func (p *SearchProductRequest) GetIsRecommend() (v bool) { + if !p.IsSetIsRecommend() { + return SearchProductRequest_IsRecommend_DEFAULT + } + return *p.IsRecommend +} + +var SearchProductRequest_EntityTypes_DEFAULT string + +func (p *SearchProductRequest) GetEntityTypes() (v string) { + if !p.IsSetEntityTypes() { + return SearchProductRequest_EntityTypes_DEFAULT + } + return *p.EntityTypes +} + +var SearchProductRequest_PluginType_DEFAULT product_common.PluginType + +func (p *SearchProductRequest) GetPluginType() (v product_common.PluginType) { + if !p.IsSetPluginType() { + return SearchProductRequest_PluginType_DEFAULT + } + return *p.PluginType +} + +var SearchProductRequest_ProductPaidType_DEFAULT product_common.ProductPaidType + +func (p *SearchProductRequest) GetProductPaidType() (v product_common.ProductPaidType) { + if !p.IsSetProductPaidType() { + return SearchProductRequest_ProductPaidType_DEFAULT + } + return *p.ProductPaidType +} + +var SearchProductRequest_Base_DEFAULT *base.Base + +func (p *SearchProductRequest) GetBase() (v *base.Base) { + if !p.IsSetBase() { + return SearchProductRequest_Base_DEFAULT + } + return p.Base +} + +var fieldIDToName_SearchProductRequest = map[int16]string{ + 1: "Keyword", + 2: "PageNum", + 3: "PageSize", + 4: "EntityType", + 5: "SortType", + 11: "PublishMode", + 12: "ModelIDs", + 13: "BotModType", + 14: "Components", + 15: "PublishPlatformIDs", + 16: "CategoryIDs", + 17: "IsOfficial", + 18: "IsRecommend", + 19: "EntityTypes", + 20: "PluginType", + 21: "ProductPaidType", + 255: "Base", +} + +func (p *SearchProductRequest) IsSetEntityType() bool { + return p.EntityType != nil +} + +func (p *SearchProductRequest) IsSetSortType() bool { + return p.SortType != nil +} + +func (p *SearchProductRequest) IsSetPublishMode() bool { + return p.PublishMode != nil +} + +func (p *SearchProductRequest) IsSetModelIDs() bool { + return p.ModelIDs != nil +} + +func (p *SearchProductRequest) IsSetBotModType() bool { + return p.BotModType != nil +} + +func (p *SearchProductRequest) IsSetComponents() bool { + return p.Components != nil +} + +func (p *SearchProductRequest) IsSetPublishPlatformIDs() bool { + return p.PublishPlatformIDs != nil +} + +func (p *SearchProductRequest) IsSetCategoryIDs() bool { + return p.CategoryIDs != nil +} + +func (p *SearchProductRequest) IsSetIsOfficial() bool { + return p.IsOfficial != nil +} + +func (p *SearchProductRequest) IsSetIsRecommend() bool { + return p.IsRecommend != nil +} + +func (p *SearchProductRequest) IsSetEntityTypes() bool { + return p.EntityTypes != nil +} + +func (p *SearchProductRequest) IsSetPluginType() bool { + return p.PluginType != nil +} + +func (p *SearchProductRequest) IsSetProductPaidType() bool { + return p.ProductPaidType != nil +} + +func (p *SearchProductRequest) IsSetBase() bool { + return p.Base != nil +} + +func (p *SearchProductRequest) Read(iprot thrift.TProtocol) (err error) { + var fieldTypeId thrift.TType + var fieldId int16 + var issetKeyword bool = false + var issetPageNum bool = false + var issetPageSize bool = false + + if _, err = iprot.ReadStructBegin(); err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + + switch fieldId { + case 1: + if fieldTypeId == thrift.STRING { + if err = p.ReadField1(iprot); err != nil { + goto ReadFieldError + } + issetKeyword = true + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + case 2: + if fieldTypeId == thrift.I32 { + if err = p.ReadField2(iprot); err != nil { + goto ReadFieldError + } + issetPageNum = true + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + case 3: + if fieldTypeId == thrift.I32 { + if err = p.ReadField3(iprot); err != nil { + goto ReadFieldError + } + issetPageSize = true + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + case 4: + if fieldTypeId == thrift.I32 { + if err = p.ReadField4(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + case 5: + if fieldTypeId == thrift.I32 { + if err = p.ReadField5(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + case 11: + if fieldTypeId == thrift.I32 { + if err = p.ReadField11(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + case 12: + if fieldTypeId == thrift.LIST { + if err = p.ReadField12(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + case 13: + if fieldTypeId == thrift.I32 { + if err = p.ReadField13(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + case 14: + if fieldTypeId == thrift.LIST { + if err = p.ReadField14(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + case 15: + if fieldTypeId == thrift.LIST { + if err = p.ReadField15(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + case 16: + if fieldTypeId == thrift.LIST { + if err = p.ReadField16(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + case 17: + if fieldTypeId == thrift.BOOL { + if err = p.ReadField17(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + case 18: + if fieldTypeId == thrift.BOOL { + if err = p.ReadField18(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + case 19: + if fieldTypeId == thrift.STRING { + if err = p.ReadField19(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + case 20: + if fieldTypeId == thrift.I32 { + if err = p.ReadField20(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + case 21: + if fieldTypeId == thrift.I32 { + if err = p.ReadField21(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + case 255: + if fieldTypeId == thrift.STRUCT { + if err = p.ReadField255(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + default: + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + } + if err = iprot.ReadFieldEnd(); err != nil { + goto ReadFieldEndError + } + } + if err = iprot.ReadStructEnd(); err != nil { + goto ReadStructEndError + } + + if !issetKeyword { + fieldId = 1 + goto RequiredFieldNotSetError + } + + if !issetPageNum { + fieldId = 2 + goto RequiredFieldNotSetError + } + + if !issetPageSize { + fieldId = 3 + goto RequiredFieldNotSetError + } + return nil +ReadStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_SearchProductRequest[fieldId]), err) +SkipFieldError: + return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) + +ReadFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +RequiredFieldNotSetError: + return thrift.NewTProtocolExceptionWithType(thrift.INVALID_DATA, fmt.Errorf("required field %s is not set", fieldIDToName_SearchProductRequest[fieldId])) +} + +func (p *SearchProductRequest) ReadField1(iprot thrift.TProtocol) error { + + var _field string + if v, err := iprot.ReadString(); err != nil { + return err + } else { + _field = v + } + p.Keyword = _field + return nil +} +func (p *SearchProductRequest) ReadField2(iprot thrift.TProtocol) error { + + var _field int32 + if v, err := iprot.ReadI32(); err != nil { + return err + } else { + _field = v + } + p.PageNum = _field + return nil +} +func (p *SearchProductRequest) ReadField3(iprot thrift.TProtocol) error { + + var _field int32 + if v, err := iprot.ReadI32(); err != nil { + return err + } else { + _field = v + } + p.PageSize = _field + return nil +} +func (p *SearchProductRequest) ReadField4(iprot thrift.TProtocol) error { + + var _field *product_common.ProductEntityType + if v, err := iprot.ReadI32(); err != nil { + return err + } else { + tmp := product_common.ProductEntityType(v) + _field = &tmp + } + p.EntityType = _field + return nil +} +func (p *SearchProductRequest) ReadField5(iprot thrift.TProtocol) error { + + var _field *product_common.SortType + if v, err := iprot.ReadI32(); err != nil { + return err + } else { + tmp := product_common.SortType(v) + _field = &tmp + } + p.SortType = _field + return nil +} +func (p *SearchProductRequest) ReadField11(iprot thrift.TProtocol) error { + + var _field *product_common.ProductPublishMode + if v, err := iprot.ReadI32(); err != nil { + return err + } else { + tmp := product_common.ProductPublishMode(v) + _field = &tmp + } + p.PublishMode = _field + return nil +} +func (p *SearchProductRequest) ReadField12(iprot thrift.TProtocol) error { + _, size, err := iprot.ReadListBegin() + if err != nil { + return err + } + _field := make([]int64, 0, size) + for i := 0; i < size; i++ { + + var _elem int64 + if v, err := iprot.ReadI64(); err != nil { + return err + } else { + _elem = v + } + + _field = append(_field, _elem) + } + if err := iprot.ReadListEnd(); err != nil { + return err + } + p.ModelIDs = _field + return nil +} +func (p *SearchProductRequest) ReadField13(iprot thrift.TProtocol) error { + + var _field *product_common.BotModType + if v, err := iprot.ReadI32(); err != nil { + return err + } else { + tmp := product_common.BotModType(v) + _field = &tmp + } + p.BotModType = _field + return nil +} +func (p *SearchProductRequest) ReadField14(iprot thrift.TProtocol) error { + _, size, err := iprot.ReadListBegin() + if err != nil { + return err + } + _field := make([]product_common.Component, 0, size) + for i := 0; i < size; i++ { + + var _elem product_common.Component + if v, err := iprot.ReadI32(); err != nil { + return err + } else { + _elem = product_common.Component(v) + } + + _field = append(_field, _elem) + } + if err := iprot.ReadListEnd(); err != nil { + return err + } + p.Components = _field + return nil +} +func (p *SearchProductRequest) ReadField15(iprot thrift.TProtocol) error { + _, size, err := iprot.ReadListBegin() + if err != nil { + return err + } + _field := make([]int64, 0, size) + for i := 0; i < size; i++ { + + var _elem int64 + if v, err := iprot.ReadI64(); err != nil { + return err + } else { + _elem = v + } + + _field = append(_field, _elem) + } + if err := iprot.ReadListEnd(); err != nil { + return err + } + p.PublishPlatformIDs = _field + return nil +} +func (p *SearchProductRequest) ReadField16(iprot thrift.TProtocol) error { + _, size, err := iprot.ReadListBegin() + if err != nil { + return err + } + _field := make([]int64, 0, size) + for i := 0; i < size; i++ { + + var _elem int64 + if v, err := iprot.ReadI64(); err != nil { + return err + } else { + _elem = v + } + + _field = append(_field, _elem) + } + if err := iprot.ReadListEnd(); err != nil { + return err + } + p.CategoryIDs = _field + return nil +} +func (p *SearchProductRequest) ReadField17(iprot thrift.TProtocol) error { + + var _field *bool + if v, err := iprot.ReadBool(); err != nil { + return err + } else { + _field = &v + } + p.IsOfficial = _field + return nil +} +func (p *SearchProductRequest) ReadField18(iprot thrift.TProtocol) error { + + var _field *bool + if v, err := iprot.ReadBool(); err != nil { + return err + } else { + _field = &v + } + p.IsRecommend = _field + return nil +} +func (p *SearchProductRequest) ReadField19(iprot thrift.TProtocol) error { + + var _field *string + if v, err := iprot.ReadString(); err != nil { + return err + } else { + _field = &v + } + p.EntityTypes = _field + return nil +} +func (p *SearchProductRequest) ReadField20(iprot thrift.TProtocol) error { + + var _field *product_common.PluginType + if v, err := iprot.ReadI32(); err != nil { + return err + } else { + tmp := product_common.PluginType(v) + _field = &tmp + } + p.PluginType = _field + return nil +} +func (p *SearchProductRequest) ReadField21(iprot thrift.TProtocol) error { + + var _field *product_common.ProductPaidType + if v, err := iprot.ReadI32(); err != nil { + return err + } else { + tmp := product_common.ProductPaidType(v) + _field = &tmp + } + p.ProductPaidType = _field + return nil +} +func (p *SearchProductRequest) ReadField255(iprot thrift.TProtocol) error { + _field := base.NewBase() + if err := _field.Read(iprot); err != nil { + return err + } + p.Base = _field + return nil +} + +func (p *SearchProductRequest) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("SearchProductRequest"); err != nil { + goto WriteStructBeginError + } + if p != nil { + if err = p.writeField1(oprot); err != nil { + fieldId = 1 + goto WriteFieldError + } + if err = p.writeField2(oprot); err != nil { + fieldId = 2 + goto WriteFieldError + } + if err = p.writeField3(oprot); err != nil { + fieldId = 3 + goto WriteFieldError + } + if err = p.writeField4(oprot); err != nil { + fieldId = 4 + goto WriteFieldError + } + if err = p.writeField5(oprot); err != nil { + fieldId = 5 + goto WriteFieldError + } + if err = p.writeField11(oprot); err != nil { + fieldId = 11 + goto WriteFieldError + } + if err = p.writeField12(oprot); err != nil { + fieldId = 12 + goto WriteFieldError + } + if err = p.writeField13(oprot); err != nil { + fieldId = 13 + goto WriteFieldError + } + if err = p.writeField14(oprot); err != nil { + fieldId = 14 + goto WriteFieldError + } + if err = p.writeField15(oprot); err != nil { + fieldId = 15 + goto WriteFieldError + } + if err = p.writeField16(oprot); err != nil { + fieldId = 16 + goto WriteFieldError + } + if err = p.writeField17(oprot); err != nil { + fieldId = 17 + goto WriteFieldError + } + if err = p.writeField18(oprot); err != nil { + fieldId = 18 + goto WriteFieldError + } + if err = p.writeField19(oprot); err != nil { + fieldId = 19 + goto WriteFieldError + } + if err = p.writeField20(oprot); err != nil { + fieldId = 20 + goto WriteFieldError + } + if err = p.writeField21(oprot); err != nil { + fieldId = 21 + goto WriteFieldError + } + if err = p.writeField255(oprot); err != nil { + fieldId = 255 + goto WriteFieldError + } + } + if err = oprot.WriteFieldStop(); err != nil { + goto WriteFieldStopError + } + if err = oprot.WriteStructEnd(); err != nil { + goto WriteStructEndError + } + return nil +WriteStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) +WriteFieldError: + return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) +WriteFieldStopError: + return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) +WriteStructEndError: + return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) +} + +func (p *SearchProductRequest) writeField1(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("Keyword", thrift.STRING, 1); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteString(p.Keyword); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) +} +func (p *SearchProductRequest) writeField2(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("PageNum", thrift.I32, 2); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteI32(p.PageNum); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 2 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 2 end error: ", p), err) +} +func (p *SearchProductRequest) writeField3(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("PageSize", thrift.I32, 3); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteI32(p.PageSize); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 3 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 3 end error: ", p), err) +} +func (p *SearchProductRequest) writeField4(oprot thrift.TProtocol) (err error) { + if p.IsSetEntityType() { + if err = oprot.WriteFieldBegin("EntityType", thrift.I32, 4); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteI32(int32(*p.EntityType)); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 4 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 4 end error: ", p), err) +} +func (p *SearchProductRequest) writeField5(oprot thrift.TProtocol) (err error) { + if p.IsSetSortType() { + if err = oprot.WriteFieldBegin("SortType", thrift.I32, 5); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteI32(int32(*p.SortType)); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 5 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 5 end error: ", p), err) +} +func (p *SearchProductRequest) writeField11(oprot thrift.TProtocol) (err error) { + if p.IsSetPublishMode() { + if err = oprot.WriteFieldBegin("PublishMode", thrift.I32, 11); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteI32(int32(*p.PublishMode)); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 11 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 11 end error: ", p), err) +} +func (p *SearchProductRequest) writeField12(oprot thrift.TProtocol) (err error) { + if p.IsSetModelIDs() { + if err = oprot.WriteFieldBegin("ModelIDs", thrift.LIST, 12); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteListBegin(thrift.I64, len(p.ModelIDs)); err != nil { + return err + } + for _, v := range p.ModelIDs { + if err := oprot.WriteI64(v); err != nil { + return err + } + } + if err := oprot.WriteListEnd(); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 12 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 12 end error: ", p), err) +} +func (p *SearchProductRequest) writeField13(oprot thrift.TProtocol) (err error) { + if p.IsSetBotModType() { + if err = oprot.WriteFieldBegin("BotModType", thrift.I32, 13); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteI32(int32(*p.BotModType)); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 13 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 13 end error: ", p), err) +} +func (p *SearchProductRequest) writeField14(oprot thrift.TProtocol) (err error) { + if p.IsSetComponents() { + if err = oprot.WriteFieldBegin("Components", thrift.LIST, 14); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteListBegin(thrift.I32, len(p.Components)); err != nil { + return err + } + for _, v := range p.Components { + if err := oprot.WriteI32(int32(v)); err != nil { + return err + } + } + if err := oprot.WriteListEnd(); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 14 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 14 end error: ", p), err) +} +func (p *SearchProductRequest) writeField15(oprot thrift.TProtocol) (err error) { + if p.IsSetPublishPlatformIDs() { + if err = oprot.WriteFieldBegin("PublishPlatformIDs", thrift.LIST, 15); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteListBegin(thrift.I64, len(p.PublishPlatformIDs)); err != nil { + return err + } + for _, v := range p.PublishPlatformIDs { + if err := oprot.WriteI64(v); err != nil { + return err + } + } + if err := oprot.WriteListEnd(); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 15 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 15 end error: ", p), err) +} +func (p *SearchProductRequest) writeField16(oprot thrift.TProtocol) (err error) { + if p.IsSetCategoryIDs() { + if err = oprot.WriteFieldBegin("CategoryIDs", thrift.LIST, 16); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteListBegin(thrift.I64, len(p.CategoryIDs)); err != nil { + return err + } + for _, v := range p.CategoryIDs { + if err := oprot.WriteI64(v); err != nil { + return err + } + } + if err := oprot.WriteListEnd(); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 16 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 16 end error: ", p), err) +} +func (p *SearchProductRequest) writeField17(oprot thrift.TProtocol) (err error) { + if p.IsSetIsOfficial() { + if err = oprot.WriteFieldBegin("IsOfficial", thrift.BOOL, 17); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteBool(*p.IsOfficial); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 17 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 17 end error: ", p), err) +} +func (p *SearchProductRequest) writeField18(oprot thrift.TProtocol) (err error) { + if p.IsSetIsRecommend() { + if err = oprot.WriteFieldBegin("IsRecommend", thrift.BOOL, 18); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteBool(*p.IsRecommend); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 18 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 18 end error: ", p), err) +} +func (p *SearchProductRequest) writeField19(oprot thrift.TProtocol) (err error) { + if p.IsSetEntityTypes() { + if err = oprot.WriteFieldBegin("EntityTypes", thrift.STRING, 19); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteString(*p.EntityTypes); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 19 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 19 end error: ", p), err) +} +func (p *SearchProductRequest) writeField20(oprot thrift.TProtocol) (err error) { + if p.IsSetPluginType() { + if err = oprot.WriteFieldBegin("PluginType", thrift.I32, 20); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteI32(int32(*p.PluginType)); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 20 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 20 end error: ", p), err) +} +func (p *SearchProductRequest) writeField21(oprot thrift.TProtocol) (err error) { + if p.IsSetProductPaidType() { + if err = oprot.WriteFieldBegin("ProductPaidType", thrift.I32, 21); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteI32(int32(*p.ProductPaidType)); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 21 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 21 end error: ", p), err) +} +func (p *SearchProductRequest) writeField255(oprot thrift.TProtocol) (err error) { + if p.IsSetBase() { + if err = oprot.WriteFieldBegin("Base", thrift.STRUCT, 255); err != nil { + goto WriteFieldBeginError + } + if err := p.Base.Write(oprot); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 255 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 255 end error: ", p), err) +} + +func (p *SearchProductRequest) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("SearchProductRequest(%+v)", *p) + +} + +type SearchProductResponse struct { + Code int32 `thrift:"Code,1,required" form:"code,required" json:"code,required"` + Message string `thrift:"Message,2,required" form:"message,required" json:"message,required"` + Data *SearchProductResponseData `thrift:"Data,3,optional" form:"data" json:"data,omitempty"` + BaseResp *base.BaseResp `thrift:"BaseResp,255,optional" form:"BaseResp" json:"BaseResp,omitempty" query:"BaseResp"` +} + +func NewSearchProductResponse() *SearchProductResponse { + return &SearchProductResponse{} +} + +func (p *SearchProductResponse) InitDefault() { +} + +func (p *SearchProductResponse) GetCode() (v int32) { + return p.Code +} + +func (p *SearchProductResponse) GetMessage() (v string) { + return p.Message +} + +var SearchProductResponse_Data_DEFAULT *SearchProductResponseData + +func (p *SearchProductResponse) GetData() (v *SearchProductResponseData) { + if !p.IsSetData() { + return SearchProductResponse_Data_DEFAULT + } + return p.Data +} + +var SearchProductResponse_BaseResp_DEFAULT *base.BaseResp + +func (p *SearchProductResponse) GetBaseResp() (v *base.BaseResp) { + if !p.IsSetBaseResp() { + return SearchProductResponse_BaseResp_DEFAULT + } + return p.BaseResp +} + +var fieldIDToName_SearchProductResponse = map[int16]string{ + 1: "Code", + 2: "Message", + 3: "Data", + 255: "BaseResp", +} + +func (p *SearchProductResponse) IsSetData() bool { + return p.Data != nil +} + +func (p *SearchProductResponse) IsSetBaseResp() bool { + return p.BaseResp != nil +} + +func (p *SearchProductResponse) Read(iprot thrift.TProtocol) (err error) { + var fieldTypeId thrift.TType + var fieldId int16 + var issetCode bool = false + var issetMessage bool = false + + if _, err = iprot.ReadStructBegin(); err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + + switch fieldId { + case 1: + if fieldTypeId == thrift.I32 { + if err = p.ReadField1(iprot); err != nil { + goto ReadFieldError + } + issetCode = true + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + case 2: + if fieldTypeId == thrift.STRING { + if err = p.ReadField2(iprot); err != nil { + goto ReadFieldError + } + issetMessage = true + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + case 3: + if fieldTypeId == thrift.STRUCT { + if err = p.ReadField3(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + case 255: + if fieldTypeId == thrift.STRUCT { + if err = p.ReadField255(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + default: + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + } + if err = iprot.ReadFieldEnd(); err != nil { + goto ReadFieldEndError + } + } + if err = iprot.ReadStructEnd(); err != nil { + goto ReadStructEndError + } + + if !issetCode { + fieldId = 1 + goto RequiredFieldNotSetError + } + + if !issetMessage { + fieldId = 2 + goto RequiredFieldNotSetError + } + return nil +ReadStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_SearchProductResponse[fieldId]), err) +SkipFieldError: + return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) + +ReadFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +RequiredFieldNotSetError: + return thrift.NewTProtocolExceptionWithType(thrift.INVALID_DATA, fmt.Errorf("required field %s is not set", fieldIDToName_SearchProductResponse[fieldId])) +} + +func (p *SearchProductResponse) ReadField1(iprot thrift.TProtocol) error { + + var _field int32 + if v, err := iprot.ReadI32(); err != nil { + return err + } else { + _field = v + } + p.Code = _field + return nil +} +func (p *SearchProductResponse) ReadField2(iprot thrift.TProtocol) error { + + var _field string + if v, err := iprot.ReadString(); err != nil { + return err + } else { + _field = v + } + p.Message = _field + return nil +} +func (p *SearchProductResponse) ReadField3(iprot thrift.TProtocol) error { + _field := NewSearchProductResponseData() + if err := _field.Read(iprot); err != nil { + return err + } + p.Data = _field + return nil +} +func (p *SearchProductResponse) ReadField255(iprot thrift.TProtocol) error { + _field := base.NewBaseResp() + if err := _field.Read(iprot); err != nil { + return err + } + p.BaseResp = _field + return nil +} + +func (p *SearchProductResponse) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("SearchProductResponse"); err != nil { + goto WriteStructBeginError + } + if p != nil { + if err = p.writeField1(oprot); err != nil { + fieldId = 1 + goto WriteFieldError + } + if err = p.writeField2(oprot); err != nil { + fieldId = 2 + goto WriteFieldError + } + if err = p.writeField3(oprot); err != nil { + fieldId = 3 + goto WriteFieldError + } + if err = p.writeField255(oprot); err != nil { + fieldId = 255 + goto WriteFieldError + } + } + if err = oprot.WriteFieldStop(); err != nil { + goto WriteFieldStopError + } + if err = oprot.WriteStructEnd(); err != nil { + goto WriteStructEndError + } + return nil +WriteStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) +WriteFieldError: + return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) +WriteFieldStopError: + return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) +WriteStructEndError: + return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) +} + +func (p *SearchProductResponse) writeField1(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("Code", thrift.I32, 1); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteI32(p.Code); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) +} +func (p *SearchProductResponse) writeField2(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("Message", thrift.STRING, 2); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteString(p.Message); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 2 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 2 end error: ", p), err) +} +func (p *SearchProductResponse) writeField3(oprot thrift.TProtocol) (err error) { + if p.IsSetData() { + if err = oprot.WriteFieldBegin("Data", thrift.STRUCT, 3); err != nil { + goto WriteFieldBeginError + } + if err := p.Data.Write(oprot); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 3 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 3 end error: ", p), err) +} +func (p *SearchProductResponse) writeField255(oprot thrift.TProtocol) (err error) { + if p.IsSetBaseResp() { + if err = oprot.WriteFieldBegin("BaseResp", thrift.STRUCT, 255); err != nil { + goto WriteFieldBeginError + } + if err := p.BaseResp.Write(oprot); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 255 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 255 end error: ", p), err) +} + +func (p *SearchProductResponse) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("SearchProductResponse(%+v)", *p) + +} + +type SearchProductResponseData struct { + Products []*ProductInfo `thrift:"Products,1,optional" form:"products" json:"products,omitempty"` + Total *int32 `thrift:"Total,2,optional" form:"total" json:"total,omitempty"` + HasMore *bool `thrift:"HasMore,3,optional" form:"has_more" json:"has_more,omitempty"` + // Entity count + EntityTotal map[product_common.ProductEntityType]int32 `thrift:"EntityTotal,4,optional" form:"entity_total" json:"entity_total,omitempty"` +} + +func NewSearchProductResponseData() *SearchProductResponseData { + return &SearchProductResponseData{} +} + +func (p *SearchProductResponseData) InitDefault() { +} + +var SearchProductResponseData_Products_DEFAULT []*ProductInfo + +func (p *SearchProductResponseData) GetProducts() (v []*ProductInfo) { + if !p.IsSetProducts() { + return SearchProductResponseData_Products_DEFAULT + } + return p.Products +} + +var SearchProductResponseData_Total_DEFAULT int32 + +func (p *SearchProductResponseData) GetTotal() (v int32) { + if !p.IsSetTotal() { + return SearchProductResponseData_Total_DEFAULT + } + return *p.Total +} + +var SearchProductResponseData_HasMore_DEFAULT bool + +func (p *SearchProductResponseData) GetHasMore() (v bool) { + if !p.IsSetHasMore() { + return SearchProductResponseData_HasMore_DEFAULT + } + return *p.HasMore +} + +var SearchProductResponseData_EntityTotal_DEFAULT map[product_common.ProductEntityType]int32 + +func (p *SearchProductResponseData) GetEntityTotal() (v map[product_common.ProductEntityType]int32) { + if !p.IsSetEntityTotal() { + return SearchProductResponseData_EntityTotal_DEFAULT + } + return p.EntityTotal +} + +var fieldIDToName_SearchProductResponseData = map[int16]string{ + 1: "Products", + 2: "Total", + 3: "HasMore", + 4: "EntityTotal", +} + +func (p *SearchProductResponseData) IsSetProducts() bool { + return p.Products != nil +} + +func (p *SearchProductResponseData) IsSetTotal() bool { + return p.Total != nil +} + +func (p *SearchProductResponseData) IsSetHasMore() bool { + return p.HasMore != nil +} + +func (p *SearchProductResponseData) IsSetEntityTotal() bool { + return p.EntityTotal != nil +} + +func (p *SearchProductResponseData) Read(iprot thrift.TProtocol) (err error) { + var fieldTypeId thrift.TType + var fieldId int16 + + if _, err = iprot.ReadStructBegin(); err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + + switch fieldId { + case 1: + if fieldTypeId == thrift.LIST { + if err = p.ReadField1(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + case 2: + if fieldTypeId == thrift.I32 { + if err = p.ReadField2(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + case 3: + if fieldTypeId == thrift.BOOL { + if err = p.ReadField3(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + case 4: + if fieldTypeId == thrift.MAP { + if err = p.ReadField4(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + default: + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + } + if err = iprot.ReadFieldEnd(); err != nil { + goto ReadFieldEndError + } + } + if err = iprot.ReadStructEnd(); err != nil { + goto ReadStructEndError + } + + return nil +ReadStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_SearchProductResponseData[fieldId]), err) +SkipFieldError: + return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) + +ReadFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *SearchProductResponseData) ReadField1(iprot thrift.TProtocol) error { + _, size, err := iprot.ReadListBegin() + if err != nil { + return err + } + _field := make([]*ProductInfo, 0, size) + values := make([]ProductInfo, size) + for i := 0; i < size; i++ { + _elem := &values[i] + _elem.InitDefault() + + if err := _elem.Read(iprot); err != nil { + return err + } + + _field = append(_field, _elem) + } + if err := iprot.ReadListEnd(); err != nil { + return err + } + p.Products = _field + return nil +} +func (p *SearchProductResponseData) ReadField2(iprot thrift.TProtocol) error { + + var _field *int32 + if v, err := iprot.ReadI32(); err != nil { + return err + } else { + _field = &v + } + p.Total = _field + return nil +} +func (p *SearchProductResponseData) ReadField3(iprot thrift.TProtocol) error { + + var _field *bool + if v, err := iprot.ReadBool(); err != nil { + return err + } else { + _field = &v + } + p.HasMore = _field + return nil +} +func (p *SearchProductResponseData) ReadField4(iprot thrift.TProtocol) error { + _, _, size, err := iprot.ReadMapBegin() + if err != nil { + return err + } + _field := make(map[product_common.ProductEntityType]int32, size) + for i := 0; i < size; i++ { + var _key product_common.ProductEntityType + if v, err := iprot.ReadI32(); err != nil { + return err + } else { + _key = product_common.ProductEntityType(v) + } + + var _val int32 + if v, err := iprot.ReadI32(); err != nil { + return err + } else { + _val = v + } + + _field[_key] = _val + } + if err := iprot.ReadMapEnd(); err != nil { + return err + } + p.EntityTotal = _field + return nil +} + +func (p *SearchProductResponseData) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("SearchProductResponseData"); err != nil { + goto WriteStructBeginError + } + if p != nil { + if err = p.writeField1(oprot); err != nil { + fieldId = 1 + goto WriteFieldError + } + if err = p.writeField2(oprot); err != nil { + fieldId = 2 + goto WriteFieldError + } + if err = p.writeField3(oprot); err != nil { + fieldId = 3 + goto WriteFieldError + } + if err = p.writeField4(oprot); err != nil { + fieldId = 4 + goto WriteFieldError + } + } + if err = oprot.WriteFieldStop(); err != nil { + goto WriteFieldStopError + } + if err = oprot.WriteStructEnd(); err != nil { + goto WriteStructEndError + } + return nil +WriteStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) +WriteFieldError: + return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) +WriteFieldStopError: + return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) +WriteStructEndError: + return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) +} + +func (p *SearchProductResponseData) writeField1(oprot thrift.TProtocol) (err error) { + if p.IsSetProducts() { + if err = oprot.WriteFieldBegin("Products", thrift.LIST, 1); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteListBegin(thrift.STRUCT, len(p.Products)); err != nil { + return err + } + for _, v := range p.Products { + if err := v.Write(oprot); err != nil { + return err + } + } + if err := oprot.WriteListEnd(); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) +} +func (p *SearchProductResponseData) writeField2(oprot thrift.TProtocol) (err error) { + if p.IsSetTotal() { + if err = oprot.WriteFieldBegin("Total", thrift.I32, 2); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteI32(*p.Total); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 2 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 2 end error: ", p), err) +} +func (p *SearchProductResponseData) writeField3(oprot thrift.TProtocol) (err error) { + if p.IsSetHasMore() { + if err = oprot.WriteFieldBegin("HasMore", thrift.BOOL, 3); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteBool(*p.HasMore); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 3 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 3 end error: ", p), err) +} +func (p *SearchProductResponseData) writeField4(oprot thrift.TProtocol) (err error) { + if p.IsSetEntityTotal() { + if err = oprot.WriteFieldBegin("EntityTotal", thrift.MAP, 4); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteMapBegin(thrift.I32, thrift.I32, len(p.EntityTotal)); err != nil { + return err + } + for k, v := range p.EntityTotal { + if err := oprot.WriteI32(int32(k)); err != nil { + return err + } + if err := oprot.WriteI32(v); err != nil { + return err + } + } + if err := oprot.WriteMapEnd(); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 4 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 4 end error: ", p), err) +} + +func (p *SearchProductResponseData) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("SearchProductResponseData(%+v)", *p) + +} + +type SearchSuggestResponse struct { + Code int32 `thrift:"Code,1,required" form:"code,required" json:"code,required"` + Message string `thrift:"Message,2,required" form:"message,required" json:"message,required"` + Data *SearchSuggestResponseData `thrift:"Data,3,optional" form:"data" json:"data,omitempty"` + BaseResp *base.BaseResp `thrift:"BaseResp,255,optional" form:"BaseResp" json:"BaseResp,omitempty" query:"BaseResp"` +} + +func NewSearchSuggestResponse() *SearchSuggestResponse { + return &SearchSuggestResponse{} +} + +func (p *SearchSuggestResponse) InitDefault() { +} + +func (p *SearchSuggestResponse) GetCode() (v int32) { + return p.Code +} + +func (p *SearchSuggestResponse) GetMessage() (v string) { + return p.Message +} + +var SearchSuggestResponse_Data_DEFAULT *SearchSuggestResponseData + +func (p *SearchSuggestResponse) GetData() (v *SearchSuggestResponseData) { + if !p.IsSetData() { + return SearchSuggestResponse_Data_DEFAULT + } + return p.Data +} + +var SearchSuggestResponse_BaseResp_DEFAULT *base.BaseResp + +func (p *SearchSuggestResponse) GetBaseResp() (v *base.BaseResp) { + if !p.IsSetBaseResp() { + return SearchSuggestResponse_BaseResp_DEFAULT + } + return p.BaseResp +} + +var fieldIDToName_SearchSuggestResponse = map[int16]string{ + 1: "Code", + 2: "Message", + 3: "Data", + 255: "BaseResp", +} + +func (p *SearchSuggestResponse) IsSetData() bool { + return p.Data != nil +} + +func (p *SearchSuggestResponse) IsSetBaseResp() bool { + return p.BaseResp != nil +} + +func (p *SearchSuggestResponse) Read(iprot thrift.TProtocol) (err error) { + var fieldTypeId thrift.TType + var fieldId int16 + var issetCode bool = false + var issetMessage bool = false + + if _, err = iprot.ReadStructBegin(); err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + + switch fieldId { + case 1: + if fieldTypeId == thrift.I32 { + if err = p.ReadField1(iprot); err != nil { + goto ReadFieldError + } + issetCode = true + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + case 2: + if fieldTypeId == thrift.STRING { + if err = p.ReadField2(iprot); err != nil { + goto ReadFieldError + } + issetMessage = true + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + case 3: + if fieldTypeId == thrift.STRUCT { + if err = p.ReadField3(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + case 255: + if fieldTypeId == thrift.STRUCT { + if err = p.ReadField255(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + default: + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + } + if err = iprot.ReadFieldEnd(); err != nil { + goto ReadFieldEndError + } + } + if err = iprot.ReadStructEnd(); err != nil { + goto ReadStructEndError + } + + if !issetCode { + fieldId = 1 + goto RequiredFieldNotSetError + } + + if !issetMessage { + fieldId = 2 + goto RequiredFieldNotSetError + } + return nil +ReadStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_SearchSuggestResponse[fieldId]), err) +SkipFieldError: + return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) + +ReadFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +RequiredFieldNotSetError: + return thrift.NewTProtocolExceptionWithType(thrift.INVALID_DATA, fmt.Errorf("required field %s is not set", fieldIDToName_SearchSuggestResponse[fieldId])) +} + +func (p *SearchSuggestResponse) ReadField1(iprot thrift.TProtocol) error { + + var _field int32 + if v, err := iprot.ReadI32(); err != nil { + return err + } else { + _field = v + } + p.Code = _field + return nil +} +func (p *SearchSuggestResponse) ReadField2(iprot thrift.TProtocol) error { + + var _field string + if v, err := iprot.ReadString(); err != nil { + return err + } else { + _field = v + } + p.Message = _field + return nil +} +func (p *SearchSuggestResponse) ReadField3(iprot thrift.TProtocol) error { + _field := NewSearchSuggestResponseData() + if err := _field.Read(iprot); err != nil { + return err + } + p.Data = _field + return nil +} +func (p *SearchSuggestResponse) ReadField255(iprot thrift.TProtocol) error { + _field := base.NewBaseResp() + if err := _field.Read(iprot); err != nil { + return err + } + p.BaseResp = _field + return nil +} + +func (p *SearchSuggestResponse) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("SearchSuggestResponse"); err != nil { + goto WriteStructBeginError + } + if p != nil { + if err = p.writeField1(oprot); err != nil { + fieldId = 1 + goto WriteFieldError + } + if err = p.writeField2(oprot); err != nil { + fieldId = 2 + goto WriteFieldError + } + if err = p.writeField3(oprot); err != nil { + fieldId = 3 + goto WriteFieldError + } + if err = p.writeField255(oprot); err != nil { + fieldId = 255 + goto WriteFieldError + } + } + if err = oprot.WriteFieldStop(); err != nil { + goto WriteFieldStopError + } + if err = oprot.WriteStructEnd(); err != nil { + goto WriteStructEndError + } + return nil +WriteStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) +WriteFieldError: + return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) +WriteFieldStopError: + return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) +WriteStructEndError: + return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) +} + +func (p *SearchSuggestResponse) writeField1(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("Code", thrift.I32, 1); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteI32(p.Code); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) +} +func (p *SearchSuggestResponse) writeField2(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("Message", thrift.STRING, 2); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteString(p.Message); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 2 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 2 end error: ", p), err) +} +func (p *SearchSuggestResponse) writeField3(oprot thrift.TProtocol) (err error) { + if p.IsSetData() { + if err = oprot.WriteFieldBegin("Data", thrift.STRUCT, 3); err != nil { + goto WriteFieldBeginError + } + if err := p.Data.Write(oprot); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 3 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 3 end error: ", p), err) +} +func (p *SearchSuggestResponse) writeField255(oprot thrift.TProtocol) (err error) { + if p.IsSetBaseResp() { + if err = oprot.WriteFieldBegin("BaseResp", thrift.STRUCT, 255); err != nil { + goto WriteFieldBeginError + } + if err := p.BaseResp.Write(oprot); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 255 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 255 end error: ", p), err) +} + +func (p *SearchSuggestResponse) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("SearchSuggestResponse(%+v)", *p) + +} + +type SearchSuggestResponseData struct { + // Deprecated + Suggestions []*ProductMetaInfo `thrift:"Suggestions,1,optional" form:"suggestions" json:"suggestions,omitempty"` + HasMore *bool `thrift:"HasMore,2,optional" form:"has_more" json:"has_more,omitempty"` + SuggestionV2 []*ProductInfo `thrift:"SuggestionV2,3,optional" form:"suggestion_v2" json:"suggestion_v2,omitempty"` +} + +func NewSearchSuggestResponseData() *SearchSuggestResponseData { + return &SearchSuggestResponseData{} +} + +func (p *SearchSuggestResponseData) InitDefault() { +} + +var SearchSuggestResponseData_Suggestions_DEFAULT []*ProductMetaInfo + +func (p *SearchSuggestResponseData) GetSuggestions() (v []*ProductMetaInfo) { + if !p.IsSetSuggestions() { + return SearchSuggestResponseData_Suggestions_DEFAULT + } + return p.Suggestions +} + +var SearchSuggestResponseData_HasMore_DEFAULT bool + +func (p *SearchSuggestResponseData) GetHasMore() (v bool) { + if !p.IsSetHasMore() { + return SearchSuggestResponseData_HasMore_DEFAULT + } + return *p.HasMore +} + +var SearchSuggestResponseData_SuggestionV2_DEFAULT []*ProductInfo + +func (p *SearchSuggestResponseData) GetSuggestionV2() (v []*ProductInfo) { + if !p.IsSetSuggestionV2() { + return SearchSuggestResponseData_SuggestionV2_DEFAULT + } + return p.SuggestionV2 +} + +var fieldIDToName_SearchSuggestResponseData = map[int16]string{ + 1: "Suggestions", + 2: "HasMore", + 3: "SuggestionV2", +} + +func (p *SearchSuggestResponseData) IsSetSuggestions() bool { + return p.Suggestions != nil +} + +func (p *SearchSuggestResponseData) IsSetHasMore() bool { + return p.HasMore != nil +} + +func (p *SearchSuggestResponseData) IsSetSuggestionV2() bool { + return p.SuggestionV2 != nil +} + +func (p *SearchSuggestResponseData) Read(iprot thrift.TProtocol) (err error) { + var fieldTypeId thrift.TType + var fieldId int16 + + if _, err = iprot.ReadStructBegin(); err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + + switch fieldId { + case 1: + if fieldTypeId == thrift.LIST { + if err = p.ReadField1(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + case 2: + if fieldTypeId == thrift.BOOL { + if err = p.ReadField2(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + case 3: + if fieldTypeId == thrift.LIST { + if err = p.ReadField3(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + default: + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + } + if err = iprot.ReadFieldEnd(); err != nil { + goto ReadFieldEndError + } + } + if err = iprot.ReadStructEnd(); err != nil { + goto ReadStructEndError + } + + return nil +ReadStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_SearchSuggestResponseData[fieldId]), err) +SkipFieldError: + return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) + +ReadFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *SearchSuggestResponseData) ReadField1(iprot thrift.TProtocol) error { + _, size, err := iprot.ReadListBegin() + if err != nil { + return err + } + _field := make([]*ProductMetaInfo, 0, size) + values := make([]ProductMetaInfo, size) + for i := 0; i < size; i++ { + _elem := &values[i] + _elem.InitDefault() + + if err := _elem.Read(iprot); err != nil { + return err + } + + _field = append(_field, _elem) + } + if err := iprot.ReadListEnd(); err != nil { + return err + } + p.Suggestions = _field + return nil +} +func (p *SearchSuggestResponseData) ReadField2(iprot thrift.TProtocol) error { + + var _field *bool + if v, err := iprot.ReadBool(); err != nil { + return err + } else { + _field = &v + } + p.HasMore = _field + return nil +} +func (p *SearchSuggestResponseData) ReadField3(iprot thrift.TProtocol) error { + _, size, err := iprot.ReadListBegin() + if err != nil { + return err + } + _field := make([]*ProductInfo, 0, size) + values := make([]ProductInfo, size) + for i := 0; i < size; i++ { + _elem := &values[i] + _elem.InitDefault() + + if err := _elem.Read(iprot); err != nil { + return err + } + + _field = append(_field, _elem) + } + if err := iprot.ReadListEnd(); err != nil { + return err + } + p.SuggestionV2 = _field + return nil +} + +func (p *SearchSuggestResponseData) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("SearchSuggestResponseData"); err != nil { + goto WriteStructBeginError + } + if p != nil { + if err = p.writeField1(oprot); err != nil { + fieldId = 1 + goto WriteFieldError + } + if err = p.writeField2(oprot); err != nil { + fieldId = 2 + goto WriteFieldError + } + if err = p.writeField3(oprot); err != nil { + fieldId = 3 + goto WriteFieldError + } + } + if err = oprot.WriteFieldStop(); err != nil { + goto WriteFieldStopError + } + if err = oprot.WriteStructEnd(); err != nil { + goto WriteStructEndError + } + return nil +WriteStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) +WriteFieldError: + return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) +WriteFieldStopError: + return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) +WriteStructEndError: + return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) +} + +func (p *SearchSuggestResponseData) writeField1(oprot thrift.TProtocol) (err error) { + if p.IsSetSuggestions() { + if err = oprot.WriteFieldBegin("Suggestions", thrift.LIST, 1); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteListBegin(thrift.STRUCT, len(p.Suggestions)); err != nil { + return err + } + for _, v := range p.Suggestions { + if err := v.Write(oprot); err != nil { + return err + } + } + if err := oprot.WriteListEnd(); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) +} +func (p *SearchSuggestResponseData) writeField2(oprot thrift.TProtocol) (err error) { + if p.IsSetHasMore() { + if err = oprot.WriteFieldBegin("HasMore", thrift.BOOL, 2); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteBool(*p.HasMore); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 2 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 2 end error: ", p), err) +} +func (p *SearchSuggestResponseData) writeField3(oprot thrift.TProtocol) (err error) { + if p.IsSetSuggestionV2() { + if err = oprot.WriteFieldBegin("SuggestionV2", thrift.LIST, 3); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteListBegin(thrift.STRUCT, len(p.SuggestionV2)); err != nil { + return err + } + for _, v := range p.SuggestionV2 { + if err := v.Write(oprot); err != nil { + return err + } + } + if err := oprot.WriteListEnd(); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 3 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 3 end error: ", p), err) +} + +func (p *SearchSuggestResponseData) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("SearchSuggestResponseData(%+v)", *p) + +} + +type SearchSuggestRequest struct { + Keyword *string `thrift:"Keyword,1,optional" json:"Keyword,omitempty" query:"keyword"` + // Optional, defaults to bot recommendation if not provided + EntityType *product_common.ProductEntityType `thrift:"EntityType,2,optional" json:"EntityType,omitempty" query:"entity_type"` + PageNum *int32 `thrift:"PageNum,3,optional" json:"PageNum,omitempty" query:"page_num"` + PageSize *int32 `thrift:"PageSize,4,optional" json:"PageSize,omitempty" query:"page_size"` + // Product type list, use this parameter first, then EntityType + EntityTypes *string `thrift:"EntityTypes,5,optional" json:"EntityTypes,omitempty" query:"entity_types"` + Base *base.Base `thrift:"Base,255,optional" form:"Base" json:"Base,omitempty" query:"Base"` +} + +func NewSearchSuggestRequest() *SearchSuggestRequest { + return &SearchSuggestRequest{} +} + +func (p *SearchSuggestRequest) InitDefault() { +} + +var SearchSuggestRequest_Keyword_DEFAULT string + +func (p *SearchSuggestRequest) GetKeyword() (v string) { + if !p.IsSetKeyword() { + return SearchSuggestRequest_Keyword_DEFAULT + } + return *p.Keyword +} + +var SearchSuggestRequest_EntityType_DEFAULT product_common.ProductEntityType + +func (p *SearchSuggestRequest) GetEntityType() (v product_common.ProductEntityType) { + if !p.IsSetEntityType() { + return SearchSuggestRequest_EntityType_DEFAULT + } + return *p.EntityType +} + +var SearchSuggestRequest_PageNum_DEFAULT int32 + +func (p *SearchSuggestRequest) GetPageNum() (v int32) { + if !p.IsSetPageNum() { + return SearchSuggestRequest_PageNum_DEFAULT + } + return *p.PageNum +} + +var SearchSuggestRequest_PageSize_DEFAULT int32 + +func (p *SearchSuggestRequest) GetPageSize() (v int32) { + if !p.IsSetPageSize() { + return SearchSuggestRequest_PageSize_DEFAULT + } + return *p.PageSize +} + +var SearchSuggestRequest_EntityTypes_DEFAULT string + +func (p *SearchSuggestRequest) GetEntityTypes() (v string) { + if !p.IsSetEntityTypes() { + return SearchSuggestRequest_EntityTypes_DEFAULT + } + return *p.EntityTypes +} + +var SearchSuggestRequest_Base_DEFAULT *base.Base + +func (p *SearchSuggestRequest) GetBase() (v *base.Base) { + if !p.IsSetBase() { + return SearchSuggestRequest_Base_DEFAULT + } + return p.Base +} + +var fieldIDToName_SearchSuggestRequest = map[int16]string{ + 1: "Keyword", + 2: "EntityType", + 3: "PageNum", + 4: "PageSize", + 5: "EntityTypes", + 255: "Base", +} + +func (p *SearchSuggestRequest) IsSetKeyword() bool { + return p.Keyword != nil +} + +func (p *SearchSuggestRequest) IsSetEntityType() bool { + return p.EntityType != nil +} + +func (p *SearchSuggestRequest) IsSetPageNum() bool { + return p.PageNum != nil +} + +func (p *SearchSuggestRequest) IsSetPageSize() bool { + return p.PageSize != nil +} + +func (p *SearchSuggestRequest) IsSetEntityTypes() bool { + return p.EntityTypes != nil +} + +func (p *SearchSuggestRequest) IsSetBase() bool { + return p.Base != nil +} + +func (p *SearchSuggestRequest) Read(iprot thrift.TProtocol) (err error) { + var fieldTypeId thrift.TType + var fieldId int16 + + if _, err = iprot.ReadStructBegin(); err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + + switch fieldId { + case 1: + if fieldTypeId == thrift.STRING { + if err = p.ReadField1(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + case 2: + if fieldTypeId == thrift.I32 { + if err = p.ReadField2(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + case 3: + if fieldTypeId == thrift.I32 { + if err = p.ReadField3(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + case 4: + if fieldTypeId == thrift.I32 { + if err = p.ReadField4(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + case 5: + if fieldTypeId == thrift.STRING { + if err = p.ReadField5(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + case 255: + if fieldTypeId == thrift.STRUCT { + if err = p.ReadField255(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + default: + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + } + if err = iprot.ReadFieldEnd(); err != nil { + goto ReadFieldEndError + } + } + if err = iprot.ReadStructEnd(); err != nil { + goto ReadStructEndError + } + + return nil +ReadStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_SearchSuggestRequest[fieldId]), err) +SkipFieldError: + return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) + +ReadFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *SearchSuggestRequest) ReadField1(iprot thrift.TProtocol) error { + + var _field *string + if v, err := iprot.ReadString(); err != nil { + return err + } else { + _field = &v + } + p.Keyword = _field + return nil +} +func (p *SearchSuggestRequest) ReadField2(iprot thrift.TProtocol) error { + + var _field *product_common.ProductEntityType + if v, err := iprot.ReadI32(); err != nil { + return err + } else { + tmp := product_common.ProductEntityType(v) + _field = &tmp + } + p.EntityType = _field + return nil +} +func (p *SearchSuggestRequest) ReadField3(iprot thrift.TProtocol) error { + + var _field *int32 + if v, err := iprot.ReadI32(); err != nil { + return err + } else { + _field = &v + } + p.PageNum = _field + return nil +} +func (p *SearchSuggestRequest) ReadField4(iprot thrift.TProtocol) error { + + var _field *int32 + if v, err := iprot.ReadI32(); err != nil { + return err + } else { + _field = &v + } + p.PageSize = _field + return nil +} +func (p *SearchSuggestRequest) ReadField5(iprot thrift.TProtocol) error { + + var _field *string + if v, err := iprot.ReadString(); err != nil { + return err + } else { + _field = &v + } + p.EntityTypes = _field + return nil +} +func (p *SearchSuggestRequest) ReadField255(iprot thrift.TProtocol) error { + _field := base.NewBase() + if err := _field.Read(iprot); err != nil { + return err + } + p.Base = _field + return nil +} + +func (p *SearchSuggestRequest) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("SearchSuggestRequest"); err != nil { + goto WriteStructBeginError + } + if p != nil { + if err = p.writeField1(oprot); err != nil { + fieldId = 1 + goto WriteFieldError + } + if err = p.writeField2(oprot); err != nil { + fieldId = 2 + goto WriteFieldError + } + if err = p.writeField3(oprot); err != nil { + fieldId = 3 + goto WriteFieldError + } + if err = p.writeField4(oprot); err != nil { + fieldId = 4 + goto WriteFieldError + } + if err = p.writeField5(oprot); err != nil { + fieldId = 5 + goto WriteFieldError + } + if err = p.writeField255(oprot); err != nil { + fieldId = 255 + goto WriteFieldError + } + } + if err = oprot.WriteFieldStop(); err != nil { + goto WriteFieldStopError + } + if err = oprot.WriteStructEnd(); err != nil { + goto WriteStructEndError + } + return nil +WriteStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) +WriteFieldError: + return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) +WriteFieldStopError: + return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) +WriteStructEndError: + return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) +} + +func (p *SearchSuggestRequest) writeField1(oprot thrift.TProtocol) (err error) { + if p.IsSetKeyword() { + if err = oprot.WriteFieldBegin("Keyword", thrift.STRING, 1); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteString(*p.Keyword); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) +} +func (p *SearchSuggestRequest) writeField2(oprot thrift.TProtocol) (err error) { + if p.IsSetEntityType() { + if err = oprot.WriteFieldBegin("EntityType", thrift.I32, 2); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteI32(int32(*p.EntityType)); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 2 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 2 end error: ", p), err) +} +func (p *SearchSuggestRequest) writeField3(oprot thrift.TProtocol) (err error) { + if p.IsSetPageNum() { + if err = oprot.WriteFieldBegin("PageNum", thrift.I32, 3); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteI32(*p.PageNum); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 3 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 3 end error: ", p), err) +} +func (p *SearchSuggestRequest) writeField4(oprot thrift.TProtocol) (err error) { + if p.IsSetPageSize() { + if err = oprot.WriteFieldBegin("PageSize", thrift.I32, 4); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteI32(*p.PageSize); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 4 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 4 end error: ", p), err) +} +func (p *SearchSuggestRequest) writeField5(oprot thrift.TProtocol) (err error) { + if p.IsSetEntityTypes() { + if err = oprot.WriteFieldBegin("EntityTypes", thrift.STRING, 5); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteString(*p.EntityTypes); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 5 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 5 end error: ", p), err) +} +func (p *SearchSuggestRequest) writeField255(oprot thrift.TProtocol) (err error) { + if p.IsSetBase() { + if err = oprot.WriteFieldBegin("Base", thrift.STRUCT, 255); err != nil { + goto WriteFieldBeginError + } + if err := p.Base.Write(oprot); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 255 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 255 end error: ", p), err) +} + +func (p *SearchSuggestRequest) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("SearchSuggestRequest(%+v)", *p) + +} + type FavoriteProductResponse struct { Code int32 `thrift:"Code,1,required" form:"code,required" json:"code,required"` Message string `thrift:"Message,2,required" form:"message,required" json:"message,required"` @@ -5750,7 +9228,8 @@ type PluginExtraInfo struct { Connectors []*PluginConnectorInfo `thrift:"Connectors,15" form:"connectors" json:"connectors"` PluginType *product_common.PluginType `thrift:"PluginType,16,optional" form:"plugin_type" json:"plugin_type,omitempty"` // for opencoze - AuthMode *PluginAuthMode `thrift:"AuthMode,50,optional" form:"auth_mode" json:"auth_mode,omitempty"` + AuthMode *PluginAuthMode `thrift:"AuthMode,50,optional" form:"auth_mode" json:"auth_mode,omitempty"` + JumpSaasURL *string `thrift:"JumpSaasURL,51,optional" form:"jump_saas_url" json:"jump_saas_url,omitempty"` } func NewPluginExtraInfo() *PluginExtraInfo { @@ -5883,6 +9362,15 @@ func (p *PluginExtraInfo) GetAuthMode() (v PluginAuthMode) { return *p.AuthMode } +var PluginExtraInfo_JumpSaasURL_DEFAULT string + +func (p *PluginExtraInfo) GetJumpSaasURL() (v string) { + if !p.IsSetJumpSaasURL() { + return PluginExtraInfo_JumpSaasURL_DEFAULT + } + return *p.JumpSaasURL +} + var fieldIDToName_PluginExtraInfo = map[int16]string{ 1: "Tools", 2: "TotalAPICount", @@ -5901,6 +9389,7 @@ var fieldIDToName_PluginExtraInfo = map[int16]string{ 15: "Connectors", 16: "PluginType", 50: "AuthMode", + 51: "JumpSaasURL", } func (p *PluginExtraInfo) IsSetTools() bool { @@ -5947,6 +9436,10 @@ func (p *PluginExtraInfo) IsSetAuthMode() bool { return p.AuthMode != nil } +func (p *PluginExtraInfo) IsSetJumpSaasURL() bool { + return p.JumpSaasURL != nil +} + func (p *PluginExtraInfo) Read(iprot thrift.TProtocol) (err error) { var fieldTypeId thrift.TType var fieldId int16 @@ -6101,6 +9594,14 @@ func (p *PluginExtraInfo) Read(iprot thrift.TProtocol) (err error) { } else if err = iprot.Skip(fieldTypeId); err != nil { goto SkipFieldError } + case 51: + if fieldTypeId == thrift.STRING { + if err = p.ReadField51(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } default: if err = iprot.Skip(fieldTypeId); err != nil { goto SkipFieldError @@ -6343,6 +9844,17 @@ func (p *PluginExtraInfo) ReadField50(iprot thrift.TProtocol) error { p.AuthMode = _field return nil } +func (p *PluginExtraInfo) ReadField51(iprot thrift.TProtocol) error { + + var _field *string + if v, err := iprot.ReadString(); err != nil { + return err + } else { + _field = &v + } + p.JumpSaasURL = _field + return nil +} func (p *PluginExtraInfo) Write(oprot thrift.TProtocol) (err error) { var fieldId int16 @@ -6418,6 +9930,10 @@ func (p *PluginExtraInfo) Write(oprot thrift.TProtocol) (err error) { fieldId = 50 goto WriteFieldError } + if err = p.writeField51(oprot); err != nil { + fieldId = 51 + goto WriteFieldError + } } if err = oprot.WriteFieldStop(); err != nil { goto WriteFieldStopError @@ -6746,6 +10262,24 @@ WriteFieldBeginError: WriteFieldEndError: return thrift.PrependError(fmt.Sprintf("%T write field 50 end error: ", p), err) } +func (p *PluginExtraInfo) writeField51(oprot thrift.TProtocol) (err error) { + if p.IsSetJumpSaasURL() { + if err = oprot.WriteFieldBegin("JumpSaasURL", thrift.STRING, 51); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteString(*p.JumpSaasURL); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 51 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 51 end error: ", p), err) +} func (p *PluginExtraInfo) String() string { if p == nil { @@ -23543,6 +27077,2678 @@ func (p *DuplicateProductData) String() string { } +type GetProductCategoryListRequest struct { + EntityType product_common.ProductEntityType `thrift:"EntityType,1" json:"EntityType" query:"entity_type"` + // When listing, need to get the full category list to distinguish between listing and homepage scenarios + NeedEmptyCategory *bool `thrift:"NeedEmptyCategory,2,optional" json:"NeedEmptyCategory,omitempty" query:"need_empty_category"` + Lang *string `thrift:"Lang,3,optional" json:"Lang,omitempty" query:"lang"` + Base *base.Base `thrift:"Base,255,optional" form:"Base" json:"Base,omitempty" query:"Base"` +} + +func NewGetProductCategoryListRequest() *GetProductCategoryListRequest { + return &GetProductCategoryListRequest{} +} + +func (p *GetProductCategoryListRequest) InitDefault() { +} + +func (p *GetProductCategoryListRequest) GetEntityType() (v product_common.ProductEntityType) { + return p.EntityType +} + +var GetProductCategoryListRequest_NeedEmptyCategory_DEFAULT bool + +func (p *GetProductCategoryListRequest) GetNeedEmptyCategory() (v bool) { + if !p.IsSetNeedEmptyCategory() { + return GetProductCategoryListRequest_NeedEmptyCategory_DEFAULT + } + return *p.NeedEmptyCategory +} + +var GetProductCategoryListRequest_Lang_DEFAULT string + +func (p *GetProductCategoryListRequest) GetLang() (v string) { + if !p.IsSetLang() { + return GetProductCategoryListRequest_Lang_DEFAULT + } + return *p.Lang +} + +var GetProductCategoryListRequest_Base_DEFAULT *base.Base + +func (p *GetProductCategoryListRequest) GetBase() (v *base.Base) { + if !p.IsSetBase() { + return GetProductCategoryListRequest_Base_DEFAULT + } + return p.Base +} + +var fieldIDToName_GetProductCategoryListRequest = map[int16]string{ + 1: "EntityType", + 2: "NeedEmptyCategory", + 3: "Lang", + 255: "Base", +} + +func (p *GetProductCategoryListRequest) IsSetNeedEmptyCategory() bool { + return p.NeedEmptyCategory != nil +} + +func (p *GetProductCategoryListRequest) IsSetLang() bool { + return p.Lang != nil +} + +func (p *GetProductCategoryListRequest) IsSetBase() bool { + return p.Base != nil +} + +func (p *GetProductCategoryListRequest) Read(iprot thrift.TProtocol) (err error) { + var fieldTypeId thrift.TType + var fieldId int16 + + if _, err = iprot.ReadStructBegin(); err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + + switch fieldId { + case 1: + if fieldTypeId == thrift.I32 { + if err = p.ReadField1(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + case 2: + if fieldTypeId == thrift.BOOL { + if err = p.ReadField2(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + case 3: + if fieldTypeId == thrift.STRING { + if err = p.ReadField3(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + case 255: + if fieldTypeId == thrift.STRUCT { + if err = p.ReadField255(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + default: + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + } + if err = iprot.ReadFieldEnd(); err != nil { + goto ReadFieldEndError + } + } + if err = iprot.ReadStructEnd(); err != nil { + goto ReadStructEndError + } + + return nil +ReadStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_GetProductCategoryListRequest[fieldId]), err) +SkipFieldError: + return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) + +ReadFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *GetProductCategoryListRequest) ReadField1(iprot thrift.TProtocol) error { + + var _field product_common.ProductEntityType + if v, err := iprot.ReadI32(); err != nil { + return err + } else { + _field = product_common.ProductEntityType(v) + } + p.EntityType = _field + return nil +} +func (p *GetProductCategoryListRequest) ReadField2(iprot thrift.TProtocol) error { + + var _field *bool + if v, err := iprot.ReadBool(); err != nil { + return err + } else { + _field = &v + } + p.NeedEmptyCategory = _field + return nil +} +func (p *GetProductCategoryListRequest) ReadField3(iprot thrift.TProtocol) error { + + var _field *string + if v, err := iprot.ReadString(); err != nil { + return err + } else { + _field = &v + } + p.Lang = _field + return nil +} +func (p *GetProductCategoryListRequest) ReadField255(iprot thrift.TProtocol) error { + _field := base.NewBase() + if err := _field.Read(iprot); err != nil { + return err + } + p.Base = _field + return nil +} + +func (p *GetProductCategoryListRequest) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("GetProductCategoryListRequest"); err != nil { + goto WriteStructBeginError + } + if p != nil { + if err = p.writeField1(oprot); err != nil { + fieldId = 1 + goto WriteFieldError + } + if err = p.writeField2(oprot); err != nil { + fieldId = 2 + goto WriteFieldError + } + if err = p.writeField3(oprot); err != nil { + fieldId = 3 + goto WriteFieldError + } + if err = p.writeField255(oprot); err != nil { + fieldId = 255 + goto WriteFieldError + } + } + if err = oprot.WriteFieldStop(); err != nil { + goto WriteFieldStopError + } + if err = oprot.WriteStructEnd(); err != nil { + goto WriteStructEndError + } + return nil +WriteStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) +WriteFieldError: + return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) +WriteFieldStopError: + return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) +WriteStructEndError: + return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) +} + +func (p *GetProductCategoryListRequest) writeField1(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("EntityType", thrift.I32, 1); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteI32(int32(p.EntityType)); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) +} +func (p *GetProductCategoryListRequest) writeField2(oprot thrift.TProtocol) (err error) { + if p.IsSetNeedEmptyCategory() { + if err = oprot.WriteFieldBegin("NeedEmptyCategory", thrift.BOOL, 2); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteBool(*p.NeedEmptyCategory); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 2 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 2 end error: ", p), err) +} +func (p *GetProductCategoryListRequest) writeField3(oprot thrift.TProtocol) (err error) { + if p.IsSetLang() { + if err = oprot.WriteFieldBegin("Lang", thrift.STRING, 3); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteString(*p.Lang); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 3 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 3 end error: ", p), err) +} +func (p *GetProductCategoryListRequest) writeField255(oprot thrift.TProtocol) (err error) { + if p.IsSetBase() { + if err = oprot.WriteFieldBegin("Base", thrift.STRUCT, 255); err != nil { + goto WriteFieldBeginError + } + if err := p.Base.Write(oprot); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 255 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 255 end error: ", p), err) +} + +func (p *GetProductCategoryListRequest) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("GetProductCategoryListRequest(%+v)", *p) + +} + +type GetProductCategoryListData struct { + EntityType product_common.ProductEntityType `thrift:"EntityType,1,required" form:"entity_type,required" json:"entity_type,required"` + Categories []*ProductCategory `thrift:"Categories,2,optional" form:"categories" json:"categories,omitempty"` +} + +func NewGetProductCategoryListData() *GetProductCategoryListData { + return &GetProductCategoryListData{} +} + +func (p *GetProductCategoryListData) InitDefault() { +} + +func (p *GetProductCategoryListData) GetEntityType() (v product_common.ProductEntityType) { + return p.EntityType +} + +var GetProductCategoryListData_Categories_DEFAULT []*ProductCategory + +func (p *GetProductCategoryListData) GetCategories() (v []*ProductCategory) { + if !p.IsSetCategories() { + return GetProductCategoryListData_Categories_DEFAULT + } + return p.Categories +} + +var fieldIDToName_GetProductCategoryListData = map[int16]string{ + 1: "EntityType", + 2: "Categories", +} + +func (p *GetProductCategoryListData) IsSetCategories() bool { + return p.Categories != nil +} + +func (p *GetProductCategoryListData) Read(iprot thrift.TProtocol) (err error) { + var fieldTypeId thrift.TType + var fieldId int16 + var issetEntityType bool = false + + if _, err = iprot.ReadStructBegin(); err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + + switch fieldId { + case 1: + if fieldTypeId == thrift.I32 { + if err = p.ReadField1(iprot); err != nil { + goto ReadFieldError + } + issetEntityType = true + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + case 2: + if fieldTypeId == thrift.LIST { + if err = p.ReadField2(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + default: + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + } + if err = iprot.ReadFieldEnd(); err != nil { + goto ReadFieldEndError + } + } + if err = iprot.ReadStructEnd(); err != nil { + goto ReadStructEndError + } + + if !issetEntityType { + fieldId = 1 + goto RequiredFieldNotSetError + } + return nil +ReadStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_GetProductCategoryListData[fieldId]), err) +SkipFieldError: + return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) + +ReadFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +RequiredFieldNotSetError: + return thrift.NewTProtocolExceptionWithType(thrift.INVALID_DATA, fmt.Errorf("required field %s is not set", fieldIDToName_GetProductCategoryListData[fieldId])) +} + +func (p *GetProductCategoryListData) ReadField1(iprot thrift.TProtocol) error { + + var _field product_common.ProductEntityType + if v, err := iprot.ReadI32(); err != nil { + return err + } else { + _field = product_common.ProductEntityType(v) + } + p.EntityType = _field + return nil +} +func (p *GetProductCategoryListData) ReadField2(iprot thrift.TProtocol) error { + _, size, err := iprot.ReadListBegin() + if err != nil { + return err + } + _field := make([]*ProductCategory, 0, size) + values := make([]ProductCategory, size) + for i := 0; i < size; i++ { + _elem := &values[i] + _elem.InitDefault() + + if err := _elem.Read(iprot); err != nil { + return err + } + + _field = append(_field, _elem) + } + if err := iprot.ReadListEnd(); err != nil { + return err + } + p.Categories = _field + return nil +} + +func (p *GetProductCategoryListData) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("GetProductCategoryListData"); err != nil { + goto WriteStructBeginError + } + if p != nil { + if err = p.writeField1(oprot); err != nil { + fieldId = 1 + goto WriteFieldError + } + if err = p.writeField2(oprot); err != nil { + fieldId = 2 + goto WriteFieldError + } + } + if err = oprot.WriteFieldStop(); err != nil { + goto WriteFieldStopError + } + if err = oprot.WriteStructEnd(); err != nil { + goto WriteStructEndError + } + return nil +WriteStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) +WriteFieldError: + return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) +WriteFieldStopError: + return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) +WriteStructEndError: + return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) +} + +func (p *GetProductCategoryListData) writeField1(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("EntityType", thrift.I32, 1); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteI32(int32(p.EntityType)); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) +} +func (p *GetProductCategoryListData) writeField2(oprot thrift.TProtocol) (err error) { + if p.IsSetCategories() { + if err = oprot.WriteFieldBegin("Categories", thrift.LIST, 2); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteListBegin(thrift.STRUCT, len(p.Categories)); err != nil { + return err + } + for _, v := range p.Categories { + if err := v.Write(oprot); err != nil { + return err + } + } + if err := oprot.WriteListEnd(); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 2 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 2 end error: ", p), err) +} + +func (p *GetProductCategoryListData) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("GetProductCategoryListData(%+v)", *p) + +} + +type GetProductCategoryListResponse struct { + Code int32 `thrift:"Code,1,required" form:"code,required" json:"code,required"` + Message string `thrift:"Message,2,required" form:"message,required" json:"message,required"` + Data *GetProductCategoryListData `thrift:"Data,3" form:"data" json:"data"` + BaseResp *base.BaseResp `thrift:"BaseResp,255,optional" form:"BaseResp" json:"BaseResp,omitempty" query:"BaseResp"` +} + +func NewGetProductCategoryListResponse() *GetProductCategoryListResponse { + return &GetProductCategoryListResponse{} +} + +func (p *GetProductCategoryListResponse) InitDefault() { +} + +func (p *GetProductCategoryListResponse) GetCode() (v int32) { + return p.Code +} + +func (p *GetProductCategoryListResponse) GetMessage() (v string) { + return p.Message +} + +var GetProductCategoryListResponse_Data_DEFAULT *GetProductCategoryListData + +func (p *GetProductCategoryListResponse) GetData() (v *GetProductCategoryListData) { + if !p.IsSetData() { + return GetProductCategoryListResponse_Data_DEFAULT + } + return p.Data +} + +var GetProductCategoryListResponse_BaseResp_DEFAULT *base.BaseResp + +func (p *GetProductCategoryListResponse) GetBaseResp() (v *base.BaseResp) { + if !p.IsSetBaseResp() { + return GetProductCategoryListResponse_BaseResp_DEFAULT + } + return p.BaseResp +} + +var fieldIDToName_GetProductCategoryListResponse = map[int16]string{ + 1: "Code", + 2: "Message", + 3: "Data", + 255: "BaseResp", +} + +func (p *GetProductCategoryListResponse) IsSetData() bool { + return p.Data != nil +} + +func (p *GetProductCategoryListResponse) IsSetBaseResp() bool { + return p.BaseResp != nil +} + +func (p *GetProductCategoryListResponse) Read(iprot thrift.TProtocol) (err error) { + var fieldTypeId thrift.TType + var fieldId int16 + var issetCode bool = false + var issetMessage bool = false + + if _, err = iprot.ReadStructBegin(); err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + + switch fieldId { + case 1: + if fieldTypeId == thrift.I32 { + if err = p.ReadField1(iprot); err != nil { + goto ReadFieldError + } + issetCode = true + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + case 2: + if fieldTypeId == thrift.STRING { + if err = p.ReadField2(iprot); err != nil { + goto ReadFieldError + } + issetMessage = true + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + case 3: + if fieldTypeId == thrift.STRUCT { + if err = p.ReadField3(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + case 255: + if fieldTypeId == thrift.STRUCT { + if err = p.ReadField255(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + default: + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + } + if err = iprot.ReadFieldEnd(); err != nil { + goto ReadFieldEndError + } + } + if err = iprot.ReadStructEnd(); err != nil { + goto ReadStructEndError + } + + if !issetCode { + fieldId = 1 + goto RequiredFieldNotSetError + } + + if !issetMessage { + fieldId = 2 + goto RequiredFieldNotSetError + } + return nil +ReadStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_GetProductCategoryListResponse[fieldId]), err) +SkipFieldError: + return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) + +ReadFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +RequiredFieldNotSetError: + return thrift.NewTProtocolExceptionWithType(thrift.INVALID_DATA, fmt.Errorf("required field %s is not set", fieldIDToName_GetProductCategoryListResponse[fieldId])) +} + +func (p *GetProductCategoryListResponse) ReadField1(iprot thrift.TProtocol) error { + + var _field int32 + if v, err := iprot.ReadI32(); err != nil { + return err + } else { + _field = v + } + p.Code = _field + return nil +} +func (p *GetProductCategoryListResponse) ReadField2(iprot thrift.TProtocol) error { + + var _field string + if v, err := iprot.ReadString(); err != nil { + return err + } else { + _field = v + } + p.Message = _field + return nil +} +func (p *GetProductCategoryListResponse) ReadField3(iprot thrift.TProtocol) error { + _field := NewGetProductCategoryListData() + if err := _field.Read(iprot); err != nil { + return err + } + p.Data = _field + return nil +} +func (p *GetProductCategoryListResponse) ReadField255(iprot thrift.TProtocol) error { + _field := base.NewBaseResp() + if err := _field.Read(iprot); err != nil { + return err + } + p.BaseResp = _field + return nil +} + +func (p *GetProductCategoryListResponse) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("GetProductCategoryListResponse"); err != nil { + goto WriteStructBeginError + } + if p != nil { + if err = p.writeField1(oprot); err != nil { + fieldId = 1 + goto WriteFieldError + } + if err = p.writeField2(oprot); err != nil { + fieldId = 2 + goto WriteFieldError + } + if err = p.writeField3(oprot); err != nil { + fieldId = 3 + goto WriteFieldError + } + if err = p.writeField255(oprot); err != nil { + fieldId = 255 + goto WriteFieldError + } + } + if err = oprot.WriteFieldStop(); err != nil { + goto WriteFieldStopError + } + if err = oprot.WriteStructEnd(); err != nil { + goto WriteStructEndError + } + return nil +WriteStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) +WriteFieldError: + return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) +WriteFieldStopError: + return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) +WriteStructEndError: + return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) +} + +func (p *GetProductCategoryListResponse) writeField1(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("Code", thrift.I32, 1); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteI32(p.Code); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) +} +func (p *GetProductCategoryListResponse) writeField2(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("Message", thrift.STRING, 2); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteString(p.Message); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 2 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 2 end error: ", p), err) +} +func (p *GetProductCategoryListResponse) writeField3(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("Data", thrift.STRUCT, 3); err != nil { + goto WriteFieldBeginError + } + if err := p.Data.Write(oprot); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 3 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 3 end error: ", p), err) +} +func (p *GetProductCategoryListResponse) writeField255(oprot thrift.TProtocol) (err error) { + if p.IsSetBaseResp() { + if err = oprot.WriteFieldBegin("BaseResp", thrift.STRUCT, 255); err != nil { + goto WriteFieldBeginError + } + if err := p.BaseResp.Write(oprot); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 255 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 255 end error: ", p), err) +} + +func (p *GetProductCategoryListResponse) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("GetProductCategoryListResponse(%+v)", *p) + +} + +type GetProductCallInfoRequest struct { + EntityType product_common.ProductEntityType `thrift:"EntityType,1" json:"EntityType" query:"entity_type"` + EntityID *int64 `thrift:"EntityID,2,optional" json:"EntityID,omitempty" query:"entity_id"` + EnterpriseID *string `thrift:"EnterpriseID,3,optional" json:"EnterpriseID,omitempty" query:"enterprise_id"` + Base *base.Base `thrift:"Base,255,optional" form:"Base" json:"Base,omitempty" query:"Base"` +} + +func NewGetProductCallInfoRequest() *GetProductCallInfoRequest { + return &GetProductCallInfoRequest{} +} + +func (p *GetProductCallInfoRequest) InitDefault() { +} + +func (p *GetProductCallInfoRequest) GetEntityType() (v product_common.ProductEntityType) { + return p.EntityType +} + +var GetProductCallInfoRequest_EntityID_DEFAULT int64 + +func (p *GetProductCallInfoRequest) GetEntityID() (v int64) { + if !p.IsSetEntityID() { + return GetProductCallInfoRequest_EntityID_DEFAULT + } + return *p.EntityID +} + +var GetProductCallInfoRequest_EnterpriseID_DEFAULT string + +func (p *GetProductCallInfoRequest) GetEnterpriseID() (v string) { + if !p.IsSetEnterpriseID() { + return GetProductCallInfoRequest_EnterpriseID_DEFAULT + } + return *p.EnterpriseID +} + +var GetProductCallInfoRequest_Base_DEFAULT *base.Base + +func (p *GetProductCallInfoRequest) GetBase() (v *base.Base) { + if !p.IsSetBase() { + return GetProductCallInfoRequest_Base_DEFAULT + } + return p.Base +} + +var fieldIDToName_GetProductCallInfoRequest = map[int16]string{ + 1: "EntityType", + 2: "EntityID", + 3: "EnterpriseID", + 255: "Base", +} + +func (p *GetProductCallInfoRequest) IsSetEntityID() bool { + return p.EntityID != nil +} + +func (p *GetProductCallInfoRequest) IsSetEnterpriseID() bool { + return p.EnterpriseID != nil +} + +func (p *GetProductCallInfoRequest) IsSetBase() bool { + return p.Base != nil +} + +func (p *GetProductCallInfoRequest) Read(iprot thrift.TProtocol) (err error) { + var fieldTypeId thrift.TType + var fieldId int16 + + if _, err = iprot.ReadStructBegin(); err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + + switch fieldId { + case 1: + if fieldTypeId == thrift.I32 { + if err = p.ReadField1(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + case 2: + if fieldTypeId == thrift.I64 { + if err = p.ReadField2(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + case 3: + if fieldTypeId == thrift.STRING { + if err = p.ReadField3(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + case 255: + if fieldTypeId == thrift.STRUCT { + if err = p.ReadField255(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + default: + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + } + if err = iprot.ReadFieldEnd(); err != nil { + goto ReadFieldEndError + } + } + if err = iprot.ReadStructEnd(); err != nil { + goto ReadStructEndError + } + + return nil +ReadStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_GetProductCallInfoRequest[fieldId]), err) +SkipFieldError: + return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) + +ReadFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *GetProductCallInfoRequest) ReadField1(iprot thrift.TProtocol) error { + + var _field product_common.ProductEntityType + if v, err := iprot.ReadI32(); err != nil { + return err + } else { + _field = product_common.ProductEntityType(v) + } + p.EntityType = _field + return nil +} +func (p *GetProductCallInfoRequest) ReadField2(iprot thrift.TProtocol) error { + + var _field *int64 + if v, err := iprot.ReadI64(); err != nil { + return err + } else { + _field = &v + } + p.EntityID = _field + return nil +} +func (p *GetProductCallInfoRequest) ReadField3(iprot thrift.TProtocol) error { + + var _field *string + if v, err := iprot.ReadString(); err != nil { + return err + } else { + _field = &v + } + p.EnterpriseID = _field + return nil +} +func (p *GetProductCallInfoRequest) ReadField255(iprot thrift.TProtocol) error { + _field := base.NewBase() + if err := _field.Read(iprot); err != nil { + return err + } + p.Base = _field + return nil +} + +func (p *GetProductCallInfoRequest) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("GetProductCallInfoRequest"); err != nil { + goto WriteStructBeginError + } + if p != nil { + if err = p.writeField1(oprot); err != nil { + fieldId = 1 + goto WriteFieldError + } + if err = p.writeField2(oprot); err != nil { + fieldId = 2 + goto WriteFieldError + } + if err = p.writeField3(oprot); err != nil { + fieldId = 3 + goto WriteFieldError + } + if err = p.writeField255(oprot); err != nil { + fieldId = 255 + goto WriteFieldError + } + } + if err = oprot.WriteFieldStop(); err != nil { + goto WriteFieldStopError + } + if err = oprot.WriteStructEnd(); err != nil { + goto WriteStructEndError + } + return nil +WriteStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) +WriteFieldError: + return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) +WriteFieldStopError: + return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) +WriteStructEndError: + return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) +} + +func (p *GetProductCallInfoRequest) writeField1(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("EntityType", thrift.I32, 1); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteI32(int32(p.EntityType)); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) +} +func (p *GetProductCallInfoRequest) writeField2(oprot thrift.TProtocol) (err error) { + if p.IsSetEntityID() { + if err = oprot.WriteFieldBegin("EntityID", thrift.I64, 2); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteI64(*p.EntityID); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 2 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 2 end error: ", p), err) +} +func (p *GetProductCallInfoRequest) writeField3(oprot thrift.TProtocol) (err error) { + if p.IsSetEnterpriseID() { + if err = oprot.WriteFieldBegin("EnterpriseID", thrift.STRING, 3); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteString(*p.EnterpriseID); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 3 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 3 end error: ", p), err) +} +func (p *GetProductCallInfoRequest) writeField255(oprot thrift.TProtocol) (err error) { + if p.IsSetBase() { + if err = oprot.WriteFieldBegin("Base", thrift.STRUCT, 255); err != nil { + goto WriteFieldBeginError + } + if err := p.Base.Write(oprot); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 255 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 255 end error: ", p), err) +} + +func (p *GetProductCallInfoRequest) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("GetProductCallInfoRequest(%+v)", *p) + +} + +type ProductCallCountLimit struct { + // Whether plugin tool calls are unlimited + IsUnlimited bool `thrift:"is_unlimited,1" form:"is_unlimited" json:"is_unlimited" query:"is_unlimited"` + // Plugin tool calls used + UsedCount int32 `thrift:"used_count,2" form:"used_count" json:"used_count" query:"used_count"` + // Plugin total tool calls + TotalCount int32 `thrift:"total_count,3" form:"total_count" json:"total_count" query:"total_count"` + // Plugin tool call count reset time + ResetDatetime int64 `thrift:"reset_datetime,4" form:"reset_datetime" json:"reset_datetime" query:"reset_datetime"` + // Plugin tool call count limit by user level + CallCountLimitByUserLevel map[UserLevel]*ProductCallCountLimit `thrift:"call_count_limit_by_user_level,5" form:"call_count_limit_by_user_level" json:"call_count_limit_by_user_level" query:"call_count_limit_by_user_level"` +} + +func NewProductCallCountLimit() *ProductCallCountLimit { + return &ProductCallCountLimit{} +} + +func (p *ProductCallCountLimit) InitDefault() { +} + +func (p *ProductCallCountLimit) GetIsUnlimited() (v bool) { + return p.IsUnlimited +} + +func (p *ProductCallCountLimit) GetUsedCount() (v int32) { + return p.UsedCount +} + +func (p *ProductCallCountLimit) GetTotalCount() (v int32) { + return p.TotalCount +} + +func (p *ProductCallCountLimit) GetResetDatetime() (v int64) { + return p.ResetDatetime +} + +func (p *ProductCallCountLimit) GetCallCountLimitByUserLevel() (v map[UserLevel]*ProductCallCountLimit) { + return p.CallCountLimitByUserLevel +} + +var fieldIDToName_ProductCallCountLimit = map[int16]string{ + 1: "is_unlimited", + 2: "used_count", + 3: "total_count", + 4: "reset_datetime", + 5: "call_count_limit_by_user_level", +} + +func (p *ProductCallCountLimit) Read(iprot thrift.TProtocol) (err error) { + var fieldTypeId thrift.TType + var fieldId int16 + + if _, err = iprot.ReadStructBegin(); err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + + switch fieldId { + case 1: + if fieldTypeId == thrift.BOOL { + if err = p.ReadField1(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + case 2: + if fieldTypeId == thrift.I32 { + if err = p.ReadField2(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + case 3: + if fieldTypeId == thrift.I32 { + if err = p.ReadField3(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + case 4: + if fieldTypeId == thrift.I64 { + if err = p.ReadField4(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + case 5: + if fieldTypeId == thrift.MAP { + if err = p.ReadField5(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + default: + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + } + if err = iprot.ReadFieldEnd(); err != nil { + goto ReadFieldEndError + } + } + if err = iprot.ReadStructEnd(); err != nil { + goto ReadStructEndError + } + + return nil +ReadStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ProductCallCountLimit[fieldId]), err) +SkipFieldError: + return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) + +ReadFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *ProductCallCountLimit) ReadField1(iprot thrift.TProtocol) error { + + var _field bool + if v, err := iprot.ReadBool(); err != nil { + return err + } else { + _field = v + } + p.IsUnlimited = _field + return nil +} +func (p *ProductCallCountLimit) ReadField2(iprot thrift.TProtocol) error { + + var _field int32 + if v, err := iprot.ReadI32(); err != nil { + return err + } else { + _field = v + } + p.UsedCount = _field + return nil +} +func (p *ProductCallCountLimit) ReadField3(iprot thrift.TProtocol) error { + + var _field int32 + if v, err := iprot.ReadI32(); err != nil { + return err + } else { + _field = v + } + p.TotalCount = _field + return nil +} +func (p *ProductCallCountLimit) ReadField4(iprot thrift.TProtocol) error { + + var _field int64 + if v, err := iprot.ReadI64(); err != nil { + return err + } else { + _field = v + } + p.ResetDatetime = _field + return nil +} +func (p *ProductCallCountLimit) ReadField5(iprot thrift.TProtocol) error { + _, _, size, err := iprot.ReadMapBegin() + if err != nil { + return err + } + _field := make(map[UserLevel]*ProductCallCountLimit, size) + values := make([]ProductCallCountLimit, size) + for i := 0; i < size; i++ { + var _key UserLevel + if v, err := iprot.ReadI32(); err != nil { + return err + } else { + _key = UserLevel(v) + } + + _val := &values[i] + _val.InitDefault() + if err := _val.Read(iprot); err != nil { + return err + } + + _field[_key] = _val + } + if err := iprot.ReadMapEnd(); err != nil { + return err + } + p.CallCountLimitByUserLevel = _field + return nil +} + +func (p *ProductCallCountLimit) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("ProductCallCountLimit"); err != nil { + goto WriteStructBeginError + } + if p != nil { + if err = p.writeField1(oprot); err != nil { + fieldId = 1 + goto WriteFieldError + } + if err = p.writeField2(oprot); err != nil { + fieldId = 2 + goto WriteFieldError + } + if err = p.writeField3(oprot); err != nil { + fieldId = 3 + goto WriteFieldError + } + if err = p.writeField4(oprot); err != nil { + fieldId = 4 + goto WriteFieldError + } + if err = p.writeField5(oprot); err != nil { + fieldId = 5 + goto WriteFieldError + } + } + if err = oprot.WriteFieldStop(); err != nil { + goto WriteFieldStopError + } + if err = oprot.WriteStructEnd(); err != nil { + goto WriteStructEndError + } + return nil +WriteStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) +WriteFieldError: + return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) +WriteFieldStopError: + return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) +WriteStructEndError: + return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) +} + +func (p *ProductCallCountLimit) writeField1(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("is_unlimited", thrift.BOOL, 1); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteBool(p.IsUnlimited); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) +} +func (p *ProductCallCountLimit) writeField2(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("used_count", thrift.I32, 2); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteI32(p.UsedCount); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 2 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 2 end error: ", p), err) +} +func (p *ProductCallCountLimit) writeField3(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("total_count", thrift.I32, 3); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteI32(p.TotalCount); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 3 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 3 end error: ", p), err) +} +func (p *ProductCallCountLimit) writeField4(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("reset_datetime", thrift.I64, 4); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteI64(p.ResetDatetime); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 4 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 4 end error: ", p), err) +} +func (p *ProductCallCountLimit) writeField5(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("call_count_limit_by_user_level", thrift.MAP, 5); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteMapBegin(thrift.I32, thrift.STRUCT, len(p.CallCountLimitByUserLevel)); err != nil { + return err + } + for k, v := range p.CallCountLimitByUserLevel { + if err := oprot.WriteI32(int32(k)); err != nil { + return err + } + if err := v.Write(oprot); err != nil { + return err + } + } + if err := oprot.WriteMapEnd(); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 5 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 5 end error: ", p), err) +} + +func (p *ProductCallCountLimit) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("ProductCallCountLimit(%+v)", *p) + +} + +type ProductCallRateLimit struct { + // qps + QPS int32 `thrift:"qps,1" form:"qps" json:"qps" query:"qps"` + // Plugin tool call rate limit by user level + CallRateLimitByUserLevel map[UserLevel]*ProductCallRateLimit `thrift:"call_rate_limit_by_user_level,2" form:"call_rate_limit_by_user_level" json:"call_rate_limit_by_user_level" query:"call_rate_limit_by_user_level"` +} + +func NewProductCallRateLimit() *ProductCallRateLimit { + return &ProductCallRateLimit{} +} + +func (p *ProductCallRateLimit) InitDefault() { +} + +func (p *ProductCallRateLimit) GetQPS() (v int32) { + return p.QPS +} + +func (p *ProductCallRateLimit) GetCallRateLimitByUserLevel() (v map[UserLevel]*ProductCallRateLimit) { + return p.CallRateLimitByUserLevel +} + +var fieldIDToName_ProductCallRateLimit = map[int16]string{ + 1: "qps", + 2: "call_rate_limit_by_user_level", +} + +func (p *ProductCallRateLimit) Read(iprot thrift.TProtocol) (err error) { + var fieldTypeId thrift.TType + var fieldId int16 + + if _, err = iprot.ReadStructBegin(); err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + + switch fieldId { + case 1: + if fieldTypeId == thrift.I32 { + if err = p.ReadField1(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + case 2: + if fieldTypeId == thrift.MAP { + if err = p.ReadField2(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + default: + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + } + if err = iprot.ReadFieldEnd(); err != nil { + goto ReadFieldEndError + } + } + if err = iprot.ReadStructEnd(); err != nil { + goto ReadStructEndError + } + + return nil +ReadStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ProductCallRateLimit[fieldId]), err) +SkipFieldError: + return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) + +ReadFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *ProductCallRateLimit) ReadField1(iprot thrift.TProtocol) error { + + var _field int32 + if v, err := iprot.ReadI32(); err != nil { + return err + } else { + _field = v + } + p.QPS = _field + return nil +} +func (p *ProductCallRateLimit) ReadField2(iprot thrift.TProtocol) error { + _, _, size, err := iprot.ReadMapBegin() + if err != nil { + return err + } + _field := make(map[UserLevel]*ProductCallRateLimit, size) + values := make([]ProductCallRateLimit, size) + for i := 0; i < size; i++ { + var _key UserLevel + if v, err := iprot.ReadI32(); err != nil { + return err + } else { + _key = UserLevel(v) + } + + _val := &values[i] + _val.InitDefault() + if err := _val.Read(iprot); err != nil { + return err + } + + _field[_key] = _val + } + if err := iprot.ReadMapEnd(); err != nil { + return err + } + p.CallRateLimitByUserLevel = _field + return nil +} + +func (p *ProductCallRateLimit) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("ProductCallRateLimit"); err != nil { + goto WriteStructBeginError + } + if p != nil { + if err = p.writeField1(oprot); err != nil { + fieldId = 1 + goto WriteFieldError + } + if err = p.writeField2(oprot); err != nil { + fieldId = 2 + goto WriteFieldError + } + } + if err = oprot.WriteFieldStop(); err != nil { + goto WriteFieldStopError + } + if err = oprot.WriteStructEnd(); err != nil { + goto WriteStructEndError + } + return nil +WriteStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) +WriteFieldError: + return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) +WriteFieldStopError: + return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) +WriteStructEndError: + return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) +} + +func (p *ProductCallRateLimit) writeField1(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("qps", thrift.I32, 1); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteI32(p.QPS); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) +} +func (p *ProductCallRateLimit) writeField2(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("call_rate_limit_by_user_level", thrift.MAP, 2); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteMapBegin(thrift.I32, thrift.STRUCT, len(p.CallRateLimitByUserLevel)); err != nil { + return err + } + for k, v := range p.CallRateLimitByUserLevel { + if err := oprot.WriteI32(int32(k)); err != nil { + return err + } + if err := v.Write(oprot); err != nil { + return err + } + } + if err := oprot.WriteMapEnd(); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 2 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 2 end error: ", p), err) +} + +func (p *ProductCallRateLimit) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("ProductCallRateLimit(%+v)", *p) + +} + +type UserInfo struct { + // User name + UserName *string `thrift:"user_name,1,optional" form:"user_name" json:"user_name,omitempty" query:"user_name"` + // User nickname + NickName *string `thrift:"nick_name,2,optional" form:"nick_name" json:"nick_name,omitempty" query:"nick_name"` + // User avatar url + AvatarURL *string `thrift:"avatar_url,3,optional" form:"avatar_url" json:"avatar_url,omitempty" query:"avatar_url"` +} + +func NewUserInfo() *UserInfo { + return &UserInfo{} +} + +func (p *UserInfo) InitDefault() { +} + +var UserInfo_UserName_DEFAULT string + +func (p *UserInfo) GetUserName() (v string) { + if !p.IsSetUserName() { + return UserInfo_UserName_DEFAULT + } + return *p.UserName +} + +var UserInfo_NickName_DEFAULT string + +func (p *UserInfo) GetNickName() (v string) { + if !p.IsSetNickName() { + return UserInfo_NickName_DEFAULT + } + return *p.NickName +} + +var UserInfo_AvatarURL_DEFAULT string + +func (p *UserInfo) GetAvatarURL() (v string) { + if !p.IsSetAvatarURL() { + return UserInfo_AvatarURL_DEFAULT + } + return *p.AvatarURL +} + +var fieldIDToName_UserInfo = map[int16]string{ + 1: "user_name", + 2: "nick_name", + 3: "avatar_url", +} + +func (p *UserInfo) IsSetUserName() bool { + return p.UserName != nil +} + +func (p *UserInfo) IsSetNickName() bool { + return p.NickName != nil +} + +func (p *UserInfo) IsSetAvatarURL() bool { + return p.AvatarURL != nil +} + +func (p *UserInfo) Read(iprot thrift.TProtocol) (err error) { + var fieldTypeId thrift.TType + var fieldId int16 + + if _, err = iprot.ReadStructBegin(); err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + + switch fieldId { + case 1: + if fieldTypeId == thrift.STRING { + if err = p.ReadField1(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + case 2: + if fieldTypeId == thrift.STRING { + if err = p.ReadField2(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + case 3: + if fieldTypeId == thrift.STRING { + if err = p.ReadField3(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + default: + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + } + if err = iprot.ReadFieldEnd(); err != nil { + goto ReadFieldEndError + } + } + if err = iprot.ReadStructEnd(); err != nil { + goto ReadStructEndError + } + + return nil +ReadStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_UserInfo[fieldId]), err) +SkipFieldError: + return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) + +ReadFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *UserInfo) ReadField1(iprot thrift.TProtocol) error { + + var _field *string + if v, err := iprot.ReadString(); err != nil { + return err + } else { + _field = &v + } + p.UserName = _field + return nil +} +func (p *UserInfo) ReadField2(iprot thrift.TProtocol) error { + + var _field *string + if v, err := iprot.ReadString(); err != nil { + return err + } else { + _field = &v + } + p.NickName = _field + return nil +} +func (p *UserInfo) ReadField3(iprot thrift.TProtocol) error { + + var _field *string + if v, err := iprot.ReadString(); err != nil { + return err + } else { + _field = &v + } + p.AvatarURL = _field + return nil +} + +func (p *UserInfo) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("UserInfo"); err != nil { + goto WriteStructBeginError + } + if p != nil { + if err = p.writeField1(oprot); err != nil { + fieldId = 1 + goto WriteFieldError + } + if err = p.writeField2(oprot); err != nil { + fieldId = 2 + goto WriteFieldError + } + if err = p.writeField3(oprot); err != nil { + fieldId = 3 + goto WriteFieldError + } + } + if err = oprot.WriteFieldStop(); err != nil { + goto WriteFieldStopError + } + if err = oprot.WriteStructEnd(); err != nil { + goto WriteStructEndError + } + return nil +WriteStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) +WriteFieldError: + return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) +WriteFieldStopError: + return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) +WriteStructEndError: + return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) +} + +func (p *UserInfo) writeField1(oprot thrift.TProtocol) (err error) { + if p.IsSetUserName() { + if err = oprot.WriteFieldBegin("user_name", thrift.STRING, 1); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteString(*p.UserName); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) +} +func (p *UserInfo) writeField2(oprot thrift.TProtocol) (err error) { + if p.IsSetNickName() { + if err = oprot.WriteFieldBegin("nick_name", thrift.STRING, 2); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteString(*p.NickName); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 2 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 2 end error: ", p), err) +} +func (p *UserInfo) writeField3(oprot thrift.TProtocol) (err error) { + if p.IsSetAvatarURL() { + if err = oprot.WriteFieldBegin("avatar_url", thrift.STRING, 3); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteString(*p.AvatarURL); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 3 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 3 end error: ", p), err) +} + +func (p *UserInfo) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("UserInfo(%+v)", *p) + +} + +type GetProductCallInfoData struct { + // mcp configuration json string + McpJSON string `thrift:"mcp_json,1" form:"mcp_json" json:"mcp_json" query:"mcp_json"` + // Payment level + UserLevel UserLevel `thrift:"user_level,2" form:"user_level" json:"user_level" query:"user_level"` + // Plugin tool call count limit + CallCountLimit *ProductCallCountLimit `thrift:"call_count_limit,3" form:"call_count_limit" json:"call_count_limit" query:"call_count_limit"` + // Plugin tool call rate limit + CallRateLimit *ProductCallRateLimit `thrift:"call_rate_limit,4" form:"call_rate_limit" json:"call_rate_limit" query:"call_rate_limit"` + // User info + UserInfo *UserInfo `thrift:"user_info,5" form:"user_info" json:"user_info" query:"user_info"` + // Enterprise revert time + RevertTime *string `thrift:"revert_time,6,optional" form:"revert_time" json:"revert_time,omitempty" query:"revert_time"` +} + +func NewGetProductCallInfoData() *GetProductCallInfoData { + return &GetProductCallInfoData{} +} + +func (p *GetProductCallInfoData) InitDefault() { +} + +func (p *GetProductCallInfoData) GetMcpJSON() (v string) { + return p.McpJSON +} + +func (p *GetProductCallInfoData) GetUserLevel() (v UserLevel) { + return p.UserLevel +} + +var GetProductCallInfoData_CallCountLimit_DEFAULT *ProductCallCountLimit + +func (p *GetProductCallInfoData) GetCallCountLimit() (v *ProductCallCountLimit) { + if !p.IsSetCallCountLimit() { + return GetProductCallInfoData_CallCountLimit_DEFAULT + } + return p.CallCountLimit +} + +var GetProductCallInfoData_CallRateLimit_DEFAULT *ProductCallRateLimit + +func (p *GetProductCallInfoData) GetCallRateLimit() (v *ProductCallRateLimit) { + if !p.IsSetCallRateLimit() { + return GetProductCallInfoData_CallRateLimit_DEFAULT + } + return p.CallRateLimit +} + +var GetProductCallInfoData_UserInfo_DEFAULT *UserInfo + +func (p *GetProductCallInfoData) GetUserInfo() (v *UserInfo) { + if !p.IsSetUserInfo() { + return GetProductCallInfoData_UserInfo_DEFAULT + } + return p.UserInfo +} + +var GetProductCallInfoData_RevertTime_DEFAULT string + +func (p *GetProductCallInfoData) GetRevertTime() (v string) { + if !p.IsSetRevertTime() { + return GetProductCallInfoData_RevertTime_DEFAULT + } + return *p.RevertTime +} + +var fieldIDToName_GetProductCallInfoData = map[int16]string{ + 1: "mcp_json", + 2: "user_level", + 3: "call_count_limit", + 4: "call_rate_limit", + 5: "user_info", + 6: "revert_time", +} + +func (p *GetProductCallInfoData) IsSetCallCountLimit() bool { + return p.CallCountLimit != nil +} + +func (p *GetProductCallInfoData) IsSetCallRateLimit() bool { + return p.CallRateLimit != nil +} + +func (p *GetProductCallInfoData) IsSetUserInfo() bool { + return p.UserInfo != nil +} + +func (p *GetProductCallInfoData) IsSetRevertTime() bool { + return p.RevertTime != nil +} + +func (p *GetProductCallInfoData) Read(iprot thrift.TProtocol) (err error) { + var fieldTypeId thrift.TType + var fieldId int16 + + if _, err = iprot.ReadStructBegin(); err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + + switch fieldId { + case 1: + if fieldTypeId == thrift.STRING { + if err = p.ReadField1(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + case 2: + if fieldTypeId == thrift.I32 { + if err = p.ReadField2(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + case 3: + if fieldTypeId == thrift.STRUCT { + if err = p.ReadField3(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + case 4: + if fieldTypeId == thrift.STRUCT { + if err = p.ReadField4(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + case 5: + if fieldTypeId == thrift.STRUCT { + if err = p.ReadField5(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + case 6: + if fieldTypeId == thrift.STRING { + if err = p.ReadField6(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + default: + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + } + if err = iprot.ReadFieldEnd(); err != nil { + goto ReadFieldEndError + } + } + if err = iprot.ReadStructEnd(); err != nil { + goto ReadStructEndError + } + + return nil +ReadStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_GetProductCallInfoData[fieldId]), err) +SkipFieldError: + return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) + +ReadFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *GetProductCallInfoData) ReadField1(iprot thrift.TProtocol) error { + + var _field string + if v, err := iprot.ReadString(); err != nil { + return err + } else { + _field = v + } + p.McpJSON = _field + return nil +} +func (p *GetProductCallInfoData) ReadField2(iprot thrift.TProtocol) error { + + var _field UserLevel + if v, err := iprot.ReadI32(); err != nil { + return err + } else { + _field = UserLevel(v) + } + p.UserLevel = _field + return nil +} +func (p *GetProductCallInfoData) ReadField3(iprot thrift.TProtocol) error { + _field := NewProductCallCountLimit() + if err := _field.Read(iprot); err != nil { + return err + } + p.CallCountLimit = _field + return nil +} +func (p *GetProductCallInfoData) ReadField4(iprot thrift.TProtocol) error { + _field := NewProductCallRateLimit() + if err := _field.Read(iprot); err != nil { + return err + } + p.CallRateLimit = _field + return nil +} +func (p *GetProductCallInfoData) ReadField5(iprot thrift.TProtocol) error { + _field := NewUserInfo() + if err := _field.Read(iprot); err != nil { + return err + } + p.UserInfo = _field + return nil +} +func (p *GetProductCallInfoData) ReadField6(iprot thrift.TProtocol) error { + + var _field *string + if v, err := iprot.ReadString(); err != nil { + return err + } else { + _field = &v + } + p.RevertTime = _field + return nil +} + +func (p *GetProductCallInfoData) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("GetProductCallInfoData"); err != nil { + goto WriteStructBeginError + } + if p != nil { + if err = p.writeField1(oprot); err != nil { + fieldId = 1 + goto WriteFieldError + } + if err = p.writeField2(oprot); err != nil { + fieldId = 2 + goto WriteFieldError + } + if err = p.writeField3(oprot); err != nil { + fieldId = 3 + goto WriteFieldError + } + if err = p.writeField4(oprot); err != nil { + fieldId = 4 + goto WriteFieldError + } + if err = p.writeField5(oprot); err != nil { + fieldId = 5 + goto WriteFieldError + } + if err = p.writeField6(oprot); err != nil { + fieldId = 6 + goto WriteFieldError + } + } + if err = oprot.WriteFieldStop(); err != nil { + goto WriteFieldStopError + } + if err = oprot.WriteStructEnd(); err != nil { + goto WriteStructEndError + } + return nil +WriteStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) +WriteFieldError: + return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) +WriteFieldStopError: + return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) +WriteStructEndError: + return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) +} + +func (p *GetProductCallInfoData) writeField1(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("mcp_json", thrift.STRING, 1); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteString(p.McpJSON); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) +} +func (p *GetProductCallInfoData) writeField2(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("user_level", thrift.I32, 2); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteI32(int32(p.UserLevel)); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 2 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 2 end error: ", p), err) +} +func (p *GetProductCallInfoData) writeField3(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("call_count_limit", thrift.STRUCT, 3); err != nil { + goto WriteFieldBeginError + } + if err := p.CallCountLimit.Write(oprot); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 3 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 3 end error: ", p), err) +} +func (p *GetProductCallInfoData) writeField4(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("call_rate_limit", thrift.STRUCT, 4); err != nil { + goto WriteFieldBeginError + } + if err := p.CallRateLimit.Write(oprot); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 4 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 4 end error: ", p), err) +} +func (p *GetProductCallInfoData) writeField5(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("user_info", thrift.STRUCT, 5); err != nil { + goto WriteFieldBeginError + } + if err := p.UserInfo.Write(oprot); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 5 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 5 end error: ", p), err) +} +func (p *GetProductCallInfoData) writeField6(oprot thrift.TProtocol) (err error) { + if p.IsSetRevertTime() { + if err = oprot.WriteFieldBegin("revert_time", thrift.STRING, 6); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteString(*p.RevertTime); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 6 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 6 end error: ", p), err) +} + +func (p *GetProductCallInfoData) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("GetProductCallInfoData(%+v)", *p) + +} + +type GetProductCallInfoResponse struct { + Code int32 `thrift:"Code,1,required" form:"code,required" json:"code,required"` + Message string `thrift:"Message,2,required" form:"message,required" json:"message,required"` + Data *GetProductCallInfoData `thrift:"Data,3,optional" form:"data" json:"data,omitempty"` + BaseResp *base.BaseResp `thrift:"BaseResp,255,optional" form:"BaseResp" json:"BaseResp,omitempty" query:"BaseResp"` +} + +func NewGetProductCallInfoResponse() *GetProductCallInfoResponse { + return &GetProductCallInfoResponse{} +} + +func (p *GetProductCallInfoResponse) InitDefault() { +} + +func (p *GetProductCallInfoResponse) GetCode() (v int32) { + return p.Code +} + +func (p *GetProductCallInfoResponse) GetMessage() (v string) { + return p.Message +} + +var GetProductCallInfoResponse_Data_DEFAULT *GetProductCallInfoData + +func (p *GetProductCallInfoResponse) GetData() (v *GetProductCallInfoData) { + if !p.IsSetData() { + return GetProductCallInfoResponse_Data_DEFAULT + } + return p.Data +} + +var GetProductCallInfoResponse_BaseResp_DEFAULT *base.BaseResp + +func (p *GetProductCallInfoResponse) GetBaseResp() (v *base.BaseResp) { + if !p.IsSetBaseResp() { + return GetProductCallInfoResponse_BaseResp_DEFAULT + } + return p.BaseResp +} + +var fieldIDToName_GetProductCallInfoResponse = map[int16]string{ + 1: "Code", + 2: "Message", + 3: "Data", + 255: "BaseResp", +} + +func (p *GetProductCallInfoResponse) IsSetData() bool { + return p.Data != nil +} + +func (p *GetProductCallInfoResponse) IsSetBaseResp() bool { + return p.BaseResp != nil +} + +func (p *GetProductCallInfoResponse) Read(iprot thrift.TProtocol) (err error) { + var fieldTypeId thrift.TType + var fieldId int16 + var issetCode bool = false + var issetMessage bool = false + + if _, err = iprot.ReadStructBegin(); err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + + switch fieldId { + case 1: + if fieldTypeId == thrift.I32 { + if err = p.ReadField1(iprot); err != nil { + goto ReadFieldError + } + issetCode = true + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + case 2: + if fieldTypeId == thrift.STRING { + if err = p.ReadField2(iprot); err != nil { + goto ReadFieldError + } + issetMessage = true + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + case 3: + if fieldTypeId == thrift.STRUCT { + if err = p.ReadField3(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + case 255: + if fieldTypeId == thrift.STRUCT { + if err = p.ReadField255(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + default: + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + } + if err = iprot.ReadFieldEnd(); err != nil { + goto ReadFieldEndError + } + } + if err = iprot.ReadStructEnd(); err != nil { + goto ReadStructEndError + } + + if !issetCode { + fieldId = 1 + goto RequiredFieldNotSetError + } + + if !issetMessage { + fieldId = 2 + goto RequiredFieldNotSetError + } + return nil +ReadStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_GetProductCallInfoResponse[fieldId]), err) +SkipFieldError: + return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) + +ReadFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +RequiredFieldNotSetError: + return thrift.NewTProtocolExceptionWithType(thrift.INVALID_DATA, fmt.Errorf("required field %s is not set", fieldIDToName_GetProductCallInfoResponse[fieldId])) +} + +func (p *GetProductCallInfoResponse) ReadField1(iprot thrift.TProtocol) error { + + var _field int32 + if v, err := iprot.ReadI32(); err != nil { + return err + } else { + _field = v + } + p.Code = _field + return nil +} +func (p *GetProductCallInfoResponse) ReadField2(iprot thrift.TProtocol) error { + + var _field string + if v, err := iprot.ReadString(); err != nil { + return err + } else { + _field = v + } + p.Message = _field + return nil +} +func (p *GetProductCallInfoResponse) ReadField3(iprot thrift.TProtocol) error { + _field := NewGetProductCallInfoData() + if err := _field.Read(iprot); err != nil { + return err + } + p.Data = _field + return nil +} +func (p *GetProductCallInfoResponse) ReadField255(iprot thrift.TProtocol) error { + _field := base.NewBaseResp() + if err := _field.Read(iprot); err != nil { + return err + } + p.BaseResp = _field + return nil +} + +func (p *GetProductCallInfoResponse) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("GetProductCallInfoResponse"); err != nil { + goto WriteStructBeginError + } + if p != nil { + if err = p.writeField1(oprot); err != nil { + fieldId = 1 + goto WriteFieldError + } + if err = p.writeField2(oprot); err != nil { + fieldId = 2 + goto WriteFieldError + } + if err = p.writeField3(oprot); err != nil { + fieldId = 3 + goto WriteFieldError + } + if err = p.writeField255(oprot); err != nil { + fieldId = 255 + goto WriteFieldError + } + } + if err = oprot.WriteFieldStop(); err != nil { + goto WriteFieldStopError + } + if err = oprot.WriteStructEnd(); err != nil { + goto WriteStructEndError + } + return nil +WriteStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) +WriteFieldError: + return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) +WriteFieldStopError: + return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) +WriteStructEndError: + return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) +} + +func (p *GetProductCallInfoResponse) writeField1(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("Code", thrift.I32, 1); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteI32(p.Code); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) +} +func (p *GetProductCallInfoResponse) writeField2(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("Message", thrift.STRING, 2); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteString(p.Message); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 2 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 2 end error: ", p), err) +} +func (p *GetProductCallInfoResponse) writeField3(oprot thrift.TProtocol) (err error) { + if p.IsSetData() { + if err = oprot.WriteFieldBegin("Data", thrift.STRUCT, 3); err != nil { + goto WriteFieldBeginError + } + if err := p.Data.Write(oprot); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 3 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 3 end error: ", p), err) +} +func (p *GetProductCallInfoResponse) writeField255(oprot thrift.TProtocol) (err error) { + if p.IsSetBaseResp() { + if err = oprot.WriteFieldBegin("BaseResp", thrift.STRUCT, 255); err != nil { + goto WriteFieldBeginError + } + if err := p.BaseResp.Write(oprot); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 255 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 255 end error: ", p), err) +} + +func (p *GetProductCallInfoResponse) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("GetProductCallInfoResponse(%+v)", *p) + +} + type PublicProductService interface { PublicGetProductList(ctx context.Context, req *GetProductListRequest) (r *GetProductListResponse, err error) @@ -23553,6 +29759,16 @@ type PublicProductService interface { PublicGetUserFavoriteListV2(ctx context.Context, req *GetUserFavoriteListV2Request) (r *GetUserFavoriteListV2Response, err error) PublicDuplicateProduct(ctx context.Context, req *DuplicateProductRequest) (r *DuplicateProductResponse, err error) + + PublicSearchProduct(ctx context.Context, req *SearchProductRequest) (r *SearchProductResponse, err error) + + PublicSearchSuggest(ctx context.Context, req *SearchSuggestRequest) (r *SearchSuggestResponse, err error) + + PublicGetProductCategoryList(ctx context.Context, req *GetProductCategoryListRequest) (r *GetProductCategoryListResponse, err error) + + PublicGetProductCallInfo(ctx context.Context, req *GetProductCallInfoRequest) (r *GetProductCallInfoResponse, err error) + + PublicGetMarketPluginConfig(ctx context.Context, req *GetMarketPluginConfigRequest) (r *GetMarketPluginConfigResponse, err error) } type PublicProductServiceClient struct { @@ -23626,6 +29842,51 @@ func (p *PublicProductServiceClient) PublicDuplicateProduct(ctx context.Context, } return _result.GetSuccess(), nil } +func (p *PublicProductServiceClient) PublicSearchProduct(ctx context.Context, req *SearchProductRequest) (r *SearchProductResponse, err error) { + var _args PublicProductServicePublicSearchProductArgs + _args.Req = req + var _result PublicProductServicePublicSearchProductResult + if err = p.Client_().Call(ctx, "PublicSearchProduct", &_args, &_result); err != nil { + return + } + return _result.GetSuccess(), nil +} +func (p *PublicProductServiceClient) PublicSearchSuggest(ctx context.Context, req *SearchSuggestRequest) (r *SearchSuggestResponse, err error) { + var _args PublicProductServicePublicSearchSuggestArgs + _args.Req = req + var _result PublicProductServicePublicSearchSuggestResult + if err = p.Client_().Call(ctx, "PublicSearchSuggest", &_args, &_result); err != nil { + return + } + return _result.GetSuccess(), nil +} +func (p *PublicProductServiceClient) PublicGetProductCategoryList(ctx context.Context, req *GetProductCategoryListRequest) (r *GetProductCategoryListResponse, err error) { + var _args PublicProductServicePublicGetProductCategoryListArgs + _args.Req = req + var _result PublicProductServicePublicGetProductCategoryListResult + if err = p.Client_().Call(ctx, "PublicGetProductCategoryList", &_args, &_result); err != nil { + return + } + return _result.GetSuccess(), nil +} +func (p *PublicProductServiceClient) PublicGetProductCallInfo(ctx context.Context, req *GetProductCallInfoRequest) (r *GetProductCallInfoResponse, err error) { + var _args PublicProductServicePublicGetProductCallInfoArgs + _args.Req = req + var _result PublicProductServicePublicGetProductCallInfoResult + if err = p.Client_().Call(ctx, "PublicGetProductCallInfo", &_args, &_result); err != nil { + return + } + return _result.GetSuccess(), nil +} +func (p *PublicProductServiceClient) PublicGetMarketPluginConfig(ctx context.Context, req *GetMarketPluginConfigRequest) (r *GetMarketPluginConfigResponse, err error) { + var _args PublicProductServicePublicGetMarketPluginConfigArgs + _args.Req = req + var _result PublicProductServicePublicGetMarketPluginConfigResult + if err = p.Client_().Call(ctx, "PublicGetMarketPluginConfig", &_args, &_result); err != nil { + return + } + return _result.GetSuccess(), nil +} type PublicProductServiceProcessor struct { processorMap map[string]thrift.TProcessorFunction @@ -23652,6 +29913,11 @@ func NewPublicProductServiceProcessor(handler PublicProductService) *PublicProdu self.AddToProcessorMap("PublicFavoriteProduct", &publicProductServiceProcessorPublicFavoriteProduct{handler: handler}) self.AddToProcessorMap("PublicGetUserFavoriteListV2", &publicProductServiceProcessorPublicGetUserFavoriteListV2{handler: handler}) self.AddToProcessorMap("PublicDuplicateProduct", &publicProductServiceProcessorPublicDuplicateProduct{handler: handler}) + self.AddToProcessorMap("PublicSearchProduct", &publicProductServiceProcessorPublicSearchProduct{handler: handler}) + self.AddToProcessorMap("PublicSearchSuggest", &publicProductServiceProcessorPublicSearchSuggest{handler: handler}) + self.AddToProcessorMap("PublicGetProductCategoryList", &publicProductServiceProcessorPublicGetProductCategoryList{handler: handler}) + self.AddToProcessorMap("PublicGetProductCallInfo", &publicProductServiceProcessorPublicGetProductCallInfo{handler: handler}) + self.AddToProcessorMap("PublicGetMarketPluginConfig", &publicProductServiceProcessorPublicGetMarketPluginConfig{handler: handler}) return self } func (p *PublicProductServiceProcessor) Process(ctx context.Context, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { @@ -23912,6 +30178,246 @@ func (p *publicProductServiceProcessorPublicDuplicateProduct) Process(ctx contex return true, err } +type publicProductServiceProcessorPublicSearchProduct struct { + handler PublicProductService +} + +func (p *publicProductServiceProcessorPublicSearchProduct) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + args := PublicProductServicePublicSearchProductArgs{} + if err = args.Read(iprot); err != nil { + iprot.ReadMessageEnd() + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) + oprot.WriteMessageBegin("PublicSearchProduct", thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush(ctx) + return false, err + } + + iprot.ReadMessageEnd() + var err2 error + result := PublicProductServicePublicSearchProductResult{} + var retval *SearchProductResponse + if retval, err2 = p.handler.PublicSearchProduct(ctx, args.Req); err2 != nil { + x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing PublicSearchProduct: "+err2.Error()) + oprot.WriteMessageBegin("PublicSearchProduct", thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush(ctx) + return true, err2 + } else { + result.Success = retval + } + if err2 = oprot.WriteMessageBegin("PublicSearchProduct", thrift.REPLY, seqId); err2 != nil { + err = err2 + } + if err2 = result.Write(oprot); err == nil && err2 != nil { + err = err2 + } + if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { + err = err2 + } + if err2 = oprot.Flush(ctx); err == nil && err2 != nil { + err = err2 + } + if err != nil { + return + } + return true, err +} + +type publicProductServiceProcessorPublicSearchSuggest struct { + handler PublicProductService +} + +func (p *publicProductServiceProcessorPublicSearchSuggest) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + args := PublicProductServicePublicSearchSuggestArgs{} + if err = args.Read(iprot); err != nil { + iprot.ReadMessageEnd() + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) + oprot.WriteMessageBegin("PublicSearchSuggest", thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush(ctx) + return false, err + } + + iprot.ReadMessageEnd() + var err2 error + result := PublicProductServicePublicSearchSuggestResult{} + var retval *SearchSuggestResponse + if retval, err2 = p.handler.PublicSearchSuggest(ctx, args.Req); err2 != nil { + x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing PublicSearchSuggest: "+err2.Error()) + oprot.WriteMessageBegin("PublicSearchSuggest", thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush(ctx) + return true, err2 + } else { + result.Success = retval + } + if err2 = oprot.WriteMessageBegin("PublicSearchSuggest", thrift.REPLY, seqId); err2 != nil { + err = err2 + } + if err2 = result.Write(oprot); err == nil && err2 != nil { + err = err2 + } + if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { + err = err2 + } + if err2 = oprot.Flush(ctx); err == nil && err2 != nil { + err = err2 + } + if err != nil { + return + } + return true, err +} + +type publicProductServiceProcessorPublicGetProductCategoryList struct { + handler PublicProductService +} + +func (p *publicProductServiceProcessorPublicGetProductCategoryList) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + args := PublicProductServicePublicGetProductCategoryListArgs{} + if err = args.Read(iprot); err != nil { + iprot.ReadMessageEnd() + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) + oprot.WriteMessageBegin("PublicGetProductCategoryList", thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush(ctx) + return false, err + } + + iprot.ReadMessageEnd() + var err2 error + result := PublicProductServicePublicGetProductCategoryListResult{} + var retval *GetProductCategoryListResponse + if retval, err2 = p.handler.PublicGetProductCategoryList(ctx, args.Req); err2 != nil { + x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing PublicGetProductCategoryList: "+err2.Error()) + oprot.WriteMessageBegin("PublicGetProductCategoryList", thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush(ctx) + return true, err2 + } else { + result.Success = retval + } + if err2 = oprot.WriteMessageBegin("PublicGetProductCategoryList", thrift.REPLY, seqId); err2 != nil { + err = err2 + } + if err2 = result.Write(oprot); err == nil && err2 != nil { + err = err2 + } + if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { + err = err2 + } + if err2 = oprot.Flush(ctx); err == nil && err2 != nil { + err = err2 + } + if err != nil { + return + } + return true, err +} + +type publicProductServiceProcessorPublicGetProductCallInfo struct { + handler PublicProductService +} + +func (p *publicProductServiceProcessorPublicGetProductCallInfo) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + args := PublicProductServicePublicGetProductCallInfoArgs{} + if err = args.Read(iprot); err != nil { + iprot.ReadMessageEnd() + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) + oprot.WriteMessageBegin("PublicGetProductCallInfo", thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush(ctx) + return false, err + } + + iprot.ReadMessageEnd() + var err2 error + result := PublicProductServicePublicGetProductCallInfoResult{} + var retval *GetProductCallInfoResponse + if retval, err2 = p.handler.PublicGetProductCallInfo(ctx, args.Req); err2 != nil { + x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing PublicGetProductCallInfo: "+err2.Error()) + oprot.WriteMessageBegin("PublicGetProductCallInfo", thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush(ctx) + return true, err2 + } else { + result.Success = retval + } + if err2 = oprot.WriteMessageBegin("PublicGetProductCallInfo", thrift.REPLY, seqId); err2 != nil { + err = err2 + } + if err2 = result.Write(oprot); err == nil && err2 != nil { + err = err2 + } + if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { + err = err2 + } + if err2 = oprot.Flush(ctx); err == nil && err2 != nil { + err = err2 + } + if err != nil { + return + } + return true, err +} + +type publicProductServiceProcessorPublicGetMarketPluginConfig struct { + handler PublicProductService +} + +func (p *publicProductServiceProcessorPublicGetMarketPluginConfig) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + args := PublicProductServicePublicGetMarketPluginConfigArgs{} + if err = args.Read(iprot); err != nil { + iprot.ReadMessageEnd() + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) + oprot.WriteMessageBegin("PublicGetMarketPluginConfig", thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush(ctx) + return false, err + } + + iprot.ReadMessageEnd() + var err2 error + result := PublicProductServicePublicGetMarketPluginConfigResult{} + var retval *GetMarketPluginConfigResponse + if retval, err2 = p.handler.PublicGetMarketPluginConfig(ctx, args.Req); err2 != nil { + x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing PublicGetMarketPluginConfig: "+err2.Error()) + oprot.WriteMessageBegin("PublicGetMarketPluginConfig", thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush(ctx) + return true, err2 + } else { + result.Success = retval + } + if err2 = oprot.WriteMessageBegin("PublicGetMarketPluginConfig", thrift.REPLY, seqId); err2 != nil { + err = err2 + } + if err2 = result.Write(oprot); err == nil && err2 != nil { + err = err2 + } + if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { + err = err2 + } + if err2 = oprot.Flush(ctx); err == nil && err2 != nil { + err = err2 + } + if err != nil { + return + } + return true, err +} + type PublicProductServicePublicGetProductListArgs struct { Req *GetProductListRequest `thrift:"req,1"` } @@ -25371,3 +31877,1463 @@ func (p *PublicProductServicePublicDuplicateProductResult) String() string { return fmt.Sprintf("PublicProductServicePublicDuplicateProductResult(%+v)", *p) } + +type PublicProductServicePublicSearchProductArgs struct { + Req *SearchProductRequest `thrift:"req,1"` +} + +func NewPublicProductServicePublicSearchProductArgs() *PublicProductServicePublicSearchProductArgs { + return &PublicProductServicePublicSearchProductArgs{} +} + +func (p *PublicProductServicePublicSearchProductArgs) InitDefault() { +} + +var PublicProductServicePublicSearchProductArgs_Req_DEFAULT *SearchProductRequest + +func (p *PublicProductServicePublicSearchProductArgs) GetReq() (v *SearchProductRequest) { + if !p.IsSetReq() { + return PublicProductServicePublicSearchProductArgs_Req_DEFAULT + } + return p.Req +} + +var fieldIDToName_PublicProductServicePublicSearchProductArgs = map[int16]string{ + 1: "req", +} + +func (p *PublicProductServicePublicSearchProductArgs) IsSetReq() bool { + return p.Req != nil +} + +func (p *PublicProductServicePublicSearchProductArgs) Read(iprot thrift.TProtocol) (err error) { + var fieldTypeId thrift.TType + var fieldId int16 + + if _, err = iprot.ReadStructBegin(); err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + + switch fieldId { + case 1: + if fieldTypeId == thrift.STRUCT { + if err = p.ReadField1(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + default: + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + } + if err = iprot.ReadFieldEnd(); err != nil { + goto ReadFieldEndError + } + } + if err = iprot.ReadStructEnd(); err != nil { + goto ReadStructEndError + } + + return nil +ReadStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_PublicProductServicePublicSearchProductArgs[fieldId]), err) +SkipFieldError: + return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) + +ReadFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *PublicProductServicePublicSearchProductArgs) ReadField1(iprot thrift.TProtocol) error { + _field := NewSearchProductRequest() + if err := _field.Read(iprot); err != nil { + return err + } + p.Req = _field + return nil +} + +func (p *PublicProductServicePublicSearchProductArgs) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("PublicSearchProduct_args"); err != nil { + goto WriteStructBeginError + } + if p != nil { + if err = p.writeField1(oprot); err != nil { + fieldId = 1 + goto WriteFieldError + } + } + if err = oprot.WriteFieldStop(); err != nil { + goto WriteFieldStopError + } + if err = oprot.WriteStructEnd(); err != nil { + goto WriteStructEndError + } + return nil +WriteStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) +WriteFieldError: + return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) +WriteFieldStopError: + return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) +WriteStructEndError: + return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) +} + +func (p *PublicProductServicePublicSearchProductArgs) writeField1(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("req", thrift.STRUCT, 1); err != nil { + goto WriteFieldBeginError + } + if err := p.Req.Write(oprot); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) +} + +func (p *PublicProductServicePublicSearchProductArgs) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("PublicProductServicePublicSearchProductArgs(%+v)", *p) + +} + +type PublicProductServicePublicSearchProductResult struct { + Success *SearchProductResponse `thrift:"success,0,optional"` +} + +func NewPublicProductServicePublicSearchProductResult() *PublicProductServicePublicSearchProductResult { + return &PublicProductServicePublicSearchProductResult{} +} + +func (p *PublicProductServicePublicSearchProductResult) InitDefault() { +} + +var PublicProductServicePublicSearchProductResult_Success_DEFAULT *SearchProductResponse + +func (p *PublicProductServicePublicSearchProductResult) GetSuccess() (v *SearchProductResponse) { + if !p.IsSetSuccess() { + return PublicProductServicePublicSearchProductResult_Success_DEFAULT + } + return p.Success +} + +var fieldIDToName_PublicProductServicePublicSearchProductResult = map[int16]string{ + 0: "success", +} + +func (p *PublicProductServicePublicSearchProductResult) IsSetSuccess() bool { + return p.Success != nil +} + +func (p *PublicProductServicePublicSearchProductResult) Read(iprot thrift.TProtocol) (err error) { + var fieldTypeId thrift.TType + var fieldId int16 + + if _, err = iprot.ReadStructBegin(); err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + + switch fieldId { + case 0: + if fieldTypeId == thrift.STRUCT { + if err = p.ReadField0(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + default: + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + } + if err = iprot.ReadFieldEnd(); err != nil { + goto ReadFieldEndError + } + } + if err = iprot.ReadStructEnd(); err != nil { + goto ReadStructEndError + } + + return nil +ReadStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_PublicProductServicePublicSearchProductResult[fieldId]), err) +SkipFieldError: + return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) + +ReadFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *PublicProductServicePublicSearchProductResult) ReadField0(iprot thrift.TProtocol) error { + _field := NewSearchProductResponse() + if err := _field.Read(iprot); err != nil { + return err + } + p.Success = _field + return nil +} + +func (p *PublicProductServicePublicSearchProductResult) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("PublicSearchProduct_result"); err != nil { + goto WriteStructBeginError + } + if p != nil { + if err = p.writeField0(oprot); err != nil { + fieldId = 0 + goto WriteFieldError + } + } + if err = oprot.WriteFieldStop(); err != nil { + goto WriteFieldStopError + } + if err = oprot.WriteStructEnd(); err != nil { + goto WriteStructEndError + } + return nil +WriteStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) +WriteFieldError: + return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) +WriteFieldStopError: + return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) +WriteStructEndError: + return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) +} + +func (p *PublicProductServicePublicSearchProductResult) writeField0(oprot thrift.TProtocol) (err error) { + if p.IsSetSuccess() { + if err = oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { + goto WriteFieldBeginError + } + if err := p.Success.Write(oprot); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 0 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 0 end error: ", p), err) +} + +func (p *PublicProductServicePublicSearchProductResult) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("PublicProductServicePublicSearchProductResult(%+v)", *p) + +} + +type PublicProductServicePublicSearchSuggestArgs struct { + Req *SearchSuggestRequest `thrift:"req,1"` +} + +func NewPublicProductServicePublicSearchSuggestArgs() *PublicProductServicePublicSearchSuggestArgs { + return &PublicProductServicePublicSearchSuggestArgs{} +} + +func (p *PublicProductServicePublicSearchSuggestArgs) InitDefault() { +} + +var PublicProductServicePublicSearchSuggestArgs_Req_DEFAULT *SearchSuggestRequest + +func (p *PublicProductServicePublicSearchSuggestArgs) GetReq() (v *SearchSuggestRequest) { + if !p.IsSetReq() { + return PublicProductServicePublicSearchSuggestArgs_Req_DEFAULT + } + return p.Req +} + +var fieldIDToName_PublicProductServicePublicSearchSuggestArgs = map[int16]string{ + 1: "req", +} + +func (p *PublicProductServicePublicSearchSuggestArgs) IsSetReq() bool { + return p.Req != nil +} + +func (p *PublicProductServicePublicSearchSuggestArgs) Read(iprot thrift.TProtocol) (err error) { + var fieldTypeId thrift.TType + var fieldId int16 + + if _, err = iprot.ReadStructBegin(); err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + + switch fieldId { + case 1: + if fieldTypeId == thrift.STRUCT { + if err = p.ReadField1(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + default: + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + } + if err = iprot.ReadFieldEnd(); err != nil { + goto ReadFieldEndError + } + } + if err = iprot.ReadStructEnd(); err != nil { + goto ReadStructEndError + } + + return nil +ReadStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_PublicProductServicePublicSearchSuggestArgs[fieldId]), err) +SkipFieldError: + return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) + +ReadFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *PublicProductServicePublicSearchSuggestArgs) ReadField1(iprot thrift.TProtocol) error { + _field := NewSearchSuggestRequest() + if err := _field.Read(iprot); err != nil { + return err + } + p.Req = _field + return nil +} + +func (p *PublicProductServicePublicSearchSuggestArgs) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("PublicSearchSuggest_args"); err != nil { + goto WriteStructBeginError + } + if p != nil { + if err = p.writeField1(oprot); err != nil { + fieldId = 1 + goto WriteFieldError + } + } + if err = oprot.WriteFieldStop(); err != nil { + goto WriteFieldStopError + } + if err = oprot.WriteStructEnd(); err != nil { + goto WriteStructEndError + } + return nil +WriteStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) +WriteFieldError: + return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) +WriteFieldStopError: + return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) +WriteStructEndError: + return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) +} + +func (p *PublicProductServicePublicSearchSuggestArgs) writeField1(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("req", thrift.STRUCT, 1); err != nil { + goto WriteFieldBeginError + } + if err := p.Req.Write(oprot); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) +} + +func (p *PublicProductServicePublicSearchSuggestArgs) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("PublicProductServicePublicSearchSuggestArgs(%+v)", *p) + +} + +type PublicProductServicePublicSearchSuggestResult struct { + Success *SearchSuggestResponse `thrift:"success,0,optional"` +} + +func NewPublicProductServicePublicSearchSuggestResult() *PublicProductServicePublicSearchSuggestResult { + return &PublicProductServicePublicSearchSuggestResult{} +} + +func (p *PublicProductServicePublicSearchSuggestResult) InitDefault() { +} + +var PublicProductServicePublicSearchSuggestResult_Success_DEFAULT *SearchSuggestResponse + +func (p *PublicProductServicePublicSearchSuggestResult) GetSuccess() (v *SearchSuggestResponse) { + if !p.IsSetSuccess() { + return PublicProductServicePublicSearchSuggestResult_Success_DEFAULT + } + return p.Success +} + +var fieldIDToName_PublicProductServicePublicSearchSuggestResult = map[int16]string{ + 0: "success", +} + +func (p *PublicProductServicePublicSearchSuggestResult) IsSetSuccess() bool { + return p.Success != nil +} + +func (p *PublicProductServicePublicSearchSuggestResult) Read(iprot thrift.TProtocol) (err error) { + var fieldTypeId thrift.TType + var fieldId int16 + + if _, err = iprot.ReadStructBegin(); err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + + switch fieldId { + case 0: + if fieldTypeId == thrift.STRUCT { + if err = p.ReadField0(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + default: + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + } + if err = iprot.ReadFieldEnd(); err != nil { + goto ReadFieldEndError + } + } + if err = iprot.ReadStructEnd(); err != nil { + goto ReadStructEndError + } + + return nil +ReadStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_PublicProductServicePublicSearchSuggestResult[fieldId]), err) +SkipFieldError: + return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) + +ReadFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *PublicProductServicePublicSearchSuggestResult) ReadField0(iprot thrift.TProtocol) error { + _field := NewSearchSuggestResponse() + if err := _field.Read(iprot); err != nil { + return err + } + p.Success = _field + return nil +} + +func (p *PublicProductServicePublicSearchSuggestResult) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("PublicSearchSuggest_result"); err != nil { + goto WriteStructBeginError + } + if p != nil { + if err = p.writeField0(oprot); err != nil { + fieldId = 0 + goto WriteFieldError + } + } + if err = oprot.WriteFieldStop(); err != nil { + goto WriteFieldStopError + } + if err = oprot.WriteStructEnd(); err != nil { + goto WriteStructEndError + } + return nil +WriteStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) +WriteFieldError: + return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) +WriteFieldStopError: + return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) +WriteStructEndError: + return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) +} + +func (p *PublicProductServicePublicSearchSuggestResult) writeField0(oprot thrift.TProtocol) (err error) { + if p.IsSetSuccess() { + if err = oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { + goto WriteFieldBeginError + } + if err := p.Success.Write(oprot); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 0 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 0 end error: ", p), err) +} + +func (p *PublicProductServicePublicSearchSuggestResult) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("PublicProductServicePublicSearchSuggestResult(%+v)", *p) + +} + +type PublicProductServicePublicGetProductCategoryListArgs struct { + Req *GetProductCategoryListRequest `thrift:"req,1"` +} + +func NewPublicProductServicePublicGetProductCategoryListArgs() *PublicProductServicePublicGetProductCategoryListArgs { + return &PublicProductServicePublicGetProductCategoryListArgs{} +} + +func (p *PublicProductServicePublicGetProductCategoryListArgs) InitDefault() { +} + +var PublicProductServicePublicGetProductCategoryListArgs_Req_DEFAULT *GetProductCategoryListRequest + +func (p *PublicProductServicePublicGetProductCategoryListArgs) GetReq() (v *GetProductCategoryListRequest) { + if !p.IsSetReq() { + return PublicProductServicePublicGetProductCategoryListArgs_Req_DEFAULT + } + return p.Req +} + +var fieldIDToName_PublicProductServicePublicGetProductCategoryListArgs = map[int16]string{ + 1: "req", +} + +func (p *PublicProductServicePublicGetProductCategoryListArgs) IsSetReq() bool { + return p.Req != nil +} + +func (p *PublicProductServicePublicGetProductCategoryListArgs) Read(iprot thrift.TProtocol) (err error) { + var fieldTypeId thrift.TType + var fieldId int16 + + if _, err = iprot.ReadStructBegin(); err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + + switch fieldId { + case 1: + if fieldTypeId == thrift.STRUCT { + if err = p.ReadField1(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + default: + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + } + if err = iprot.ReadFieldEnd(); err != nil { + goto ReadFieldEndError + } + } + if err = iprot.ReadStructEnd(); err != nil { + goto ReadStructEndError + } + + return nil +ReadStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_PublicProductServicePublicGetProductCategoryListArgs[fieldId]), err) +SkipFieldError: + return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) + +ReadFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *PublicProductServicePublicGetProductCategoryListArgs) ReadField1(iprot thrift.TProtocol) error { + _field := NewGetProductCategoryListRequest() + if err := _field.Read(iprot); err != nil { + return err + } + p.Req = _field + return nil +} + +func (p *PublicProductServicePublicGetProductCategoryListArgs) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("PublicGetProductCategoryList_args"); err != nil { + goto WriteStructBeginError + } + if p != nil { + if err = p.writeField1(oprot); err != nil { + fieldId = 1 + goto WriteFieldError + } + } + if err = oprot.WriteFieldStop(); err != nil { + goto WriteFieldStopError + } + if err = oprot.WriteStructEnd(); err != nil { + goto WriteStructEndError + } + return nil +WriteStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) +WriteFieldError: + return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) +WriteFieldStopError: + return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) +WriteStructEndError: + return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) +} + +func (p *PublicProductServicePublicGetProductCategoryListArgs) writeField1(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("req", thrift.STRUCT, 1); err != nil { + goto WriteFieldBeginError + } + if err := p.Req.Write(oprot); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) +} + +func (p *PublicProductServicePublicGetProductCategoryListArgs) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("PublicProductServicePublicGetProductCategoryListArgs(%+v)", *p) + +} + +type PublicProductServicePublicGetProductCategoryListResult struct { + Success *GetProductCategoryListResponse `thrift:"success,0,optional"` +} + +func NewPublicProductServicePublicGetProductCategoryListResult() *PublicProductServicePublicGetProductCategoryListResult { + return &PublicProductServicePublicGetProductCategoryListResult{} +} + +func (p *PublicProductServicePublicGetProductCategoryListResult) InitDefault() { +} + +var PublicProductServicePublicGetProductCategoryListResult_Success_DEFAULT *GetProductCategoryListResponse + +func (p *PublicProductServicePublicGetProductCategoryListResult) GetSuccess() (v *GetProductCategoryListResponse) { + if !p.IsSetSuccess() { + return PublicProductServicePublicGetProductCategoryListResult_Success_DEFAULT + } + return p.Success +} + +var fieldIDToName_PublicProductServicePublicGetProductCategoryListResult = map[int16]string{ + 0: "success", +} + +func (p *PublicProductServicePublicGetProductCategoryListResult) IsSetSuccess() bool { + return p.Success != nil +} + +func (p *PublicProductServicePublicGetProductCategoryListResult) Read(iprot thrift.TProtocol) (err error) { + var fieldTypeId thrift.TType + var fieldId int16 + + if _, err = iprot.ReadStructBegin(); err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + + switch fieldId { + case 0: + if fieldTypeId == thrift.STRUCT { + if err = p.ReadField0(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + default: + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + } + if err = iprot.ReadFieldEnd(); err != nil { + goto ReadFieldEndError + } + } + if err = iprot.ReadStructEnd(); err != nil { + goto ReadStructEndError + } + + return nil +ReadStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_PublicProductServicePublicGetProductCategoryListResult[fieldId]), err) +SkipFieldError: + return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) + +ReadFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *PublicProductServicePublicGetProductCategoryListResult) ReadField0(iprot thrift.TProtocol) error { + _field := NewGetProductCategoryListResponse() + if err := _field.Read(iprot); err != nil { + return err + } + p.Success = _field + return nil +} + +func (p *PublicProductServicePublicGetProductCategoryListResult) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("PublicGetProductCategoryList_result"); err != nil { + goto WriteStructBeginError + } + if p != nil { + if err = p.writeField0(oprot); err != nil { + fieldId = 0 + goto WriteFieldError + } + } + if err = oprot.WriteFieldStop(); err != nil { + goto WriteFieldStopError + } + if err = oprot.WriteStructEnd(); err != nil { + goto WriteStructEndError + } + return nil +WriteStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) +WriteFieldError: + return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) +WriteFieldStopError: + return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) +WriteStructEndError: + return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) +} + +func (p *PublicProductServicePublicGetProductCategoryListResult) writeField0(oprot thrift.TProtocol) (err error) { + if p.IsSetSuccess() { + if err = oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { + goto WriteFieldBeginError + } + if err := p.Success.Write(oprot); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 0 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 0 end error: ", p), err) +} + +func (p *PublicProductServicePublicGetProductCategoryListResult) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("PublicProductServicePublicGetProductCategoryListResult(%+v)", *p) + +} + +type PublicProductServicePublicGetProductCallInfoArgs struct { + Req *GetProductCallInfoRequest `thrift:"req,1"` +} + +func NewPublicProductServicePublicGetProductCallInfoArgs() *PublicProductServicePublicGetProductCallInfoArgs { + return &PublicProductServicePublicGetProductCallInfoArgs{} +} + +func (p *PublicProductServicePublicGetProductCallInfoArgs) InitDefault() { +} + +var PublicProductServicePublicGetProductCallInfoArgs_Req_DEFAULT *GetProductCallInfoRequest + +func (p *PublicProductServicePublicGetProductCallInfoArgs) GetReq() (v *GetProductCallInfoRequest) { + if !p.IsSetReq() { + return PublicProductServicePublicGetProductCallInfoArgs_Req_DEFAULT + } + return p.Req +} + +var fieldIDToName_PublicProductServicePublicGetProductCallInfoArgs = map[int16]string{ + 1: "req", +} + +func (p *PublicProductServicePublicGetProductCallInfoArgs) IsSetReq() bool { + return p.Req != nil +} + +func (p *PublicProductServicePublicGetProductCallInfoArgs) Read(iprot thrift.TProtocol) (err error) { + var fieldTypeId thrift.TType + var fieldId int16 + + if _, err = iprot.ReadStructBegin(); err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + + switch fieldId { + case 1: + if fieldTypeId == thrift.STRUCT { + if err = p.ReadField1(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + default: + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + } + if err = iprot.ReadFieldEnd(); err != nil { + goto ReadFieldEndError + } + } + if err = iprot.ReadStructEnd(); err != nil { + goto ReadStructEndError + } + + return nil +ReadStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_PublicProductServicePublicGetProductCallInfoArgs[fieldId]), err) +SkipFieldError: + return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) + +ReadFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *PublicProductServicePublicGetProductCallInfoArgs) ReadField1(iprot thrift.TProtocol) error { + _field := NewGetProductCallInfoRequest() + if err := _field.Read(iprot); err != nil { + return err + } + p.Req = _field + return nil +} + +func (p *PublicProductServicePublicGetProductCallInfoArgs) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("PublicGetProductCallInfo_args"); err != nil { + goto WriteStructBeginError + } + if p != nil { + if err = p.writeField1(oprot); err != nil { + fieldId = 1 + goto WriteFieldError + } + } + if err = oprot.WriteFieldStop(); err != nil { + goto WriteFieldStopError + } + if err = oprot.WriteStructEnd(); err != nil { + goto WriteStructEndError + } + return nil +WriteStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) +WriteFieldError: + return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) +WriteFieldStopError: + return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) +WriteStructEndError: + return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) +} + +func (p *PublicProductServicePublicGetProductCallInfoArgs) writeField1(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("req", thrift.STRUCT, 1); err != nil { + goto WriteFieldBeginError + } + if err := p.Req.Write(oprot); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) +} + +func (p *PublicProductServicePublicGetProductCallInfoArgs) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("PublicProductServicePublicGetProductCallInfoArgs(%+v)", *p) + +} + +type PublicProductServicePublicGetProductCallInfoResult struct { + Success *GetProductCallInfoResponse `thrift:"success,0,optional"` +} + +func NewPublicProductServicePublicGetProductCallInfoResult() *PublicProductServicePublicGetProductCallInfoResult { + return &PublicProductServicePublicGetProductCallInfoResult{} +} + +func (p *PublicProductServicePublicGetProductCallInfoResult) InitDefault() { +} + +var PublicProductServicePublicGetProductCallInfoResult_Success_DEFAULT *GetProductCallInfoResponse + +func (p *PublicProductServicePublicGetProductCallInfoResult) GetSuccess() (v *GetProductCallInfoResponse) { + if !p.IsSetSuccess() { + return PublicProductServicePublicGetProductCallInfoResult_Success_DEFAULT + } + return p.Success +} + +var fieldIDToName_PublicProductServicePublicGetProductCallInfoResult = map[int16]string{ + 0: "success", +} + +func (p *PublicProductServicePublicGetProductCallInfoResult) IsSetSuccess() bool { + return p.Success != nil +} + +func (p *PublicProductServicePublicGetProductCallInfoResult) Read(iprot thrift.TProtocol) (err error) { + var fieldTypeId thrift.TType + var fieldId int16 + + if _, err = iprot.ReadStructBegin(); err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + + switch fieldId { + case 0: + if fieldTypeId == thrift.STRUCT { + if err = p.ReadField0(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + default: + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + } + if err = iprot.ReadFieldEnd(); err != nil { + goto ReadFieldEndError + } + } + if err = iprot.ReadStructEnd(); err != nil { + goto ReadStructEndError + } + + return nil +ReadStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_PublicProductServicePublicGetProductCallInfoResult[fieldId]), err) +SkipFieldError: + return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) + +ReadFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *PublicProductServicePublicGetProductCallInfoResult) ReadField0(iprot thrift.TProtocol) error { + _field := NewGetProductCallInfoResponse() + if err := _field.Read(iprot); err != nil { + return err + } + p.Success = _field + return nil +} + +func (p *PublicProductServicePublicGetProductCallInfoResult) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("PublicGetProductCallInfo_result"); err != nil { + goto WriteStructBeginError + } + if p != nil { + if err = p.writeField0(oprot); err != nil { + fieldId = 0 + goto WriteFieldError + } + } + if err = oprot.WriteFieldStop(); err != nil { + goto WriteFieldStopError + } + if err = oprot.WriteStructEnd(); err != nil { + goto WriteStructEndError + } + return nil +WriteStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) +WriteFieldError: + return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) +WriteFieldStopError: + return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) +WriteStructEndError: + return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) +} + +func (p *PublicProductServicePublicGetProductCallInfoResult) writeField0(oprot thrift.TProtocol) (err error) { + if p.IsSetSuccess() { + if err = oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { + goto WriteFieldBeginError + } + if err := p.Success.Write(oprot); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 0 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 0 end error: ", p), err) +} + +func (p *PublicProductServicePublicGetProductCallInfoResult) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("PublicProductServicePublicGetProductCallInfoResult(%+v)", *p) + +} + +type PublicProductServicePublicGetMarketPluginConfigArgs struct { + Req *GetMarketPluginConfigRequest `thrift:"req,1"` +} + +func NewPublicProductServicePublicGetMarketPluginConfigArgs() *PublicProductServicePublicGetMarketPluginConfigArgs { + return &PublicProductServicePublicGetMarketPluginConfigArgs{} +} + +func (p *PublicProductServicePublicGetMarketPluginConfigArgs) InitDefault() { +} + +var PublicProductServicePublicGetMarketPluginConfigArgs_Req_DEFAULT *GetMarketPluginConfigRequest + +func (p *PublicProductServicePublicGetMarketPluginConfigArgs) GetReq() (v *GetMarketPluginConfigRequest) { + if !p.IsSetReq() { + return PublicProductServicePublicGetMarketPluginConfigArgs_Req_DEFAULT + } + return p.Req +} + +var fieldIDToName_PublicProductServicePublicGetMarketPluginConfigArgs = map[int16]string{ + 1: "req", +} + +func (p *PublicProductServicePublicGetMarketPluginConfigArgs) IsSetReq() bool { + return p.Req != nil +} + +func (p *PublicProductServicePublicGetMarketPluginConfigArgs) Read(iprot thrift.TProtocol) (err error) { + var fieldTypeId thrift.TType + var fieldId int16 + + if _, err = iprot.ReadStructBegin(); err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + + switch fieldId { + case 1: + if fieldTypeId == thrift.STRUCT { + if err = p.ReadField1(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + default: + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + } + if err = iprot.ReadFieldEnd(); err != nil { + goto ReadFieldEndError + } + } + if err = iprot.ReadStructEnd(); err != nil { + goto ReadStructEndError + } + + return nil +ReadStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_PublicProductServicePublicGetMarketPluginConfigArgs[fieldId]), err) +SkipFieldError: + return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) + +ReadFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *PublicProductServicePublicGetMarketPluginConfigArgs) ReadField1(iprot thrift.TProtocol) error { + _field := NewGetMarketPluginConfigRequest() + if err := _field.Read(iprot); err != nil { + return err + } + p.Req = _field + return nil +} + +func (p *PublicProductServicePublicGetMarketPluginConfigArgs) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("PublicGetMarketPluginConfig_args"); err != nil { + goto WriteStructBeginError + } + if p != nil { + if err = p.writeField1(oprot); err != nil { + fieldId = 1 + goto WriteFieldError + } + } + if err = oprot.WriteFieldStop(); err != nil { + goto WriteFieldStopError + } + if err = oprot.WriteStructEnd(); err != nil { + goto WriteStructEndError + } + return nil +WriteStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) +WriteFieldError: + return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) +WriteFieldStopError: + return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) +WriteStructEndError: + return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) +} + +func (p *PublicProductServicePublicGetMarketPluginConfigArgs) writeField1(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("req", thrift.STRUCT, 1); err != nil { + goto WriteFieldBeginError + } + if err := p.Req.Write(oprot); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) +} + +func (p *PublicProductServicePublicGetMarketPluginConfigArgs) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("PublicProductServicePublicGetMarketPluginConfigArgs(%+v)", *p) + +} + +type PublicProductServicePublicGetMarketPluginConfigResult struct { + Success *GetMarketPluginConfigResponse `thrift:"success,0,optional"` +} + +func NewPublicProductServicePublicGetMarketPluginConfigResult() *PublicProductServicePublicGetMarketPluginConfigResult { + return &PublicProductServicePublicGetMarketPluginConfigResult{} +} + +func (p *PublicProductServicePublicGetMarketPluginConfigResult) InitDefault() { +} + +var PublicProductServicePublicGetMarketPluginConfigResult_Success_DEFAULT *GetMarketPluginConfigResponse + +func (p *PublicProductServicePublicGetMarketPluginConfigResult) GetSuccess() (v *GetMarketPluginConfigResponse) { + if !p.IsSetSuccess() { + return PublicProductServicePublicGetMarketPluginConfigResult_Success_DEFAULT + } + return p.Success +} + +var fieldIDToName_PublicProductServicePublicGetMarketPluginConfigResult = map[int16]string{ + 0: "success", +} + +func (p *PublicProductServicePublicGetMarketPluginConfigResult) IsSetSuccess() bool { + return p.Success != nil +} + +func (p *PublicProductServicePublicGetMarketPluginConfigResult) Read(iprot thrift.TProtocol) (err error) { + var fieldTypeId thrift.TType + var fieldId int16 + + if _, err = iprot.ReadStructBegin(); err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + + switch fieldId { + case 0: + if fieldTypeId == thrift.STRUCT { + if err = p.ReadField0(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + default: + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + } + if err = iprot.ReadFieldEnd(); err != nil { + goto ReadFieldEndError + } + } + if err = iprot.ReadStructEnd(); err != nil { + goto ReadStructEndError + } + + return nil +ReadStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_PublicProductServicePublicGetMarketPluginConfigResult[fieldId]), err) +SkipFieldError: + return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) + +ReadFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *PublicProductServicePublicGetMarketPluginConfigResult) ReadField0(iprot thrift.TProtocol) error { + _field := NewGetMarketPluginConfigResponse() + if err := _field.Read(iprot); err != nil { + return err + } + p.Success = _field + return nil +} + +func (p *PublicProductServicePublicGetMarketPluginConfigResult) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("PublicGetMarketPluginConfig_result"); err != nil { + goto WriteStructBeginError + } + if p != nil { + if err = p.writeField0(oprot); err != nil { + fieldId = 0 + goto WriteFieldError + } + } + if err = oprot.WriteFieldStop(); err != nil { + goto WriteFieldStopError + } + if err = oprot.WriteStructEnd(); err != nil { + goto WriteStructEndError + } + return nil +WriteStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) +WriteFieldError: + return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) +WriteFieldStopError: + return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) +WriteStructEndError: + return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) +} + +func (p *PublicProductServicePublicGetMarketPluginConfigResult) writeField0(oprot thrift.TProtocol) (err error) { + if p.IsSetSuccess() { + if err = oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { + goto WriteFieldBeginError + } + if err := p.Success.Write(oprot); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 0 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 0 end error: ", p), err) +} + +func (p *PublicProductServicePublicGetMarketPluginConfigResult) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("PublicProductServicePublicGetMarketPluginConfigResult(%+v)", *p) + +} diff --git a/backend/api/model/playground/playground.go b/backend/api/model/playground/playground.go index 421341f4d..95ec2f537 100644 --- a/backend/api/model/playground/playground.go +++ b/backend/api/model/playground/playground.go @@ -23,7 +23,6 @@ import ( "database/sql" "database/sql/driver" "fmt" - "github.com/apache/thrift/lib/go/thrift" "github.com/coze-dev/coze-studio/backend/api/model/app/bot_common" "github.com/coze-dev/coze-studio/backend/api/model/base" @@ -4534,6 +4533,8 @@ type PluginDetal struct { PluginType *int64 `thrift:"plugin_type,5,optional" form:"plugin_type" json:"plugin_type,string,omitempty" query:"plugin_type"` PluginStatus *int64 `thrift:"plugin_status,6,optional" form:"plugin_status" json:"plugin_status,string,omitempty" query:"plugin_status"` IsOfficial *bool `thrift:"is_official,7,optional" form:"is_official" json:"is_official,omitempty" query:"is_official"` + // + PluginFrom *bot_common.PluginFrom `thrift:"plugin_from,9,optional" form:"plugin_from" json:"plugin_from,omitempty" query:"plugin_from"` } func NewPluginDetal() *PluginDetal { @@ -4606,6 +4607,15 @@ func (p *PluginDetal) GetIsOfficial() (v bool) { return *p.IsOfficial } +var PluginDetal_PluginFrom_DEFAULT bot_common.PluginFrom + +func (p *PluginDetal) GetPluginFrom() (v bot_common.PluginFrom) { + if !p.IsSetPluginFrom() { + return PluginDetal_PluginFrom_DEFAULT + } + return *p.PluginFrom +} + var fieldIDToName_PluginDetal = map[int16]string{ 1: "id", 2: "name", @@ -4614,6 +4624,7 @@ var fieldIDToName_PluginDetal = map[int16]string{ 5: "plugin_type", 6: "plugin_status", 7: "is_official", + 9: "plugin_from", } func (p *PluginDetal) IsSetID() bool { @@ -4644,6 +4655,10 @@ func (p *PluginDetal) IsSetIsOfficial() bool { return p.IsOfficial != nil } +func (p *PluginDetal) IsSetPluginFrom() bool { + return p.PluginFrom != nil +} + func (p *PluginDetal) Read(iprot thrift.TProtocol) (err error) { var fieldTypeId thrift.TType var fieldId int16 @@ -4718,6 +4733,14 @@ func (p *PluginDetal) Read(iprot thrift.TProtocol) (err error) { } else if err = iprot.Skip(fieldTypeId); err != nil { goto SkipFieldError } + case 9: + if fieldTypeId == thrift.I32 { + if err = p.ReadField9(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } default: if err = iprot.Skip(fieldTypeId); err != nil { goto SkipFieldError @@ -4824,6 +4847,18 @@ func (p *PluginDetal) ReadField7(iprot thrift.TProtocol) error { p.IsOfficial = _field return nil } +func (p *PluginDetal) ReadField9(iprot thrift.TProtocol) error { + + var _field *bot_common.PluginFrom + if v, err := iprot.ReadI32(); err != nil { + return err + } else { + tmp := bot_common.PluginFrom(v) + _field = &tmp + } + p.PluginFrom = _field + return nil +} func (p *PluginDetal) Write(oprot thrift.TProtocol) (err error) { var fieldId int16 @@ -4859,6 +4894,10 @@ func (p *PluginDetal) Write(oprot thrift.TProtocol) (err error) { fieldId = 7 goto WriteFieldError } + if err = p.writeField9(oprot); err != nil { + fieldId = 9 + goto WriteFieldError + } } if err = oprot.WriteFieldStop(); err != nil { goto WriteFieldStopError @@ -5003,6 +5042,24 @@ WriteFieldBeginError: WriteFieldEndError: return thrift.PrependError(fmt.Sprintf("%T write field 7 end error: ", p), err) } +func (p *PluginDetal) writeField9(oprot thrift.TProtocol) (err error) { + if p.IsSetPluginFrom() { + if err = oprot.WriteFieldBegin("plugin_from", thrift.I32, 9); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteI32(int32(*p.PluginFrom)); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 9 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 9 end error: ", p), err) +} func (p *PluginDetal) String() string { if p == nil { diff --git a/backend/api/model/playground/shortcut_command.go b/backend/api/model/playground/shortcut_command.go index be5b54596..1d21e1f69 100644 --- a/backend/api/model/playground/shortcut_command.go +++ b/backend/api/model/playground/shortcut_command.go @@ -1,3 +1,19 @@ +/* + * Copyright 2025 coze-dev Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + // Code generated by thriftgo (0.4.1). DO NOT EDIT. package playground @@ -7,6 +23,7 @@ import ( "database/sql/driver" "fmt" "github.com/apache/thrift/lib/go/thrift" + "github.com/coze-dev/coze-studio/backend/api/model/app/bot_common" "github.com/coze-dev/coze-studio/backend/api/model/base" ) @@ -912,8 +929,9 @@ type ShortcutCommand struct { // command icon ShortcutIcon *ShortcutFileInfo `thrift:"shortcut_icon,18" form:"shortcut_icon" json:"shortcut_icon" query:"shortcut_icon"` //Multi instruction, which node executes the instruction - AgentID *string `thrift:"agent_id,21,optional" form:"agent_id" json:"agent_id,omitempty" query:"agent_id"` - PluginAPIID int64 `thrift:"plugin_api_id,22" form:"plugin_api_id" json:"plugin_api_id,string" query:"plugin_api_id"` + AgentID *string `thrift:"agent_id,21,optional" form:"agent_id" json:"agent_id,omitempty" query:"agent_id"` + PluginAPIID int64 `thrift:"plugin_api_id,22" form:"plugin_api_id" json:"plugin_api_id,string" query:"plugin_api_id"` + PluginFrom *bot_common.PluginFrom `thrift:"plugin_from,23,optional" form:"plugin_from" json:"plugin_from,omitempty" query:"plugin_from"` } func NewShortcutCommand() *ShortcutCommand { @@ -1006,6 +1024,15 @@ func (p *ShortcutCommand) GetPluginAPIID() (v int64) { return p.PluginAPIID } +var ShortcutCommand_PluginFrom_DEFAULT bot_common.PluginFrom + +func (p *ShortcutCommand) GetPluginFrom() (v bot_common.PluginFrom) { + if !p.IsSetPluginFrom() { + return ShortcutCommand_PluginFrom_DEFAULT + } + return *p.PluginFrom +} + var fieldIDToName_ShortcutCommand = map[int16]string{ 2: "object_id", 3: "command_name", @@ -1024,6 +1051,7 @@ var fieldIDToName_ShortcutCommand = map[int16]string{ 18: "shortcut_icon", 21: "agent_id", 22: "plugin_api_id", + 23: "plugin_from", } func (p *ShortcutCommand) IsSetToolInfo() bool { @@ -1038,6 +1066,10 @@ func (p *ShortcutCommand) IsSetAgentID() bool { return p.AgentID != nil } +func (p *ShortcutCommand) IsSetPluginFrom() bool { + return p.PluginFrom != nil +} + func (p *ShortcutCommand) Read(iprot thrift.TProtocol) (err error) { var fieldTypeId thrift.TType var fieldId int16 @@ -1192,6 +1224,14 @@ func (p *ShortcutCommand) Read(iprot thrift.TProtocol) (err error) { } else if err = iprot.Skip(fieldTypeId); err != nil { goto SkipFieldError } + case 23: + if fieldTypeId == thrift.I32 { + if err = p.ReadField23(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } default: if err = iprot.Skip(fieldTypeId); err != nil { goto SkipFieldError @@ -1414,6 +1454,18 @@ func (p *ShortcutCommand) ReadField22(iprot thrift.TProtocol) error { p.PluginAPIID = _field return nil } +func (p *ShortcutCommand) ReadField23(iprot thrift.TProtocol) error { + + var _field *bot_common.PluginFrom + if v, err := iprot.ReadI32(); err != nil { + return err + } else { + tmp := bot_common.PluginFrom(v) + _field = &tmp + } + p.PluginFrom = _field + return nil +} func (p *ShortcutCommand) Write(oprot thrift.TProtocol) (err error) { var fieldId int16 @@ -1489,6 +1541,10 @@ func (p *ShortcutCommand) Write(oprot thrift.TProtocol) (err error) { fieldId = 22 goto WriteFieldError } + if err = p.writeField23(oprot); err != nil { + fieldId = 23 + goto WriteFieldError + } } if err = oprot.WriteFieldStop(); err != nil { goto WriteFieldStopError @@ -1789,6 +1845,24 @@ WriteFieldBeginError: WriteFieldEndError: return thrift.PrependError(fmt.Sprintf("%T write field 22 end error: ", p), err) } +func (p *ShortcutCommand) writeField23(oprot thrift.TProtocol) (err error) { + if p.IsSetPluginFrom() { + if err = oprot.WriteFieldBegin("plugin_from", thrift.I32, 23); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteI32(int32(*p.PluginFrom)); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 23 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 23 end error: ", p), err) +} func (p *ShortcutCommand) String() string { if p == nil { diff --git a/backend/api/model/resource/common/resource_common.go b/backend/api/model/resource/common/resource_common.go index e82b3656d..5bd6168f9 100644 --- a/backend/api/model/resource/common/resource_common.go +++ b/backend/api/model/resource/common/resource_common.go @@ -1,3 +1,19 @@ +/* + * Copyright 2025 coze-dev Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + // Code generated by thriftgo (0.4.1). DO NOT EDIT. package common @@ -6,7 +22,6 @@ import ( "database/sql" "database/sql/driver" "fmt" - "github.com/apache/thrift/lib/go/thrift" ) diff --git a/backend/api/model/workflow/workflow.go b/backend/api/model/workflow/workflow.go index d69d84d8d..5f6b25b2e 100644 --- a/backend/api/model/workflow/workflow.go +++ b/backend/api/model/workflow/workflow.go @@ -22,8 +22,8 @@ import ( "database/sql" "database/sql/driver" "fmt" - "github.com/apache/thrift/lib/go/thrift" + "github.com/coze-dev/coze-studio/backend/api/model/app/bot_common" "github.com/coze-dev/coze-studio/backend/api/model/base" ) @@ -45023,13 +45023,14 @@ func (p *WorkflowNodeDebugV2Response) String() string { } type GetApiDetailRequest struct { - PluginID string `thrift:"pluginID,1" form:"pluginID" json:"pluginID" query:"pluginID"` - ApiName string `thrift:"apiName,2" form:"apiName" json:"apiName" query:"apiName"` - SpaceID string `thrift:"space_id,3" form:"space_id" json:"space_id" query:"space_id"` - APIID string `thrift:"api_id,4" form:"api_id" json:"api_id" query:"api_id"` - ProjectID *string `thrift:"project_id,5,optional" form:"project_id" json:"project_id,omitempty" query:"project_id"` - PluginVersion *string `thrift:"plugin_version,6,optional" form:"plugin_version" json:"plugin_version,omitempty" query:"plugin_version"` - Base *base.Base `thrift:"Base,255,optional" form:"Base" json:"Base,omitempty" query:"Base"` + PluginID string `thrift:"pluginID,1" form:"pluginID" json:"pluginID" query:"pluginID"` + ApiName string `thrift:"apiName,2" form:"apiName" json:"apiName" query:"apiName"` + SpaceID string `thrift:"space_id,3" form:"space_id" json:"space_id" query:"space_id"` + APIID string `thrift:"api_id,4" form:"api_id" json:"api_id" query:"api_id"` + ProjectID *string `thrift:"project_id,5,optional" form:"project_id" json:"project_id,omitempty" query:"project_id"` + PluginVersion *string `thrift:"plugin_version,6,optional" form:"plugin_version" json:"plugin_version,omitempty" query:"plugin_version"` + PluginFrom *bot_common.PluginFrom `thrift:"plugin_from,7,optional" form:"plugin_from" json:"plugin_from,omitempty" query:"plugin_from"` + Base *base.Base `thrift:"Base,255,optional" form:"Base" json:"Base,omitempty" query:"Base"` } func NewGetApiDetailRequest() *GetApiDetailRequest { @@ -45073,6 +45074,15 @@ func (p *GetApiDetailRequest) GetPluginVersion() (v string) { return *p.PluginVersion } +var GetApiDetailRequest_PluginFrom_DEFAULT bot_common.PluginFrom + +func (p *GetApiDetailRequest) GetPluginFrom() (v bot_common.PluginFrom) { + if !p.IsSetPluginFrom() { + return GetApiDetailRequest_PluginFrom_DEFAULT + } + return *p.PluginFrom +} + var GetApiDetailRequest_Base_DEFAULT *base.Base func (p *GetApiDetailRequest) GetBase() (v *base.Base) { @@ -45089,6 +45099,7 @@ var fieldIDToName_GetApiDetailRequest = map[int16]string{ 4: "api_id", 5: "project_id", 6: "plugin_version", + 7: "plugin_from", 255: "Base", } @@ -45100,6 +45111,10 @@ func (p *GetApiDetailRequest) IsSetPluginVersion() bool { return p.PluginVersion != nil } +func (p *GetApiDetailRequest) IsSetPluginFrom() bool { + return p.PluginFrom != nil +} + func (p *GetApiDetailRequest) IsSetBase() bool { return p.Base != nil } @@ -45170,6 +45185,14 @@ func (p *GetApiDetailRequest) Read(iprot thrift.TProtocol) (err error) { } else if err = iprot.Skip(fieldTypeId); err != nil { goto SkipFieldError } + case 7: + if fieldTypeId == thrift.I32 { + if err = p.ReadField7(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } case 255: if fieldTypeId == thrift.STRUCT { if err = p.ReadField255(iprot); err != nil { @@ -45273,6 +45296,18 @@ func (p *GetApiDetailRequest) ReadField6(iprot thrift.TProtocol) error { p.PluginVersion = _field return nil } +func (p *GetApiDetailRequest) ReadField7(iprot thrift.TProtocol) error { + + var _field *bot_common.PluginFrom + if v, err := iprot.ReadI32(); err != nil { + return err + } else { + tmp := bot_common.PluginFrom(v) + _field = &tmp + } + p.PluginFrom = _field + return nil +} func (p *GetApiDetailRequest) ReadField255(iprot thrift.TProtocol) error { _field := base.NewBase() if err := _field.Read(iprot); err != nil { @@ -45312,6 +45347,10 @@ func (p *GetApiDetailRequest) Write(oprot thrift.TProtocol) (err error) { fieldId = 6 goto WriteFieldError } + if err = p.writeField7(oprot); err != nil { + fieldId = 7 + goto WriteFieldError + } if err = p.writeField255(oprot); err != nil { fieldId = 255 goto WriteFieldError @@ -45434,6 +45473,24 @@ WriteFieldBeginError: WriteFieldEndError: return thrift.PrependError(fmt.Sprintf("%T write field 6 end error: ", p), err) } +func (p *GetApiDetailRequest) writeField7(oprot thrift.TProtocol) (err error) { + if p.IsSetPluginFrom() { + if err = oprot.WriteFieldBegin("plugin_from", thrift.I32, 7); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteI32(int32(*p.PluginFrom)); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 7 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 7 end error: ", p), err) +} func (p *GetApiDetailRequest) writeField255(oprot thrift.TProtocol) (err error) { if p.IsSetBase() { if err = oprot.WriteFieldBegin("Base", thrift.STRUCT, 255); err != nil { @@ -45646,24 +45703,25 @@ func (p *DebugExample) String() string { } type ApiDetailData struct { - PluginID string `thrift:"pluginID,1" form:"pluginID" json:"pluginID" query:"pluginID"` - ApiName string `thrift:"apiName,2" form:"apiName" json:"apiName" query:"apiName"` - Inputs string `thrift:"inputs,3" form:"inputs" json:"inputs" query:"inputs"` - Outputs string `thrift:"outputs,4" form:"outputs" json:"outputs" query:"outputs"` - Icon string `thrift:"icon,5" form:"icon" json:"icon" query:"icon"` - Name string `thrift:"name,6" form:"name" json:"name" query:"name"` - Desc string `thrift:"desc,7" form:"desc" json:"desc" query:"desc"` - PluginProductStatus int64 `thrift:"pluginProductStatus,8" form:"pluginProductStatus" json:"pluginProductStatus" query:"pluginProductStatus"` - PluginProductUnlistType int64 `thrift:"pluginProductUnlistType,9" form:"pluginProductUnlistType" json:"pluginProductUnlistType" query:"pluginProductUnlistType"` - SpaceID string `thrift:"spaceID,10" form:"spaceID" json:"spaceID" query:"spaceID"` - DebugExample *DebugExample `thrift:"debugExample,11,optional" form:"debugExample" json:"debugExample,omitempty" query:"debugExample"` - UpdateTime int64 `thrift:"updateTime,12" form:"updateTime" json:"updateTime" query:"updateTime"` - ProjectID *string `thrift:"projectID,13,optional" form:"projectID" json:"projectID,omitempty" query:"projectID"` - Version *string `thrift:"version,14,optional" form:"version" json:"version,omitempty" query:"version"` - PluginType PluginType `thrift:"pluginType,16" form:"pluginType" json:"pluginType" query:"pluginType"` - LatestVersion *string `thrift:"latest_version,17,optional" form:"latest_version" json:"latest_version,omitempty" query:"latest_version"` - LatestVersionName *string `thrift:"latest_version_name,18,optional" form:"latest_version_name" json:"latest_version_name,omitempty" query:"latest_version_name"` - VersionName *string `thrift:"version_name,19,optional" form:"version_name" json:"version_name,omitempty" query:"version_name"` + PluginID string `thrift:"pluginID,1" form:"pluginID" json:"pluginID" query:"pluginID"` + ApiName string `thrift:"apiName,2" form:"apiName" json:"apiName" query:"apiName"` + Inputs string `thrift:"inputs,3" form:"inputs" json:"inputs" query:"inputs"` + Outputs string `thrift:"outputs,4" form:"outputs" json:"outputs" query:"outputs"` + Icon string `thrift:"icon,5" form:"icon" json:"icon" query:"icon"` + Name string `thrift:"name,6" form:"name" json:"name" query:"name"` + Desc string `thrift:"desc,7" form:"desc" json:"desc" query:"desc"` + PluginProductStatus int64 `thrift:"pluginProductStatus,8" form:"pluginProductStatus" json:"pluginProductStatus" query:"pluginProductStatus"` + PluginProductUnlistType int64 `thrift:"pluginProductUnlistType,9" form:"pluginProductUnlistType" json:"pluginProductUnlistType" query:"pluginProductUnlistType"` + SpaceID string `thrift:"spaceID,10" form:"spaceID" json:"spaceID" query:"spaceID"` + DebugExample *DebugExample `thrift:"debugExample,11,optional" form:"debugExample" json:"debugExample,omitempty" query:"debugExample"` + UpdateTime int64 `thrift:"updateTime,12" form:"updateTime" json:"updateTime" query:"updateTime"` + ProjectID *string `thrift:"projectID,13,optional" form:"projectID" json:"projectID,omitempty" query:"projectID"` + Version *string `thrift:"version,14,optional" form:"version" json:"version,omitempty" query:"version"` + PluginType PluginType `thrift:"pluginType,16" form:"pluginType" json:"pluginType" query:"pluginType"` + LatestVersion *string `thrift:"latest_version,17,optional" form:"latest_version" json:"latest_version,omitempty" query:"latest_version"` + LatestVersionName *string `thrift:"latest_version_name,18,optional" form:"latest_version_name" json:"latest_version_name,omitempty" query:"latest_version_name"` + VersionName *string `thrift:"version_name,19,optional" form:"version_name" json:"version_name,omitempty" query:"version_name"` + PluginFrom *bot_common.PluginFrom `thrift:"plugin_from,50,optional" form:"plugin_from" json:"plugin_from,omitempty" query:"plugin_from"` } func NewApiDetailData() *ApiDetailData { @@ -45775,6 +45833,15 @@ func (p *ApiDetailData) GetVersionName() (v string) { return *p.VersionName } +var ApiDetailData_PluginFrom_DEFAULT bot_common.PluginFrom + +func (p *ApiDetailData) GetPluginFrom() (v bot_common.PluginFrom) { + if !p.IsSetPluginFrom() { + return ApiDetailData_PluginFrom_DEFAULT + } + return *p.PluginFrom +} + var fieldIDToName_ApiDetailData = map[int16]string{ 1: "pluginID", 2: "apiName", @@ -45794,6 +45861,7 @@ var fieldIDToName_ApiDetailData = map[int16]string{ 17: "latest_version", 18: "latest_version_name", 19: "version_name", + 50: "plugin_from", } func (p *ApiDetailData) IsSetDebugExample() bool { @@ -45820,6 +45888,10 @@ func (p *ApiDetailData) IsSetVersionName() bool { return p.VersionName != nil } +func (p *ApiDetailData) IsSetPluginFrom() bool { + return p.PluginFrom != nil +} + func (p *ApiDetailData) Read(iprot thrift.TProtocol) (err error) { var fieldTypeId thrift.TType var fieldId int16 @@ -45982,6 +46054,14 @@ func (p *ApiDetailData) Read(iprot thrift.TProtocol) (err error) { } else if err = iprot.Skip(fieldTypeId); err != nil { goto SkipFieldError } + case 50: + if fieldTypeId == thrift.I32 { + if err = p.ReadField50(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } default: if err = iprot.Skip(fieldTypeId); err != nil { goto SkipFieldError @@ -46206,6 +46286,18 @@ func (p *ApiDetailData) ReadField19(iprot thrift.TProtocol) error { p.VersionName = _field return nil } +func (p *ApiDetailData) ReadField50(iprot thrift.TProtocol) error { + + var _field *bot_common.PluginFrom + if v, err := iprot.ReadI32(); err != nil { + return err + } else { + tmp := bot_common.PluginFrom(v) + _field = &tmp + } + p.PluginFrom = _field + return nil +} func (p *ApiDetailData) Write(oprot thrift.TProtocol) (err error) { var fieldId int16 @@ -46285,6 +46377,10 @@ func (p *ApiDetailData) Write(oprot thrift.TProtocol) (err error) { fieldId = 19 goto WriteFieldError } + if err = p.writeField50(oprot); err != nil { + fieldId = 50 + goto WriteFieldError + } } if err = oprot.WriteFieldStop(); err != nil { goto WriteFieldStopError @@ -46603,6 +46699,24 @@ WriteFieldBeginError: WriteFieldEndError: return thrift.PrependError(fmt.Sprintf("%T write field 19 end error: ", p), err) } +func (p *ApiDetailData) writeField50(oprot thrift.TProtocol) (err error) { + if p.IsSetPluginFrom() { + if err = oprot.WriteFieldBegin("plugin_from", thrift.I32, 50); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteI32(int32(*p.PluginFrom)); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 50 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 50 end error: ", p), err) +} func (p *ApiDetailData) String() string { if p == nil { @@ -52002,9 +52116,10 @@ type FCPluginSetting struct { ResponseParams []*APIParameter `thrift:"response_params,5" form:"response_params" json:"response_params" query:"response_params"` ResponseStyle *ResponseStyle `thrift:"response_style,6" form:"response_style" json:"response_style" query:"response_style"` // This issue is temporarily not supported. - AsyncConf *AsyncConf `thrift:"async_conf,7,optional" form:"async_conf" json:"async_conf,omitempty" query:"async_conf"` - IsDraft bool `thrift:"is_draft,8" form:"is_draft" json:"is_draft" query:"is_draft"` - PluginVersion string `thrift:"plugin_version,9" form:"plugin_version" json:"plugin_version" query:"plugin_version"` + AsyncConf *AsyncConf `thrift:"async_conf,7,optional" form:"async_conf" json:"async_conf,omitempty" query:"async_conf"` + IsDraft bool `thrift:"is_draft,8" form:"is_draft" json:"is_draft" query:"is_draft"` + PluginVersion string `thrift:"plugin_version,9" form:"plugin_version" json:"plugin_version" query:"plugin_version"` + PluginFrom *bot_common.PluginFrom `thrift:"plugin_from,50,optional" form:"plugin_from" json:"plugin_from,omitempty" query:"plugin_from"` } func NewFCPluginSetting() *FCPluginSetting { @@ -52060,16 +52175,26 @@ func (p *FCPluginSetting) GetPluginVersion() (v string) { return p.PluginVersion } +var FCPluginSetting_PluginFrom_DEFAULT bot_common.PluginFrom + +func (p *FCPluginSetting) GetPluginFrom() (v bot_common.PluginFrom) { + if !p.IsSetPluginFrom() { + return FCPluginSetting_PluginFrom_DEFAULT + } + return *p.PluginFrom +} + var fieldIDToName_FCPluginSetting = map[int16]string{ - 1: "plugin_id", - 2: "api_id", - 3: "api_name", - 4: "request_params", - 5: "response_params", - 6: "response_style", - 7: "async_conf", - 8: "is_draft", - 9: "plugin_version", + 1: "plugin_id", + 2: "api_id", + 3: "api_name", + 4: "request_params", + 5: "response_params", + 6: "response_style", + 7: "async_conf", + 8: "is_draft", + 9: "plugin_version", + 50: "plugin_from", } func (p *FCPluginSetting) IsSetResponseStyle() bool { @@ -52080,6 +52205,10 @@ func (p *FCPluginSetting) IsSetAsyncConf() bool { return p.AsyncConf != nil } +func (p *FCPluginSetting) IsSetPluginFrom() bool { + return p.PluginFrom != nil +} + func (p *FCPluginSetting) Read(iprot thrift.TProtocol) (err error) { var fieldTypeId thrift.TType var fieldId int16 @@ -52170,6 +52299,14 @@ func (p *FCPluginSetting) Read(iprot thrift.TProtocol) (err error) { } else if err = iprot.Skip(fieldTypeId); err != nil { goto SkipFieldError } + case 50: + if fieldTypeId == thrift.I32 { + if err = p.ReadField50(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } default: if err = iprot.Skip(fieldTypeId); err != nil { goto SkipFieldError @@ -52316,6 +52453,18 @@ func (p *FCPluginSetting) ReadField9(iprot thrift.TProtocol) error { p.PluginVersion = _field return nil } +func (p *FCPluginSetting) ReadField50(iprot thrift.TProtocol) error { + + var _field *bot_common.PluginFrom + if v, err := iprot.ReadI32(); err != nil { + return err + } else { + tmp := bot_common.PluginFrom(v) + _field = &tmp + } + p.PluginFrom = _field + return nil +} func (p *FCPluginSetting) Write(oprot thrift.TProtocol) (err error) { var fieldId int16 @@ -52359,6 +52508,10 @@ func (p *FCPluginSetting) Write(oprot thrift.TProtocol) (err error) { fieldId = 9 goto WriteFieldError } + if err = p.writeField50(oprot); err != nil { + fieldId = 50 + goto WriteFieldError + } } if err = oprot.WriteFieldStop(); err != nil { goto WriteFieldStopError @@ -52539,6 +52692,24 @@ WriteFieldBeginError: WriteFieldEndError: return thrift.PrependError(fmt.Sprintf("%T write field 9 end error: ", p), err) } +func (p *FCPluginSetting) writeField50(oprot thrift.TProtocol) (err error) { + if p.IsSetPluginFrom() { + if err = oprot.WriteFieldBegin("plugin_from", thrift.I32, 50); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteI32(int32(*p.PluginFrom)); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 50 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 50 end error: ", p), err) +} func (p *FCPluginSetting) String() string { if p == nil { @@ -54024,11 +54195,12 @@ func (p *GetLLMNodeFCSettingsMergedResponse) String() string { } type PluginFCItem struct { - PluginID string `thrift:"plugin_id,1" form:"plugin_id" json:"plugin_id" query:"plugin_id"` - APIID string `thrift:"api_id,2" form:"api_id" json:"api_id" query:"api_id"` - APIName string `thrift:"api_name,3" form:"api_name" json:"api_name" query:"api_name"` - IsDraft bool `thrift:"is_draft,4" form:"is_draft" json:"is_draft" query:"is_draft"` - PluginVersion *string `thrift:"plugin_version,5,optional" form:"plugin_version" json:"plugin_version,omitempty" query:"plugin_version"` + PluginID string `thrift:"plugin_id,1" form:"plugin_id" json:"plugin_id" query:"plugin_id"` + APIID string `thrift:"api_id,2" form:"api_id" json:"api_id" query:"api_id"` + APIName string `thrift:"api_name,3" form:"api_name" json:"api_name" query:"api_name"` + IsDraft bool `thrift:"is_draft,4" form:"is_draft" json:"is_draft" query:"is_draft"` + PluginVersion *string `thrift:"plugin_version,5,optional" form:"plugin_version" json:"plugin_version,omitempty" query:"plugin_version"` + PluginFrom *bot_common.PluginFrom `thrift:"plugin_from,6,optional" form:"plugin_from" json:"plugin_from,omitempty" query:"plugin_from"` } func NewPluginFCItem() *PluginFCItem { @@ -54063,18 +54235,32 @@ func (p *PluginFCItem) GetPluginVersion() (v string) { return *p.PluginVersion } +var PluginFCItem_PluginFrom_DEFAULT bot_common.PluginFrom + +func (p *PluginFCItem) GetPluginFrom() (v bot_common.PluginFrom) { + if !p.IsSetPluginFrom() { + return PluginFCItem_PluginFrom_DEFAULT + } + return *p.PluginFrom +} + var fieldIDToName_PluginFCItem = map[int16]string{ 1: "plugin_id", 2: "api_id", 3: "api_name", 4: "is_draft", 5: "plugin_version", + 6: "plugin_from", } func (p *PluginFCItem) IsSetPluginVersion() bool { return p.PluginVersion != nil } +func (p *PluginFCItem) IsSetPluginFrom() bool { + return p.PluginFrom != nil +} + func (p *PluginFCItem) Read(iprot thrift.TProtocol) (err error) { var fieldTypeId thrift.TType var fieldId int16 @@ -54133,6 +54319,14 @@ func (p *PluginFCItem) Read(iprot thrift.TProtocol) (err error) { } else if err = iprot.Skip(fieldTypeId); err != nil { goto SkipFieldError } + case 6: + if fieldTypeId == thrift.I32 { + if err = p.ReadField6(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } default: if err = iprot.Skip(fieldTypeId); err != nil { goto SkipFieldError @@ -54217,6 +54411,18 @@ func (p *PluginFCItem) ReadField5(iprot thrift.TProtocol) error { p.PluginVersion = _field return nil } +func (p *PluginFCItem) ReadField6(iprot thrift.TProtocol) error { + + var _field *bot_common.PluginFrom + if v, err := iprot.ReadI32(); err != nil { + return err + } else { + tmp := bot_common.PluginFrom(v) + _field = &tmp + } + p.PluginFrom = _field + return nil +} func (p *PluginFCItem) Write(oprot thrift.TProtocol) (err error) { var fieldId int16 @@ -54244,6 +54450,10 @@ func (p *PluginFCItem) Write(oprot thrift.TProtocol) (err error) { fieldId = 5 goto WriteFieldError } + if err = p.writeField6(oprot); err != nil { + fieldId = 6 + goto WriteFieldError + } } if err = oprot.WriteFieldStop(); err != nil { goto WriteFieldStopError @@ -54344,6 +54554,24 @@ WriteFieldBeginError: WriteFieldEndError: return thrift.PrependError(fmt.Sprintf("%T write field 5 end error: ", p), err) } +func (p *PluginFCItem) writeField6(oprot thrift.TProtocol) (err error) { + if p.IsSetPluginFrom() { + if err = oprot.WriteFieldBegin("plugin_from", thrift.I32, 6); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteI32(int32(*p.PluginFrom)); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 6 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 6 end error: ", p), err) +} func (p *PluginFCItem) String() string { if p == nil { diff --git a/backend/api/model/workflow/workflow_svc.go b/backend/api/model/workflow/workflow_svc.go index 6a3d96a8b..bae6d2b36 100644 --- a/backend/api/model/workflow/workflow_svc.go +++ b/backend/api/model/workflow/workflow_svc.go @@ -21,7 +21,6 @@ package workflow import ( "context" "fmt" - "github.com/apache/thrift/lib/go/thrift" ) diff --git a/backend/api/router/coze/api.go b/backend/api/router/coze/api.go index b095c2b8b..f8d1a9b45 100644 --- a/backend/api/router/coze/api.go +++ b/backend/api/router/coze/api.go @@ -159,12 +159,21 @@ func Register(r *server.Hertz) { _marketplace := _api.Group("/marketplace", _marketplaceMw()...) { _product := _marketplace.Group("/product", _productMw()...) + _product.GET("/call_info", append(_publicgetproductcallinfoMw(), coze.PublicGetProductCallInfo)...) + _product.GET("/config", append(_publicgetmarketpluginconfigMw(), coze.PublicGetMarketPluginConfig)...) _product.GET("/detail", append(_publicgetproductdetailMw(), coze.PublicGetProductDetail)...) _product.POST("/duplicate", append(_publicduplicateproductMw(), coze.PublicDuplicateProduct)...) _product.POST("/favorite", append(_publicfavoriteproductMw(), coze.PublicFavoriteProduct)...) _favorite := _product.Group("/favorite", _favoriteMw()...) _favorite.GET("/list.v2", append(_publicgetuserfavoritelistv2Mw(), coze.PublicGetUserFavoriteListV2)...) _product.GET("/list", append(_publicgetproductlistMw(), coze.PublicGetProductList)...) + _product.GET("/search", append(_publicsearchproductMw(), coze.PublicSearchProduct)...) + _search0 := _product.Group("/search", _search0Mw()...) + _search0.GET("/suggest", append(_publicsearchsuggestMw(), coze.PublicSearchSuggest)...) + { + _category := _product.Group("/category", _categoryMw()...) + _category.GET("/list", append(_publicgetproductcategorylistMw(), coze.PublicGetProductCategoryList)...) + } } } { diff --git a/backend/api/router/coze/middleware.go b/backend/api/router/coze/middleware.go index 271edfc95..33ad5763f 100644 --- a/backend/api/router/coze/middleware.go +++ b/backend/api/router/coze/middleware.go @@ -1570,3 +1570,38 @@ func _getonlineappdataMw() []app.HandlerFunc { // your code... return nil } + +func _search0Mw() []app.HandlerFunc { + // your code... + return nil +} + +func _publicsearchproductMw() []app.HandlerFunc { + // your code... + return nil +} + +func _publicsearchsuggestMw() []app.HandlerFunc { + // your code... + return nil +} + +func _publicgetproductcallinfoMw() []app.HandlerFunc { + // your code... + return nil +} + +func _categoryMw() []app.HandlerFunc { + // your code... + return nil +} + +func _publicgetproductcategorylistMw() []app.HandlerFunc { + // your code... + return nil +} + +func _publicgetmarketpluginconfigMw() []app.HandlerFunc { + // your code... + return nil +} diff --git a/backend/application/conversation/agent_run.go b/backend/application/conversation/agent_run.go index 5f910cd6c..3932c3533 100644 --- a/backend/application/conversation/agent_run.go +++ b/backend/application/conversation/agent_run.go @@ -25,6 +25,7 @@ import ( "github.com/cloudwego/eino/schema" + "github.com/coze-dev/coze-studio/backend/api/model/app/bot_common" "github.com/coze-dev/coze-studio/backend/api/model/conversation/message" "github.com/coze-dev/coze-studio/backend/api/model/conversation/run" "github.com/coze-dev/coze-studio/backend/api/model/crossdomain/agentrun" @@ -362,11 +363,12 @@ func (c *ConversationApplicationService) buildTools(ctx context.Context, tools [ argBytes, err := json.Marshal(arguments) if err == nil { ts = append(ts, &entity.Tool{ - PluginID: shortcutCMD.PluginID, - Arguments: string(argBytes), - ToolName: shortcutCMD.PluginToolName, - ToolID: shortcutCMD.PluginToolID, - Type: agentrun.ToolType(shortcutCMD.ToolType), + PluginID: shortcutCMD.PluginID, + Arguments: string(argBytes), + ToolName: shortcutCMD.PluginToolName, + ToolID: shortcutCMD.PluginToolID, + Type: agentrun.ToolType(shortcutCMD.ToolType), + PluginFrom: bot_common.PluginFromPtr(bot_common.PluginFrom(shortcutCMD.Source)), }) } diff --git a/backend/application/conversation/openapi_agent_run.go b/backend/application/conversation/openapi_agent_run.go index e6d9c713b..f8fd9b836 100644 --- a/backend/application/conversation/openapi_agent_run.go +++ b/backend/application/conversation/openapi_agent_run.go @@ -26,6 +26,7 @@ import ( "github.com/cloudwego/eino/schema" + "github.com/coze-dev/coze-studio/backend/api/model/app/bot_common" "github.com/coze-dev/coze-studio/backend/api/model/conversation/common" "github.com/coze-dev/coze-studio/backend/api/model/conversation/run" "github.com/coze-dev/coze-studio/backend/api/model/crossdomain/agentrun" @@ -205,11 +206,12 @@ func (a *OpenapiAgentRunApplication) buildTools(ctx context.Context, shortcmd *r argBytes, err := json.Marshal(shortcmd.Parameters) if err == nil { ts = append(ts, &entity.Tool{ - PluginID: shortcutCMD.PluginID, - Arguments: string(argBytes), - ToolName: shortcutCMD.PluginToolName, - ToolID: shortcutCMD.PluginToolID, - Type: agentrun.ToolType(shortcutCMD.ToolType), + PluginID: shortcutCMD.PluginID, + Arguments: string(argBytes), + ToolName: shortcutCMD.PluginToolName, + ToolID: shortcutCMD.PluginToolID, + Type: agentrun.ToolType(shortcutCMD.ToolType), + PluginFrom: bot_common.PluginFromPtr(bot_common.PluginFrom(shortcutCMD.Source)), }) } } diff --git a/backend/application/plugin/playground.go b/backend/application/plugin/playground.go index dc8e2e9c2..ada930fe4 100644 --- a/backend/application/plugin/playground.go +++ b/backend/application/plugin/playground.go @@ -19,8 +19,11 @@ package plugin import ( "context" "fmt" + "slices" "strconv" + "github.com/coze-dev/coze-studio/backend/api/model/app/bot_common" + "github.com/coze-dev/coze-studio/backend/api/model/marketplace/product_common" pluginAPI "github.com/coze-dev/coze-studio/backend/api/model/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/convert" @@ -36,8 +39,17 @@ func (p *PluginApplicationService) GetPlaygroundPluginList(ctx context.Context, plugins []*entity.PluginInfo total int64 ) + + var isSaasPlugin bool + if slices.Contains(req.PluginTypes, int32(product_common.ProductEntityType_SaasPlugin)) { + isSaasPlugin = true + } if len(req.PluginIds) > 0 { - plugins, total, err = p.getPlaygroundPluginListByIDs(ctx, req.PluginIds) + if isSaasPlugin { + plugins, total, err = p.getSaasPluginListByIDs(ctx, req.PluginIds) + } else { + plugins, total, err = p.getPlaygroundPluginListByIDs(ctx, req.PluginIds) + } } else { plugins, total, err = p.getPlaygroundPluginList(ctx, req) } @@ -47,18 +59,37 @@ func (p *PluginApplicationService) GetPlaygroundPluginList(ctx context.Context, } pluginList := make([]*common.PluginInfoForPlayground, 0, len(plugins)) - for _, pl := range plugins { - tools, err := p.toolRepo.GetPluginAllOnlineTools(ctx, pl.ID) - if err != nil { - return nil, errorx.Wrapf(err, "GetPluginAllOnlineTools failed, pluginID=%d", pl.ID) + + if isSaasPlugin { + pluginIDs := make([]int64, 0, len(plugins)) + for _, product := range plugins { + pluginIDs = append(pluginIDs, product.ID) } - pluginInfo, err := p.toPluginInfoForPlayground(ctx, pl, tools) + tools, err := p.getSaasPluginToolsList(ctx, pluginIDs) + if err != nil { + logs.CtxErrorf(ctx, "BatchGetSaasPluginToolsInfo failed: %v", err) + return nil, err + } + pluginList, err = p.convertSaasPluginListToPlayground(ctx, plugins, tools) if err != nil { return nil, err } - pluginList = append(pluginList, pluginInfo) + } else { + for _, pl := range plugins { + tools, err := p.toolRepo.GetPluginAllOnlineTools(ctx, pl.ID) + if err != nil { + return nil, errorx.Wrapf(err, "GetPluginAllOnlineTools failed, pluginID=%d", pl.ID) + } + + pluginInfo, err := p.toPluginInfoForPlayground(ctx, pl, tools) + if err != nil { + return nil, err + } + + pluginList = append(pluginList, pluginInfo) + } } resp = &pluginAPI.GetPlaygroundPluginListResponse{ @@ -71,6 +102,38 @@ func (p *PluginApplicationService) GetPlaygroundPluginList(ctx context.Context, return resp, nil } +func (p *PluginApplicationService) convertSaasPluginListToPlayground(ctx context.Context, plugins []*entity.PluginInfo, tools map[int64][]*entity.ToolInfo) ([]*common.PluginInfoForPlayground, error) { + products := make([]*common.PluginInfoForPlayground, 0, len(plugins)) + for _, pl := range plugins { + tools := tools[pl.ID] + pluginInfo, err := p.toPluginInfoForPlayground(ctx, pl, tools) + if err != nil { + return nil, err + } + products = append(products, pluginInfo) + } + return products, nil +} + +func (p *PluginApplicationService) getSaasPluginListByIDs(ctx context.Context, pluginIDs []string) ([]*entity.PluginInfo, int64, error) { + ids := make([]int64, 0, len(pluginIDs)) + + for _, pluginIDStr := range pluginIDs { + pluginID, err := strconv.ParseInt(pluginIDStr, 10, 64) + if err != nil { + return nil, 0, fmt.Errorf("invalid pluginID '%s': %w", pluginIDStr, err) + } + ids = append(ids, pluginID) + } + + plugins, err := p.DomainSVC.GetSaasPluginInfo(ctx, ids) + if err != nil { + return nil, 0, errorx.Wrapf(err, "GetSaasPluginInfo failed, pluginIDs=%v", pluginIDs) + } + + return plugins, int64(len(plugins)), nil +} + func (p *PluginApplicationService) getPlaygroundPluginListByIDs(ctx context.Context, pluginIDs []string) (plugins []*entity.PluginInfo, total int64, err error) { ids := make([]int64, 0, len(pluginIDs)) for _, id := range pluginIDs { @@ -132,16 +195,18 @@ func (p *PluginApplicationService) toPluginInfoForPlayground(ctx context.Context } var creator *common.Creator - userInfo, err := p.userSVC.GetUserInfo(ctx, pl.DeveloperID) - if err != nil { - logs.CtxErrorf(ctx, "get user info failed, err=%v", err) - creator = common.NewCreator() - } else { - creator = &common.Creator{ - ID: strconv.FormatInt(pl.DeveloperID, 10), - Name: userInfo.Name, - AvatarURL: userInfo.IconURL, - UserUniqueName: userInfo.UniqueName, + if pl.Source != ptr.Of(bot_common.PluginFrom_FromSaas) { + userInfo, err := p.userSVC.GetUserInfo(ctx, pl.DeveloperID) + if err != nil { + logs.CtxErrorf(ctx, "get user info failed, err=%v", err) + creator = common.NewCreator() + } else { + creator = &common.Creator{ + ID: strconv.FormatInt(pl.DeveloperID, 10), + Name: userInfo.Name, + AvatarURL: userInfo.IconURL, + UserUniqueName: userInfo.UniqueName, + } } } diff --git a/backend/application/plugin/plugin.go b/backend/application/plugin/plugin.go index 1400c65fc..259b2be8a 100644 --- a/backend/application/plugin/plugin.go +++ b/backend/application/plugin/plugin.go @@ -18,9 +18,14 @@ package plugin import ( "context" + "os" + "strconv" "strings" "time" + typesConsts "github.com/coze-dev/coze-studio/backend/types/consts" + + "github.com/coze-dev/coze-studio/backend/api/model/app/bot_common" 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" @@ -33,6 +38,7 @@ import ( "github.com/coze-dev/coze-studio/backend/domain/plugin/repository" "github.com/coze-dev/coze-studio/backend/domain/plugin/service" search "github.com/coze-dev/coze-studio/backend/domain/search/service" + userEntity "github.com/coze-dev/coze-studio/backend/domain/user/entity" user "github.com/coze-dev/coze-studio/backend/domain/user/service" "github.com/coze-dev/coze-studio/backend/infra/storage" "github.com/coze-dev/coze-studio/backend/pkg/errorx" @@ -64,15 +70,8 @@ func (p *PluginApplicationService) CheckAndLockPluginEdit(ctx context.Context, r } func (p *PluginApplicationService) GetBotDefaultParams(ctx context.Context, req *pluginAPI.GetBotDefaultParamsRequest) (resp *pluginAPI.GetBotDefaultParamsResponse, err error) { - _, exist, err := p.pluginRepo.GetOnlinePlugin(ctx, req.PluginID, repository.WithPluginID()) - if err != nil { - return nil, errorx.Wrapf(err, "GetOnlinePlugin failed, pluginID=%d", req.PluginID) - } - if !exist { - return nil, errorx.New(errno.ErrPluginRecordNotFound) - } - draftAgentTool, err := p.DomainSVC.GetDraftAgentToolByName(ctx, req.BotID, req.APIName) + draftAgentTool, err := p.DomainSVC.GetDraftAgentToolByName(ctx, req.BotID, req.PluginID, req.APIName) if err != nil { return nil, errorx.Wrapf(err, "GetDraftAgentToolByName failed, agentID=%d, toolName=%s", req.BotID, req.APIName) } @@ -220,6 +219,12 @@ func (p *PluginApplicationService) buildPluginProductExtraInfo(ctx context.Conte } return ptr.Of(productCommon.PluginType_CLoudPlugin) }(), + JumpSaasURL: func() *string { + if plugin.SaasPluginExtra != nil && plugin.SaasPluginExtra.JumpSaasURL != nil { + return plugin.SaasPluginExtra.JumpSaasURL + } + return nil + }(), } toolInfos := make([]*productAPI.PluginToolInfo, 0, len(tools)) @@ -261,6 +266,8 @@ func (p *PluginApplicationService) buildPluginProductExtraInfo(ctx context.Conte } else { authMode = ptr.Of(productAPI.PluginAuthMode_Configured) } + } else if authInfo.Type == consts.AuthTypeOfSaasInstalled { + authMode = ptr.Of(productAPI.PluginAuthMode_NeedInstalled) } } @@ -314,3 +321,330 @@ func (p *PluginApplicationService) validateDraftPluginAccess(ctx context.Context return plugin, nil } + +// convertPluginToProductInfo converts a plugin entity to ProductInfo +func convertPluginToProductInfo(plugin *entity.PluginInfo) *productAPI.ProductInfo { + + isOfficial := func() bool { + if plugin.SaasPluginExtra == nil { + return true + } + return plugin.SaasPluginExtra.IsOfficial + }() + return &productAPI.ProductInfo{ + MetaInfo: &productAPI.ProductMetaInfo{ + ID: plugin.GetRefProductID(), + Name: plugin.GetName(), + EntityID: plugin.ID, + Description: plugin.GetDesc(), + IconURL: plugin.GetIconURI(), + ListedAt: plugin.CreatedAt, + EntityType: func() productCommon.ProductEntityType { + if ptr.From(plugin.Source) == bot_common.PluginFrom_FromSaas { + return productCommon.ProductEntityType_SaasPlugin + } + return productCommon.ProductEntityType_Plugin + }(), + IsOfficial: isOfficial, + Status: productCommon.ProductStatus_Listed, + UserInfo: &productCommon.UserInfo{ + Name: func() string { + if isOfficial { + return "Coze Official" + } + return "Coze Community" + }(), + }, + }, + } +} + +func (p *PluginApplicationService) convertPluginsToProductInfos(ctx context.Context, plugins []*entity.PluginInfo, tools map[int64][]*entity.ToolInfo) []*productAPI.ProductInfo { + products := make([]*productAPI.ProductInfo, 0, len(plugins)) + for _, plugin := range plugins { + var pExtra *productAPI.PluginExtraInfo + if tool, exist := tools[plugin.ID]; exist { + pluginExtra, err := p.buildPluginProductExtraInfo(ctx, plugin, tool) + if err != nil { + logs.CtxErrorf(ctx, "buildPluginProductExtraInfo failed: %v", err) + } else { + pExtra = pluginExtra + } + } + pi := convertPluginToProductInfo(plugin) + pi.PluginExtra = pExtra + products = append(products, pi) + } + return products +} +func (p *PluginApplicationService) convertPluginsToMetaInfos(ctx context.Context, plugins []*entity.PluginInfo, tools map[int64][]*entity.ToolInfo) []*productAPI.ProductMetaInfo { + products := make([]*productAPI.ProductMetaInfo, 0, len(plugins)) + for _, plugin := range plugins { + pi := &productAPI.ProductMetaInfo{ + ID: plugin.ID, + Name: plugin.GetName(), + Description: plugin.GetDesc(), + IconURL: plugin.GetIconURI(), + ListedAt: plugin.CreatedAt, + EntityID: plugin.ID, + } + products = append(products, pi) + } + return products +} + +func (p *PluginApplicationService) getSaasPluginList(ctx context.Context, domainReq *dto.ListSaasPluginProductsRequest) (*dto.ListPluginProductsResponse, error) { + return p.DomainSVC.ListSaasPluginProducts(ctx, domainReq) +} + +func (p *PluginApplicationService) getSaasPluginToolsList(ctx context.Context, pluginIDs []int64) (map[int64][]*entity.ToolInfo, error) { + tools, _, err := p.DomainSVC.BatchGetSaasPluginToolsInfo(ctx, pluginIDs) + return tools, err +} + +func (p *PluginApplicationService) GetCozeSaasPluginList(ctx context.Context, req *productAPI.GetProductListRequest) (resp *productAPI.GetProductListResponse, err error) { + domainResp, err := p.getSaasPluginList(ctx, &dto.ListSaasPluginProductsRequest{ + PageNum: ptr.Of(req.PageNum), + PageSize: ptr.Of(req.PageSize), + Keyword: req.Keyword, + EntityTypes: req.EntityTypes, + }) + if err != nil { + logs.CtxErrorf(ctx, "ListSaasPluginProducts failed: %v", err) + return nil, err + } + + // tools + pluginIDs := make([]int64, 0, len(domainResp.Plugins)) + for _, product := range domainResp.Plugins { + pluginIDs = append(pluginIDs, product.ID) + } + + tools, err := p.getSaasPluginToolsList(ctx, pluginIDs) + if err != nil { + logs.CtxErrorf(ctx, "BatchGetSaasPluginToolsInfo failed: %v", err) + return nil, err + } + + products := p.convertPluginsToProductInfos(ctx, domainResp.Plugins, tools) + + return &productAPI.GetProductListResponse{ + Code: 0, + Message: "success", + Data: &productAPI.GetProductListData{ + Products: products, + Total: int32(domainResp.Total), + HasMore: domainResp.HasMore, + }, + }, nil +} + +func (p *PluginApplicationService) PublicSearchProduct(ctx context.Context, req *productAPI.SearchProductRequest) (resp *productAPI.SearchProductResponse, err error) { + domainResp, err := p.getSaasPluginList(ctx, &dto.ListSaasPluginProductsRequest{ + PageNum: ptr.Of(req.PageNum), + PageSize: ptr.Of(req.PageSize), + Keyword: ptr.Of(req.Keyword), + EntityTypes: func() []productCommon.ProductEntityType { + if req.EntityTypes == nil { + return nil + } + return p.convertEntityTypesStrToSlice(*req.EntityTypes) + }(), + CategoryIDs: req.CategoryIDs, + IsOfficial: req.IsOfficial, + PluginType: req.PluginType, + ProductPaidType: req.ProductPaidType, + SortType: req.SortType, + }) + if err != nil { + logs.CtxErrorf(ctx, "ListSaasPluginProducts failed: %v", err) + return nil, err + } + // tools + pluginIDs := make([]int64, 0, len(domainResp.Plugins)) + for _, product := range domainResp.Plugins { + pluginIDs = append(pluginIDs, product.ID) + } + + tools, err := p.getSaasPluginToolsList(ctx, pluginIDs) + if err != nil { + logs.CtxErrorf(ctx, "BatchGetSaasPluginToolsInfo failed: %v", err) + return nil, err + } + + products := p.convertPluginsToProductInfos(ctx, domainResp.Plugins, tools) + + return &productAPI.SearchProductResponse{ + Code: 0, + Message: "success", + Data: &productAPI.SearchProductResponseData{ + Products: products, + Total: ptr.Of(int32(domainResp.Total)), + HasMore: ptr.Of(domainResp.HasMore), + }, + }, nil +} + +func (p *PluginApplicationService) convertEntityTypesStrToSlice(entityTypesStr string) []productCommon.ProductEntityType { + var entityTypes []productCommon.ProductEntityType + if entityTypesStr != "" { + typeStrs := strings.Split(entityTypesStr, ",") + for _, typeStr := range typeStrs { + typeStr = strings.TrimSpace(typeStr) + if typeStr != "" { + if entityType, err := productCommon.ProductEntityTypeFromString(typeStr); err == nil { + entityTypes = append(entityTypes, entityType) + } + } + } + } + return entityTypes +} +func (p *PluginApplicationService) PublicSearchSuggest(ctx context.Context, req *productAPI.SearchSuggestRequest) (resp *productAPI.SearchSuggestResponse, err error) { + domainResp, err := p.getSaasPluginList(ctx, &dto.ListSaasPluginProductsRequest{ + PageNum: req.PageNum, + PageSize: req.PageSize, + Keyword: req.Keyword, + EntityTypes: func() []productCommon.ProductEntityType { + if req.EntityTypes == nil { + return nil + } + return p.convertEntityTypesStrToSlice(*req.EntityTypes) + }(), + }) + + if err != nil { + logs.CtxErrorf(ctx, "ListSaasPluginProducts for suggestions failed: %v", err) + return nil, err + } + + // tools + pluginIDs := make([]int64, 0, len(domainResp.Plugins)) + for _, product := range domainResp.Plugins { + pluginIDs = append(pluginIDs, product.ID) + } + + tools, err := p.getSaasPluginToolsList(ctx, pluginIDs) + if err != nil { + logs.CtxErrorf(ctx, "BatchGetSaasPluginToolsInfo failed: %v", err) + return nil, err + } + + suggestionProducts := p.convertPluginsToProductInfos(ctx, domainResp.Plugins, tools) + + return &productAPI.SearchSuggestResponse{ + Code: 0, + Message: "success", + Data: &productAPI.SearchSuggestResponseData{ + SuggestionV2: suggestionProducts, + Suggestions: p.convertPluginsToMetaInfos(ctx, domainResp.Plugins, tools), + HasMore: ptr.Of(domainResp.HasMore), + }, + }, nil +} + +func (p *PluginApplicationService) GetSaasProductCategoryList(ctx context.Context, req *productAPI.GetProductCategoryListRequest) (resp *productAPI.GetProductCategoryListResponse, err error) { + + domainReq := &dto.ListPluginCategoriesRequest{} + + if req.GetEntityType() == productCommon.ProductEntityType_SaasPlugin { + domainReq.EntityType = ptr.Of("plugin") + } + + domainResp, err := p.DomainSVC.ListSaasPluginCategories(ctx, domainReq) + if err != nil { + logs.CtxErrorf(ctx, "ListSaasPluginCategories failed: %v", err) + return nil, err + } + + // 转换响应数据 + categories := make([]*productAPI.ProductCategory, 0) + if domainResp.Data != nil && domainResp.Data.Items != nil { + for _, item := range domainResp.Data.Items { + // 将字符串 ID 转换为 int64 + categoryID, _ := strconv.ParseInt(item.ID, 10, 64) + categories = append(categories, &productAPI.ProductCategory{ + ID: categoryID, + Name: item.Name, + }) + } + } + + return &productAPI.GetProductCategoryListResponse{ + Code: 0, + Message: "success", + Data: &productAPI.GetProductCategoryListData{ + EntityType: req.GetEntityType(), + Categories: categories, + }, + }, nil +} + +func (p *PluginApplicationService) GetProductCallInfo(ctx context.Context, req *productAPI.GetProductCallInfoRequest) (resp *productAPI.GetProductCallInfoResponse, err error) { + userInfo, err := p.userSVC.GetSaasUserInfo(ctx) + if err != nil { + logs.CtxErrorf(ctx, "GetSaasUserInfo failed: %v", err) + return nil, err + } + + benefit, err := p.userSVC.GetUserBenefit(ctx) + if err != nil { + logs.CtxErrorf(ctx, "GetUserBenefit failed: %v", err) + return nil, err + } + + // Build response data + data := &productAPI.GetProductCallInfoData{ + UserInfo: &productAPI.UserInfo{ + UserName: ptr.Of(userInfo.UserName), + NickName: ptr.Of(userInfo.NickName), + AvatarURL: ptr.Of(userInfo.AvatarURL), + }, + } + + if benefit != nil { + data.UserLevel = func() productAPI.UserLevel { + switch benefit.UserLevel { + case userEntity.UserLevelPro: + return productAPI.UserLevel_ProPersonal + case userEntity.UserLevelEnterprise: + return productAPI.UserLevel_Enterprise + default: + return productAPI.UserLevel_Free + } + }() + data.CallCountLimit = &productAPI.ProductCallCountLimit{ + IsUnlimited: benefit.IsUnlimited, + UsedCount: benefit.UsedCount, + TotalCount: benefit.TotalCount, + ResetDatetime: benefit.ResetDatetime, + } + data.CallRateLimit = &productAPI.ProductCallRateLimit{ + QPS: benefit.CallQPS, + } + } + + return &productAPI.GetProductCallInfoResponse{ + Code: 0, + Message: "success", + Data: data, + }, nil +} + +func (p *PluginApplicationService) GetMarketPluginConfig(ctx context.Context, req *productAPI.GetMarketPluginConfigRequest) (resp *productAPI.GetMarketPluginConfigResponse, err error) { + + enableSaasPluginEnv := os.Getenv(typesConsts.CozeSaasPluginEnabled) + saasAPIiKey := os.Getenv(typesConsts.CozeSaasAPIKey) + + enableSaasPlugin := enableSaasPluginEnv == "true" && len(saasAPIiKey) > 0 + + resp = &productAPI.GetMarketPluginConfigResponse{ + Code: 0, + Message: "success", + Data: &productAPI.Configuration{ + EnableSaasPlugin: &enableSaasPlugin, + }, + } + + return resp, nil +} diff --git a/backend/application/plugin/plugin_test.go b/backend/application/plugin/plugin_test.go new file mode 100644 index 000000000..515c31f09 --- /dev/null +++ b/backend/application/plugin/plugin_test.go @@ -0,0 +1,291 @@ +/* + * 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 plugin + +import ( + "context" + "errors" + "testing" + + "github.com/stretchr/testify/assert" + "go.uber.org/mock/gomock" + + productAPI "github.com/coze-dev/coze-studio/backend/api/model/marketplace/product_public_api" + pluginCommon "github.com/coze-dev/coze-studio/backend/api/model/plugin_develop/common" + "github.com/coze-dev/coze-studio/backend/crossdomain/contract/plugin/consts" + "github.com/coze-dev/coze-studio/backend/crossdomain/contract/plugin/model" + "github.com/coze-dev/coze-studio/backend/domain/plugin/dto" + "github.com/coze-dev/coze-studio/backend/domain/plugin/entity" + mockPlugin "github.com/coze-dev/coze-studio/backend/internal/mock/domain/plugin" + "github.com/coze-dev/coze-studio/backend/pkg/lang/ptr" +) + +func TestPluginApplicationService_GetCozeSaasPluginList(t *testing.T) { + ctrl := gomock.NewController(t) + defer ctrl.Finish() + + mockDomainSVC := mockPlugin.NewMockPluginService(ctrl) + + service := &PluginApplicationService{ + DomainSVC: mockDomainSVC, + } + + ctx := context.Background() + req := &productAPI.GetProductListRequest{} + + t.Run("Success - Normal case with plugins", func(t *testing.T) { + // Prepare test data + testPlugins := []*entity.PluginInfo{ + createTestPluginInfo(1, "Test Plugin 1", "Description 1"), + createTestPluginInfo(2, "Test Plugin 2", "Description 2"), + } + + domainResp := &dto.ListPluginProductsResponse{ + Plugins: testPlugins, + Total: 2, + } + + // Setup mock expectations + mockDomainSVC.EXPECT(). + ListSaasPluginProducts(ctx, gomock.Any()). + Return(domainResp, nil). + Times(1) + + // Mock BatchGetSaasPluginToolsInfo + mockDomainSVC.EXPECT(). + BatchGetSaasPluginToolsInfo(ctx, []int64{1, 2}). + Return(map[int64][]*entity.ToolInfo{ + 1: {}, + 2: {}, + }, map[int64]*entity.PluginInfo{}, nil). + Times(1) + + // Execute the method + resp, err := service.GetCozeSaasPluginList(ctx, req) + + // Assertions + assert.NoError(t, err) + assert.NotNil(t, resp) + assert.Equal(t, int32(0), resp.Code) + assert.Equal(t, "success", resp.Message) + assert.NotNil(t, resp.Data) + assert.Equal(t, int32(2), resp.Data.Total) + assert.False(t, resp.Data.HasMore) + assert.Len(t, resp.Data.Products, 2) + + // Verify product info conversion + product1 := resp.Data.Products[0] + assert.Equal(t, int64(1), product1.MetaInfo.ID) + assert.Equal(t, int64(1), product1.MetaInfo.EntityID) + assert.Equal(t, "Test Plugin 1", product1.MetaInfo.Name) + assert.Equal(t, "Description 1", product1.MetaInfo.Description) + assert.Equal(t, "https://example.com/icon.png", product1.MetaInfo.IconURL) + assert.Equal(t, int64(1640995200), product1.MetaInfo.ListedAt) + assert.NotNil(t, product1.PluginExtra) + assert.True(t, product1.PluginExtra.IsOfficial) // buildPluginProductExtraInfo always sets IsOfficial to true + }) + + t.Run("Error - ListSaasPluginProducts returns error", func(t *testing.T) { + // Setup mock to return error + expectedError := errors.New("failed to fetch SaaS plugins") + mockDomainSVC.EXPECT(). + ListSaasPluginProducts(ctx, gomock.Any()). + Return(nil, expectedError). + Times(1) + + // Execute the method + resp, err := service.GetCozeSaasPluginList(ctx, req) + + // Assertions + assert.Error(t, err) // The method returns error when domain service fails + assert.Nil(t, resp) + assert.Contains(t, err.Error(), "failed to fetch SaaS plugins") + }) + + t.Run("Success - Empty plugin list", func(t *testing.T) { + // Prepare empty response + domainResp := &dto.ListPluginProductsResponse{ + Plugins: []*entity.PluginInfo{}, + Total: 0, + } + + // Setup mock expectations + mockDomainSVC.EXPECT(). + ListSaasPluginProducts(ctx, gomock.Any()). + Return(domainResp, nil). + Times(1) + + // Mock BatchGetSaasPluginToolsInfo for empty list + mockDomainSVC.EXPECT(). + BatchGetSaasPluginToolsInfo(ctx, []int64{}). + Return(map[int64][]*entity.ToolInfo{}, map[int64]*entity.PluginInfo{}, nil). + Times(1) + + // Execute the method + resp, err := service.GetCozeSaasPluginList(ctx, req) + + // Assertions + assert.NoError(t, err) + assert.NotNil(t, resp) + assert.Equal(t, int32(0), resp.Code) + assert.Equal(t, "success", resp.Message) + assert.NotNil(t, resp.Data) + assert.Equal(t, int32(0), resp.Data.Total) + assert.False(t, resp.Data.HasMore) + assert.Len(t, resp.Data.Products, 0) + assert.Empty(t, resp.Data.Products) + }) + + t.Run("Success - Multiple plugins", func(t *testing.T) { + // Prepare test data with multiple plugins + testPlugins := []*entity.PluginInfo{ + createTestPluginInfo(100, "Weather Plugin", "Get weather information"), + createTestPluginInfo(200, "Translation Plugin", "Translate text between languages"), + createTestPluginInfo(300, "Calculator Plugin", "Perform mathematical calculations"), + createTestPluginInfo(400, "News Plugin", "Get latest news updates"), + createTestPluginInfo(500, "Email Plugin", "Send and manage emails"), + } + + domainResp := &dto.ListPluginProductsResponse{ + Plugins: testPlugins, + Total: 5, + } + + // Setup mock expectations + mockDomainSVC.EXPECT(). + ListSaasPluginProducts(ctx, gomock.Any()). + Return(domainResp, nil). + Times(1) + + // Mock BatchGetSaasPluginToolsInfo for multiple plugins + mockDomainSVC.EXPECT(). + BatchGetSaasPluginToolsInfo(ctx, []int64{100, 200, 300, 400, 500}). + Return(map[int64][]*entity.ToolInfo{ + 100: {}, + 200: {}, + 300: {}, + 400: {}, + 500: {}, + }, map[int64]*entity.PluginInfo{}, nil). + Times(1) + + // Execute the method + resp, err := service.GetCozeSaasPluginList(ctx, req) + + // Assertions + assert.NoError(t, err) + assert.NotNil(t, resp) + assert.Equal(t, int32(0), resp.Code) + assert.Equal(t, "success", resp.Message) + assert.NotNil(t, resp.Data) + assert.Equal(t, int32(5), resp.Data.Total) + assert.False(t, resp.Data.HasMore) + assert.Len(t, resp.Data.Products, 5) + + // Verify all plugins are converted correctly + expectedNames := []string{"Weather Plugin", "Translation Plugin", "Calculator Plugin", "News Plugin", "Email Plugin"} + expectedIDs := []int64{100, 200, 300, 400, 500} + + for i, product := range resp.Data.Products { + assert.Equal(t, expectedIDs[i], product.MetaInfo.ID) + assert.Equal(t, expectedIDs[i], product.MetaInfo.EntityID) + assert.Equal(t, expectedNames[i], product.MetaInfo.Name) + assert.Equal(t, "https://example.com/icon.png", product.MetaInfo.IconURL) + assert.Equal(t, int64(1640995200), product.MetaInfo.ListedAt) + assert.NotNil(t, product.PluginExtra) + assert.True(t, product.PluginExtra.IsOfficial) // buildPluginProductExtraInfo always sets IsOfficial to true + } + }) +} + +// createTestPluginInfo creates a test PluginInfo entity for testing +func createTestPluginInfo(id int64, name, desc string) *entity.PluginInfo { + manifest := &model.PluginManifest{ + SchemaVersion: "v1", + NameForModel: name, + NameForHuman: name, + DescriptionForModel: desc, + DescriptionForHuman: desc, + LogoURL: "https://example.com/icon.png", + Auth: &model.AuthV2{ + Type: consts.AuthzTypeOfNone, + }, + API: model.APIDesc{ + Type: "openapi", + }, + } + + pluginInfo := &model.PluginInfo{ + ID: id, + PluginType: pluginCommon.PluginType_PLUGIN, + SpaceID: 0, + DeveloperID: 0, + APPID: nil, + RefProductID: ptr.Of(id), // Set RefProductID to the same as ID + IconURI: ptr.Of("https://example.com/icon.png"), + ServerURL: ptr.Of(""), + CreatedAt: 1640995200, // 2022-01-01 00:00:00 + UpdatedAt: 1640995200, + SaasPluginExtra: &model.SaasPluginExtraInfo{ + IsOfficial: false, + }, + Manifest: manifest, + } + + return entity.NewPluginInfo(pluginInfo) +} + +// createTestPluginInfoWithCustomIcon creates a test PluginInfo entity with custom icon for testing +func createTestPluginInfoWithCustomIcon(id int64, name, desc, iconURL string) *entity.PluginInfo { + manifest := &model.PluginManifest{ + SchemaVersion: "v1", + NameForModel: name, + NameForHuman: name, + DescriptionForModel: desc, + DescriptionForHuman: desc, + LogoURL: iconURL, + Auth: &model.AuthV2{ + Type: consts.AuthzTypeOfNone, + }, + API: model.APIDesc{ + Type: "openapi", + }, + } + + pluginInfo := &model.PluginInfo{ + ID: id, + PluginType: pluginCommon.PluginType_PLUGIN, + SpaceID: 0, + DeveloperID: 0, + APPID: nil, + IconURI: ptr.Of(iconURL), + ServerURL: ptr.Of(""), + CreatedAt: 1640995200, + UpdatedAt: 1640995200, + Manifest: manifest, + } + + return entity.NewPluginInfo(pluginInfo) +} + +// createTestDomainResponse creates a test domain response for testing +func createTestDomainResponse(plugins []*entity.PluginInfo) *dto.ListPluginProductsResponse { + return &dto.ListPluginProductsResponse{ + Plugins: plugins, + Total: int64(len(plugins)), + } +} diff --git a/backend/application/shortcutcmd/shortcut_cmd.go b/backend/application/shortcutcmd/shortcut_cmd.go index 825257e4d..b67798797 100644 --- a/backend/application/shortcutcmd/shortcut_cmd.go +++ b/backend/application/shortcutcmd/shortcut_cmd.go @@ -93,6 +93,7 @@ func (s *ShortcutCmdApplicationService) buildReq(ctx context.Context, req *playg PluginToolName: req.GetShortcuts().PluginAPIName, TemplateQuery: req.GetShortcuts().TemplateQuery, ShortcutIcon: req.GetShortcuts().ShortcutIcon, + Source: int32(req.GetShortcuts().GetPluginFrom()), }, nil } diff --git a/backend/application/singleagent/get.go b/backend/application/singleagent/get.go index b9f7fd622..18f6b53bf 100644 --- a/backend/application/singleagent/get.go +++ b/backend/application/singleagent/get.go @@ -155,6 +155,7 @@ func (s *SingleAgentApplicationService) shortcutCMDDo2Vo(cmdDOs []*shortcutCMDEn ComponentsList: cmdDO.Components, CardSchema: cmdDO.CardSchema, ToolInfo: cmdDO.ToolInfo, + PluginFrom: ptr.Of(bot_common.PluginFrom(cmdDO.Source)), } }) } @@ -206,27 +207,55 @@ func (s *SingleAgentApplicationService) fetchToolDetails(ctx context.Context, ag IsDraft: true, VersionAgentTools: slices.Transform(agentInfo.Plugin, func(a *bot_common.PluginInfo) model.VersionAgentTool { return model.VersionAgentTool{ - ToolID: a.GetApiId(), + ToolID: a.GetApiId(), + PluginFrom: a.PluginFrom, + PluginID: a.GetPluginId(), } }), }) } func (s *SingleAgentApplicationService) fetchPluginDetails(ctx context.Context, agentInfo *entity.SingleAgent, toolInfos []*pluginEntity.ToolInfo) ([]*pluginEntity.PluginInfo, error) { - vPlugins := make([]model.VersionPlugin, 0, len(agentInfo.Plugin)) + vLocalPlugins := make([]model.VersionPlugin, 0, len(agentInfo.Plugin)) vPluginMap := make(map[string]bool, len(agentInfo.Plugin)) + vSaasPlugin := make([]model.VersionPlugin, 0, len(agentInfo.Plugin)) for _, v := range toolInfos { - k := fmt.Sprintf("%d:%s", v.PluginID, v.GetVersion()) + k := fmt.Sprintf("%d:%s:%s", v.PluginID, v.GetVersion(), v.GetPluginFrom()) if vPluginMap[k] { continue } vPluginMap[k] = true - vPlugins = append(vPlugins, model.VersionPlugin{ - PluginID: v.PluginID, - Version: v.GetVersion(), - }) + if v.GetPluginFrom() == bot_common.PluginFrom_FromSaas { + vSaasPlugin = append(vSaasPlugin, model.VersionPlugin{ + PluginID: v.PluginID, + Version: v.GetVersion(), + }) + } else { + vLocalPlugins = append(vLocalPlugins, model.VersionPlugin{ + PluginID: v.PluginID, + Version: v.GetVersion(), + }) + } } - return s.appContext.PluginDomainSVC.MGetVersionPlugins(ctx, vPlugins) + pluginInfos := make([]*pluginEntity.PluginInfo, 0, len(vLocalPlugins)+len(vSaasPlugin)) + if len(vLocalPlugins) > 0 { + localPluginInfos, err := s.appContext.PluginDomainSVC.MGetVersionPlugins(ctx, vLocalPlugins) + if err != nil { + return nil, fmt.Errorf("fetch local plugin details failed: %v", err) + } + pluginInfos = append(pluginInfos, localPluginInfos...) + } + + if len(vSaasPlugin) > 0 { + saasPluginInfos, err := s.appContext.PluginDomainSVC.GetSaasPluginInfo(ctx, slices.Transform(vSaasPlugin, func(v model.VersionPlugin) int64 { + return v.PluginID + })) + if err != nil { + return nil, fmt.Errorf("fetch saas plugin details failed: %v", err) + } + pluginInfos = append(pluginInfos, saasPluginInfos...) + } + return pluginInfos, nil } func (s *SingleAgentApplicationService) fetchWorkflowDetails(ctx context.Context, agentInfo *entity.SingleAgent) ([]*workflowEntity.Workflow, error) { @@ -305,7 +334,9 @@ func (s *SingleAgentApplicationService) pluginInfoDo2Vo(ctx context.Context, plu e := v.PluginInfo var iconURL string - if e.GetIconURI() != "" { + if e.IconURL != nil { + iconURL = *e.IconURL + } else if e.GetIconURI() != "" { var err error iconURL, err = s.appContext.TosClient.GetObjectUrl(ctx, e.GetIconURI()) if err != nil { @@ -326,6 +357,7 @@ func (s *SingleAgentApplicationService) pluginInfoDo2Vo(ctx context.Context, plu } return ptr.Of(false) }(), + PluginFrom: e.Source, } }) } diff --git a/backend/application/workflow/workflow.go b/backend/application/workflow/workflow.go index 9e3c32a97..31a7f0364 100644 --- a/backend/application/workflow/workflow.go +++ b/backend/application/workflow/workflow.go @@ -2654,6 +2654,7 @@ func (w *ApplicationService) GetApiDetail(ctx context.Context, req *workflow.Get PluginEntity: vo.PluginEntity{ PluginID: pluginID, PluginVersion: req.PluginVersion, + PluginFrom: req.PluginFrom, }, ToolIDs: []int64{toolID}, }) @@ -2691,6 +2692,7 @@ func (w *ApplicationService) GetApiDetail(ctx context.Context, req *workflow.Get LatestVersion: toolInfoResponse.LatestVersion, PluginProductStatus: ternary.IFElse(toolInfoResponse.IsOfficial, int64(1), 0), ProjectID: ternary.IFElse(toolInfoResponse.AppID != 0, ptr.Of(strconv.FormatInt(toolInfoResponse.AppID, 10)), nil), + PluginFrom: req.PluginFrom, }, ToolInputs: inputVars, ToolOutputs: outputVars, @@ -2743,6 +2745,7 @@ func (w *ApplicationService) GetLLMNodeFCSettingDetail(ctx context.Context, req PluginEntity: vo.PluginEntity{ PluginID: pluginID, PluginVersion: pl.PluginVersion, + PluginFrom: pl.PluginFrom, }, ToolIDs: []int64{toolID}, IsDraft: pl.IsDraft, @@ -2940,7 +2943,8 @@ func (w *ApplicationService) GetLLMNodeFCSettingsMerged(ctx context.Context, req pluginReq := &plugin.ToolsInfoRequest{ PluginEntity: vo.PluginEntity{ - PluginID: pluginID, + PluginID: pluginID, + PluginFrom: pluginFcSetting.PluginFrom, }, ToolIDs: []int64{toolID}, IsDraft: isDraft, diff --git a/backend/crossdomain/contract/plugin/consts/consts.go b/backend/crossdomain/contract/plugin/consts/consts.go index 658add7df..a1677e458 100644 --- a/backend/crossdomain/contract/plugin/consts/consts.go +++ b/backend/crossdomain/contract/plugin/consts/consts.go @@ -32,6 +32,8 @@ const ( AuthzTypeOfNone AuthzType = "none" AuthzTypeOfService AuthzType = "service_http" AuthzTypeOfOAuth AuthzType = "oauth" + + AuthTypeOfSaasInstalled AuthzType = "saas_installed" ) type AuthzSubType string diff --git a/backend/crossdomain/contract/plugin/convert/api/api.go b/backend/crossdomain/contract/plugin/convert/api/api.go index fb0f344e2..1e2d0fbc1 100644 --- a/backend/crossdomain/contract/plugin/convert/api/api.go +++ b/backend/crossdomain/contract/plugin/convert/api/api.go @@ -266,11 +266,14 @@ func toOpenapi3Schema(apiParam *common.APIParameter) (*openapi3.Schema, error) { sc := &openapi3.Schema{ Description: apiParam.Desc, Type: paramType, - Default: apiParam.GlobalDefault, Extensions: map[string]interface{}{ consts.APISchemaExtendGlobalDisable: apiParam.GlobalDisable, }, } + if apiParam.GlobalDefault != nil && *apiParam.GlobalDefault != "" { + sc.Default = apiParam.GlobalDefault + } + if apiParam.LocalDefault != nil && *apiParam.LocalDefault != "" { sc.Default = apiParam.LocalDefault } diff --git a/backend/crossdomain/contract/plugin/model/plugin.go b/backend/crossdomain/contract/plugin/model/plugin.go index d9ee5dc06..76ec09118 100644 --- a/backend/crossdomain/contract/plugin/model/plugin.go +++ b/backend/crossdomain/contract/plugin/model/plugin.go @@ -17,9 +17,15 @@ package model import ( + "github.com/coze-dev/coze-studio/backend/api/model/app/bot_common" api "github.com/coze-dev/coze-studio/backend/api/model/plugin_develop/common" ) +type BindToolInfo struct { + ToolID int64 + PluginID int64 + Source *bot_common.PluginFrom +} type VersionPlugin struct { PluginID int64 Version string @@ -37,6 +43,7 @@ type PluginInfo struct { APPID *int64 RefProductID *int64 // for product plugin IconURI *string + IconURL *string ServerURL *string Version *string VersionDesc *string @@ -44,10 +51,18 @@ type PluginInfo struct { CreatedAt int64 UpdatedAt int64 + Source *bot_common.PluginFrom + SaasPluginExtra *SaasPluginExtraInfo + Extra map[string]any + Manifest *PluginManifest OpenapiDoc *Openapi3T } +type SaasPluginExtraInfo struct { + IsOfficial bool + JumpSaasURL *string +} type ToolExample struct { RequestExample string ResponseExample string @@ -77,3 +92,10 @@ type CheckCanPublishPluginsRequest struct { type CheckCanPublishPluginsResponse struct { InvalidPlugins []*PluginInfo } + +type ListPluginProductsRequest struct{} + +type ListPluginProductsResponse struct { + Plugins []*PluginInfo + Total int64 +} diff --git a/backend/crossdomain/contract/plugin/model/toolinfo.go b/backend/crossdomain/contract/plugin/model/toolinfo.go index 7d512e498..a4ee64e6a 100644 --- a/backend/crossdomain/contract/plugin/model/toolinfo.go +++ b/backend/crossdomain/contract/plugin/model/toolinfo.go @@ -25,6 +25,7 @@ import ( "github.com/getkin/kin-openapi/openapi3" gonanoid "github.com/matoous/go-nanoid" + "github.com/coze-dev/coze-studio/backend/api/model/app/bot_common" 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/crossdomain/contract/plugin/consts" @@ -43,6 +44,9 @@ type ToolInfo struct { ActivatedStatus *consts.ActivatedStatus DebugStatus *common.APIDebugStatus + Source *bot_common.PluginFrom + Extra map[string]any + Method *string SubURL *string Operation *Openapi3Operation @@ -66,6 +70,10 @@ func (t ToolInfo) GetVersion() string { return ptr.FromOrDefault(t.Version, "") } +func (t ToolInfo) GetPluginFrom() bot_common.PluginFrom { + return ptr.FromOrDefault(t.Source, 0) +} + func (t ToolInfo) GetActivatedStatus() consts.ActivatedStatus { return ptr.FromOrDefault(t.ActivatedStatus, consts.ActivateTool) } @@ -600,7 +608,9 @@ type VersionAgentTool struct { ToolName *string ToolID int64 + PluginID int64 AgentVersion *string + PluginFrom *bot_common.PluginFrom } type MGetAgentToolsRequest struct { @@ -618,6 +628,8 @@ type ExecuteToolRequest struct { ExecDraftTool bool // if true, execute draft tool ExecScene consts.ExecuteScene + PluginFrom *bot_common.PluginFrom + ArgumentsInJson string } diff --git a/backend/crossdomain/contract/plugin/plugin.go b/backend/crossdomain/contract/plugin/plugin.go index 3522ee065..bfde11973 100644 --- a/backend/crossdomain/contract/plugin/plugin.go +++ b/backend/crossdomain/contract/plugin/plugin.go @@ -23,11 +23,12 @@ import ( "github.com/coze-dev/coze-studio/backend/api/model/crossdomain/workflow" model "github.com/coze-dev/coze-studio/backend/crossdomain/contract/plugin/model" + "github.com/coze-dev/coze-studio/backend/domain/plugin/entity" ) //go:generate mockgen -destination pluginmock/plugin_mock.go --package pluginmock -source plugin.go type PluginService interface { - BindAgentTools(ctx context.Context, agentID int64, toolIDs []int64) (err error) + BindAgentTools(ctx context.Context, agentID int64, bindTools []*model.BindToolInfo) (err error) MGetAgentTools(ctx context.Context, req *model.MGetAgentToolsRequest) (tools []*model.ToolInfo, err error) ExecuteTool(ctx context.Context, req *model.ExecuteToolRequest, opts ...model.ExecuteToolOpt) (resp *model.ExecuteToolResponse, err error) PublishAPPPlugins(ctx context.Context, req *model.PublishAPPPluginsRequest) (resp *model.PublishAPPPluginsResponse, err error) @@ -38,6 +39,8 @@ type PluginService interface { MGetDraftTools(ctx context.Context, pluginIDs []int64) (tools []*model.ToolInfo, err error) MGetOnlineTools(ctx context.Context, pluginIDs []int64) (tools []*model.ToolInfo, err error) MGetVersionTools(ctx context.Context, versionTools []model.VersionTool) (tools []*model.ToolInfo, err error) + + BatchGetSaasPluginToolsInfo(ctx context.Context, pluginIDs []int64) (tools map[int64][]*entity.ToolInfo, plugins map[int64]*model.PluginInfo, err error) } type InvokableTool interface { diff --git a/backend/crossdomain/contract/plugin/pluginmock/plugin_mock.go b/backend/crossdomain/contract/plugin/pluginmock/plugin_mock.go index f1f2d291b..18573c127 100644 --- a/backend/crossdomain/contract/plugin/pluginmock/plugin_mock.go +++ b/backend/crossdomain/contract/plugin/pluginmock/plugin_mock.go @@ -1,3 +1,19 @@ +/* + * Copyright 2025 coze-dev Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + // Code generated by MockGen. DO NOT EDIT. // Source: plugin.go // @@ -15,7 +31,8 @@ import ( schema "github.com/cloudwego/eino/schema" workflow "github.com/coze-dev/coze-studio/backend/api/model/crossdomain/workflow" - "github.com/coze-dev/coze-studio/backend/crossdomain/contract/plugin/model" + model "github.com/coze-dev/coze-studio/backend/crossdomain/contract/plugin/model" + entity "github.com/coze-dev/coze-studio/backend/domain/plugin/entity" gomock "go.uber.org/mock/gomock" ) @@ -43,18 +60,34 @@ func (m *MockPluginService) EXPECT() *MockPluginServiceMockRecorder { return m.recorder } -// BindAgentTools mocks base method. -func (m *MockPluginService) BindAgentTools(ctx context.Context, agentID int64, toolIDs []int64) error { +// BatchGetSaasPluginToolsInfo mocks base method. +func (m *MockPluginService) BatchGetSaasPluginToolsInfo(ctx context.Context, pluginIDs []int64) (map[int64][]*entity.ToolInfo, map[int64]*model.PluginInfo, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "BindAgentTools", ctx, agentID, toolIDs) + ret := m.ctrl.Call(m, "BatchGetSaasPluginToolsInfo", ctx, pluginIDs) + ret0, _ := ret[0].(map[int64][]*entity.ToolInfo) + ret1, _ := ret[1].(map[int64]*model.PluginInfo) + ret2, _ := ret[2].(error) + return ret0, ret1, ret2 +} + +// BatchGetSaasPluginToolsInfo indicates an expected call of BatchGetSaasPluginToolsInfo. +func (mr *MockPluginServiceMockRecorder) BatchGetSaasPluginToolsInfo(ctx, pluginIDs any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "BatchGetSaasPluginToolsInfo", reflect.TypeOf((*MockPluginService)(nil).BatchGetSaasPluginToolsInfo), ctx, pluginIDs) +} + +// BindAgentTools mocks base method. +func (m *MockPluginService) BindAgentTools(ctx context.Context, agentID int64, bindTools []*model.BindToolInfo) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "BindAgentTools", ctx, agentID, bindTools) ret0, _ := ret[0].(error) return ret0 } // BindAgentTools indicates an expected call of BindAgentTools. -func (mr *MockPluginServiceMockRecorder) BindAgentTools(ctx, agentID, toolIDs any) *gomock.Call { +func (mr *MockPluginServiceMockRecorder) BindAgentTools(ctx, agentID, bindTools any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "BindAgentTools", reflect.TypeOf((*MockPluginService)(nil).BindAgentTools), ctx, agentID, toolIDs) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "BindAgentTools", reflect.TypeOf((*MockPluginService)(nil).BindAgentTools), ctx, agentID, bindTools) } // ExecuteTool mocks base method. diff --git a/backend/crossdomain/impl/plugin/plugin.go b/backend/crossdomain/impl/plugin/plugin.go index 21bfca9cd..ee37bbdfb 100644 --- a/backend/crossdomain/impl/plugin/plugin.go +++ b/backend/crossdomain/impl/plugin/plugin.go @@ -43,8 +43,8 @@ func InitDomainService(c plugin.PluginService, tos storage.Storage) crossplugin. return defaultSVC } -func (s *impl) BindAgentTools(ctx context.Context, agentID int64, toolIDs []int64) (err error) { - return s.DomainSVC.BindAgentTools(ctx, agentID, toolIDs) +func (s *impl) BindAgentTools(ctx context.Context, agentID int64, bindTools []*model.BindToolInfo) (err error) { + return s.DomainSVC.BindAgentTools(ctx, agentID, bindTools) } func (s *impl) MGetAgentTools(ctx context.Context, req *model.MGetAgentToolsRequest) (tools []*model.ToolInfo, err error) { @@ -84,6 +84,26 @@ func (s *impl) MGetDraftPlugins(ctx context.Context, pluginIDs []int64) (plugins return plugins, nil } +func (s *impl) BatchGetSaasPluginToolsInfo(ctx context.Context, pluginIDs []int64) (map[int64][]*model.ToolInfo, map[int64]*model.PluginInfo, error) { + + tools, plugins, err := s.DomainSVC.BatchGetSaasPluginToolsInfo(ctx, pluginIDs) + if err != nil { + return nil, nil, err + } + + var mPlugins map[int64]*model.PluginInfo + mPlugins = make(map[int64]*model.PluginInfo) + for _, p := range plugins { + mPlugins[p.ID] = p.PluginInfo + } + var mTools map[int64][]*model.ToolInfo + mTools = make(map[int64][]*model.ToolInfo) + for id, t := range tools { + mTools[id] = t + } + + return mTools, mPlugins, nil +} func (s *impl) MGetOnlinePlugins(ctx context.Context, pluginIDs []int64) (plugins []*model.PluginInfo, err error) { ePlugins, err := s.DomainSVC.MGetOnlinePlugins(ctx, pluginIDs) diff --git a/backend/crossdomain/impl/singleagent/single_agent.go b/backend/crossdomain/impl/singleagent/single_agent.go index 28820eb24..4e1dbdbf5 100644 --- a/backend/crossdomain/impl/singleagent/single_agent.go +++ b/backend/crossdomain/impl/singleagent/single_agent.go @@ -78,6 +78,7 @@ func (c *impl) buildSingleAgentStreamExecuteReq(ctx context.Context, agentRuntim } return agentrun.ToolTypePlugin }(tool.Type), + PluginFrom: tool.PluginFrom, } }), ResumeInfo: agentRuntime.ResumeInfo, diff --git a/backend/domain/agent/singleagent/internal/agentflow/node_tool_plugin.go b/backend/domain/agent/singleagent/internal/agentflow/node_tool_plugin.go index 70741f9c2..e297d2be6 100644 --- a/backend/domain/agent/singleagent/internal/agentflow/node_tool_plugin.go +++ b/backend/domain/agent/singleagent/internal/agentflow/node_tool_plugin.go @@ -51,6 +51,8 @@ func newPluginTools(ctx context.Context, conf *toolConfig) ([]tool.InvokableTool return model.VersionAgentTool{ ToolID: a.GetApiId(), AgentVersion: ptr.Of(conf.agentIdentity.Version), + PluginFrom: a.PluginFrom, + PluginID: a.GetPluginId(), } }), } @@ -73,6 +75,7 @@ func newPluginTools(ctx context.Context, conf *toolConfig) ([]tool.InvokableTool isDraft: conf.agentIdentity.IsDraft, projectInfo: projectInfo, toolInfo: ti, + pluginFrom: ti.Source, conversationID: conf.conversationID, }) @@ -87,6 +90,8 @@ type pluginInvokableTool struct { toolInfo *pluginEntity.ToolInfo projectInfo *model.ProjectInfo + pluginFrom *bot_common.PluginFrom + conversationID int64 } @@ -117,6 +122,7 @@ func (p *pluginInvokableTool) InvokableRun(ctx context.Context, argumentsInJSON PluginID: p.toolInfo.PluginID, ToolID: p.toolInfo.ID, ExecDraftTool: false, + PluginFrom: p.pluginFrom, ArgumentsInJson: argumentsInJSON, ExecScene: func() consts.ExecuteScene { if p.isDraft { diff --git a/backend/domain/agent/singleagent/internal/agentflow/node_tool_pre_retriever.go b/backend/domain/agent/singleagent/internal/agentflow/node_tool_pre_retriever.go index 8fb55cdac..1f023d0eb 100644 --- a/backend/domain/agent/singleagent/internal/agentflow/node_tool_pre_retriever.go +++ b/backend/domain/agent/singleagent/internal/agentflow/node_tool_pre_retriever.go @@ -64,6 +64,7 @@ func (pr *toolPreCallConf) toolPreRetrieve(ctx context.Context, ar *AgentRequest return consts.ExecSceneOfOnlineAgent } }(ar.Identity.IsDraft), + PluginFrom: item.PluginFrom, } opts := []model.ExecuteToolOpt{ diff --git a/backend/domain/agent/singleagent/service/single_agent_impl.go b/backend/domain/agent/singleagent/service/single_agent_impl.go index 0f0e747e4..6d36bf61f 100644 --- a/backend/domain/agent/singleagent/service/single_agent_impl.go +++ b/backend/domain/agent/singleagent/service/single_agent_impl.go @@ -28,6 +28,7 @@ import ( "github.com/coze-dev/coze-studio/backend/api/model/app/bot_common" crossplugin "github.com/coze-dev/coze-studio/backend/crossdomain/contract/plugin" + "github.com/coze-dev/coze-studio/backend/crossdomain/contract/plugin/model" "github.com/coze-dev/coze-studio/backend/domain/agent/singleagent/entity" "github.com/coze-dev/coze-studio/backend/domain/agent/singleagent/internal/agentflow" "github.com/coze-dev/coze-studio/backend/domain/agent/singleagent/repository" @@ -148,10 +149,13 @@ func (s *singleAgentImpl) GetSingleAgent(ctx context.Context, agentID int64, ver func (s *singleAgentImpl) UpdateSingleAgentDraft(ctx context.Context, agentInfo *entity.SingleAgent) (err error) { if agentInfo.Plugin != nil { - toolIDs := slices.Transform(agentInfo.Plugin, func(item *bot_common.PluginInfo) int64 { - return item.GetApiId() - }) - err = crossplugin.DefaultSVC().BindAgentTools(ctx, agentInfo.AgentID, toolIDs) + err = crossplugin.DefaultSVC().BindAgentTools(ctx, agentInfo.AgentID, slices.Transform(agentInfo.Plugin, func(item *bot_common.PluginInfo) *model.BindToolInfo { + return &model.BindToolInfo{ + ToolID: item.GetApiId(), + PluginID: item.GetPluginId(), + Source: item.PluginFrom, + } + })) if err != nil { return fmt.Errorf("bind agent tools failed, err=%v", err) } diff --git a/backend/domain/plugin/dto/coze_saas.go b/backend/domain/plugin/dto/coze_saas.go new file mode 100644 index 000000000..f9752a4fb --- /dev/null +++ b/backend/domain/plugin/dto/coze_saas.go @@ -0,0 +1,321 @@ +/* + * 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 ( + "encoding/json" + + "github.com/coze-dev/coze-studio/backend/api/model/marketplace/product_common" +) + +// SearchSaasPluginRequest represents the request parameters for searching SaaS plugins +type SearchSaasPluginRequest struct { + Keyword *string `json:"keyword,omitempty"` + PageNum *int `json:"page_num,omitempty"` + PageSize *int `json:"page_size,omitempty"` + SortType *string `json:"sort_type,omitempty"` + CategoryIDs []int64 `json:"category_ids,omitempty"` + IsOfficial *bool `json:"is_official,omitempty"` + ProductPaidType *product_common.ProductPaidType `json:"product_paid_type,omitempty"` +} + +// SearchSaasPluginResponse represents the response from coze.cn search API +type SearchSaasPluginResponse struct { + Code int `json:"code"` + Msg string `json:"msg"` + Detail *ResponseDetail `json:"detail,omitempty"` + Data *SearchSaasPluginData `json:"data"` +} + +// ResponseDetail represents the detail section of API response +type ResponseDetail struct { + LogID string `json:"logid"` +} + +// SearchSaasPluginData represents the data section of search response +type SearchSaasPluginData struct { + Items []*SaasPluginItem `json:"items"` + HasMore bool `json:"has_more"` +} + +// SaasPluginItem represents a single plugin item in search results +type SaasPluginItem struct { + MetaInfo *SaasPluginMetaInfo `json:"metainfo"` + PluginInfo *SaasPluginInfo `json:"plugin_info"` +} + +// SaasPluginMetaInfo represents the metadata of a SaaS plugin +type SaasPluginMetaInfo struct { + ProductID string `json:"product_id"` + EntityID string `json:"entity_id"` + EntityVersion string `json:"entity_version"` + EntityType string `json:"entity_type"` + Name string `json:"name"` + Description string `json:"description"` + UserInfo *SaasPluginUserInfo `json:"user_info"` + Category *SaasPluginCategory `json:"category"` + IconURL string `json:"icon_url"` + ProductURL string `json:"product_url"` + ListedAt int64 `json:"listed_at"` + PaidType string `json:"paid_type"` + IsOfficial bool `json:"is_official"` +} + +// SaasPluginUserInfo represents the user information of a SaaS plugin +type SaasPluginUserInfo struct { + UserID string `json:"user_id"` + UserName string `json:"user_name"` + NickName string `json:"nick_name"` + AvatarURL string `json:"avatar_url"` +} + +// SaasPluginCategory represents the category information of a SaaS plugin +type SaasPluginCategory struct { + ID string `json:"id"` + Name string `json:"name"` +} + +// SaasPluginInfo represents the plugin statistics and information +type SaasPluginInfo struct { + Description string `json:"description"` + TotalToolsCount int `json:"total_tools_count"` + FavoriteCount int `json:"favorite_count"` + Heat int `json:"heat"` + SuccessRate float64 `json:"success_rate"` + AvgExecDurationMs float64 `json:"avg_exec_duration_ms"` + BotsUseCount int64 `json:"bots_use_count"` + AssociatedBotsUseCount int64 `json:"associated_bots_use_count"` + CallCount int64 `json:"call_count"` + IsCallAvailable bool `json:"is_call_available"` +} + +type ListPluginCategoriesRequest struct { + PageNum *int `json:"page_num,omitempty"` + PageSize *int `json:"page_size,omitempty"` + EntityType *string `json:"entity_type,omitempty"` +} + +type ListPluginCategoriesResponse struct { + Code int `json:"code"` + Msg string `json:"msg"` + Data *ListPluginCategoriesData `json:"data"` +} + +type ListPluginCategoriesData struct { + Items []*PluginCategoryItem `json:"items"` + HasMore bool `json:"has_more"` +} + +type PluginCategoryItem struct { + ID string `json:"id"` + Name string `json:"name"` +} + +type GetSaasPluginCallInfoRequest struct { + PluginID int64 `json:"plugin_id"` +} + +type GetSaasPluginCallInfoResponse struct { + Code int `json:"code"` + Msg string `json:"msg"` + Data *GetSaasPluginCallInfoData `json:"data"` +} + +type GetSaasPluginCallInfoData struct { +} + +type JsonSchemaType int32 + +const ( + JsonSchemaType_STRING JsonSchemaType = 1 + JsonSchemaType_NUMBER JsonSchemaType = 2 + JsonSchemaType_INTEGER JsonSchemaType = 3 + JsonSchemaType_BOOLEAN JsonSchemaType = 4 + JsonSchemaType_OBJECT JsonSchemaType = 5 + JsonSchemaType_ARRAY JsonSchemaType = 6 + JsonSchemaType_NULL JsonSchemaType = 7 +) + +type AnyValue struct { + Type JsonSchemaType `json:"type,omitempty"` + StringValue string `json:"stringValue,omitempty"` +} +type JsonSchema struct { + // core + ID string `json:"$id,omitempty"` + Schema string `json:"$schema,omitempty"` + Ref string `json:"$ref,omitempty"` + Comment string `json:"$comment,omitempty"` + Defs map[string]*JsonSchema `json:"$defs,omitempty"` + Definitions map[string]*JsonSchema `json:"definitions,omitempty"` // deprecated but still allowed + + Anchor string `json:"$anchor,omitempty"` + DynamicAnchor string `json:"$dynamicAnchor,omitempty"` + DynamicRef string `json:"$dynamicRef,omitempty"` + Vocabulary map[string]bool `json:"$vocabulary,omitempty"` + + // metadata + Title string `json:"title,omitempty"` + Description string `json:"description,omitempty"` + Default interface{} `json:"default,omitempty"` + Deprecated bool `json:"deprecated,omitempty"` + ReadOnly bool `json:"readOnly,omitempty"` + WriteOnly bool `json:"writeOnly,omitempty"` + + // validation + // Use Type for a single type, or Types for multiple types; never both. + Type JsonSchemaType `json:"type,omitempty"` + Types []JsonSchemaType `json:"types,omitempty"` + Enum []*AnyValue `json:"enum,omitempty"` + MultipleOf *float64 `json:"multipleOf,omitempty"` + Minimum *float64 `json:"minimum,omitempty"` + Maximum *float64 `json:"maximum,omitempty"` + ExclusiveMinimum *bool `json:"exclusiveMinimum,omitempty"` + ExclusiveMaximum *bool `json:"exclusiveMaximum,omitempty"` + MinLength *int32 `json:"minLength,omitempty"` + MaxLength *int32 `json:"maxLength,omitempty"` + Pattern string `json:"pattern,omitempty"` + + // arrays + PrefixItems []*JsonSchema `json:"prefixItems,omitempty"` + Items *JsonSchema `json:"items,omitempty"` + MinItems *int32 `json:"minItems,omitempty"` + MaxItems *int32 `json:"maxItems,omitempty"` + AdditionalItems *JsonSchema `json:"additionalItems,omitempty"` + UniqueItems bool `json:"uniqueItems,omitempty"` + Contains *JsonSchema `json:"contains,omitempty"` + MinContains *int32 `json:"minContains,omitempty"` + MaxContains *int32 `json:"maxContains,omitempty"` + UnevaluatedItems *JsonSchema `json:"unevaluatedItems,omitempty"` + + // objects + MinProperties *int32 `json:"minProperties,omitempty"` + MaxProperties *int32 `json:"maxProperties,omitempty"` + Required []string `json:"required,omitempty"` + DependentRequired map[string][]string `json:"dependentRequired,omitempty"` + Properties map[string]*JsonSchema `json:"properties,omitempty"` + PatternProperties map[string]*JsonSchema `json:"patternProperties,omitempty"` + AdditionalProperties *JsonSchema `json:"additionalProperties,omitempty"` + PropertyNames *JsonSchema `json:"propertyNames,omitempty"` + UnevaluatedProperties *JsonSchema `json:"unevaluatedProperties,omitempty"` + + // logic + AllOf []*JsonSchema `json:"allOf,omitempty"` + AnyOf []*JsonSchema `json:"anyOf,omitempty"` + OneOf []*JsonSchema `json:"oneOf,omitempty"` + Not *JsonSchema `json:"not,omitempty"` + + // conditional + If map[string]*JsonSchema `json:"if,omitempty"` + Then map[string]*JsonSchema `json:"then,omitempty"` + Else map[string]*JsonSchema `json:"else,omitempty"` + DependentSchemas map[string]*JsonSchema `json:"dependentSchemas,omitempty"` + + // other + ContentEncoding *JsonSchema `json:"contentEncoding,omitempty"` + ContentMediaType *JsonSchema `json:"contentMediaType,omitempty"` + ContentSchema *JsonSchema `json:"contentSchema,omitempty"` + + Format string `json:"format,omitempty"` + + // Extra allows for additional keywords beyond those specified. + Extra map[string]*JsonSchema `json:"-"` +} + +type SaasPluginToolsListResponse struct { + Items []SaasPluginToolsList `json:"items"` +} +type SaasPluginToolsList struct { + Tools []Tools `json:"tools"` + PluginID string `json:"plugin_id"` + Name string `json:"name"` + NameForModel string `json:"name_for_model"` + Description string `json:"description"` + IconURL string `json:"icon_url"` + Category string `json:"category"` + CreatedAt int64 `json:"created_at"` + UpdatedAt int64 `json:"updated_at"` + IsCallAvailable bool `json:"is_call_available"` + McpJSON string `json:"mcp_json"` +} + +type Tools struct { + ToolID string `json:"tool_id"` + Description string `json:"description"` + InputSchema *JsonSchema `json:"inputSchema"` + Name string `json:"name"` + OutputSchema *JsonSchema `json:"outputSchema"` +} + +// stringToJsonSchemaType converts a string to JsonSchemaType +func stringToJsonSchemaType(s string) JsonSchemaType { + switch s { + case "string": + return JsonSchemaType_STRING + case "number": + return JsonSchemaType_NUMBER + case "integer": + return JsonSchemaType_INTEGER + case "boolean": + return JsonSchemaType_BOOLEAN + case "object": + return JsonSchemaType_OBJECT + case "array": + return JsonSchemaType_ARRAY + case "null": + return JsonSchemaType_NULL + default: + return JsonSchemaType_STRING // default fallback + } +} + +// UnmarshalJSON implements custom JSON unmarshaling for JsonSchema +func (js *JsonSchema) UnmarshalJSON(data []byte) error { + // Create a temporary struct with the same fields but string type for Type field + type Alias JsonSchema + aux := &struct { + TypeString interface{} `json:"type"` + *Alias + }{ + Alias: (*Alias)(&JsonSchema{}), + } + + if err := json.Unmarshal(data, &aux); err != nil { + return err + } + + // Copy all fields from aux.Alias to js + *js = JsonSchema(*aux.Alias) + + // Handle the type field conversion + if aux.TypeString != nil { + switch v := aux.TypeString.(type) { + case string: + js.Type = stringToJsonSchemaType(v) + case []interface{}: + // Handle array of types + js.Types = make([]JsonSchemaType, len(v)) + for i, typeVal := range v { + if typeStr, ok := typeVal.(string); ok { + js.Types[i] = stringToJsonSchemaType(typeStr) + } + } + } + } + + return nil +} diff --git a/backend/domain/plugin/dto/plugin.go b/backend/domain/plugin/dto/plugin.go index 9f6c18cc0..e71994dfb 100644 --- a/backend/domain/plugin/dto/plugin.go +++ b/backend/domain/plugin/dto/plugin.go @@ -17,6 +17,7 @@ package dto import ( + "github.com/coze-dev/coze-studio/backend/api/model/marketplace/product_common" "github.com/coze-dev/coze-studio/backend/api/model/plugin_develop/common" "github.com/coze-dev/coze-studio/backend/crossdomain/contract/plugin/consts" "github.com/coze-dev/coze-studio/backend/crossdomain/contract/plugin/model" @@ -94,11 +95,25 @@ type CreateDraftPluginWithCodeResponse struct { Tools []*entity.ToolInfo } -type ListPluginProductsRequest struct{} +type ListPluginProductsRequest struct { +} + +type ListSaasPluginProductsRequest struct { + PageNum *int32 `json:"page_num,omitempty"` + PageSize *int32 `json:"page_size,omitempty"` + Keyword *string `json:"keyword,omitempty"` + EntityTypes []product_common.ProductEntityType `json:"entity_types,omitempty"` + CategoryIDs []int64 `json:"category_ids,omitempty"` + IsOfficial *bool `json:"is_official,omitempty"` + PluginType *product_common.PluginType `json:"plugin_type,omitempty"` + ProductPaidType *product_common.ProductPaidType `json:"product_paid_type,omitempty"` + SortType *product_common.SortType `json:"sort_type,omitempty"` +} type ListPluginProductsResponse struct { Plugins []*entity.PluginInfo Total int64 + HasMore bool } type CopyPluginRequest struct { @@ -113,3 +128,51 @@ type CopyPluginResponse struct { Plugin *entity.PluginInfo Tools map[int64]*entity.ToolInfo // old tool id -> new tool } + +// DefaultParamSource 表示默认参数的设置来源 +type DefaultParamSource int32 + +const ( + DefaultParamSource_Input DefaultParamSource = 0 // 默认用户输入 + DefaultParamSource_Variable DefaultParamSource = 1 // 引用变量 +) + +// AssistParameterType 表示辅助参数类型 +type AssistParameterType int32 + +const ( + AssistParameterType_DEFAULT AssistParameterType = 1 + AssistParameterType_IMAGE AssistParameterType = 2 + AssistParameterType_DOC AssistParameterType = 3 + AssistParameterType_CODE AssistParameterType = 4 + AssistParameterType_PPT AssistParameterType = 5 + AssistParameterType_TXT AssistParameterType = 6 + AssistParameterType_EXCEL AssistParameterType = 7 + AssistParameterType_AUDIO AssistParameterType = 8 + AssistParameterType_ZIP AssistParameterType = 9 + AssistParameterType_VIDEO AssistParameterType = 10 +) + +type Parameter struct { + Name string `json:"name,omitempty"` + Desc string `json:"desc,omitempty"` + Required bool `json:"required,omitempty"` + Type string `json:"type,omitempty"` + SubParameters []*Parameter `json:"subParameters,omitempty"` + SubType string `json:"subType,omitempty"` // 如果Type是数组,则有subtype + FromNodeId *string `json:"fromNodeId,omitempty"` // 如果入参的值是引用的则有fromNodeId + FromOutput []string `json:"fromOutput,omitempty"` // 具体引用哪个节点的key + Value *string `json:"value,omitempty"` // 如果入参是用户手输 就放这里 + Format *string `json:"format,omitempty"` + Title *string `json:"title,omitempty"` + EnumList []string `json:"enumList,omitempty"` + EnumVarNames []string `json:"enumVarNames,omitempty"` + Minimum *float64 `json:"minimum,omitempty"` + Maximum *float64 `json:"maximum,omitempty"` + ExclusiveMinimum *bool `json:"exclusiveMinimum,omitempty"` + ExclusiveMaximum *bool `json:"exclusiveMaximum,omitempty"` + BizExtend *string `json:"bizExtend,omitempty"` + DefaultParamSource *DefaultParamSource `json:"defaultParamSource,omitempty"` // 默认入参的设置来源 + VariableRef *string `json:"variableRef,omitempty"` // 引用variable的key + AssistType *AssistParameterType `json:"assistType,omitempty"` +} diff --git a/backend/domain/plugin/dto/tool.go b/backend/domain/plugin/dto/tool.go index bfa86df8a..ac7ff21e0 100644 --- a/backend/domain/plugin/dto/tool.go +++ b/backend/domain/plugin/dto/tool.go @@ -63,12 +63,13 @@ type ConvertToOpenapi3DocResponse struct { } type UpdateBotDefaultParamsRequest struct { - PluginID int64 - AgentID int64 - ToolName string - Parameters openapi3.Parameters - RequestBody *openapi3.RequestBodyRef - Responses openapi3.Responses + PluginID int64 + AgentID int64 + ToolName string + Parameters openapi3.Parameters + RequestBody *openapi3.RequestBodyRef + Responses openapi3.Responses + PluginFormat *common.PluginDataFormat } type UniqueToolAPI struct { SubURL string diff --git a/backend/domain/plugin/entity/tool.go b/backend/domain/plugin/entity/tool.go index 271914d2c..bea81b60a 100644 --- a/backend/domain/plugin/entity/tool.go +++ b/backend/domain/plugin/entity/tool.go @@ -16,6 +16,8 @@ package entity -import "github.com/coze-dev/coze-studio/backend/crossdomain/contract/plugin/model" +import ( + "github.com/coze-dev/coze-studio/backend/crossdomain/contract/plugin/model" +) type ToolInfo = model.ToolInfo diff --git a/backend/domain/plugin/internal/dal/agent_tool_draft.go b/backend/domain/plugin/internal/dal/agent_tool_draft.go index 886c7ed0b..cfc5c1ad1 100644 --- a/backend/domain/plugin/internal/dal/agent_tool_draft.go +++ b/backend/domain/plugin/internal/dal/agent_tool_draft.go @@ -24,10 +24,12 @@ import ( "gorm.io/gorm" "gorm.io/gorm/clause" + "github.com/coze-dev/coze-studio/backend/api/model/app/bot_common" "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" "github.com/coze-dev/coze-studio/backend/infra/idgen" + "github.com/coze-dev/coze-studio/backend/pkg/lang/ptr" "github.com/coze-dev/coze-studio/backend/pkg/lang/slices" ) @@ -54,6 +56,7 @@ func (a agentToolDraftPO) ToDO() *entity.ToolInfo { Method: &a.Method, SubURL: &a.SubURL, Operation: a.Operation, + Source: ptr.Of(bot_common.PluginFrom(a.Source)), } } @@ -221,6 +224,9 @@ func (at *AgentToolDraftDAO) batchCreateWithTX(ctx context.Context, tx *query.Qu ToolName: tl.GetName(), Operation: tl.Operation, } + if tl.Source != nil { + m.Source = int32(ptr.From(tl.Source)) + } tls = append(tls, m) } diff --git a/backend/domain/plugin/internal/dal/agent_tool_version.go b/backend/domain/plugin/internal/dal/agent_tool_version.go index 4c5961e21..bdf47d657 100644 --- a/backend/domain/plugin/internal/dal/agent_tool_version.go +++ b/backend/domain/plugin/internal/dal/agent_tool_version.go @@ -24,11 +24,13 @@ import ( "gorm.io/gen" "gorm.io/gorm" + "github.com/coze-dev/coze-studio/backend/api/model/app/bot_common" pluginModel "github.com/coze-dev/coze-studio/backend/crossdomain/contract/plugin/model" "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" "github.com/coze-dev/coze-studio/backend/infra/idgen" + "github.com/coze-dev/coze-studio/backend/pkg/lang/ptr" "github.com/coze-dev/coze-studio/backend/pkg/lang/slices" ) @@ -54,6 +56,7 @@ func (a agentToolVersionPO) ToDO() *entity.ToolInfo { Method: &a.Method, SubURL: &a.SubURL, Operation: a.Operation, + Source: ptr.Of(bot_common.PluginFrom(a.Source)), } } @@ -215,6 +218,7 @@ func (at *AgentToolVersionDAO) BatchCreate(ctx context.Context, agentID int64, a Method: tl.GetMethod(), ToolName: tl.GetName(), Operation: tl.Operation, + Source: int32(ptr.From(tl.Source)), }) } diff --git a/backend/domain/plugin/internal/dal/model/agent_tool_draft.gen.go b/backend/domain/plugin/internal/dal/model/agent_tool_draft.gen.go index 54e5c60ad..913392496 100644 --- a/backend/domain/plugin/internal/dal/model/agent_tool_draft.gen.go +++ b/backend/domain/plugin/internal/dal/model/agent_tool_draft.gen.go @@ -1,12 +1,26 @@ +/* + * Copyright 2025 coze-dev Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + // Code generated by gorm.io/gen. DO NOT EDIT. // Code generated by gorm.io/gen. DO NOT EDIT. // Code generated by gorm.io/gen. DO NOT EDIT. package model -import ( - "github.com/coze-dev/coze-studio/backend/crossdomain/contract/plugin/model" -) +import "github.com/coze-dev/coze-studio/backend/crossdomain/contract/plugin/model" const TableNameAgentToolDraft = "agent_tool_draft" @@ -22,6 +36,7 @@ type AgentToolDraft struct { 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 *model.Openapi3Operation `gorm:"column:operation;comment:Tool Openapi Operation Schema;serializer:json" json:"operation"` // Tool Openapi Operation Schema + Source int32 `gorm:"column:source;not null;comment:tool source 1 coze saas 0 default" json:"source"` // tool source 1 coze saas 0 default } // TableName AgentToolDraft's table name diff --git a/backend/domain/plugin/internal/dal/model/agent_tool_version.gen.go b/backend/domain/plugin/internal/dal/model/agent_tool_version.gen.go index e47a313da..2ab79f659 100644 --- a/backend/domain/plugin/internal/dal/model/agent_tool_version.gen.go +++ b/backend/domain/plugin/internal/dal/model/agent_tool_version.gen.go @@ -1,3 +1,19 @@ +/* + * Copyright 2025 coze-dev Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + // Code generated by gorm.io/gen. DO NOT EDIT. // Code generated by gorm.io/gen. DO NOT EDIT. // Code generated by gorm.io/gen. DO NOT EDIT. @@ -21,6 +37,7 @@ type AgentToolVersion struct { Method string `gorm:"column:method;not null;comment:HTTP Request Method" json:"method"` // HTTP Request Method Operation *model.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 + Source int32 `gorm:"column:source;not null;comment:tool source 1 coze saas 0 default" json:"source"` // tool source 1 coze saas 0 default } // TableName AgentToolVersion's table name diff --git a/backend/domain/plugin/internal/dal/model/plugin.gen.go b/backend/domain/plugin/internal/dal/model/plugin.gen.go index c1c1ec981..b2412f116 100644 --- a/backend/domain/plugin/internal/dal/model/plugin.gen.go +++ b/backend/domain/plugin/internal/dal/model/plugin.gen.go @@ -1,3 +1,19 @@ +/* + * Copyright 2025 coze-dev Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + // Code generated by gorm.io/gen. DO NOT EDIT. // Code generated by gorm.io/gen. DO NOT EDIT. // Code generated by gorm.io/gen. DO NOT EDIT. @@ -10,19 +26,21 @@ 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 *model.PluginManifest `gorm:"column:manifest;comment:Plugin Manifest;serializer:json" json:"manifest"` // Plugin Manifest - OpenapiDoc *model.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 *model.PluginManifest `gorm:"column:manifest;comment:Plugin Manifest;serializer:json" json:"manifest"` // Plugin Manifest + OpenapiDoc *model.Openapi3T `gorm:"column:openapi_doc;comment:OpenAPI Document, only stores the root;serializer:json" json:"openapi_doc"` // OpenAPI Document, only stores the root + Source int32 `gorm:"column:source;not null;comment:plugin source 1 from saas 0 default" json:"source"` // plugin source 1 from saas 0 default + Ext map[string]interface{} `gorm:"column:ext;comment:extra ;serializer:json" json:"ext"` // extra } // TableName Plugin's table name diff --git a/backend/domain/plugin/internal/dal/model/plugin_version.gen.go b/backend/domain/plugin/internal/dal/model/plugin_version.gen.go index 0a8ee7f79..a323e4fe6 100644 --- a/backend/domain/plugin/internal/dal/model/plugin_version.gen.go +++ b/backend/domain/plugin/internal/dal/model/plugin_version.gen.go @@ -1,3 +1,19 @@ +/* + * Copyright 2025 coze-dev Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + // Code generated by gorm.io/gen. DO NOT EDIT. // Code generated by gorm.io/gen. DO NOT EDIT. // Code generated by gorm.io/gen. DO NOT EDIT. @@ -13,20 +29,22 @@ 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 *model.PluginManifest `gorm:"column:manifest;comment:Plugin Manifest;serializer:json" json:"manifest"` // Plugin Manifest - OpenapiDoc *model.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 *model.PluginManifest `gorm:"column:manifest;comment:Plugin Manifest;serializer:json" json:"manifest"` // Plugin Manifest + OpenapiDoc *model.Openapi3T `gorm:"column:openapi_doc;comment:OpenAPI Document, only stores the root;serializer:json" json:"openapi_doc"` // OpenAPI Document, only stores the root + Source int32 `gorm:"column:source;not null;comment:plugin source 1 from saas 0 default" json:"source"` // plugin source 1 from saas 0 default + Ext map[string]interface{} `gorm:"column:ext;comment:extra ;serializer:json" json:"ext"` // extra + 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 diff --git a/backend/domain/plugin/internal/dal/model/tool.gen.go b/backend/domain/plugin/internal/dal/model/tool.gen.go index 8fd09051a..9f5a83a5f 100644 --- a/backend/domain/plugin/internal/dal/model/tool.gen.go +++ b/backend/domain/plugin/internal/dal/model/tool.gen.go @@ -1,3 +1,19 @@ +/* + * Copyright 2025 coze-dev Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + // Code generated by gorm.io/gen. DO NOT EDIT. // Code generated by gorm.io/gen. DO NOT EDIT. // Code generated by gorm.io/gen. DO NOT EDIT. @@ -19,6 +35,8 @@ type Tool struct { Method string `gorm:"column:method;not null;comment:HTTP Request Method" json:"method"` // HTTP Request Method Operation *model.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 + Source int32 `gorm:"column:source;not null;comment:tool source 1 coze saas 0 default" json:"source"` // tool source 1 coze saas 0 default + Ext map[string]interface{} `gorm:"column:ext;comment:extra;serializer:json" json:"ext"` // extra } // TableName Tool's table name diff --git a/backend/domain/plugin/internal/dal/model/tool_version.gen.go b/backend/domain/plugin/internal/dal/model/tool_version.gen.go index 0a5ed9d1d..b2c766628 100644 --- a/backend/domain/plugin/internal/dal/model/tool_version.gen.go +++ b/backend/domain/plugin/internal/dal/model/tool_version.gen.go @@ -1,3 +1,19 @@ +/* + * Copyright 2025 coze-dev Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + // Code generated by gorm.io/gen. DO NOT EDIT. // Code generated by gorm.io/gen. DO NOT EDIT. // Code generated by gorm.io/gen. DO NOT EDIT. @@ -22,6 +38,8 @@ type ToolVersion struct { Operation *model.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 + Source int32 `gorm:"column:source;not null;comment:tool source 1 coze saas 0 default" json:"source"` // tool source 1 coze saas 0 default + Ext map[string]interface{} `gorm:"column:ext;comment:extra;serializer:json" json:"ext"` // extra } // TableName ToolVersion's table name diff --git a/backend/domain/plugin/internal/dal/plugin.go b/backend/domain/plugin/internal/dal/plugin.go index 200584dfd..071f5ff71 100644 --- a/backend/domain/plugin/internal/dal/plugin.go +++ b/backend/domain/plugin/internal/dal/plugin.go @@ -25,6 +25,7 @@ import ( "gorm.io/gen/field" "gorm.io/gorm" + "github.com/coze-dev/coze-studio/backend/api/model/app/bot_common" 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/model" "github.com/coze-dev/coze-studio/backend/domain/plugin/dto" @@ -63,6 +64,8 @@ func (p pluginPO) ToDO() *entity.PluginInfo { VersionDesc: &p.VersionDesc, Manifest: p.Manifest, OpenapiDoc: p.OpenapiDoc, + Source: bot_common.PluginFromPtr(bot_common.PluginFrom(p.Source)), + Extra: p.Ext, }) } diff --git a/backend/domain/plugin/internal/dal/plugin_version.go b/backend/domain/plugin/internal/dal/plugin_version.go index d9a264b70..c452fede8 100644 --- a/backend/domain/plugin/internal/dal/plugin_version.go +++ b/backend/domain/plugin/internal/dal/plugin_version.go @@ -24,6 +24,7 @@ import ( "gorm.io/gen/field" "gorm.io/gorm" + "github.com/coze-dev/coze-studio/backend/api/model/app/bot_common" 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/model" "github.com/coze-dev/coze-studio/backend/domain/plugin/dto" @@ -62,6 +63,8 @@ func (p pluginVersionPO) ToDO() *entity.PluginInfo { VersionDesc: &p.VersionDesc, Manifest: p.Manifest, OpenapiDoc: p.OpenapiDoc, + Source: bot_common.PluginFromPtr(bot_common.PluginFrom(p.Source)), + Extra: p.Ext, }) } diff --git a/backend/domain/plugin/internal/dal/query/agent_tool_draft.gen.go b/backend/domain/plugin/internal/dal/query/agent_tool_draft.gen.go index 519b8b28e..3756f4878 100644 --- a/backend/domain/plugin/internal/dal/query/agent_tool_draft.gen.go +++ b/backend/domain/plugin/internal/dal/query/agent_tool_draft.gen.go @@ -1,3 +1,19 @@ +/* + * Copyright 2025 coze-dev Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + // Code generated by gorm.io/gen. DO NOT EDIT. // Code generated by gorm.io/gen. DO NOT EDIT. // Code generated by gorm.io/gen. DO NOT EDIT. @@ -37,6 +53,7 @@ func newAgentToolDraft(db *gorm.DB, opts ...gen.DOOption) agentToolDraft { _agentToolDraft.ToolName = field.NewString(tableName, "tool_name") _agentToolDraft.ToolVersion = field.NewString(tableName, "tool_version") _agentToolDraft.Operation = field.NewField(tableName, "operation") + _agentToolDraft.Source = field.NewInt32(tableName, "source") _agentToolDraft.fillFieldMap() @@ -58,6 +75,7 @@ type agentToolDraft struct { ToolName field.String // Tool Name ToolVersion field.String // Tool Version, e.g. v1.0.0 Operation field.Field // Tool Openapi Operation Schema + Source field.Int32 // tool source 1 coze saas 0 default fieldMap map[string]field.Expr } @@ -84,6 +102,7 @@ func (a *agentToolDraft) updateTableName(table string) *agentToolDraft { a.ToolName = field.NewString(table, "tool_name") a.ToolVersion = field.NewString(table, "tool_version") a.Operation = field.NewField(table, "operation") + a.Source = field.NewInt32(table, "source") a.fillFieldMap() @@ -100,7 +119,7 @@ func (a *agentToolDraft) GetFieldByName(fieldName string) (field.OrderExpr, bool } func (a *agentToolDraft) fillFieldMap() { - a.fieldMap = make(map[string]field.Expr, 10) + a.fieldMap = make(map[string]field.Expr, 11) a.fieldMap["id"] = a.ID a.fieldMap["agent_id"] = a.AgentID a.fieldMap["plugin_id"] = a.PluginID @@ -111,6 +130,7 @@ func (a *agentToolDraft) fillFieldMap() { a.fieldMap["tool_name"] = a.ToolName a.fieldMap["tool_version"] = a.ToolVersion a.fieldMap["operation"] = a.Operation + a.fieldMap["source"] = a.Source } func (a agentToolDraft) clone(db *gorm.DB) agentToolDraft { diff --git a/backend/domain/plugin/internal/dal/query/agent_tool_version.gen.go b/backend/domain/plugin/internal/dal/query/agent_tool_version.gen.go index 6b76d609c..2fc5c8b66 100644 --- a/backend/domain/plugin/internal/dal/query/agent_tool_version.gen.go +++ b/backend/domain/plugin/internal/dal/query/agent_tool_version.gen.go @@ -1,3 +1,19 @@ +/* + * Copyright 2025 coze-dev Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + // Code generated by gorm.io/gen. DO NOT EDIT. // Code generated by gorm.io/gen. DO NOT EDIT. // Code generated by gorm.io/gen. DO NOT EDIT. @@ -38,6 +54,7 @@ func newAgentToolVersion(db *gorm.DB, opts ...gen.DOOption) agentToolVersion { _agentToolVersion.Method = field.NewString(tableName, "method") _agentToolVersion.Operation = field.NewField(tableName, "operation") _agentToolVersion.CreatedAt = field.NewInt64(tableName, "created_at") + _agentToolVersion.Source = field.NewInt32(tableName, "source") _agentToolVersion.fillFieldMap() @@ -60,6 +77,7 @@ type agentToolVersion struct { Method field.String // HTTP Request Method Operation field.Field // Tool Openapi Operation Schema CreatedAt field.Int64 // Create Time in Milliseconds + Source field.Int32 // tool source 1 coze saas 0 default fieldMap map[string]field.Expr } @@ -87,6 +105,7 @@ func (a *agentToolVersion) updateTableName(table string) *agentToolVersion { a.Method = field.NewString(table, "method") a.Operation = field.NewField(table, "operation") a.CreatedAt = field.NewInt64(table, "created_at") + a.Source = field.NewInt32(table, "source") a.fillFieldMap() @@ -103,7 +122,7 @@ func (a *agentToolVersion) GetFieldByName(fieldName string) (field.OrderExpr, bo } func (a *agentToolVersion) fillFieldMap() { - a.fieldMap = make(map[string]field.Expr, 11) + a.fieldMap = make(map[string]field.Expr, 12) a.fieldMap["id"] = a.ID a.fieldMap["agent_id"] = a.AgentID a.fieldMap["plugin_id"] = a.PluginID @@ -115,6 +134,7 @@ func (a *agentToolVersion) fillFieldMap() { a.fieldMap["method"] = a.Method a.fieldMap["operation"] = a.Operation a.fieldMap["created_at"] = a.CreatedAt + a.fieldMap["source"] = a.Source } func (a agentToolVersion) clone(db *gorm.DB) agentToolVersion { diff --git a/backend/domain/plugin/internal/dal/query/plugin.gen.go b/backend/domain/plugin/internal/dal/query/plugin.gen.go index 5f4f3386f..b9e3c5980 100644 --- a/backend/domain/plugin/internal/dal/query/plugin.gen.go +++ b/backend/domain/plugin/internal/dal/query/plugin.gen.go @@ -1,3 +1,19 @@ +/* + * Copyright 2025 coze-dev Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + // Code generated by gorm.io/gen. DO NOT EDIT. // Code generated by gorm.io/gen. DO NOT EDIT. // Code generated by gorm.io/gen. DO NOT EDIT. @@ -40,6 +56,8 @@ func newPlugin(db *gorm.DB, opts ...gen.DOOption) plugin { _plugin.VersionDesc = field.NewString(tableName, "version_desc") _plugin.Manifest = field.NewField(tableName, "manifest") _plugin.OpenapiDoc = field.NewField(tableName, "openapi_doc") + _plugin.Source = field.NewInt32(tableName, "source") + _plugin.Ext = field.NewField(tableName, "ext") _plugin.fillFieldMap() @@ -64,6 +82,8 @@ type plugin struct { VersionDesc field.String // Plugin Version Description Manifest field.Field // Plugin Manifest OpenapiDoc field.Field // OpenAPI Document, only stores the root + Source field.Int32 // plugin source 1 from saas 0 default + Ext field.Field // extra fieldMap map[string]field.Expr } @@ -93,6 +113,8 @@ func (p *plugin) updateTableName(table string) *plugin { p.VersionDesc = field.NewString(table, "version_desc") p.Manifest = field.NewField(table, "manifest") p.OpenapiDoc = field.NewField(table, "openapi_doc") + p.Source = field.NewInt32(table, "source") + p.Ext = field.NewField(table, "ext") p.fillFieldMap() @@ -109,7 +131,7 @@ func (p *plugin) GetFieldByName(fieldName string) (field.OrderExpr, bool) { } func (p *plugin) fillFieldMap() { - p.fieldMap = make(map[string]field.Expr, 13) + p.fieldMap = make(map[string]field.Expr, 15) p.fieldMap["id"] = p.ID p.fieldMap["space_id"] = p.SpaceID p.fieldMap["developer_id"] = p.DeveloperID @@ -123,6 +145,8 @@ func (p *plugin) fillFieldMap() { p.fieldMap["version_desc"] = p.VersionDesc p.fieldMap["manifest"] = p.Manifest p.fieldMap["openapi_doc"] = p.OpenapiDoc + p.fieldMap["source"] = p.Source + p.fieldMap["ext"] = p.Ext } func (p plugin) clone(db *gorm.DB) plugin { diff --git a/backend/domain/plugin/internal/dal/query/plugin_version.gen.go b/backend/domain/plugin/internal/dal/query/plugin_version.gen.go index 75af76435..4026509bc 100644 --- a/backend/domain/plugin/internal/dal/query/plugin_version.gen.go +++ b/backend/domain/plugin/internal/dal/query/plugin_version.gen.go @@ -1,3 +1,19 @@ +/* + * Copyright 2025 coze-dev Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + // Code generated by gorm.io/gen. DO NOT EDIT. // Code generated by gorm.io/gen. DO NOT EDIT. // Code generated by gorm.io/gen. DO NOT EDIT. @@ -39,6 +55,8 @@ func newPluginVersion(db *gorm.DB, opts ...gen.DOOption) pluginVersion { _pluginVersion.VersionDesc = field.NewString(tableName, "version_desc") _pluginVersion.Manifest = field.NewField(tableName, "manifest") _pluginVersion.OpenapiDoc = field.NewField(tableName, "openapi_doc") + _pluginVersion.Source = field.NewInt32(tableName, "source") + _pluginVersion.Ext = field.NewField(tableName, "ext") _pluginVersion.CreatedAt = field.NewInt64(tableName, "created_at") _pluginVersion.DeletedAt = field.NewField(tableName, "deleted_at") @@ -64,6 +82,8 @@ type pluginVersion struct { VersionDesc field.String // Plugin Version Description Manifest field.Field // Plugin Manifest OpenapiDoc field.Field // OpenAPI Document, only stores the root + Source field.Int32 // plugin source 1 from saas 0 default + Ext field.Field // extra CreatedAt field.Int64 // Create Time in Milliseconds DeletedAt field.Field // Delete Time @@ -94,6 +114,8 @@ func (p *pluginVersion) updateTableName(table string) *pluginVersion { p.VersionDesc = field.NewString(table, "version_desc") p.Manifest = field.NewField(table, "manifest") p.OpenapiDoc = field.NewField(table, "openapi_doc") + p.Source = field.NewInt32(table, "source") + p.Ext = field.NewField(table, "ext") p.CreatedAt = field.NewInt64(table, "created_at") p.DeletedAt = field.NewField(table, "deleted_at") @@ -112,7 +134,7 @@ func (p *pluginVersion) GetFieldByName(fieldName string) (field.OrderExpr, bool) } func (p *pluginVersion) fillFieldMap() { - p.fieldMap = make(map[string]field.Expr, 14) + p.fieldMap = make(map[string]field.Expr, 16) p.fieldMap["id"] = p.ID p.fieldMap["space_id"] = p.SpaceID p.fieldMap["developer_id"] = p.DeveloperID @@ -125,6 +147,8 @@ func (p *pluginVersion) fillFieldMap() { p.fieldMap["version_desc"] = p.VersionDesc p.fieldMap["manifest"] = p.Manifest p.fieldMap["openapi_doc"] = p.OpenapiDoc + p.fieldMap["source"] = p.Source + p.fieldMap["ext"] = p.Ext p.fieldMap["created_at"] = p.CreatedAt p.fieldMap["deleted_at"] = p.DeletedAt } diff --git a/backend/domain/plugin/internal/dal/query/tool.gen.go b/backend/domain/plugin/internal/dal/query/tool.gen.go index 17f3955b2..5e2fdc603 100644 --- a/backend/domain/plugin/internal/dal/query/tool.gen.go +++ b/backend/domain/plugin/internal/dal/query/tool.gen.go @@ -1,3 +1,19 @@ +/* + * Copyright 2025 coze-dev Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + // Code generated by gorm.io/gen. DO NOT EDIT. // Code generated by gorm.io/gen. DO NOT EDIT. // Code generated by gorm.io/gen. DO NOT EDIT. @@ -36,6 +52,8 @@ func newTool(db *gorm.DB, opts ...gen.DOOption) tool { _tool.Method = field.NewString(tableName, "method") _tool.Operation = field.NewField(tableName, "operation") _tool.ActivatedStatus = field.NewInt32(tableName, "activated_status") + _tool.Source = field.NewInt32(tableName, "source") + _tool.Ext = field.NewField(tableName, "ext") _tool.fillFieldMap() @@ -56,6 +74,8 @@ type tool struct { Method field.String // HTTP Request Method Operation field.Field // Tool Openapi Operation Schema ActivatedStatus field.Int32 // 0:activated; 1:deactivated + Source field.Int32 // tool source 1 coze saas 0 default + Ext field.Field // extra fieldMap map[string]field.Expr } @@ -81,6 +101,8 @@ func (t *tool) updateTableName(table string) *tool { t.Method = field.NewString(table, "method") t.Operation = field.NewField(table, "operation") t.ActivatedStatus = field.NewInt32(table, "activated_status") + t.Source = field.NewInt32(table, "source") + t.Ext = field.NewField(table, "ext") t.fillFieldMap() @@ -97,7 +119,7 @@ func (t *tool) GetFieldByName(fieldName string) (field.OrderExpr, bool) { } func (t *tool) fillFieldMap() { - t.fieldMap = make(map[string]field.Expr, 9) + t.fieldMap = make(map[string]field.Expr, 11) t.fieldMap["id"] = t.ID t.fieldMap["plugin_id"] = t.PluginID t.fieldMap["created_at"] = t.CreatedAt @@ -107,6 +129,8 @@ func (t *tool) fillFieldMap() { t.fieldMap["method"] = t.Method t.fieldMap["operation"] = t.Operation t.fieldMap["activated_status"] = t.ActivatedStatus + t.fieldMap["source"] = t.Source + t.fieldMap["ext"] = t.Ext } func (t tool) clone(db *gorm.DB) tool { diff --git a/backend/domain/plugin/internal/dal/query/tool_version.gen.go b/backend/domain/plugin/internal/dal/query/tool_version.gen.go index df07b3c37..00539251c 100644 --- a/backend/domain/plugin/internal/dal/query/tool_version.gen.go +++ b/backend/domain/plugin/internal/dal/query/tool_version.gen.go @@ -1,3 +1,19 @@ +/* + * Copyright 2025 coze-dev Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + // Code generated by gorm.io/gen. DO NOT EDIT. // Code generated by gorm.io/gen. DO NOT EDIT. // Code generated by gorm.io/gen. DO NOT EDIT. @@ -36,6 +52,8 @@ func newToolVersion(db *gorm.DB, opts ...gen.DOOption) toolVersion { _toolVersion.Operation = field.NewField(tableName, "operation") _toolVersion.CreatedAt = field.NewInt64(tableName, "created_at") _toolVersion.DeletedAt = field.NewField(tableName, "deleted_at") + _toolVersion.Source = field.NewInt32(tableName, "source") + _toolVersion.Ext = field.NewField(tableName, "ext") _toolVersion.fillFieldMap() @@ -56,6 +74,8 @@ type toolVersion struct { Operation field.Field // Tool Openapi Operation Schema CreatedAt field.Int64 // Create Time in Milliseconds DeletedAt field.Field // Delete Time + Source field.Int32 // tool source 1 coze saas 0 default + Ext field.Field // extra fieldMap map[string]field.Expr } @@ -81,6 +101,8 @@ func (t *toolVersion) updateTableName(table string) *toolVersion { t.Operation = field.NewField(table, "operation") t.CreatedAt = field.NewInt64(table, "created_at") t.DeletedAt = field.NewField(table, "deleted_at") + t.Source = field.NewInt32(table, "source") + t.Ext = field.NewField(table, "ext") t.fillFieldMap() @@ -97,7 +119,7 @@ func (t *toolVersion) GetFieldByName(fieldName string) (field.OrderExpr, bool) { } func (t *toolVersion) fillFieldMap() { - t.fieldMap = make(map[string]field.Expr, 9) + t.fieldMap = make(map[string]field.Expr, 11) t.fieldMap["id"] = t.ID t.fieldMap["tool_id"] = t.ToolID t.fieldMap["plugin_id"] = t.PluginID @@ -107,6 +129,8 @@ func (t *toolVersion) fillFieldMap() { t.fieldMap["operation"] = t.Operation t.fieldMap["created_at"] = t.CreatedAt t.fieldMap["deleted_at"] = t.DeletedAt + t.fieldMap["source"] = t.Source + t.fieldMap["ext"] = t.Ext } func (t toolVersion) clone(db *gorm.DB) toolVersion { diff --git a/backend/domain/plugin/internal/dal/tool.go b/backend/domain/plugin/internal/dal/tool.go index 38580b9e7..0076028d2 100644 --- a/backend/domain/plugin/internal/dal/tool.go +++ b/backend/domain/plugin/internal/dal/tool.go @@ -24,6 +24,7 @@ import ( "gorm.io/gen/field" "gorm.io/gorm" + "github.com/coze-dev/coze-studio/backend/api/model/app/bot_common" "github.com/coze-dev/coze-studio/backend/crossdomain/contract/plugin/consts" "github.com/coze-dev/coze-studio/backend/domain/plugin/entity" "github.com/coze-dev/coze-studio/backend/domain/plugin/internal/dal/model" @@ -58,6 +59,9 @@ func (t toolPO) ToDO() *entity.ToolInfo { Method: ptr.Of(t.Method), Operation: t.Operation, ActivatedStatus: ptr.Of(consts.ActivatedStatus(t.ActivatedStatus)), + + Source: bot_common.PluginFromPtr(bot_common.PluginFrom(t.Source)), + Extra: t.Ext, } } diff --git a/backend/domain/plugin/internal/dal/tool_version.go b/backend/domain/plugin/internal/dal/tool_version.go index 51a80cf0c..ecb0b434c 100644 --- a/backend/domain/plugin/internal/dal/tool_version.go +++ b/backend/domain/plugin/internal/dal/tool_version.go @@ -22,6 +22,7 @@ import ( "gorm.io/gorm" + "github.com/coze-dev/coze-studio/backend/api/model/app/bot_common" pluginModel "github.com/coze-dev/coze-studio/backend/crossdomain/contract/plugin/model" "github.com/coze-dev/coze-studio/backend/domain/plugin/entity" "github.com/coze-dev/coze-studio/backend/domain/plugin/internal/dal/model" @@ -54,6 +55,9 @@ func (t toolVersionPO) ToDO() *entity.ToolInfo { SubURL: &t.SubURL, Method: ptr.Of(t.Method), Operation: t.Operation, + + Source: bot_common.PluginFromPtr(bot_common.PluginFrom(t.Source)), + Extra: t.Ext, } } diff --git a/backend/domain/plugin/repository/tool_impl.go b/backend/domain/plugin/repository/tool_impl.go index b89365c53..120da5fac 100644 --- a/backend/domain/plugin/repository/tool_impl.go +++ b/backend/domain/plugin/repository/tool_impl.go @@ -18,11 +18,18 @@ package repository import ( "context" + "encoding/json" "fmt" "runtime/debug" + "strconv" + "strings" "gorm.io/gorm" + "github.com/coze-dev/coze-studio/backend/api/model/app/bot_common" + pluginCommon "github.com/coze-dev/coze-studio/backend/api/model/plugin_develop/common" + "github.com/coze-dev/coze-studio/backend/crossdomain/contract/plugin/consts" + "github.com/coze-dev/coze-studio/backend/crossdomain/contract/plugin/convert/api" "github.com/coze-dev/coze-studio/backend/crossdomain/contract/plugin/model" pluginConf "github.com/coze-dev/coze-studio/backend/domain/plugin/conf" "github.com/coze-dev/coze-studio/backend/domain/plugin/dto" @@ -30,8 +37,11 @@ import ( "github.com/coze-dev/coze-studio/backend/domain/plugin/internal/dal" "github.com/coze-dev/coze-studio/backend/domain/plugin/internal/dal/query" "github.com/coze-dev/coze-studio/backend/infra/idgen" + "github.com/coze-dev/coze-studio/backend/pkg/errorx" + "github.com/coze-dev/coze-studio/backend/pkg/lang/ptr" "github.com/coze-dev/coze-studio/backend/pkg/lang/slices" "github.com/coze-dev/coze-studio/backend/pkg/logs" + "github.com/coze-dev/coze-studio/backend/pkg/saasapi" ) type toolRepoImpl struct { @@ -271,7 +281,7 @@ func (t *toolRepoImpl) MGetVersionTools(ctx context.Context, versionTools []mode return tools, nil } -func (t *toolRepoImpl) BindDraftAgentTools(ctx context.Context, agentID int64, toolIDs []int64) (err error) { +func (t *toolRepoImpl) BindDraftAgentTools(ctx context.Context, agentID int64, bindTools []*model.BindToolInfo) (err error) { opt := &dal.ToolSelectedOption{ ToolID: true, } @@ -280,21 +290,44 @@ func (t *toolRepoImpl) BindDraftAgentTools(ctx context.Context, agentID int64, t return err } + var allToolIDs []int64 + var localToolIDs []int64 + var saasToolIDs []int64 + var saasToolPluginIDs []int64 + allToolIDs = slices.Transform(bindTools, func(tool *model.BindToolInfo) int64 { + return tool.ToolID + }) + + for _, tool := range bindTools { + if ptr.From(tool.Source) == bot_common.PluginFrom_FromSaas { + saasToolIDs = append(saasToolIDs, tool.ToolID) + saasToolPluginIDs = append(saasToolPluginIDs, tool.PluginID) + } else { + localToolIDs = append(localToolIDs, tool.ToolID) + + } + } + draftAgentToolIDMap := slices.ToMap(draftAgentTools, func(tool *entity.ToolInfo) (int64, bool) { return tool.ID, true }) - bindToolIDMap := slices.ToMap(toolIDs, func(toolID int64) (int64, bool) { + bindToolIDMap := slices.ToMap(allToolIDs, func(toolID int64) (int64, bool) { return toolID, true }) - newBindToolIDs := make([]int64, 0, len(toolIDs)) - for _, toolID := range toolIDs { + newLocalBindToolIDs := make([]int64, 0, len(allToolIDs)) + newSaasBindToolIDs := make([]int64, 0, len(allToolIDs)) + for _, toolID := range allToolIDs { _, ok := draftAgentToolIDMap[toolID] if ok { continue } - newBindToolIDs = append(newBindToolIDs, toolID) + if slices.Contains(saasToolIDs, toolID) { + newSaasBindToolIDs = append(newSaasBindToolIDs, toolID) + } else { + newLocalBindToolIDs = append(newLocalBindToolIDs, toolID) + } } removeToolIDs := make([]int64, 0, len(draftAgentTools)) @@ -306,6 +339,21 @@ func (t *toolRepoImpl) BindDraftAgentTools(ctx context.Context, agentID int64, t removeToolIDs = append(removeToolIDs, toolID) } + var onlineTools []*entity.ToolInfo + if len(newSaasBindToolIDs) > 0 { + saasPluginTools, _, err := t.BatchGetSaasPluginToolsInfo(ctx, saasToolPluginIDs) + if err != nil { + return err + } + for _, toolIDs := range saasPluginTools { + for _, toolInfo := range toolIDs { + if slices.Contains(saasToolIDs, toolInfo.ID) { + onlineTools = append(onlineTools, toolInfo) + } + } + } + } + tx := t.query.Begin() if tx.Error != nil { return tx.Error @@ -326,9 +374,12 @@ func (t *toolRepoImpl) BindDraftAgentTools(ctx context.Context, agentID int64, t } }() - onlineTools, err := t.MGetOnlineTools(ctx, newBindToolIDs) - if err != nil { - return err + if len(newLocalBindToolIDs) > 0 { + localTools, err := t.MGetOnlineTools(ctx, newLocalBindToolIDs) + if err != nil { + return err + } + onlineTools = append(onlineTools, localTools...) } if len(onlineTools) > 0 { @@ -428,3 +479,250 @@ func (t *toolRepoImpl) MGetVersionAgentTool(ctx context.Context, agentID int64, func (t *toolRepoImpl) BatchCreateVersionAgentTools(ctx context.Context, agentID int64, agentVersion string, tools []*entity.ToolInfo) (err error) { return t.agentToolVersionDAO.BatchCreate(ctx, agentID, agentVersion, tools) } + +// BatchGetSaasPluginToolsInfo retrieves tools information for SaaS plugins +func (t *toolRepoImpl) BatchGetSaasPluginToolsInfo(ctx context.Context, pluginIDs []int64) (tools map[int64][]*entity.ToolInfo, plugins map[int64]*entity.PluginInfo, err error) { + if len(pluginIDs) == 0 { + return make(map[int64][]*entity.ToolInfo), make(map[int64]*entity.PluginInfo), nil + } + + client := saasapi.NewCozeAPIClient() + + var idStrings []string + for _, id := range pluginIDs { + idStrings = append(idStrings, strconv.FormatInt(id, 10)) + } + idsStr := strings.Join(idStrings, ",") + + queryParams := map[string]interface{}{ + "ids": idsStr, + } + + resp, err := client.GetWithQuery(ctx, "/v1/plugins/mget", queryParams) + if err != nil { + return nil, nil, errorx.Wrapf(err, "failed to call coze.cn /v1/plugins/mget API") + } + + var apiResp dto.SaasPluginToolsListResponse + + if err := json.Unmarshal(resp.Data, &apiResp); err != nil { + return nil, nil, errorx.Wrapf(err, "failed to parse coze.cn API response") + } + + result := make(map[int64][]*entity.ToolInfo) + plugins = make(map[int64]*entity.PluginInfo) + + for _, plugin := range apiResp.Items { + + pluginID, err := strconv.ParseInt(plugin.PluginID, 10, 64) + if err != nil { + return nil, nil, errorx.Wrapf(err, "failed to parse plugin ID %s", plugin.PluginID) + } + + pluginInfo := convertCozePluginToEntity(&plugin) + plugins[pluginID] = pluginInfo + + toolInfos := make([]*entity.ToolInfo, 0, len(plugin.Tools)) + + for _, tool := range plugin.Tools { + + openapi3Operation, err := api.APIParamsToOpenapiOperation(convertFromJsonSchema(tool.InputSchema), convertFromJsonSchema(tool.OutputSchema)) + if err != nil { + return nil, nil, errorx.Wrapf(err, "failed to convert input schema to openapi operation parameters") + } + openapi3Operation.OperationID = tool.Name + openapi3Operation.Summary = tool.Description + operation := &model.Openapi3Operation{ + Operation: openapi3Operation, + } + id, err := strconv.ParseInt(tool.ToolID, 10, 64) + if err != nil { + return nil, nil, errorx.Wrapf(err, "failed to parse tool ID %s", tool.ToolID) + } + toolInfo := &entity.ToolInfo{ + ID: id, + PluginID: pluginID, + Operation: operation, + Source: ptr.Of(bot_common.PluginFrom_FromSaas), + Version: ptr.Of("0"), + Method: ptr.Of("POST"), + SubURL: ptr.Of(convertSaasToolSubUrl(pluginID)), + } + + toolInfos = append(toolInfos, toolInfo) + } + + result[pluginID] = toolInfos + } + + return result, plugins, nil +} + +func convertCozePluginToEntity(cozePlugin *dto.SaasPluginToolsList) *entity.PluginInfo { + var pluginID int64 + if id, err := strconv.ParseInt(cozePlugin.PluginID, 10, 64); err == nil { + pluginID = id + } + + manifest := &model.PluginManifest{ + SchemaVersion: "v1", + NameForModel: cozePlugin.Name, + NameForHuman: cozePlugin.Name, + DescriptionForModel: cozePlugin.Description, + DescriptionForHuman: cozePlugin.Description, + LogoURL: cozePlugin.IconURL, + Auth: &model.AuthV2{ + Type: func() consts.AuthzType { + if !cozePlugin.IsCallAvailable { + return consts.AuthTypeOfSaasInstalled + } + return consts.AuthzTypeOfNone + }(), + }, + API: model.APIDesc{ + Type: "openapi", + }, + } + + pluginInfo := &model.PluginInfo{ + ID: pluginID, + PluginType: pluginCommon.PluginType_PLUGIN, + SpaceID: 0, + DeveloperID: 0, + APPID: nil, + IconURL: &cozePlugin.IconURL, + ServerURL: ptr.Of("https://api.coze.cn"), + CreatedAt: cozePlugin.CreatedAt, + UpdatedAt: cozePlugin.UpdatedAt, + Manifest: manifest, + Source: ptr.Of(bot_common.PluginFrom_FromSaas), + } + + return entity.NewPluginInfo(pluginInfo) +} + +func convertSaasToolSubUrl(pluginID int64) string { + return fmt.Sprintf("/v1/plugins/%d/tools/call", pluginID) +} + +// convertFromJsonSchema converts JSON schema to API parameters +func convertFromJsonSchema(schema *dto.JsonSchema) []*pluginCommon.APIParameter { + if schema == nil { + return []*pluginCommon.APIParameter{} + } + + return convertJsonSchemaToParameters(schema, pluginCommon.ParameterLocation_Body) +} + +// ConvertFromJsonSchemaForTest is an exported version for testing purposes +func ConvertFromJsonSchemaForTest(schema *dto.JsonSchema) []*pluginCommon.APIParameter { + return convertFromJsonSchema(schema) +} + +// convertJsonSchemaToParameters recursively converts JSON schema to API parameters +func convertJsonSchemaToParameters(schema *dto.JsonSchema, location pluginCommon.ParameterLocation) []*pluginCommon.APIParameter { + if schema == nil { + return []*pluginCommon.APIParameter{} + } + + var parameters []*pluginCommon.APIParameter + + // Handle object type with properties + if schema.Type == dto.JsonSchemaType_OBJECT && len(schema.Properties) > 0 { + // Create a set of required fields for quick lookup + requiredFields := make(map[string]bool) + for _, field := range schema.Required { + requiredFields[field] = true + } + + // Convert each property to a parameter + for name, propSchema := range schema.Properties { + if propSchema == nil { + continue + } + + param := &pluginCommon.APIParameter{ + Name: name, + Desc: propSchema.Description, + IsRequired: requiredFields[name], + Type: mapJsonSchemaTypeToParameterType(propSchema.Type), + Location: location, + } + + // Handle nested object properties + if propSchema.Type == dto.JsonSchemaType_OBJECT && len(propSchema.Properties) > 0 { + param.SubParameters = convertJsonSchemaToParameters(propSchema, location) + } + + // Handle array properties + if propSchema.Type == dto.JsonSchemaType_ARRAY && propSchema.Items != nil { + // Create a parameter for the array item + arrayItemParam := &pluginCommon.APIParameter{ + Name: "[Array Item]", + Desc: propSchema.Items.Description, + IsRequired: true, // Array items are typically required + Type: mapJsonSchemaTypeToParameterType(propSchema.Items.Type), + Location: location, + } + + // If array item is an object, recursively convert its properties + if propSchema.Items.Type == dto.JsonSchemaType_OBJECT && len(propSchema.Items.Properties) > 0 { + arrayItemParam.SubParameters = convertJsonSchemaToParameters(propSchema.Items, location) + } + + // If array item is also an array, handle nested arrays + if propSchema.Items.Type == dto.JsonSchemaType_ARRAY && propSchema.Items.Items != nil { + // For nested arrays, create sub-parameters recursively + nestedArraySchema := &dto.JsonSchema{ + Type: propSchema.Items.Type, + Items: propSchema.Items.Items, + Properties: propSchema.Items.Properties, + Required: propSchema.Items.Required, + } + arrayItemParam.SubParameters = convertJsonSchemaToParameters(nestedArraySchema, location) + } + + param.SubParameters = []*pluginCommon.APIParameter{arrayItemParam} + } + + parameters = append(parameters, param) + } + } else if schema.Type == dto.JsonSchemaType_ARRAY && schema.Items != nil { + // Handle top-level array (though this is less common for API parameters) + arrayItemParam := &pluginCommon.APIParameter{ + Name: "[Array Item]", + Desc: schema.Items.Description, + IsRequired: true, + Type: mapJsonSchemaTypeToParameterType(schema.Items.Type), + Location: location, + } + + if schema.Items.Type == dto.JsonSchemaType_OBJECT && len(schema.Items.Properties) > 0 { + arrayItemParam.SubParameters = convertJsonSchemaToParameters(schema.Items, location) + } + + parameters = append(parameters, arrayItemParam) + } + + return parameters +} + +// mapJsonSchemaTypeToParameterType maps JSON schema types to parameter types +func mapJsonSchemaTypeToParameterType(schemaType dto.JsonSchemaType) pluginCommon.ParameterType { + switch schemaType { + case dto.JsonSchemaType_STRING: + return pluginCommon.ParameterType_String + case dto.JsonSchemaType_NUMBER: + return pluginCommon.ParameterType_Number + case dto.JsonSchemaType_INTEGER: + return pluginCommon.ParameterType_Integer + case dto.JsonSchemaType_BOOLEAN: + return pluginCommon.ParameterType_Bool + case dto.JsonSchemaType_OBJECT: + return pluginCommon.ParameterType_Object + case dto.JsonSchemaType_ARRAY: + return pluginCommon.ParameterType_Array + default: + return pluginCommon.ParameterType_String + } +} diff --git a/backend/domain/plugin/repository/tool_impl_test.go b/backend/domain/plugin/repository/tool_impl_test.go new file mode 100644 index 000000000..f07421877 --- /dev/null +++ b/backend/domain/plugin/repository/tool_impl_test.go @@ -0,0 +1,189 @@ +/* + * 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 repository + +import ( + "testing" + + "github.com/stretchr/testify/assert" + + pluginCommon "github.com/coze-dev/coze-studio/backend/api/model/plugin_develop/common" + "github.com/coze-dev/coze-studio/backend/domain/plugin/dto" +) + +func TestConvertJsonSchemaToParameters(t *testing.T) { + tests := []struct { + name string + schema *dto.JsonSchema + expected int // expected number of parameters + validate func(t *testing.T, params []*pluginCommon.APIParameter) + }{ + { + name: "Simple object with properties", + schema: &dto.JsonSchema{ + Type: dto.JsonSchemaType_OBJECT, + Properties: map[string]*dto.JsonSchema{ + "name": { + Type: dto.JsonSchemaType_STRING, + Description: "User name", + }, + "age": { + Type: dto.JsonSchemaType_INTEGER, + Description: "User age", + }, + }, + Required: []string{"name"}, + }, + expected: 2, + validate: func(t *testing.T, params []*pluginCommon.APIParameter) { + assert.Len(t, params, 2) + + // Find name parameter + var nameParam *pluginCommon.APIParameter + for _, p := range params { + if p.Name == "name" { + nameParam = p + break + } + } + assert.NotNil(t, nameParam) + assert.True(t, nameParam.IsRequired) + assert.Equal(t, pluginCommon.ParameterType_String, nameParam.Type) + }, + }, + { + name: "Array with object items", + schema: &dto.JsonSchema{ + Type: dto.JsonSchemaType_OBJECT, + Properties: map[string]*dto.JsonSchema{ + "users": { + Type: dto.JsonSchemaType_ARRAY, + Items: &dto.JsonSchema{ + Type: dto.JsonSchemaType_OBJECT, + Properties: map[string]*dto.JsonSchema{ + "name": { + Type: dto.JsonSchemaType_STRING, + Description: "User name", + }, + "email": { + Type: dto.JsonSchemaType_STRING, + Description: "User email", + }, + }, + Required: []string{"name"}, + }, + }, + }, + }, + expected: 1, + validate: func(t *testing.T, params []*pluginCommon.APIParameter) { + assert.Len(t, params, 1) + + usersParam := params[0] + assert.Equal(t, "users", usersParam.Name) + assert.Equal(t, pluginCommon.ParameterType_Array, usersParam.Type) + + // Check array item parameter + assert.Len(t, usersParam.SubParameters, 1) + arrayItemParam := usersParam.SubParameters[0] + assert.Equal(t, "[Array Item]", arrayItemParam.Name) + assert.Equal(t, pluginCommon.ParameterType_Object, arrayItemParam.Type) + + // Check object properties in array item + assert.Len(t, arrayItemParam.SubParameters, 2) + + // Find name parameter in array item + var nameParam *pluginCommon.APIParameter + for _, p := range arrayItemParam.SubParameters { + if p.Name == "name" { + nameParam = p + break + } + } + assert.NotNil(t, nameParam) + assert.True(t, nameParam.IsRequired) + assert.Equal(t, pluginCommon.ParameterType_String, nameParam.Type) + }, + }, + { + name: "Nested arrays", + schema: &dto.JsonSchema{ + Type: dto.JsonSchemaType_OBJECT, + Properties: map[string]*dto.JsonSchema{ + "matrix": { + Type: dto.JsonSchemaType_ARRAY, + Items: &dto.JsonSchema{ + Type: dto.JsonSchemaType_ARRAY, + Items: &dto.JsonSchema{ + Type: dto.JsonSchemaType_INTEGER, + Description: "Matrix element", + }, + }, + }, + }, + }, + expected: 1, + validate: func(t *testing.T, params []*pluginCommon.APIParameter) { + assert.Len(t, params, 1) + + matrixParam := params[0] + assert.Equal(t, "matrix", matrixParam.Name) + assert.Equal(t, pluginCommon.ParameterType_Array, matrixParam.Type) + + // Check first level array item + assert.Len(t, matrixParam.SubParameters, 1) + firstLevelItem := matrixParam.SubParameters[0] + assert.Equal(t, "[Array Item]", firstLevelItem.Name) + assert.Equal(t, pluginCommon.ParameterType_Array, firstLevelItem.Type) + + // Check second level array item + assert.Len(t, firstLevelItem.SubParameters, 1) + secondLevelItem := firstLevelItem.SubParameters[0] + assert.Equal(t, "[Array Item]", secondLevelItem.Name) + assert.Equal(t, pluginCommon.ParameterType_Integer, secondLevelItem.Type) + }, + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + result := convertJsonSchemaToParameters(tt.schema, pluginCommon.ParameterLocation_Body) + assert.Len(t, result, tt.expected) + if tt.validate != nil { + tt.validate(t, result) + } + }) + } +} + +func TestConvertFromJsonSchema(t *testing.T) { + // Test the main entry function + schema := &dto.JsonSchema{ + Type: dto.JsonSchemaType_OBJECT, + Properties: map[string]*dto.JsonSchema{ + "test": { + Type: dto.JsonSchemaType_STRING, + Description: "Test field", + }, + }, + } + + result := convertFromJsonSchema(schema) + assert.Len(t, result, 1) + assert.Equal(t, "test", result[0].Name) + assert.Equal(t, pluginCommon.ParameterLocation_Body, result[0].Location) +} diff --git a/backend/domain/plugin/repository/tool_repository.go b/backend/domain/plugin/repository/tool_repository.go index 71d69665a..d6cf39211 100644 --- a/backend/domain/plugin/repository/tool_repository.go +++ b/backend/domain/plugin/repository/tool_repository.go @@ -41,7 +41,7 @@ type ToolRepository interface { GetVersionTool(ctx context.Context, vTool model.VersionTool) (tool *entity.ToolInfo, exist bool, err error) MGetVersionTools(ctx context.Context, vTools []model.VersionTool) (tools []*entity.ToolInfo, err error) - BindDraftAgentTools(ctx context.Context, agentID int64, toolIDs []int64) (err error) + BindDraftAgentTools(ctx context.Context, agentID int64, bindTools []*model.BindToolInfo) (err error) DuplicateDraftAgentTools(ctx context.Context, fromAgentID, toAgentID int64) (err error) GetDraftAgentTool(ctx context.Context, agentID, toolID int64) (tool *entity.ToolInfo, exist bool, err error) GetDraftAgentToolWithToolName(ctx context.Context, agentID int64, toolName string) (tool *entity.ToolInfo, exist bool, err error) @@ -58,6 +58,9 @@ type ToolRepository interface { GetPluginAllDraftTools(ctx context.Context, pluginID int64, opts ...ToolSelectedOptions) (tools []*entity.ToolInfo, err error) GetPluginAllOnlineTools(ctx context.Context, pluginID int64) (tools []*entity.ToolInfo, err error) ListPluginDraftTools(ctx context.Context, pluginID int64, pageInfo dto.PageInfo) (tools []*entity.ToolInfo, total int64, err error) + + // SaaS plugin tools + BatchGetSaasPluginToolsInfo(ctx context.Context, pluginIDs []int64) (tools map[int64][]*entity.ToolInfo, plugins map[int64]*entity.PluginInfo, err error) } type GetVersionAgentToolWithToolNameRequest struct { diff --git a/backend/domain/plugin/service/agent_tool.go b/backend/domain/plugin/service/agent_tool.go index 0ddf95fbf..852561b84 100644 --- a/backend/domain/plugin/service/agent_tool.go +++ b/backend/domain/plugin/service/agent_tool.go @@ -20,28 +20,31 @@ import ( "context" "fmt" "net/http" + "slices" "strconv" "github.com/getkin/kin-openapi/openapi3" + "github.com/coze-dev/coze-studio/backend/api/model/app/bot_common" "github.com/coze-dev/coze-studio/backend/crossdomain/contract/plugin/consts" "github.com/coze-dev/coze-studio/backend/crossdomain/contract/plugin/model" "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" + "github.com/coze-dev/coze-studio/backend/pkg/lang/ptr" "github.com/coze-dev/coze-studio/backend/types/errno" ) -func (p *pluginServiceImpl) BindAgentTools(ctx context.Context, agentID int64, toolIDs []int64) (err error) { - return p.toolRepo.BindDraftAgentTools(ctx, agentID, toolIDs) +func (p *pluginServiceImpl) BindAgentTools(ctx context.Context, agentID int64, bindTools []*model.BindToolInfo) (err error) { + return p.toolRepo.BindDraftAgentTools(ctx, agentID, bindTools) } func (p *pluginServiceImpl) DuplicateDraftAgentTools(ctx context.Context, fromAgentID, toAgentID int64) (err error) { return p.toolRepo.DuplicateDraftAgentTools(ctx, fromAgentID, toAgentID) } -func (p *pluginServiceImpl) GetDraftAgentToolByName(ctx context.Context, agentID int64, toolName string) (tool *entity.ToolInfo, err error) { +func (p *pluginServiceImpl) GetDraftAgentToolByName(ctx context.Context, agentID int64, pluginID int64, toolName string) (tool *entity.ToolInfo, err error) { draftAgentTool, exist, err := p.toolRepo.GetDraftAgentToolWithToolName(ctx, agentID, toolName) if err != nil { return nil, errorx.Wrapf(err, "GetDraftAgentToolWithToolName failed, agentID=%d, toolName=%s", agentID, toolName) @@ -50,9 +53,36 @@ func (p *pluginServiceImpl) GetDraftAgentToolByName(ctx context.Context, agentID return nil, errorx.New(errno.ErrPluginRecordNotFound) } - tool, exist, err = p.toolRepo.GetOnlineTool(ctx, draftAgentTool.ID) - if err != nil { - return nil, errorx.Wrapf(err, "GetOnlineTool failed, id=%d", draftAgentTool.ID) + if draftAgentTool.GetPluginFrom() == bot_common.PluginFrom_FromSaas { + tools, _, err := p.toolRepo.BatchGetSaasPluginToolsInfo(ctx, []int64{draftAgentTool.PluginID}) + if err != nil { + return nil, errorx.Wrapf(err, "BatchGetSaasPluginToolsInfo failed, pluginIDs=%v", []int64{draftAgentTool.PluginID}) + } + if len(tools) == 0 || len(tools[draftAgentTool.PluginID]) == 0 { + return nil, errorx.New(errno.ErrPluginRecordNotFound) + } + exist = false + for _, saasTool := range tools[draftAgentTool.PluginID] { + if saasTool.ID == draftAgentTool.ID { + tool = saasTool + exist = true + break + } + } + + } else { + _, exist, err := p.pluginRepo.GetOnlinePlugin(ctx, pluginID, repository.WithPluginID()) + if err != nil { + return nil, errorx.Wrapf(err, "GetOnlinePlugin failed, pluginID=%d", pluginID) + } + if !exist { + return nil, errorx.New(errno.ErrPluginRecordNotFound) + } + tool, exist, err = p.toolRepo.GetOnlineTool(ctx, draftAgentTool.ID) + if err != nil { + return nil, errorx.Wrapf(err, "GetOnlineTool failed, id=%d", draftAgentTool.ID) + } + } if !exist { return nil, errorx.New(errno.ErrPluginRecordNotFound) @@ -67,14 +97,35 @@ func (p *pluginServiceImpl) GetDraftAgentToolByName(ctx context.Context, agentID } func (p *pluginServiceImpl) MGetAgentTools(ctx context.Context, req *model.MGetAgentToolsRequest) (tools []*entity.ToolInfo, err error) { - toolIDs := make([]int64, 0, len(req.VersionAgentTools)) + localToolIDs := make([]int64, 0, len(req.VersionAgentTools)) + saasToolIDs := make([]int64, 0, len(req.VersionAgentTools)) + saasToolPluginIDs := make([]int64, 0, len(req.VersionAgentTools)) for _, v := range req.VersionAgentTools { - toolIDs = append(toolIDs, v.ToolID) + if ptr.From(v.PluginFrom) == bot_common.PluginFrom_FromSaas { + saasToolIDs = append(saasToolIDs, v.ToolID) + saasToolPluginIDs = append(saasToolPluginIDs, v.PluginID) + } else { + localToolIDs = append(localToolIDs, v.ToolID) + } } - existTools, err := p.toolRepo.MGetOnlineTools(ctx, toolIDs, repository.WithToolID()) + existTools, err := p.toolRepo.MGetOnlineTools(ctx, localToolIDs, repository.WithToolID()) if err != nil { - return nil, errorx.Wrapf(err, "MGetOnlineTools failed, toolIDs=%v", toolIDs) + return nil, errorx.Wrapf(err, "MGetOnlineTools failed, toolIDs=%v", localToolIDs) + } + + if len(saasToolIDs) > 0 { + saasToolPluginInfos, _, err := p.toolRepo.BatchGetSaasPluginToolsInfo(ctx, saasToolPluginIDs) + if err != nil { + return nil, errorx.Wrapf(err, "BatchGetSaasPluginToolsInfo failed, pluginIDs=%v", saasToolPluginIDs) + } + for _, tools := range saasToolPluginInfos { + for _, saasTool := range tools { + if slices.Contains(saasToolIDs, saasTool.ID) { + existTools = append(existTools, saasTool) + } + } + } } if len(existTools) == 0 { @@ -109,6 +160,7 @@ func (p *pluginServiceImpl) MGetAgentTools(ctx context.Context, req *model.MGetA } } + //local plugin tools, err = p.toolRepo.MGetVersionAgentTool(ctx, req.AgentID, vTools) if err != nil { return nil, errorx.Wrapf(err, "MGetVersionAgentTool failed, agentID=%d, vTools=%v", req.AgentID, vTools) @@ -132,13 +184,6 @@ func (p *pluginServiceImpl) PublishAgentTools(ctx context.Context, agentID int64 } 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) - } - if !exist { - return errorx.New(errno.ErrPluginRecordNotFound) - } draftAgentTool, exist, err := p.toolRepo.GetDraftAgentToolWithToolName(ctx, req.AgentID, req.ToolName) if err != nil { @@ -148,9 +193,35 @@ func (p *pluginServiceImpl) UpdateBotDefaultParams(ctx context.Context, req *dto return errorx.New(errno.ErrPluginRecordNotFound) } - onlineTool, exist, err := p.toolRepo.GetOnlineTool(ctx, draftAgentTool.ID) - if err != nil { - return errorx.Wrapf(err, "GetOnlineTool failed, id=%d", draftAgentTool.ID) + var onlineTool *entity.ToolInfo + if draftAgentTool.GetPluginFrom() == bot_common.PluginFrom_FromSaas { + tools, _, err := p.toolRepo.BatchGetSaasPluginToolsInfo(ctx, []int64{draftAgentTool.PluginID}) + if err != nil { + return errorx.Wrapf(err, "BatchGetSaasPluginToolsInfo failed, pluginIDs=%v", []int64{draftAgentTool.PluginID}) + } + if len(tools) == 0 || len(tools[draftAgentTool.PluginID]) == 0 { + return errorx.New(errno.ErrPluginRecordNotFound) + } + for _, saasTool := range tools[draftAgentTool.PluginID] { + if saasTool.ID == draftAgentTool.ID { + onlineTool = saasTool + exist = true + break + } + } + } else { + _, exist, err := p.pluginRepo.GetOnlinePlugin(ctx, req.PluginID, repository.WithPluginID()) + if err != nil { + return errorx.Wrapf(err, "GetOnlinePlugin failed, pluginID=%d", req.PluginID) + } + if !exist { + return errorx.New(errno.ErrPluginRecordNotFound) + } + + onlineTool, exist, err = p.toolRepo.GetOnlineTool(ctx, draftAgentTool.ID) + if err != nil { + return errorx.Wrapf(err, "GetOnlineTool failed, id=%d", draftAgentTool.ID) + } } if !exist { return errorx.New(errno.ErrPluginRecordNotFound) diff --git a/backend/domain/plugin/service/exec_tool.go b/backend/domain/plugin/service/exec_tool.go index c9509eac7..d40d16b37 100644 --- a/backend/domain/plugin/service/exec_tool.go +++ b/backend/domain/plugin/service/exec_tool.go @@ -28,6 +28,7 @@ import ( "github.com/bytedance/sonic" "github.com/getkin/kin-openapi/openapi3" + "github.com/coze-dev/coze-studio/backend/api/model/app/bot_common" common "github.com/coze-dev/coze-studio/backend/api/model/plugin_develop/common" "github.com/coze-dev/coze-studio/backend/crossdomain/contract/plugin/consts" "github.com/coze-dev/coze-studio/backend/crossdomain/contract/plugin/model" @@ -184,12 +185,32 @@ func (p *pluginServiceImpl) getDraftAgentPluginInfo(ctx context.Context, req *mo return nil, nil, fmt.Errorf("draft tool is not supported in online agent") } - onlineTool, exist, err := p.toolRepo.GetOnlineTool(ctx, req.ToolID) - if err != nil { - return nil, nil, errorx.Wrapf(err, "GetOnlineTool failed, toolID=%d", req.ToolID) - } - if !exist { - return nil, nil, errorx.New(errno.ErrPluginRecordNotFound) + var ( + exist bool + ) + if req.PluginFrom != nil && *req.PluginFrom == bot_common.PluginFrom_FromSaas { + + tools, _, err := p.toolRepo.BatchGetSaasPluginToolsInfo(ctx, []int64{req.PluginID}) + if err != nil { + return nil, nil, errorx.Wrapf(err, "BatchGetSaasPluginToolsInfo failed, pluginID=%d", req.PluginID) + } + if len(tools) == 0 { + return nil, nil, errorx.New(errno.ErrPluginRecordNotFound) + } + for _, tool := range tools[req.PluginID] { + if tool.ID == req.ToolID { + onlineTool = tool + break + } + } + } else { + onlineTool, exist, err = p.toolRepo.GetOnlineTool(ctx, req.ToolID) + if err != nil { + return nil, nil, errorx.Wrapf(err, "GetOnlineTool failed, toolID=%d", req.ToolID) + } + if !exist { + return nil, nil, errorx.New(errno.ErrPluginRecordNotFound) + } } agentTool, exist, err := p.toolRepo.GetDraftAgentTool(ctx, execOpt.ProjectInfo.ProjectID, req.ToolID) @@ -200,24 +221,35 @@ func (p *pluginServiceImpl) getDraftAgentPluginInfo(ctx context.Context, req *mo return nil, nil, errorx.New(errno.ErrPluginRecordNotFound) } - if execOpt.ToolVersion == "" { - onlinePlugin, exist, err = p.pluginRepo.GetOnlinePlugin(ctx, req.PluginID) + if req.PluginFrom != nil && *req.PluginFrom == bot_common.PluginFrom_FromSaas { + saasPlugins, err := p.GetSaasPluginInfo(ctx, []int64{req.PluginID}) if err != nil { - return nil, nil, errorx.Wrapf(err, "GetOnlinePlugin failed, pluginID=%d", req.PluginID) + return nil, nil, errorx.Wrapf(err, "GetSaasPluginInfo failed, pluginID=%d", req.PluginID) } - if !exist { + if len(saasPlugins) == 0 { return nil, nil, errorx.New(errno.ErrPluginRecordNotFound) } + onlinePlugin = saasPlugins[0] } else { - onlinePlugin, exist, err = p.pluginRepo.GetVersionPlugin(ctx, model.VersionPlugin{ - PluginID: req.PluginID, - Version: execOpt.ToolVersion, - }) - if err != nil { - return nil, nil, errorx.Wrapf(err, "GetVersionPlugin failed, pluginID=%d, version=%s", req.PluginID, execOpt.ToolVersion) - } - if !exist { - return nil, nil, errorx.New(errno.ErrPluginRecordNotFound) + if execOpt.ToolVersion == "" { + onlinePlugin, exist, err = p.pluginRepo.GetOnlinePlugin(ctx, req.PluginID) + if err != nil { + return nil, nil, errorx.Wrapf(err, "GetOnlinePlugin failed, pluginID=%d", req.PluginID) + } + if !exist { + return nil, nil, errorx.New(errno.ErrPluginRecordNotFound) + } + } else { + onlinePlugin, exist, err = p.pluginRepo.GetVersionPlugin(ctx, model.VersionPlugin{ + PluginID: req.PluginID, + Version: execOpt.ToolVersion, + }) + if err != nil { + return nil, nil, errorx.Wrapf(err, "GetVersionPlugin failed, pluginID=%d, version=%s", req.PluginID, execOpt.ToolVersion) + } + if !exist { + return nil, nil, errorx.New(errno.ErrPluginRecordNotFound) + } } } @@ -236,12 +268,32 @@ func (p *pluginServiceImpl) getOnlineAgentPluginInfo(ctx context.Context, req *m return nil, nil, fmt.Errorf("draft tool is not supported in online agent") } - onlineTool, exist, err := p.toolRepo.GetOnlineTool(ctx, req.ToolID) - if err != nil { - return nil, nil, errorx.Wrapf(err, "GetOnlineTool failed, toolID=%d", req.ToolID) - } - if !exist { - return nil, nil, errorx.New(errno.ErrPluginRecordNotFound) + var ( + exist bool + ) + if req.PluginFrom != nil && *req.PluginFrom == bot_common.PluginFrom_FromSaas { + + tools, _, err := p.toolRepo.BatchGetSaasPluginToolsInfo(ctx, []int64{req.PluginID}) + if err != nil { + return nil, nil, errorx.Wrapf(err, "BatchGetSaasPluginToolsInfo failed, pluginID=%d", req.PluginID) + } + if len(tools) == 0 { + return nil, nil, errorx.New(errno.ErrPluginRecordNotFound) + } + for _, tool := range tools[req.PluginID] { + if tool.ID == req.ToolID { + onlineTool = tool + break + } + } + } else { + onlineTool, exist, err = p.toolRepo.GetOnlineTool(ctx, req.ToolID) + if err != nil { + return nil, nil, errorx.Wrapf(err, "GetOnlineTool failed, toolID=%d", req.ToolID) + } + if !exist { + return nil, nil, errorx.New(errno.ErrPluginRecordNotFound) + } } agentTool, exist, err := p.toolRepo.GetVersionAgentTool(ctx, execOpt.ProjectInfo.ProjectID, model.VersionAgentTool{ @@ -256,24 +308,35 @@ func (p *pluginServiceImpl) getOnlineAgentPluginInfo(ctx context.Context, req *m return nil, nil, errorx.New(errno.ErrPluginRecordNotFound) } - if execOpt.ToolVersion == "" { - onlinePlugin, exist, err = p.pluginRepo.GetOnlinePlugin(ctx, req.PluginID) + if req.PluginFrom != nil && *req.PluginFrom == bot_common.PluginFrom_FromSaas { + saasPlugins, err := p.GetSaasPluginInfo(ctx, []int64{req.PluginID}) if err != nil { - return nil, nil, errorx.Wrapf(err, "GetOnlinePlugin failed, pluginID=%d", req.PluginID) + return nil, nil, errorx.Wrapf(err, "GetSaasPluginInfo failed, pluginID=%d", req.PluginID) } - if !exist { + if len(saasPlugins) == 0 { return nil, nil, errorx.New(errno.ErrPluginRecordNotFound) } + onlinePlugin = saasPlugins[0] } else { - onlinePlugin, exist, err = p.pluginRepo.GetVersionPlugin(ctx, model.VersionPlugin{ - PluginID: req.PluginID, - Version: execOpt.ToolVersion, - }) - if err != nil { - return nil, nil, errorx.Wrapf(err, "GetVersionPlugin failed, pluginID=%d, version=%s", req.PluginID, execOpt.ToolVersion) - } - if !exist { - return nil, nil, errorx.New(errno.ErrPluginRecordNotFound) + if execOpt.ToolVersion == "" { + onlinePlugin, exist, err = p.pluginRepo.GetOnlinePlugin(ctx, req.PluginID) + if err != nil { + return nil, nil, errorx.Wrapf(err, "GetOnlinePlugin failed, pluginID=%d", req.PluginID) + } + if !exist { + return nil, nil, errorx.New(errno.ErrPluginRecordNotFound) + } + } else { + onlinePlugin, exist, err = p.pluginRepo.GetVersionPlugin(ctx, model.VersionPlugin{ + PluginID: req.PluginID, + Version: execOpt.ToolVersion, + }) + if err != nil { + return nil, nil, errorx.Wrapf(err, "GetVersionPlugin failed, pluginID=%d, version=%s", req.PluginID, execOpt.ToolVersion) + } + if !exist { + return nil, nil, errorx.New(errno.ErrPluginRecordNotFound) + } } } @@ -288,6 +351,27 @@ func (p *pluginServiceImpl) getOnlineAgentPluginInfo(ctx context.Context, req *m func (p *pluginServiceImpl) getWorkflowPluginInfo(ctx context.Context, req *model.ExecuteToolRequest, execOpt *model.ExecuteToolOption) (pl *entity.PluginInfo, tl *entity.ToolInfo, err error) { + if req.PluginFrom != nil && *req.PluginFrom == bot_common.PluginFrom_FromSaas { + tools, plugin, err := p.toolRepo.BatchGetSaasPluginToolsInfo(ctx, []int64{req.PluginID}) + if err != nil { + return nil, nil, errorx.Wrapf(err, "BatchGetSaasPluginToolsInfo failed, pluginID=%d", req.PluginID) + } + if len(tools) == 0 { + return nil, nil, errorx.New(errno.ErrPluginRecordNotFound) + } + for _, tool := range tools[req.PluginID] { + if tool.ID == req.ToolID { + tl = tool + break + } + } + if plugin != nil { + pl = plugin[req.PluginID] + } + + return pl, tl, nil + } + if req.ExecDraftTool { var exist bool pl, exist, err = p.pluginRepo.GetDraftPlugin(ctx, req.PluginID) @@ -557,8 +641,13 @@ func (t *toolExecutor) execute(ctx context.Context, argumentsInJson, accessToken } } - toolInvocation := newToolInvocation(t) - requestStr, rawResp, err := toolInvocation.Do(ctx, invocation) + var requestStr, rawResp string + if t.plugin.Source != nil && *t.plugin.Source == bot_common.PluginFrom_FromSaas { + requestStr, rawResp, err = tool.NewSaasCallImpl().Do(ctx, invocation) + } else { + requestStr, rawResp, err = newToolInvocation(t).Do(ctx, invocation) + } + if err != nil { return nil, err } diff --git a/backend/domain/plugin/service/plugin_online.go b/backend/domain/plugin/service/plugin_online.go index 7771e36d8..637e044ca 100644 --- a/backend/domain/plugin/service/plugin_online.go +++ b/backend/domain/plugin/service/plugin_online.go @@ -97,6 +97,19 @@ func (p *pluginServiceImpl) ListPluginProducts(ctx context.Context, req *dto.Lis return plugins[i].GetRefProductID() < plugins[j].GetRefProductID() }) + // official plugins + officialPlugins, _, err := p.pluginRepo.ListCustomOnlinePlugins(ctx, 999999, dto.PageInfo{ + Page: 1, + Size: 1000, + OrderByACS: ptr.Of(true), + SortBy: ptr.Of(dto.SortByCreatedAt), + }) + if err != nil { + return nil, errorx.Wrapf(err, "ListCustomOnlinePlugins failed, spaceID=999999") + } + + plugins = append(plugins, officialPlugins...) + return &dto.ListPluginProductsResponse{ Plugins: plugins, Total: int64(len(plugins)), diff --git a/backend/domain/plugin/service/plugin_saas.go b/backend/domain/plugin/service/plugin_saas.go new file mode 100644 index 000000000..5e96c70dc --- /dev/null +++ b/backend/domain/plugin/service/plugin_saas.go @@ -0,0 +1,302 @@ +/* + * 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 service + +import ( + "context" + "encoding/json" + "strconv" + "strings" + + "github.com/coze-dev/coze-studio/backend/api/model/app/bot_common" + + pluginCommon "github.com/coze-dev/coze-studio/backend/api/model/plugin_develop/common" + "github.com/coze-dev/coze-studio/backend/crossdomain/contract/plugin/consts" + "github.com/coze-dev/coze-studio/backend/crossdomain/contract/plugin/model" + "github.com/coze-dev/coze-studio/backend/domain/plugin/dto" + 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" + "github.com/coze-dev/coze-studio/backend/types/errno" + + "github.com/coze-dev/coze-studio/backend/pkg/lang/ptr" + "github.com/coze-dev/coze-studio/backend/pkg/saasapi" +) + +type CozePlugin struct { + PluginID string `json:"plugin_id"` + Name string `json:"name"` + NameForModel string `json:"name_for_model"` + Description string `json:"description"` + IconURL string `json:"icon_url"` + Category string `json:"category"` + CreatedAt int64 `json:"created_at"` + UpdatedAt int64 `json:"updated_at"` + IsCallAvailable bool `json:"is_call_available"` +} + +func (p *pluginServiceImpl) ListSaasPluginProducts(ctx context.Context, req *domainDto.ListSaasPluginProductsRequest) (resp *domainDto.ListPluginProductsResponse, err error) { + searchReq := &domainDto.SearchSaasPluginRequest{ + PageNum: ptr.Of(int(*req.PageNum)), + PageSize: ptr.Of(int(*req.PageSize)), + Keyword: req.Keyword, + IsOfficial: req.IsOfficial, + ProductPaidType: req.ProductPaidType, + } + if len(req.CategoryIDs) > 0 { + searchReq.CategoryIDs = req.CategoryIDs + } + plugins, hasMore, err := p.fetchSaasPluginsFromCoze(ctx, searchReq) + if err != nil { + return nil, err + } + + return &domainDto.ListPluginProductsResponse{ + Plugins: plugins, + Total: int64(len(plugins)), + HasMore: hasMore, + }, nil +} +func (p *pluginServiceImpl) BatchGetSaasPluginToolsInfo(ctx context.Context, pluginIDs []int64) (tools map[int64][]*entity.ToolInfo, plugins map[int64]*entity.PluginInfo, err error) { + return p.toolRepo.BatchGetSaasPluginToolsInfo(ctx, pluginIDs) +} + +func (p *pluginServiceImpl) fetchSaasPluginsFromCoze(ctx context.Context, searchReq *domainDto.SearchSaasPluginRequest) ([]*entity.PluginInfo, bool, error) { + + searchResp, err := p.searchSaasPlugin(ctx, searchReq) + if err != nil { + return nil, false, err + } + + if searchResp == nil || searchResp.Data == nil { + return nil, false, nil + } + + plugins := make([]*entity.PluginInfo, 0, len(searchResp.Data.Items)) + for _, item := range searchResp.Data.Items { + plugin := convertSaasPluginItemToEntity(item) + plugins = append(plugins, plugin) + } + + return plugins, searchResp.Data.HasMore, nil +} + +func convertSaasPluginItemToEntity(item *domainDto.SaasPluginItem) *entity.PluginInfo { + if item == nil || item.MetaInfo == nil { + return nil + } + + metaInfo := item.MetaInfo + var pluginID int64 + if id, err := strconv.ParseInt(metaInfo.EntityID, 10, 64); err == nil { + pluginID = id + } + + // 创建插件清单 + manifest := &model.PluginManifest{ + SchemaVersion: "v1", + NameForModel: metaInfo.Name, + NameForHuman: metaInfo.Name, + DescriptionForModel: metaInfo.Description, + DescriptionForHuman: metaInfo.Description, + LogoURL: metaInfo.IconURL, + Auth: &model.AuthV2{ + Type: func() consts.AuthzType { + if !item.PluginInfo.IsCallAvailable { + return consts.AuthTypeOfSaasInstalled + } + return consts.AuthzTypeOfNone + }(), + }, + API: model.APIDesc{ + Type: "openapi", + }, + } + + pluginInfo := &model.PluginInfo{ + ID: pluginID, + PluginType: pluginCommon.PluginType_PLUGIN, + SpaceID: 0, + DeveloperID: 0, + APPID: nil, + IconURI: &metaInfo.IconURL, + ServerURL: ptr.Of(""), + CreatedAt: metaInfo.ListedAt, + UpdatedAt: metaInfo.ListedAt, + Manifest: manifest, + Source: ptr.Of(bot_common.PluginFrom_FromSaas), + SaasPluginExtra: &model.SaasPluginExtraInfo{ + IsOfficial: metaInfo.IsOfficial, + JumpSaasURL: &metaInfo.ProductURL, + }, + RefProductID: func() *int64 { + if id, err := strconv.ParseInt(metaInfo.ProductID, 10, 64); err == nil { + return ptr.Of(id) + } + return nil + }(), + } + + return entity.NewPluginInfo(pluginInfo) +} + +func convertCozePluginToEntity(cozePlugin *dto.SaasPluginToolsList) *entity.PluginInfo { + var pluginID int64 + if id, err := strconv.ParseInt(cozePlugin.PluginID, 10, 64); err == nil { + pluginID = id + } + + manifest := &model.PluginManifest{ + SchemaVersion: "v1", + NameForModel: cozePlugin.Name, + NameForHuman: cozePlugin.Name, + DescriptionForModel: cozePlugin.Description, + DescriptionForHuman: cozePlugin.Description, + LogoURL: cozePlugin.IconURL, + Auth: &model.AuthV2{ + Type: func() consts.AuthzType { + if !cozePlugin.IsCallAvailable { + return consts.AuthTypeOfSaasInstalled + } + return consts.AuthzTypeOfNone + }(), + }, + API: model.APIDesc{ + Type: "openapi", + }, + } + + pluginInfo := &model.PluginInfo{ + ID: pluginID, + PluginType: pluginCommon.PluginType_PLUGIN, + SpaceID: 0, + DeveloperID: 0, + APPID: nil, + IconURL: &cozePlugin.IconURL, + ServerURL: ptr.Of("https://api.coze.cn"), + CreatedAt: cozePlugin.CreatedAt, + UpdatedAt: cozePlugin.UpdatedAt, + Manifest: manifest, + Source: ptr.Of(bot_common.PluginFrom_FromSaas), + } + + return entity.NewPluginInfo(pluginInfo) +} + +func (p *pluginServiceImpl) GetSaasPluginInfo(ctx context.Context, pluginIDs []int64) (plugin []*entity.PluginInfo, err error) { + client := saasapi.NewCozeAPIClient() + + var idStrings []string + for _, id := range pluginIDs { + idStrings = append(idStrings, strconv.FormatInt(id, 10)) + } + idsStr := strings.Join(idStrings, ",") + + queryParams := map[string]interface{}{ + "ids": idsStr, + } + + resp, err := client.GetWithQuery(ctx, "/v1/plugins/mget", queryParams) + if err != nil { + return nil, errorx.WrapByCode(err, errno.ErrPluginCallCozeAPIFailed) + } + + var apiResp dto.SaasPluginToolsListResponse + + if err := json.Unmarshal(resp.Data, &apiResp); err != nil { + return nil, errorx.WrapByCode(err, errno.ErrPluginParseCozeAPIResponseFailed) + } + + plugins := make([]*entity.PluginInfo, 0, len(idStrings)) + for _, cozePlugin := range apiResp.Items { + plugin := convertCozePluginToEntity(&cozePlugin) + plugins = append(plugins, plugin) + } + + return plugins, nil +} + +func (p *pluginServiceImpl) searchSaasPlugin(ctx context.Context, req *domainDto.SearchSaasPluginRequest) (resp *domainDto.SearchSaasPluginResponse, err error) { + client := saasapi.NewCozeAPIClient() + + // 构建查询参数 + queryParams := make(map[string]any) + if req.Keyword != nil { + queryParams["keyword"] = req.Keyword + } + if req.PageNum != nil { + queryParams["page_num"] = req.PageNum + } + if req.PageSize != nil { + queryParams["page_size"] = req.PageSize + } + if req.SortType != nil { + queryParams["sort_type"] = req.SortType + } + if len(req.CategoryIDs) > 0 { + var categoryIDStrs []string + for _, id := range req.CategoryIDs { + categoryIDStrs = append(categoryIDStrs, strconv.FormatInt(id, 10)) + } + queryParams["category_ids"] = strings.Join(categoryIDStrs, ",") + } + if req.IsOfficial != nil { + queryParams["is_official"] = req.IsOfficial + } + + apiResp, err := client.GetWithQuery(ctx, "/v1/stores/plugins", queryParams) + if err != nil { + return nil, errorx.WrapByCode(err, errno.ErrPluginCallCozeSearchAPIFailed) + } + + var searchResp domainDto.SearchSaasPluginResponse + if err := json.Unmarshal(apiResp.Data, &searchResp.Data); err != nil { + return nil, errorx.WrapByCode(err, errno.ErrPluginParseCozeSearchAPIResponseFailed) + } + + return &searchResp, nil +} + +func (p *pluginServiceImpl) ListSaasPluginCategories(ctx context.Context, req *domainDto.ListPluginCategoriesRequest) (resp *domainDto.ListPluginCategoriesResponse, err error) { + client := saasapi.NewCozeAPIClient() + + queryParams := make(map[string]any) + if req.PageNum != nil { + queryParams["page_num"] = req.PageNum + } + if req.PageSize != nil { + queryParams["page_size"] = req.PageSize + } + if req.EntityType != nil { + queryParams["entity_type"] = req.EntityType + } + + apiResp, err := client.GetWithQuery(ctx, "/v1/stores/categories", queryParams) + if err != nil { + return nil, errorx.WrapByCode(err, errno.ErrPluginCallCozeCategoriesAPIFailed) + } + + var categoriesResp domainDto.ListPluginCategoriesResponse + if err := json.Unmarshal(apiResp.Data, &categoriesResp.Data); err != nil { + return nil, errorx.WrapByCode(err, errno.ErrPluginParseCozeCategoriesAPIResponseFailed) + } + + categoriesResp.Code = apiResp.Code + categoriesResp.Msg = apiResp.Msg + + return &categoriesResp, nil +} diff --git a/backend/domain/plugin/service/plugin_saas_test.go b/backend/domain/plugin/service/plugin_saas_test.go new file mode 100644 index 000000000..2277a9e0f --- /dev/null +++ b/backend/domain/plugin/service/plugin_saas_test.go @@ -0,0 +1,542 @@ +/* + * 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 service + +import ( + "encoding/json" + "testing" + + "github.com/stretchr/testify/assert" + + "github.com/coze-dev/coze-studio/backend/domain/plugin/dto" + domainDto "github.com/coze-dev/coze-studio/backend/domain/plugin/dto" + "github.com/coze-dev/coze-studio/backend/domain/plugin/repository" + + pluginCommon "github.com/coze-dev/coze-studio/backend/api/model/plugin_develop/common" +) + +func TestSearchSaasPluginResponse_JSONUnmarshal(t *testing.T) { + // Test JSON data based on the actual API response + jsonData := `{ + "msg": "", + "detail": { + "logid": "2025092821165570E59640C37BF984D370" + }, + "data": { + "has_more": true, + "items": [ + { + "metainfo": { + "description": "当你需要获取某些分类的时候,就调用\n", + "user_info": { + "nick_name": "testlbsZEOkZJP", + "avatar_url": "https://p6-passport.byteacctimg.com/img/user-avatar/e67e7ddd636a2087e79d624a64a19359~300x300.image", + "user_id": "3235179593473241", + "user_name": "dataEngine_yulu_cn" + }, + "category": { + "id": "7327137275714830373", + "name": "社交" + }, + "icon_url": "https://p9-flow-product-sign.byteimg.com/tos-cn-i-13w3uml6bg/3be533c88a224f30ac587d577514110c~tplv-13w3uml6bg-resize:128:128.image", + "product_id": "7546432661141602358", + "listed_at": 1757337314, + "is_official": true, + "entity_type": "plugin", + "product_url": "https://www.coze.cn/store/plugin/7546432661141602358", + "entity_id": "7546499763995410451", + "entity_version": "0", + "name": "ppe_test_官方付费", + "paid_type": "paid" + }, + "plugin_info": { + "favorite_count": 1, + "heat": 0, + "avg_exec_duration_ms": 114.61111, + "call_count": 20, + "description": "当你需要获取某些分类的时候,就调用", + "total_tools_count": 2, + "bots_use_count": 7, + "associated_bots_use_count": 0, + "success_rate": 0.8333349999999999 + } + } + ] + }, + "code": 0 + }` + + var searchResp domainDto.SearchSaasPluginResponse + err := json.Unmarshal([]byte(jsonData), &searchResp) + + // Assertions + assert.NoError(t, err) + assert.Equal(t, 0, searchResp.Code) + assert.Equal(t, "", searchResp.Msg) + + // Verify detail field + assert.NotNil(t, searchResp.Detail) + assert.Equal(t, "2025092821165570E59640C37BF984D370", searchResp.Detail.LogID) + + // Verify data field + assert.NotNil(t, searchResp.Data) + assert.True(t, searchResp.Data.HasMore) + assert.Len(t, searchResp.Data.Items, 1) + + // Verify plugin item + item := searchResp.Data.Items[0] + assert.NotNil(t, item.MetaInfo) + assert.NotNil(t, item.PluginInfo) + + // Verify metainfo fields + metaInfo := item.MetaInfo + assert.Equal(t, "7546432661141602358", metaInfo.ProductID) + assert.Equal(t, "7546499763995410451", metaInfo.EntityID) + assert.Equal(t, "ppe_test_官方付费", metaInfo.Name) + assert.Equal(t, "https://www.coze.cn/store/plugin/7546432661141602358", metaInfo.ProductURL) + assert.True(t, metaInfo.IsOfficial) + + // Verify user_info field (should be string now) + assert.NotNil(t, metaInfo.UserInfo) + assert.Equal(t, "3235179593473241", metaInfo.UserInfo.UserID) + assert.Equal(t, "testlbsZEOkZJP", metaInfo.UserInfo.NickName) + + // Verify plugin_info fields + pluginInfo := item.PluginInfo + assert.Equal(t, 1, pluginInfo.FavoriteCount) + assert.Equal(t, int64(20), pluginInfo.CallCount) + assert.Equal(t, 2, pluginInfo.TotalToolsCount) +} + +func TestConvertSaasPluginItemToEntity_WithNewFields(t *testing.T) { + // Test the conversion function with our new fields to ensure they're handled correctly + item := &domainDto.SaasPluginItem{ + MetaInfo: &domainDto.SaasPluginMetaInfo{ + ProductID: "7546432661141602358", + EntityID: "7546499763995410451", + EntityVersion: "0", + EntityType: "plugin", + Name: "Test Plugin", + Description: "Test plugin description", + UserInfo: &domainDto.SaasPluginUserInfo{ + UserID: "3235179593473241", // String type (our fix) + UserName: "testUserName", + NickName: "testUser", + AvatarURL: "https://example.com/avatar.png", + }, + Category: &domainDto.SaasPluginCategory{ + ID: "7327137275714830373", + Name: "测试分类", + }, + IconURL: "https://example.com/icon.png", + ProductURL: "https://www.coze.cn/store/plugin/7546432661141602358", // New field (our fix) + ListedAt: 1757337314, + PaidType: "free", + IsOfficial: true, + }, + PluginInfo: &domainDto.SaasPluginInfo{ + FavoriteCount: 1, + Heat: 0, + AvgExecDurationMs: 114.61111, + CallCount: 20, + Description: "Test plugin description", + TotalToolsCount: 2, + BotsUseCount: 7, + AssociatedBotsUseCount: 0, + SuccessRate: 0.8333349999999999, + }, + } + + // Execute the conversion + plugin := convertSaasPluginItemToEntity(item) + + // Assertions + assert.NotNil(t, plugin) + assert.Equal(t, "Test Plugin", plugin.GetName()) + assert.Equal(t, "Test plugin description", plugin.GetDesc()) + assert.Equal(t, "https://example.com/icon.png", plugin.GetIconURI()) + + // This test verifies that: + // 1. ProductURL field is accessible (even if not directly used in conversion) + // 2. UserID string type works correctly + // 3. All new fields are properly handled in the conversion process +} + +func TestSearchSaasPluginResponse_WithAllNewFields(t *testing.T) { + // Test JSON parsing with all our new fields to ensure complete coverage + jsonData := `{ + "code": 0, + "msg": "success", + "detail": { + "logid": "test-log-id-12345" + }, + "data": { + "has_more": false, + "items": [ + { + "metainfo": { + "product_id": "123", + "entity_id": "456", + "entity_version": "1", + "entity_type": "plugin", + "name": "Test Plugin", + "description": "Test Description", + "user_info": { + "user_id": "9876543210", + "user_name": "testuser", + "nick_name": "Test User", + "avatar_url": "https://example.com/avatar.jpg" + }, + "category": { + "id": "cat123", + "name": "Test Category" + }, + "icon_url": "https://example.com/icon.jpg", + "product_url": "https://example.com/product/123", + "listed_at": 1640995200, + "paid_type": "free", + "is_official": false + }, + "plugin_info": { + "favorite_count": 5, + "heat": 10, + "avg_exec_duration_ms": 200.5, + "call_count": 100, + "description": "Plugin Info Description", + "total_tools_count": 3, + "bots_use_count": 15, + "associated_bots_use_count": 2, + "success_rate": 0.95 + } + } + ] + } + }` + + var searchResp domainDto.SearchSaasPluginResponse + err := json.Unmarshal([]byte(jsonData), &searchResp) + + // Assertions for basic structure + assert.NoError(t, err) + assert.Equal(t, 0, searchResp.Code) + assert.Equal(t, "success", searchResp.Msg) + + // Test our new ResponseDetail field + assert.NotNil(t, searchResp.Detail) + assert.Equal(t, "test-log-id-12345", searchResp.Detail.LogID) + + // Test data structure + assert.NotNil(t, searchResp.Data) + assert.False(t, searchResp.Data.HasMore) + assert.Len(t, searchResp.Data.Items, 1) + + // Test item with all our fixes + item := searchResp.Data.Items[0] + assert.NotNil(t, item.MetaInfo) + + // Test our new ProductURL field + assert.Equal(t, "https://example.com/product/123", item.MetaInfo.ProductURL) + + // Test our fixed UserID string type + assert.NotNil(t, item.MetaInfo.UserInfo) + assert.Equal(t, "9876543210", item.MetaInfo.UserInfo.UserID) // String, not int64 + + // Test other fields to ensure nothing broke + assert.Equal(t, "Test Plugin", item.MetaInfo.Name) + assert.Equal(t, "Test Description", item.MetaInfo.Description) + assert.False(t, item.MetaInfo.IsOfficial) + + // Test plugin info + assert.NotNil(t, item.PluginInfo) + assert.Equal(t, 5, item.PluginInfo.FavoriteCount) + assert.Equal(t, int64(100), item.PluginInfo.CallCount) +} + +func TestJsonSchemaTypeUnmarshaling(t *testing.T) { + // Test JSON data with inputSchema containing type field + jsonData := `{ + "plugins": [{ + "tools": [{ + "tool_id": "7379227817307029513", + "description": "当你需要获取网页、pdf、doc、docx、xlsx、csv、text 内容时,使用此工具", + "name": "LinkReaderPlugin", + "inputSchema": { + "required": ["url"], + "properties": { + "need_image_url": { + "description": "是否需要返回图片url", + "type": "boolean" + }, + "url": { + "description": "网页url、pdf url、docx url、csv url、 xlsx url。", + "type": "string" + } + }, + "type": "object" + }, + "outputSchema": { + "properties": { + "data": { + "properties": { + "content": { + "type": "string" + } + }, + "type": "object" + } + }, + "type": "object" + } + }] + }] + }` + + var apiResp struct { + Plugins []struct { + Tools []struct { + ToolID string `json:"tool_id"` + Description string `json:"description"` + InputSchema *domainDto.JsonSchema `json:"inputSchema"` + Name string `json:"name"` + OutputSchema *domainDto.JsonSchema `json:"outputSchema"` + } `json:"tools"` + } `json:"plugins"` + } + + err := json.Unmarshal([]byte(jsonData), &apiResp) + assert.NoError(t, err) + + // Verify that we have the expected structure + assert.Len(t, apiResp.Plugins, 1) + assert.Len(t, apiResp.Plugins[0].Tools, 1) + + tool := apiResp.Plugins[0].Tools[0] + assert.Equal(t, "7379227817307029513", tool.ToolID) + assert.Equal(t, "LinkReaderPlugin", tool.Name) + + // Verify InputSchema type field is correctly parsed + assert.NotNil(t, tool.InputSchema) + assert.Equal(t, domainDto.JsonSchemaType_OBJECT, tool.InputSchema.Type) + assert.Len(t, tool.InputSchema.Required, 1) + assert.Equal(t, "url", tool.InputSchema.Required[0]) + + // Verify properties are correctly parsed with their types + assert.NotNil(t, tool.InputSchema.Properties) + assert.Len(t, tool.InputSchema.Properties, 2) + + urlProp := tool.InputSchema.Properties["url"] + assert.NotNil(t, urlProp) + assert.Equal(t, domainDto.JsonSchemaType_STRING, urlProp.Type) + assert.Equal(t, "网页url、pdf url、docx url、csv url、 xlsx url。", urlProp.Description) + + needImageProp := tool.InputSchema.Properties["need_image_url"] + assert.NotNil(t, needImageProp) + assert.Equal(t, domainDto.JsonSchemaType_BOOLEAN, needImageProp.Type) + assert.Equal(t, "是否需要返回图片url", needImageProp.Description) + + // Verify OutputSchema type field is correctly parsed + assert.NotNil(t, tool.OutputSchema) + assert.Equal(t, domainDto.JsonSchemaType_OBJECT, tool.OutputSchema.Type) +} + +func TestConvertFromJsonSchemaWithFixedType(t *testing.T) { + // Test the convertFromJsonSchema function + parameters := repository.ConvertFromJsonSchemaForTest(&dto.JsonSchema{ + Type: dto.JsonSchemaType_OBJECT, + Properties: map[string]*dto.JsonSchema{ + "url": { + Type: dto.JsonSchemaType_STRING, + Description: "图片的url", + }, + "return_url": { + Type: dto.JsonSchemaType_BOOLEAN, + Description: "是否需要返回图片url", + }, + }, + Required: []string{"url"}, + }) + + // Debug: print the actual values + t.Logf("Number of parameters: %d", len(parameters)) + for i, param := range parameters { + t.Logf("Parameter %d: Name=%s, Location=%d, Type=%d", i, param.Name, param.Location, param.Type) + } + + // Verify that parameters are correctly generated + assert.Len(t, parameters, 2) + + // Find the url parameter + var urlParam, imageParam *pluginCommon.APIParameter + for _, param := range parameters { + if param.Name == "url" { + urlParam = param + } else if param.Name == "return_url" { + imageParam = param + } + } + + // Verify url parameter + assert.NotNil(t, urlParam) + assert.Equal(t, "url", urlParam.Name) + assert.Equal(t, "图片的url", urlParam.Desc) + assert.True(t, urlParam.IsRequired) + assert.Equal(t, pluginCommon.ParameterType_String, urlParam.Type) + assert.Equal(t, pluginCommon.ParameterLocation_Body, urlParam.Location) + + // Verify return_url parameter + assert.NotNil(t, imageParam) + assert.Equal(t, "return_url", imageParam.Name) + assert.Equal(t, "是否需要返回图片url", imageParam.Desc) + assert.False(t, imageParam.IsRequired) // not in required array + assert.Equal(t, pluginCommon.ParameterType_Bool, imageParam.Type) + assert.Equal(t, pluginCommon.ParameterLocation_Body, imageParam.Location) +} + +func TestBatchGetSaasPluginToolsInfoIntegration(t *testing.T) { + // This test simulates the original issue scenario + // Create mock response data similar to what was provided in the issue + respData := `{ + "plugins": [{ + "tools": [{ + "tool_id": "7379227817307029513", + "description": "当你需要获取网页、pdf、doc、docx、xlsx、csv、text 内容时,使用此工具,可以获取url链接下的标题和内容。由于个别网站自身站点限制,无法获取网页内容。", + "name": "LinkReaderPlugin", + "inputSchema": { + "required": ["url"], + "properties": { + "need_image_url": { + "description": "是否需要返回图片url", + "type": "boolean" + }, + "url": { + "description": "网页url、pdf url、docx url、csv url、 xlsx url。", + "type": "string" + } + }, + "type": "object" + }, + "outputSchema": { + "properties": { + "data": { + "properties": { + "images": { + "items": { + "properties": { + "title": {"type": "string"}, + "url": {"type": "string"}, + "width": {"type": "integer"}, + "alt": {"type": "string"}, + "height": {"type": "integer"} + }, + "type": "object" + }, + "type": "array" + }, + "title": {"type": "string"}, + "content": {"type": "string"} + }, + "type": "object" + }, + "err_msg": { + "description": "错误信息", + "type": "string" + }, + "error_code": { + "description": "错误码", + "type": "string" + }, + "error_msg": { + "description": "错误信息", + "type": "string" + }, + "message": { + "description": "错误信息", + "type": "string" + }, + "pdf_content": { + "description": "pdf的内容", + "type": "string" + }, + "code": { + "description": "错误码", + "type": "integer" + } + }, + "type": "object" + } + }] + }] + }` + + // Simulate the unmarshaling process that happens in BatchGetSaasPluginToolsInfo + var apiResp struct { + Plugins []struct { + Tools []struct { + ToolID string `json:"tool_id"` + Description string `json:"description"` + InputSchema *domainDto.JsonSchema `json:"inputSchema"` + Name string `json:"name"` + OutputSchema *domainDto.JsonSchema `json:"outputSchema"` + } `json:"tools"` + McpJSON string `json:"mcp_json"` + } `json:"plugins"` + } + + err := json.Unmarshal([]byte(respData), &apiResp) + assert.NoError(t, err) + + // Verify the structure is correctly parsed + assert.Len(t, apiResp.Plugins, 1) + assert.Len(t, apiResp.Plugins[0].Tools, 1) + + tool := apiResp.Plugins[0].Tools[0] + + // Verify InputSchema type is correctly parsed (this was the original issue) + assert.NotNil(t, tool.InputSchema) + assert.Equal(t, domainDto.JsonSchemaType_OBJECT, tool.InputSchema.Type) + + // Now test the convertFromJsonSchema function with the parsed schema + parameters := repository.ConvertFromJsonSchemaForTest(tool.InputSchema) + + // This should NOT be empty anymore (this was the original problem) + assert.NotEmpty(t, parameters) + assert.Len(t, parameters, 2) + + // Verify the parameters are correctly generated + paramMap := make(map[string]*pluginCommon.APIParameter) + for _, param := range parameters { + paramMap[param.Name] = param + } + + // Check url parameter + urlParam := paramMap["url"] + assert.NotNil(t, urlParam) + assert.Equal(t, "url", urlParam.Name) + assert.True(t, urlParam.IsRequired) + assert.Equal(t, pluginCommon.ParameterType_String, urlParam.Type) + assert.Equal(t, pluginCommon.ParameterLocation_Body, urlParam.Location) + assert.Equal(t, "网页url、pdf url、docx url、csv url、 xlsx url。", urlParam.Desc) + + // Check need_image_url parameter + imageParam := paramMap["need_image_url"] + assert.NotNil(t, imageParam) + assert.Equal(t, "need_image_url", imageParam.Name) + assert.False(t, imageParam.IsRequired) + assert.Equal(t, pluginCommon.ParameterType_Bool, imageParam.Type) + assert.Equal(t, pluginCommon.ParameterLocation_Body, imageParam.Location) + assert.Equal(t, "是否需要返回图片url", imageParam.Desc) +} diff --git a/backend/domain/plugin/service/service.go b/backend/domain/plugin/service/service.go index a7af904c6..814d697f4 100644 --- a/backend/domain/plugin/service/service.go +++ b/backend/domain/plugin/service/service.go @@ -63,9 +63,9 @@ type PluginService interface { MoveAPPPluginToLibrary(ctx context.Context, pluginID int64) (plugin *entity.PluginInfo, err error) // Agent Tool - BindAgentTools(ctx context.Context, agentID int64, toolIDs []int64) (err error) + BindAgentTools(ctx context.Context, agentID int64, bindTools []*model.BindToolInfo) (err error) DuplicateDraftAgentTools(ctx context.Context, fromAgentID, toAgentID int64) (err error) - GetDraftAgentToolByName(ctx context.Context, agentID int64, toolName string) (tool *entity.ToolInfo, err error) + GetDraftAgentToolByName(ctx context.Context, agentID int64, pluginID int64, toolName string) (tool *entity.ToolInfo, err error) MGetAgentTools(ctx context.Context, req *model.MGetAgentToolsRequest) (tools []*entity.ToolInfo, err error) UpdateBotDefaultParams(ctx context.Context, req *dto.UpdateBotDefaultParamsRequest) (err error) @@ -79,6 +79,12 @@ type PluginService interface { GetOAuthStatus(ctx context.Context, userID, pluginID int64) (resp *dto.GetOAuthStatusResponse, err error) GetAgentPluginsOAuthStatus(ctx context.Context, userID, agentID int64) (status []*dto.AgentPluginOAuthStatus, err error) + //Saas Plugin Product + ListSaasPluginProducts(ctx context.Context, req *dto.ListSaasPluginProductsRequest) (resp *dto.ListPluginProductsResponse, err error) + BatchGetSaasPluginToolsInfo(ctx context.Context, pluginIDs []int64) (tools map[int64][]*entity.ToolInfo, plugins map[int64]*entity.PluginInfo, err error) + GetSaasPluginInfo(ctx context.Context, pluginIDs []int64) (plugins []*entity.PluginInfo, err error) + ListSaasPluginCategories(ctx context.Context, req *dto.ListPluginCategoriesRequest) (resp *dto.ListPluginCategoriesResponse, 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) diff --git a/backend/domain/plugin/service/tool/invocation_http.go b/backend/domain/plugin/service/tool/invocation_http.go index cc97fc8d7..ac8873bcd 100644 --- a/backend/domain/plugin/service/tool/invocation_http.go +++ b/backend/domain/plugin/service/tool/invocation_http.go @@ -38,6 +38,7 @@ import ( "github.com/coze-dev/coze-studio/backend/pkg/i18n" "github.com/coze-dev/coze-studio/backend/pkg/lang/conv" "github.com/coze-dev/coze-studio/backend/pkg/logs" + "github.com/coze-dev/coze-studio/backend/pkg/saasapi" "github.com/coze-dev/coze-studio/backend/types/consts" "github.com/coze-dev/coze-studio/backend/types/errno" @@ -279,6 +280,16 @@ func (h *httpCallImpl) buildRequestBody(ctx context.Context, op *model.Openapi3O return body, contentType, nil } +func (h *httpCallImpl) injectCozeSaasAPIToken(ctx context.Context, httpReq *http.Request) (errMsg string, err error) { + + saasapiClient := saasapi.NewCozeAPIClient() + if saasapiClient.APIKey == "" { + return "", fmt.Errorf("coze saas api token is empty") + } + httpReq.Header.Set("Authorization", "Bearer "+saasapiClient.APIKey) + return "", nil +} + func (h *httpCallImpl) injectServiceAPIToken(ctx context.Context, httpReq *http.Request, authInfo *model.AuthV2) (errMsg string, err error) { if authInfo.SubType == pluginConsts.AuthzSubTypeOfServiceAPIToken { authOfAPIToken := authInfo.AuthOfAPIToken diff --git a/backend/domain/plugin/service/tool/invocation_saas.go b/backend/domain/plugin/service/tool/invocation_saas.go new file mode 100644 index 000000000..c08ea8dce --- /dev/null +++ b/backend/domain/plugin/service/tool/invocation_saas.go @@ -0,0 +1,194 @@ +/* + * 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 tool + +import ( + "bytes" + "context" + "fmt" + "io" + "net/http" + "net/url" + "strings" + + "github.com/bytedance/sonic" + + "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/logs" + "github.com/coze-dev/coze-studio/backend/pkg/saasapi" + "github.com/coze-dev/coze-studio/backend/types/errno" +) + +type saasCallImpl struct { +} + +func NewSaasCallImpl() Invocation { + return &saasCallImpl{} +} + +func (s *saasCallImpl) Do(ctx context.Context, args *InvocationArgs) (request string, resp string, err error) { + httpReq, err := s.buildHTTPRequest(ctx, args) + if err != nil { + return "", "", err + } + + err = s.injectAuthInfo(ctx, httpReq, args) + if err != nil { + return "", "", err + } + + var reqBodyBytes []byte + if httpReq.GetBody != nil { + reqBody, err := httpReq.GetBody() + if err != nil { + return "", "", err + } + defer reqBody.Close() + + reqBodyBytes, err = io.ReadAll(reqBody) + if err != nil { + return "", "", err + } + } + + requestStr, err := genRequestString(httpReq, reqBodyBytes) + if err != nil { + return "", "", err + } + + restyReq := defaultHttpCli.NewRequest() + restyReq.Header = httpReq.Header + restyReq.Method = httpReq.Method + restyReq.URL = httpReq.URL.String() + if reqBodyBytes != nil { + restyReq.SetBody(reqBodyBytes) + } + restyReq.SetContext(ctx) + + logs.CtxDebugf(ctx, "[execute] url=%s, header=%s, method=%s, body=%s", + restyReq.URL, restyReq.Header, restyReq.Method, restyReq.Body) + + httpResp, err := restyReq.Send() + if err != nil { + return "", "", errorx.New(errno.ErrPluginExecuteToolFailed, errorx.KVf(errno.PluginMsgKey, "http request failed, err=%s", err)) + } + + logs.CtxDebugf(ctx, "[execute] status=%s, response=%s", httpResp.Status(), httpResp.String()) + + if httpResp.StatusCode() != http.StatusOK { + return "", "", errorx.New(errno.ErrPluginExecuteToolFailed, + errorx.KVf(errno.PluginMsgKey, "http request failed, status=%s\nresp=%s", httpResp.Status(), httpResp.String())) + } + httpRespBody := httpResp.String() + + type CozeAPIResponse struct { + Code int `json:"code"` + Msg string `json:"msg"` + Data map[string]any `json:"data"` + } + var apiResp CozeAPIResponse + if err := sonic.UnmarshalString(httpRespBody, &apiResp); err != nil { + return "", "", fmt.Errorf("failed to parse API response: %w", err) + } + + rawResp := apiResp.Data["result"] + return requestStr, encoder.MustString(rawResp), nil +} + +func (s *saasCallImpl) injectAuthInfo(ctx context.Context, httpReq *http.Request, args *InvocationArgs) (err error) { + + saasapiClient := saasapi.NewCozeAPIClient() + if saasapiClient.APIKey == "" { + return fmt.Errorf("coze saas api token is empty") + } + httpReq.Header.Set("Authorization", "Bearer "+saasapiClient.APIKey) + return nil +} + +func (s *saasCallImpl) buildHTTPRequest(ctx context.Context, args *InvocationArgs) (httpReq *http.Request, err error) { + tool := args.Tool + rawURL := args.ServerURL + tool.GetSubURL() + + reqURL, err := s.buildHTTPRequestURL(ctx, rawURL, args) + if err != nil { + return nil, err + } + + type callSaasTool struct { + Arguments map[string]any `json:"arguments"` + ToolName string `json:"tool_name"` + } + + callSaasToolData := &callSaasTool{ + ToolName: tool.GetName(), + Arguments: args.Body, + } + + bodyBytes, err := sonic.MarshalString(callSaasToolData) + if err != nil { + return nil, err + } + + httpReq, err = http.NewRequestWithContext(ctx, tool.GetMethod(), reqURL.String(), bytes.NewBufferString(bodyBytes)) + if err != nil { + return nil, err + } + + return httpReq, nil +} + +func (s *saasCallImpl) buildHTTPRequestURL(ctx context.Context, rawURL string, args *InvocationArgs) (reqURL *url.URL, err error) { + if len(args.Path) > 0 { + for k, v := range args.Path { + p := args.groupedKeySchema.PathKeys[k] + vStr, eErr := encoder.EncodeParameter(p, v) + if eErr != nil { + return nil, eErr + } + rawURL = strings.ReplaceAll(rawURL, "{"+k+"}", vStr) + } + } + + query := url.Values{} + if len(args.Query) > 0 { + for k, val := range args.Query { + switch v := val.(type) { + case []any: + for _, _v := range v { + query.Add(k, encoder.MustString(_v)) + } + default: + query.Add(k, encoder.MustString(v)) + } + } + } + + encodeQuery := query.Encode() + + reqURL, err = url.Parse(rawURL) + if err != nil { + return nil, err + } + + if len(reqURL.RawQuery) > 0 && len(encodeQuery) > 0 { + reqURL.RawQuery += "&" + encodeQuery + } else if len(encodeQuery) > 0 { + reqURL.RawQuery = encodeQuery + } + + return reqURL, nil +} diff --git a/backend/domain/shortcutcmd/internal/dal/dao.go b/backend/domain/shortcutcmd/internal/dal/dao.go index 28490c74b..1ba053bb0 100644 --- a/backend/domain/shortcutcmd/internal/dal/dao.go +++ b/backend/domain/shortcutcmd/internal/dal/dao.go @@ -87,6 +87,7 @@ func (dao *ShortCutCmdDAO) buildCreatePO(ctx context.Context, shortcut *entity.S AgentID: shortcut.AgentID, ShortcutIcon: shortcut.ShortcutIcon, PluginToolID: shortcut.PluginToolID, + Source: shortcut.Source, } return po, nil } diff --git a/backend/domain/shortcutcmd/internal/dal/model/shortcut_command.gen.go b/backend/domain/shortcutcmd/internal/dal/model/shortcut_command.gen.go index 29afbdf90..1dd5fe1e1 100644 --- a/backend/domain/shortcutcmd/internal/dal/model/shortcut_command.gen.go +++ b/backend/domain/shortcutcmd/internal/dal/model/shortcut_command.gen.go @@ -49,6 +49,7 @@ type ShortcutCommand struct { AgentID int64 `gorm:"column:agent_id;not null;comment:When executing a multi instruction, which node executes the instruction" json:"agent_id"` // When executing a multi instruction, which node executes the instruction ShortcutIcon *playground.ShortcutFileInfo `gorm:"column:shortcut_icon;comment:shortcut icon;serializer:json" json:"shortcut_icon"` // shortcut icon PluginToolID int64 `gorm:"column:plugin_tool_id;not null;comment:tool_id" json:"plugin_tool_id"` // tool_id + Source int32 `gorm:"column:source;comment:plugin source 1 coze saas 0 default" json:"source"` // plugin source 1 coze saas 0 default } // TableName ShortcutCommand's table name diff --git a/backend/domain/shortcutcmd/internal/dal/query/shortcut_command.gen.go b/backend/domain/shortcutcmd/internal/dal/query/shortcut_command.gen.go index 37a501b01..f019fb80e 100644 --- a/backend/domain/shortcutcmd/internal/dal/query/shortcut_command.gen.go +++ b/backend/domain/shortcutcmd/internal/dal/query/shortcut_command.gen.go @@ -1,3 +1,19 @@ +/* + * Copyright 2025 coze-dev Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + // Code generated by gorm.io/gen. DO NOT EDIT. // Code generated by gorm.io/gen. DO NOT EDIT. // Code generated by gorm.io/gen. DO NOT EDIT. @@ -50,6 +66,7 @@ func newShortcutCommand(db *gorm.DB, opts ...gen.DOOption) shortcutCommand { _shortcutCommand.AgentID = field.NewInt64(tableName, "agent_id") _shortcutCommand.ShortcutIcon = field.NewField(tableName, "shortcut_icon") _shortcutCommand.PluginToolID = field.NewInt64(tableName, "plugin_tool_id") + _shortcutCommand.Source = field.NewInt32(tableName, "source") _shortcutCommand.fillFieldMap() @@ -84,6 +101,7 @@ type shortcutCommand struct { AgentID field.Int64 // When executing a multi instruction, which node executes the instruction ShortcutIcon field.Field // shortcut icon PluginToolID field.Int64 // tool_id + Source field.Int32 // plugin source 1 coze saas 0 default fieldMap map[string]field.Expr } @@ -123,6 +141,7 @@ func (s *shortcutCommand) updateTableName(table string) *shortcutCommand { s.AgentID = field.NewInt64(table, "agent_id") s.ShortcutIcon = field.NewField(table, "shortcut_icon") s.PluginToolID = field.NewInt64(table, "plugin_tool_id") + s.Source = field.NewInt32(table, "source") s.fillFieldMap() @@ -139,7 +158,7 @@ func (s *shortcutCommand) GetFieldByName(fieldName string) (field.OrderExpr, boo } func (s *shortcutCommand) fillFieldMap() { - s.fieldMap = make(map[string]field.Expr, 23) + s.fieldMap = make(map[string]field.Expr, 24) s.fieldMap["id"] = s.ID s.fieldMap["object_id"] = s.ObjectID s.fieldMap["command_id"] = s.CommandID @@ -163,6 +182,7 @@ func (s *shortcutCommand) fillFieldMap() { s.fieldMap["agent_id"] = s.AgentID s.fieldMap["shortcut_icon"] = s.ShortcutIcon s.fieldMap["plugin_tool_id"] = s.PluginToolID + s.fieldMap["source"] = s.Source } func (s shortcutCommand) clone(db *gorm.DB) shortcutCommand { diff --git a/backend/domain/user/entity/saas_user.go b/backend/domain/user/entity/saas_user.go new file mode 100644 index 000000000..e7797c375 --- /dev/null +++ b/backend/domain/user/entity/saas_user.go @@ -0,0 +1,152 @@ +/* + * 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 entity + +// BenefitType represents the type of benefit +type BenefitType string + +const ( + BenefitTypeCallToolLimit BenefitType = "call_tool_limit" + BenefitTypeAPIRunQPS BenefitType = "api_run_qps" +) + +// UserLevel represents the user level (string type to match API) +type UserLevel string + +const ( + UserLevelUnknown UserLevel = "unknown" + UserLevelBasic UserLevel = "basic" + UserLevelPro UserLevel = "v1_pro_instance" + UserLevelEnterprise UserLevel = "enterprise" + // Add more levels as needed +) + +// EntityBenefitStatus represents the status of a benefit entity (string type to match API) +type EntityBenefitStatus string + +const ( + EntityBenefitStatusUnknown EntityBenefitStatus = "unknown" + EntityBenefitStatusValid EntityBenefitStatus = "valid" + EntityBenefitStatusExpired EntityBenefitStatus = "expired" + // Add more statuses as needed +) + +// ResourceUsageStrategy represents the resource usage strategy (string type to match API) +type ResourceUsageStrategy string + +const ( + ResourceUsageStrategyUnknown ResourceUsageStrategy = "unknown" + ResourceUsageStrategyByQuota ResourceUsageStrategy = "quota" + ResourceUsageStrategyUnlimit ResourceUsageStrategy = "unlimit" + // Add more strategies as needed +) + +// GetEnterpriseBenefitRequest represents the request for getting enterprise benefit +type GetEnterpriseBenefitRequest struct { + BenefitType *string `json:"benefit_type,omitempty" form:"benefit_type"` + ResourceID *string `json:"resource_id,omitempty" form:"resource_id"` +} + +// GetEnterpriseBenefitResponse represents the response for getting enterprise benefit +type GetEnterpriseBenefitResponse struct { + Code int32 `json:"code"` + Message string `json:"message"` + Data *BenefitData `json:"data,omitempty"` +} + +// BenefitData represents the benefit data +type BenefitData struct { + BasicInfo *BasicInfo `json:"basic_info,omitempty"` + BenefitInfo []*BenefitInfo `json:"benefit_info,omitempty"` +} + +// BasicInfo represents the basic information +type BasicInfo struct { + UserLevel UserLevel `json:"user_level,omitempty"` +} + +// BenefitInfo represents the benefit information +type BenefitInfo struct { + BenefitType BenefitType `json:"benefit_type,omitempty"` + Basic *BenefitTypeInfoItem `json:"basic,omitempty"` + Effective *BenefitTypeInfoItem `json:"effective,omitempty"` + ResourceID string `json:"resource_id,omitempty"` +} + +// BenefitTypeInfoItem represents a benefit type info item +type BenefitTypeInfoItem struct { + ItemID string `json:"item_id,omitempty"` + ItemInfo *CommonCounter `json:"item_info,omitempty"` + Status EntityBenefitStatus `json:"status,omitempty"` + BenefitID string `json:"benefit_id,omitempty"` +} + +// CommonCounter represents a common counter +type CommonCounter struct { + Used float64 `json:"used,omitempty"` // Used amount when Strategy == ByQuota, returns 0 if no usage data + Total float64 `json:"total,omitempty"` // Total limit when Strategy == ByQuota + Strategy ResourceUsageStrategy `json:"strategy,omitempty"` // Resource usage strategy + StartAt int64 `json:"start_at,omitempty"` // Start time in seconds + EndAt int64 `json:"end_at,omitempty"` // End time in seconds +} + +// String methods for enums (for better debugging and logging) + +// String methods for enums (for better debugging and logging) +func (bt BenefitType) String() string { + return string(bt) +} + +func (ul UserLevel) String() string { + return string(ul) +} + +func (ebs EntityBenefitStatus) String() string { + return string(ebs) +} + +func (rus ResourceUsageStrategy) String() string { + return string(rus) +} + +// Validation methods +func (ul UserLevel) IsValid() bool { + switch ul { + case UserLevelUnknown, UserLevelBasic, UserLevelPro, UserLevelEnterprise: + return true + default: + return false + } +} + +func (ebs EntityBenefitStatus) IsValid() bool { + switch ebs { + case EntityBenefitStatusUnknown, EntityBenefitStatusValid, EntityBenefitStatusExpired: + return true + default: + return false + } +} + +func (rus ResourceUsageStrategy) IsValid() bool { + switch rus { + case ResourceUsageStrategyUnknown, ResourceUsageStrategyByQuota, ResourceUsageStrategyUnlimit: + return true + default: + return false + } +} diff --git a/backend/domain/user/entity/user.go b/backend/domain/user/entity/user.go index 45f454de4..61359abf5 100644 --- a/backend/domain/user/entity/user.go +++ b/backend/domain/user/entity/user.go @@ -32,3 +32,20 @@ type User struct { CreatedAt int64 // creation time UpdatedAt int64 // update time } + +type UserBenefit struct { + UserID int64 + UserLevel UserLevel + UsedCount int32 + TotalCount int32 + IsUnlimited bool + ResetDatetime int64 + CallQPS int32 +} + +type SaasUserData struct { + UserID string `json:"user_id"` + UserName string `json:"user_name"` + NickName string `json:"nick_name"` + AvatarURL string `json:"avatar_url"` +} diff --git a/backend/domain/user/service/user.go b/backend/domain/user/service/user.go index ae1ab2ccb..250afcf89 100644 --- a/backend/domain/user/service/user.go +++ b/backend/domain/user/service/user.go @@ -64,6 +64,7 @@ type CreateUserResponse struct { } type User interface { + SaasUserProvider // Create creates or registers a new user. Create(ctx context.Context, req *CreateUserRequest) (user *entity.User, err error) Login(ctx context.Context, email, password string) (user *entity.User, err error) @@ -78,3 +79,8 @@ type User interface { ValidateSession(ctx context.Context, sessionKey string) (session *entity.Session, exist bool, err error) GetUserSpaceList(ctx context.Context, userID int64) (spaces []*entity.Space, err error) } + +type SaasUserProvider interface { + GetSaasUserInfo(ctx context.Context) (user *entity.SaasUserData, err error) + GetUserBenefit(ctx context.Context) (benefit *entity.UserBenefit, err error) +} diff --git a/backend/domain/user/service/user_saas_impl.go b/backend/domain/user/service/user_saas_impl.go new file mode 100644 index 000000000..fd6f831e7 --- /dev/null +++ b/backend/domain/user/service/user_saas_impl.go @@ -0,0 +1,142 @@ +/* + * 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 service + +import ( + "context" + "encoding/json" + + "github.com/coze-dev/coze-studio/backend/domain/user/entity" + "github.com/coze-dev/coze-studio/backend/pkg/errorx" + "github.com/coze-dev/coze-studio/backend/pkg/lang/ptr" + "github.com/coze-dev/coze-studio/backend/pkg/logs" + "github.com/coze-dev/coze-studio/backend/pkg/saasapi" + "github.com/coze-dev/coze-studio/backend/types/errno" +) + +// CozeUserService provides user-related API operations +type CozeUserService struct { + client *saasapi.CozeAPIClient +} + +// NewCozeUserService creates a new user service +func NewCozeUserService() *CozeUserService { + return &CozeUserService{ + client: saasapi.NewCozeAPIClient(), + } +} + +// GetUserInfo calls the /v1/users/me endpoint +func (s *CozeUserService) GetUserInfo(ctx context.Context) (*entity.SaasUserData, error) { + resp, err := s.client.Get(ctx, "/v1/users/me") + if err != nil { + logs.CtxErrorf(ctx, "failed to call GetUserInfo API: %v", err) + return nil, errorx.New(errno.ErrUserResourceNotFound, errorx.KV("reason", "API call failed")) + } + + // Parse the data field + var userData entity.SaasUserData + + if err := json.Unmarshal(resp.Data, &userData); err != nil { + logs.CtxErrorf(ctx, "failed to parse user data: %v", err) + return nil, errorx.New(errno.ErrUserResourceNotFound, errorx.KV("reason", "data parse failed")) + } + + // Map to entity.SaasUserData + return &entity.SaasUserData{ + UserID: userData.UserID, + UserName: userData.UserName, + NickName: userData.NickName, + AvatarURL: userData.AvatarURL, + }, nil +} + +func (s *CozeUserService) GetEnterpriseBenefit(ctx context.Context, req *entity.GetEnterpriseBenefitRequest) (*entity.UserBenefit, error) { + + queryParams := make(map[string]interface{}) + if req.BenefitType != nil { + queryParams["benefit_type_list"] = *req.BenefitType + } + if req.ResourceID != nil { + queryParams["resource_id"] = *req.ResourceID + } + + resp, err := s.client.GetWithQuery(ctx, "/v1/commerce/benefit/benefits/get", queryParams) + if err != nil { + logs.CtxErrorf(ctx, "failed to call GetEnterpriseBenefit API: %v", err) + return nil, nil + } + + var benefitData entity.BenefitData + userBenefit := &entity.UserBenefit{} + if err := json.Unmarshal(resp.Data, &benefitData); err != nil { + logs.CtxErrorf(ctx, "failed to parse benefit data: %v", err) + return nil, nil + } + + for _, userBenefitInfo := range benefitData.BenefitInfo { + + if userBenefitInfo != nil && userBenefitInfo.BenefitType == entity.BenefitTypeCallToolLimit && userBenefitInfo.Basic != nil && userBenefitInfo.Basic.ItemInfo != nil { + userBenefit.UsedCount = int32(userBenefitInfo.Basic.ItemInfo.Used) + userBenefit.TotalCount = int32(userBenefitInfo.Basic.ItemInfo.Total) + userBenefit.IsUnlimited = func() bool { + return userBenefitInfo.Basic.ItemInfo.Strategy == entity.ResourceUsageStrategyUnlimit + }() + userBenefit.ResetDatetime = userBenefitInfo.Basic.ItemInfo.EndAt + 1 + } + if userBenefitInfo != nil && userBenefitInfo.BenefitType == entity.BenefitTypeAPIRunQPS && userBenefitInfo.Effective != nil && userBenefitInfo.Effective.ItemInfo != nil { + userBenefit.CallQPS = int32(userBenefitInfo.Effective.ItemInfo.Total) + } + } + + if benefitData.BasicInfo != nil { + userBenefit.UserLevel = benefitData.BasicInfo.UserLevel + } + + return userBenefit, nil +} + +func (s *CozeUserService) GetUserBenefit(ctx context.Context) (*entity.UserBenefit, error) { + + req := &entity.GetEnterpriseBenefitRequest{ + BenefitType: ptr.Of(string(entity.BenefitTypeCallToolLimit) + "," + string(entity.BenefitTypeAPIRunQPS)), + ResourceID: ptr.Of("plugin"), + } + benefit, err := s.GetEnterpriseBenefit(ctx, req) + if err != nil { + return nil, err + } + + return benefit, nil +} + +var cozeUserService *CozeUserService + +func getCozeUserService() *CozeUserService { + if cozeUserService == nil { + cozeUserService = NewCozeUserService() + } + return cozeUserService +} + +func (u *userImpl) GetSaasUserInfo(ctx context.Context) (*entity.SaasUserData, error) { + return getCozeUserService().GetUserInfo(ctx) +} + +func (u *userImpl) GetUserBenefit(ctx context.Context) (*entity.UserBenefit, error) { + return getCozeUserService().GetUserBenefit(ctx) +} diff --git a/backend/domain/workflow/entity/vo/canvas.go b/backend/domain/workflow/entity/vo/canvas.go index e9373e2db..6f49a7c8e 100644 --- a/backend/domain/workflow/entity/vo/canvas.go +++ b/backend/domain/workflow/entity/vo/canvas.go @@ -19,6 +19,7 @@ package vo import ( "fmt" + "github.com/coze-dev/coze-studio/backend/api/model/app/bot_common" model "github.com/coze-dev/coze-studio/backend/api/model/crossdomain/modelmgr" "github.com/coze-dev/coze-studio/backend/api/model/workflow" "github.com/coze-dev/coze-studio/backend/pkg/i18n" @@ -252,7 +253,9 @@ type FCParam struct { ApiName string `json:"api_name"` PluginVersion string `json:"plugin_version"` IsDraft bool `json:"is_draft"` - FCSetting *struct { + + PluginFrom *bot_common.PluginFrom `json:"plugin_from"` + FCSetting *struct { RequestParameters []*workflow.APIParameter `json:"request_params"` ResponseParameters []*workflow.APIParameter `json:"response_params"` } `json:"fc_setting,omitempty"` @@ -303,7 +306,8 @@ type VariableAggregator struct { } type PluginAPIParam struct { - APIParams []*Param `json:"apiParam"` + APIParams []*Param `json:"apiParam"` + PluginFrom *bot_common.PluginFrom `json:"pluginFrom"` } type CodeRunner struct { diff --git a/backend/domain/workflow/entity/vo/workflow_copy.go b/backend/domain/workflow/entity/vo/workflow_copy.go index c56e73d88..70182a063 100644 --- a/backend/domain/workflow/entity/vo/workflow_copy.go +++ b/backend/domain/workflow/entity/vo/workflow_copy.go @@ -16,9 +16,12 @@ package vo +import "github.com/coze-dev/coze-studio/backend/api/model/app/bot_common" + type PluginEntity struct { PluginID int64 PluginVersion *string // nil or "0" means draft, "" means latest/online version, otherwise is specific version + PluginFrom *bot_common.PluginFrom } type ExternalResourceRelated struct { diff --git a/backend/domain/workflow/internal/compose/designate_option.go b/backend/domain/workflow/internal/compose/designate_option.go index aa9ca5087..d97d59fd6 100644 --- a/backend/domain/workflow/internal/compose/designate_option.go +++ b/backend/domain/workflow/internal/compose/designate_option.go @@ -300,6 +300,7 @@ func llmToolCallbackOptions(ctx context.Context, ns *schema2.NodeSchema, eventCh PluginEntity: vo.PluginEntity{ PluginID: pluginID, PluginVersion: ptr.Of(p.PluginVersion), + PluginFrom: p.PluginFrom, }, ToolIDs: []int64{toolID}, }) diff --git a/backend/domain/workflow/internal/nodes/llm/llm.go b/backend/domain/workflow/internal/nodes/llm/llm.go index ce143f573..57bf4fbc8 100644 --- a/backend/domain/workflow/internal/nodes/llm/llm.go +++ b/backend/domain/workflow/internal/nodes/llm/llm.go @@ -491,6 +491,7 @@ func (c *Config) Build(ctx context.Context, ns *schema2.NodeSchema, _ ...schema2 PluginEntity: vo.PluginEntity{ PluginID: pid, PluginVersion: ptr.Of(p.PluginVersion), + PluginFrom: p.PluginFrom, }, ToolsInvokableInfo: map[int64]*wrapPlugin.ToolsInvokableInfo{ toolID: { diff --git a/backend/domain/workflow/internal/nodes/plugin/exec.go b/backend/domain/workflow/internal/nodes/plugin/exec.go index 837868e3b..09d5875d6 100644 --- a/backend/domain/workflow/internal/nodes/plugin/exec.go +++ b/backend/domain/workflow/internal/nodes/plugin/exec.go @@ -56,6 +56,7 @@ func ExecutePlugin(ctx context.Context, input map[string]any, pe *vo.PluginEntit ExecScene: consts.ExecSceneOfWorkflow, ArgumentsInJson: args, ExecDraftTool: pe.PluginVersion == nil || *pe.PluginVersion == "0", + PluginFrom: pe.PluginFrom, } execOpts := []model.ExecuteToolOpt{ model.WithInvalidRespProcessStrategy(consts.InvalidResponseProcessStrategyOfReturnDefault), diff --git a/backend/domain/workflow/internal/nodes/plugin/plugin.go b/backend/domain/workflow/internal/nodes/plugin/plugin.go index cfa5025ac..2acba0989 100644 --- a/backend/domain/workflow/internal/nodes/plugin/plugin.go +++ b/backend/domain/workflow/internal/nodes/plugin/plugin.go @@ -23,6 +23,7 @@ import ( "github.com/cloudwego/eino/compose" + "github.com/coze-dev/coze-studio/backend/api/model/app/bot_common" workflowModel "github.com/coze-dev/coze-studio/backend/api/model/crossdomain/workflow" "github.com/coze-dev/coze-studio/backend/domain/workflow/entity" "github.com/coze-dev/coze-studio/backend/domain/workflow/entity/vo" @@ -40,6 +41,7 @@ type Config struct { PluginID int64 ToolID int64 PluginVersion string + PluginFrom *bot_common.PluginFrom } func (c *Config) Adapt(ctx context.Context, n *vo.Node, opts ...nodes.AdaptOption) (*schema.NodeSchema, error) { @@ -63,6 +65,7 @@ func (c *Config) Adapt(ctx context.Context, n *vo.Node, opts ...nodes.AdaptOptio pID, err := strconv.ParseInt(ps.Input.Value.Content.(string), 10, 64) c.PluginID = pID + c.PluginFrom = inputs.PluginFrom ps, ok = apiParams["apiID"] if !ok { @@ -100,6 +103,7 @@ func (c *Config) Build(_ context.Context, _ *schema.NodeSchema, _ ...schema.Buil pluginID: c.PluginID, toolID: c.ToolID, pluginVersion: c.PluginVersion, + pluginFrom: c.PluginFrom, }, nil } @@ -107,6 +111,7 @@ type Plugin struct { pluginID int64 toolID int64 pluginVersion string + pluginFrom *bot_common.PluginFrom } func (p *Plugin) Invoke(ctx context.Context, parameters map[string]any) (ret map[string]any, err error) { @@ -117,6 +122,7 @@ func (p *Plugin) Invoke(ctx context.Context, parameters map[string]any) (ret map result, err := ExecutePlugin(ctx, parameters, &vo.PluginEntity{ PluginID: p.pluginID, PluginVersion: ptr.Of(p.pluginVersion), + PluginFrom: p.pluginFrom, }, p.toolID, exeCfg) if err != nil { if extra, ok := compose.IsInterruptRerunError(err); ok { diff --git a/backend/domain/workflow/plugin/plugin.go b/backend/domain/workflow/plugin/plugin.go index 7a99e2079..b9f6ca949 100644 --- a/backend/domain/workflow/plugin/plugin.go +++ b/backend/domain/workflow/plugin/plugin.go @@ -25,6 +25,7 @@ import ( "github.com/getkin/kin-openapi/openapi3" "golang.org/x/exp/maps" + "github.com/coze-dev/coze-studio/backend/api/model/app/bot_common" 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" @@ -55,6 +56,23 @@ type pluginInfo struct { LatestVersion *string } +func getSaasPluginWithTools(ctx context.Context, pluginEntity *vo.PluginEntity, toolIDs []int64) (*pluginInfo, []*entity.ToolInfo, error) { + tools, plugin, err := crossplugin.DefaultSVC().BatchGetSaasPluginToolsInfo(ctx, []int64{pluginEntity.PluginID}) + if err != nil { + return nil, nil, err + } + if len(tools) == 0 { + return nil, nil, vo.NewError(errno.ErrPluginIDNotFound, errorx.KV("id", strconv.FormatInt(pluginEntity.PluginID, 10))) + } + toolsInfo := make([]*entity.ToolInfo, 0, len(toolIDs)) + for _, t := range tools[pluginEntity.PluginID] { + if slices.Contains(toolIDs, t.ID) { + toolsInfo = append(toolsInfo, t) + } + } + return &pluginInfo{PluginInfo: plugin[pluginEntity.PluginID]}, toolsInfo, nil +} + func getPluginsWithTools(ctx context.Context, pluginEntity *vo.PluginEntity, toolIDs []int64, isDraft bool) ( _ *pluginInfo, toolsInfo []*entity.ToolInfo, err error) { defer func() { @@ -66,6 +84,11 @@ func getPluginsWithTools(ctx context.Context, pluginEntity *vo.PluginEntity, too var pluginsInfo []*model.PluginInfo var latestPluginInfo *model.PluginInfo pluginID := pluginEntity.PluginID + + if ptr.From(pluginEntity.PluginFrom) == bot_common.PluginFrom_FromSaas { + return getSaasPluginWithTools(ctx, pluginEntity, toolIDs) + } + if isDraft { plugins, err := crossplugin.DefaultSVC().MGetDraftPlugins(ctx, []int64{pluginID}) if err != nil { @@ -152,19 +175,33 @@ func GetPluginToolsInfo(ctx context.Context, req *ToolsInfoRequest) (_ *ToolsInf }() var toolsInfo []*entity.ToolInfo - isDraft := req.IsDraft || (req.PluginEntity.PluginVersion != nil && *req.PluginEntity.PluginVersion == "0") - pInfo, toolsInfo, err := getPluginsWithTools(ctx, &vo.PluginEntity{PluginID: req.PluginEntity.PluginID, PluginVersion: req.PluginEntity.PluginVersion}, req.ToolIDs, isDraft) - if err != nil { - return nil, err - } + var pInfo *pluginInfo + var url string + if ptr.From(req.PluginEntity.PluginFrom) == bot_common.PluginFrom_FromSaas { + pInfo, toolsInfo, err = getSaasPluginWithTools(ctx, &vo.PluginEntity{PluginID: req.PluginEntity.PluginID, PluginVersion: req.PluginEntity.PluginVersion}, req.ToolIDs) + if err != nil { + return nil, err + } - if oss == nil { - return nil, vo.NewError(errno.ErrTOSError, errorx.KV("msg", "oss is nil")) - } + if pInfo.IconURL != nil { + url = *pInfo.IconURL + } - url, err := oss.GetObjectUrl(ctx, pInfo.GetIconURI()) - if err != nil { - return nil, vo.WrapIfNeeded(errno.ErrTOSError, err) + } else { + isDraft := req.IsDraft || (req.PluginEntity.PluginVersion != nil && *req.PluginEntity.PluginVersion == "0") + pInfo, toolsInfo, err = getPluginsWithTools(ctx, &vo.PluginEntity{PluginID: req.PluginEntity.PluginID, PluginVersion: req.PluginEntity.PluginVersion}, req.ToolIDs, isDraft) + if err != nil { + return nil, err + } + + if oss == nil { + return nil, vo.NewError(errno.ErrTOSError, errorx.KV("msg", "oss is nil")) + } + + url, err = oss.GetObjectUrl(ctx, pInfo.GetIconURI()) + if err != nil { + return nil, vo.WrapIfNeeded(errno.ErrTOSError, err) + } } response := &ToolsInfoResponse{ @@ -230,6 +267,7 @@ func GetPluginInvokableTools(ctx context.Context, req *ToolsInvokableRequest) ( pInfo, toolsInfo, err := getPluginsWithTools(ctx, &vo.PluginEntity{ PluginID: req.PluginEntity.PluginID, PluginVersion: req.PluginEntity.PluginVersion, + PluginFrom: req.PluginEntity.PluginFrom, }, maps.Keys(req.ToolsInvokableInfo), isDraft) if err != nil { return nil, err @@ -241,6 +279,7 @@ func GetPluginInvokableTools(ctx context.Context, req *ToolsInvokableRequest) ( pluginEntity: vo.PluginEntity{ PluginID: pInfo.ID, PluginVersion: pInfo.Version, + PluginFrom: pInfo.Source, }, toolInfo: tf, IsDraft: isDraft, @@ -304,6 +343,7 @@ func (p *pluginInvokeTool) PluginInvoke(ctx context.Context, argumentsInJSON str ExecScene: consts.ExecSceneOfWorkflow, ArgumentsInJson: argumentsInJSON, ExecDraftTool: p.IsDraft, + PluginFrom: p.pluginEntity.PluginFrom, } execOpts := []model.ExecuteToolOpt{ model.WithInvalidRespProcessStrategy(consts.InvalidResponseProcessStrategyOfReturnDefault), diff --git a/backend/go.mod b/backend/go.mod index 1388b2bd3..16b34ccd3 100755 --- a/backend/go.mod +++ b/backend/go.mod @@ -50,7 +50,7 @@ require ( github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 github.com/nikolalohinski/gonja v1.5.3 // indirect github.com/nsqio/go-nsq v1.1.0 - github.com/ollama/ollama v0.9.6 + github.com/ollama/ollama v0.9.6 // indirect github.com/onsi/gomega v1.35.1 github.com/pingcap/tidb/pkg/parser v0.0.0-20250417044355-c5882b1f6c58 github.com/pkg/errors v0.9.1 @@ -282,7 +282,10 @@ require ( stathat.com/c/consistent v1.0.0 // indirect ) -require github.com/apache/pulsar-client-go v0.16.0 +require ( + github.com/apache/pulsar-client-go v0.16.0 + github.com/eino-contrib/ollama v0.1.0 +) require ( github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect @@ -296,7 +299,6 @@ require ( github.com/danieljoos/wincred v1.1.2 // indirect github.com/dvsekhvalnov/jose2go v1.6.0 // indirect github.com/eino-contrib/jsonschema v1.0.0 // indirect - github.com/eino-contrib/ollama v0.1.0 // indirect github.com/felixge/httpsnoop v1.0.4 // indirect github.com/fxamacker/cbor/v2 v2.7.0 // indirect github.com/go-jose/go-jose/v4 v4.0.5 // indirect diff --git a/backend/go.sum b/backend/go.sum index 52ffab10b..c13a936f6 100644 --- a/backend/go.sum +++ b/backend/go.sum @@ -232,8 +232,6 @@ github.com/cloudwego/eino-ext/components/model/deepseek v0.0.0-20250715055739-0d github.com/cloudwego/eino-ext/components/model/deepseek v0.0.0-20250715055739-0d0e28441a2f/go.mod h1:3XV+kHvG6IrVj4WXlquihx8i7a8fUKa09PzuS7IvF2k= github.com/cloudwego/eino-ext/components/model/gemini v0.1.2 h1:bt9xftOQhP0Nuh1Po6ZNljSzBvv11Aw6hFLR7V1sLd8= 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/ollama v0.1.3 h1:XTKGB68ks6UwfYkEVGjsrgRJyd3BQIebNDPbnIbxjxI= github.com/cloudwego/eino-ext/components/model/ollama v0.1.3/go.mod h1:FW/VPCspDVRxv5BSUEGFaOBGVdHcsxqnqD2IqMXcWv0= github.com/cloudwego/eino-ext/components/model/openai v0.1.1 h1:VRdUDcnfi/T8F0jcuovhdADU9Io/oMqiKpY2ZJTBc1o= diff --git a/backend/internal/mock/domain/plugin/interface.go b/backend/internal/mock/domain/plugin/interface.go index ca257666c..1680e722e 100644 --- a/backend/internal/mock/domain/plugin/interface.go +++ b/backend/internal/mock/domain/plugin/interface.go @@ -1,3 +1,19 @@ +/* + * Copyright 2025 coze-dev Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + // Code generated by MockGen. DO NOT EDIT. // Source: service.go // @@ -13,8 +29,8 @@ import ( context "context" reflect "reflect" - "github.com/coze-dev/coze-studio/backend/crossdomain/contract/plugin/model" - dto0 "github.com/coze-dev/coze-studio/backend/domain/plugin/dto" + model "github.com/coze-dev/coze-studio/backend/crossdomain/contract/plugin/model" + dto "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" ) @@ -43,18 +59,34 @@ func (m *MockPluginService) EXPECT() *MockPluginServiceMockRecorder { return m.recorder } -// BindAgentTools mocks base method. -func (m *MockPluginService) BindAgentTools(ctx context.Context, agentID int64, toolIDs []int64) error { +// BatchGetSaasPluginToolsInfo mocks base method. +func (m *MockPluginService) BatchGetSaasPluginToolsInfo(ctx context.Context, pluginIDs []int64) (map[int64][]*entity.ToolInfo, map[int64]*entity.PluginInfo, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "BindAgentTools", ctx, agentID, toolIDs) + ret := m.ctrl.Call(m, "BatchGetSaasPluginToolsInfo", ctx, pluginIDs) + ret0, _ := ret[0].(map[int64][]*entity.ToolInfo) + ret1, _ := ret[1].(map[int64]*entity.PluginInfo) + ret2, _ := ret[2].(error) + return ret0, ret1, ret2 +} + +// BatchGetSaasPluginToolsInfo indicates an expected call of BatchGetSaasPluginToolsInfo. +func (mr *MockPluginServiceMockRecorder) BatchGetSaasPluginToolsInfo(ctx, pluginIDs any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "BatchGetSaasPluginToolsInfo", reflect.TypeOf((*MockPluginService)(nil).BatchGetSaasPluginToolsInfo), ctx, pluginIDs) +} + +// BindAgentTools mocks base method. +func (m *MockPluginService) BindAgentTools(ctx context.Context, agentID int64, bindTools []*model.BindToolInfo) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "BindAgentTools", ctx, agentID, bindTools) ret0, _ := ret[0].(error) return ret0 } // BindAgentTools indicates an expected call of BindAgentTools. -func (mr *MockPluginServiceMockRecorder) BindAgentTools(ctx, agentID, toolIDs any) *gomock.Call { +func (mr *MockPluginServiceMockRecorder) BindAgentTools(ctx, agentID, bindTools any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "BindAgentTools", reflect.TypeOf((*MockPluginService)(nil).BindAgentTools), ctx, agentID, toolIDs) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "BindAgentTools", reflect.TypeOf((*MockPluginService)(nil).BindAgentTools), ctx, agentID, bindTools) } // CheckPluginToolsDebugStatus mocks base method. @@ -72,10 +104,10 @@ func (mr *MockPluginServiceMockRecorder) CheckPluginToolsDebugStatus(ctx, plugin } // ConvertToOpenapi3Doc mocks base method. -func (m *MockPluginService) ConvertToOpenapi3Doc(ctx context.Context, req *dto0.ConvertToOpenapi3DocRequest) *dto0.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].(*dto0.ConvertToOpenapi3DocResponse) + ret0, _ := ret[0].(*dto.ConvertToOpenapi3DocResponse) return ret0 } @@ -86,10 +118,10 @@ func (mr *MockPluginServiceMockRecorder) ConvertToOpenapi3Doc(ctx, req any) *gom } // CopyPlugin mocks base method. -func (m *MockPluginService) CopyPlugin(ctx context.Context, req *dto0.CopyPluginRequest) (*dto0.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].(*dto0.CopyPluginResponse) + ret0, _ := ret[0].(*dto.CopyPluginResponse) ret1, _ := ret[1].(error) return ret0, ret1 } @@ -101,7 +133,7 @@ func (mr *MockPluginServiceMockRecorder) CopyPlugin(ctx, req any) *gomock.Call { } // CreateDraftPlugin mocks base method. -func (m *MockPluginService) CreateDraftPlugin(ctx context.Context, req *dto0.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) @@ -116,10 +148,10 @@ func (mr *MockPluginServiceMockRecorder) CreateDraftPlugin(ctx, req any) *gomock } // CreateDraftPluginWithCode mocks base method. -func (m *MockPluginService) CreateDraftPluginWithCode(ctx context.Context, req *dto0.CreateDraftPluginWithCodeRequest) (*dto0.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].(*dto0.CreateDraftPluginWithCodeResponse) + ret0, _ := ret[0].(*dto.CreateDraftPluginWithCodeResponse) ret1, _ := ret[1].(error) return ret0, ret1 } @@ -131,10 +163,10 @@ func (mr *MockPluginServiceMockRecorder) CreateDraftPluginWithCode(ctx, req any) } // CreateDraftToolsWithCode mocks base method. -func (m *MockPluginService) CreateDraftToolsWithCode(ctx context.Context, req *dto0.CreateDraftToolsWithCodeRequest) (*dto0.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].(*dto0.CreateDraftToolsWithCodeResponse) + ret0, _ := ret[0].(*dto.CreateDraftToolsWithCodeResponse) ret1, _ := ret[1].(error) return ret0, ret1 } @@ -224,7 +256,7 @@ func (mr *MockPluginServiceMockRecorder) GetAPPAllPlugins(ctx, appID any) *gomoc } // GetAccessToken mocks base method. -func (m *MockPluginService) GetAccessToken(ctx context.Context, oa *dto0.OAuthInfo) (string, error) { +func (m *MockPluginService) GetAccessToken(ctx context.Context, oa *dto.OAuthInfo) (string, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetAccessToken", ctx, oa) ret0, _ := ret[0].(string) @@ -239,10 +271,10 @@ func (mr *MockPluginServiceMockRecorder) GetAccessToken(ctx, oa any) *gomock.Cal } // GetAgentPluginsOAuthStatus mocks base method. -func (m *MockPluginService) GetAgentPluginsOAuthStatus(ctx context.Context, userID, agentID int64) ([]*dto0.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].([]*dto0.AgentPluginOAuthStatus) + ret0, _ := ret[0].([]*dto.AgentPluginOAuthStatus) ret1, _ := ret[1].(error) return ret0, ret1 } @@ -254,18 +286,18 @@ func (mr *MockPluginServiceMockRecorder) GetAgentPluginsOAuthStatus(ctx, userID, } // GetDraftAgentToolByName mocks base method. -func (m *MockPluginService) GetDraftAgentToolByName(ctx context.Context, agentID int64, toolName string) (*entity.ToolInfo, error) { +func (m *MockPluginService) GetDraftAgentToolByName(ctx context.Context, agentID, pluginID int64, toolName string) (*entity.ToolInfo, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetDraftAgentToolByName", ctx, agentID, toolName) + ret := m.ctrl.Call(m, "GetDraftAgentToolByName", ctx, agentID, pluginID, toolName) ret0, _ := ret[0].(*entity.ToolInfo) ret1, _ := ret[1].(error) return ret0, ret1 } // GetDraftAgentToolByName indicates an expected call of GetDraftAgentToolByName. -func (mr *MockPluginServiceMockRecorder) GetDraftAgentToolByName(ctx, agentID, toolName any) *gomock.Call { +func (mr *MockPluginServiceMockRecorder) GetDraftAgentToolByName(ctx, agentID, pluginID, toolName any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetDraftAgentToolByName", reflect.TypeOf((*MockPluginService)(nil).GetDraftAgentToolByName), ctx, agentID, toolName) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetDraftAgentToolByName", reflect.TypeOf((*MockPluginService)(nil).GetDraftAgentToolByName), ctx, agentID, pluginID, toolName) } // GetDraftPlugin mocks base method. @@ -284,10 +316,10 @@ func (mr *MockPluginServiceMockRecorder) GetDraftPlugin(ctx, pluginID any) *gomo } // GetOAuthStatus mocks base method. -func (m *MockPluginService) GetOAuthStatus(ctx context.Context, userID, pluginID int64) (*dto0.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].(*dto0.GetOAuthStatusResponse) + ret0, _ := ret[0].(*dto.GetOAuthStatusResponse) ret1, _ := ret[1].(error) return ret0, ret1 } @@ -358,8 +390,23 @@ func (mr *MockPluginServiceMockRecorder) GetPluginProductAllTools(ctx, pluginID return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetPluginProductAllTools", reflect.TypeOf((*MockPluginService)(nil).GetPluginProductAllTools), ctx, pluginID) } +// GetSaasPluginInfo mocks base method. +func (m *MockPluginService) GetSaasPluginInfo(ctx context.Context, pluginIDs []int64) ([]*entity.PluginInfo, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetSaasPluginInfo", ctx, pluginIDs) + ret0, _ := ret[0].([]*entity.PluginInfo) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetSaasPluginInfo indicates an expected call of GetSaasPluginInfo. +func (mr *MockPluginServiceMockRecorder) GetSaasPluginInfo(ctx, pluginIDs any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetSaasPluginInfo", reflect.TypeOf((*MockPluginService)(nil).GetSaasPluginInfo), ctx, pluginIDs) +} + // ListCustomOnlinePlugins mocks base method. -func (m *MockPluginService) ListCustomOnlinePlugins(ctx context.Context, spaceID int64, pageInfo dto0.PageInfo) ([]*entity.PluginInfo, int64, error) { +func (m *MockPluginService) ListCustomOnlinePlugins(ctx context.Context, spaceID int64, pageInfo dto.PageInfo) ([]*entity.PluginInfo, int64, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "ListCustomOnlinePlugins", ctx, spaceID, pageInfo) ret0, _ := ret[0].([]*entity.PluginInfo) @@ -375,10 +422,10 @@ func (mr *MockPluginServiceMockRecorder) ListCustomOnlinePlugins(ctx, spaceID, p } // ListDraftPlugins mocks base method. -func (m *MockPluginService) ListDraftPlugins(ctx context.Context, req *dto0.ListDraftPluginsRequest) (*dto0.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].(*dto0.ListDraftPluginsResponse) + ret0, _ := ret[0].(*dto.ListDraftPluginsResponse) ret1, _ := ret[1].(error) return ret0, ret1 } @@ -390,10 +437,10 @@ func (mr *MockPluginServiceMockRecorder) ListDraftPlugins(ctx, req any) *gomock. } // ListPluginProducts mocks base method. -func (m *MockPluginService) ListPluginProducts(ctx context.Context, req *dto0.ListPluginProductsRequest) (*dto0.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].(*dto0.ListPluginProductsResponse) + ret0, _ := ret[0].(*dto.ListPluginProductsResponse) ret1, _ := ret[1].(error) return ret0, ret1 } @@ -404,6 +451,36 @@ func (mr *MockPluginServiceMockRecorder) ListPluginProducts(ctx, req any) *gomoc return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListPluginProducts", reflect.TypeOf((*MockPluginService)(nil).ListPluginProducts), ctx, req) } +// ListSaasPluginCategories mocks base method. +func (m *MockPluginService) ListSaasPluginCategories(ctx context.Context, req *dto.ListPluginCategoriesRequest) (*dto.ListPluginCategoriesResponse, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "ListSaasPluginCategories", ctx, req) + ret0, _ := ret[0].(*dto.ListPluginCategoriesResponse) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// ListSaasPluginCategories indicates an expected call of ListSaasPluginCategories. +func (mr *MockPluginServiceMockRecorder) ListSaasPluginCategories(ctx, req any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListSaasPluginCategories", reflect.TypeOf((*MockPluginService)(nil).ListSaasPluginCategories), ctx, req) +} + +// ListSaasPluginProducts mocks base method. +func (m *MockPluginService) ListSaasPluginProducts(ctx context.Context, req *dto.ListSaasPluginProductsRequest) (*dto.ListPluginProductsResponse, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "ListSaasPluginProducts", ctx, req) + ret0, _ := ret[0].(*dto.ListPluginProductsResponse) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// ListSaasPluginProducts indicates an expected call of ListSaasPluginProducts. +func (mr *MockPluginServiceMockRecorder) ListSaasPluginProducts(ctx, req any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListSaasPluginProducts", reflect.TypeOf((*MockPluginService)(nil).ListSaasPluginProducts), ctx, req) +} + // MGetAgentTools mocks base method. func (m *MockPluginService) MGetAgentTools(ctx context.Context, req *model.MGetAgentToolsRequest) ([]*entity.ToolInfo, error) { m.ctrl.T.Helper() @@ -540,7 +617,7 @@ func (mr *MockPluginServiceMockRecorder) MoveAPPPluginToLibrary(ctx, pluginID an } // OAuthCode mocks base method. -func (m *MockPluginService) OAuthCode(ctx context.Context, code string, state *dto0.OAuthState) error { +func (m *MockPluginService) OAuthCode(ctx context.Context, code string, state *dto.OAuthState) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "OAuthCode", ctx, code, state) ret0, _ := ret[0].(error) @@ -597,7 +674,7 @@ func (mr *MockPluginServiceMockRecorder) PublishPlugin(ctx, req any) *gomock.Cal } // RevokeAccessToken mocks base method. -func (m *MockPluginService) RevokeAccessToken(ctx context.Context, meta *dto0.AuthorizationCodeMeta) error { +func (m *MockPluginService) RevokeAccessToken(ctx context.Context, meta *dto.AuthorizationCodeMeta) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "RevokeAccessToken", ctx, meta) ret0, _ := ret[0].(error) @@ -611,7 +688,7 @@ func (mr *MockPluginServiceMockRecorder) RevokeAccessToken(ctx, meta any) *gomoc } // UpdateBotDefaultParams mocks base method. -func (m *MockPluginService) UpdateBotDefaultParams(ctx context.Context, req *dto0.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) @@ -625,7 +702,7 @@ func (mr *MockPluginServiceMockRecorder) UpdateBotDefaultParams(ctx, req any) *g } // UpdateDraftPlugin mocks base method. -func (m *MockPluginService) UpdateDraftPlugin(ctx context.Context, plugin *dto0.UpdateDraftPluginRequest) error { +func (m *MockPluginService) UpdateDraftPlugin(ctx context.Context, plugin *dto.UpdateDraftPluginRequest) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "UpdateDraftPlugin", ctx, plugin) ret0, _ := ret[0].(error) @@ -639,7 +716,7 @@ func (mr *MockPluginServiceMockRecorder) UpdateDraftPlugin(ctx, plugin any) *gom } // UpdateDraftPluginWithCode mocks base method. -func (m *MockPluginService) UpdateDraftPluginWithCode(ctx context.Context, req *dto0.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) @@ -653,7 +730,7 @@ func (mr *MockPluginServiceMockRecorder) UpdateDraftPluginWithCode(ctx, req any) } // UpdateDraftTool mocks base method. -func (m *MockPluginService) UpdateDraftTool(ctx context.Context, req *dto0.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) diff --git a/backend/pkg/lang/slices/iter.go b/backend/pkg/lang/slices/iter.go index 7452e229b..ad27a6856 100644 --- a/backend/pkg/lang/slices/iter.go +++ b/backend/pkg/lang/slices/iter.go @@ -29,6 +29,17 @@ func Transform[A, B any](src []A, fn func(A) B) []B { return dst } +func Contains[T comparable](src []T, item T) bool { + if src == nil { + return false + } + for _, s := range src { + if s == item { + return true + } + } + return false +} func TransformWithErrorCheck[A, B any](src []A, fn func(A) (B, error)) ([]B, error) { if src == nil { return nil, nil diff --git a/backend/pkg/saasapi/client.go b/backend/pkg/saasapi/client.go new file mode 100644 index 000000000..b60d45d4d --- /dev/null +++ b/backend/pkg/saasapi/client.go @@ -0,0 +1,278 @@ +/* + * 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 saasapi + +import ( + "bytes" + "context" + "encoding/json" + "fmt" + "io" + "net/http" + "net/url" + "os" + "strconv" + "time" + + "github.com/coze-dev/coze-studio/backend/pkg/logs" + "github.com/coze-dev/coze-studio/backend/types/consts" +) + +// CozeAPIClient represents a client for coze.cn OpenAPI +type CozeAPIClient struct { + BaseURL string + APIKey string + HTTPClient *http.Client + MaxRetries int +} + +// CozeAPIResponse represents the standard response format from coze.cn API +type CozeAPIResponse struct { + Code int `json:"code"` + Msg string `json:"msg"` + Data json.RawMessage `json:"data"` +} + +// NewCozeAPIClient creates a new coze.cn API client +func NewCozeAPIClient() *CozeAPIClient { + return &CozeAPIClient{ + BaseURL: getSaasOpenAPIUrl(), + APIKey: getSaasOpenAPIKey(), + HTTPClient: &http.Client{ + Timeout: 30 * time.Second, + }, + MaxRetries: 1, + } +} + +// Get performs a GET request to the coze.cn API +func (c *CozeAPIClient) Get(ctx context.Context, path string) (*CozeAPIResponse, error) { + return c.request(ctx, "GET", path, nil) +} + +// GetWithQuery performs a GET request to the coze.cn API with query parameters +func (c *CozeAPIClient) GetWithQuery(ctx context.Context, path string, queryParams map[string]interface{}) (*CozeAPIResponse, error) { + return c.requestWithQuery(ctx, "GET", path, nil, queryParams) +} + +// Post performs a POST request to the coze.cn API +func (c *CozeAPIClient) Post(ctx context.Context, path string, body interface{}) (*CozeAPIResponse, error) { + var bodyBytes []byte + var err error + + if body != nil { + bodyBytes, err = json.Marshal(body) + if err != nil { + return nil, fmt.Errorf("failed to marshal request body: %w", err) + } + } + + return c.request(ctx, "POST", path, bodyBytes) +} + +// request is the core method for making HTTP requests to coze.cn API +func (c *CozeAPIClient) request(ctx context.Context, method, path string, body []byte) (*CozeAPIResponse, error) { + url := fmt.Sprintf("%s%s", c.BaseURL, path) + + var req *http.Request + var err error + + if body != nil { + req, err = http.NewRequestWithContext(ctx, method, url, bytes.NewReader(body)) + } else { + req, err = http.NewRequestWithContext(ctx, method, url, nil) + } + + if err != nil { + return nil, fmt.Errorf("failed to create request: %w", err) + } + + // Set headers + req.Header.Set("Content-Type", "application/json") + req.Header.Set("Accept", "application/json") + + // Add API key if available + if c.APIKey != "" { + req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", c.APIKey)) + } + + // Make request with retries + var resp *http.Response + for i := 0; i <= c.MaxRetries; i++ { + resp, err = c.HTTPClient.Do(req) + if err == nil { + break + } + + if i < c.MaxRetries { + logs.CtxWarnf(ctx, "coze API request failed, retrying (%d/%d): %v", i+1, c.MaxRetries, err) + time.Sleep(time.Duration(i+1) * time.Second) + } + } + + if err != nil { + return nil, fmt.Errorf("request failed after %d retries: %w", c.MaxRetries, err) + } + defer resp.Body.Close() + + // Read response body + respBody, err := io.ReadAll(resp.Body) + if err != nil { + return nil, fmt.Errorf("failed to read response body: %w", err) + } + + // Check HTTP status code + if resp.StatusCode < 200 || resp.StatusCode >= 300 { + return nil, fmt.Errorf("API request failed with status %d: %s", resp.StatusCode, string(respBody)) + } + + // Parse response + var apiResp CozeAPIResponse + if err := json.Unmarshal(respBody, &apiResp); err != nil { + return nil, fmt.Errorf("failed to parse API response: %w", err) + } + + // Check API response code + if apiResp.Code != 0 { + return nil, fmt.Errorf("API returned error: code=%d, msg=%s", apiResp.Code, apiResp.Msg) + } + + return &apiResp, nil +} + +// requestWithQuery is the core method for making HTTP requests to coze.cn API with query parameters +func (c *CozeAPIClient) requestWithQuery(ctx context.Context, method, path string, body []byte, queryParams map[string]interface{}) (*CozeAPIResponse, error) { + baseURL := fmt.Sprintf("%s%s", c.BaseURL, path) + + // Build query parameters + if len(queryParams) > 0 { + u, err := url.Parse(baseURL) + if err != nil { + return nil, fmt.Errorf("failed to parse URL: %w", err) + } + + q := u.Query() + for key, value := range queryParams { + if value != nil { + switch v := value.(type) { + case string: + if v != "" { + q.Set(key, v) + } + case int: + q.Set(key, strconv.Itoa(v)) + case bool: + q.Set(key, strconv.FormatBool(v)) + case *string: + if v != nil && *v != "" { + q.Set(key, *v) + } + case *int: + if v != nil { + q.Set(key, strconv.Itoa(*v)) + } + case *bool: + if v != nil { + q.Set(key, strconv.FormatBool(*v)) + } + } + } + } + u.RawQuery = q.Encode() + baseURL = u.String() + } + + var req *http.Request + var err error + + if body != nil { + req, err = http.NewRequestWithContext(ctx, method, baseURL, bytes.NewReader(body)) + } else { + req, err = http.NewRequestWithContext(ctx, method, baseURL, nil) + } + + if err != nil { + return nil, fmt.Errorf("failed to create request: %w", err) + } + + // Set headers + req.Header.Set("Content-Type", "application/json") + req.Header.Set("Accept", "application/json") + + // Add API key if available + if c.APIKey != "" { + req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", c.APIKey)) + } + + // Make request with retries + var resp *http.Response + for i := 0; i <= c.MaxRetries; i++ { + resp, err = c.HTTPClient.Do(req) + if err == nil { + break + } + + if i < c.MaxRetries { + logs.CtxWarnf(ctx, "coze API request failed, retrying (%d/%d): %v", i+1, c.MaxRetries, err) + time.Sleep(time.Duration(i+1) * time.Second) + } + } + + if err != nil { + return nil, fmt.Errorf("request failed after %d retries: %w", c.MaxRetries, err) + } + defer resp.Body.Close() + + // Read response body + respBody, err := io.ReadAll(resp.Body) + if err != nil { + return nil, fmt.Errorf("failed to read response body: %w", err) + } + + // Check HTTP status code + if resp.StatusCode < 200 || resp.StatusCode >= 300 { + return nil, fmt.Errorf("API request failed with status %d: %s", resp.StatusCode, string(respBody)) + } + + // Parse response + var apiResp CozeAPIResponse + if err := json.Unmarshal(respBody, &apiResp); err != nil { + return nil, fmt.Errorf("failed to parse API response: %w", err) + } + + // Check API response code + if apiResp.Code != 0 { + return nil, fmt.Errorf("API returned error: code=%d, msg=%s", apiResp.Code, apiResp.Msg) + } + + return &apiResp, nil +} + +// getEnvOrDefault returns environment variable value or default if not set +func getSaasOpenAPIUrl() string { + if value := os.Getenv(consts.CozeSaasAPIBaseURL); value != "" { + return value + } + return "https://api.coze.cn" +} + +func getSaasOpenAPIKey() string { + if value := os.Getenv(consts.CozeSaasAPIKey); value != "" { + return value + } + return "" +} diff --git a/backend/types/consts/consts.go b/backend/types/consts/consts.go index 4d6f54190..8177163c6 100644 --- a/backend/types/consts/consts.go +++ b/backend/types/consts/consts.go @@ -51,6 +51,10 @@ const ( S3Endpoint = "S3_ENDPOINT" S3BucketEndpoint = "S3_BUCKET_ENDPOINT" + CozeSaasPluginEnabled = "COZE_SAAS_PLUGIN_ENABLED" + CozeSaasAPIKey = "COZE_SAAS_API_KEY" + CozeSaasAPIBaseURL = "COZE_SAAS_API_BASE_URL" + HostKeyInCtx = "HOST_KEY_IN_CTX" RequestSchemeKeyInCtx = "REQUEST_SCHEME_IN_CTX" diff --git a/backend/types/ddl/gen_orm_query.go b/backend/types/ddl/gen_orm_query.go index b16c93ae2..bc703f85f 100644 --- a/backend/types/ddl/gen_orm_query.go +++ b/backend/types/ddl/gen_orm_query.go @@ -82,6 +82,7 @@ var path2Table2Columns2Model = map[string]map[string]map[string]any{ "plugin": { "manifest": &plugin.PluginManifest{}, "openapi_doc": &plugin.Openapi3T{}, + "ext": map[string]any{}, }, "plugin_draft": { "manifest": &plugin.PluginManifest{}, @@ -90,6 +91,7 @@ var path2Table2Columns2Model = map[string]map[string]map[string]any{ "plugin_version": { "manifest": &plugin.PluginManifest{}, "openapi_doc": &plugin.Openapi3T{}, + "ext": map[string]any{}, }, "agent_tool_draft": { "operation": &plugin.Openapi3Operation{}, @@ -99,12 +101,14 @@ var path2Table2Columns2Model = map[string]map[string]map[string]any{ }, "tool": { "operation": &plugin.Openapi3Operation{}, + "ext": map[string]any{}, }, "tool_draft": { "operation": &plugin.Openapi3Operation{}, }, "tool_version": { "operation": &plugin.Openapi3Operation{}, + "ext": map[string]any{}, }, "plugin_oauth_auth": { "oauth_config": &plugin.OAuthAuthorizationCodeConfig{}, diff --git a/backend/types/errno/plugin.go b/backend/types/errno/plugin.go index ddaa05cd0..0d0664ad1 100644 --- a/backend/types/errno/plugin.go +++ b/backend/types/errno/plugin.go @@ -40,6 +40,13 @@ const ( ErrPluginOAuthFailed = 109000013 ErrPluginIDExist = 109000014 ErrToolIDExist = 109000015 + + ErrPluginCallCozeAPIFailed = 109000016 + ErrPluginParseCozeAPIResponseFailed = 109000017 + ErrPluginCallCozeSearchAPIFailed = 109000018 + ErrPluginParseCozeSearchAPIResponseFailed = 109000019 + ErrPluginCallCozeCategoriesAPIFailed = 109000020 + ErrPluginParseCozeCategoriesAPIResponseFailed = 109000021 ) const ( @@ -135,4 +142,40 @@ func init() { fmt.Sprintf("oauth failed : {%s}", PluginMsgKey), code.WithAffectStability(false), ) + + code.Register( + ErrPluginCallCozeAPIFailed, + fmt.Sprintf("failed to call coze.cn API : {%s}", PluginMsgKey), + code.WithAffectStability(false), + ) + + code.Register( + ErrPluginParseCozeAPIResponseFailed, + fmt.Sprintf("failed to parse coze.cn API response : {%s}", PluginMsgKey), + code.WithAffectStability(false), + ) + + code.Register( + ErrPluginCallCozeSearchAPIFailed, + fmt.Sprintf("failed to call coze.cn search API : {%s}", PluginMsgKey), + code.WithAffectStability(false), + ) + + code.Register( + ErrPluginParseCozeSearchAPIResponseFailed, + fmt.Sprintf("failed to parse coze.cn search API response : {%s}", PluginMsgKey), + code.WithAffectStability(false), + ) + + code.Register( + ErrPluginCallCozeCategoriesAPIFailed, + fmt.Sprintf("failed to call coze.cn categories API : {%s}", PluginMsgKey), + code.WithAffectStability(false), + ) + + code.Register( + ErrPluginParseCozeCategoriesAPIResponseFailed, + fmt.Sprintf("failed to parse coze.cn categories API response : {%s}", PluginMsgKey), + code.WithAffectStability(false), + ) } diff --git a/common/config/rush/pnpm-config.json b/common/config/rush/pnpm-config.json index cb53611b3..6d57d0c37 100644 --- a/common/config/rush/pnpm-config.json +++ b/common/config/rush/pnpm-config.json @@ -24,7 +24,7 @@ "tailwindcss@3.3.6>postcss": "8.4.49", "@types/react": "18.2.37", "@types/react-dom": "18.2.15", - "@coze-arch/coze-design": "0.0.6-alpha.101d0c", + "@coze-arch/coze-design": "0.0.7-alpha.985c0d", "typescript": "5.8.2" }, "globalPeerDependencyRules": {}, diff --git a/common/config/subspaces/default/common-versions.json b/common/config/subspaces/default/common-versions.json index 64a390c4d..e5c489644 100644 --- a/common/config/subspaces/default/common-versions.json +++ b/common/config/subspaces/default/common-versions.json @@ -2,10 +2,10 @@ "$schema": "https://developer.microsoft.com/json-schemas/rush/v5/common-versions.schema.json", "ensureConsistentVersions": true, "preferredVersions": { - "@coze-arch/coze-design": "0.0.6-alpha.eec92c" + "@coze-arch/coze-design": "0.0.7-alpha.985c0d" }, "allowedAlternativeVersions": { - "@coze-arch/coze-design": ["0.0.6-alpha.eec92c"], + "@coze-arch/coze-design": ["0.0.7-alpha.985c0d"], "@rspack/cli": ["0.6.0"], "@rspack/core": ["0.6.0", ">=0.7"], "@rspack/plugin-react-refresh": ["0.6.0"], diff --git a/common/config/subspaces/default/pnpm-config.json b/common/config/subspaces/default/pnpm-config.json index 7d2580d43..1d4360a19 100644 --- a/common/config/subspaces/default/pnpm-config.json +++ b/common/config/subspaces/default/pnpm-config.json @@ -9,7 +9,7 @@ } }, "globalOverrides": { - "@coze-arch/coze-design": "0.0.6-alpha.eec92c", + "@coze-arch/coze-design": "0.0.7-alpha.985c0d", "inversify": "6.0.2", "sass@1.74.1>immutable": "3.8.2", "web-streams-polyfill": "3.3.2", diff --git a/common/config/subspaces/default/pnpm-lock.yaml b/common/config/subspaces/default/pnpm-lock.yaml index f58063eda..9348b9465 100644 --- a/common/config/subspaces/default/pnpm-lock.yaml +++ b/common/config/subspaces/default/pnpm-lock.yaml @@ -9,7 +9,7 @@ neverBuiltDependencies: - canvas overrides: - '@coze-arch/coze-design': 0.0.6-alpha.eec92c + '@coze-arch/coze-design': 0.0.7-alpha.985c0d inversify: 6.0.2 sass@1.74.1>immutable: 3.8.2 web-streams-polyfill: 3.3.2 @@ -61,8 +61,8 @@ importers: specifier: workspace:* version: link:../../packages/arch/bot-md-box-adapter '@coze-arch/coze-design': - specifier: 0.0.6-alpha.eec92c - version: 0.0.6-alpha.eec92c(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) + specifier: 0.0.7-alpha.985c0d + version: 0.0.7-alpha.985c0d(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) '@coze-arch/foundation-sdk': specifier: workspace:* version: link:../../packages/arch/foundation-sdk @@ -1144,8 +1144,8 @@ importers: specifier: workspace:* version: link:../../arch/bot-tea '@coze-arch/coze-design': - specifier: 0.0.6-alpha.eec92c - version: 0.0.6-alpha.eec92c(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) + specifier: 0.0.7-alpha.985c0d + version: 0.0.7-alpha.985c0d(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) '@coze-arch/i18n': specifier: workspace:* version: link:../../arch/i18n @@ -1408,8 +1408,8 @@ importers: specifier: workspace:* version: link:../../arch/bot-store '@coze-arch/coze-design': - specifier: 0.0.6-alpha.eec92c - version: 0.0.6-alpha.eec92c(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) + specifier: 0.0.7-alpha.985c0d + version: 0.0.7-alpha.985c0d(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) '@coze-arch/i18n': specifier: workspace:* version: link:../../arch/i18n @@ -1508,8 +1508,8 @@ importers: specifier: workspace:* version: link:../../components/bot-semi '@coze-arch/coze-design': - specifier: 0.0.6-alpha.eec92c - version: 0.0.6-alpha.eec92c(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) + specifier: 0.0.7-alpha.985c0d + version: 0.0.7-alpha.985c0d(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) '@coze-arch/i18n': specifier: workspace:* version: link:../../arch/i18n @@ -1787,8 +1787,8 @@ importers: specifier: workspace:* version: link:../../../arch/bot-utils '@coze-arch/coze-design': - specifier: 0.0.6-alpha.eec92c - version: 0.0.6-alpha.eec92c(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) + specifier: 0.0.7-alpha.985c0d + version: 0.0.7-alpha.985c0d(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) '@coze-arch/foundation-sdk': specifier: workspace:* version: link:../../../arch/foundation-sdk @@ -2028,8 +2028,8 @@ importers: specifier: workspace:* version: link:../../../arch/bot-utils '@coze-arch/coze-design': - specifier: 0.0.6-alpha.eec92c - version: 0.0.6-alpha.eec92c(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) + specifier: 0.0.7-alpha.985c0d + version: 0.0.7-alpha.985c0d(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) '@coze-arch/foundation-sdk': specifier: workspace:* version: link:../../../arch/foundation-sdk @@ -2215,8 +2215,8 @@ importers: specifier: workspace:* version: link:../../../arch/bot-tea '@coze-arch/coze-design': - specifier: 0.0.6-alpha.eec92c - version: 0.0.6-alpha.eec92c(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) + specifier: 0.0.7-alpha.985c0d + version: 0.0.7-alpha.985c0d(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) '@coze-arch/i18n': specifier: workspace:* version: link:../../../arch/i18n @@ -2427,8 +2427,8 @@ importers: specifier: workspace:* version: link:../../../arch/bot-utils '@coze-arch/coze-design': - specifier: 0.0.6-alpha.eec92c - version: 0.0.6-alpha.eec92c(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) + specifier: 0.0.7-alpha.985c0d + version: 0.0.7-alpha.985c0d(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) '@coze-arch/i18n': specifier: workspace:* version: link:../../../arch/i18n @@ -2536,8 +2536,8 @@ importers: specifier: workspace:* version: link:../../arch/bot-tea '@coze-arch/coze-design': - specifier: 0.0.6-alpha.eec92c - version: 0.0.6-alpha.eec92c(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) + specifier: 0.0.7-alpha.985c0d + version: 0.0.7-alpha.985c0d(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) '@coze-arch/i18n': specifier: workspace:* version: link:../../arch/i18n @@ -2630,8 +2630,8 @@ importers: specifier: workspace:* version: link:../../arch/bot-utils '@coze-arch/coze-design': - specifier: 0.0.6-alpha.eec92c - version: 0.0.6-alpha.eec92c(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) + specifier: 0.0.7-alpha.985c0d + version: 0.0.7-alpha.985c0d(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) '@coze-arch/i18n': specifier: workspace:* version: link:../../arch/i18n @@ -2940,8 +2940,8 @@ importers: specifier: workspace:* version: link:../../arch/bot-utils '@coze-arch/coze-design': - specifier: 0.0.6-alpha.eec92c - version: 0.0.6-alpha.eec92c(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) + specifier: 0.0.7-alpha.985c0d + version: 0.0.7-alpha.985c0d(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) '@coze-arch/eslint-config': specifier: workspace:* version: link:../../../config/eslint-config @@ -3027,8 +3027,8 @@ importers: specifier: workspace:* version: link:../../components/bot-semi '@coze-arch/coze-design': - specifier: 0.0.6-alpha.eec92c - version: 0.0.6-alpha.eec92c(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) + specifier: 0.0.7-alpha.985c0d + version: 0.0.7-alpha.985c0d(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) '@coze-arch/i18n': specifier: workspace:* version: link:../../arch/i18n @@ -3400,8 +3400,8 @@ importers: specifier: workspace:* version: link:../../arch/bot-utils '@coze-arch/coze-design': - specifier: 0.0.6-alpha.eec92c - version: 0.0.6-alpha.eec92c(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) + specifier: 0.0.7-alpha.985c0d + version: 0.0.7-alpha.985c0d(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) '@coze-arch/i18n': specifier: workspace:* version: link:../../arch/i18n @@ -3581,8 +3581,8 @@ importers: specifier: workspace:* version: link:../../arch/bot-tea '@coze-arch/coze-design': - specifier: 0.0.6-alpha.eec92c - version: 0.0.6-alpha.eec92c(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) + specifier: 0.0.7-alpha.985c0d + version: 0.0.7-alpha.985c0d(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) '@coze-arch/i18n': specifier: workspace:* version: link:../../arch/i18n @@ -3721,8 +3721,8 @@ importers: specifier: workspace:* version: link:../../components/bot-semi '@coze-arch/coze-design': - specifier: 0.0.6-alpha.eec92c - version: 0.0.6-alpha.eec92c(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) + specifier: 0.0.7-alpha.985c0d + version: 0.0.7-alpha.985c0d(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) '@coze-arch/i18n': specifier: workspace:* version: link:../../arch/i18n @@ -3875,8 +3875,8 @@ importers: specifier: workspace:* version: link:../../arch/bot-utils '@coze-arch/coze-design': - specifier: 0.0.6-alpha.eec92c - version: 0.0.6-alpha.eec92c(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) + specifier: 0.0.7-alpha.985c0d + version: 0.0.7-alpha.985c0d(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) '@coze-arch/i18n': specifier: workspace:* version: link:../../arch/i18n @@ -4098,8 +4098,8 @@ importers: specifier: workspace:* version: link:../../arch/bot-utils '@coze-arch/coze-design': - specifier: 0.0.6-alpha.eec92c - version: 0.0.6-alpha.eec92c(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) + specifier: 0.0.7-alpha.985c0d + version: 0.0.7-alpha.985c0d(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) '@coze-arch/i18n': specifier: workspace:* version: link:../../arch/i18n @@ -4279,8 +4279,8 @@ importers: specifier: workspace:* version: link:../../arch/bot-utils '@coze-arch/coze-design': - specifier: 0.0.6-alpha.eec92c - version: 0.0.6-alpha.eec92c(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) + specifier: 0.0.7-alpha.985c0d + version: 0.0.7-alpha.985c0d(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) '@coze-arch/i18n': specifier: workspace:* version: link:../../arch/i18n @@ -4457,8 +4457,8 @@ importers: specifier: workspace:* version: link:../../components/bot-semi '@coze-arch/coze-design': - specifier: 0.0.6-alpha.eec92c - version: 0.0.6-alpha.eec92c(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) + specifier: 0.0.7-alpha.985c0d + version: 0.0.7-alpha.985c0d(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) '@coze-arch/i18n': specifier: workspace:* version: link:../../arch/i18n @@ -4539,8 +4539,8 @@ importers: specifier: workspace:* version: link:../../arch/bot-flags '@coze-arch/coze-design': - specifier: 0.0.6-alpha.eec92c - version: 0.0.6-alpha.eec92c(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) + specifier: 0.0.7-alpha.985c0d + version: 0.0.7-alpha.985c0d(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) '@coze-arch/i18n': specifier: workspace:* version: link:../../arch/i18n @@ -4676,8 +4676,8 @@ importers: specifier: workspace:* version: link:../../arch/bot-utils '@coze-arch/coze-design': - specifier: 0.0.6-alpha.eec92c - version: 0.0.6-alpha.eec92c(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) + specifier: 0.0.7-alpha.985c0d + version: 0.0.7-alpha.985c0d(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) '@coze-arch/eslint-config': specifier: workspace:* version: link:../../../config/eslint-config @@ -4912,8 +4912,8 @@ importers: specifier: workspace:* version: link:../../arch/bot-utils '@coze-arch/coze-design': - specifier: 0.0.6-alpha.eec92c - version: 0.0.6-alpha.eec92c(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) + specifier: 0.0.7-alpha.985c0d + version: 0.0.7-alpha.985c0d(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) '@coze-arch/eslint-config': specifier: workspace:* version: link:../../../config/eslint-config @@ -5178,8 +5178,8 @@ importers: specifier: workspace:* version: link:../../arch/bot-tea '@coze-arch/coze-design': - specifier: 0.0.6-alpha.eec92c - version: 0.0.6-alpha.eec92c(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) + specifier: 0.0.7-alpha.985c0d + version: 0.0.7-alpha.985c0d(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) '@coze-arch/i18n': specifier: workspace:* version: link:../../arch/i18n @@ -5324,14 +5324,20 @@ importers: specifier: workspace:* version: link:../../arch/bot-store '@coze-arch/coze-design': - specifier: 0.0.6-alpha.eec92c - version: 0.0.6-alpha.eec92c(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) + specifier: 0.0.7-alpha.985c0d + version: 0.0.7-alpha.985c0d(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) '@coze-arch/i18n': specifier: workspace:* version: link:../../arch/i18n '@coze-common/assets': specifier: workspace:* version: link:../../common/assets + '@coze-studio/api-schema': + specifier: workspace:* + version: link:../../arch/api-schema + ahooks: + specifier: 3.7.8 + version: 3.7.8(patch_hash=sa4ddrxdk2yhjzudeck6u5ww3i)(react@18.2.0) classnames: specifier: ^2.3.2 version: 2.5.1 @@ -5418,8 +5424,8 @@ importers: specifier: workspace:* version: link:../../arch/bot-tea '@coze-arch/coze-design': - specifier: 0.0.6-alpha.eec92c - version: 0.0.6-alpha.eec92c(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) + specifier: 0.0.7-alpha.985c0d + version: 0.0.7-alpha.985c0d(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) '@coze-arch/i18n': specifier: workspace:* version: link:../../arch/i18n @@ -5591,8 +5597,8 @@ importers: specifier: workspace:* version: link:../../arch/bot-utils '@coze-arch/coze-design': - specifier: 0.0.6-alpha.eec92c - version: 0.0.6-alpha.eec92c(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) + specifier: 0.0.7-alpha.985c0d + version: 0.0.7-alpha.985c0d(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) '@coze-arch/i18n': specifier: workspace:* version: link:../../arch/i18n @@ -5700,8 +5706,8 @@ importers: specifier: workspace:* version: link:../../arch/bot-store '@coze-arch/coze-design': - specifier: 0.0.6-alpha.eec92c - version: 0.0.6-alpha.eec92c(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) + specifier: 0.0.7-alpha.985c0d + version: 0.0.7-alpha.985c0d(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) '@coze-arch/i18n': specifier: workspace:* version: link:../../arch/i18n @@ -5912,8 +5918,8 @@ importers: specifier: workspace:* version: link:../../arch/bot-utils '@coze-arch/coze-design': - specifier: 0.0.6-alpha.eec92c - version: 0.0.6-alpha.eec92c(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) + specifier: 0.0.7-alpha.985c0d + version: 0.0.7-alpha.985c0d(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) '@coze-arch/fetch-stream': specifier: workspace:* version: link:../../arch/fetch-stream @@ -6096,8 +6102,8 @@ importers: specifier: workspace:* version: link:../space-bot '@coze-arch/coze-design': - specifier: 0.0.6-alpha.eec92c - version: 0.0.6-alpha.eec92c(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) + specifier: 0.0.7-alpha.985c0d + version: 0.0.7-alpha.985c0d(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) '@coze-arch/i18n': specifier: workspace:* version: link:../../arch/i18n @@ -6235,8 +6241,8 @@ importers: specifier: workspace:* version: link:../../arch/bot-utils '@coze-arch/coze-design': - specifier: 0.0.6-alpha.eec92c - version: 0.0.6-alpha.eec92c(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) + specifier: 0.0.7-alpha.985c0d + version: 0.0.7-alpha.985c0d(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) '@coze-arch/fetch-stream': specifier: workspace:* version: link:../../arch/fetch-stream @@ -6557,8 +6563,8 @@ importers: specifier: workspace:* version: link:../../arch/bot-utils '@coze-arch/coze-design': - specifier: 0.0.6-alpha.eec92c - version: 0.0.6-alpha.eec92c(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) + specifier: 0.0.7-alpha.985c0d + version: 0.0.7-alpha.985c0d(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) '@coze-arch/i18n': specifier: workspace:* version: link:../../arch/i18n @@ -6826,8 +6832,8 @@ importers: specifier: workspace:* version: link:../../arch/bot-utils '@coze-arch/coze-design': - specifier: 0.0.6-alpha.eec92c - version: 0.0.6-alpha.eec92c(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) + specifier: 0.0.7-alpha.985c0d + version: 0.0.7-alpha.985c0d(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) '@coze-arch/i18n': specifier: workspace:* version: link:../../arch/i18n @@ -7114,8 +7120,8 @@ importers: specifier: workspace:* version: link:../../arch/bot-store '@coze-arch/coze-design': - specifier: 0.0.6-alpha.eec92c - version: 0.0.6-alpha.eec92c(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) + specifier: 0.0.7-alpha.985c0d + version: 0.0.7-alpha.985c0d(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) '@coze-arch/i18n': specifier: workspace:* version: link:../../arch/i18n @@ -7208,8 +7214,8 @@ importers: specifier: workspace:* version: link:../../arch/bot-utils '@coze-arch/coze-design': - specifier: 0.0.6-alpha.eec92c - version: 0.0.6-alpha.eec92c(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) + specifier: 0.0.7-alpha.985c0d + version: 0.0.7-alpha.985c0d(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) '@coze-arch/i18n': specifier: workspace:* version: link:../../arch/i18n @@ -8402,8 +8408,8 @@ importers: ../../../frontend/packages/arch/foundation-sdk: devDependencies: '@coze-arch/coze-design': - specifier: 0.0.6-alpha.eec92c - version: 0.0.6-alpha.eec92c(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) + specifier: 0.0.7-alpha.985c0d + version: 0.0.7-alpha.985c0d(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) '@coze-arch/eslint-config': specifier: workspace:* version: link:../../../config/eslint-config @@ -8487,8 +8493,8 @@ importers: ../../../frontend/packages/arch/i18n: dependencies: '@coze-arch/coze-design': - specifier: 0.0.6-alpha.eec92c - version: 0.0.6-alpha.eec92c(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) + specifier: 0.0.7-alpha.985c0d + version: 0.0.7-alpha.985c0d(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) '@coze-studio/studio-i18n-resource-adapter': specifier: workspace:* version: link:../resources/studio-i18n-resource @@ -9235,8 +9241,8 @@ importers: specifier: workspace:* version: link:../../arch/bot-utils '@coze-arch/coze-design': - specifier: 0.0.6-alpha.eec92c - version: 0.0.6-alpha.eec92c(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) + specifier: 0.0.7-alpha.985c0d + version: 0.0.7-alpha.985c0d(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) '@coze-arch/foundation-sdk': specifier: workspace:* version: link:../../arch/foundation-sdk @@ -9414,8 +9420,8 @@ importers: specifier: workspace:* version: link:../../../arch/bot-utils '@coze-arch/coze-design': - specifier: 0.0.6-alpha.eec92c - version: 0.0.6-alpha.eec92c(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) + specifier: 0.0.7-alpha.985c0d + version: 0.0.7-alpha.985c0d(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) '@coze-arch/eslint-config': specifier: workspace:* version: link:../../../../config/eslint-config @@ -9510,8 +9516,8 @@ importers: specifier: workspace:* version: link:../../../arch/bot-utils '@coze-arch/coze-design': - specifier: 0.0.6-alpha.eec92c - version: 0.0.6-alpha.eec92c(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) + specifier: 0.0.7-alpha.985c0d + version: 0.0.7-alpha.985c0d(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) '@coze-common/chat-area-utils': specifier: workspace:* version: link:../utils @@ -9861,8 +9867,8 @@ importers: specifier: workspace:* version: link:../../../arch/bot-typings '@coze-arch/coze-design': - specifier: 0.0.6-alpha.eec92c - version: 0.0.6-alpha.eec92c(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) + specifier: 0.0.7-alpha.985c0d + version: 0.0.7-alpha.985c0d(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) '@coze-arch/i18n': specifier: workspace:* version: link:../../../arch/i18n @@ -10136,8 +10142,8 @@ importers: ../../../frontend/packages/common/chat-area/chat-workflow-render: dependencies: '@coze-arch/coze-design': - specifier: 0.0.6-alpha.eec92c - version: 0.0.6-alpha.eec92c(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) + specifier: 0.0.7-alpha.985c0d + version: 0.0.7-alpha.985c0d(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) '@coze-arch/i18n': specifier: workspace:* version: link:../../../arch/i18n @@ -10378,8 +10384,8 @@ importers: specifier: workspace:* version: link:../../../arch/bot-tea '@coze-arch/coze-design': - specifier: 0.0.6-alpha.eec92c - version: 0.0.6-alpha.eec92c(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) + specifier: 0.0.7-alpha.985c0d + version: 0.0.7-alpha.985c0d(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) '@coze-arch/i18n': specifier: workspace:* version: link:../../../arch/i18n @@ -10520,8 +10526,8 @@ importers: specifier: workspace:* version: link:../../../components/bot-semi '@coze-arch/coze-design': - specifier: 0.0.6-alpha.eec92c - version: 0.0.6-alpha.eec92c(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) + specifier: 0.0.7-alpha.985c0d + version: 0.0.7-alpha.985c0d(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) '@coze-arch/i18n': specifier: workspace:* version: link:../../../arch/i18n @@ -10617,8 +10623,8 @@ importers: specifier: workspace:* version: link:../../../components/bot-semi '@coze-arch/coze-design': - specifier: 0.0.6-alpha.eec92c - version: 0.0.6-alpha.eec92c(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) + specifier: 0.0.7-alpha.985c0d + version: 0.0.7-alpha.985c0d(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) '@coze-common/chat-area': specifier: workspace:* version: link:../chat-area @@ -10879,8 +10885,8 @@ importers: specifier: workspace:* version: link:../../components/bot-semi '@coze-arch/coze-design': - specifier: 0.0.6-alpha.eec92c - version: 0.0.6-alpha.eec92c(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) + specifier: 0.0.7-alpha.985c0d + version: 0.0.7-alpha.985c0d(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) '@coze-arch/i18n': specifier: workspace:* version: link:../../arch/i18n @@ -11237,8 +11243,8 @@ importers: specifier: workspace:* version: link:../../arch/bot-api '@coze-arch/coze-design': - specifier: 0.0.6-alpha.eec92c - version: 0.0.6-alpha.eec92c(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) + specifier: 0.0.7-alpha.985c0d + version: 0.0.7-alpha.985c0d(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) classnames: specifier: ^2.3.2 version: 2.5.1 @@ -11368,8 +11374,8 @@ importers: specifier: workspace:* version: link:../../../arch/bot-tea '@coze-arch/coze-design': - specifier: 0.0.6-alpha.eec92c - version: 0.0.6-alpha.eec92c(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) + specifier: 0.0.7-alpha.985c0d + version: 0.0.7-alpha.985c0d(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) '@coze-arch/i18n': specifier: workspace:* version: link:../../../arch/i18n @@ -11483,8 +11489,8 @@ importers: specifier: workspace:* version: link:../../../arch/bot-tea '@coze-arch/coze-design': - specifier: 0.0.6-alpha.eec92c - version: 0.0.6-alpha.eec92c(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) + specifier: 0.0.7-alpha.985c0d + version: 0.0.7-alpha.985c0d(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) '@coze-arch/i18n': specifier: workspace:* version: link:../../../arch/i18n @@ -11740,9 +11746,15 @@ importers: '@coze-arch/bot-semi': specifier: workspace:* version: link:../../components/bot-semi + '@coze-arch/bot-tea': + specifier: workspace:* + version: link:../../arch/bot-tea + '@coze-arch/bot-utils': + specifier: workspace:* + version: link:../../arch/bot-utils '@coze-arch/coze-design': - specifier: 0.0.6-alpha.eec92c - version: 0.0.6-alpha.eec92c(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) + specifier: 0.0.7-alpha.985c0d + version: 0.0.7-alpha.985c0d(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) '@coze-arch/i18n': specifier: workspace:* version: link:../../arch/i18n @@ -11770,9 +11782,24 @@ importers: ahooks: specifier: 3.7.8 version: 3.7.8(patch_hash=sa4ddrxdk2yhjzudeck6u5ww3i)(react@18.2.0) + axios: + specifier: ^1.4.0 + version: 1.10.0(debug@4.3.3) classnames: specifier: ^2.3.2 version: 2.5.1 + dayjs: + specifier: ^1.11.7 + version: 1.11.13 + lodash-es: + specifier: ^4.17.21 + version: 4.17.21 + query-string: + specifier: ^8.1.0 + version: 8.2.0 + zustand: + specifier: ^4.4.7 + version: 4.5.7(@types/react@18.2.37)(immer@10.1.1)(react@18.2.0) devDependencies: '@coze-arch/bot-env': specifier: workspace:* @@ -11936,30 +11963,60 @@ importers: ../../../frontend/packages/community/explore: dependencies: + '@ahooksjs/use-url-state': + specifier: ^3.5.1 + version: 3.5.1(react-router@6.30.1)(react@18.2.0) '@coze-arch/bot-api': specifier: workspace:* version: link:../../arch/bot-api '@coze-arch/bot-hooks': specifier: workspace:* version: link:../../arch/bot-hooks + '@coze-arch/bot-icons': + specifier: workspace:* + version: link:../../components/bot-icons + '@coze-arch/bot-semi': + specifier: workspace:* + version: link:../../components/bot-semi + '@coze-arch/bot-studio-store': + specifier: workspace:* + version: link:../../arch/bot-store + '@coze-arch/bot-tea': + specifier: workspace:* + version: link:../../arch/bot-tea + '@coze-arch/bot-utils': + specifier: workspace:* + version: link:../../arch/bot-utils '@coze-arch/coze-design': - specifier: 0.0.6-alpha.eec92c - version: 0.0.6-alpha.eec92c(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) + specifier: 0.0.7-alpha.985c0d + version: 0.0.7-alpha.985c0d(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) '@coze-arch/i18n': specifier: workspace:* version: link:../../arch/i18n + '@coze-arch/responsive-kit': + specifier: workspace:* + version: link:../../arch/responsive-kit '@coze-community/components': specifier: workspace:* version: link:../component '@coze-studio/api-schema': specifier: workspace:* version: link:../../arch/api-schema + '@coze-studio/components': + specifier: workspace:* + version: link:../../studio/components + '@coze-studio/entity-adapter': + specifier: workspace:* + version: link:../../studio/entity-adapter ahooks: specifier: 3.7.8 version: 3.7.8(patch_hash=sa4ddrxdk2yhjzudeck6u5ww3i)(react@18.2.0) classnames: specifier: ^2.3.2 version: 2.5.1 + query-string: + specifier: ^8.1.0 + version: 8.2.0 react-router-dom: specifier: ^6.11.1 version: 6.30.1(react-dom@18.2.0)(react@18.2.0) @@ -12363,8 +12420,8 @@ importers: specifier: workspace:* version: link:../bot-semi '@coze-arch/coze-design': - specifier: 0.0.6-alpha.eec92c - version: 0.0.6-alpha.eec92c(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) + specifier: 0.0.7-alpha.985c0d + version: 0.0.7-alpha.985c0d(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) '@coze-arch/i18n': specifier: workspace:* version: link:../../arch/i18n @@ -12463,8 +12520,8 @@ importers: specifier: workspace:* version: link:../bot-semi '@coze-arch/coze-design': - specifier: 0.0.6-alpha.eec92c - version: 0.0.6-alpha.eec92c(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) + specifier: 0.0.7-alpha.985c0d + version: 0.0.7-alpha.985c0d(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) '@coze-arch/i18n': specifier: workspace:* version: link:../../arch/i18n @@ -12639,8 +12696,8 @@ importers: specifier: workspace:* version: link:../bot-semi '@coze-arch/coze-design': - specifier: 0.0.6-alpha.eec92c - version: 0.0.6-alpha.eec92c(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) + specifier: 0.0.7-alpha.985c0d + version: 0.0.7-alpha.985c0d(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) '@coze-arch/i18n': specifier: workspace:* version: link:../../arch/i18n @@ -12967,8 +13024,8 @@ importers: specifier: workspace:* version: link:../../../components/bot-semi '@coze-arch/coze-design': - specifier: 0.0.6-alpha.eec92c - version: 0.0.6-alpha.eec92c(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) + specifier: 0.0.7-alpha.985c0d + version: 0.0.7-alpha.985c0d(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) '@coze-arch/i18n': specifier: workspace:* version: link:../../../arch/i18n @@ -13079,8 +13136,8 @@ importers: specifier: workspace:* version: link:../../../../components/bot-semi '@coze-arch/coze-design': - specifier: 0.0.6-alpha.eec92c - version: 0.0.6-alpha.eec92c(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) + specifier: 0.0.7-alpha.985c0d + version: 0.0.7-alpha.985c0d(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) '@coze-arch/i18n': specifier: workspace:* version: link:../../../../arch/i18n @@ -13224,8 +13281,8 @@ importers: specifier: workspace:* version: link:../../../../arch/bot-store '@coze-arch/coze-design': - specifier: 0.0.6-alpha.eec92c - version: 0.0.6-alpha.eec92c(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) + specifier: 0.0.7-alpha.985c0d + version: 0.0.7-alpha.985c0d(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) '@coze-arch/i18n': specifier: workspace:* version: link:../../../../arch/i18n @@ -13595,8 +13652,8 @@ importers: specifier: workspace:* version: link:../../../arch/bot-utils '@coze-arch/coze-design': - specifier: 0.0.6-alpha.eec92c - version: 0.0.6-alpha.eec92c(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) + specifier: 0.0.7-alpha.985c0d + version: 0.0.7-alpha.985c0d(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) '@coze-arch/i18n': specifier: workspace:* version: link:../../../arch/i18n @@ -13767,8 +13824,8 @@ importers: specifier: workspace:* version: link:../../../arch/bot-store '@coze-arch/coze-design': - specifier: 0.0.6-alpha.eec92c - version: 0.0.6-alpha.eec92c(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) + specifier: 0.0.7-alpha.985c0d + version: 0.0.7-alpha.985c0d(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) '@coze-arch/i18n': specifier: workspace:* version: link:../../../arch/i18n @@ -13870,8 +13927,8 @@ importers: specifier: workspace:* version: link:../../../arch/bot-tea '@coze-arch/coze-design': - specifier: 0.0.6-alpha.eec92c - version: 0.0.6-alpha.eec92c(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) + specifier: 0.0.7-alpha.985c0d + version: 0.0.7-alpha.985c0d(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) '@coze-arch/i18n': specifier: workspace:* version: link:../../../arch/i18n @@ -14094,8 +14151,8 @@ importers: specifier: workspace:* version: link:../../../arch/bot-utils '@coze-arch/coze-design': - specifier: 0.0.6-alpha.eec92c - version: 0.0.6-alpha.eec92c(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) + specifier: 0.0.7-alpha.985c0d + version: 0.0.7-alpha.985c0d(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) '@coze-arch/foundation-sdk': specifier: workspace:* version: link:../../../arch/foundation-sdk @@ -14269,8 +14326,8 @@ importers: specifier: workspace:* version: link:../../../components/bot-semi '@coze-arch/coze-design': - specifier: 0.0.6-alpha.eec92c - version: 0.0.6-alpha.eec92c(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) + specifier: 0.0.7-alpha.985c0d + version: 0.0.7-alpha.985c0d(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) '@coze-arch/pdfjs-shadow': specifier: workspace:* version: link:../../../arch/pdfjs-shadow @@ -14345,8 +14402,8 @@ importers: specifier: workspace:* version: link:../../../arch/bot-tea '@coze-arch/coze-design': - specifier: 0.0.6-alpha.eec92c - version: 0.0.6-alpha.eec92c(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) + specifier: 0.0.7-alpha.985c0d + version: 0.0.7-alpha.985c0d(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) '@coze-arch/i18n': specifier: workspace:* version: link:../../../arch/i18n @@ -14632,8 +14689,8 @@ importers: specifier: workspace:* version: link:../../../components/bot-semi '@coze-arch/coze-design': - specifier: 0.0.6-alpha.eec92c - version: 0.0.6-alpha.eec92c(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) + specifier: 0.0.7-alpha.985c0d + version: 0.0.7-alpha.985c0d(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) '@coze-arch/i18n': specifier: workspace:* version: link:../../../arch/i18n @@ -14717,8 +14774,8 @@ importers: specifier: workspace:* version: link:../../../arch/bot-tea '@coze-arch/coze-design': - specifier: 0.0.6-alpha.eec92c - version: 0.0.6-alpha.eec92c(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) + specifier: 0.0.7-alpha.985c0d + version: 0.0.7-alpha.985c0d(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) '@coze-arch/i18n': specifier: workspace:* version: link:../../../arch/i18n @@ -14835,8 +14892,8 @@ importers: specifier: workspace:* version: link:../../../arch/bot-utils '@coze-arch/coze-design': - specifier: 0.0.6-alpha.eec92c - version: 0.0.6-alpha.eec92c(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) + specifier: 0.0.7-alpha.985c0d + version: 0.0.7-alpha.985c0d(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) '@coze-arch/i18n': specifier: workspace:* version: link:../../../arch/i18n @@ -15083,8 +15140,8 @@ importers: specifier: workspace:* version: link:../../../arch/bot-utils '@coze-arch/coze-design': - specifier: 0.0.6-alpha.eec92c - version: 0.0.6-alpha.eec92c(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) + specifier: 0.0.7-alpha.985c0d + version: 0.0.7-alpha.985c0d(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) '@coze-arch/i18n': specifier: workspace:* version: link:../../../arch/i18n @@ -15243,8 +15300,8 @@ importers: specifier: workspace:* version: link:../../components/bot-semi '@coze-arch/coze-design': - specifier: 0.0.6-alpha.eec92c - version: 0.0.6-alpha.eec92c(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) + specifier: 0.0.7-alpha.985c0d + version: 0.0.7-alpha.985c0d(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) '@coze-arch/i18n': specifier: workspace:* version: link:../../arch/i18n @@ -15383,8 +15440,8 @@ importers: specifier: workspace:* version: link:../../../arch/bot-typings '@coze-arch/coze-design': - specifier: 0.0.6-alpha.eec92c - version: 0.0.6-alpha.eec92c(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) + specifier: 0.0.7-alpha.985c0d + version: 0.0.7-alpha.985c0d(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) '@coze-arch/eslint-config': specifier: workspace:* version: link:../../../../config/eslint-config @@ -15458,8 +15515,8 @@ importers: specifier: workspace:* version: link:../../arch/bot-tea '@coze-arch/coze-design': - specifier: 0.0.6-alpha.eec92c - version: 0.0.6-alpha.eec92c(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) + specifier: 0.0.7-alpha.985c0d + version: 0.0.7-alpha.985c0d(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) '@coze-arch/i18n': specifier: workspace:* version: link:../../arch/i18n @@ -15894,8 +15951,8 @@ importers: specifier: workspace:* version: link:../../components/bot-semi '@coze-arch/coze-design': - specifier: 0.0.6-alpha.eec92c - version: 0.0.6-alpha.eec92c(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) + specifier: 0.0.7-alpha.985c0d + version: 0.0.7-alpha.985c0d(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) '@coze-arch/i18n': specifier: workspace:* version: link:../../arch/i18n @@ -15985,8 +16042,8 @@ importers: specifier: workspace:* version: link:../../arch/bot-utils '@coze-arch/coze-design': - specifier: 0.0.6-alpha.eec92c - version: 0.0.6-alpha.eec92c(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) + specifier: 0.0.7-alpha.985c0d + version: 0.0.7-alpha.985c0d(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) '@coze-arch/foundation-sdk': specifier: workspace:* version: link:../../arch/foundation-sdk @@ -16070,8 +16127,8 @@ importers: ../../../frontend/packages/foundation/browser-upgrade-banner: dependencies: '@coze-arch/coze-design': - specifier: 0.0.6-alpha.eec92c - version: 0.0.6-alpha.eec92c(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) + specifier: 0.0.7-alpha.985c0d + version: 0.0.7-alpha.985c0d(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) '@coze-arch/i18n': specifier: workspace:* version: link:../../arch/i18n @@ -16219,8 +16276,8 @@ importers: specifier: workspace:* version: link:../../arch/bot-api '@coze-arch/coze-design': - specifier: 0.0.6-alpha.eec92c - version: 0.0.6-alpha.eec92c(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) + specifier: 0.0.7-alpha.985c0d + version: 0.0.7-alpha.985c0d(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) '@coze-foundation/account-adapter': specifier: workspace:* version: link:../account-adapter @@ -16268,8 +16325,8 @@ importers: specifier: workspace:* version: link:../../arch/bot-tea '@coze-arch/coze-design': - specifier: 0.0.6-alpha.eec92c - version: 0.0.6-alpha.eec92c(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) + specifier: 0.0.7-alpha.985c0d + version: 0.0.7-alpha.985c0d(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) '@coze-arch/i18n': specifier: workspace:* version: link:../../arch/i18n @@ -16362,8 +16419,8 @@ importers: specifier: workspace:* version: link:../../arch/bot-utils '@coze-arch/coze-design': - specifier: 0.0.6-alpha.eec92c - version: 0.0.6-alpha.eec92c(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) + specifier: 0.0.7-alpha.985c0d + version: 0.0.7-alpha.985c0d(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) '@coze-arch/foundation-sdk': specifier: workspace:* version: link:../../arch/foundation-sdk @@ -16553,8 +16610,8 @@ importers: specifier: workspace:* version: link:../../arch/bot-utils '@coze-arch/coze-design': - specifier: 0.0.6-alpha.eec92c - version: 0.0.6-alpha.eec92c(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) + specifier: 0.0.7-alpha.985c0d + version: 0.0.7-alpha.985c0d(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) '@coze-arch/i18n': specifier: workspace:* version: link:../../arch/i18n @@ -16899,8 +16956,8 @@ importers: specifier: workspace:* version: link:../../arch/bot-hooks '@coze-arch/coze-design': - specifier: 0.0.6-alpha.eec92c - version: 0.0.6-alpha.eec92c(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) + specifier: 0.0.7-alpha.985c0d + version: 0.0.7-alpha.985c0d(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) '@coze-arch/i18n': specifier: workspace:* version: link:../../arch/i18n @@ -16981,8 +17038,8 @@ importers: specifier: workspace:* version: link:../../arch/bot-tea '@coze-arch/coze-design': - specifier: 0.0.6-alpha.eec92c - version: 0.0.6-alpha.eec92c(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) + specifier: 0.0.7-alpha.985c0d + version: 0.0.7-alpha.985c0d(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) '@coze-arch/i18n': specifier: workspace:* version: link:../../arch/i18n @@ -17164,8 +17221,8 @@ importers: specifier: workspace:* version: link:../../components/bot-icons '@coze-arch/coze-design': - specifier: 0.0.6-alpha.eec92c - version: 0.0.6-alpha.eec92c(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) + specifier: 0.0.7-alpha.985c0d + version: 0.0.7-alpha.985c0d(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) '@coze-arch/i18n': specifier: workspace:* version: link:../../arch/i18n @@ -17258,8 +17315,8 @@ importers: specifier: workspace:* version: link:../../components/bot-semi '@coze-arch/coze-design': - specifier: 0.0.6-alpha.eec92c - version: 0.0.6-alpha.eec92c(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) + specifier: 0.0.7-alpha.985c0d + version: 0.0.7-alpha.985c0d(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) '@coze-arch/i18n': specifier: workspace:* version: link:../../arch/i18n @@ -17385,8 +17442,8 @@ importers: specifier: workspace:* version: link:../../arch/bot-store '@coze-arch/coze-design': - specifier: 0.0.6-alpha.eec92c - version: 0.0.6-alpha.eec92c(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) + specifier: 0.0.7-alpha.985c0d + version: 0.0.7-alpha.985c0d(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) '@coze-arch/i18n': specifier: workspace:* version: link:../../arch/i18n @@ -17443,8 +17500,8 @@ importers: ../../../frontend/packages/project-ide/biz-plugin-registry-adapter: dependencies: '@coze-arch/coze-design': - specifier: 0.0.6-alpha.eec92c - version: 0.0.6-alpha.eec92c(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) + specifier: 0.0.7-alpha.985c0d + version: 0.0.7-alpha.985c0d(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) '@coze-project-ide/biz-plugin': specifier: workspace:* version: link:../biz-plugin @@ -17519,8 +17576,8 @@ importers: specifier: workspace:* version: link:../../arch/bot-typings '@coze-arch/coze-design': - specifier: 0.0.6-alpha.eec92c - version: 0.0.6-alpha.eec92c(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) + specifier: 0.0.7-alpha.985c0d + version: 0.0.7-alpha.985c0d(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) '@coze-arch/i18n': specifier: workspace:* version: link:../../arch/i18n @@ -17738,8 +17795,8 @@ importers: specifier: workspace:* version: link:../../arch/bot-utils '@coze-arch/coze-design': - specifier: 0.0.6-alpha.eec92c - version: 0.0.6-alpha.eec92c(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) + specifier: 0.0.7-alpha.985c0d + version: 0.0.7-alpha.985c0d(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) '@coze-arch/i18n': specifier: workspace:* version: link:../../arch/i18n @@ -17832,8 +17889,8 @@ importers: specifier: workspace:* version: link:../../arch/bot-utils '@coze-arch/coze-design': - specifier: 0.0.6-alpha.eec92c - version: 0.0.6-alpha.eec92c(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) + specifier: 0.0.7-alpha.985c0d + version: 0.0.7-alpha.985c0d(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) '@coze-arch/fetch-stream': specifier: workspace:* version: link:../../arch/fetch-stream @@ -18202,8 +18259,8 @@ importers: ../../../frontend/packages/studio/bot-utils: dependencies: '@coze-arch/coze-design': - specifier: 0.0.6-alpha.eec92c - version: 0.0.6-alpha.eec92c(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) + specifier: 0.0.7-alpha.985c0d + version: 0.0.7-alpha.985c0d(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) '@coze-arch/i18n': specifier: workspace:* version: link:../../arch/i18n @@ -18381,8 +18438,8 @@ importers: specifier: workspace:* version: link:../../arch/bot-utils '@coze-arch/coze-design': - specifier: 0.0.6-alpha.eec92c - version: 0.0.6-alpha.eec92c(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) + specifier: 0.0.7-alpha.985c0d + version: 0.0.7-alpha.985c0d(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) '@coze-arch/i18n': specifier: workspace:* version: link:../../arch/i18n @@ -18541,8 +18598,8 @@ importers: specifier: workspace:* version: link:../../arch/bot-store '@coze-arch/coze-design': - specifier: 0.0.6-alpha.eec92c - version: 0.0.6-alpha.eec92c(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) + specifier: 0.0.7-alpha.985c0d + version: 0.0.7-alpha.985c0d(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) '@coze-arch/i18n': specifier: workspace:* version: link:../../arch/i18n @@ -18934,8 +18991,8 @@ importers: specifier: workspace:* version: link:../../../arch/bot-utils '@coze-arch/coze-design': - specifier: 0.0.6-alpha.eec92c - version: 0.0.6-alpha.eec92c(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) + specifier: 0.0.7-alpha.985c0d + version: 0.0.7-alpha.985c0d(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) '@coze-arch/eslint-config': specifier: workspace:* version: link:../../../../config/eslint-config @@ -19078,8 +19135,8 @@ importers: specifier: workspace:* version: link:../../../components/bot-semi '@coze-arch/coze-design': - specifier: 0.0.6-alpha.eec92c - version: 0.0.6-alpha.eec92c(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) + specifier: 0.0.7-alpha.985c0d + version: 0.0.7-alpha.985c0d(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) '@coze-arch/i18n': specifier: workspace:* version: link:../../../arch/i18n @@ -19217,8 +19274,8 @@ importers: specifier: workspace:* version: link:../../../arch/bot-utils '@coze-arch/coze-design': - specifier: 0.0.6-alpha.eec92c - version: 0.0.6-alpha.eec92c(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) + specifier: 0.0.7-alpha.985c0d + version: 0.0.7-alpha.985c0d(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) '@coze-arch/i18n': specifier: workspace:* version: link:../../../arch/i18n @@ -19500,8 +19557,8 @@ importers: specifier: workspace:* version: link:../../arch/bot-utils '@coze-arch/coze-design': - specifier: 0.0.6-alpha.eec92c - version: 0.0.6-alpha.eec92c(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) + specifier: 0.0.7-alpha.985c0d + version: 0.0.7-alpha.985c0d(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) '@coze-arch/i18n': specifier: workspace:* version: link:../../arch/i18n @@ -19582,8 +19639,8 @@ importers: specifier: workspace:* version: link:../../arch/bot-api '@coze-arch/coze-design': - specifier: 0.0.6-alpha.eec92c - version: 0.0.6-alpha.eec92c(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) + specifier: 0.0.7-alpha.985c0d + version: 0.0.7-alpha.985c0d(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) '@coze-arch/i18n': specifier: workspace:* version: link:../../arch/i18n @@ -20114,8 +20171,8 @@ importers: specifier: workspace:* version: link:../../../arch/bot-utils '@coze-arch/coze-design': - specifier: 0.0.6-alpha.eec92c - version: 0.0.6-alpha.eec92c(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) + specifier: 0.0.7-alpha.985c0d + version: 0.0.7-alpha.985c0d(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) '@coze-arch/i18n': specifier: workspace:* version: link:../../../arch/i18n @@ -20360,8 +20417,8 @@ importers: specifier: workspace:* version: link:../../../arch/bot-tea '@coze-arch/coze-design': - specifier: 0.0.6-alpha.eec92c - version: 0.0.6-alpha.eec92c(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) + specifier: 0.0.7-alpha.985c0d + version: 0.0.7-alpha.985c0d(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) '@coze-arch/i18n': specifier: workspace:* version: link:../../../arch/i18n @@ -20463,8 +20520,8 @@ importers: specifier: workspace:* version: link:../../../arch/bot-utils '@coze-arch/coze-design': - specifier: 0.0.6-alpha.eec92c - version: 0.0.6-alpha.eec92c(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) + specifier: 0.0.7-alpha.985c0d + version: 0.0.7-alpha.985c0d(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) '@coze-arch/i18n': specifier: workspace:* version: link:../../../arch/i18n @@ -20747,8 +20804,8 @@ importers: specifier: workspace:* version: link:../../../arch/bot-utils '@coze-arch/coze-design': - specifier: 0.0.6-alpha.eec92c - version: 0.0.6-alpha.eec92c(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) + specifier: 0.0.7-alpha.985c0d + version: 0.0.7-alpha.985c0d(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) '@coze-arch/i18n': specifier: workspace:* version: link:../../../arch/i18n @@ -20865,8 +20922,8 @@ importers: specifier: workspace:* version: link:../../../components/bot-semi '@coze-arch/coze-design': - specifier: 0.0.6-alpha.eec92c - version: 0.0.6-alpha.eec92c(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) + specifier: 0.0.7-alpha.985c0d + version: 0.0.7-alpha.985c0d(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) '@coze-arch/foundation-sdk': specifier: workspace:* version: link:../../../arch/foundation-sdk @@ -21074,8 +21131,8 @@ importers: specifier: ^6.34.1 version: 6.37.2 '@coze-arch/coze-design': - specifier: 0.0.6-alpha.eec92c - version: 0.0.6-alpha.eec92c(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) + specifier: 0.0.7-alpha.985c0d + version: 0.0.7-alpha.985c0d(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) '@coze-arch/i18n': specifier: workspace:* version: link:../../../arch/i18n @@ -21202,8 +21259,8 @@ importers: specifier: workspace:* version: link:../../../arch/bot-hooks '@coze-arch/coze-design': - specifier: 0.0.6-alpha.eec92c - version: 0.0.6-alpha.eec92c(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) + specifier: 0.0.7-alpha.985c0d + version: 0.0.7-alpha.985c0d(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) '@coze-arch/i18n': specifier: workspace:* version: link:../../../arch/i18n @@ -21517,8 +21574,8 @@ importers: specifier: workspace:* version: link:../../arch/bot-utils '@coze-arch/coze-design': - specifier: 0.0.6-alpha.eec92c - version: 0.0.6-alpha.eec92c(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) + specifier: 0.0.7-alpha.985c0d + version: 0.0.7-alpha.985c0d(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) '@coze-arch/foundation-sdk': specifier: workspace:* version: link:../../arch/foundation-sdk @@ -21716,8 +21773,8 @@ importers: ../../../frontend/packages/workflow/fabric-canvas: dependencies: '@coze-arch/coze-design': - specifier: 0.0.6-alpha.eec92c - version: 0.0.6-alpha.eec92c(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) + specifier: 0.0.7-alpha.985c0d + version: 0.0.7-alpha.985c0d(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) '@coze-arch/i18n': specifier: workspace:* version: link:../../arch/i18n @@ -21846,8 +21903,8 @@ importers: specifier: workspace:* version: link:../../components/bot-semi '@coze-arch/coze-design': - specifier: 0.0.6-alpha.eec92c - version: 0.0.6-alpha.eec92c(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) + specifier: 0.0.7-alpha.985c0d + version: 0.0.7-alpha.985c0d(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) '@coze-arch/i18n': specifier: workspace:* version: link:../../arch/i18n @@ -22022,8 +22079,8 @@ importers: specifier: workspace:* version: link:../../arch/bot-utils '@coze-arch/coze-design': - specifier: 0.0.6-alpha.eec92c - version: 0.0.6-alpha.eec92c(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) + specifier: 0.0.7-alpha.985c0d + version: 0.0.7-alpha.985c0d(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) '@coze-arch/i18n': specifier: workspace:* version: link:../../arch/i18n @@ -22230,8 +22287,8 @@ importers: specifier: workspace:* version: link:../../arch/bot-utils '@coze-arch/coze-design': - specifier: 0.0.6-alpha.eec92c - version: 0.0.6-alpha.eec92c(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) + specifier: 0.0.7-alpha.985c0d + version: 0.0.7-alpha.985c0d(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) '@coze-arch/hooks': specifier: workspace:* version: link:../../arch/hooks @@ -22690,8 +22747,8 @@ importers: specifier: workspace:* version: link:../../arch/bot-flags '@coze-arch/coze-design': - specifier: 0.0.6-alpha.eec92c - version: 0.0.6-alpha.eec92c(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) + specifier: 0.0.7-alpha.985c0d + version: 0.0.7-alpha.985c0d(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) '@coze-arch/report-tti': specifier: workspace:* version: link:../../arch/report-tti @@ -22830,8 +22887,8 @@ importers: ../../../frontend/packages/workflow/setters: dependencies: '@coze-arch/coze-design': - specifier: 0.0.6-alpha.eec92c - version: 0.0.6-alpha.eec92c(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) + specifier: 0.0.7-alpha.985c0d + version: 0.0.7-alpha.985c0d(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) '@coze-arch/i18n': specifier: workspace:* version: link:../../arch/i18n @@ -22987,8 +23044,8 @@ importers: specifier: workspace:* version: link:../../arch/bot-utils '@coze-arch/coze-design': - specifier: 0.0.6-alpha.eec92c - version: 0.0.6-alpha.eec92c(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) + specifier: 0.0.7-alpha.985c0d + version: 0.0.7-alpha.985c0d(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) '@coze-arch/i18n': specifier: workspace:* version: link:../../arch/i18n @@ -23123,8 +23180,8 @@ importers: ../../../frontend/packages/workflow/test-run-next/form: dependencies: '@coze-arch/coze-design': - specifier: 0.0.6-alpha.eec92c - version: 0.0.6-alpha.eec92c(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) + specifier: 0.0.7-alpha.985c0d + version: 0.0.7-alpha.985c0d(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) '@coze-arch/i18n': specifier: workspace:* version: link:../../../arch/i18n @@ -23242,8 +23299,8 @@ importers: specifier: ^6.34.1 version: 6.37.2 '@coze-arch/coze-design': - specifier: 0.0.6-alpha.eec92c - version: 0.0.6-alpha.eec92c(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) + specifier: 0.0.7-alpha.985c0d + version: 0.0.7-alpha.985c0d(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) '@coze-editor/editor': specifier: 0.1.0-alpha.dd871b version: 0.1.0-alpha.dd871b(@codemirror/autocomplete@6.18.6)(@codemirror/language@6.11.1)(@codemirror/merge@6.10.2)(@codemirror/state@6.5.2)(@codemirror/view@6.37.2)(@lezer/common@1.2.3)(@types/react@18.2.37)(react-dom@18.2.0)(react@18.2.0)(typescript@5.8.2)(vue@3.5.16) @@ -23300,8 +23357,8 @@ importers: specifier: workspace:* version: link:../../../arch/bot-api '@coze-arch/coze-design': - specifier: 0.0.6-alpha.eec92c - version: 0.0.6-alpha.eec92c(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) + specifier: 0.0.7-alpha.985c0d + version: 0.0.7-alpha.985c0d(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) '@coze-arch/i18n': specifier: workspace:* version: link:../../../arch/i18n @@ -23518,6 +23575,19 @@ packages: - debug dev: false + /@ahooksjs/use-url-state@3.5.1(react-router@6.30.1)(react@18.2.0): + resolution: {integrity: sha512-XTrOLZKOAXahDD1Evg+aSN6qNzoh/FuvRKbUtB/0RhYvz57tyXRPbED0KXK4h2C3ZyHUKBJcVCSDcd6EsTyMyQ==} + peerDependencies: + react: 18.2.0 + react-router: ^5.0.0 || ^6.0.0 + dependencies: + ahooks: 3.7.8(patch_hash=sa4ddrxdk2yhjzudeck6u5ww3i)(react@18.2.0) + query-string: 6.14.1 + react: 18.2.0 + react-router: 6.30.1(react@18.2.0) + tslib: 2.8.1 + dev: false + /@alloc/quick-lru@5.2.0: resolution: {integrity: sha512-UrcABB+4bUrFABwbluTIBErXwvbsU/V7TZWfmbgJfbkwiBuziS9gxdODUyuiecfdGQ85jglMW6juS3+z5TsKLw==} engines: {node: '>=10'} @@ -25685,29 +25755,29 @@ packages: dev: true optional: true - /@coze-arch/arco-icon@0.0.6-alpha.eec92c(react@18.2.0): - resolution: {integrity: sha512-BzQdOtawSp92Uyg4LFvJSyawaFlJ4xliKvwlzbfMyK1hnFDpLLvx2UVP08o5+UrFBFllUtosErYolnNp+qF9dA==} + /@coze-arch/arco-icon@0.0.6-alpha.985c0d(react@18.2.0): + resolution: {integrity: sha512-DtHARfICp7dkdbUBqf6dyhVuoSvAQxm59a0MimCyJ8QnyJap97mqGDgFZ/yvOkeCfnF32rKqaFsYgG0YIx1NbA==} peerDependencies: react: 18.2.0 dependencies: react: 18.2.0 - /@coze-arch/arco-illustration@0.0.12-alpha.eec92c(react@18.2.0): - resolution: {integrity: sha512-mTJQ9sHC/MqYxcpkmu/mYkoPOjiA3ICZ+37vysi9FlY0yXsO7aZ0aWceF4ew2vlYIPfrqJ/YTAj5HhGy64vevw==} + /@coze-arch/arco-illustration@0.0.12-alpha.985c0d(react@18.2.0): + resolution: {integrity: sha512-Z1GsMK8kJhLzlssHBbmHFqF16PDLtva+wTNsDe1nBguYgxJP+fFD2M5W862A+tPR1B4W7OZWaq1HnCKY2NuuXw==} peerDependencies: react: 18.2.0 dependencies: react: 18.2.0 - /@coze-arch/coze-design@0.0.6-alpha.eec92c(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0): - resolution: {integrity: sha512-NS7rSPmTuFx+9XKm1eujh7CxOK7DSmD861rLZDDuXndTRrnub8yYlR6nbcLqjKwiZQrRgLr107vXnC51SxS9Qg==} + /@coze-arch/coze-design@0.0.7-alpha.985c0d(@types/react@18.2.37)(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0): + resolution: {integrity: sha512-PyFKDHlNx0aNuzXu+XGtscJu5kTTVsdRVLcP1KvYNBDAfxz/tDpw6xisVsaR28kHY/D/OIinJ0vMvuinaHnExQ==} peerDependencies: react: 18.2.0 react-dom: 18.2.0 dependencies: - '@coze-arch/arco-icon': 0.0.6-alpha.eec92c(react@18.2.0) - '@coze-arch/arco-illustration': 0.0.12-alpha.eec92c(react@18.2.0) - '@coze-arch/semi-theme-hand01': 0.0.6-alpha.eec92c + '@coze-arch/arco-icon': 0.0.6-alpha.985c0d(react@18.2.0) + '@coze-arch/arco-illustration': 0.0.12-alpha.985c0d(react@18.2.0) + '@coze-arch/semi-theme-hand01': 0.0.6-alpha.985c0d '@douyinfe/semi-ui': 2.72.3(acorn@8.15.0)(react-dom@18.2.0)(react@18.2.0) ahooks: 3.7.8(patch_hash=sa4ddrxdk2yhjzudeck6u5ww3i)(react@18.2.0) class-variance-authority: 0.7.1 @@ -25734,8 +25804,8 @@ packages: /@coze-arch/semi-theme-hand01@0.0.6-alpha.346d77: resolution: {integrity: sha512-64YfAtHYVpssHXA4YOVu40CVUpZ+1JqESGA+esVI0lvFoNfdxF8WY5GkuIz5Xlj/73IKfgwIrxUHxM4EosAfMA==} - /@coze-arch/semi-theme-hand01@0.0.6-alpha.eec92c: - resolution: {integrity: sha512-mamZcgMbMHxr34Vp4IKqa0QESrW8OUfUJSze8tqefiUgIOvM0b1OsBvClQHCvkwByI60rENl1p6ff9FOhKyk7w==} + /@coze-arch/semi-theme-hand01@0.0.6-alpha.985c0d: + resolution: {integrity: sha512-69y9cz4PFQO7kkVIVAylk2cCyCSH3GKSLft6Y7h6QT483/6+CYeWCR8aLCuDZz/DjXOLR3uLqByXC8IqyuVu1g==} /@coze-editor/code-language-json@0.1.0-alpha.dd871b(@codemirror/language@6.11.1)(@codemirror/state@6.5.2)(@codemirror/view@6.37.2)(@coze-editor/code-language-shared@0.1.0-alpha.dd871b): resolution: {integrity: sha512-wMg/4HMZNKcUFtGTBhZHVb2PyZzGWwIjF7jXpBkNc2y+lKyINblpMdWGhyaovI/JVHxFUTaUysSiwuGoI55Gug==} @@ -42252,6 +42322,11 @@ packages: dependencies: to-regex-range: 5.0.1 + /filter-obj@1.1.0: + resolution: {integrity: sha512-8rXg1ZnX7xzy2NGDVkBVaAy+lSlPNwad13BtgSlLuxfIslyt5Vg64U7tFcCt4WS1R0hvtnQybT/IyCkGZ3DpXQ==} + engines: {node: '>=0.10.0'} + dev: false + /filter-obj@5.1.0: resolution: {integrity: sha512-qWeTREPoT7I0bifpPUXtxkZJ1XJzxWtfoWWkdVGqa+eCr3SHW/Ocp89o8vLvbUuQnadybJpjOKu4V+RwO6sGng==} engines: {node: '>=14.16'} @@ -49041,6 +49116,16 @@ packages: engines: {node: '>=0.6'} dev: false + /query-string@6.14.1: + resolution: {integrity: sha512-XDxAeVmpfu1/6IjyT/gXHOl+S0vQ9owggJ30hhWKdHAsNPOcasn5o9BW0eejZqL2e4vMjhAxoW3jVHcD6mbcYw==} + engines: {node: '>=6'} + dependencies: + decode-uri-component: 0.2.2 + filter-obj: 1.1.0 + split-on-first: 1.1.0 + strict-uri-encode: 2.0.0 + dev: false + /query-string@8.2.0: resolution: {integrity: sha512-tUZIw8J0CawM5wyGBiDOAp7ObdRQh4uBor/fUR9ZjmbZVvw95OD9If4w3MQxr99rg0DJZ/9CIORcpEqU5hQG7g==} engines: {node: '>=14.16'} @@ -51856,6 +51941,11 @@ packages: wicked-good-xpath: 1.3.0 dev: false + /split-on-first@1.1.0: + resolution: {integrity: sha512-43ZssAJaMusuKWL8sKUBQXHWOpq8d6CfN/u1p4gUzfJkM05C8rxTmYrkIPTXapZpORA6LkkzcUulJ8FqA7Uudw==} + engines: {node: '>=6'} + dev: false + /split-on-first@3.0.0: resolution: {integrity: sha512-qxQJTx2ryR0Dw0ITYyekNQWpz6f8dGd7vffGNflQQ3Iqj9NJ6qiZ7ELpZsJ/QBhIVAiDfXdag3+Gp8RvWa62AA==} engines: {node: '>=12'} @@ -52201,6 +52291,11 @@ packages: resolution: {integrity: sha512-ZuEDP9sgjiAwUVoDModftG0JtYiLUV8K4ljYD1VyUMRWtbVf92474o4kuuul43iZ8t/hRuiDAx1dIJSvirrK/g==} dev: false + /strict-uri-encode@2.0.0: + resolution: {integrity: sha512-QwiXZgpRcKkhTj2Scnn++4PKtWsH0kpzZ62L2R6c/LUVYv7hVnZqcg2+sMuT6R7Jusu1vviK/MFsu6kNJfWlEQ==} + engines: {node: '>=4'} + dev: false + /string-hash@1.1.3: resolution: {integrity: sha512-kJUvRUFK49aub+a7T1nNE66EJbZBMnBgoC1UbCZ5n6bsZKBRga4KgBRTMn/pFkeCZSYtNeSyMxPDM0AXWELk2A==} dev: true diff --git a/common/config/subspaces/default/repo-state.json b/common/config/subspaces/default/repo-state.json index 26b7b44c0..ea7d44684 100644 --- a/common/config/subspaces/default/repo-state.json +++ b/common/config/subspaces/default/repo-state.json @@ -1,4 +1,4 @@ // DO NOT MODIFY THIS FILE MANUALLY BUT DO COMMIT IT. It is generated and used by Rush. { - "preferredVersionsHash": "683e562f9f3624bdf732fefc244584f915173525" + "preferredVersionsHash": "952e3e1a65c3a8705213d584aa5dcb7365b57a96" } diff --git a/common/config/subspaces/e2e-opencoze/pnpm-lock.yaml b/common/config/subspaces/e2e-opencoze/pnpm-lock.yaml index 9c2c3e3d2..4189ace54 100644 --- a/common/config/subspaces/e2e-opencoze/pnpm-lock.yaml +++ b/common/config/subspaces/e2e-opencoze/pnpm-lock.yaml @@ -23,7 +23,7 @@ overrides: tailwindcss@3.3.6>postcss: 8.4.49 '@types/react': 18.2.37 '@types/react-dom': 18.2.15 - '@coze-arch/coze-design': 0.0.6-alpha.101d0c + '@coze-arch/coze-design': 0.0.7-alpha.985c0d typescript: 5.8.2 importers: diff --git a/docker/.env.debug.example b/docker/.env.debug.example index 3623adf9d..4b30330d7 100644 --- a/docker/.env.debug.example +++ b/docker/.env.debug.example @@ -269,3 +269,9 @@ export PLUGIN_AES_STATE_SECRET='osj^kfhsd*(z!sno' # PLUGIN_AES_OAUTH_TOKEN_SECRET is the secret of used to encrypt oauth refresh token and access token. # The size of secret must be 16, 24 or 32 bytes. export PLUGIN_AES_OAUTH_TOKEN_SECRET='cn+$PJ(HhJ[5d*z9' + + +# Coze Saas API Configuration +export COZE_SAAS_PLUGIN_ENABLED="" # default "", if you want to enable, set to true +export COZE_SAAS_API_BASE_URL="https://api.coze.cn" +export COZE_SAAS_API_KEY="" diff --git a/docker/.env.example b/docker/.env.example index ea3bb661b..b8643f42a 100644 --- a/docker/.env.example +++ b/docker/.env.example @@ -271,3 +271,8 @@ export PLUGIN_AES_STATE_SECRET='osj^kfhsd*(z!sno' # PLUGIN_AES_OAUTH_TOKEN_SECRET is the secret of used to encrypt oauth refresh token and access token. # The size of secret must be 16, 24 or 32 bytes. export PLUGIN_AES_OAUTH_TOKEN_SECRET='cn+$PJ(HhJ[5d*z9' + +# Coze Saas API Configuration +export COZE_SAAS_PLUGIN_ENABLED="" # default "", if you want to enable, set to true +export COZE_SAAS_API_BASE_URL="https://api.coze.cn" +export COZE_SAAS_API_KEY="" diff --git a/docker/atlas/migrations/20251015103940_update.sql b/docker/atlas/migrations/20251015103940_update.sql new file mode 100644 index 000000000..da69719ab --- /dev/null +++ b/docker/atlas/migrations/20251015103940_update.sql @@ -0,0 +1,7 @@ +-- Modify "agent_tool_draft" table +ALTER TABLE `opencoze`.`agent_tool_draft` ADD COLUMN `source` tinyint NOT NULL DEFAULT 0 COMMENT "tool source 1 coze saas 0 default"; +-- Modify "agent_tool_version" table +ALTER TABLE `opencoze`.`agent_tool_version` ADD COLUMN `source` tinyint NOT NULL DEFAULT 0 COMMENT "tool source 1 coze saas 0 default"; + +-- Modify "shortcut_command" table +ALTER TABLE `opencoze`.`shortcut_command` ADD COLUMN `source` tinyint NULL DEFAULT 0 COMMENT "plugin source 1 coze saas 0 default"; diff --git a/docker/atlas/migrations/atlas.sum b/docker/atlas/migrations/atlas.sum index 43935af66..71ecec9b9 100644 --- a/docker/atlas/migrations/atlas.sum +++ b/docker/atlas/migrations/atlas.sum @@ -1,4 +1,4 @@ -h1:pZ9P9pFFqnfVc+o3V1CJLD8Rv3WyFM+mSwqKk1GTRRs= +h1:pI33vf1vp/2PZugeIpA8ZzR8pQQf1t91dmG2Yf9V1ro= 20250703095335_initial.sql h1:/joaeUTMhXqAEc0KwsSve5+bYM0qPOp+9OizJtsRc+U= 20250703115304_update.sql h1:cbYo6Q6Lh96hB4hu5KW2Nn/Mr0VDpg7a1WPgpIb1SOc= 20250704040445_update.sql h1:QWmoPY//oQ+GFZwET9w/oAWa8mM0KVaD5G8Yiu9bMqY= @@ -12,3 +12,4 @@ h1:pZ9P9pFFqnfVc+o3V1CJLD8Rv3WyFM+mSwqKk1GTRRs= 20250812093734_update.sql h1:27fQaPt0LYi1dA7MABvERthVR4pj4MRWFgdRVR3cd6w= 20250813081543_update.sql h1:HyBPu1LVs8oiyABbZDU3fFW0n6MeC7qOpzcHWVkwNVc= 20250822060516_update.sql h1:KoL8FPXw5/JMsJMtJsoGFIc4wYHlngBudeYSz5o4iKU= +20251015103940_update.sql h1:F5/wEP+Gjtnd3nYgUFiKaPdKpgedMqtnhSWpfUsf1c4= diff --git a/docker/atlas/opencoze_latest_schema.hcl b/docker/atlas/opencoze_latest_schema.hcl index c56c599ae..598926801 100644 --- a/docker/atlas/opencoze_latest_schema.hcl +++ b/docker/atlas/opencoze_latest_schema.hcl @@ -106,6 +106,12 @@ table "agent_tool_draft" { type = json comment = "Tool Openapi Operation Schema" } + column "source" { + null = false + type = tinyint + default = 0 + comment = "tool source 1 coze saas 0 default" + } primary_key { columns = [column.id] } @@ -197,6 +203,12 @@ table "agent_tool_version" { unsigned = true comment = "Create Time in Milliseconds" } + column "source" { + null = false + type = tinyint + default = 0 + comment = "tool source 1 coze saas 0 default" + } primary_key { columns = [column.id] } @@ -997,12 +1009,6 @@ table "conversation" { comment = "id" auto_increment = true } - column "name" { - null = true - type = varchar(255) - default = "" - comment = "conversation name" - } column "connector_id" { null = false type = bigint @@ -1061,6 +1067,12 @@ table "conversation" { unsigned = true comment = "Update Time in Milliseconds" } + column "name" { + null = true + type = varchar(255) + default = "" + comment = "conversation name" + } primary_key { columns = [column.id] } @@ -3012,6 +3024,12 @@ table "shortcut_command" { default = 0 comment = "tool_id" } + column "source" { + null = true + type = tinyint + default = 0 + comment = "plugin source 1 coze saas 0 default" + } primary_key { columns = [column.id] } @@ -3139,6 +3157,11 @@ table "single_agent_draft" { type = json comment = "Agent Database Base Configuration" } + column "shortcut_command" { + null = true + type = json + comment = "shortcut command" + } column "bot_mode" { null = false type = tinyint @@ -3150,11 +3173,6 @@ table "single_agent_draft" { type = text comment = "chatflow layout info" } - column "shortcut_command" { - null = true - type = json - comment = "shortcut command" - } primary_key { columns = [column.id] } @@ -3311,17 +3329,6 @@ table "single_agent_version" { unsigned = true comment = "Create Time in Milliseconds" } - column "bot_mode" { - null = false - type = tinyint - default = 0 - comment = "bot mode,0:single mode 2:chatflow mode" - } - column "layout_info" { - null = true - type = text - comment = "chatflow layout info" - } column "updated_at" { null = false type = bigint @@ -3406,6 +3413,17 @@ table "single_agent_version" { type = json comment = "shortcut command" } + column "bot_mode" { + null = false + type = tinyint + default = 0 + comment = "bot mode,0:single mode 2:chatflow mode" + } + column "layout_info" { + null = true + type = text + comment = "chatflow layout info" + } primary_key { columns = [column.id] } diff --git a/frontend/apps/coze-studio/src/routes/async-components.tsx b/frontend/apps/coze-studio/src/routes/async-components.tsx index 80574ab75..24964e2fd 100644 --- a/frontend/apps/coze-studio/src/routes/async-components.tsx +++ b/frontend/apps/coze-studio/src/routes/async-components.tsx @@ -114,6 +114,13 @@ export const WorkflowPage = lazy(() => })), ); +// search page +export const SearchPage = lazy(() => + import('@coze-community/explore').then(exps => ({ + default: exps.SearchPage, + })), +); + // plugin resource page layout component export const PluginLayout = lazy(() => import('../pages/plugin/layout')); diff --git a/frontend/apps/coze-studio/src/routes/index.tsx b/frontend/apps/coze-studio/src/routes/index.tsx index a8b799570..db09942b2 100644 --- a/frontend/apps/coze-studio/src/routes/index.tsx +++ b/frontend/apps/coze-studio/src/routes/index.tsx @@ -33,6 +33,7 @@ import { spaceSubMenu, exploreSubMenu, WorkflowPage, + SearchPage, ProjectIDE, ProjectIDEPublish, Library, @@ -248,6 +249,16 @@ export const router: ReturnType = }), }, + // search + { + path: 'search/:word', + Component: SearchPage, + loader: () => ({ + hasSider: true, + requireAuth: true, + }), + }, + // explore { path: 'explore', diff --git a/frontend/packages/agent-ide/bot-plugin/export/src/component/agent-skill-plugin-modal/use-request-cache.tsx b/frontend/packages/agent-ide/bot-plugin/export/src/component/agent-skill-plugin-modal/use-request-cache.tsx index fe3acb6b0..280f011d8 100644 --- a/frontend/packages/agent-ide/bot-plugin/export/src/component/agent-skill-plugin-modal/use-request-cache.tsx +++ b/frontend/packages/agent-ide/bot-plugin/export/src/component/agent-skill-plugin-modal/use-request-cache.tsx @@ -16,8 +16,8 @@ import { type MutableRefObject, useEffect } from 'react'; -import { setCache, getCache, clearCache } from '@coze-arch/bot-utils'; import { type InfiniteListDataProps } from '@coze-community/components'; +import { setCache, getCache, clearCache } from '@coze-arch/bot-utils'; import { DEFAULT_PAGE_SIZE, MineActiveEnum, @@ -48,6 +48,7 @@ export interface InfiniteScrollViewportOptions< isTemplate: boolean; isFavorite: boolean; isProject: boolean; + isCoze: boolean; }, ) => Promise | undefined>; // @ts-expect-error -- linter-disable-autofix @@ -80,6 +81,7 @@ export function useInfiniteScrollCacheLoad< const isTeam = type === PluginFilterType.Team; const isFavorite = type === PluginFilterType.Favorite; const isProject = type === PluginFilterType.Project; + const isCoze = type === PluginFilterType.Coze; // team tools -> my creator const isCreatorMine = mineActive === MineActiveEnum.Mine; @@ -152,6 +154,7 @@ export function useInfiniteScrollCacheLoad< isTemplate, isFavorite, isProject, + isCoze, }); setCacheData(cachedKey, DEFAULT_CACHE_TIME, res); } diff --git a/frontend/packages/agent-ide/plugin-modal-adapter/package.json b/frontend/packages/agent-ide/plugin-modal-adapter/package.json index 912ad58b5..46bc45f4e 100644 --- a/frontend/packages/agent-ide/plugin-modal-adapter/package.json +++ b/frontend/packages/agent-ide/plugin-modal-adapter/package.json @@ -21,6 +21,8 @@ "@coze-arch/coze-design": "0.0.6-alpha.346d77", "@coze-arch/i18n": "workspace:*", "@coze-common/assets": "workspace:*", + "@coze-studio/api-schema": "workspace:*", + "ahooks": "^3.7.8", "classnames": "^2.3.2" }, "devDependencies": { diff --git a/frontend/packages/agent-ide/plugin-modal-adapter/src/components/plugin-modal/plugin-filter/index.tsx b/frontend/packages/agent-ide/plugin-modal-adapter/src/components/plugin-modal/plugin-filter/index.tsx index cc593169a..734c33988 100644 --- a/frontend/packages/agent-ide/plugin-modal-adapter/src/components/plugin-modal/plugin-filter/index.tsx +++ b/frontend/packages/agent-ide/plugin-modal-adapter/src/components/plugin-modal/plugin-filter/index.tsx @@ -13,9 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - import classNames from 'classnames'; +import { useRequest } from 'ahooks'; +import { explore } from '@coze-studio/api-schema'; import { I18n } from '@coze-arch/i18n'; +import { IconCozDesktopFill, IconCozCoze } from '@coze-arch/coze-design/icons'; import { useSpaceStore } from '@coze-arch/bot-studio-store'; import { UICompositionModalSider } from '@coze-arch/bot-semi'; import { IconMyTools, IconTeamTools } from '@coze-arch/bot-icons'; @@ -47,6 +49,12 @@ export const PluginFilter: React.FC = ({ }) => { const spaceType = useSpaceStore(store => store.space.space_type); const defaultId = getDefaultPluginCategory().id; + + const { data: enableSaaSPlugin } = useRequest(async () => { + const res = await explore.PublicGetMarketPluginConfig({}); + return res.data?.enable_saas_plugin || false; + }); + const onChangeAfterDiff = (freshType: typeof type) => { // If you are searching, leave the search blank if (isSearching) { @@ -97,9 +105,24 @@ export const PluginFilter: React.FC = ({ })} onClick={() => onChangeAfterDiff(defaultId)} > + {I18n.t('explore_tools')} + + {enableSaaSPlugin ? ( +
+
onChangeAfterDiff(PluginFilterType.Coze)} + > + + Coze.cn 插件 +
+
+ ) : null} ) : null} diff --git a/frontend/packages/agent-ide/plugin-modal-adapter/tsconfig.build.json b/frontend/packages/agent-ide/plugin-modal-adapter/tsconfig.build.json index beecc92fd..c985b2b6a 100644 --- a/frontend/packages/agent-ide/plugin-modal-adapter/tsconfig.build.json +++ b/frontend/packages/agent-ide/plugin-modal-adapter/tsconfig.build.json @@ -12,6 +12,9 @@ "include": ["src"], "exclude": ["node_modules", "dist"], "references": [ + { + "path": "../../arch/api-schema/tsconfig.build.json" + }, { "path": "../../arch/bot-api/tsconfig.build.json" }, diff --git a/frontend/packages/agent-ide/plugin-shared/src/components/plugin-panel/activate-popover/index.tsx b/frontend/packages/agent-ide/plugin-shared/src/components/plugin-panel/activate-popover/index.tsx new file mode 100644 index 000000000..81f05b997 --- /dev/null +++ b/frontend/packages/agent-ide/plugin-shared/src/components/plugin-panel/activate-popover/index.tsx @@ -0,0 +1,70 @@ +/* + * 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. + */ + +import { type FC, type PropsWithChildren } from 'react'; + +// import { I18n } from '@coze-arch/i18n'; +import { IconCozDiamondFill } from '@coze-arch/coze-design/icons'; +import { AIButton, Popover, Space } from '@coze-arch/coze-design'; + +export interface ActivatePopoverProps { + id?: string; + show?: boolean; +} + +// 去开通popover弹窗 +export const ActivatePopover: FC> = ({ + children, + id, + show = true, +}) => + !show ? ( + children + ) : ( + + + + 此插件需要管理员开通后使用 + + +
+ 此插件为三方付费插件,需要开通后使用。 +
+ +
+ { + window.open( + `https://www.coze.cn/store/plugin/${id}?from=coze-studio-open`, + '_blank', + ); + }} + > + 去开通 + +
+ + } + showArrow + > + {children} +
+ ); diff --git a/frontend/packages/agent-ide/plugin-shared/src/components/plugin-panel/index.tsx b/frontend/packages/agent-ide/plugin-shared/src/components/plugin-panel/index.tsx index b46cad2d0..6f1695466 100644 --- a/frontend/packages/agent-ide/plugin-shared/src/components/plugin-panel/index.tsx +++ b/frontend/packages/agent-ide/plugin-shared/src/components/plugin-panel/index.tsx @@ -69,6 +69,8 @@ import { PluginType, } from '@coze-arch/bot-api/plugin_develop'; import { type Int64 } from '@coze-arch/bot-api/developer_api'; +import { ProductEntityType } from '@coze-arch/bot-api/product_api'; +import { PluginFrom } from '@coze-arch/bot-api/playground_api'; import s from './index.module.less'; import { type SimplifyProductInfo } from '../../service/fetch-plugin'; @@ -84,7 +86,7 @@ import { IconCozDesktop, IconCozInfoCircle, } from '@coze-arch/coze-design/icons'; - +import { ActivatePopover } from './activate-popover'; import { isBoolean, isUndefined } from 'lodash-es'; import { type CommercialSetting, @@ -249,19 +251,29 @@ export const PluginPanel: React.FC = ({ const timePrefixText = showPublishTime ? I18n.t('mkl_plugin_publish') : showCreateTime - ? I18n.t('mkl_plugin_created') - : I18n.t('mkl_plugin_updated'); + ? I18n.t('mkl_plugin_created') + : I18n.t('mkl_plugin_updated'); const timeToShow = (showPublishTime ? Number(listed_at) : showCreateTime - ? Number(create_time) - : Number(update_time)) || 0; + ? Number(create_time) + : Number(update_time)) || 0; const renderAuthStatus = () => { if (isUndefined(auth_mode) || auth_mode === PluginAuthMode.NoAuth) { return null; } + if (auth_mode === PluginAuthMode.NeedInstalled) { + return ( + + + 待开通 + + + ); + } + if ( auth_mode === PluginAuthMode.Required || auth_mode === PluginAuthMode.Supported @@ -479,7 +491,9 @@ export const PluginPanel: React.FC = ({ data-testid="plugin-panel-item-pluginapi" isAdded={isAdded} pluginApi={api} + productId={productInfo?.id} from={from} + auth_mode={auth_mode} workflowNodes={ pluginApiNodesMap[`${api?.plugin_id}_${api?.api_id}`] ?? [] } @@ -531,6 +545,10 @@ export const PluginPanel: React.FC = ({ project_id, version_name, version_ts, + plugin_from: + productInfo?.entity_type === ProductEntityType.SaasPlugin + ? PluginFrom.FromSaas + : PluginFrom.Default, }; // Check whether the name of the Plugins currently to be added has a duplicate name in the added list (the model does not support it, so this is added) if ( @@ -559,6 +577,10 @@ export const PluginPanel: React.FC = ({ PluginType.PLUGIN, PluginType.APP, PluginType.LOCAL, + ...(productInfo?.entity_type === + ProductEntityType.SaasPlugin + ? [ProductEntityType.SaasPlugin] + : []), ], space_id: useSpaceStore.getState().getSpaceId(), }); diff --git a/frontend/packages/agent-ide/plugin-shared/src/components/plugin-panel/item.tsx b/frontend/packages/agent-ide/plugin-shared/src/components/plugin-panel/item.tsx index 4e757d741..a84ebeb8e 100644 --- a/frontend/packages/agent-ide/plugin-shared/src/components/plugin-panel/item.tsx +++ b/frontend/packages/agent-ide/plugin-shared/src/components/plugin-panel/item.tsx @@ -25,6 +25,7 @@ import { type WorkflowNodeJSON } from '@flowgram-adapter/free-layout-editor'; import { ParametersPopover } from '@coze-studio/components/parameters-popover'; import { CardThumbnailPopover } from '@coze-studio/components'; import { I18n } from '@coze-arch/i18n'; +import { Popconfirm } from '@coze-arch/coze-design'; import { Space, Tooltip, @@ -35,11 +36,12 @@ import { import { ProductStatus, type public_api } from '@coze-arch/bot-api/product_api'; import { type PluginApi } from '@coze-arch/bot-api/plugin_develop'; import { useViewExample } from '@coze-agent-ide/bot-plugin-tools/useViewExample'; -import { Popconfirm } from '@coze-arch/coze-design'; import { OverflowList } from '@blueprintjs/core'; import { From } from '../../types/plugin-modal-types'; +import { PluginAuthMode } from '../../types/auth-mode'; import { PluginPerfStatics } from './plugin-perf-statics'; +import { ActivatePopover } from './activate-popover'; import s from './index.module.less'; @@ -57,6 +59,8 @@ export interface PluginItemProps { marketPluginInfo?: PluginToolInfo; isLocalPlugin?: boolean; connectors?: string[]; + auth_mode?: PluginAuthMode; + productId?: string; } interface OverflowTagItem { @@ -77,6 +81,8 @@ export const PluginItem: React.FC = ({ marketPluginInfo, isLocalPlugin, connectors, + auth_mode, + productId, }) => { const { name, desc, parameters, debug_example } = pluginApi; const { exampleNode, doShowExample } = useViewExample(); @@ -105,7 +111,9 @@ export const PluginItem: React.FC = ({ {item.tagName} ); - const isDisabled = marketStatus === ProductStatus?.Unlisted; + const isDisabled = + marketStatus === ProductStatus?.Unlisted || + auth_mode === PluginAuthMode.NeedInstalled; // The end plug-in has not been added, and the applicable channel is prompted. const showAddConfirm = isLocalPlugin && @@ -218,42 +226,49 @@ export const PluginItem: React.FC = ({ content={I18n.t('mkpl_plugin_delisted_tips')} trigger={isDisabled ? 'hover' : 'custom'} > - { - if (showAddConfirm) { - return; - } - onApiToggle?.().then(isSuccess => { - if (isSuccess) { - setCount(prev => prev + 1); - } - }); - }} - onMouseEnter={onMouseEnter} - disabled={isDisabled} - loading={loading && isFromWorkflow} - onMouseLeave={onMouseLeave} + - {isAdded && !isDisabled ? ( - isMouseIn ? ( - I18n.t('Remove') + { + if (showAddConfirm) { + return; + } + onApiToggle?.().then(isSuccess => { + if (isSuccess) { + setCount(prev => prev + 1); + } + }); + }} + onMouseEnter={onMouseEnter} + disabled={isDisabled} + loading={loading && isFromWorkflow} + onMouseLeave={onMouseLeave} + > + {isAdded && !isDisabled ? ( + isMouseIn ? ( + I18n.t('Remove') + ) : ( + I18n.t('Added') + ) ) : ( - I18n.t('Added') - ) - ) : ( - <> - {I18n.t('Add_1')} - {isFromWorkflow && count !== 0 ? ( - {count} - ) : null} - - )} - + <> + {I18n.t('Add_1')} + {isFromWorkflow && count !== 0 ? ( + + {count} + + ) : null} + + )} + + diff --git a/frontend/packages/agent-ide/plugin-shared/src/constants/plugin-modal-constants.ts b/frontend/packages/agent-ide/plugin-shared/src/constants/plugin-modal-constants.ts index 4bd1a180a..e1dd43ed3 100644 --- a/frontend/packages/agent-ide/plugin-shared/src/constants/plugin-modal-constants.ts +++ b/frontend/packages/agent-ide/plugin-shared/src/constants/plugin-modal-constants.ts @@ -26,4 +26,6 @@ export enum PluginFilterType { Team = 'team', Favorite = 'favorite', Project = 'project', + Local = 'local', + Coze = 'coze', } diff --git a/frontend/packages/agent-ide/plugin-shared/src/service/fetch-plugin.ts b/frontend/packages/agent-ide/plugin-shared/src/service/fetch-plugin.ts index 1cc75ef10..e0a07ea2f 100644 --- a/frontend/packages/agent-ide/plugin-shared/src/service/fetch-plugin.ts +++ b/frontend/packages/agent-ide/plugin-shared/src/service/fetch-plugin.ts @@ -157,7 +157,7 @@ async function getPluginFromMarket( // @ts-expect-error -- linter-disable-autofix commParams, ): Promise | undefined> { - const { nextPage } = commParams; + const { nextPage, isCoze } = commParams; const { search, @@ -170,7 +170,9 @@ async function getPluginFromMarket( const res = await ProductApi.PublicGetProductList( { - entity_type: ProductEntityType.Plugin, + entity_type: isCoze + ? ProductEntityType.SaasPlugin + : ProductEntityType.Plugin, category_id: type === 'recommend' || IS_OPEN_SOURCE ? undefined : type, sort_type: orderByPublic, page_num: nextPage, diff --git a/frontend/packages/agent-ide/plugin-shared/src/types/auth-mode.ts b/frontend/packages/agent-ide/plugin-shared/src/types/auth-mode.ts index dc3a58424..b33def927 100644 --- a/frontend/packages/agent-ide/plugin-shared/src/types/auth-mode.ts +++ b/frontend/packages/agent-ide/plugin-shared/src/types/auth-mode.ts @@ -24,6 +24,8 @@ export enum PluginAuthMode { Configured = 2, /** Authorization is required, but the configuration can be empty */ Supported = 3, + /** Authorization is required, but the configuration can be empty */ + NeedInstalled = 9, } export interface AuthMode { diff --git a/frontend/packages/agent-ide/plugin-shared/src/types/plugin-modal-types.ts b/frontend/packages/agent-ide/plugin-shared/src/types/plugin-modal-types.ts index 38b127612..6dbb4c856 100644 --- a/frontend/packages/agent-ide/plugin-shared/src/types/plugin-modal-types.ts +++ b/frontend/packages/agent-ide/plugin-shared/src/types/plugin-modal-types.ts @@ -22,6 +22,7 @@ import { type SortType, } from '@coze-arch/bot-api/product_api'; import { type PluginInfoForPlayground } from '@coze-arch/bot-api/plugin_develop'; +import { type PluginFrom } from '@coze-arch/bot-api/playground_api'; import { type OrderBy, type PluginApi } from '@coze-arch/bot-api/developer_api'; import { type MineActiveEnum } from '../constants/plugin-modal-constants'; @@ -97,6 +98,7 @@ export interface PluginModalModeProps { project_id?: string; version_name?: string; version_ts?: string; + plugin_from?: PluginFrom; }, ) => void; showButton?: boolean; diff --git a/frontend/packages/arch/api-schema/src/idl/marketplace/product_common.ts b/frontend/packages/arch/api-schema/src/idl/marketplace/product_common.ts index 449889c91..177342208 100644 --- a/frontend/packages/arch/api-schema/src/idl/marketplace/product_common.ts +++ b/frontend/packages/arch/api-schema/src/idl/marketplace/product_common.ts @@ -16,6 +16,18 @@ import * as marketplace_common from './marketplace_common'; export { marketplace_common }; +export enum BotModType { + SingleAgent = 1, + MultiAgent = 2, +} +export enum Component { + UsePlugin = 1, + UseWorkFlow = 2, + UseKnowledge = 3, + UseVoice = 4, + UseCard = 5, + UseImageWorkflow = 6, +} export enum ProductEntityType { Bot = 1, Plugin = 2, @@ -45,6 +57,8 @@ export enum ProductEntityType { Common = 99, /** Special Topics (Compatible with previous designs) */ Topic = 101, + /** Saas plugin,the plugins from coze saas */ + SaasPlugin = 901, } export enum SortType { Heat = 1, diff --git a/frontend/packages/arch/api-schema/src/idl/marketplace/public_api.ts b/frontend/packages/arch/api-schema/src/idl/marketplace/public_api.ts index 3ba776f2a..ee1f97d7f 100644 --- a/frontend/packages/arch/api-schema/src/idl/marketplace/public_api.ts +++ b/frontend/packages/arch/api-schema/src/idl/marketplace/public_api.ts @@ -87,6 +87,136 @@ export const PublicDuplicateProduct = /*#__PURE__*/createAPI({ + "url": "/api/marketplace/product/search", + "method": "GET", + "name": "PublicSearchProduct", + "reqType": "SearchProductRequest", + "reqMapping": { + "query": ["keyword", "page_num", "page_size", "entity_type", "sort_type", "publish_mode", "model_ids", "bot_mod_type", "components", "publish_platform_ids", "category_ids", "is_official", "is_recommend", "entity_types", "plugin_type", "product_paid_type"] + }, + "resType": "SearchProductResponse", + "schemaRoot": "api://schemas/idl_marketplace_public_api", + "service": "explore" +}); +export const PublicSearchSuggest = /*#__PURE__*/createAPI({ + "url": "/api/marketplace/product/search/suggest", + "method": "GET", + "name": "PublicSearchSuggest", + "reqType": "SearchSuggestRequest", + "reqMapping": { + "query": ["keyword", "entity_type", "page_num", "page_size", "entity_types"] + }, + "resType": "SearchSuggestResponse", + "schemaRoot": "api://schemas/idl_marketplace_public_api", + "service": "explore" +}); +export const PublicGetProductCategoryList = /*#__PURE__*/createAPI({ + "url": "/api/marketplace/product/category/list", + "method": "GET", + "name": "PublicGetProductCategoryList", + "reqType": "GetProductCategoryListRequest", + "reqMapping": { + "query": ["entity_type", "need_empty_category", "lang"] + }, + "resType": "GetProductCategoryListResponse", + "schemaRoot": "api://schemas/idl_marketplace_public_api", + "service": "explore" +}); +export const PublicGetProductCallInfo = /*#__PURE__*/createAPI({ + "url": "/api/marketplace/product/call_info", + "method": "GET", + "name": "PublicGetProductCallInfo", + "reqType": "GetProductCallInfoRequest", + "reqMapping": { + "query": ["entity_type", "entity_id", "enterprise_id"] + }, + "resType": "GetProductCallInfoResponse", + "schemaRoot": "api://schemas/idl_marketplace_public_api", + "service": "explore" +}); +export const PublicGetMarketPluginConfig = /*#__PURE__*/createAPI({ + "url": "/api/marketplace/product/config", + "method": "GET", + "name": "PublicGetMarketPluginConfig", + "reqType": "GetMarketPluginConfigRequest", + "reqMapping": {}, + "resType": "GetMarketPluginConfigResponse", + "schemaRoot": "api://schemas/idl_marketplace_public_api", + "service": "explore" +}); +export interface GetMarketPluginConfigRequest {} +export interface GetMarketPluginConfigResponse { + code: number, + message: string, + data?: Configuration, +} +export interface Configuration { + enable_saas_plugin?: boolean +} +export interface SearchProductRequest { + keyword: string, + page_num: number, + page_size: number, + entity_type?: product_common.ProductEntityType, + sort_type?: product_common.SortType, + /** Open/closed source */ + publish_mode?: product_common.ProductPublishMode, + /** Models used */ + model_ids?: string[], + /** Multimodal type */ + bot_mod_type?: product_common.BotModType, + /** Sub-attributes */ + components?: product_common.Component[], + /** Publish platform IDs */ + publish_platform_ids?: string[], + /** Product category IDs */ + category_ids?: string[], + /** Is official */ + is_official?: boolean, + /** Is recommended */ + is_recommend?: boolean, + /** Product type list, use this parameter first, then EntityType */ + entity_types?: string, + /** Plugin type */ + plugin_type?: product_common.PluginType, + /** Product paid type */ + product_paid_type?: product_common.ProductPaidType, +} +export interface SearchProductResponse { + code: number, + message: string, + data?: SearchProductResponseData, +} +export interface SearchProductResponseData { + products?: ProductInfo[], + total?: number, + has_more?: boolean, + /** Entity count */ + entity_total?: { + [key: string | number]: number + }, +} +export interface SearchSuggestResponse { + code: number, + message: string, + data?: SearchSuggestResponseData, +} +export interface SearchSuggestResponseData { + /** Deprecated */ + suggestions?: ProductMetaInfo[], + has_more?: boolean, + suggestion_v2?: ProductInfo[], +} +export interface SearchSuggestRequest { + keyword?: string, + /** Optional, defaults to bot recommendation if not provided */ + entity_type?: product_common.ProductEntityType, + page_num?: number, + page_size?: number, + /** Product type list, use this parameter first, then EntityType */ + entity_types?: string, +} export interface FavoriteProductResponse { code: number, message: string, @@ -234,6 +364,8 @@ export enum PluginAuthMode { Configured = 2, /** Authorization is required, but the authorization configuration may be user-level and can be configured by the user himself */ Supported = 3, + /** the third-party of coze saas plugin needs to be installed in the saas before it can be used. */ + NeedInstalled = 9, } export interface PluginExtraInfo { tools?: PluginToolInfo[], @@ -259,6 +391,7 @@ export interface PluginExtraInfo { plugin_type?: product_common.PluginType, /** for opencoze */ auth_mode?: PluginAuthMode, + jump_saas_url?: string, } export interface ToolParameter { name: string, @@ -726,4 +859,96 @@ export interface DuplicateProductData { new_entity_id: string, /** Plugin ID for workflow */ new_plugin_id?: string, +} +export interface GetProductCategoryListRequest { + entity_type: product_common.ProductEntityType, + /** When listing, need to get the full category list to distinguish between listing and homepage scenarios */ + need_empty_category?: boolean, + lang?: string, +} +export interface GetProductCategoryListData { + entity_type: product_common.ProductEntityType, + categories?: ProductCategory[], +} +export interface GetProductCategoryListResponse { + code: number, + message: string, + data: GetProductCategoryListData, +} +export interface GetProductCallInfoRequest { + entity_type: product_common.ProductEntityType, + entity_id?: string, + enterprise_id?: string, +} +export enum UserLevel { + /** Free version */ + Free = 0, + /** + * Overseas + * PremiumLite + */ + PremiumLite = 10, + /** Premium */ + Premium = 15, + PremiumPlus = 20, + /** + * Domestic + * V1 Volcano Professional Edition + */ + V1ProInstance = 100, + /** Personal flagship edition */ + ProPersonal = 110, + /** Team edition */ + Team = 120, + /** Enterprise edition */ + Enterprise = 130, +} +export interface ProductCallCountLimit { + /** Whether plugin tool calls are unlimited */ + is_unlimited: boolean, + /** Plugin tool calls used */ + used_count: number, + /** Plugin total tool calls */ + total_count: number, + /** Plugin tool call count reset time */ + reset_datetime: number, + /** Plugin tool call count limit by user level */ + call_count_limit_by_user_level: { + [key: string | number]: ProductCallCountLimit + }, +} +export interface ProductCallRateLimit { + /** qps */ + qps: number, + /** Plugin tool call rate limit by user level */ + call_rate_limit_by_user_level: { + [key: string | number]: ProductCallRateLimit + }, +} +export interface UserInfo { + /** User name */ + user_name?: string, + /** User nickname */ + nick_name?: string, + /** User avatar url */ + avatar_url?: string, +} +export interface GetProductCallInfoData { + /** mcp configuration json string */ + mcp_json: string, + /** Payment level */ + user_level: UserLevel, + /** Plugin tool call count limit */ + call_count_limit: ProductCallCountLimit, + /** Plugin tool call rate limit */ + call_rate_limit: ProductCallRateLimit, + /** User info */ + user_info: UserInfo, + /** Enterprise revert time */ + revert_time?: string, +} +export interface GetProductCallInfoResponse { + code: number, + message: string, + data?: GetProductCallInfoData, } \ No newline at end of file diff --git a/frontend/packages/arch/idl/src/auto-generated/playground_api/index.ts b/frontend/packages/arch/idl/src/auto-generated/playground_api/index.ts index c131cb320..2c3e9ecf7 100644 --- a/frontend/packages/arch/idl/src/auto-generated/playground_api/index.ts +++ b/frontend/packages/arch/idl/src/auto-generated/playground_api/index.ts @@ -14,7 +14,6 @@ * limitations under the License. */ -// THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. /* eslint-disable */ /* tslint:disable */ // @ts-nocheck @@ -26,6 +25,7 @@ import * as bot_task_common from './namespaces/bot_task_common'; import * as douyin_fenshen from './namespaces/douyin_fenshen'; import * as frontier from './namespaces/frontier'; import * as long_term_memory from './namespaces/long_term_memory'; +import * as model from './namespaces/model'; import * as op from './namespaces/op'; import * as open_api_playground from './namespaces/open_api_playground'; import * as playground from './namespaces/playground'; @@ -45,6 +45,7 @@ export { douyin_fenshen, frontier, long_term_memory, + model, op, open_api_playground, playground, @@ -63,6 +64,7 @@ export * from './namespaces/bot_task_common'; export * from './namespaces/douyin_fenshen'; export * from './namespaces/frontier'; export * from './namespaces/long_term_memory'; +export * from './namespaces/model'; export * from './namespaces/op'; export * from './namespaces/open_api_playground'; export * from './namespaces/playground'; @@ -1388,6 +1390,24 @@ export default class PlaygroundApiService { return this.request({ url, method, data }, options); } + /** POST /v1/workspaces */ + OpenCreateSpace( + req?: open_api_playground.OpenCreateSpaceRequest, + options?: T, + ): Promise { + const _req = req || {}; + const url = this.genBaseURL('/v1/workspaces'); + const method = 'POST'; + const data = { + name: _req['name'], + description: _req['description'], + icon_file_id: _req['icon_file_id'], + coze_account_id: _req['coze_account_id'], + owner_uid: _req['owner_uid'], + }; + return this.request({ url, method, data }, options); + } + /** POST /api/playground_api/notice/mark_read */ NoticeMarkRead( req?: playground.NoticeMarkReadRequest, @@ -1448,6 +1468,7 @@ export default class PlaygroundApiService { enterprise_id: _req['enterprise_id'], user_id: _req['user_id'], coze_account_id: _req['coze_account_id'], + scope: _req['scope'], }; return this.request({ url, method, params }, options); } @@ -2214,6 +2235,8 @@ export default class PlaygroundApiService { tags: _req['tags'], time_capsule_item_type: _req['time_capsule_item_type'], iid: _req['iid'], + meta_type: _req['meta_type'], + memory_type: _req['memory_type'], }; return this.request({ url, method, data }, options); } @@ -2250,6 +2273,7 @@ export default class PlaygroundApiService { biz_ids: _req['biz_ids'], time_capsule_item_type: _req['time_capsule_item_type'], iids: _req['iids'], + memory_meta_type_map: _req['memory_meta_type_map'], }; return this.request({ url, method, data }, options); } @@ -2352,5 +2376,114 @@ export default class PlaygroundApiService { }; return this.request({ url, method, params }, options); } + + /** POST /v1/workspaces/:workspace_id/members/apply */ + OpenApplyJoinSpace( + req?: open_api_playground.OpenApplyJoinSpaceRequest, + options?: T, + ): Promise { + const _req = req || {}; + const url = this.genBaseURL( + `/v1/workspaces/${_req['workspace_id']}/members/apply`, + ); + const method = 'POST'; + const data = { user_ids: _req['user_ids'] }; + return this.request({ url, method, data }, options); + } + + /** DELETE /v1/workspaces/:workspace_id */ + OpenRemoveSpace( + req?: open_api_playground.OpenRemoveSpaceRequest, + options?: T, + ): Promise { + const _req = req || {}; + const url = this.genBaseURL(`/v1/workspaces/${_req['workspace_id']}`); + const method = 'DELETE'; + return this.request({ url, method }, options); + } + + /** + * POST /api/playground_api/get_type_list + * + * 获取空间下的模型列表(从develpper_api迁移过来) + */ + GetTypeList( + req?: playground.GetTypeListRequest, + options?: T, + ): Promise { + const _req = req || {}; + const url = this.genBaseURL('/api/playground_api/get_type_list'); + const method = 'POST'; + const data = { + model: _req['model'], + voice: _req['voice'], + raw_model: _req['raw_model'], + space_id: _req['space_id'], + cur_model_id: _req['cur_model_id'], + cur_model_ids: _req['cur_model_ids'], + model_scene: _req['model_scene'], + tag_filters: _req['tag_filters'], + }; + return this.request({ url, method, data }, options); + } + + /** + * POST /api/playground_api/get_coze_lane_info + * + * 根据用户信息、权益信息等获取泳道信息并设置到cookie + */ + GetCozeLaneInfo( + req?: playground.GetCozeLaneInfoRequest, + options?: T, + ): Promise { + const url = this.genBaseURL('/api/playground_api/get_coze_lane_info'); + const method = 'POST'; + return this.request({ url, method }, options); + } + + /** PUT /v1/workspaces/:workspace_id/members/:user_id */ + OpenUpdateSpaceMember( + req?: open_api_playground.OpenUpdateSpaceMemberRequest, + options?: T, + ): Promise { + const _req = req || {}; + const url = this.genBaseURL( + `/v1/workspaces/${_req['workspace_id']}/members/${_req['user_id']}`, + ); + const method = 'PUT'; + const data = { role_type: _req['role_type'] }; + return this.request({ url, method, data }, options); + } + + /** GET /v1/bots/:bot_id/versions */ + OpenListBotVersions( + req?: open_api_playground.OpenListBotVersionsRequest, + options?: T, + ): Promise { + const _req = req || {}; + const url = this.genBaseURL(`/v1/bots/${_req['bot_id']}/versions`); + const method = 'GET'; + const params = { + page_num: _req['page_num'], + page_size: _req['page_size'], + publish_status: _req['publish_status'], + connector_id: _req['connector_id'], + }; + return this.request({ url, method, params }, options); + } + + /** POST /v1/bots/:bot_id/collaboration_mode */ + OpenSwitchBotDevelopMode( + req?: open_api_playground.OpenSwitchBotDevelopModeRequest, + options?: T, + ): Promise { + const _req = req || {}; + const url = this.genBaseURL( + `/v1/bots/${_req['bot_id']}/collaboration_mode`, + ); + const method = 'POST'; + const data = { collaboration_mode: _req['collaboration_mode'] }; + return this.request({ url, method, data }, options); + } } /* eslint-enable */ diff --git a/frontend/packages/arch/idl/src/auto-generated/playground_api/namespaces/base.ts b/frontend/packages/arch/idl/src/auto-generated/playground_api/namespaces/base.ts index 33bb4bbe4..b266270b8 100644 --- a/frontend/packages/arch/idl/src/auto-generated/playground_api/namespaces/base.ts +++ b/frontend/packages/arch/idl/src/auto-generated/playground_api/namespaces/base.ts @@ -14,7 +14,6 @@ * limitations under the License. */ -// THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. /* eslint-disable */ /* tslint:disable */ // @ts-nocheck diff --git a/frontend/packages/arch/idl/src/auto-generated/playground_api/namespaces/bot_common.ts b/frontend/packages/arch/idl/src/auto-generated/playground_api/namespaces/bot_common.ts index 880933d3a..8f8cd8de6 100644 --- a/frontend/packages/arch/idl/src/auto-generated/playground_api/namespaces/bot_common.ts +++ b/frontend/packages/arch/idl/src/auto-generated/playground_api/namespaces/bot_common.ts @@ -14,7 +14,6 @@ * limitations under the License. */ -// THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. /* eslint-disable */ /* tslint:disable */ // @ts-nocheck @@ -295,6 +294,12 @@ export enum ParamSource { Variable = 1, } +export enum PluginFrom { + /** 插件来源 opencoze 使用 */ + Default = 0, + FromSaas = 1, +} + export enum PromptMode { Standard = 0, /** 前缀提示词 */ @@ -414,6 +419,11 @@ export enum TimeCapsuleMode { On = 1, } +export enum TimeCapsuleType { + CozeOldTimeCapsule = 0, + VolcanoTimeCapsule = 1, +} + export enum WorkflowMode { Workflow = 0, Imageflow = 1, @@ -645,6 +655,8 @@ export interface BotInfo { /** workflow模式的编排信息 */ layout_info?: LayoutInfo; business_type?: BusinessType; + time_capsule_type?: TimeCapsuleType; + time_capsule_info?: TimeCapsuleInfo; } /** bot信息 for 更新 */ @@ -699,7 +711,7 @@ export interface BotInfoForUpdate { agents?: Array; /** Bot种类 */ bot_species?: BotSpecies; - /** bot tag 信息,用户新增字段 */ + /** bot tag 信息,用户新增字段(存量长期记忆的Bot用这个字段) */ bot_tag_info?: BotTagInfo; /** filebox 信息 */ filebox_info?: FileboxInfo; @@ -713,6 +725,10 @@ export interface BotInfoForUpdate { user_query_collect_conf?: UserQueryCollectConf; /** workflow模式的编排信息 */ layout_info?: LayoutInfo; + /** Bot的长期记忆类型 */ + time_capsule_type?: TimeCapsuleType; + /** 新版长期记忆Bot的长期记忆用这个配置 */ + time_capsule_info?: TimeCapsuleInfo; } export interface BotTagInfo { @@ -1019,6 +1035,8 @@ export interface PluginInfo { api_id?: string; /** api name O项目用 */ api_name?: string; + /** 区分插件来源,开源版本使用字段 */ + plugin_from?: PluginFrom; } export interface PluginParameter { @@ -1192,6 +1210,12 @@ export interface TimeCapsuleInfo { disable_prompt_calling?: DisablePromptCalling; /** 时间胶囊过期时间,单位天(0表示永久有效) */ time_capsule_time_to_live?: string; + /** 记忆库id */ + memorybase_id?: string; + /** 记忆库名称 */ + memorybase_name?: string; + /** 记忆库简介 */ + memorybase_desc?: string; } export interface Usage { diff --git a/frontend/packages/arch/idl/src/auto-generated/playground_api/namespaces/bot_open_api.ts b/frontend/packages/arch/idl/src/auto-generated/playground_api/namespaces/bot_open_api.ts index 70e494806..18a61b8bc 100644 --- a/frontend/packages/arch/idl/src/auto-generated/playground_api/namespaces/bot_open_api.ts +++ b/frontend/packages/arch/idl/src/auto-generated/playground_api/namespaces/bot_open_api.ts @@ -14,7 +14,6 @@ * limitations under the License. */ -// THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. /* eslint-disable */ /* tslint:disable */ // @ts-nocheck @@ -109,6 +108,8 @@ export interface BotInfo { /** owner_id */ owner_user_id?: string; folder_id?: string; + /** tts配置 */ + media_config?: MediaConfig; } export interface BotOnboardingReq { @@ -241,6 +242,10 @@ export interface ChatV3Request { /** key=参数名 value=值 传递给 workflows parameters 参数 */ parameters?: string; enable_card?: boolean; + /** 发布状态:published_online / unpublished_draft。默认 published_online;不传等同 published_online */ + publish_status?: string; + /** 指定 bot 版本;不传取最新版本;publish_status=unpublished_draft 时此参数无效 */ + bot_version?: string; } /** no stream */ @@ -405,6 +410,11 @@ export interface KnowledgeInfo { name?: string; } +export interface MediaConfig { + /** 是否关闭语音通话,true:关闭 false:开启 默认为false */ + is_voice_call_closed?: boolean; +} + export interface MetaData { img?: Array; file?: Array; @@ -578,6 +588,7 @@ export interface PublishDraftBotData { export interface PublishDraftBotRequest { bot_id: string; connector_ids: Array; + connectors?: Record>; } export interface PublishDraftBotResponse { diff --git a/frontend/packages/arch/idl/src/auto-generated/playground_api/namespaces/bot_task_common.ts b/frontend/packages/arch/idl/src/auto-generated/playground_api/namespaces/bot_task_common.ts index 0038511c9..3ae496b53 100644 --- a/frontend/packages/arch/idl/src/auto-generated/playground_api/namespaces/bot_task_common.ts +++ b/frontend/packages/arch/idl/src/auto-generated/playground_api/namespaces/bot_task_common.ts @@ -14,7 +14,6 @@ * limitations under the License. */ -// THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. /* eslint-disable */ /* tslint:disable */ // @ts-nocheck @@ -159,7 +158,7 @@ export interface PresetWebhookTriggerData { } /** bot 新增自动化 - */ + https://bytedance.larkoffice.com/docx/WQNadMk9HoSuGgxuMNZcfTvTnOh */ export interface TaskInfo { id: Int64; id_str: string; diff --git a/frontend/packages/arch/idl/src/auto-generated/playground_api/namespaces/douyin_fenshen.ts b/frontend/packages/arch/idl/src/auto-generated/playground_api/namespaces/douyin_fenshen.ts index eb1ba239b..be82e90a8 100644 --- a/frontend/packages/arch/idl/src/auto-generated/playground_api/namespaces/douyin_fenshen.ts +++ b/frontend/packages/arch/idl/src/auto-generated/playground_api/namespaces/douyin_fenshen.ts @@ -14,7 +14,6 @@ * limitations under the License. */ -// THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. /* eslint-disable */ /* tslint:disable */ // @ts-nocheck diff --git a/frontend/packages/arch/idl/src/auto-generated/playground_api/namespaces/frontier.ts b/frontend/packages/arch/idl/src/auto-generated/playground_api/namespaces/frontier.ts index bdb03d99f..fb95ad093 100644 --- a/frontend/packages/arch/idl/src/auto-generated/playground_api/namespaces/frontier.ts +++ b/frontend/packages/arch/idl/src/auto-generated/playground_api/namespaces/frontier.ts @@ -14,7 +14,6 @@ * limitations under the License. */ -// THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. /* eslint-disable */ /* tslint:disable */ // @ts-nocheck diff --git a/frontend/packages/arch/idl/src/auto-generated/playground_api/namespaces/long_term_memory.ts b/frontend/packages/arch/idl/src/auto-generated/playground_api/namespaces/long_term_memory.ts index 1997c2d43..9c8302db1 100644 --- a/frontend/packages/arch/idl/src/auto-generated/playground_api/namespaces/long_term_memory.ts +++ b/frontend/packages/arch/idl/src/auto-generated/playground_api/namespaces/long_term_memory.ts @@ -14,13 +14,19 @@ * limitations under the License. */ -// THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. /* eslint-disable */ /* tslint:disable */ // @ts-nocheck export type Int64 = string | number; +export enum MetaType { + /** 事件记忆元信息 */ + EventMeta = 1, + /** 画像记忆元信息 */ + ProfileMeta = 2, +} + export interface LongTermMemoryClearAllRequest { bot_id: string; connector_id: string; @@ -36,8 +42,10 @@ export interface LongTermMemoryDeleteRequest { biz_ids: Array; /** xmemory使用 1: 原始对话 2: 总结后的话题 3: 精华记忆 */ time_capsule_item_type?: number; - /** xmemory使用 */ + /** xmemory使用(如果是火山记忆就是其记忆id) */ iids?: Array; + /** 火山记忆具体类型,key:iids, val: meta_type */ + memory_meta_type_map?: Record; } export interface LongTermMemoryDeleteResponse {} @@ -57,6 +65,10 @@ export interface LongTermMemoryItem { time_capsule_item_type?: number; /** xmemory记忆的Iid */ iid?: string; + /** 火山记忆元数据类型 */ + meta_type?: MetaType; + /** 火山记忆具体类型 */ + memory_type?: string; } export interface LongTermMemoryListRequest { @@ -91,6 +103,10 @@ export interface LongTermMemoryUpdateRequest { time_capsule_item_type?: number; /** xmemory记忆的Iid */ iid?: string; + /** 火山记忆元数据类型 */ + meta_type?: MetaType; + /** 火山记忆具体类型 */ + memory_type?: string; } export interface LongTermMemoryUpdateResponse {} diff --git a/frontend/packages/arch/idl/src/auto-generated/playground_api/namespaces/model.ts b/frontend/packages/arch/idl/src/auto-generated/playground_api/namespaces/model.ts new file mode 100644 index 000000000..10c061e94 --- /dev/null +++ b/frontend/packages/arch/idl/src/auto-generated/playground_api/namespaces/model.ts @@ -0,0 +1,290 @@ +/* + * 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. + */ + +/* eslint-disable */ +/* tslint:disable */ +// @ts-nocheck + +import * as bot_common from './bot_common'; + +export type Int64 = string | number; + +export enum ModelClass { + GPT = 1, + SEED = 2, + Claude = 3, + /** name: MiniMax */ + MiniMax = 4, + Plugin = 5, + StableDiffusion = 6, + ByteArtist = 7, + Maas = 9, + /** 废弃:千帆(百度云) */ + QianFan = 10, + /** name:Google Gemini */ + Gemini = 11, + /** name: Moonshot */ + Moonshot = 12, + /** name:智谱 */ + GLM = 13, + /** name: 火山方舟 */ + MaaSAutoSync = 14, + /** name:通义千问 */ + QWen = 15, + /** name: Cohere */ + Cohere = 16, + /** name: 百川智能 */ + Baichuan = 17, + /** name:文心一言 */ + Ernie = 18, + /** name: 幻方 */ + DeekSeek = 19, + /** name: Llama */ + Llama = 20, + StepFun = 23, + Custom = 24, + Other = 999, +} + +export enum ModelParamType { + Float = 1, + Int = 2, + Boolean = 3, + String = 4, +} + +export enum ModelTagClass { + ModelType = 1, + ModelUserRight = 2, + ModelFeature = 3, + ModelFunction = 4, + ModelPaid = 15, + /** 模型运行时能力 */ + ModelAbility = 16, + /** 模型状态 */ + ModelStatus = 17, + /** 本期不做 */ + Custom = 20, + Others = 100, +} + +export enum ModelTagValue { + Flagship = 1, + HighSpeed = 2, + ToolInvocation = 3, + RolePlaying = 4, + LongText = 5, + ImageUnderstanding = 6, + Reasoning = 7, + VideoUnderstanding = 8, + CostPerformance = 9, + CodeSpecialization = 10, + AudioUnderstanding = 11, +} + +export enum VideoGenType { + /** 文生视频 */ + Text = 1, + /** 首帧 */ + ImageFirstFrame = 2, + /** 首尾帧 */ + ImageFirstLastFrame = 3, + /** 参考图 */ + ReferencePicture = 4, +} + +export interface Model { + name?: string; + model_type?: Int64; + model_class?: ModelClass; + /** model icon的url */ + model_icon?: string; + model_input_price?: number; + model_output_price?: number; + model_quota?: ModelQuota; + /** model真实名,前端计算token用 */ + model_name?: string; + model_class_name?: string; + is_offline?: boolean; + model_params?: Array; + model_desc?: Array; + /** 模型功能配置 */ + func_config?: Record< + bot_common.ModelFuncConfigType, + bot_common.ModelFuncConfigStatus + >; + /** 方舟模型节点名称 */ + endpoint_name?: string; + /** 模型标签 */ + model_tag_list?: Array; + /** user prompt是否必须有且不能为空 */ + is_up_required?: boolean; + /** 模型简要描述 */ + model_brief_desc?: string; + /** 模型系列 */ + model_series?: ModelSeriesInfo; + /** 模型状态 */ + model_status_details?: ModelStatusDetails; + /** 模型能力 */ + model_ability?: ModelAbility; + model_show_family_id?: string; + hot_flag?: number; + hot_ranking?: number; + online_time?: Int64; + /** 0-用户可见 1-用户不可见 */ + config_type?: number; + offline_time?: Int64; + volc_account_id?: string; + /** 秒级时间戳 */ + terminate_time?: Int64; +} + +export interface ModelAbility { + /** 是否展示cot */ + cot_display?: boolean; + /** 是否支持function call */ + function_call?: boolean; + /** 是否支持图片理解 */ + image_understanding?: boolean; + /** 是否支持视频理解 */ + video_understanding?: boolean; + /** 是否支持音频理解 */ + audio_understanding?: boolean; + /** 是否支持多模态 */ + support_multi_modal?: boolean; + /** 是否支持续写 */ + prefill_resp?: boolean; + /** 是否支持视频理解 */ + video_gen?: Array; +} + +export interface ModelDescGroup { + group_name?: string; + desc?: Array; +} + +export interface ModelParamClass { + /** 1="Generation diversity", 2="Input and output length", 3="Output format" */ + class_id?: number; + label?: string; +} + +export interface ModelParamDefaultValue { + default_val: string; + creative?: string; + balance?: string; + precise?: string; +} + +export interface ModelParameter { + /** 配置字段,如max_tokens */ + name: string; + /** 配置字段展示名称 */ + label?: string; + /** 配置字段详情描述 */ + desc?: string; + /** 类型 */ + type: ModelParamType; + /** 数值类型参数,允许设置的最小值 */ + min?: string; + /** 数值类型参数,允许设置的最大值 */ + max?: string; + /** float类型参数的精度 */ + precision?: number; + /** 参数默认值{"default": xx, "creative":xx} */ + default_val: ModelParamDefaultValue; + /** 枚举值,如response_format支持text,markdown,json */ + options?: Array