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,65 @@
/*
* Copyright 2025 coze-dev Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { type TabDisplayItems } from '@coze-arch/bot-api/developer_api';
import { ToolKey, AgentSkillKey, ToolGroupKey } from './types';
export const TOOL_KEY_STORE_MAP = {
[ToolKey.PLUGIN]: 'pluginApis',
[ToolKey.SHORTCUT]: 'shortcut',
[ToolKey.DEV_HOOKS]: 'devHooks',
};
export const AGENT_SKILL_KEY_MAP = {
[AgentSkillKey.PLUGIN]: 'pluginApis',
};
export const TOOL_KEY_TO_API_STATUS_KEY_MAP: {
[key in ToolKey]: keyof TabDisplayItems;
} = {
[ToolKey.PLUGIN]: 'plugin_tab_status',
[ToolKey.WORKFLOW]: 'workflow_tab_status',
[ToolKey.IMAGEFLOW]: 'imageflow_tab_status',
[ToolKey.DATABASE]: 'database_tab_status',
[ToolKey.FILE_BOX]: 'filebox_tab_status',
[ToolKey.KNOWLEDGE]: 'knowledge_tab_status',
[ToolKey.ONBOARDING]: 'opening_dialog_tab_status',
[ToolKey.SUGGEST]: 'suggestion_tab_status',
[ToolKey.TRIGGER]: 'scheduled_task_tab_status',
[ToolKey.VARIABLE]: 'variable_tab_status',
[ToolKey.VOICE]: 'tts_tab_status',
[ToolKey.LONG_TERM_MEMORY]: 'long_term_memory_tab_status',
[ToolKey.BACKGROUND]: 'background_image_tab_status',
[ToolKey.TABLE]: 'knowledge_table_tab_status',
[ToolKey.DOCUMENT]: 'knowledge_text_tab_status',
[ToolKey.PHOTO]: 'knowledge_photo_tab_status',
[ToolKey.SHORTCUT]: 'shortcut_tab_status',
[ToolKey.DEV_HOOKS]: 'hook_info_tab_status',
[ToolKey.USER_INPUT]: 'default_user_input_tab_status',
};
/**
* 这里的顺序 决定展示的顺序 请注意
*/
export const TOOL_GROUP_CONFIG = {
[ToolGroupKey.SKILL]: 'Skill',
[ToolGroupKey.KNOWLEDGE]: 'Knowledge',
[ToolGroupKey.MEMORY]: 'Memory',
[ToolGroupKey.DIALOG]: 'Dialog',
[ToolGroupKey.CHARACTER]: 'Character',
[ToolGroupKey.HOOKS]: 'Hooks',
};

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.
*/
export {
AbilityScope,
ToolKey,
AgentSkillKey,
AgentModalTabKey,
AbilityKey,
ToolGroupKey,
SkillKeyEnum,
} from './types';
export {
TOOL_KEY_STORE_MAP,
AGENT_SKILL_KEY_MAP,
TOOL_KEY_TO_API_STATUS_KEY_MAP,
TOOL_GROUP_CONFIG,
} from './constants';
export {
ShortCutCommand,
TemplateShortCutForWorkFlow,
QueryShortCut,
TemplateShortCutForPlugin,
} from './shortcut-config/type';
export { getStrictShortcuts } from './shortcut-config/get-strict-shortcuts';
export { ShortCutStruct } from './shortcut-config/type';

View File

@@ -0,0 +1,42 @@
/*
* Copyright 2025 coze-dev Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {
type ShortcutCommand as ShortcutCommandFromService,
ToolType,
} from '@coze-arch/bot-api/playground_api';
import type { ShortCutCommand } from './type';
export function getStrictShortcuts(shortcuts?: ShortcutCommandFromService[]) {
return shortcuts?.filter((shortcut): shortcut is ShortCutCommand => {
const { tool_type } = shortcut;
const withoutCommandId = !shortcut.command_id;
// const panelWithoutCardSchema =
// send_type === SendType.SendTypePanel && !shortcut.card_schema;
const workflowWithoutWorkflowId =
tool_type === ToolType.ToolTypeWorkFlow && !shortcut.plugin_id;
const pluginWithoutPluginId =
tool_type === ToolType.ToolTypePlugin && !shortcut.plugin_id;
return !(
withoutCommandId ||
// panelWithoutCardSchema ||
workflowWithoutWorkflowId ||
pluginWithoutPluginId
);
});
}

View File

@@ -0,0 +1,89 @@
/*
* Copyright 2025 coze-dev Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import type {
SendType,
ShortcutCommand as ShortcutCommandFromService,
ToolType,
ShortcutStruct as ShortcutStructFromService,
} from '@coze-arch/bot-api/playground_api';
export type ShortCutStruct = Pick<
ShortcutStructFromService,
'shortcut_sort'
> & {
shortcut_list?: ShortCutCommand[];
};
export type ShortCutCommand =
| TemplateShortCutForWorkFlow
| TemplateShortCutForPlugin
| QueryShortCut;
type BaseShortCutInfo = Pick<
ShortcutCommandFromService,
'command_name' | 'template_query' | 'description' | 'send_type'
> & {
command_id: string;
object_id: string;
bot_info: {
icon_url?: string;
name?: string;
};
};
type WorkflowTool = Pick<
ShortcutCommandFromService,
'tool_type' | 'work_flow_id'
> & {
tool_type: ToolType.ToolTypeWorkFlow;
work_flow_id: string;
};
type PluginTool = Pick<
ShortcutCommandFromService,
'tool_type' | 'plugin_id' | 'plugin_api_name'
> & {
tool_type: ToolType.ToolTypePlugin;
plugin_id: string;
plugin_api_name: string;
plugin_api_id: string;
};
export type TemplateShortCutForWorkFlow = BaseShortCutInfo &
Omit<
ShortcutCommandFromService,
'send_type' | 'tool_type' | 'work_flow_id' | 'components_list'
> & {
send_type: SendType.SendTypePanel;
} & {
components_list: ShortcutCommandFromService['components_list'];
} & WorkflowTool;
export type TemplateShortCutForPlugin = BaseShortCutInfo &
Omit<
ShortcutCommandFromService,
'send_type' | 'tool_type' | 'plugin_id' | 'plugin_api_name'
> & {
send_type: SendType.SendTypePanel;
} & {
components_list: ShortcutCommandFromService['components_list'];
} & PluginTool;
export type QueryShortCut = BaseShortCutInfo &
Omit<ShortcutCommandFromService, 'send_type'> & {
send_type: SendType.SendTypeQuery;
};

View File

@@ -0,0 +1,91 @@
/*
* 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 const enum AbilityScope {
TOOL = 'tool',
AGENT_SKILL = 'agentSkill',
}
export type AbilityKey = ToolKey | AgentSkillKey;
/**
* ToolKey为了项目临时给大家起了一个名称如果觉得名称不好可以全局替换一下
*/
export const enum ToolKey {
PLUGIN = 'plugin',
WORKFLOW = 'workflow',
IMAGEFLOW = 'imageflow',
KNOWLEDGE = 'knowledge',
VARIABLE = 'variable',
DATABASE = 'database',
LONG_TERM_MEMORY = 'longTermMemory',
FILE_BOX = 'fileBox',
TRIGGER = 'trigger',
ONBOARDING = 'onboarding',
SUGGEST = 'suggest',
VOICE = 'voice',
BACKGROUND = 'background',
DOCUMENT = 'document',
TABLE = 'table',
PHOTO = 'photo',
SHORTCUT = 'shortcut',
DEV_HOOKS = 'devHooks',
USER_INPUT = 'userInput',
}
export const enum AgentSkillKey {
PLUGIN = 'plugin',
WORKFLOW = 'workflow',
KNOWLEDGE = 'knowledge',
}
export const enum AgentModalTabKey {
TOOLS = 'tools',
WORKFLOW = 'workflow',
DATASETS = 'datasets',
}
export const enum ToolGroupKey {
SKILL = 'skill',
KNOWLEDGE = 'knowledge',
MEMORY = 'memory',
DIALOG = 'dialog',
HOOKS = 'hooks',
CHARACTER = 'character',
}
/**
* 模块主键
* @deprecated 该使用方式已废弃, 请使用: `import { ToolKey } from '@coze-agent-ide/tool-config'`;
*/
export enum SkillKeyEnum {
/** Skills */
PLUGIN_API_BLOCK = 'plugin',
WORKFLOW_BLOCK = 'workflow',
IMAGE_BLOCK = 'imageflow',
/** Memory */
DATA_SET_BLOCK = 'knowledge',
DATA_MEMORY_BLOCK = 'variable',
TABLE_MEMORY_BLOCK = 'database',
TIME_CAPSULE_BLOCK = 'time_capsule',
FILEBOX_BLOCK = 'filebox',
/** Advanced */
TASK_MANAGE_BLOCK = 'scheduled_task',
ONBORDING_MESSAGE_BLOCK = 'opening_dialog',
AUTO_SUGGESTION = 'suggestion',
TEXT_TO_SPEECH = 'tts',
BACKGROUND_IMAGE_BLOCK = 'background_image',
}