feat: manually mirror opencoze's code from bytedance

Change-Id: I09a73aadda978ad9511264a756b2ce51f5761adf
This commit is contained in:
fanlv
2025-07-20 17:36:12 +08:00
commit 890153324f
14811 changed files with 1923430 additions and 0 deletions

View File

@@ -0,0 +1,116 @@
/*
* 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 errno
import (
"github.com/coze-dev/coze-studio/backend/pkg/errorx/code"
)
// single agent: 100 000 000 ~ 100 999 999
const (
ErrAgentInvalidParamCode = 100000000
ErrAgentSupportedChatModelProtocol = 100000001
ErrAgentResourceNotFound = 100000002
ErrAgentPermissionCode = 100000003
ErrAgentIDGenFailCode = 100000004
ErrAgentCreateDraftCode = 100000005
ErrAgentGetCode = 100000006
ErrAgentUpdateCode = 100000007
ErrAgentSetDraftBotDisplayInfo = 100000008
ErrAgentGetDraftBotDisplayInfoNotFound = 100000009
ErrAgentPublishSingleAgentCode = 100000010
ErrAgentAlreadyBindDatabaseCode = 100000011
ErrAgentExecuteErrCode = 100000012
)
func init() {
code.Register(
ErrAgentPublishSingleAgentCode,
"publish single agent failed",
code.WithAffectStability(true),
)
code.Register(
ErrAgentGetDraftBotDisplayInfoNotFound,
"get draft bot display info failed",
code.WithAffectStability(true),
)
code.Register(
ErrAgentSetDraftBotDisplayInfo,
"set draft bot display info failed",
code.WithAffectStability(true),
)
code.Register(
ErrAgentUpdateCode,
"update single agent failed",
code.WithAffectStability(true),
)
code.Register(
ErrAgentGetCode,
"get single agent failed",
code.WithAffectStability(true),
)
code.Register(
ErrAgentCreateDraftCode,
"create single agent failed",
code.WithAffectStability(true),
)
code.Register(
ErrAgentIDGenFailCode,
"gen id failed : {msg}",
code.WithAffectStability(true),
)
code.Register(
ErrAgentPermissionCode,
"unauthorized access : {msg}",
code.WithAffectStability(false),
)
code.Register(
ErrAgentResourceNotFound,
"{type} not found: {id}",
code.WithAffectStability(false),
)
code.Register(
ErrAgentSupportedChatModelProtocol,
"unsupported chat model protocol : {protocol}",
code.WithAffectStability(false),
)
code.Register(
ErrAgentInvalidParamCode,
"invalid parameter : {msg}",
code.WithAffectStability(false),
)
code.Register(
ErrAgentAlreadyBindDatabaseCode,
"already bind database : {msg}",
code.WithAffectStability(false),
)
code.Register(
ErrAgentExecuteErrCode,
"systemt error",
code.WithAffectStability(true),
)
}

View File

@@ -0,0 +1,48 @@
/*
* 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 errno
import "github.com/coze-dev/coze-studio/backend/pkg/errorx/code"
// App: 101 000 000 ~ 101 999 999
const (
ErrAppInvalidParamCode = 101000000
ErrAppPermissionCode = 101000001
ErrAppRecordNotFound = 109000002
)
const APPMsgKey = "msg"
func init() {
code.Register(
ErrAppPermissionCode,
"unauthorized access : {msg}",
code.WithAffectStability(false),
)
code.Register(
ErrAppInvalidParamCode,
"invalid parameter : {msg}",
code.WithAffectStability(false),
)
code.Register(
ErrAppRecordNotFound,
"record not found",
code.WithAffectStability(false),
)
}

View File

@@ -0,0 +1,46 @@
/*
* 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 errno
import "github.com/coze-dev/coze-studio/backend/pkg/errorx/code"
// Connector: 102 000 000 ~ 102 999 999
const (
ErrConnectorInvalidParamCode = 102000000
ErrConnectorPermissionCode = 102000001
ErrConnectorNotFound = 102000002
)
func init() {
code.Register(
ErrConnectorNotFound,
"connector not found : {id}",
code.WithAffectStability(false),
)
code.Register(
ErrConnectorPermissionCode,
"unauthorized access : {msg}",
code.WithAffectStability(false),
)
code.Register(
ErrConnectorInvalidParamCode,
"invalid parameter : {msg}",
code.WithAffectStability(false),
)
}

View File

@@ -0,0 +1,96 @@
/*
* 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 errno
import "github.com/coze-dev/coze-studio/backend/pkg/errorx/code"
// Conversation: 103 000 000 ~ 103 999 999
const (
ErrConversationInvalidParamCode = 103000000
ErrConversationPermissionCode = 103000001
ErrConversationNotFound = 103000002
ErrConversationJsonMarshal = 103000003
ErrConversationAgentRunError = 103100001
ErrAgentNotExists = 103100002
ErrReplyUnknowEventType = 103100003
ErrUnknowInterruptType = 103100004
ErrInterruptDataEmpty = 103100005
ErrConversationMessageNotFound = 103200001
)
func init() {
code.Register(
ErrConversationJsonMarshal,
"json marshal failed",
code.WithAffectStability(true),
)
code.Register(
ErrConversationNotFound,
"conversation not found",
code.WithAffectStability(false),
)
code.Register(
ErrConversationPermissionCode,
"unauthorized access : {msg}",
code.WithAffectStability(false),
)
code.Register(
ErrConversationInvalidParamCode,
"invalid parameter : {msg}",
code.WithAffectStability(false),
)
code.Register(
ErrConversationAgentRunError,
"agent run error : {msg}",
code.WithAffectStability(true),
)
code.Register(
ErrAgentNotExists,
"agent not exists",
code.WithAffectStability(false),
)
code.Register(
ErrConversationMessageNotFound,
"message not found",
code.WithAffectStability(false),
)
code.Register(
ErrReplyUnknowEventType,
"unknow event type",
code.WithAffectStability(true),
)
code.Register(
ErrUnknowInterruptType,
"unknow interrupt type",
code.WithAffectStability(true),
)
code.Register(
ErrInterruptDataEmpty,
"interrupt data is empty",
code.WithAffectStability(true),
)
}

View File

@@ -0,0 +1,277 @@
/*
* 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 errno
import "github.com/coze-dev/coze-studio/backend/pkg/errorx/code"
// Knowledge: 105 000 000 ~ 105 999 999
const (
ErrKnowledgeInvalidParamCode = 105000000
ErrKnowledgePermissionCode = 105000001
ErrKnowledgeNonRetryableCode = 105000002
ErrKnowledgeDBCode = 105000003
ErrKnowledgeSearchStoreCode = 105000004
ErrKnowledgeSystemCode = 105000005
ErrKnowledgeCrossDomainCode = 105000006
ErrKnowledgeEmbeddingCode = 105000007
ErrKnowledgeIDGenCode = 105000008
ErrKnowledgeMQSendFailCode = 105000009
ErrKnowledgeDuplicateCode = 105000010
ErrKnowledgeNotExistCode = 105000011
ErrKnowledgeDocumentNotExistCode = 105000012
ErrKnowledgeSemanticColumnValueEmptyCode = 105000013
ErrKnowledgeParseJSONCode = 105000014
ErrKnowledgeResegmentNotSupportedCode = 105000015
ErrKnowledgeFieldNameDuplicatedCode = 105000016
ErrKnowledgeDocOversizeCode = 105000017
ErrKnowledgeDocNotReadyCode = 105000018
ErrKnowledgeDownloadFailedCode = 105000019
ErrKnowledgeTableInfoNotExistCode = 105000020
ErrKnowledgePutObjectFailCode = 105000021
ErrKnowledgeGetObjectURLFailCode = 105000022
ErrKnowledgeGetDocProgressFailCode = 105000023
ErrKnowledgeSliceInsertPositionIllegalCode = 105000024
ErrKnowledgeSliceNotExistCode = 105000025
ErrKnowledgeColumnParseFailCode = 105000026
ErrKnowledgeAutoAnnotationNotSupportedCode = 105000027
ErrKnowledgeGetParserFailCode = 105000028
ErrKnowledgeGetObjectFailCode = 105000029
ErrKnowledgeParserParseFailCode = 105000030
ErrKnowledgeBuildRetrieveChainFailCode = 105000031
ErrKnowledgeRetrieveExecFailCode = 105000032
ErrKnowledgeNL2SqlExecFailCode = 105000033
ErrKnowledgeCopyFailCode = 105000034
ErrKnowledgeParseResultEmptyCode = 105000035
ErrKnowledgeCacheClientSetFailCode = 105000036
ErrKnowledgeCheckTableSliceValidCode = 105000037
)
func init() {
code.Register(
ErrKnowledgeNonRetryableCode,
"non-retryable error",
code.WithAffectStability(false),
)
code.Register(
ErrKnowledgePermissionCode,
"unauthorized access : {msg}",
code.WithAffectStability(false),
)
code.Register(
ErrKnowledgeInvalidParamCode,
"invalid parameter : {msg}",
code.WithAffectStability(false),
)
code.Register(
ErrKnowledgeDBCode,
"MySQL operation failed: {msg}",
code.WithAffectStability(false),
)
code.Register(
ErrKnowledgeSearchStoreCode,
"SearchStore operation failed: {msg}",
code.WithAffectStability(false),
)
code.Register(
ErrKnowledgeSystemCode,
"system internal error: {msg}",
code.WithAffectStability(false),
)
code.Register(
ErrKnowledgeCrossDomainCode,
"cross-domain error: {msg}",
code.WithAffectStability(false),
)
code.Register(
ErrKnowledgeEmbeddingCode,
"embedding error: {msg}",
code.WithAffectStability(false),
)
code.Register(
ErrKnowledgeIDGenCode,
"ID generation failed: {msg}",
code.WithAffectStability(false),
)
code.Register(
ErrKnowledgeMQSendFailCode,
"MQ send message failed: {msg}",
code.WithAffectStability(false),
)
code.Register(
ErrKnowledgeDuplicateCode,
"knowledge name duplicate: {msg}",
code.WithAffectStability(false),
)
code.Register(
ErrKnowledgeNotExistCode,
"knowledge not exist: {msg}",
code.WithAffectStability(false),
)
code.Register(
ErrKnowledgeDocumentNotExistCode,
"document not exist: {msg}",
code.WithAffectStability(false),
)
code.Register(
ErrKnowledgeSemanticColumnValueEmptyCode,
"semantic column value empty: {msg}",
code.WithAffectStability(false),
)
code.Register(
ErrKnowledgeParseJSONCode,
"parse json failed: {msg}",
code.WithAffectStability(false),
)
code.Register(
ErrKnowledgeResegmentNotSupportedCode,
"Processing, resegment is not supported: {msg}",
code.WithAffectStability(false),
)
code.Register(
ErrKnowledgeFieldNameDuplicatedCode,
"field name duplicated: {msg}",
code.WithAffectStability(false),
)
code.Register(
ErrKnowledgeDocOversizeCode,
"document oversize: {msg}",
code.WithAffectStability(false),
)
code.Register(
ErrKnowledgeDocNotReadyCode,
"document not ready: {msg}",
code.WithAffectStability(false),
)
code.Register(
ErrKnowledgeDownloadFailedCode,
"download failed: {msg}",
code.WithAffectStability(false),
)
code.Register(
ErrKnowledgeGetObjectURLFailCode,
"get object url failed: {msg}",
code.WithAffectStability(false),
)
code.Register(
ErrKnowledgeTableInfoNotExistCode,
"table info not exist: {msg}",
code.WithAffectStability(false),
)
code.Register(
ErrKnowledgeGetDocProgressFailCode,
"get document progress failed: {msg}",
code.WithAffectStability(false),
)
code.Register(
ErrKnowledgeSliceInsertPositionIllegalCode,
"slice insert position illegal: {msg}",
code.WithAffectStability(false),
)
code.Register(
ErrKnowledgeSliceNotExistCode,
"slice not exist: {msg}",
code.WithAffectStability(false),
)
code.Register(
ErrKnowledgeColumnParseFailCode,
"column parse failed: {msg}",
code.WithAffectStability(false),
)
code.Register(
ErrKnowledgeAutoAnnotationNotSupportedCode,
"auto annotation not supported: {msg}",
code.WithAffectStability(false),
)
code.Register(
ErrKnowledgeGetParserFailCode,
"get parser failed: {msg}",
code.WithAffectStability(false),
)
code.Register(
ErrKnowledgeGetObjectFailCode,
"get object failed: {msg}",
code.WithAffectStability(false),
)
code.Register(
ErrKnowledgeParserParseFailCode,
"parser parse failed: {msg}",
code.WithAffectStability(false),
)
code.Register(
ErrKnowledgeBuildRetrieveChainFailCode,
"build retrieve chain failed: {msg}",
code.WithAffectStability(false),
)
code.Register(
ErrKnowledgeRetrieveExecFailCode,
"retrieve exec failed: {msg}",
code.WithAffectStability(false),
)
code.Register(
ErrKnowledgeNL2SqlExecFailCode,
"nl2sql exec failed: {msg}",
code.WithAffectStability(false),
)
code.Register(
ErrKnowledgeCopyFailCode,
"copy failed: {msg}",
code.WithAffectStability(false),
)
code.Register(
ErrKnowledgeParseResultEmptyCode,
"parse result empty: {msg}",
code.WithAffectStability(false),
)
code.Register(
ErrKnowledgeCacheClientSetFailCode,
"cache client set failed: {msg}",
code.WithAffectStability(false),
)
code.Register(
ErrKnowledgeCheckTableSliceValidCode,
"slice content validation failed, please check if the input is correct:{msg}",
code.WithAffectStability(false),
)
}

View File

@@ -0,0 +1,213 @@
/*
* 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 errno
import "github.com/coze-dev/coze-studio/backend/pkg/errorx/code"
// Memory: 106 000 000 ~ 106 999 999
const (
ErrMemoryInvalidParamCode = 106000000
ErrMemoryPermissionCode = 106000001
ErrMemoryIDGenFailCode = 106000002
ErrMemorySchemeInvalidCode = 106000003
ErrMemoryGetAppVariableCode = 106000004
ErrMemoryCreateAppVariableCode = 106000005
ErrMemoryUpdateAppVariableCode = 106000006
ErrMemoryGetVariableMetaCode = 106000007
ErrMemoryVariableMetaNotFoundCode = 106000008
ErrMemoryNoVariableCanBeChangedCode = 106000009
ErrMemoryDeleteVariableInstanceCode = 106000010
ErrMemoryGetSysUUIDInstanceCode = 106000011
ErrMemoryGetVariableInstanceCode = 106000012
ErrMemorySetKvMemoryItemInstanceCode = 106000013
ErrMemoryUpdateVariableInstanceCode = 106000014
ErrMemoryInsertVariableInstanceCode = 106000015
ErrMemoryDatabaseFieldNotFoundCode = 106000016
ErrMemoryDatabaseNotFoundCode = 106000017
ErrMemoryDatabaseCannotAddData = 106000018
ErrMemoryDatabaseColumnNotMatch = 106000019
ErrMemoryDatabaseXlsSheetEmpty = 106000020
ErrMemoryDatabaseSheetSizeExceed = 106000021
ErrMemoryDatabaseUnsupportedFileType = 106000022
ErrMemoryDatabaseSheetRowCountExceed = 106000023
ErrMemoryDatabaseSheetIndexExceed = 106000024
ErrMemoryDatabaseNoSheetFound = 106000025
ErrMemoryDatabaseNameInvalid = 106000026
)
func init() {
code.Register(
ErrMemorySchemeInvalidCode,
"schema is invalid : {msg}",
code.WithAffectStability(false),
)
code.Register(
ErrMemoryGetAppVariableCode,
"get project variable failed ",
code.WithAffectStability(true),
)
code.Register(
ErrMemoryCreateAppVariableCode,
"get project variable failed ",
code.WithAffectStability(true),
)
code.Register(
ErrMemoryUpdateAppVariableCode,
"update project variable failed ",
code.WithAffectStability(true),
)
code.Register(
ErrMemoryGetVariableMetaCode,
"get variable meta failed ",
code.WithAffectStability(true),
)
code.Register(
ErrMemoryVariableMetaNotFoundCode,
"variable meta not found ",
code.WithAffectStability(false),
)
code.Register(
ErrMemoryNoVariableCanBeChangedCode,
"no variable can be changed ",
code.WithAffectStability(false),
)
code.Register(
ErrMemoryDeleteVariableInstanceCode,
"delete variable instance failed",
code.WithAffectStability(true),
)
code.Register(
ErrMemoryGetSysUUIDInstanceCode,
"get sys uuid instance failed {msg}",
code.WithAffectStability(false),
)
code.Register(
ErrMemoryGetVariableInstanceCode,
"get sys uuid instance failed {msg}",
code.WithAffectStability(true),
)
code.Register(
ErrMemorySetKvMemoryItemInstanceCode,
"no key can be changed",
code.WithAffectStability(false),
)
code.Register(
ErrMemoryUpdateVariableInstanceCode,
"update variable instance failed",
code.WithAffectStability(true),
)
code.Register(
ErrMemoryInsertVariableInstanceCode,
"insert variable instance failed",
code.WithAffectStability(true),
)
code.Register(
ErrMemoryIDGenFailCode,
"gen id failed : {msg}",
code.WithAffectStability(true),
)
code.Register(
ErrMemoryPermissionCode,
"unauthorized access : {msg}",
code.WithAffectStability(false),
)
code.Register(
ErrMemoryInvalidParamCode,
"invalid parameter : {msg}",
code.WithAffectStability(false),
)
code.Register(
ErrMemoryDatabaseFieldNotFoundCode,
"database field not found",
code.WithAffectStability(false),
)
code.Register(
ErrMemoryDatabaseNotFoundCode,
"database not found",
code.WithAffectStability(false),
)
code.Register(
ErrMemoryDatabaseCannotAddData,
"database cannot add data",
code.WithAffectStability(false),
)
code.Register(
ErrMemoryDatabaseColumnNotMatch,
"database column not match : {msg}",
code.WithAffectStability(false),
)
code.Register(
ErrMemoryDatabaseXlsSheetEmpty,
"database xls sheet empty",
code.WithAffectStability(false),
)
code.Register(
ErrMemoryDatabaseSheetSizeExceed,
"database sheet size exceed",
code.WithAffectStability(false),
)
code.Register(
ErrMemoryDatabaseUnsupportedFileType,
"database unsupported file type",
code.WithAffectStability(false),
)
code.Register(
ErrMemoryDatabaseSheetRowCountExceed,
"database sheet row count exceed : {msg}",
code.WithAffectStability(false),
)
code.Register(
ErrMemoryDatabaseSheetIndexExceed,
"database sheet index exceed",
code.WithAffectStability(false),
)
code.Register(
ErrMemoryDatabaseNoSheetFound,
"database no sheet found",
code.WithAffectStability(false),
)
code.Register(
ErrMemoryDatabaseNameInvalid,
"database name invalid",
code.WithAffectStability(false),
)
}

View File

@@ -0,0 +1,39 @@
/*
* 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 errno
import "github.com/coze-dev/coze-studio/backend/pkg/errorx/code"
// ModelMgr: 107 000 000 ~ 107 999 999
const (
ErrModelMgrInvalidParamCode = 107000000
ErrModelMgrPermissionCode = 107000001
)
func init() {
code.Register(
ErrModelMgrPermissionCode,
"unauthorized access : {msg}",
code.WithAffectStability(false),
)
code.Register(
ErrModelMgrInvalidParamCode,
"invalid parameter : {msg}",
code.WithAffectStability(false),
)
}

View File

@@ -0,0 +1,32 @@
/*
* 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 errno
import "github.com/coze-dev/coze-studio/backend/pkg/errorx/code"
// Permission: 108 000 000 ~ 108 999 999
const (
ErrPermissionInvalidParamCode = 108000000
)
func init() {
code.Register(
ErrPermissionInvalidParamCode,
"invalid parameter : {msg}",
code.WithAffectStability(false),
)
}

View File

@@ -0,0 +1,125 @@
/*
* 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 errno
import (
"fmt"
"github.com/coze-dev/coze-studio/backend/pkg/errorx/code"
)
// Plugin: 109 000 000 ~ 109 999 999
const (
ErrPluginInvalidParamCode = 109000000
ErrPluginPermissionCode = 109000001
ErrPluginInvalidClientCredentialsCode = 109000002
ErrPluginInvalidOpenapi3Doc = 109000003
ErrPluginInvalidManifest = 109000004
ErrPluginRecordNotFound = 109000005
ErrPluginDeactivatedTool = 109000006
ErrPluginDuplicatedTool = 109000007
ErrPluginInvalidThirdPartyCode = 109000008
ErrPluginExecuteToolFailed = 109000009
ErrPluginConvertProtocolFailed = 109000010
ErrPluginToolsCheckFailed = 109000011
ErrPluginParseToolRespFailed = 109000012
ErrPluginOAuthFailed = 109000013
)
const (
PluginMsgKey = "msg"
)
func init() {
code.Register(
ErrPluginPermissionCode,
fmt.Sprintf("unauthorized access : {%s}", PluginMsgKey),
code.WithAffectStability(false),
)
code.Register(
ErrPluginInvalidParamCode,
fmt.Sprintf("invalid parameter : {%s}", PluginMsgKey),
code.WithAffectStability(false),
)
code.Register(
ErrPluginInvalidClientCredentialsCode,
"invalid client credentials",
code.WithAffectStability(false),
)
code.Register(
ErrPluginInvalidOpenapi3Doc,
fmt.Sprintf("invalid plugin openapi3 document : {%s}", PluginMsgKey),
code.WithAffectStability(false),
)
code.Register(
ErrPluginInvalidManifest,
fmt.Sprintf("invalid plugin manifest : {%s}", PluginMsgKey),
code.WithAffectStability(false),
)
code.Register(
ErrPluginRecordNotFound,
fmt.Sprintf("record not found"),
code.WithAffectStability(false),
)
code.Register(
ErrPluginDeactivatedTool,
fmt.Sprintf("tool is deactivated : {%s}", PluginMsgKey),
code.WithAffectStability(false),
)
code.Register(
ErrPluginDuplicatedTool,
fmt.Sprintf("duplicated tool : {%s}", PluginMsgKey),
code.WithAffectStability(false),
)
code.Register(
ErrPluginExecuteToolFailed,
fmt.Sprintf("execute tool failed : {%s}", PluginMsgKey),
code.WithAffectStability(false),
)
code.Register(
ErrPluginConvertProtocolFailed,
fmt.Sprintf("convert protocol failed : {%s}", PluginMsgKey),
code.WithAffectStability(false),
)
code.Register(
ErrPluginToolsCheckFailed,
fmt.Sprintf("tools check failed : {%s}", PluginMsgKey),
code.WithAffectStability(false),
)
code.Register(
ErrPluginParseToolRespFailed,
fmt.Sprintf("parse tool response failed : {%s}", PluginMsgKey),
code.WithAffectStability(false),
)
code.Register(
ErrPluginOAuthFailed,
fmt.Sprintf("oauth failed : {%s}", PluginMsgKey),
code.WithAffectStability(false),
)
}

View File

@@ -0,0 +1,80 @@
/*
* 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 errno
import "github.com/coze-dev/coze-studio/backend/pkg/errorx/code"
// Prompt: 110 000 000 ~ 110 999 999
const (
ErrPromptInvalidParamCode = 110000000
ErrPromptPermissionCode = 110000001
ErrPromptIDGenFailCode = 110000002
ErrPromptCreateCode = 110000003
ErrPromptGetCode = 110000004
ErrPromptDataNotFoundCode = 110000005
ErrPromptUpdateCode = 110000006
ErrPromptDeleteCode = 110000007
)
func init() {
code.Register(
ErrPromptDeleteCode,
"delete prompt resource failed",
code.WithAffectStability(true),
)
code.Register(
ErrPromptUpdateCode,
"update prompt resource failed",
code.WithAffectStability(true),
)
code.Register(
ErrPromptDataNotFoundCode,
"prompt resource not found",
code.WithAffectStability(false),
)
code.Register(
ErrPromptGetCode,
"get prompt resource failed",
code.WithAffectStability(true),
)
code.Register(
ErrPromptCreateCode,
"create prompt resource failed",
code.WithAffectStability(true),
)
code.Register(
ErrPromptIDGenFailCode,
"gen id failed : {msg}",
code.WithAffectStability(true),
)
code.Register(
ErrPromptPermissionCode,
"unauthorized access : {msg}",
code.WithAffectStability(false),
)
code.Register(
ErrPromptInvalidParamCode,
"invalid parameter : {msg}",
code.WithAffectStability(false),
)
}

View File

@@ -0,0 +1,39 @@
/*
* 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 errno
import "github.com/coze-dev/coze-studio/backend/pkg/errorx/code"
// Search: 111 000 000 ~ 111 999 999
const (
ErrSearchInvalidParamCode = 111000000
ErrSearchPermissionCode = 111000001
)
func init() {
code.Register(
ErrSearchPermissionCode,
"unauthorized access : {msg}",
code.WithAffectStability(false),
)
code.Register(
ErrSearchInvalidParamCode,
"invalid parameter : {msg}",
code.WithAffectStability(false),
)
}

View File

@@ -0,0 +1,39 @@
/*
* 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 errno
import "github.com/coze-dev/coze-studio/backend/pkg/errorx/code"
// ShortCmd: 112 000 000 ~ 112 999 999
const (
ErrShortCmdInvalidParamCode = 112000000
ErrShortCmdPermissionCode = 112000002
)
func init() {
code.Register(
ErrShortCmdPermissionCode,
"unauthorized access : {msg}",
code.WithAffectStability(false),
)
code.Register(
ErrShortCmdInvalidParamCode,
"invalid parameter : {msg}",
code.WithAffectStability(false),
)
}

View File

@@ -0,0 +1,102 @@
/*
* 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 errno
import "github.com/coze-dev/coze-studio/backend/pkg/errorx/code"
// Upload: 104 000 000 ~ 104 999 999
const (
ErrUploadInvalidParamCode = 104000000
ErrUploadPermissionCode = 104000001
ErrUploadInvalidType = 104000002
ErrUploadInvalidContentTypeCode = 104000003
ErrUploadInvalidFileSizeCode = 104000004
ErrUploadMultipartFormDataReadFailedCode = 104000005
ErrUploadEmptyFileCode = 104000006
ErrUploadFileUploadGreaterOneCode = 104000007
ErrUploadSystemErrorCode = 104000008
ErrUploadHostNotExistCode = 104000009
ErrUploadHostSchemaNotExistCode = 104000010
)
func init() {
code.Register(
ErrUploadInvalidType,
"invalid Upload type : {type}",
code.WithAffectStability(false),
)
code.Register(
ErrUploadPermissionCode,
"unauthorized access : {msg}",
code.WithAffectStability(false),
)
code.Register(
ErrUploadInvalidParamCode,
"invalid parameter : {msg}",
code.WithAffectStability(false),
)
code.Register(
ErrUploadInvalidContentTypeCode,
"invalid content-type : {content-type}",
code.WithAffectStability(false),
)
code.Register(
ErrUploadInvalidFileSizeCode,
"文件size过大",
code.WithAffectStability(false),
)
code.Register(
ErrUploadMultipartFormDataReadFailedCode,
"multipart form data read failed",
code.WithAffectStability(false),
)
code.Register(
ErrUploadEmptyFileCode,
"upload fileopencan't find file",
code.WithAffectStability(false),
)
code.Register(
ErrUploadFileUploadGreaterOneCode,
"upload fileopenexceed one file",
code.WithAffectStability(false),
)
code.Register(
ErrUploadSystemErrorCode,
"system error : {msg}",
code.WithAffectStability(false),
)
code.Register(
ErrUploadHostNotExistCode,
"upload host not exist",
code.WithAffectStability(false),
)
code.Register(
ErrUploadHostSchemaNotExistCode,
"upload host schema not exist",
code.WithAffectStability(false),
)
}

View File

@@ -0,0 +1,77 @@
/*
* 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 errno
import (
"github.com/coze-dev/coze-studio/backend/pkg/errorx/code"
)
// Passport: 700 000 000 ~ 700 999 999
const (
ErrUserAuthenticationFailed = 700012006 // Don't change this code. It is used in the frontend.
ErrUserEmailAlreadyExistCode = 700000001
ErrUserUniqueNameAlreadyExistCode = 700000002
ErrUserInfoInvalidateCode = 700000003
ErrUserSessionInvalidateCode = 700000004
ErrUserResourceNotFound = 700000005
ErrUserInvalidParamCode = 700000006
ErrUserPermissionCode = 700000007
)
func init() {
code.Register(
ErrUserPermissionCode,
"unauthorized access : {msg}",
code.WithAffectStability(false),
)
code.Register(
ErrUserInvalidParamCode,
"invalid parameter : {msg}",
code.WithAffectStability(false),
)
code.Register(
ErrUserResourceNotFound,
"{type} not found: {id}",
code.WithAffectStability(false),
)
code.Register(
ErrUserInfoInvalidateCode,
"invalid email or password, please try again.",
code.WithAffectStability(false),
)
code.Register(
ErrUserUniqueNameAlreadyExistCode,
"unique name already exist : {name}",
code.WithAffectStability(false),
)
code.Register(
ErrUserEmailAlreadyExistCode,
"email already exist : {email}",
code.WithAffectStability(false),
)
code.Register(
ErrUserAuthenticationFailed,
"authentication failed: {reason}",
code.WithAffectStability(false),
)
}

View File

@@ -0,0 +1,299 @@
/*
* 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 errno
import (
"github.com/coze-dev/coze-studio/backend/pkg/errorx"
"github.com/coze-dev/coze-studio/backend/pkg/errorx/code"
)
const (
ErrWorkflowNotPublished = 720702011
ErrMissingRequiredParam = 720702002
ErrInterruptNotSupported = 720702078
ErrInvalidParameter = 720702001
ErrArrIndexOutOfRange = 720712014
ErrWorkflowExecuteFail = 720701013
ErrCodeExecuteFail = 305000002
ErrQuestionOptionsEmpty = 720712049
ErrNodeOutputParseFail = 720712023
ErrWorkflowTimeout = 720702085
ErrWorkflowNotFound = 720702004
ErrSerializationDeserializationFail = 720701011
ErrInternalBadRequest = 720701007
ErrSchemaConversionFail = 720702089
ErrWorkflowCompileFail = 720701003
ErrPluginAPIErr = 720701004
)
const (
ErrWorkflowSpecifiedVersionNotFound = 777777778
ErrWorkflowCanceledByUser = 777777777
ErrNodeTimeout = 777777776
ErrWorkflowOperationFail = 777777775
ErrIndexingNilArray = 777777774
ErrLLMStructuredOutputParseFail = 777777773
ErrCreateNodeFail = 777777772
ErrWorkflowSnapshotNotFound = 777777771
ErrNotifyWorkflowResourceChangeErr = 777777770
ErrInvalidVersionName = 777777769
ErrPluginIDNotFound = 777777768
ErrTOSError = 777777767
ErrToolIDNotFound = 777777766
ErrAuthorizationRequired = 777777765
ErrVariablesAPIFail = 777777764
ErrInputFieldMissing = 777777763
)
// stability problems
const (
ErrDatabaseError = 720700801
ErrRedisError = 720700803
ErrIDGenError = 720700808
)
const (
ErrOpenAPIWorkflowNotPublished = 6031
ErrOpenAPIBadRequest = 4000
ErrOpenAPIInterruptNotSupported = 6039
ErrOpenAPIWorkflowTimeout = 6023
)
func init() {
code.Register(
ErrWorkflowNotPublished,
"Workflow not published. The requested operation cannot be performed on an unpublished workflow. Please publish the workflow and try again.",
code.WithAffectStability(false),
)
code.Register(
ErrMissingRequiredParam,
"Missing required parameters {param}. Please review the API documentation and ensure all mandatory fields are included in your request.",
code.WithAffectStability(false),
)
code.Register(
ErrInterruptNotSupported,
"Synchronous requests do not support interruption. Please switch to asynchronous requests for interruptible operations.",
code.WithAffectStability(false),
)
code.Register(
ErrInvalidParameter,
"Invalid request parameters. Please check your input and ensure all required fields are correctly formatted and within allowed ranges.",
code.WithAffectStability(false),
)
code.Register(
ErrArrIndexOutOfRange,
"Array {arr_name} index out of bounds: The requested index {req_index} exceeds the array's length {arr_len}. Please ensure the index is within the valid range of the array. You can refer to debug_url for more details.",
code.WithAffectStability(false),
)
code.Register(
ErrIndexingNilArray,
"Array {arr_name} is nil: The requested index {req_index} cannot be extracted.",
code.WithAffectStability(false),
)
code.Register(
ErrWorkflowExecuteFail,
"Workflow execution failure: {cause}",
code.WithAffectStability(false),
)
code.Register(
ErrWorkflowOperationFail,
"Workflow operation failure: {cause}",
code.WithAffectStability(false),
)
code.Register(
ErrCodeExecuteFail,
"Function execution failed, please check the code of the function. Detail: {detail}",
code.WithAffectStability(false),
)
code.Register(
ErrQuestionOptionsEmpty,
"question option is empty",
code.WithAffectStability(false),
)
code.Register(
ErrNodeOutputParseFail,
"node output parse fail: {warnings}",
code.WithAffectStability(false),
)
code.Register(
ErrWorkflowCanceledByUser,
"workflow cancel by user",
code.WithAffectStability(false),
)
code.Register(
ErrNodeTimeout,
"node timeout",
code.WithAffectStability(false),
)
code.Register(
ErrWorkflowTimeout,
"Workflow execution timed out. Please check for long-running operations, optimize if possible, or retry later.",
code.WithAffectStability(false),
)
code.Register(
ErrLLMStructuredOutputParseFail,
"parse LLM structured output failed, please refer to LLM's raw output for detail.",
code.WithAffectStability(false),
)
code.Register(
ErrCreateNodeFail,
"create node {node_name} failed: {cause}",
code.WithAffectStability(false),
)
code.Register(
ErrDatabaseError,
"database operation failed",
code.WithAffectStability(true),
)
code.Register(
ErrRedisError,
"redis operation failed",
code.WithAffectStability(true),
)
code.Register(
ErrIDGenError,
"id generator failed",
code.WithAffectStability(true),
)
code.Register(
ErrWorkflowNotFound,
"workflow {id} not found, please check if the workflow exists and not deleted",
code.WithAffectStability(false),
)
code.Register(
ErrSerializationDeserializationFail,
"data serialization/deserialization fail, please contact support team",
code.WithAffectStability(false),
)
code.Register(
ErrWorkflowSnapshotNotFound,
"workflow {id} snapshot {commit_id} not found, please contact support team",
code.WithAffectStability(false),
)
code.Register(
ErrInternalBadRequest,
"one of the request parameters for {scene} is invalid, please contact support team",
code.WithAffectStability(false),
)
code.Register(
ErrSchemaConversionFail,
"schema conversion failed, please contact support team",
code.WithAffectStability(false),
)
code.Register(
ErrWorkflowCompileFail,
"workflow compile failed, please contact support team",
code.WithAffectStability(false),
)
code.Register(
ErrNotifyWorkflowResourceChangeErr,
"notify workflow resource change failed, please try again later",
code.WithAffectStability(false),
)
code.Register(
ErrInvalidVersionName,
"workflow version name is invalid",
code.WithAffectStability(false),
)
code.Register(
ErrPluginAPIErr,
"plugin api error",
code.WithAffectStability(false),
)
code.Register(
ErrPluginIDNotFound,
"plugin {id} not found",
code.WithAffectStability(false),
)
code.Register(
ErrTOSError,
"tos operation failed",
code.WithAffectStability(true),
)
code.Register(
ErrToolIDNotFound,
"tool {id} not found",
code.WithAffectStability(false),
)
code.Register(
ErrAuthorizationRequired,
"authorization required: {extra}",
code.WithAffectStability(false),
)
code.Register(
ErrVariablesAPIFail,
"variables API failed",
code.WithAffectStability(false),
)
code.Register(
ErrInputFieldMissing,
"input field {name} not found",
code.WithAffectStability(false),
)
}
var errnoMap = map[int]int{
ErrWorkflowNotPublished: ErrOpenAPIWorkflowNotPublished,
ErrMissingRequiredParam: ErrOpenAPIBadRequest,
ErrInterruptNotSupported: ErrOpenAPIInterruptNotSupported,
ErrInvalidParameter: ErrOpenAPIBadRequest,
ErrArrIndexOutOfRange: ErrOpenAPIBadRequest,
ErrWorkflowTimeout: ErrOpenAPIWorkflowTimeout,
}
func CodeForOpenAPI(err errorx.StatusError) int {
if err == nil {
return 0
}
if c, ok := errnoMap[int(err.Code())]; ok {
return c
}
return int(err.Code())
}