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,21 @@
/*
* 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.
*/
export enum BotDetailEvents {
BotDetailInitHooks = 'bot_detail_init_hooks',
BotDetailInitBot = 'bot_detail_init_bot',
BotDetailPublishGetDraftBotInfo = 'bot_detail_publish_get_draft_bot_info',
}

View File

@@ -0,0 +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.
*/
export enum ChatRoomEvents {
PayloadSocietyStateEmpty = 'chat_room_ws_payload_society_state_empty',
}

View File

@@ -0,0 +1,45 @@
/*
* 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 @typescript-eslint/naming-convention */
export enum CommonError {
/** webpack chunk load 失败 */
ChunkLoadError = 'chunk_load_error',
/** 参数校验类错误 */
parmasValidation = 'parmas_validation',
/** 返回结果 校验错误的 */
responseValidation = 'response_validation',
/** 错误 path */
errorPath = 'error_path',
/** fws 抛出的错误 */
fwsError = 'fws_error',
/** get tokens 初始化 */
getTokenInit = 'get_token_init',
/** get tokens get encode */
getTokenEncode = 'get_token_encode',
/** get tokens 错误 */
getTokenError = 'get_token_error',
/** 表单校验 error */
formValidation = 'form_validation',
/** 第三方登录失败 */
thirdPartyAuth = 'third_party_auth',
/** 用于常规的 Error */
normalError = 'normal_error',
/** 获取 bot diff error */
getBotDiffError = 'get_bot_diff_error',
/** merge bot diff error */
mergeBotDiffError = 'merge_bot_diff_error',
}

View File

@@ -0,0 +1,20 @@
/*
* 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.
*/
export enum CookieBannerEvents {
ParseStorageValueError = 'parse_storage_value_error',
GetLoginInfoError = 'get_login_info_error',
}

View File

@@ -0,0 +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.
*/
export enum CustomPlatformEvents {
CreateCustomPlat = 'create-custom-plat',
UpdateCustomPlat = 'update-custom-plat',
DeleteCustomPlat = 'delete-custom-plat',
GetCustomPlatList = 'get-custom-plat-list',
GetOauthConfig = 'get-oauth-config',
GetSpaceListFromCustomPlat = 'get-space-list-from-custom-plat',
GetOauthAppListFromCustomPlat = 'get-oauth-app-list-from-custom-plat',
UpdateCustomPlatOauthConfig = 'update-custom-plat-oauth-config',
}

View File

@@ -0,0 +1,31 @@
/*
* 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.
*/
export enum DatabaseEvents {
DatabaseUploadExcelFile = 'database_upload_excel_file',
DatabaseAddTable = 'database_add_table',
DatabaseAlterTable = 'database_alter_table',
DatabaseQueryTable = 'database_query_table',
DatabaseListTable = 'database_list_table',
DatabaseDeleteTable = 'database_delete_table',
DatabaseGetExcelInfo = 'database_get_excel_info',
DatabaseGetPreviewData = 'database_get_preview_data',
DatabaseAddFromExcel = 'database_add_from_excel',
DatabaseGetTaskInfo = 'database_get_task_info',
DatabaseNL2DB = 'database_nl2db',
DatabaseResetTableRecords = 'database_reset_table_records',
DatabaseGetExpertConfig = 'database_get_expert_config',
}

View File

@@ -0,0 +1,20 @@
/*
* 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.
*/
export enum EditorAutosaveEvents {
AutosaveSuccess = 'autosave_success',
AutosaveError = 'autosave_error',
}

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.
*/
import { WorkflowEvents } from './workflow-event';
import { VariableEvents } from './variable-event';
import { TemplateEvents } from './template-event';
import { SocialSceneEvents } from './social-scene-event';
import { PublishEvents } from './publish-event';
import { PluginEvents } from './plugin-event';
import { MultiAgentEvents } from './multi-agent';
import { KnowledgeEvents } from './knowledge-event';
import { InviteEvents } from './invite-event';
import { InteractionEvents } from './interaction-event';
import { FileboxEvents } from './filebox-event';
import { FeatureEvents } from './feature-event';
import { ExploreEvents } from './explore-event';
import { EditorAutosaveEvents } from './editor-autosave';
import { DatabaseEvents } from './database-event';
import { CustomPlatformEvents } from './custom-platform-event';
import { CookieBannerEvents } from './cookie-banner';
import { CommonError } from './common-error';
import { ChatRoomEvents } from './chat-room-event';
import { BotDetailEvents } from './bot-detail-event';
export type EventNames =
| InteractionEvents
| FeatureEvents
| CommonError
| KnowledgeEvents
| FileboxEvents
| DatabaseEvents
| PublishEvents
| VariableEvents
| BotDetailEvents
| ExploreEvents
| InviteEvents
| PluginEvents
| WorkflowEvents
| CookieBannerEvents
| SocialSceneEvents
| ChatRoomEvents
| EditorAutosaveEvents
| MultiAgentEvents
| TemplateEvents;
export const REPORT_EVENTS = {
...InteractionEvents,
...FeatureEvents,
...CommonError,
...KnowledgeEvents,
...FileboxEvents,
...DatabaseEvents,
...PublishEvents,
...VariableEvents,
...BotDetailEvents,
...ExploreEvents,
...InviteEvents,
...PluginEvents,
...WorkflowEvents,
...CookieBannerEvents,
...SocialSceneEvents,
...ChatRoomEvents,
...MultiAgentEvents,
...EditorAutosaveEvents,
...CustomPlatformEvents,
...TemplateEvents,
};

View File

@@ -0,0 +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.
*/
export enum ExploreEvents {
ExploreInitBotDetail = 'explore_init_bot_detail',
}

View File

@@ -0,0 +1,92 @@
/*
* 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 @typescript-eslint/naming-convention */
export enum FeatureEvents {
/**
* space event
*/
createSpace = 'create_space', // 创建空间
updateSpace = 'update_space', // 更新空间
transferSpace = 'transfer_space',
spaceMemberSearch = 'space_member_search',
spaceMemberDetail = 'space_member_detail', // 获取空间成员
spaceMemberAdd = 'space_member_add', // 空间添加成员
deleteSpace = 'delete_space',
leaveSpace = 'leave_space',
spaceParseMemberCsv = 'space_parse_member_csv',
spaceImportMembers = 'space_import_members',
/**
* user profile
*/
editUserProfile = 'edit_user_profile',
updateUserProfileCheck = 'update_user_profile_check',
getUserAuthList = 'user_auth_list',
/**
* http 图片转化测试用
*/
convertHttpImg = 'convert_http_img',
// content-box
loadContentBox = 'load-content-box',
/**
* publish-event
*/
publishPlatform = 'publish_platform',
unbindPublishPlatform = 'unbind_publish_platform',
generateChangeLog = 'generate_changelog',
recordChangeLog = 'record_changelog',
/**
* passport
*/
passportService = 'passport_service', // passport相关的全部请求
passportHttpRequestFail = 'passport_http_request_fail', // passport 请求失败(非业务失败)
InviteLinkCopySuccess = 'invite_link_copy_success',
JoinSpaceSuccess = 'join_space_success',
unhandledrejection = 'unhandledrejection',
oauthLogin = 'oauth_login',
/**
* 消息链路事件
*/
botDebugMessageSubmit = 'bot_debug_message_submit', // Bot执行调试发送消息
receiveMessage = 'receive_message',
emptyReceiveMessage = 'empty_receive_message',
messageReceiveSuggests = 'message_receive_suggests',
receiveTotalMessages = 'receive_total_messages',
getCategoryList = 'get_category_list', // explore获取分类列表
/**
* coze token
*/
getTokenSkus = 'get_token_Skus',
createTokenChargeOrder = 'create_token_charge_order',
/**
* coze open api
*/
openGetSpace = 'open_get_space',
openArcositeContent = 'open_arcosite_content',
openGetPatList = 'open_get_pat_list',
openPatAction = 'open_pat_action',
/**
* 协作模式长链接
*/
editWebSocketInit = 'edit_web_socket_init',
pluginIdeInit = 'plugin_ide_init', // plugin ide初始化监控
pluginIdeInitTrace = 'plugin_ide_init_trace', // plugin ide初始化性能监控
pluginIdeDispose = 'plugin_ide_dispose', // plugin ide dispose
// 路由重定向
pathFallbackRedirect = 'path_fallback_redirect',
}

View File

@@ -0,0 +1,27 @@
/*
* 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.
*/
export enum FileboxEvents {
SaveFileboxMode = 'save_filebox_mode',
GetFileboxPluginsInfo = 'get_filebox_plugin_info',
GetMDCardDetailPageInfo = 'get_card_detail_info',
GetMDCardDetailPageInfoInvalid = 'get_card_detail_info_invalid',
CopyFileboxApiName = 'copy_filebox_api_name',
FileBoxListFile = 'filebox_list_file',
FileBoxUpdateFile = 'filebox_update_file',
FileBoxDeleteFile = 'filebox_delete_file',
FileBoxUploadFile = 'filebox_upload_file',
}

View File

@@ -0,0 +1,17 @@
/*
* 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.
*/
/// <reference types='@coze-arch/bot-typings' />

View File

@@ -0,0 +1,22 @@
/*
* 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.
*/
export { type EventNames, REPORT_EVENTS } from './events';
export {
type DurationPoint,
type ReportEvent,
createReportEvent,
} from './report-event';

View File

@@ -0,0 +1,81 @@
/*
* 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 @typescript-eslint/naming-convention */
export enum InteractionEvents {
logout = 'logout',
loginStatusCheck = 'login_status_check',
getBotList = 'get_bot_list',
// getDiscoverBotList = 'get_discover_bot_list', -- deprecated
// getUserBotFavorite = 'get_user_bot_favorite', -- deprecated
createBot = 'create_bot',
updateBot = 'update_bot',
createOcean = 'create_ocean',
updateOcean = 'update_ocean',
// clickBotCard = 'click_bot_card', -- deprecated
getHistoryInfo = 'get_history_info',
publishBot = 'publish_bot', // Bot发布
// offlineBot = 'offline_bot', -- deprecated
botDebugMessageReploy = 'bot_debug_message_reploy', // Bot调试内容返回
getDatasetList = 'get_dataset_list', // 获取dataset列表
createDataSet = 'create_dataset', // 创建dataset
updateDataset = 'update_dataset', // 更新dataset
deleteDataset = 'delete_dataset',
submitDatasetUrl = 'submit_dataset_url',
uploadDatasetFile = 'upload_dataset_file',
processDatasetTask = 'process_dataset_task',
datasetGetSliceList = 'dataset_get_slice_list',
datasetChangeSliceStatus = 'dataset_change_slice_status',
datasetUpdateDocumnet = 'dataset_update_document',
datasetUpdateSliceContent = 'dataset_update_slice_content',
datasetUpdateWebRule = 'dataset_update_web_rule',
datasetCreateSlice = 'dataset_create_slice',
datasetDeleteSlice = 'dataset_delete_slice',
datasetCheckBot = 'dataset_check_bot',
processSubmitUrl = 'process_submit_url',
botDebugSaveAll = 'bot_debug_save_all',
botDebugShareBotGetLink = 'bot_debug_share_bot_get_link',
// botDebugShareBotOpen = 'bot_debug_share_bot_open', -- deprecated
// botDebugShareBotClose = 'bot_debug_share_bot_close', -- deprecated
botDebugGetRecord = 'bot_debug_get_record', // Bot详情页初始化
// botDebugCheckItemId = 'bot_debug_check_item_id', -- deprecated
botDebugAutosaveItem = 'bot_debug_autosave_item', // Bot自动保存
botDebugGetPluginList = 'bot_debug_get_plugin_list',
pluginPageGetPluginList = 'plugin_page_get_plugin_list',
botDebugUploadImage = 'bot_debug_upload_image',
// botCardShareBotGetLink = 'bot_card_share_bot_get_link', -- deprecated
botRevert = 'bot_revert',
botSubmit = 'bot_submit',
botMergeToDraft = 'bot_merge_to_draft',
botGetDraftBotInfo = 'bot_get_draft_bot_info', // bot获取详情
copy = 'copy',
botDuplicate = 'bot_duplicate',
botExperience = 'bot_experience',
botGetModelVoidTypeList = 'bot_get_model_voice_type_list',
botGetTaskIntro = 'bot_get_task_intro',
botCreatePresetTask = 'bot_create_preset_task',
botGetScheduleTasks = 'bot_get_schedule_tasks',
botRemoveScheduleTask = 'bot_remove_schedule_task',
parseJSON = 'parse_json_error',
botGetAiGenerateAvatar = 'bot_get_ai_generate_avatar', // AI生成头像
ttsVoiceConfig = 'tts_voice_config',
ttsVoiceToken = 'tts_voice_token',
ttsVoiceWs = 'tts_voice_ws',
audioPlayError = 'audio_play_error',
createDocument = 'create_document',
botSendMsg = 'bot_send_msg',
}

View File

@@ -0,0 +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.
*/
export enum InviteEvents {
InviteGetSpaceInfo = 'invite_get_space_info',
}

View File

@@ -0,0 +1,111 @@
/*
* 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.
*/
export enum KnowledgeEvents {
// knowledge
KnowledgeListDataset = 'knowledge_list_dataset',
KnowledgeCreateKnowledge = 'knowledge_create_knowledge',
KnowledgeUpdateKnowledge = 'knowledge_update_knowledge',
KnowledgeUpdateDocumentStatus = 'knowledge_update_document_status',
KnowledgeDeleteDocument = 'knowledge_delete_document',
KnowledgeListDocument = 'knowledge_list_document',
KnowledgeGetBotListByDataset = 'knowledge_get_bot_by_dataset',
KnowledgeCheckBot = 'knowledge_check_bot',
KnowledgeGetSliceList = 'knowledge_get_slice_list',
KnowledgeProcessDocument = 'knowledge_process_document',
KnowledgeSubmitWebURL = 'knowledge_submit_web_url',
KnowledgeQueryWebInfo = 'knowledge_query_web_info',
KnowledgeProcessWebDocument = 'knowledge_process_web_document',
KnowledgeCreateDocument = 'knowledge_create_document',
KnowledgeCreateSlice = 'knowledge_create_slice',
KnowledgeUpdateSlice = 'knowledge_update_slice',
KnowledgeDeleteSlice = 'knowledge_delete_slice',
KnowledgeUploadFile = 'knowledge_upload_file',
KnowledgeParseFile = 'knowledge_parse_file',
KnowledgeGetTaskProgress = 'knowledge_get_task_progress',
KnowledgeRenameDocument = 'knowledge_rename_document',
KnowledgeUpdateDocumentFrequency = 'knowledge_update_document_frequency',
KnowledgeUpdateDocumentName = 'knowledge_update_document_name',
KnowledgeGetThirdDataSource = 'Knowledge_get_third_data_source',
KnowledgeGetTableInfo = 'knowledge_get_table_info',
KnowledgeGetAuthorizeFile = 'knowledge_get_authorize_file',
KnowledgeUpdateDocument = 'knowledge_update_document',
KnowledgeResegment = 'knowledge_resegment',
KnowledgeTableSchemaValid = 'knowledge_table_schema_valid',
KnowledgeTableAddSegment = 'knowledge_table_add_segment',
KnowledgeDatasetsSegmentsFile = 'knowledge_datasets_segments_file',
KnowledgeUseListDataSetReq = 'knowledge_use_list_data_set_req',
KnowledgeListDataSet = 'knowledge_list_data_set',
KnowledgeParseSiteMapUrl = 'knowledge_parse_site_map_url',
KnowledgeCreateSubLinkDiscoveryTask = 'knowledge_create_sub_link_discovery_task',
KnowledgeGetSubLinkDiscoveryTask = 'knowledge_get_sub_link_discovery_task',
KnowledgeAbortSubLinkDiscoveryTask = 'knowledge_abort_sub_link_discovery_task',
KnowledgeSubmitBatchCrawlTask = 'knowledge_submit_batch_crawl_task',
KnowledgeSubmitBatchUrlCount = 'knowledge_submit_batch_url_count',
KnowledgeSourceGetURL = 'knowledge_source_get_url',
KnowledgePhotoList = 'knowledge_photo_list',
KnowledgeUpdatePhotoCaption = 'knowledge_update_photo_caption',
KnowledgeGeneratePhotoCaption = 'knowledge_generate_photo_caption',
KnowledgeFetchWebUrl = 'knowledge_fetch_web_url',
KnowledgeBatchUpdateDocument = 'knowledge_batch_update_document',
KnowledgeGetDatasetRefDetail = 'knowledge_get_dataset_ref_detail',
KnowledgeUpdateWechatFrequency = 'knowledge_update_wechat_frequency',
KnowledgeGetAuthList = 'knowledge_get_auth_list',
// timeCapsule
TimeCapsuleListItems = 'time_capsule_list_items',
TimeCapsuleClearItems = 'time_capsule_clear_items',
TimeCapsuleClearItemsInvalid = 'time_capsule_clear_items_invalid',
TimeCapsuleSummary = 'time_capsule_summary',
TimeCapsuleUpdateItem = 'time_capsule_update_item',
TimeCapsuleDeleteItems = 'time_capsule_delete_items',
TimeCapsulePluginJsonParseError = 'time_capsule_plugin_json_parse_error',
// third document
KnowledgeProcessThirdDocument = 'knowledge_process_third_document',
KnowledgeAssociateFile = 'knowledge_associate_file',
KnowledgeThirdAuth = 'knowledge_third_auth',
KnowledgeThirdFileCheck = 'knowledge_third_file_check',
// third dataSource
KnowledgeDataSourceFetch = 'knowledge_third_data_source_fetch',
KnowledgeDataSourceDelete = 'knowledge_third_data_source_delete',
KnowledgeGetThirdPartyGray = 'knowledge_get_third_party_gray',
//table view
KnowledgeTableViewGetColWidth = 'knowledge_table_view_get_col_width',
KnowledgeTableViewSetColWidth = 'knowledge_table_view_set_col_width',
// feishu
KnowledgeConnectorListFetch = 'knowledge_connector_list_fetch',
KnowledgeGetConnectorEntity = 'knowledge_get_connector_entity',
KnowledgeConnectorTaskSubmit = 'knowledge_connector_task_submit',
KnowledgeConnectorTaskRetry = 'knowledge_connector_task_retry',
KnowledgeConnectorTaskCancel = 'knowledge_connector_task_cancel',
KnowledgeConnectorTaskPoll = 'knowledge_connector_task_poll',
KnowledgeGetOAuthConsentURL = 'knowledge_get_oauth_url',
KnowledgeDeleteConnectorAuth = 'knowledge_delete_connector_auth',
KnowledgeSearchFeishuDocument = 'knowledge_search_feishu_document',
KnowledgeGetFeishuDocumentTreeList = 'knowledge_get_feishu_document_tree_list',
// bot页面中的知识库
KnowledgeGetDataSetList = 'knowledge_get_dataset_list',
// 新版知识库交互
KnowledgeGetDataSetDeatil = 'knowledge_get_dataset_detail',
KnowledgeRefreshDocument = 'knowledge_refresh_document',
}

View File

@@ -0,0 +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.
*/
export enum MultiAgentEvents {
BotLastPublishInfoError = 'bot_last_publish_info_error',
}

View File

@@ -0,0 +1,20 @@
/*
* 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.
*/
export enum PluginEvents {
PluginGetApis = 'plugin_get_apis',
PluginInitError = 'plugin_init_error',
}

View File

@@ -0,0 +1,20 @@
/*
* 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.
*/
export enum PublishEvents {
PublishCheckError = 'publish_check_error',
HistoryPublishResultError = 'history_publish_result_error',
}

View File

@@ -0,0 +1,185 @@
/*
* 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 { set } from 'lodash-es';
import { logger as globalLogger, type Logger } from '@coze-arch/logger';
import { type EventNames } from './events';
/** 描述用于计算 duration 的点位 */
export interface DurationPoint {
/** 点位名,一般是某个行为 */
pointName: string;
/** 当前时间戳,用于计算 duration */
time: number;
}
export interface ReportEvent {
/**
* 事件开始。记录 startTime后续用于计算 duration
* 注:创建事件时会自动执行,一般不需要调用
*/
start: () => void;
/**
* 上报成功事件。携带 success=1、duration 参数
*/
success: (payload?: { meta?: Record<string, unknown> }) => void;
/**
* 上报失败事件。携带 success=0、error、reason 参数
* - reason: 有限枚举,导致失败的原因
*/
error: (payload: {
reason: string;
error?: Error;
meta?: Record<string, unknown>;
}) => void;
/**
* 添加一个名为 @param pointName 的点位,用于计算 duration
*
* 假设有 [a、b、c] 三个点位,最终上报的 duration 是
* duration: {
* a: aTime - startTime,
* b: bTime - startTime,
* c: cTime - startTime,
* interval: {
* a: aTime - startTime,
* b: bTime - aTime,
* c: cTime - bTime,
* }
* }
*/
addDurationPoint: (pointName: string) => void;
/**
* 获取耗时
*/
getDuration: () => Record<string, number> | undefined;
/** 获取 Meta一般用于获取创建时设置的 meta 字段 */
getMeta: () => Record<string, unknown>;
}
//
/**
* 创建一个标准的上报事件
* - 成功success=1duration={...}
* - 失败success=0, reason, error
*/
/**
* @deprecated 该方法已废弃,请统一使用`import { reporter } from '@coze-arch/logger'的`reporter.tracer`替换,具体请查看:
*/
export const createReportEvent = ({
eventName,
logger: propsLogger,
meta: metaInCtx,
}: {
eventName: EventNames;
logger?: Logger;
meta?: Record<string, unknown>;
}): ReportEvent => {
const logger = propsLogger || globalLogger;
const durationPoints: DurationPoint[] = [];
let startTime = 0;
let isFinished = false;
const start = () => {
startTime = Date.now();
};
const getMetaInCtx = () => ({
...metaInCtx,
...(isFinished
? {
event_has_finished: true, // 标记事件已 success/error 过,提示可能存在问题
}
: {}),
});
const getDuration = () => {
if (durationPoints.length === 0) {
return;
}
return durationPoints.reduce<Record<string, number>>((acc, cur, index) => {
const { pointName } = cur;
acc[pointName] = cur.time - startTime;
set(
acc,
['interval', pointName],
index === 0
? acc[pointName]
: cur.time - durationPoints[index - 1].time,
);
return acc;
}, {});
};
const success = ({ meta }: { meta?: Record<string, unknown> } = {}) => {
logger.persist.success({
eventName,
meta: {
...getMetaInCtx(),
success: 1,
duration: getDuration(),
...meta,
},
});
isFinished = true;
};
const sendError = ({
reason,
error,
meta,
}: {
reason: string;
error?: Error;
meta?: Record<string, unknown>;
}) => {
logger.persist.error({
eventName,
error: error ? error : new Error(reason),
meta: {
...getMetaInCtx(),
success: 0,
reason,
...meta,
},
});
isFinished = true;
};
const addDurationPoint = (pointName: string) => {
durationPoints.push({
pointName,
time: Date.now(),
});
};
start();
return {
start,
addDurationPoint,
getDuration,
success,
error: sendError,
getMeta: getMetaInCtx,
};
};

View File

@@ -0,0 +1,24 @@
/*
* 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.
*/
export enum SocialSceneEvents {
ConfirmSceneModalError = 'confirm_scene_modal',
DeleteSceneMetaError = 'delete_scene_meta_error',
DuplicateSceneMetaError = 'duplicate_scene_meta_error',
SceneMetaListSearchError = 'scene_meta_list_search_error',
SceneMetaListLoadMoreError = 'scene_meta_list_load_more_error',
SceneModalCallbackIdEmptyError = 'scene_modal_callback_id_empty_error',
}

View File

@@ -0,0 +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.
*/
export enum TemplateEvents {
EmptyOrderCheckoutUrl = 'empty_order_checkout_url',
}

View File

@@ -0,0 +1,21 @@
/*
* 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.
*/
export enum VariableEvents {
VariableGetValue = 'variable_get_value',
VariableSetValue = 'variable_set_value',
VariableDeleteValue = 'variable_delete_value',
}

View File

@@ -0,0 +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.
*/
export enum WorkflowEvents {
WorkFlowOldError = 'work_flow_old_error',
}