chore: replace all cn comments of fe to en version by volc api (#320)

This commit is contained in:
tecvan
2025-07-31 10:32:15 +08:00
committed by GitHub
parent 716ec0cba8
commit 71f6245a01
2960 changed files with 15545 additions and 15545 deletions

View File

@@ -77,10 +77,10 @@ export const AgentSkillContentBlock = forwardRef<
const target = childNodeRef.current;
if (autoExpandWhenDomChange && target && allowToggleCollapsible) {
const config = { attributes: true, childList: true, subtree: true };
// 只有开启了dom改变自动展开功能才启动
// Only when the dom change auto-unfold function is turned on
const callback: MutationCallback = mutationList => {
if (mutationList.length > 0 && !isOpen) {
// 当dom改变并且没有开启时会自动开启
// When the dom changes and is not turned on, it will automatically turn on
setIsOpen(!isOpen);
}
};
@@ -113,15 +113,15 @@ export const AgentSkillContentBlock = forwardRef<
if (!allowToggleCollapsible) {
return;
}
// @danger 不可以阻止内部节点的点击冒泡,不然无法设置节点的选中态
// @Danger cannot prevent the click bubbling of internal nodes, otherwise the selected state of the node cannot be set
const el = e.target as HTMLElement;
// 这里需要多重判断,
// 第一次判断如果包含在container内才需要去切换open
// 第二次判断如果包含在action内则不能切换open其他都可以
// @TIP contains方法会判断自身节点,即A.contains(A)也是true。但是这里就算是自身也没有影响
// Multiple judgments are required here,
// The first judgment: If it is contained in the container, you need to switch open.
// Second judgment: If it is included in the action, it cannot switch open, everything else is OK
// The @TIP contains method will determine its own node, that is, A.contains (A) is also true. But even itself has no effect here
if (containerRef.current && containerRef.current.contains(el)) {
if (actionDivRef.current && actionDivRef.current.contains(el)) {
// 此时不切换open
// Do not switch open at this time
return;
}
setIsOpen(!isOpen);

View File

@@ -56,7 +56,7 @@ export const AgentSkillView: FC<PropsWithChildren<IProps>> = ({
useSubscribeToolStore(AbilityScope.AGENT_SKILL, agentId);
// 前置注册
// pre-registration
useEffect(() => {
Children.map(children, child => {
if (!hasValidAgentSkillKey(child)) {

View File

@@ -33,7 +33,7 @@ import { usePreference } from '../../context/preference-context';
import styles from './index.module.less';
/**
* 分组容器
* Packet container
* @see
*/
@@ -47,7 +47,7 @@ interface IProps {
export const GroupingContainer: FC<IProps> = props => {
const { children, title, toolGroupKey, actionNodes, className } = props;
// 容器在页面中的展示位置,不同位置样式有区别
// The placement of the container on the page is different in different position styles
const { placement } = useLayoutContext();
const { isReadonly } = usePreference();

View File

@@ -131,7 +131,7 @@ const TipsImplForKnowledge: FC<{
? ModelFuncConfigType.KnowledgeAutoCall
: ModelFuncConfigType.KnowledgeOnDemandCall
];
// 根据自动调用还是按需调用,获取另一个 status取合并
// According to the automatic call or on-demand call, get another status, take and merge
const [configStatus, modelName] = modelCapabilityConfig[configType];
const mergedStatus = mergeModelFuncConfigStatus(
autoConfigStatus,
@@ -152,7 +152,7 @@ const TipsImplForKnowledge: FC<{
<TipsDisplay
status={mergedStatus}
modelName={mergedStatus === autoConfigStatus ? autoModelName : modelName}
// 因为按需调用的提示合并到了这里,知识库显示 tips 时,需要显示具体不支持的能力(按需调用 / 知识库)
// Because the prompts for on-demand calls are merged here, when the knowledge base displays tips, it needs to display specific unsupported capabilities (on-demand calls/knowledge base)
toolName={mergedToolTittle.join(', ')}
/>
);
@@ -167,9 +167,9 @@ const ModelCapabilityTipsImpl = () => {
? abilityKey2ModelFunctionConfigType(abilityKey)
: undefined;
// 降低 useModelCapabilityConfig 调用频率
// Reduce the frequency of useModelCapabilityConfig calls
if (toolConfig && configType) {
// 知识库需要引入一个额外的判断是否是按需调用
// The knowledge base needs to introduce an additional judgment whether it is called on demand
if (toolConfig.toolGroupKey === ToolGroupKey.KNOWLEDGE) {
return (
<TipsImplForKnowledge
@@ -180,7 +180,7 @@ const ModelCapabilityTipsImpl = () => {
}
return <TipsImpl configType={configType} />;
}
// 不需要渲染任何内容
// No need to render anything
return null;
};

View File

@@ -75,7 +75,7 @@ export const ToolContainer: FC<PropsWithChildren<IProps>> = ({
const handleOnMouseEnter = (key: string) => {
const siblingClassList = document.querySelector(`.collapse-panel-${key}`)
?.previousElementSibling?.classList;
// 如果找到兄弟节点则隐藏下划线
// Hide the underscore if a sibling is found
if (siblingClassList?.contains('collapse-panel')) {
siblingClassList.add('collapse-panel-hide-underline');
}

View File

@@ -79,7 +79,7 @@ interface ToolContentBlockProps {
defaultExpand?: boolean;
onRef?: ForwardedRef<ToolContentRef>;
/**
* @deprecated tool 插件化改造后无需传入 (如果保留老式event则需要传入)
* @Deprecated tool does not need to be passed in after plugin modification (if you keep old-fashioned events, you need to pass in)
*/
blockEventName?: OpenBlockEvent;
tooltipType?: 'tooltip' | 'popOver';
@@ -112,7 +112,7 @@ export const ToolContentBlock: React.FC<
childNodeWrapClassName,
headerClassName,
}) => {
/** 后续长期使用的ToolKey */
/** ToolKey for long-term use */
const { abilityKey } = useAbilityConfig();
const { registerCollapse } = useRegisterCollapse();
@@ -138,7 +138,7 @@ export const ToolContentBlock: React.FC<
})),
);
// 容器在页面中的展示位置,不同位置样式有区别
// The placement of the container on the page is different in different position styles
const { placement } = useLayoutContext();
const [isOpen, setIsOpen] = useState(false);
const initialized = useRef<boolean>(false);
@@ -152,7 +152,7 @@ export const ToolContentBlock: React.FC<
);
const setOpen = ($isOpen: boolean) => {
setIsOpen($isOpen);
// 记录用户使用状态
// Record user usage status
if (editable && !isReadonly && (abilityKey || blockEventName)) {
if (blockEventName) {
const blockKey = openBlockEventToToolKey[blockEventName];
@@ -171,7 +171,7 @@ export const ToolContentBlock: React.FC<
});
}
}
// 尚未完成初始化时如果用户手动展开/收起,则马上完成初始化
// If the user manually expands/retracts the initialization, the initialization is completed immediately
if (!initialized.current) {
initialized.current = true;
}
@@ -217,9 +217,9 @@ export const ToolContentBlock: React.FC<
}, [onEvent]);
useEffect(() => {
// 传入默认值之后才能初始化
// Initialization can only be done after passing in the default value
if (isBoolean(defaultExpand)) {
// 初始化完成后忽略 defaultExpand 变化
// Ignore defaultExpand changes after initialization is complete
if (!initialized.current) {
setIsOpen(defaultExpand);
initialized.current = true;
@@ -231,7 +231,7 @@ export const ToolContentBlock: React.FC<
}, [defaultExpand]);
const content = useMemo(() => {
// 初始化成功之后才能开始渲染 Collapsible 组件
// Only after successful initialization can we start rendering the Collapsible component
if (!initialized.current) {
return null;
}

View File

@@ -22,7 +22,7 @@ import { ToolTooltip } from '../tool-tooltip';
import { type ToolButtonCommonProps } from '../../typings/button';
type ToolItemActionProps = ToolButtonCommonProps & {
/** 是否展示hover样式 **/
/** Whether to display hover style **/
hoverStyle?: boolean;
};

View File

@@ -31,11 +31,11 @@ import s from './index.module.less';
interface ToolItemProps {
/**
* 标题
* title
*/
title: string;
/**
* 描述
* describe
*/
description: string;
/**
@@ -47,15 +47,15 @@ interface ToolItemProps {
*/
avatar: string;
/**
* Actions区域
* Actions area
*/
actions?: ReactNode;
/**
* Icon展示区域
* Icon display area
*/
icons?: ReactNode;
/**
* 禁用状态
* disabled state
*/
disabled?: boolean;
/**
@@ -63,11 +63,11 @@ interface ToolItemProps {
*/
tooltips?: ReactNode;
/**
* 点击卡片的回调
* Click on the card's callback
*/
onClick?: () => void;
// 尺寸 - 适配 workflow-as-agent 模式下的大号卡片
// Size - Fits large cards in workflow-as-agent mode
size?: 'default' | 'large';
avatarStyle?: React.CSSProperties;

View File

@@ -60,14 +60,14 @@ export const ToolView: FC<PropsWithChildren<IProps>> = ({ children }) => {
);
}
// 遍历 GroupingContainer 的所有子元素
// Iterate through all child elements of GroupingContainer
return Children.map(allChildren, childLevel1 => {
if (Children.count(childLevel1?.props?.children)) {
return {
...childLevel1,
props: {
...childLevel1.props,
// 子元素都套一层 ToolContainer
// Child elements are covered with a layer of ToolContainer.
children: Children.map(childLevel1.props.children, childLevel2 => {
const { toolKey, title: toolTitle } = childLevel2?.props ?? {};
const { toolGroupKey, title: groupTitle } =

View File

@@ -18,7 +18,7 @@ import { SkillKeyEnum } from '@coze-agent-ide/tool-config';
import { OpenBlockEvent } from '@coze-arch/bot-utils';
type IOpenBlockEventToToolKey = Record<string, SkillKeyEnum>;
// `模块折叠 有关事件` 和 `模块主键` 之间的映射关系
// Module folding, the mapping between related events and module primary keys
export const openBlockEventToToolKey: IOpenBlockEventToToolKey = {
[OpenBlockEvent.PLUGIN_API_BLOCK_OPEN]: SkillKeyEnum.PLUGIN_API_BLOCK,
[OpenBlockEvent.WORKFLOW_BLOCK_OPEN]: SkillKeyEnum.WORKFLOW_BLOCK,

View File

@@ -75,7 +75,7 @@ export const AbilityAreaContextProvider: FC<
clearStore: clearToolAreaStore,
} = useToolAreaStore.getState();
/**
* 清除
* clear
*/
useEffect(() => {
updateIsModeSwitching(modeSwitching);

View File

@@ -25,11 +25,11 @@ import { merge } from 'lodash-es';
export interface IPreferenceContext {
/**
* 是否开启Tool隐藏模式
* Whether to enable Tool Hide Mode
*/
enableToolHiddenMode: boolean;
/**
* 是否只读状态
* Read-only status
*/
isReadonly: boolean;
}

View File

@@ -24,7 +24,7 @@ import {
} from '../../typings/event';
/**
* 内部使用的方法,不对外使用,用于抛出事件
* Methods used internally, not externally, for throwing events
*/
export const useAgentModalTriggerEvent = () => {
const { emit } = useEvent();

View File

@@ -20,7 +20,7 @@ import { type AgentSkillKey } from '@coze-agent-ide/tool-config';
import { useAbilityAreaContext } from '../../context/ability-area-context';
/**
* @deprecated 内部使用过渡期方案针对非注册组件使用外部的skill设置
* @Deprecated internal use, transition scenario, using external skill settings for non-registered components
*/
export const useHasAgentSkillWithPK = () => {
const {
@@ -35,7 +35,7 @@ export const useHasAgentSkillWithPK = () => {
);
/**
* @deprecated 内部使用,过渡期
* @deprecated internal use, transition period
*/
const setHasAgentSkill = (
agentSkillKey: AgentSkillKey,

View File

@@ -17,7 +17,7 @@
import { useAbilityConfigContext } from '../../context/ability-config-context';
/**
* 用户内部获取ToolKey使用
* Users obtain ToolKey usage internally
*/
export const useAbilityConfig = () => {
const { abilityKey, scope } = useAbilityConfigContext();

View File

@@ -19,7 +19,7 @@ import { type AgentSkillKey } from '@coze-agent-ide/tool-config';
import { useAbilityAreaContext } from '../../context/ability-area-context';
/**
* 用于内部注册AgentSkill使用
* For internal registration AgentSkill use
*/
export const useRegisterAgentSkillKey = () => {
const {

View File

@@ -20,7 +20,7 @@ import { type IRegisteredToolKeyConfig } from '../../store/tool-area';
import { useAbilityAreaContext } from '../../context/ability-area-context';
/**
* 用于内部注册Tool使用
* For Internal Registration Tool Use
*/
export const useRegisterToolKey = () => {
const {

View File

@@ -30,11 +30,11 @@ import { useAbilityConfig } from '../../builtin/use-ability-config';
import { toolKeyToApiStatusKeyTransformer } from '../../../utils/tool-content-block';
/**
* 用于校验当前模块默认展开收起状态
* Used to verify the default expanded and stowed state of the current module
*
* @param blockKey 主键 - tool 插件化改造后无需传入
* @param configured 是否有配置内容
* @param when 是否校验
* @Param blockKey primary key - no need to pass in after tool plugin transformation
* @param configured whether there is configuration content
* Check when @param
*
* @see
*/
@@ -56,18 +56,18 @@ export const useToolContentBlockDefaultExpand = (
})),
);
return useMemo(() => {
// 不做校验
// No verification
if (!$when) {
return undefined;
// 状态机未就绪
// Finite-state machine not ready
} else if (!init || size(botSkillBlockCollapsibleState) === 0) {
return undefined;
/**
* @description 仅在满足以下条件时用户行为记录才能生效
* @Description A user behavior record is only valid if the following conditions are met
*
* 1. 拥有编辑权限
* 2. 不能是历史预览环境
* 3. 必须已配置
* 1. Have editing rights
* 2. Cannot be a historical preview environment
* 3. Must be configured
*/
} else if (editable && !isReadonly && configured) {
const key = abilityKey ?? blockKey;

View File

@@ -59,8 +59,8 @@ export const useToolValidData = () => {
});
/**
* 异常场景兜底,视图和服务端数据无法匹配,需要触发更新服务端数据
* 有数据但是隐藏状态
* Abnormal scene cover, view and server level data cannot match, need to trigger update server level data
* There is data but hidden state
*/
if (toolStatus === TabStatus.Hide && hasValidData) {
setBotSkillBlockCollapsibleState(

View File

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { useEffect } from 'react';
import { useShallow } from 'zustand/react/shallow';
@@ -40,7 +40,7 @@ const KEY_MAP = {
[AbilityScope.AGENT_SKILL]: AGENT_SKILL_KEY_MAP,
};
// 访问全局状态机中的状态
// Access state in the global fine-state machine
export function useToolStore<U>(selector: (state: BotSkillStore) => U): U {
const { abilityKey } = useAbilityConfig();
@@ -51,7 +51,7 @@ export function useToolStore<U>(selector: (state: BotSkillStore) => U): U {
return useBotSkillStore(selector) as U;
}
// 访问全局状态机中的方法
// Access methods in the global fine-state machine
export function useToolStoreAction<U>(
selector: (state: BotSkillAction) => U,
): U {
@@ -64,7 +64,7 @@ export function useToolStoreAction<U>(
return useBotSkillStore(selector) as U;
}
// 提交数据
// submit data
export function useToolDispatch<T>() {
const { abilityKey, scope } = useAbilityConfig();
@@ -78,16 +78,16 @@ export function useToolDispatch<T>() {
setState({
[scope]: {
...state[scope],
// @ts-expect-error -- 以后想着解决一下这里的类型问题
// @ts-expect-error -- I want to solve the type problem here in the future
[KEY_MAP[scope][abilityKey]]: newState,
},
});
};
}
// 监听 tool 状态机数据变化,并同步到 bot detail store
// Monitor tool fine-state machine data changes and sync to bot detail store
export function useSubscribeToolStore(scope: AbilityScope, agentId?: string) {
// bot detail store 更新方法
// Bot detail store update method
const { setBotSkill } = useBotSkillStore(
useShallow(state => ({
setBotSkill: state.setBotSkill,
@@ -99,11 +99,11 @@ export function useSubscribeToolStore(scope: AbilityScope, agentId?: string) {
})),
);
// tools store 数据
// Tools store data
const { state } = useAbilityStoreContext();
const newState = state[scope];
// 同步数据
// synchronize data
useEffect(() => {
if (size(newState)) {
if (!newState) {

View File

@@ -21,7 +21,7 @@ import { EventCenterEventName } from '../../typings/scoped-events';
import { type IToggleContentBlockEventParams } from '../../typings/event';
/**
* 私有的hooks不对外暴露使用
* Private hooks, not exposed to the outside world
* @returns
*/

View File

@@ -15,7 +15,7 @@
*/
/**
* START 对外长期暴露的类型、常量、函数、Hooks、组件等
* Types, constants, functions, hooks, components, etc. exposed by START for a long time
*/
export {
AbilityScope,
@@ -72,16 +72,16 @@ export { TipsDisplay as ModelCapabilityTipsDisplay } from './components/model-ca
export { abilityKey2ModelFunctionConfigType } from './utils/model-function-config-type-mapping';
/**
* END 对外长期暴露的类型、常量、函数、Hooks、组件等
* END exposes types, constants, functions, hooks, components, etc. for a long time
*/
/**
* START 过渡期对外暴露的类型、常量、函数、Hooks、组件等
* Types, constants, functions, hooks, components, etc. exposed during the START transition period
*/
export {
/**
* 模块主键
* @deprecated 该使用方式已废弃, 请使用: `import { ToolKey } from '@coze-agent-ide/tool-config'`;
* module primary key
* @Deprecated This usage is deprecated, please use: 'import {ToolKey} from' @code-agent-ide/tool-config ';
*/
SkillKeyEnum,
} from '@coze-agent-ide/tool-config';
@@ -93,5 +93,5 @@ export { useEvent } from './hooks/event/use-event';
export { EventCenterEventName } from './typings/scoped-events';
export { IToggleContentBlockEventParams } from './typings/event';
/**
* END 过渡期对外暴露的类型、常量、函数、Hooks、组件等
* Types, constants, functions, hooks, components, etc. exposed during the END transition period
*/

View File

@@ -21,7 +21,7 @@ import { type AgentSkillKey } from '@coze-agent-ide/tool-config';
export interface IAgentAreaState {
/**
* @deprecated 过渡期使用,用户手动搞的key list
* @deprecated transition period use, user manually engaged key list
*/
manualAgentSkillKeyList: AgentSkillKey[];
hasAgentSkillKeyList: AgentSkillKey[];
@@ -31,7 +31,7 @@ export interface IAgentAreaState {
export interface IAgentAreaAction {
/**
* @deprecated 过渡期使用,后续删除
* @deprecated transitional use, subsequent deletion
*/
appendManualAgentSkillKeyList: (skillKey: AgentSkillKey) => void;
setHasAgentSkillKey: (skillKey: AgentSkillKey, hasSkill: boolean) => void;

View File

@@ -17,23 +17,23 @@
export type IEventCenterEventName = EventCenterEventName | string;
/**
* 事件中心内置的事件
* Event Center built-in events
*/
export const enum EventCenterEventName {
/**
* 插件初始化后的事件名
* The event name after the plugin is initialized
*/
AbilityInitialed = 'abilityInitialed',
/**
* 折叠展开ContentBlock的事件
* Collapse events that expand ContentBlock
*/
ToggleContentBlock = 'toggleContentBlock',
/**
* Agent Modal中tab切换的事件
* Events of tab switching in Agent Modal
*/
AgentModalTabChange = 'agentModalTabChange',
/**
* Agent Modal中显隐发生变化
* Stealth Changes in Agent Modal
*/
AgentModalVisibleChange = 'agentModalVisibleChange',
}

View File

@@ -17,9 +17,9 @@
import { type AbilityKey } from '@coze-agent-ide/tool-config';
import { ModelFuncConfigType } from '@coze-arch/bot-api/developer_api';
// AbilityKey ModelFuncConfigType 的映射
// Mapping of AbilityKey to ModelFuncConfigType
const abilityKeyFuncConfigTypeMap: {
// 确保每个 key 这里都有配置
// Make sure each key is configured here
[key in AbilityKey]: ModelFuncConfigType | null;
} = {
plugin: ModelFuncConfigType.Plugin,

View File

@@ -22,8 +22,8 @@ import {
} from '@coze-agent-ide/tool-config';
/**
* `能力模块主键` 转 `接口定义的属性名` 函数
* ⚠️ 命名需参看 @/services/auto-generate/developer_api/namespaces/developer_api > TabDisplayItems
* 'Capability module primary key 'to'interface-defined attribute name' function
* ⚠️ For naming, see @/services/auto-generate/developer_api/namespaces/developer_api > TabDisplayItems
*/
export const toolKeyToApiStatusKeyTransformer = (
$key: AbilityKey | SkillKeyEnum,