diff --git a/backend/api/model/app/bot_common/bot_common.go b/backend/api/model/app/bot_common/bot_common.go index 758afd10..204472ec 100644 --- a/backend/api/model/app/bot_common/bot_common.go +++ b/backend/api/model/app/bot_common/bot_common.go @@ -1,4 +1,20 @@ -// Code generated by thriftgo (0.4.1). DO NOT EDIT. +/* + * 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.2). DO NOT EDIT. package bot_common @@ -9,6 +25,12 @@ import ( "github.com/apache/thrift/lib/go/thrift" ) +const ( + ShortcutSendTypeQuery = "query" + + ShortcutSendTypePanel = "panel" +) + type ModelStyle int64 const ( @@ -1993,6 +2015,8 @@ func (p *ReferenceInfoStatus) Value() (driver.Value, error) { return int64(*p), nil } +type ShortcutSendType = string + type AuthToken struct { ServiceID string `thrift:"service_id,1" form:"service_id" json:"service_id" query:"service_id"` AccessKeyID string `thrift:"access_key_id,2" form:"access_key_id" json:"access_key_id" query:"access_key_id"` @@ -15575,34 +15599,57 @@ func (p *ShortcutCommandComponent) String() string { } -type ShortcutCommandToolInfo struct { - // - Name string `thrift:"name,1" form:"name" json:"name" query:"name"` - // Tool type workflow plugin - Type string `thrift:"type,2" form:"type" json:"type" query:"type"` +type ShortcutToolParam struct { + Name string `thrift:"name,1" form:"name" json:"name" query:"name"` + IsRequired bool `thrift:"is_required,2" form:"is_required" json:"is_required" query:"is_required"` + Description string `thrift:"description,3" form:"description" json:"description" query:"description"` + Type string `thrift:"type,4" form:"type" json:"type" query:"type"` + DefaultValue string `thrift:"default_value,5" form:"default_value" json:"default_value" query:"default_value"` + // 是否是panel参数 + IsReferComponent bool `thrift:"is_refer_component,6" form:"is_refer_component" json:"is_refer_component" query:"is_refer_component"` } -func NewShortcutCommandToolInfo() *ShortcutCommandToolInfo { - return &ShortcutCommandToolInfo{} +func NewShortcutToolParam() *ShortcutToolParam { + return &ShortcutToolParam{} } -func (p *ShortcutCommandToolInfo) InitDefault() { +func (p *ShortcutToolParam) InitDefault() { } -func (p *ShortcutCommandToolInfo) GetName() (v string) { +func (p *ShortcutToolParam) GetName() (v string) { return p.Name } -func (p *ShortcutCommandToolInfo) GetType() (v string) { +func (p *ShortcutToolParam) GetIsRequired() (v bool) { + return p.IsRequired +} + +func (p *ShortcutToolParam) GetDescription() (v string) { + return p.Description +} + +func (p *ShortcutToolParam) GetType() (v string) { return p.Type } -var fieldIDToName_ShortcutCommandToolInfo = map[int16]string{ +func (p *ShortcutToolParam) GetDefaultValue() (v string) { + return p.DefaultValue +} + +func (p *ShortcutToolParam) GetIsReferComponent() (v bool) { + return p.IsReferComponent +} + +var fieldIDToName_ShortcutToolParam = map[int16]string{ 1: "name", - 2: "type", + 2: "is_required", + 3: "description", + 4: "type", + 5: "default_value", + 6: "is_refer_component", } -func (p *ShortcutCommandToolInfo) Read(iprot thrift.TProtocol) (err error) { +func (p *ShortcutToolParam) Read(iprot thrift.TProtocol) (err error) { var fieldTypeId thrift.TType var fieldId int16 @@ -15629,13 +15676,45 @@ func (p *ShortcutCommandToolInfo) Read(iprot thrift.TProtocol) (err error) { goto SkipFieldError } case 2: - if fieldTypeId == thrift.STRING { + 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 4: + if fieldTypeId == thrift.STRING { + 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 6: + if fieldTypeId == thrift.BOOL { + 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 @@ -15655,7 +15734,7 @@ ReadStructBeginError: 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_ShortcutCommandToolInfo[fieldId]), err) + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ShortcutToolParam[fieldId]), err) SkipFieldError: return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) @@ -15665,7 +15744,7 @@ ReadStructEndError: return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } -func (p *ShortcutCommandToolInfo) ReadField1(iprot thrift.TProtocol) error { +func (p *ShortcutToolParam) ReadField1(iprot thrift.TProtocol) error { var _field string if v, err := iprot.ReadString(); err != nil { @@ -15676,7 +15755,29 @@ func (p *ShortcutCommandToolInfo) ReadField1(iprot thrift.TProtocol) error { p.Name = _field return nil } -func (p *ShortcutCommandToolInfo) ReadField2(iprot thrift.TProtocol) error { +func (p *ShortcutToolParam) ReadField2(iprot thrift.TProtocol) error { + + var _field bool + if v, err := iprot.ReadBool(); err != nil { + return err + } else { + _field = v + } + p.IsRequired = _field + return nil +} +func (p *ShortcutToolParam) ReadField3(iprot thrift.TProtocol) error { + + var _field string + if v, err := iprot.ReadString(); err != nil { + return err + } else { + _field = v + } + p.Description = _field + return nil +} +func (p *ShortcutToolParam) ReadField4(iprot thrift.TProtocol) error { var _field string if v, err := iprot.ReadString(); err != nil { @@ -15687,10 +15788,32 @@ func (p *ShortcutCommandToolInfo) ReadField2(iprot thrift.TProtocol) error { p.Type = _field return nil } +func (p *ShortcutToolParam) ReadField5(iprot thrift.TProtocol) error { -func (p *ShortcutCommandToolInfo) Write(oprot thrift.TProtocol) (err error) { + var _field string + if v, err := iprot.ReadString(); err != nil { + return err + } else { + _field = v + } + p.DefaultValue = _field + return nil +} +func (p *ShortcutToolParam) ReadField6(iprot thrift.TProtocol) error { + + var _field bool + if v, err := iprot.ReadBool(); err != nil { + return err + } else { + _field = v + } + p.IsReferComponent = _field + return nil +} + +func (p *ShortcutToolParam) Write(oprot thrift.TProtocol) (err error) { var fieldId int16 - if err = oprot.WriteStructBegin("ShortcutCommandToolInfo"); err != nil { + if err = oprot.WriteStructBegin("ShortcutToolParam"); err != nil { goto WriteStructBeginError } if p != nil { @@ -15702,6 +15825,22 @@ func (p *ShortcutCommandToolInfo) Write(oprot thrift.TProtocol) (err error) { 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 @@ -15720,7 +15859,7 @@ WriteStructEndError: return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) } -func (p *ShortcutCommandToolInfo) writeField1(oprot thrift.TProtocol) (err error) { +func (p *ShortcutToolParam) writeField1(oprot thrift.TProtocol) (err error) { if err = oprot.WriteFieldBegin("name", thrift.STRING, 1); err != nil { goto WriteFieldBeginError } @@ -15736,11 +15875,11 @@ WriteFieldBeginError: WriteFieldEndError: return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) } -func (p *ShortcutCommandToolInfo) writeField2(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("type", thrift.STRING, 2); err != nil { +func (p *ShortcutToolParam) writeField2(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("is_required", thrift.BOOL, 2); err != nil { goto WriteFieldBeginError } - if err := oprot.WriteString(p.Type); err != nil { + if err := oprot.WriteBool(p.IsRequired); err != nil { return err } if err = oprot.WriteFieldEnd(); err != nil { @@ -15752,118 +15891,644 @@ WriteFieldBeginError: WriteFieldEndError: return thrift.PrependError(fmt.Sprintf("%T write field 2 end error: ", p), err) } +func (p *ShortcutToolParam) writeField3(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("description", thrift.STRING, 3); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteString(p.Description); 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 *ShortcutToolParam) writeField4(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("type", thrift.STRING, 4); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteString(p.Type); 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 *ShortcutToolParam) writeField5(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("default_value", thrift.STRING, 5); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteString(p.DefaultValue); 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 *ShortcutToolParam) writeField6(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("is_refer_component", thrift.BOOL, 6); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteBool(p.IsReferComponent); 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 *ShortcutCommandToolInfo) String() string { +func (p *ShortcutToolParam) String() string { if p == nil { return "" } - return fmt.Sprintf("ShortcutCommandToolInfo(%+v)", *p) + return fmt.Sprintf("ShortcutToolParam(%+v)", *p) } -type ShortcutCommandInfo struct { - // Quick Command ID - ID int64 `thrift:"id,1" form:"id" json:"id,string" query:"id"` - // Shortcut button name - Name string `thrift:"name,2" form:"name" json:"name" query:"name"` - // Quick Instruction - Command string `thrift:"command,3" form:"command" json:"command" query:"command"` - // shortcut description - Description string `thrift:"description,4" form:"description" json:"description" query:"description"` - // Command query template - QueryTemplate string `thrift:"query_template,5" form:"query_template" json:"query_template" query:"query_template"` - // Quick command icon - IconURL string `thrift:"icon_url,6" form:"icon_url" json:"icon_url" query:"icon_url"` - // Component list (parameter list) - Components []*ShortcutCommandComponent `thrift:"components,7,optional" form:"components" json:"components,omitempty" query:"components"` - // Tool information - Tool *ShortcutCommandToolInfo `thrift:"tool,8,optional" form:"tool" json:"tool,omitempty" query:"tool"` - //When the multi instruction is executed by which node, it will not be returned without configuration - AgentID *int64 `thrift:"agent_id,9,optional" form:"agent_id" json:"agent_id,string,omitempty" query:"agent_id"` -} - -func NewShortcutCommandInfo() *ShortcutCommandInfo { - return &ShortcutCommandInfo{} +type ShortcutCommandToolInfo struct { + // + Name string `thrift:"name,1" form:"name" json:"name" query:"name"` + // Tool type workflow plugin + Type string `thrift:"type,2" form:"type" json:"type" query:"type"` + PluginID *int64 `thrift:"plugin_id,3,optional" form:"plugin_id" json:"plugin_id,string,omitempty" query:"plugin_id"` + PluginAPIName *string `thrift:"plugin_api_name,4,optional" form:"plugin_api_name" json:"plugin_api_name,omitempty" query:"plugin_api_name"` + WorkflowID *int64 `thrift:"workflow_id,5,optional" form:"workflow_id" json:"workflow_id,string,omitempty" query:"workflow_id"` + Params []*ShortcutToolParam `thrift:"params,6,optional" form:"params" json:"params,omitempty" query:"params"` } -func (p *ShortcutCommandInfo) InitDefault() { +func NewShortcutCommandToolInfo() *ShortcutCommandToolInfo { + return &ShortcutCommandToolInfo{} } -func (p *ShortcutCommandInfo) GetID() (v int64) { - return p.ID +func (p *ShortcutCommandToolInfo) InitDefault() { } -func (p *ShortcutCommandInfo) GetName() (v string) { +func (p *ShortcutCommandToolInfo) GetName() (v string) { return p.Name } -func (p *ShortcutCommandInfo) GetCommand() (v string) { - return p.Command -} - -func (p *ShortcutCommandInfo) GetDescription() (v string) { - return p.Description +func (p *ShortcutCommandToolInfo) GetType() (v string) { + return p.Type } -func (p *ShortcutCommandInfo) GetQueryTemplate() (v string) { - return p.QueryTemplate -} +var ShortcutCommandToolInfo_PluginID_DEFAULT int64 -func (p *ShortcutCommandInfo) GetIconURL() (v string) { - return p.IconURL +func (p *ShortcutCommandToolInfo) GetPluginID() (v int64) { + if !p.IsSetPluginID() { + return ShortcutCommandToolInfo_PluginID_DEFAULT + } + return *p.PluginID } -var ShortcutCommandInfo_Components_DEFAULT []*ShortcutCommandComponent +var ShortcutCommandToolInfo_PluginAPIName_DEFAULT string -func (p *ShortcutCommandInfo) GetComponents() (v []*ShortcutCommandComponent) { - if !p.IsSetComponents() { - return ShortcutCommandInfo_Components_DEFAULT +func (p *ShortcutCommandToolInfo) GetPluginAPIName() (v string) { + if !p.IsSetPluginAPIName() { + return ShortcutCommandToolInfo_PluginAPIName_DEFAULT } - return p.Components + return *p.PluginAPIName } -var ShortcutCommandInfo_Tool_DEFAULT *ShortcutCommandToolInfo +var ShortcutCommandToolInfo_WorkflowID_DEFAULT int64 -func (p *ShortcutCommandInfo) GetTool() (v *ShortcutCommandToolInfo) { - if !p.IsSetTool() { - return ShortcutCommandInfo_Tool_DEFAULT +func (p *ShortcutCommandToolInfo) GetWorkflowID() (v int64) { + if !p.IsSetWorkflowID() { + return ShortcutCommandToolInfo_WorkflowID_DEFAULT } - return p.Tool + return *p.WorkflowID } -var ShortcutCommandInfo_AgentID_DEFAULT int64 +var ShortcutCommandToolInfo_Params_DEFAULT []*ShortcutToolParam -func (p *ShortcutCommandInfo) GetAgentID() (v int64) { - if !p.IsSetAgentID() { - return ShortcutCommandInfo_AgentID_DEFAULT +func (p *ShortcutCommandToolInfo) GetParams() (v []*ShortcutToolParam) { + if !p.IsSetParams() { + return ShortcutCommandToolInfo_Params_DEFAULT } - return *p.AgentID + return p.Params } -var fieldIDToName_ShortcutCommandInfo = map[int16]string{ - 1: "id", - 2: "name", - 3: "command", - 4: "description", - 5: "query_template", - 6: "icon_url", - 7: "components", - 8: "tool", - 9: "agent_id", +var fieldIDToName_ShortcutCommandToolInfo = map[int16]string{ + 1: "name", + 2: "type", + 3: "plugin_id", + 4: "plugin_api_name", + 5: "workflow_id", + 6: "params", } -func (p *ShortcutCommandInfo) IsSetComponents() bool { - return p.Components != nil +func (p *ShortcutCommandToolInfo) IsSetPluginID() bool { + return p.PluginID != nil } -func (p *ShortcutCommandInfo) IsSetTool() bool { - return p.Tool != nil +func (p *ShortcutCommandToolInfo) IsSetPluginAPIName() bool { + return p.PluginAPIName != nil } -func (p *ShortcutCommandInfo) IsSetAgentID() bool { +func (p *ShortcutCommandToolInfo) IsSetWorkflowID() bool { + return p.WorkflowID != nil +} + +func (p *ShortcutCommandToolInfo) IsSetParams() bool { + return p.Params != nil +} + +func (p *ShortcutCommandToolInfo) 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.I64 { + if err = p.ReadField3(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + case 4: + if fieldTypeId == thrift.STRING { + if err = p.ReadField4(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + case 5: + if fieldTypeId == thrift.I64 { + if err = p.ReadField5(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + case 6: + if fieldTypeId == thrift.LIST { + 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_ShortcutCommandToolInfo[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 *ShortcutCommandToolInfo) ReadField1(iprot thrift.TProtocol) error { + + var _field string + if v, err := iprot.ReadString(); err != nil { + return err + } else { + _field = v + } + p.Name = _field + return nil +} +func (p *ShortcutCommandToolInfo) ReadField2(iprot thrift.TProtocol) error { + + var _field string + if v, err := iprot.ReadString(); err != nil { + return err + } else { + _field = v + } + p.Type = _field + return nil +} +func (p *ShortcutCommandToolInfo) ReadField3(iprot thrift.TProtocol) error { + + var _field *int64 + if v, err := iprot.ReadI64(); err != nil { + return err + } else { + _field = &v + } + p.PluginID = _field + return nil +} +func (p *ShortcutCommandToolInfo) ReadField4(iprot thrift.TProtocol) error { + + var _field *string + if v, err := iprot.ReadString(); err != nil { + return err + } else { + _field = &v + } + p.PluginAPIName = _field + return nil +} +func (p *ShortcutCommandToolInfo) ReadField5(iprot thrift.TProtocol) error { + + var _field *int64 + if v, err := iprot.ReadI64(); err != nil { + return err + } else { + _field = &v + } + p.WorkflowID = _field + return nil +} +func (p *ShortcutCommandToolInfo) ReadField6(iprot thrift.TProtocol) error { + _, size, err := iprot.ReadListBegin() + if err != nil { + return err + } + _field := make([]*ShortcutToolParam, 0, size) + values := make([]ShortcutToolParam, 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.Params = _field + return nil +} + +func (p *ShortcutCommandToolInfo) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("ShortcutCommandToolInfo"); 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 *ShortcutCommandToolInfo) writeField1(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("name", thrift.STRING, 1); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteString(p.Name); 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 *ShortcutCommandToolInfo) writeField2(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("type", thrift.STRING, 2); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteString(p.Type); 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 *ShortcutCommandToolInfo) writeField3(oprot thrift.TProtocol) (err error) { + if p.IsSetPluginID() { + if err = oprot.WriteFieldBegin("plugin_id", thrift.I64, 3); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteI64(*p.PluginID); 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 *ShortcutCommandToolInfo) writeField4(oprot thrift.TProtocol) (err error) { + if p.IsSetPluginAPIName() { + if err = oprot.WriteFieldBegin("plugin_api_name", thrift.STRING, 4); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteString(*p.PluginAPIName); 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 *ShortcutCommandToolInfo) writeField5(oprot thrift.TProtocol) (err error) { + if p.IsSetWorkflowID() { + if err = oprot.WriteFieldBegin("workflow_id", thrift.I64, 5); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteI64(*p.WorkflowID); 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 *ShortcutCommandToolInfo) writeField6(oprot thrift.TProtocol) (err error) { + if p.IsSetParams() { + if err = oprot.WriteFieldBegin("params", thrift.LIST, 6); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteListBegin(thrift.STRUCT, len(p.Params)); err != nil { + return err + } + for _, v := range p.Params { + 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 6 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 6 end error: ", p), err) +} + +func (p *ShortcutCommandToolInfo) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("ShortcutCommandToolInfo(%+v)", *p) + +} + +type ShortcutCommandInfo struct { + // Quick Command ID + ID int64 `thrift:"id,1" form:"id" json:"id,string" query:"id"` + // Shortcut button name + Name string `thrift:"name,2" form:"name" json:"name" query:"name"` + // Quick Instruction + Command string `thrift:"command,3" form:"command" json:"command" query:"command"` + // shortcut description + Description string `thrift:"description,4" form:"description" json:"description" query:"description"` + // Command query template + QueryTemplate string `thrift:"query_template,5" form:"query_template" json:"query_template" query:"query_template"` + // Quick command icon + IconURL string `thrift:"icon_url,6" form:"icon_url" json:"icon_url" query:"icon_url"` + // Component list (parameter list) + Components []*ShortcutCommandComponent `thrift:"components,7,optional" form:"components" json:"components,omitempty" query:"components"` + // Tool information + Tool *ShortcutCommandToolInfo `thrift:"tool,8,optional" form:"tool" json:"tool,omitempty" query:"tool"` + //When the multi instruction is executed by which node, it will not be returned without configuration + AgentID *int64 `thrift:"agent_id,9,optional" form:"agent_id" json:"agent_id,string,omitempty" query:"agent_id"` + // chatsdk 使用 + SendType *ShortcutSendType `thrift:"send_type,10,optional" form:"send_type" json:"send_type,omitempty" query:"send_type"` + // chatsdk 使用,表单的schema + CardSchema *string `thrift:"card_schema,11,optional" form:"card_schema" json:"card_schema,omitempty" query:"card_schema"` +} + +func NewShortcutCommandInfo() *ShortcutCommandInfo { + return &ShortcutCommandInfo{} +} + +func (p *ShortcutCommandInfo) InitDefault() { +} + +func (p *ShortcutCommandInfo) GetID() (v int64) { + return p.ID +} + +func (p *ShortcutCommandInfo) GetName() (v string) { + return p.Name +} + +func (p *ShortcutCommandInfo) GetCommand() (v string) { + return p.Command +} + +func (p *ShortcutCommandInfo) GetDescription() (v string) { + return p.Description +} + +func (p *ShortcutCommandInfo) GetQueryTemplate() (v string) { + return p.QueryTemplate +} + +func (p *ShortcutCommandInfo) GetIconURL() (v string) { + return p.IconURL +} + +var ShortcutCommandInfo_Components_DEFAULT []*ShortcutCommandComponent + +func (p *ShortcutCommandInfo) GetComponents() (v []*ShortcutCommandComponent) { + if !p.IsSetComponents() { + return ShortcutCommandInfo_Components_DEFAULT + } + return p.Components +} + +var ShortcutCommandInfo_Tool_DEFAULT *ShortcutCommandToolInfo + +func (p *ShortcutCommandInfo) GetTool() (v *ShortcutCommandToolInfo) { + if !p.IsSetTool() { + return ShortcutCommandInfo_Tool_DEFAULT + } + return p.Tool +} + +var ShortcutCommandInfo_AgentID_DEFAULT int64 + +func (p *ShortcutCommandInfo) GetAgentID() (v int64) { + if !p.IsSetAgentID() { + return ShortcutCommandInfo_AgentID_DEFAULT + } + return *p.AgentID +} + +var ShortcutCommandInfo_SendType_DEFAULT ShortcutSendType + +func (p *ShortcutCommandInfo) GetSendType() (v ShortcutSendType) { + if !p.IsSetSendType() { + return ShortcutCommandInfo_SendType_DEFAULT + } + return *p.SendType +} + +var ShortcutCommandInfo_CardSchema_DEFAULT string + +func (p *ShortcutCommandInfo) GetCardSchema() (v string) { + if !p.IsSetCardSchema() { + return ShortcutCommandInfo_CardSchema_DEFAULT + } + return *p.CardSchema +} + +var fieldIDToName_ShortcutCommandInfo = map[int16]string{ + 1: "id", + 2: "name", + 3: "command", + 4: "description", + 5: "query_template", + 6: "icon_url", + 7: "components", + 8: "tool", + 9: "agent_id", + 10: "send_type", + 11: "card_schema", +} + +func (p *ShortcutCommandInfo) IsSetComponents() bool { + return p.Components != nil +} + +func (p *ShortcutCommandInfo) IsSetTool() bool { + return p.Tool != nil +} + +func (p *ShortcutCommandInfo) IsSetAgentID() bool { return p.AgentID != nil } +func (p *ShortcutCommandInfo) IsSetSendType() bool { + return p.SendType != nil +} + +func (p *ShortcutCommandInfo) IsSetCardSchema() bool { + return p.CardSchema != nil +} + func (p *ShortcutCommandInfo) Read(iprot thrift.TProtocol) (err error) { var fieldTypeId thrift.TType var fieldId int16 @@ -15954,6 +16619,22 @@ func (p *ShortcutCommandInfo) Read(iprot thrift.TProtocol) (err error) { } else if err = iprot.Skip(fieldTypeId); err != nil { goto SkipFieldError } + case 10: + if fieldTypeId == thrift.STRING { + if err = p.ReadField10(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + case 11: + if fieldTypeId == thrift.STRING { + if err = p.ReadField11(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 @@ -16091,6 +16772,28 @@ func (p *ShortcutCommandInfo) ReadField9(iprot thrift.TProtocol) error { p.AgentID = _field return nil } +func (p *ShortcutCommandInfo) ReadField10(iprot thrift.TProtocol) error { + + var _field *ShortcutSendType + if v, err := iprot.ReadString(); err != nil { + return err + } else { + _field = &v + } + p.SendType = _field + return nil +} +func (p *ShortcutCommandInfo) ReadField11(iprot thrift.TProtocol) error { + + var _field *string + if v, err := iprot.ReadString(); err != nil { + return err + } else { + _field = &v + } + p.CardSchema = _field + return nil +} func (p *ShortcutCommandInfo) Write(oprot thrift.TProtocol) (err error) { var fieldId int16 @@ -16134,6 +16837,14 @@ func (p *ShortcutCommandInfo) Write(oprot thrift.TProtocol) (err error) { fieldId = 9 goto WriteFieldError } + if err = p.writeField10(oprot); err != nil { + fieldId = 10 + goto WriteFieldError + } + if err = p.writeField11(oprot); err != nil { + fieldId = 11 + goto WriteFieldError + } } if err = oprot.WriteFieldStop(); err != nil { goto WriteFieldStopError @@ -16310,6 +17021,42 @@ WriteFieldBeginError: WriteFieldEndError: return thrift.PrependError(fmt.Sprintf("%T write field 9 end error: ", p), err) } +func (p *ShortcutCommandInfo) writeField10(oprot thrift.TProtocol) (err error) { + if p.IsSetSendType() { + if err = oprot.WriteFieldBegin("send_type", thrift.STRING, 10); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteString(*p.SendType); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 10 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 10 end error: ", p), err) +} +func (p *ShortcutCommandInfo) writeField11(oprot thrift.TProtocol) (err error) { + if p.IsSetCardSchema() { + if err = oprot.WriteFieldBegin("card_schema", thrift.STRING, 11); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteString(*p.CardSchema); 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 *ShortcutCommandInfo) String() string { if p == nil { diff --git a/backend/application/singleagent/single_agent.go b/backend/application/singleagent/single_agent.go index dde12c73..3faed990 100644 --- a/backend/application/singleagent/single_agent.go +++ b/backend/application/singleagent/single_agent.go @@ -38,6 +38,7 @@ import ( "github.com/coze-dev/coze-studio/backend/api/model/data/database/table" "github.com/coze-dev/coze-studio/backend/api/model/playground" "github.com/coze-dev/coze-studio/backend/application/base/ctxutil" + "github.com/coze-dev/coze-studio/backend/crossdomain/contract/agent" crossdatabase "github.com/coze-dev/coze-studio/backend/crossdomain/contract/database" "github.com/coze-dev/coze-studio/backend/domain/agent/singleagent/entity" singleagent "github.com/coze-dev/coze-studio/backend/domain/agent/singleagent/service" @@ -733,16 +734,64 @@ func (s *SingleAgentApplicationService) getAgentInfo(ctx context.Context, botID sc := &bot_common.ShortcutCommandComponent{ Name: i.Name, Description: i.Description, - Type: i.InputType.String(), + Type: getShortcutCommandComponentType(i.InputType), ToolParameter: ptr.Of(i.Parameter), - Options: i.Options, IsHide: i.Hide, } if i.DefaultValue != nil { sc.DefaultValue = ptr.Of(i.DefaultValue.Value) } + + switch i.InputType { + case playground.InputType_Select: + sc.Options = i.Options + case playground.InputType_MixUpload: + options := make([]string, 0, len(i.UploadOptions)) + for _, uploadOption := range i.UploadOptions { + options = append(options, string(getShortcutCommandComponentFileType(uploadOption))) + } + sc.Options = options + case playground.InputType_UploadImage, playground.InputType_UploadDoc, playground.InputType_UploadTable, playground.InputType_UploadAudio, + playground.InputType_VIDEO, playground.InputType_ARCHIVE, playground.InputType_CODE, playground.InputType_TXT, + playground.InputType_PPT: + sc.Options = []string{string(getShortcutCommandComponentFileType(i.InputType))} + default: + } + return sc }), + Tool: &bot_common.ShortcutCommandToolInfo{ + Name: si.ToolInfo.ToolName, + Type: func() string { + if si.ToolType == 1 { + return string(agent.ShortcutCommandToolTypePlugin) + } + if si.ToolType == 2 { + return string(agent.ShortcutCommandToolTypeWorkflow) + } + return "" + }(), + PluginID: ptr.Of(si.PluginID), + WorkflowID: ptr.Of(si.WorkFlowID), + PluginAPIName: &si.PluginToolName, + Params: slices.Transform(si.ToolInfo.ToolParamsList, func(i *playground.ToolParams) *bot_common.ShortcutToolParam { + return &bot_common.ShortcutToolParam{ + Name: i.Name, + Type: i.Type, + DefaultValue: i.DefaultValue, + IsReferComponent: i.ReferComponent, + IsRequired: i.Required, + Description: i.Desc, + } + }), + }, + SendType: func() *bot_common.ShortcutSendType { + if si.SendType == 1 { + return ptr.Of(bot_common.ShortcutSendTypePanel) + } + return ptr.Of(bot_common.ShortcutSendTypeQuery) + }(), + CardSchema: ptr.Of(si.CardSchema), } }) @@ -767,3 +816,12 @@ func (s *SingleAgentApplicationService) OpenGetBotInfo(ctx context.Context, req resp.Data = agentInfo return resp, nil } + +func getShortcutCommandComponentType(inputType playground.InputType) string { + componentType := agent.ShortcutCommandComponentTypeMapping[inputType] + return string(componentType) +} + +func getShortcutCommandComponentFileType(inputType playground.InputType) string { + return string(agent.ShortcutCommandComponentFileTypeMapping[inputType]) +} diff --git a/backend/crossdomain/contract/agent/single_agent.go b/backend/crossdomain/contract/agent/single_agent.go index a1e6e801..d9d4266b 100644 --- a/backend/crossdomain/contract/agent/single_agent.go +++ b/backend/crossdomain/contract/agent/single_agent.go @@ -23,6 +23,7 @@ import ( "github.com/coze-dev/coze-studio/backend/api/model/crossdomain/agentrun" "github.com/coze-dev/coze-studio/backend/api/model/crossdomain/singleagent" + "github.com/coze-dev/coze-studio/backend/api/model/playground" ) // Requests and responses must not reference domain entities and can only use models under api/model/crossdomain. @@ -59,3 +60,60 @@ func DefaultSVC() SingleAgent { func SetDefaultSVC(svc SingleAgent) { defaultSVC = svc } + + +type ShortcutCommandComponentType string + +const ( + ShortcutCommandComponentTypeText ShortcutCommandComponentType = "text" + ShortcutCommandComponentTypeSelect ShortcutCommandComponentType = "select" + ShortcutCommandComponentTypeFile ShortcutCommandComponentType = "file" +) + + +var ShortcutCommandComponentTypeMapping = map[playground.InputType]ShortcutCommandComponentType{ + playground.InputType_TextInput: ShortcutCommandComponentTypeText, + playground.InputType_Select: ShortcutCommandComponentTypeSelect, + playground.InputType_MixUpload: ShortcutCommandComponentTypeFile, + playground.InputType_UploadImage: ShortcutCommandComponentTypeFile, + playground.InputType_UploadDoc: ShortcutCommandComponentTypeFile, + playground.InputType_UploadTable: ShortcutCommandComponentTypeFile, + playground.InputType_UploadAudio: ShortcutCommandComponentTypeFile, + playground.InputType_VIDEO: ShortcutCommandComponentTypeFile, + playground.InputType_ARCHIVE: ShortcutCommandComponentTypeFile, + playground.InputType_CODE: ShortcutCommandComponentTypeFile, + playground.InputType_TXT: ShortcutCommandComponentTypeFile, + playground.InputType_PPT: ShortcutCommandComponentTypeFile, +} +type ShortcutCommandComponentFileType string + +const ( + ShortcutCommandComponentFileTypeImage ShortcutCommandComponentFileType = "image" + ShortcutCommandComponentFileTypeDoc ShortcutCommandComponentFileType = "doc" + ShortcutCommandComponentFileTypeTable ShortcutCommandComponentFileType = "table" + ShortcutCommandComponentFileTypeAudio ShortcutCommandComponentFileType = "audio" + ShortcutCommandComponentFileTypeVideo ShortcutCommandComponentFileType = "video" + ShortcutCommandComponentFileTypeZip ShortcutCommandComponentFileType = "zip" + ShortcutCommandComponentFileTypeCode ShortcutCommandComponentFileType = "code" + ShortcutCommandComponentFileTypeTxt ShortcutCommandComponentFileType = "txt" + ShortcutCommandComponentFileTypePPT ShortcutCommandComponentFileType = "ppt" +) + +var ShortcutCommandComponentFileTypeMapping = map[playground.InputType]ShortcutCommandComponentFileType{ + playground.InputType_UploadImage: ShortcutCommandComponentFileTypeImage, + playground.InputType_UploadDoc: ShortcutCommandComponentFileTypeDoc, + playground.InputType_UploadTable: ShortcutCommandComponentFileTypeTable, + playground.InputType_UploadAudio: ShortcutCommandComponentFileTypeAudio, + playground.InputType_VIDEO: ShortcutCommandComponentFileTypeVideo, + playground.InputType_ARCHIVE: ShortcutCommandComponentFileTypeZip, + playground.InputType_CODE: ShortcutCommandComponentFileTypeCode, + playground.InputType_TXT: ShortcutCommandComponentFileTypeTxt, + playground.InputType_PPT: ShortcutCommandComponentFileTypePPT, +} + +type ShortcutCommandToolType string + +const ( + ShortcutCommandToolTypeWorkflow ShortcutCommandToolType = "workflow" + ShortcutCommandToolTypePlugin ShortcutCommandToolType = "plugin" +) diff --git a/idl/app/bot_common.thrift b/idl/app/bot_common.thrift index cee9667a..d58a28c9 100644 --- a/idl/app/bot_common.thrift +++ b/idl/app/bot_common.thrift @@ -487,10 +487,26 @@ struct ShortcutCommandComponent { // Panel parameters 7 : bool is_hide // Whether to hide or not to show, the shortcut command of the online bot tool type does not return the component with hide = true } +struct ShortcutToolParam { + 1: string name + 2: bool is_required + 3: string description + 4: string type + 5: string default_value + 6: bool is_refer_component +} + struct ShortcutCommandToolInfo { 1: string name // 2: string type // Tool type workflow plugin + 3: optional i64 plugin_id (api.js_conv="true") + 4: optional string plugin_api_name + 5: optional i64 workflow_id (api.js_conv="true") + 6: optional list params } +typedef string ShortcutSendType +const ShortcutSendType ShortcutSendTypeQuery = 'query' +const ShortcutSendType ShortcutSendTypePanel = 'panel' struct ShortcutCommandInfo { 1: i64 id (api.js_conv="true") // Quick Command ID @@ -502,6 +518,8 @@ struct ShortcutCommandInfo { 7: optional list components // Component list (parameter list) 8: optional ShortcutCommandToolInfo tool // Tool information 9: optional i64 agent_id (api.js_conv="true") //When the multi instruction is executed by which node, it will not be returned without configuration + 10: optional ShortcutSendType send_type // chatsdk used + 11: optional string card_schema // chatsdk schema }