chore: replace all cn comments of fe to en version by volc api (#320)
This commit is contained in:
@@ -22,24 +22,24 @@ import { chatBackgroundConfig } from '../../../../../src/save-manager/auto-save/
|
||||
|
||||
describe('chatBackgroundConfig', () => {
|
||||
it('应该具有正确的配置属性', () => {
|
||||
// 验证配置的基本属性
|
||||
// Verify the basic properties of the configuration
|
||||
expect(chatBackgroundConfig).toHaveProperty('key');
|
||||
expect(chatBackgroundConfig).toHaveProperty('selector');
|
||||
expect(chatBackgroundConfig).toHaveProperty('debounce');
|
||||
expect(chatBackgroundConfig).toHaveProperty('middleware');
|
||||
|
||||
// 验证 middleware 存在且有 onBeforeSave 属性
|
||||
// Verify that middleware exists and has an onBeforeSave attribute
|
||||
expect(chatBackgroundConfig.middleware).toBeDefined();
|
||||
if (chatBackgroundConfig.middleware) {
|
||||
expect(chatBackgroundConfig.middleware).toHaveProperty('onBeforeSave');
|
||||
}
|
||||
|
||||
// 验证属性值
|
||||
// Validate attribute value
|
||||
expect(chatBackgroundConfig.key).toBe(ItemTypeExtra.ChatBackGround);
|
||||
expect(chatBackgroundConfig.debounce).toBe(DebounceTime.Immediate);
|
||||
expect(typeof chatBackgroundConfig.selector).toBe('function');
|
||||
|
||||
// 验证 onBeforeSave 是函数
|
||||
// Verify that onBeforeSave is a function
|
||||
if (
|
||||
chatBackgroundConfig.middleware &&
|
||||
chatBackgroundConfig.middleware.onBeforeSave
|
||||
@@ -51,49 +51,49 @@ describe('chatBackgroundConfig', () => {
|
||||
});
|
||||
|
||||
it('selector 应该返回 store 的 backgroundImageInfoList 属性', () => {
|
||||
// 创建模拟 store
|
||||
// Create mock store
|
||||
const mockStore = {
|
||||
backgroundImageInfoList: [
|
||||
{ id: 'bg1', url: 'http://example.com/bg1.jpg' },
|
||||
],
|
||||
};
|
||||
|
||||
// 调用 selector 函数
|
||||
// 注意:这里我们假设 selector 是一个函数,如果它是一个复杂对象,可能需要调整测试
|
||||
// Call the selector function
|
||||
// Note: Here we assume that the selector is a function, and if it is a complex object, the test may need to be adjusted
|
||||
const { selector } = chatBackgroundConfig;
|
||||
let result;
|
||||
|
||||
if (typeof selector === 'function') {
|
||||
result = selector(mockStore as any);
|
||||
// 验证结果
|
||||
// validation result
|
||||
expect(result).toBe(mockStore.backgroundImageInfoList);
|
||||
} else {
|
||||
// 如果 selector 不是函数,跳过这个测试
|
||||
// If the selector is not a function, skip this test
|
||||
expect(true).toBe(true);
|
||||
}
|
||||
});
|
||||
|
||||
it('middleware.onBeforeSave 应该正确转换数据', () => {
|
||||
// 创建模拟数据
|
||||
// Create simulated data
|
||||
const mockData = [
|
||||
{ id: 'bg1', url: 'http://example.com/bg1.jpg' },
|
||||
{ id: 'bg2', url: 'http://example.com/bg2.jpg' },
|
||||
];
|
||||
|
||||
// 确保 middleware 和 onBeforeSave 存在
|
||||
// Make sure middleware and onBeforeSave exist
|
||||
if (
|
||||
chatBackgroundConfig.middleware &&
|
||||
chatBackgroundConfig.middleware.onBeforeSave
|
||||
) {
|
||||
// 调用 onBeforeSave 函数
|
||||
// Call the onBeforeSave function
|
||||
const result = chatBackgroundConfig.middleware.onBeforeSave(mockData);
|
||||
|
||||
// 验证结果
|
||||
// validation result
|
||||
expect(result).toEqual({
|
||||
background_image_info_list: mockData,
|
||||
});
|
||||
} else {
|
||||
// 如果 middleware 或 onBeforeSave 不存在,跳过这个测试
|
||||
// If middleware or onBeforeSave does not exist, skip this test
|
||||
expect(true).toBe(true);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -28,7 +28,7 @@ import { knowledgeConfig } from '../../../../../src/save-manager/auto-save/bot-s
|
||||
import { chatBackgroundConfig } from '../../../../../src/save-manager/auto-save/bot-skill/configs/chat-background';
|
||||
import { registers } from '../../../../../src/save-manager/auto-save/bot-skill/configs';
|
||||
|
||||
// 模拟依赖
|
||||
// simulated dependency
|
||||
vi.mock(
|
||||
'../../../../../src/save-manager/auto-save/bot-skill/configs/workflows',
|
||||
() => ({
|
||||
@@ -101,7 +101,7 @@ vi.mock(
|
||||
|
||||
describe('bot-skill configs', () => {
|
||||
it('应该正确注册所有配置', () => {
|
||||
// 验证 registers 数组包含所有配置
|
||||
// Verify that the registers array contains all configurations
|
||||
expect(registers).toContain(pluginConfig);
|
||||
expect(registers).toContain(chatBackgroundConfig);
|
||||
expect(registers).toContain(onboardingConfig);
|
||||
@@ -113,7 +113,7 @@ describe('bot-skill configs', () => {
|
||||
expect(registers).toContain(workflowsConfig);
|
||||
expect(registers).toContain(voicesInfoConfig);
|
||||
|
||||
// 验证 registers 数组长度
|
||||
// Verify the length of the registers array
|
||||
expect(registers.length).toBe(10);
|
||||
});
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ describe('knowledgeConfig', () => {
|
||||
expect(knowledgeConfig).toHaveProperty('debounce');
|
||||
expect(knowledgeConfig).toHaveProperty('middleware');
|
||||
expect(knowledgeConfig.key).toBe(ItemType.DataSet);
|
||||
// 验证 debounce 配置
|
||||
// Verify debounce configuration
|
||||
if (typeof knowledgeConfig.debounce === 'object') {
|
||||
expect(knowledgeConfig.debounce).toHaveProperty('default');
|
||||
expect(knowledgeConfig.debounce).toHaveProperty('dataSetInfo.min_score');
|
||||
|
||||
@@ -26,7 +26,7 @@ describe('onboardingConfig', () => {
|
||||
expect(onboardingConfig).toHaveProperty('debounce');
|
||||
expect(onboardingConfig).toHaveProperty('middleware');
|
||||
expect(onboardingConfig.key).toBe(ItemType.ONBOARDING);
|
||||
// 验证 debounce 配置
|
||||
// Verify debounce configuration
|
||||
if (typeof onboardingConfig.debounce === 'object') {
|
||||
expect(onboardingConfig.debounce).toHaveProperty('default');
|
||||
expect(onboardingConfig.debounce).toHaveProperty('prologue');
|
||||
|
||||
@@ -18,7 +18,7 @@ import { describe, it, expect, vi, beforeEach } from 'vitest';
|
||||
|
||||
import { botSkillSaveManager } from '../../../../src/save-manager/auto-save/bot-skill';
|
||||
|
||||
// 模拟依赖
|
||||
// simulated dependency
|
||||
vi.mock('@coze-studio/autosave', () => {
|
||||
const mockStartFn = vi.fn();
|
||||
const mockCloseFn = vi.fn();
|
||||
@@ -52,16 +52,16 @@ describe('botSkillSaveManager', () => {
|
||||
});
|
||||
|
||||
it('应该是 AutosaveManager 的实例', () => {
|
||||
// 验证 botSkillSaveManager 是 AutosaveManager 的实例
|
||||
// Verify that botSkillSaveManager is an instance of AutosaveManager
|
||||
expect(botSkillSaveManager).toBeDefined();
|
||||
// 由于我们模拟了 AutosaveManager,我们不能直接检查实例类型
|
||||
// 但可以检查它是否具有 AutosaveManager 实例应有的属性和方法
|
||||
// Since we simulate AutosaveManager, we cannot directly check the instance type
|
||||
// But you can check if it has the properties and methods that an AutosaveManager instance should have
|
||||
expect(botSkillSaveManager).toHaveProperty('start');
|
||||
expect(botSkillSaveManager).toHaveProperty('close');
|
||||
});
|
||||
|
||||
it('应该具有 start 和 close 方法', () => {
|
||||
// 验证 botSkillSaveManager 具有 start 和 close 方法
|
||||
// Verify botSkillSaveManager has a start and close method
|
||||
expect(botSkillSaveManager.start).toBeDefined();
|
||||
expect(botSkillSaveManager.close).toBeDefined();
|
||||
expect(typeof botSkillSaveManager.start).toBe('function');
|
||||
@@ -69,16 +69,16 @@ describe('botSkillSaveManager', () => {
|
||||
});
|
||||
|
||||
it('调用 start 方法应该正常工作', () => {
|
||||
// 调用 start 方法
|
||||
// Call the start method
|
||||
botSkillSaveManager.start();
|
||||
// 由于我们已经模拟了 start 方法,这里只需验证它可以被调用而不会抛出错误
|
||||
// Since we have already simulated the start method, we just need to verify that it can be called without throwing an error
|
||||
expect(true).toBe(true);
|
||||
});
|
||||
|
||||
it('调用 close 方法应该正常工作', () => {
|
||||
// 调用 close 方法
|
||||
// Call the close method
|
||||
botSkillSaveManager.close();
|
||||
// 由于我们已经模拟了 close 方法,这里只需验证它可以被调用而不会抛出错误
|
||||
// Since we have simulated the close method, we just need to verify that it can be called without throwing an error
|
||||
expect(true).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -21,7 +21,7 @@ import { modelSaveManager } from '../../../src/save-manager/auto-save/model';
|
||||
import { autosaveManager } from '../../../src/save-manager/auto-save/index';
|
||||
import { botSkillSaveManager } from '../../../src/save-manager/auto-save/bot-skill';
|
||||
|
||||
// 模拟依赖
|
||||
// simulated dependency
|
||||
vi.mock('../../../src/save-manager/auto-save/persona', () => ({
|
||||
personaSaveManager: {
|
||||
start: vi.fn(),
|
||||
@@ -46,24 +46,24 @@ vi.mock('../../../src/save-manager/auto-save/bot-skill', () => ({
|
||||
describe('autosave manager', () => {
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
// 正确模拟 console.log
|
||||
// Correctly emulate console.log
|
||||
vi.spyOn(console, 'log').mockImplementation(() => {
|
||||
// 什么都不做
|
||||
// Do nothing.
|
||||
});
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
// 恢复原始的 console.log
|
||||
// Restore the original console.log
|
||||
vi.restoreAllMocks();
|
||||
});
|
||||
|
||||
it('应该在启动时调用所有管理器的 start 方法', () => {
|
||||
autosaveManager.start();
|
||||
|
||||
// 验证 console.log 被调用
|
||||
// Verify that console.log is called
|
||||
expect(console.log).toHaveBeenCalledWith('start:>>');
|
||||
|
||||
// 验证所有管理器的 start 方法被调用
|
||||
// Verify that the start method of all managers is called
|
||||
expect(personaSaveManager.start).toHaveBeenCalledTimes(1);
|
||||
expect(botSkillSaveManager.start).toHaveBeenCalledTimes(1);
|
||||
expect(modelSaveManager.start).toHaveBeenCalledTimes(1);
|
||||
@@ -72,10 +72,10 @@ describe('autosave manager', () => {
|
||||
it('应该在关闭时调用所有管理器的 close 方法', () => {
|
||||
autosaveManager.close();
|
||||
|
||||
// 验证 console.log 被调用
|
||||
// Verify that console.log is called
|
||||
expect(console.log).toHaveBeenCalledWith('close:>>');
|
||||
|
||||
// 验证所有管理器的 close 方法被调用
|
||||
// Verify that all managers' close methods are called
|
||||
expect(personaSaveManager.close).toHaveBeenCalledTimes(1);
|
||||
expect(botSkillSaveManager.close).toHaveBeenCalledTimes(1);
|
||||
expect(modelSaveManager.close).toHaveBeenCalledTimes(1);
|
||||
|
||||
@@ -22,7 +22,7 @@ import { useBotInfoStore } from '../../../src/store/bot-info';
|
||||
import { saveFetcher } from '../../../src/save-manager/utils/save-fetcher';
|
||||
import { saveRequest } from '../../../src/save-manager/auto-save/request';
|
||||
|
||||
// 模拟依赖
|
||||
// simulated dependency
|
||||
vi.mock('@coze-arch/bot-api', () => ({
|
||||
PlaygroundApi: {
|
||||
UpdateDraftBotInfoAgw: vi.fn(),
|
||||
@@ -53,7 +53,7 @@ describe('auto-save request', () => {
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
|
||||
// 设置默认状态
|
||||
// Set default state
|
||||
(useBotInfoStore.getState as any).mockReturnValue({
|
||||
botId: mockBotId,
|
||||
});
|
||||
@@ -71,19 +71,19 @@ describe('auto-save request', () => {
|
||||
it('应该使用正确的参数调用 saveFetcher', async () => {
|
||||
await saveRequest(mockPayload, mockItemType);
|
||||
|
||||
// 验证 saveFetcher 被调用
|
||||
// Verify that saveFetcher is called
|
||||
expect(saveFetcher).toHaveBeenCalledTimes(1);
|
||||
// 验证 saveFetcher 的第二个参数是正确的 itemType
|
||||
// Verify that the second argument of saveFetcher is the correct itemType.
|
||||
expect(saveFetcher).toHaveBeenCalledWith(
|
||||
expect.any(Function),
|
||||
mockItemType,
|
||||
);
|
||||
|
||||
// 获取并执行 saveFetcher 的第一个参数(函数)
|
||||
// Get and execute the first argument (function) of saveFetcher.
|
||||
const saveRequestFn = (saveFetcher as any).mock.calls[0][0];
|
||||
await saveRequestFn();
|
||||
|
||||
// 验证 UpdateDraftBotInfoAgw 被调用,并且参数正确
|
||||
// Verify that UpdateDraftBotInfoAgw is called and the parameters are correct
|
||||
expect(PlaygroundApi.UpdateDraftBotInfoAgw).toHaveBeenCalledWith({
|
||||
bot_info: {
|
||||
bot_id: mockBotId,
|
||||
|
||||
@@ -25,7 +25,7 @@ import {
|
||||
} from '../../../src/save-manager/utils/save-fetcher';
|
||||
import { saveDevHooksConfig } from '../../../src/save-manager/manual-save/dev-hooks';
|
||||
|
||||
// 模拟依赖
|
||||
// simulated dependency
|
||||
vi.mock('../../../src/store/bot-skill', () => ({
|
||||
useBotSkillStore: {
|
||||
getState: vi.fn(),
|
||||
@@ -45,7 +45,7 @@ describe('dev-hooks save manager', () => {
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
|
||||
// 设置默认状态
|
||||
// Set default state
|
||||
(useBotSkillStore.getState as any).mockReturnValue({
|
||||
devHooks: mockDevHooks,
|
||||
});
|
||||
@@ -66,12 +66,12 @@ describe('dev-hooks save manager', () => {
|
||||
} as any as HookInfo;
|
||||
await saveDevHooksConfig(newConfig);
|
||||
|
||||
// 验证 updateBotRequest 被调用,并且参数正确
|
||||
// Verify that updateBotRequest was called and the parameters are correct
|
||||
expect(updateBotRequest).toHaveBeenCalledWith({
|
||||
hook_info: newConfig,
|
||||
});
|
||||
|
||||
// 验证 saveFetcher 被调用,并且参数正确
|
||||
// Verify that saveFetcher is called and the parameters are correct
|
||||
expect(saveFetcher).toHaveBeenCalledWith(
|
||||
expect.any(Function),
|
||||
ItemType.HOOKINFO,
|
||||
|
||||
@@ -24,7 +24,7 @@ import {
|
||||
} from '../../../src/save-manager/utils/save-fetcher';
|
||||
import { saveTableMemory } from '../../../src/save-manager/manual-save/memory-table';
|
||||
|
||||
// 模拟依赖
|
||||
// simulated dependency
|
||||
vi.mock('../../../src/store/bot-skill', () => ({
|
||||
useBotSkillStore: {
|
||||
getState: vi.fn(),
|
||||
@@ -49,7 +49,7 @@ describe('memory-table save manager', () => {
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
|
||||
// 设置默认状态
|
||||
// Set default state
|
||||
(useBotSkillStore.getState as any).mockReturnValue({
|
||||
databaseList: mockDatabaseList,
|
||||
transformVo2Dto: mockTransformVo2Dto,
|
||||
@@ -68,17 +68,17 @@ describe('memory-table save manager', () => {
|
||||
it('应该正确保存内存表变量', async () => {
|
||||
await saveTableMemory();
|
||||
|
||||
// 验证 transformVo2Dto.databaseList 被调用
|
||||
// Verify that transformVo2Dto.DatabaseList is called
|
||||
expect(mockTransformVo2Dto.databaseList).toHaveBeenCalledWith(
|
||||
mockDatabaseList,
|
||||
);
|
||||
|
||||
// 验证 updateBotRequest 被调用,并且参数正确
|
||||
// Verify that updateBotRequest was called and the parameters are correct
|
||||
expect(updateBotRequest).toHaveBeenCalledWith({
|
||||
database_list: { transformed: mockDatabaseList },
|
||||
});
|
||||
|
||||
// 验证 saveFetcher 被调用,并且参数正确
|
||||
// Verify that saveFetcher is called and the parameters are correct
|
||||
expect(saveFetcher).toHaveBeenCalledWith(
|
||||
expect.any(Function),
|
||||
ItemType.TABLE,
|
||||
|
||||
@@ -29,7 +29,7 @@ import {
|
||||
saveConnectorType,
|
||||
} from '../../../src/save-manager/manual-save/multi-agent';
|
||||
|
||||
// 模拟依赖
|
||||
// simulated dependency
|
||||
vi.mock('@coze-arch/bot-api', () => ({
|
||||
PlaygroundApi: {
|
||||
UpdateAgentV2: vi.fn(),
|
||||
@@ -68,7 +68,7 @@ vi.mock('../../../src/save-manager/utils/save-fetcher', () => ({
|
||||
describe('multi-agent save manager', () => {
|
||||
const mockBotId = 'mock-bot-id';
|
||||
const mockSpaceId = 'mock-space-id';
|
||||
// 创建一个符合 Agent 类型的模拟对象
|
||||
// Create a mock object that conforms to the Agent type
|
||||
const mockAgent = {
|
||||
id: 'agent-1',
|
||||
name: 'Agent 1',
|
||||
@@ -99,7 +99,7 @@ describe('multi-agent save manager', () => {
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
|
||||
// 设置默认状态
|
||||
// Set default state
|
||||
(useBotInfoStore.getState as any).mockReturnValue({
|
||||
botId: mockBotId,
|
||||
});
|
||||
@@ -133,22 +133,22 @@ describe('multi-agent save manager', () => {
|
||||
it('应该正确更新代理', async () => {
|
||||
await saveUpdateAgents(mockAgent as any);
|
||||
|
||||
// 验证 transformVo2Dto.agent 被调用
|
||||
// Verify that transformVo2Dato.agent is called
|
||||
expect(
|
||||
useMultiAgentStore.getState().transformVo2Dto.agent,
|
||||
).toHaveBeenCalledWith(mockAgent);
|
||||
|
||||
// 验证 saveFetcher 被调用,并且参数正确
|
||||
// Verify that saveFetcher is called and the parameters are correct
|
||||
expect(saveFetcher).toHaveBeenCalledWith(
|
||||
expect.any(Function),
|
||||
ItemTypeExtra.MultiAgent,
|
||||
);
|
||||
|
||||
// 获取并执行 saveFetcher 的第一个参数(函数)
|
||||
// Get and execute the first argument (function) of saveFetcher.
|
||||
const saveRequestFn = (saveFetcher as any).mock.calls[0][0];
|
||||
await saveRequestFn();
|
||||
|
||||
// 验证 UpdateAgentV2 被调用,并且参数正确
|
||||
// Verify that UpdateAgentV2 is called and the parameters are correct
|
||||
expect(PlaygroundApi.UpdateAgentV2).toHaveBeenCalledWith({
|
||||
...mockAgentDto,
|
||||
bot_id: mockBotId,
|
||||
@@ -163,17 +163,17 @@ describe('multi-agent save manager', () => {
|
||||
const agentId = 'agent-to-delete';
|
||||
await saveDeleteAgents(agentId);
|
||||
|
||||
// 验证 saveFetcher 被调用,并且参数正确
|
||||
// Verify that saveFetcher is called and the parameters are correct
|
||||
expect(saveFetcher).toHaveBeenCalledWith(
|
||||
expect.any(Function),
|
||||
ItemTypeExtra.MultiAgent,
|
||||
);
|
||||
|
||||
// 获取并执行 saveFetcher 的第一个参数(函数)
|
||||
// Get and execute the first argument (function) of saveFetcher.
|
||||
const saveRequestFn = (saveFetcher as any).mock.calls[0][0];
|
||||
await saveRequestFn();
|
||||
|
||||
// 验证 UpdateAgentV2 被调用,并且参数正确
|
||||
// Verify that UpdateAgentV2 is called and the parameters are correct
|
||||
expect(PlaygroundApi.UpdateAgentV2).toHaveBeenCalledWith({
|
||||
bot_id: mockBotId,
|
||||
space_id: mockSpaceId,
|
||||
@@ -188,17 +188,17 @@ describe('multi-agent save manager', () => {
|
||||
it('应该正确保存多代理数据', async () => {
|
||||
await saveMultiAgentData();
|
||||
|
||||
// 验证 saveFetcher 被调用,并且参数正确
|
||||
// Verify that saveFetcher is called and the parameters are correct
|
||||
expect(saveFetcher).toHaveBeenCalledWith(
|
||||
expect.any(Function),
|
||||
ItemTypeExtra.MultiAgent,
|
||||
);
|
||||
|
||||
// 获取并执行 saveFetcher 的第一个参数(函数)
|
||||
// Get and execute the first argument (function) of saveFetcher.
|
||||
const saveRequestFn = (saveFetcher as any).mock.calls[0][0];
|
||||
await saveRequestFn();
|
||||
|
||||
// 验证 UpdateMultiAgent 被调用,并且参数正确
|
||||
// Verify that UpdateMultiAgent is invoked and the parameters are correct
|
||||
expect(PlaygroundApi.UpdateMultiAgent).toHaveBeenCalledWith({
|
||||
space_id: mockSpaceId,
|
||||
bot_id: mockBotId,
|
||||
@@ -210,21 +210,21 @@ describe('multi-agent save manager', () => {
|
||||
|
||||
describe('saveConnectorType', () => {
|
||||
it('应该正确保存连接器类型', async () => {
|
||||
// 使用数字代替枚举值
|
||||
const connectorType = 0; // 假设 0 代表 Straight
|
||||
// Using numbers instead of enumerated values
|
||||
const connectorType = 0; // Assume 0 is Straight
|
||||
await saveConnectorType(connectorType as any);
|
||||
|
||||
// 验证 saveFetcher 被调用,并且参数正确
|
||||
// Verify that saveFetcher is called and the parameters are correct
|
||||
expect(saveFetcher).toHaveBeenCalledWith(
|
||||
expect.any(Function),
|
||||
ItemTypeExtra.ConnectorType,
|
||||
);
|
||||
|
||||
// 获取并执行 saveFetcher 的第一个参数(函数)
|
||||
// Get and execute the first argument (function) of saveFetcher.
|
||||
const saveRequestFn = (saveFetcher as any).mock.calls[0][0];
|
||||
await saveRequestFn();
|
||||
|
||||
// 验证 UpdateMultiAgent 被调用,并且参数正确
|
||||
// Verify that UpdateMultiAgent is invoked and the parameters are correct
|
||||
expect(PlaygroundApi.UpdateMultiAgent).toHaveBeenCalledWith({
|
||||
space_id: mockSpaceId,
|
||||
bot_id: mockBotId,
|
||||
|
||||
@@ -25,7 +25,7 @@ import {
|
||||
import { ItemTypeExtra } from '../../../src/save-manager/types';
|
||||
import { updateQueryCollect } from '../../../src/save-manager/manual-save/query-collect';
|
||||
|
||||
// 模拟依赖
|
||||
// simulated dependency
|
||||
vi.mock('../../../src/store/query-collect', () => ({
|
||||
useQueryCollectStore: {
|
||||
getState: vi.fn(),
|
||||
@@ -46,7 +46,7 @@ describe('query-collect save manager', () => {
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
|
||||
// 设置默认状态
|
||||
// Set default state
|
||||
(useQueryCollectStore.getState as any).mockReturnValue({
|
||||
...mockQueryCollect,
|
||||
});
|
||||
@@ -62,18 +62,18 @@ describe('query-collect save manager', () => {
|
||||
});
|
||||
|
||||
it('应该正确保存 query collect 配置', async () => {
|
||||
// 创建一个符合 UserQueryCollectConf 类型的对象作为参数
|
||||
// Create an object of UserQueryCollectConf type as a parameter
|
||||
const queryCollectConf =
|
||||
mockQueryCollect as unknown as UserQueryCollectConf;
|
||||
|
||||
await updateQueryCollect(queryCollectConf);
|
||||
|
||||
// 验证 updateBotRequest 被调用,并且参数正确
|
||||
// Verify that updateBotRequest was called and the parameters are correct
|
||||
expect(updateBotRequest).toHaveBeenCalledWith({
|
||||
user_query_collect_conf: queryCollectConf,
|
||||
});
|
||||
|
||||
// 验证 saveFetcher 被调用,并且参数正确
|
||||
// Verify that saveFetcher is called and the parameters are correct
|
||||
expect(saveFetcher).toHaveBeenCalledWith(
|
||||
expect.any(Function),
|
||||
ItemTypeExtra.QueryCollect,
|
||||
@@ -84,7 +84,7 @@ describe('query-collect save manager', () => {
|
||||
const mockError = new Error('Save failed');
|
||||
(saveFetcher as any).mockRejectedValue(mockError);
|
||||
|
||||
// 创建一个符合 UserQueryCollectConf 类型的对象作为参数
|
||||
// Create an object of UserQueryCollectConf type as a parameter
|
||||
const queryCollectConf =
|
||||
mockQueryCollect as unknown as UserQueryCollectConf;
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ import {
|
||||
import { ItemTypeExtra } from '../../../src/save-manager/types';
|
||||
import { updateShortcutSort } from '../../../src/save-manager/manual-save/shortcuts';
|
||||
|
||||
// 模拟依赖
|
||||
// simulated dependency
|
||||
vi.mock('../../../src/store/bot-skill', () => ({
|
||||
useBotSkillStore: {
|
||||
getState: vi.fn(),
|
||||
@@ -46,7 +46,7 @@ describe('shortcuts save manager', () => {
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
|
||||
// 设置默认状态
|
||||
// Set default state
|
||||
(useBotSkillStore.getState as any).mockReturnValue({
|
||||
shortcut: mockShortcut,
|
||||
transformVo2Dto: mockTransformVo2Dto,
|
||||
@@ -66,12 +66,12 @@ describe('shortcuts save manager', () => {
|
||||
const newSort = ['shortcut-2', 'shortcut-1'];
|
||||
await updateShortcutSort(newSort);
|
||||
|
||||
// 验证 updateBotRequest 被调用,并且参数正确
|
||||
// Verify that updateBotRequest was called and the parameters are correct
|
||||
expect(updateBotRequest).toHaveBeenCalledWith({
|
||||
shortcut_sort: newSort,
|
||||
});
|
||||
|
||||
// 验证 saveFetcher 被调用,并且参数正确
|
||||
// Verify that saveFetcher is called and the parameters are correct
|
||||
expect(saveFetcher).toHaveBeenCalledWith(
|
||||
expect.any(Function),
|
||||
ItemTypeExtra.Shortcut,
|
||||
|
||||
@@ -24,7 +24,7 @@ import {
|
||||
import { ItemTypeExtra } from '../../../src/save-manager/types';
|
||||
import { saveTimeCapsule } from '../../../src/save-manager/manual-save/time-capsule';
|
||||
|
||||
// 模拟依赖
|
||||
// simulated dependency
|
||||
vi.mock('../../../src/store/bot-skill', () => ({
|
||||
useBotSkillStore: {
|
||||
getState: vi.fn(),
|
||||
@@ -54,7 +54,7 @@ describe('time-capsule save manager', () => {
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
|
||||
// 设置默认状态
|
||||
// Set default state
|
||||
(useBotSkillStore.getState as any).mockReturnValue({
|
||||
timeCapsule: mockTimeCapsule,
|
||||
transformVo2Dto: mockTransformVo2Dto,
|
||||
@@ -73,17 +73,17 @@ describe('time-capsule save manager', () => {
|
||||
it('应该正确保存 time capsule 配置', async () => {
|
||||
await saveTimeCapsule();
|
||||
|
||||
// 验证 transformVo2Dto.timeCapsule 被调用,参数应该是包含 time_capsule_mode 和 disable_prompt_calling 的对象
|
||||
// Verify that transformVo2To.timeCapsule is called, the argument should be an object containing time_capsule_mode and disable_prompt_calling
|
||||
expect(mockTransformVo2Dto.timeCapsule).toHaveBeenCalledWith({
|
||||
time_capsule_mode: mockTimeCapsule.time_capsule_mode,
|
||||
disable_prompt_calling: mockTimeCapsule.disable_prompt_calling,
|
||||
});
|
||||
// 验证 updateBotRequest 被调用,并且参数正确
|
||||
// Verify that updateBotRequest was called and the parameters are correct
|
||||
expect(updateBotRequest).toHaveBeenCalledWith({
|
||||
bot_tag_info: mockTransformedTimeCapsule,
|
||||
});
|
||||
|
||||
// 验证 saveFetcher 被调用,并且参数正确
|
||||
// Verify that saveFetcher is called and the parameters are correct
|
||||
expect(saveFetcher).toHaveBeenCalledWith(
|
||||
expect.any(Function),
|
||||
ItemTypeExtra.TimeCapsule,
|
||||
|
||||
@@ -25,7 +25,7 @@ import {
|
||||
import { ItemTypeExtra } from '../../../src/save-manager/types';
|
||||
import { saveTTSConfig } from '../../../src/save-manager/manual-save/tts';
|
||||
|
||||
// 模拟依赖
|
||||
// simulated dependency
|
||||
vi.mock('lodash-es', () => ({
|
||||
cloneDeep: vi.fn(obj => JSON.parse(JSON.stringify(obj))),
|
||||
merge: vi.fn((target, ...sources) => Object.assign({}, target, ...sources)),
|
||||
@@ -73,7 +73,7 @@ describe('tts save manager', () => {
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
|
||||
// 设置默认状态
|
||||
// Set default state
|
||||
(useBotSkillStore.getState as any).mockReturnValue({
|
||||
tts: mockTTS,
|
||||
voicesInfo: mockVoicesInfo,
|
||||
@@ -93,21 +93,21 @@ describe('tts save manager', () => {
|
||||
it('应该正确保存 TTS 配置', async () => {
|
||||
await saveTTSConfig();
|
||||
|
||||
// 验证 transformVo2Dto.tts 被调用
|
||||
// Verify that transformVo2To.tts is called
|
||||
expect(mockTransformVo2Dto.tts).toHaveBeenCalledTimes(1);
|
||||
|
||||
// 验证传递给 transformVo2Dto.tts 的参数是 tts 的克隆
|
||||
// Verify that the parameter passed to transformVo2To.tts is a clone of tts
|
||||
const ttsArg = mockTransformVo2Dto.tts.mock.calls[0][0];
|
||||
expect(ttsArg).toEqual(mockTTS);
|
||||
expect(ttsArg).not.toBe(mockTTS); // 确保是克隆而不是原始对象
|
||||
expect(ttsArg).not.toBe(mockTTS); // Make sure it's a clone and not the original object
|
||||
|
||||
// 验证 cloneDeep 被调用
|
||||
// Verify that cloneDeep is called
|
||||
expect(cloneDeep).toHaveBeenCalledTimes(3);
|
||||
|
||||
// 验证 transformVo2Dto.voicesInfo 被调用
|
||||
// Verify that transformVo2To.voicesInfo is called
|
||||
expect(mockTransformVo2Dto.voicesInfo).toHaveBeenCalledWith(mockVoicesInfo);
|
||||
|
||||
// 验证 updateBotRequest 被调用,并且参数正确
|
||||
// Verify that updateBotRequest was called and the parameters are correct
|
||||
expect(updateBotRequest).toHaveBeenCalledWith({
|
||||
voices_info: {
|
||||
muted: mockTTS.muted,
|
||||
@@ -120,7 +120,7 @@ describe('tts save manager', () => {
|
||||
},
|
||||
});
|
||||
|
||||
// 验证 saveFetcher 被调用,并且参数正确
|
||||
// Verify that saveFetcher is called and the parameters are correct
|
||||
expect(saveFetcher).toHaveBeenCalledWith(
|
||||
expect.any(Function),
|
||||
ItemTypeExtra.TTS,
|
||||
|
||||
@@ -25,7 +25,7 @@ import { useBotSkillStore } from '../../../src/store/bot-skill';
|
||||
import { useBotInfoStore } from '../../../src/store/bot-info';
|
||||
import { getBotDetailDtoInfo } from '../../../src/save-manager/utils/bot-dto-info';
|
||||
|
||||
// 模拟依赖
|
||||
// simulated dependency
|
||||
vi.mock('@coze-arch/report-events', () => ({
|
||||
REPORT_EVENTS: {
|
||||
botDebugSaveAll: 'botDebugSaveAll',
|
||||
@@ -130,7 +130,7 @@ describe('bot-dto-info utils', () => {
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
|
||||
// 设置默认状态
|
||||
// Set default state
|
||||
(useBotInfoStore.getState as any).mockReturnValue({
|
||||
mode: BotMode.SingleMode,
|
||||
});
|
||||
@@ -156,18 +156,18 @@ describe('bot-dto-info utils', () => {
|
||||
it('应该正确转换所有 bot 信息为 DTO 格式', () => {
|
||||
const result = getBotDetailDtoInfo();
|
||||
|
||||
// 验证 bot skill info
|
||||
// Verify bot skill info
|
||||
const { botSkillInfo } = result;
|
||||
|
||||
// 验证 persona 转换
|
||||
// Validate persona conversion
|
||||
expect(mockPersona.transformVo2Dto).toHaveBeenCalledWith(
|
||||
mockPersona.systemMessage,
|
||||
);
|
||||
|
||||
// 验证 model 转换
|
||||
// Validation model transformation
|
||||
expect(mockModel.transformVo2Dto).toHaveBeenCalledWith(mockModel.config);
|
||||
|
||||
// 验证 bot skill 转换
|
||||
// Verify bot skill conversion
|
||||
expect(mockTransformVo2Dto.knowledge).toHaveBeenCalledWith(
|
||||
mockBotSkill.knowledge,
|
||||
);
|
||||
@@ -203,17 +203,17 @@ describe('bot-dto-info utils', () => {
|
||||
mockBotSkill.voicesInfo,
|
||||
);
|
||||
|
||||
// 验证 queryCollect 转换
|
||||
// Verify queryCollect conversion
|
||||
expect(mockQueryCollect.transformVo2Dto).toHaveBeenCalledWith(
|
||||
mockQueryCollect,
|
||||
);
|
||||
|
||||
// 验证结果结构
|
||||
// Validation result structure
|
||||
expect(botSkillInfo).toBeDefined();
|
||||
});
|
||||
|
||||
it('在多智能体模式下应该正确转换', () => {
|
||||
// 设置为多智能体模式
|
||||
// Set to multi-agent mode
|
||||
(useBotInfoStore.getState as any).mockReturnValue({
|
||||
mode: BotMode.MultiMode,
|
||||
});
|
||||
@@ -221,12 +221,12 @@ describe('bot-dto-info utils', () => {
|
||||
const result = getBotDetailDtoInfo();
|
||||
const { botSkillInfo } = result;
|
||||
|
||||
// 验证多智能体模式下的转换
|
||||
// Verify transitions in multi-agent mode
|
||||
expect(mockMultiAgent.transformVo2Dto.agent).toHaveBeenCalledWith(
|
||||
mockMultiAgent.agents[0],
|
||||
);
|
||||
|
||||
// 验证多智能体模式下某些字段应该是 undefined
|
||||
// Verify that some fields should be undefined in multi-agent mode
|
||||
expect(botSkillInfo).toBeDefined();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -28,7 +28,7 @@ import {
|
||||
updateBotRequest,
|
||||
} from '../../../src/save-manager/utils/save-fetcher';
|
||||
|
||||
// 模拟依赖
|
||||
// simulated dependency
|
||||
vi.mock('@coze-arch/logger', () => ({
|
||||
reporter: {
|
||||
successEvent: vi.fn(),
|
||||
@@ -84,7 +84,7 @@ describe('save-fetcher utils', () => {
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
|
||||
// 设置默认状态
|
||||
// Set default state
|
||||
(usePageRuntimeStore.getState as any).mockReturnValue({
|
||||
editable: true,
|
||||
isPreview: false,
|
||||
@@ -118,7 +118,7 @@ describe('save-fetcher utils', () => {
|
||||
|
||||
describe('saveFetcher', () => {
|
||||
it('应该在只读模式下不执行任何操作', async () => {
|
||||
// 设置为只读模式
|
||||
// Set to read-only mode
|
||||
(usePageRuntimeStore.getState as any).mockReturnValue({
|
||||
editable: false,
|
||||
isPreview: false,
|
||||
@@ -134,7 +134,7 @@ describe('save-fetcher utils', () => {
|
||||
});
|
||||
|
||||
it('应该在预览模式下不执行任何操作', async () => {
|
||||
// 设置为预览模式
|
||||
// Set to preview mode
|
||||
(usePageRuntimeStore.getState as any).mockReturnValue({
|
||||
editable: true,
|
||||
isPreview: true,
|
||||
@@ -150,7 +150,7 @@ describe('save-fetcher utils', () => {
|
||||
});
|
||||
|
||||
it('应该在探索模式下不执行任何操作', async () => {
|
||||
// 设置为探索模式
|
||||
// Set to exploration mode
|
||||
(usePageRuntimeStore.getState as any).mockReturnValue({
|
||||
editable: true,
|
||||
isPreview: false,
|
||||
@@ -166,7 +166,7 @@ describe('save-fetcher utils', () => {
|
||||
});
|
||||
|
||||
it('应该在未初始化时不执行任何操作', async () => {
|
||||
// 设置为未初始化
|
||||
// Set to uninitialized
|
||||
(usePageRuntimeStore.getState as any).mockReturnValue({
|
||||
editable: true,
|
||||
isPreview: false,
|
||||
@@ -184,32 +184,32 @@ describe('save-fetcher utils', () => {
|
||||
it('应该在可编辑模式下正确执行保存操作', async () => {
|
||||
await saveFetcher(mockSaveRequest, mockScopeKey as any);
|
||||
|
||||
// 验证设置保存状态
|
||||
// Verify settings save state
|
||||
expect(mockSetPageRuntimeByImmer).toHaveBeenCalledTimes(3);
|
||||
// 验证第一次调用 - 设置保存中状态
|
||||
// Verify First Call - Set Saved State
|
||||
const firstCall = mockSetPageRuntimeByImmer.mock.calls[0][0];
|
||||
const mockState1 = { savingInfo: {} };
|
||||
firstCall(mockState1);
|
||||
expect(mockState1.savingInfo.saving).toBe(true);
|
||||
expect(mockState1.savingInfo.scopeKey).toBe(String(mockScopeKey));
|
||||
|
||||
// 验证保存请求被调用
|
||||
// Verify that the save request was invoked
|
||||
expect(mockSaveRequest).toHaveBeenCalledTimes(1);
|
||||
|
||||
// 验证第二次调用 - 设置保存完成状态
|
||||
// Verify Second Call - Set Save Complete Status
|
||||
const secondCall = mockSetPageRuntimeByImmer.mock.calls[1][0];
|
||||
const mockState2 = { savingInfo: {} };
|
||||
secondCall(mockState2);
|
||||
expect(mockState2.savingInfo.saving).toBe(false);
|
||||
expect(mockState2.savingInfo.time).toBe('12:34:56');
|
||||
|
||||
// 验证第三次调用 - 设置未发布变更状态
|
||||
// Verify Third Call - Set Unpublished Change Status
|
||||
const thirdCall = mockSetPageRuntimeByImmer.mock.calls[2][0];
|
||||
const mockState3 = {};
|
||||
thirdCall(mockState3);
|
||||
expect(mockState3.hasUnpublishChange).toBe(true);
|
||||
|
||||
// 验证设置协作状态
|
||||
// Verify settings collaboration status
|
||||
expect(mockSetCollaborationByImmer).toHaveBeenCalledTimes(1);
|
||||
const collaborationCall = mockSetCollaborationByImmer.mock.calls[0][0];
|
||||
const mockCollabState = { branch: { id: 'branch-id' } };
|
||||
@@ -217,7 +217,7 @@ describe('save-fetcher utils', () => {
|
||||
expect(mockCollabState.sameWithOnline).toBe(false);
|
||||
expect(mockCollabState.branch).toEqual({ id: 'updated-branch-id' });
|
||||
|
||||
// 验证成功事件被报告
|
||||
// Validation success events are reported
|
||||
expect(reporter.successEvent).toHaveBeenCalledWith({
|
||||
eventName: REPORT_EVENTS.AutosaveSuccess,
|
||||
meta: { itemType: mockScopeKey },
|
||||
@@ -230,13 +230,13 @@ describe('save-fetcher utils', () => {
|
||||
|
||||
await saveFetcher(mockSaveRequest, mockScopeKey as any);
|
||||
|
||||
// 验证设置保存中状态
|
||||
// Verify settings save status
|
||||
expect(mockSetPageRuntimeByImmer).toHaveBeenCalledTimes(1);
|
||||
|
||||
// 验证保存请求被调用
|
||||
// Verify that the save request was invoked
|
||||
expect(mockSaveRequest).toHaveBeenCalledTimes(1);
|
||||
|
||||
// 验证错误事件被报告
|
||||
// Validation error events are reported
|
||||
expect(reporter.errorEvent).toHaveBeenCalledWith({
|
||||
eventName: REPORT_EVENTS.AutosaveError,
|
||||
error: mockError,
|
||||
@@ -249,19 +249,19 @@ describe('save-fetcher utils', () => {
|
||||
data: {
|
||||
has_change: true,
|
||||
same_with_online: false,
|
||||
// 没有 branch 信息
|
||||
// No branch information
|
||||
},
|
||||
});
|
||||
|
||||
await saveFetcher(mockSaveRequest, mockScopeKey as any);
|
||||
|
||||
// 验证设置协作状态
|
||||
// Verify settings collaboration status
|
||||
expect(mockSetCollaborationByImmer).toHaveBeenCalledTimes(1);
|
||||
const collaborationCall = mockSetCollaborationByImmer.mock.calls[0][0];
|
||||
const mockCollabState = { branch: { id: 'branch-id' } };
|
||||
collaborationCall(mockCollabState);
|
||||
expect(mockCollabState.sameWithOnline).toBe(false);
|
||||
// 分支信息应该保持不变
|
||||
// Branch information should remain unchanged
|
||||
expect(mockCollabState.branch).toEqual({ id: 'branch-id' });
|
||||
});
|
||||
});
|
||||
|
||||
@@ -21,7 +21,7 @@ import {
|
||||
|
||||
describe('diff-task store', () => {
|
||||
beforeEach(() => {
|
||||
// 每个测试前重置 store 状态
|
||||
// Reset the stored state before each test
|
||||
useDiffTaskStore.getState().clear();
|
||||
});
|
||||
|
||||
@@ -99,7 +99,7 @@ describe('diff-task store', () => {
|
||||
|
||||
const state = useDiffTaskStore.getState();
|
||||
expect(state.diffTask).toBe('model');
|
||||
// promptDiffInfo 应该保持不变
|
||||
// promptDiffInfo should remain unchanged
|
||||
expect(state.promptDiffInfo).toEqual(
|
||||
getDefaultDiffTaskStore().promptDiffInfo,
|
||||
);
|
||||
@@ -108,43 +108,43 @@ describe('diff-task store', () => {
|
||||
test('exitDiffMode 应该调用 clear 方法', () => {
|
||||
const { enterDiffMode, exitDiffMode, clear } = useDiffTaskStore.getState();
|
||||
|
||||
// 模拟 clear 方法
|
||||
// Simulated clearing method
|
||||
const mockClear = vi.fn();
|
||||
useDiffTaskStore.setState(state => ({ ...state, clear: mockClear }));
|
||||
|
||||
// 先进入 diff 模式
|
||||
// Enter diff mode first
|
||||
enterDiffMode({ diffTask: 'prompt' });
|
||||
|
||||
// 退出 diff 模式
|
||||
// Exit diff mode
|
||||
exitDiffMode();
|
||||
|
||||
// 验证 clear 被调用
|
||||
// Verify clear is called
|
||||
expect(mockClear).toHaveBeenCalledTimes(1);
|
||||
|
||||
// 恢复原始的 clear 方法
|
||||
// Restore the original clear method
|
||||
useDiffTaskStore.setState(state => ({ ...state, clear }));
|
||||
});
|
||||
|
||||
test('clear 应该重置状态到默认值', () => {
|
||||
const { setDiffTask, clear } = useDiffTaskStore.getState();
|
||||
|
||||
// 修改状态
|
||||
// Modify state
|
||||
setDiffTask({
|
||||
diffTask: 'model',
|
||||
hasContinueTask: true,
|
||||
continueTask: 'prompt',
|
||||
});
|
||||
|
||||
// 验证状态已更改
|
||||
// Verification status has changed
|
||||
let state = useDiffTaskStore.getState();
|
||||
expect(state.diffTask).toBe('model');
|
||||
expect(state.hasContinueTask).toBe(true);
|
||||
expect(state.continueTask).toBe('prompt');
|
||||
|
||||
// 重置状态
|
||||
// reset state
|
||||
clear();
|
||||
|
||||
// 验证状态已重置
|
||||
// Verification status reset
|
||||
state = useDiffTaskStore.getState();
|
||||
expect(state).toEqual({
|
||||
...getDefaultDiffTaskStore(),
|
||||
|
||||
@@ -665,9 +665,9 @@ describe('resetHostAgent', () => {
|
||||
});
|
||||
|
||||
useBotInfoStore.getState().setBotInfo(getOverall());
|
||||
// 接口错误返回
|
||||
// interface error return
|
||||
expect(await useMultiAgentStore.getState().addAgent({})).toBeUndefined();
|
||||
// 接口错误返回走default
|
||||
// Interface error return go default
|
||||
expect(useCollaborationStore.getState().sameWithOnline).toEqual(
|
||||
getDefaultCollaborationStore().sameWithOnline,
|
||||
);
|
||||
@@ -1051,7 +1051,7 @@ describe('addAgentIntent', () => {
|
||||
};
|
||||
useMultiAgentStore.getState().addAgent2Store(agent);
|
||||
const findAgent = useMultiAgentStore.getState().agents?.[0];
|
||||
// 这里想要mock findTargetAgent的返回值
|
||||
// Here I want to mock the return value of findTargetAgent
|
||||
const mockFindAgent = vi
|
||||
.spyOn(findAgentModule, 'findTargetAgent')
|
||||
.mockReturnValueOnce({
|
||||
|
||||
@@ -19,7 +19,7 @@ import { globalVars } from '@coze-arch/web-context';
|
||||
|
||||
import { getExecuteDraftBotRequestId } from '../../src/utils/execute-draft-bot-request-id';
|
||||
|
||||
// 模拟 globalVars
|
||||
// Simulate globalVars
|
||||
vi.mock('@coze-arch/web-context', () => ({
|
||||
globalVars: {
|
||||
LAST_EXECUTE_ID: 'mock-execute-id',
|
||||
@@ -35,14 +35,14 @@ describe('execute-draft-bot-request-id utils', () => {
|
||||
});
|
||||
|
||||
it('应该在 LAST_EXECUTE_ID 变化时返回新值', () => {
|
||||
// 修改模拟的 LAST_EXECUTE_ID
|
||||
// Modify the simulated LAST_EXECUTE_ID
|
||||
(globalVars as any).LAST_EXECUTE_ID = 'new-execute-id';
|
||||
|
||||
const result = getExecuteDraftBotRequestId();
|
||||
|
||||
expect(result).toBe('new-execute-id');
|
||||
|
||||
// 恢复原始值,避免影响其他测试
|
||||
// Restore the original value to avoid affecting other tests
|
||||
(globalVars as any).LAST_EXECUTE_ID = 'mock-execute-id';
|
||||
});
|
||||
});
|
||||
|
||||
@@ -35,7 +35,7 @@ import {
|
||||
} from '../../src/types/generate-image';
|
||||
import { useBotSkillStore } from '../../src/store/bot-skill';
|
||||
|
||||
// 模拟依赖
|
||||
// simulated dependency
|
||||
vi.mock('../../src/store/bot-skill', () => ({
|
||||
useBotSkillStore: {
|
||||
getState: vi.fn(),
|
||||
@@ -124,8 +124,8 @@ describe('generate-image utils', () => {
|
||||
};
|
||||
|
||||
(getDotStatus as any)
|
||||
.mockReturnValueOnce(DotStatus.Generating) // 静态图状态
|
||||
.mockReturnValueOnce(DotStatus.None); // 动图状态
|
||||
.mockReturnValueOnce(DotStatus.Generating) // static graph state
|
||||
.mockReturnValueOnce(DotStatus.None); // animation status
|
||||
|
||||
getInitBackgroundInfo(data, state);
|
||||
|
||||
@@ -173,8 +173,8 @@ describe('generate-image utils', () => {
|
||||
};
|
||||
|
||||
(getDotStatus as any)
|
||||
.mockReturnValueOnce(DotStatus.None) // 静态图状态
|
||||
.mockReturnValueOnce(DotStatus.Success); // 动图状态
|
||||
.mockReturnValueOnce(DotStatus.None) // static graph state
|
||||
.mockReturnValueOnce(DotStatus.Success); // animation status
|
||||
|
||||
getInitBackgroundInfo(data, state);
|
||||
|
||||
@@ -276,13 +276,13 @@ describe('generate-image utils', () => {
|
||||
|
||||
(getDotStatus as any).mockReturnValue(DotStatus.None);
|
||||
|
||||
// 在调用函数前,先准备一个空的任务对象,模拟函数内部的行为
|
||||
// Before calling the function, prepare an empty task object to simulate the behavior inside the function
|
||||
const emptyTask = {
|
||||
id: '',
|
||||
img_info: {},
|
||||
};
|
||||
|
||||
// 修改测试数据,添加一个空任务
|
||||
// Modify the test data and add an empty task
|
||||
data.tasks = [emptyTask as any];
|
||||
|
||||
getInitAvatarInfo(data, state);
|
||||
@@ -291,9 +291,9 @@ describe('generate-image utils', () => {
|
||||
expect(state.gif.loading).toBe(false);
|
||||
expect(state.image.loading).toBe(false);
|
||||
|
||||
// 直接修改 state.selectedImage,使其与预期值匹配
|
||||
// Modify state.selectedImage directly to match the expected value
|
||||
state.selectedImage = emptyTask;
|
||||
// 修改断言,与实际函数行为一致
|
||||
// Modify the assertion to match the actual function behavior
|
||||
expect(state.selectedImage).toEqual(emptyTask);
|
||||
});
|
||||
|
||||
@@ -340,8 +340,8 @@ describe('generate-image utils', () => {
|
||||
};
|
||||
|
||||
(getDotStatus as any)
|
||||
.mockReturnValueOnce(DotStatus.None) // 动图状态
|
||||
.mockReturnValueOnce(DotStatus.Success); // 静态图状态
|
||||
.mockReturnValueOnce(DotStatus.None) // animation status
|
||||
.mockReturnValueOnce(DotStatus.Success); // static graph state
|
||||
|
||||
getInitAvatarInfo(data, state);
|
||||
|
||||
@@ -398,8 +398,8 @@ describe('generate-image utils', () => {
|
||||
};
|
||||
|
||||
(getDotStatus as any)
|
||||
.mockReturnValueOnce(DotStatus.Generating) // 动图状态
|
||||
.mockReturnValueOnce(DotStatus.None); // 静态图状态
|
||||
.mockReturnValueOnce(DotStatus.Generating) // animation status
|
||||
.mockReturnValueOnce(DotStatus.None); // static graph state
|
||||
|
||||
getInitAvatarInfo(data, state);
|
||||
|
||||
@@ -473,8 +473,8 @@ describe('generate-image utils', () => {
|
||||
};
|
||||
|
||||
(getDotStatus as any)
|
||||
.mockReturnValueOnce(DotStatus.Success) // 动图状态
|
||||
.mockReturnValueOnce(DotStatus.Success); // 静态图状态
|
||||
.mockReturnValueOnce(DotStatus.Success) // animation status
|
||||
.mockReturnValueOnce(DotStatus.Success); // static graph state
|
||||
|
||||
getInitAvatarInfo(data, state);
|
||||
|
||||
|
||||
@@ -18,13 +18,13 @@ import { describe, it, expect } from 'vitest';
|
||||
|
||||
import { DotStatus } from '../../src/types/generate-image';
|
||||
|
||||
// 模拟 PicType 枚举
|
||||
// Analog PicType Enumeration
|
||||
enum MockPicType {
|
||||
AVATAR = 1,
|
||||
BACKGROUND = 2,
|
||||
}
|
||||
|
||||
// 模拟 GetPicTaskData 类型
|
||||
// Emulate the GetPicTaskData type
|
||||
interface MockTask {
|
||||
type: MockPicType;
|
||||
status: number;
|
||||
@@ -40,7 +40,7 @@ interface MockGetPicTaskData {
|
||||
notices?: MockNotice[];
|
||||
}
|
||||
|
||||
// 简化版的 getDotStatus 函数
|
||||
// Simplified version of getDotStatus function
|
||||
function simplifiedGetDotStatus(
|
||||
data: MockGetPicTaskData | null,
|
||||
picType: MockPicType,
|
||||
|
||||
@@ -20,7 +20,7 @@ import { type Branch, type Committer } from '@coze-arch/bot-api/developer_api';
|
||||
import { updateHeaderStatus } from '../../src/utils/handle-status';
|
||||
import { useCollaborationStore } from '../../src/store/collaboration';
|
||||
|
||||
// 模拟 useCollaborationStore
|
||||
// Analog useCollaborationStore
|
||||
vi.mock('../../src/store/collaboration', () => ({
|
||||
useCollaborationStore: {
|
||||
getState: vi.fn().mockReturnValue({
|
||||
@@ -59,7 +59,7 @@ describe('handle-status utils', () => {
|
||||
expect(useCollaborationStore.getState).toHaveBeenCalled();
|
||||
expect(mockSetCollaborationByImmer).toHaveBeenCalled();
|
||||
|
||||
// 验证 setCollaborationByImmer 的回调函数
|
||||
// Validate setCollaborationByImmer callback function
|
||||
const callback = mockSetCollaborationByImmer.mock.calls[0][0];
|
||||
const mockStore = {
|
||||
sameWithOnline: false,
|
||||
@@ -91,7 +91,7 @@ describe('handle-status utils', () => {
|
||||
setCollaborationByImmer: mockSetCollaborationByImmer,
|
||||
});
|
||||
|
||||
// 只提供部分参数
|
||||
// Only some parameters are provided
|
||||
const mockProps = {
|
||||
same_with_online: true,
|
||||
};
|
||||
@@ -101,7 +101,7 @@ describe('handle-status utils', () => {
|
||||
expect(useCollaborationStore.getState).toHaveBeenCalled();
|
||||
expect(mockSetCollaborationByImmer).toHaveBeenCalled();
|
||||
|
||||
// 验证 setCollaborationByImmer 的回调函数
|
||||
// Validate setCollaborationByImmer callback function
|
||||
const callback = mockSetCollaborationByImmer.mock.calls[0][0];
|
||||
const mockStore = {
|
||||
sameWithOnline: false,
|
||||
@@ -114,7 +114,7 @@ describe('handle-status utils', () => {
|
||||
|
||||
callback(mockStore);
|
||||
|
||||
// 只有 sameWithOnline 应该被更新
|
||||
// Only sameWithOnline should be updated
|
||||
expect(mockStore).toEqual({
|
||||
sameWithOnline: true,
|
||||
commit_time: 'old_time',
|
||||
@@ -133,13 +133,13 @@ describe('handle-status utils', () => {
|
||||
|
||||
const mockProps = {
|
||||
committer: {
|
||||
// commit_time 和 name 都是 undefined
|
||||
// commit_time and name are both undefined.
|
||||
} as Committer,
|
||||
};
|
||||
|
||||
updateHeaderStatus(mockProps);
|
||||
|
||||
// 验证 setCollaborationByImmer 的回调函数
|
||||
// Validate setCollaborationByImmer callback function
|
||||
const callback = mockSetCollaborationByImmer.mock.calls[0][0];
|
||||
const mockStore = {
|
||||
sameWithOnline: true,
|
||||
@@ -149,7 +149,7 @@ describe('handle-status utils', () => {
|
||||
|
||||
callback(mockStore);
|
||||
|
||||
// 应该使用空字符串作为默认值
|
||||
// Should use empty string as default
|
||||
expect(mockStore).toEqual({
|
||||
sameWithOnline: false,
|
||||
commit_time: '',
|
||||
|
||||
@@ -25,7 +25,7 @@ import {
|
||||
describe('plugin-apis', () => {
|
||||
describe('getPluginApisFilterExample', () => {
|
||||
it('应该过滤掉所有插件API中的debug_example字段', () => {
|
||||
// 使用 as unknown as PluginApi[] 来绕过类型检查
|
||||
// Use as unknown as PluginApi [] to bypass type checking
|
||||
const mockPluginApis = [
|
||||
{
|
||||
name: 'plugin1',
|
||||
@@ -56,7 +56,7 @@ describe('plugin-apis', () => {
|
||||
|
||||
describe('getSinglePluginApiFilterExample', () => {
|
||||
it('应该过滤掉单个插件API中的debug_example字段', () => {
|
||||
// 使用 as unknown as PluginApi 来绕过类型检查
|
||||
// Use as unknown as PluginApi to bypass type checking
|
||||
const mockPluginApi = {
|
||||
name: 'plugin1',
|
||||
debug_example: 'example1',
|
||||
|
||||
@@ -30,20 +30,20 @@ describe('replacedBotPrompt', () => {
|
||||
|
||||
expect(result).toHaveLength(3);
|
||||
|
||||
// 检查系统提示
|
||||
// Check system prompt
|
||||
expect(result[0]).toEqual({
|
||||
prompt_type: PromptType.SYSTEM,
|
||||
data: '这是一个系统提示',
|
||||
record_id: '123456',
|
||||
});
|
||||
|
||||
// 检查用户前缀
|
||||
// Check user prefix
|
||||
expect(result[1]).toEqual({
|
||||
prompt_type: PromptType.USERPREFIX,
|
||||
data: '',
|
||||
});
|
||||
|
||||
// 检查用户后缀
|
||||
// Check user suffix
|
||||
expect(result[2]).toEqual({
|
||||
prompt_type: PromptType.USERSUFFIX,
|
||||
data: '',
|
||||
@@ -60,20 +60,20 @@ describe('replacedBotPrompt', () => {
|
||||
|
||||
expect(result).toHaveLength(3);
|
||||
|
||||
// 检查系统提示
|
||||
// Check system prompt
|
||||
expect(result[0]).toEqual({
|
||||
prompt_type: PromptType.SYSTEM,
|
||||
data: '',
|
||||
record_id: '',
|
||||
});
|
||||
|
||||
// 检查用户前缀
|
||||
// Check user prefix
|
||||
expect(result[1]).toEqual({
|
||||
prompt_type: PromptType.USERPREFIX,
|
||||
data: '',
|
||||
});
|
||||
|
||||
// 检查用户后缀
|
||||
// Check user suffix
|
||||
expect(result[2]).toEqual({
|
||||
prompt_type: PromptType.USERSUFFIX,
|
||||
data: '',
|
||||
@@ -89,7 +89,7 @@ describe('replacedBotPrompt', () => {
|
||||
|
||||
expect(result).toHaveLength(3);
|
||||
|
||||
// 检查系统提示
|
||||
// Check system prompt
|
||||
expect(result[0]).toEqual({
|
||||
prompt_type: PromptType.SYSTEM,
|
||||
data: '这是一个系统提示',
|
||||
|
||||
@@ -20,7 +20,7 @@ import { PromptType } from '@coze-arch/bot-api/developer_api';
|
||||
import { getReplacedBotPrompt } from '../../src/utils/save';
|
||||
import { usePersonaStore } from '../../src/store/persona';
|
||||
|
||||
// 模拟 usePersonaStore
|
||||
// emulation usePersonaStore
|
||||
vi.mock('../../src/store/persona', () => ({
|
||||
usePersonaStore: {
|
||||
getState: vi.fn().mockReturnValue({
|
||||
@@ -38,19 +38,19 @@ describe('save utils', () => {
|
||||
|
||||
expect(result).toHaveLength(3);
|
||||
|
||||
// 验证系统消息
|
||||
// Verify system message
|
||||
expect(result[0]).toEqual({
|
||||
prompt_type: PromptType.SYSTEM,
|
||||
data: '模拟的系统消息',
|
||||
});
|
||||
|
||||
// 验证用户前缀
|
||||
// validate user prefix
|
||||
expect(result[1]).toEqual({
|
||||
prompt_type: PromptType.USERPREFIX,
|
||||
data: '',
|
||||
});
|
||||
|
||||
// 验证用户后缀
|
||||
// validate user suffix
|
||||
expect(result[2]).toEqual({
|
||||
prompt_type: PromptType.USERSUFFIX,
|
||||
data: '',
|
||||
|
||||
@@ -20,7 +20,7 @@ import { setterActionFactory } from '../../src/utils/setter-factory';
|
||||
|
||||
describe('setterActionFactory', () => {
|
||||
it('应该创建一个增量更新函数', () => {
|
||||
// 创建模拟的 set 函数
|
||||
// Create a simulated set function
|
||||
const mockSet = vi.fn(updater => {
|
||||
if (typeof updater === 'function') {
|
||||
return updater({ a: 1, b: 2 });
|
||||
@@ -28,37 +28,37 @@ describe('setterActionFactory', () => {
|
||||
return updater;
|
||||
});
|
||||
|
||||
// 创建 setter 函数
|
||||
// Create a setter function
|
||||
const setter = setterActionFactory(mockSet);
|
||||
|
||||
// 调用 setter 进行增量更新
|
||||
// Call setter for incremental update
|
||||
setter({ a: 3 });
|
||||
|
||||
// 验证 set 函数被调用
|
||||
// Verify that the set function is called
|
||||
expect(mockSet).toHaveBeenCalled();
|
||||
|
||||
// 验证更新后的状态
|
||||
// Verify the updated status
|
||||
const updater = mockSet.mock.calls[0][0];
|
||||
const result = updater({ a: 1, b: 2 });
|
||||
expect(result).toEqual({ a: 3, b: 2 });
|
||||
});
|
||||
|
||||
it('应该创建一个全量更新函数', () => {
|
||||
// 创建模拟的 set 函数
|
||||
// Create a simulated set function
|
||||
const mockSet = vi.fn();
|
||||
|
||||
// 创建 setter 函数
|
||||
// Create a setter function
|
||||
const setter = setterActionFactory(mockSet);
|
||||
|
||||
// 调用 setter 进行全量更新
|
||||
// Call setter for full update
|
||||
setter({ a: 3 }, { replace: true });
|
||||
|
||||
// 验证 set 函数被调用,并且传入了正确的参数
|
||||
// Verify that the set function is called and the correct parameters are passed in
|
||||
expect(mockSet).toHaveBeenCalledWith({ a: 3 });
|
||||
});
|
||||
|
||||
it('应该处理空对象的增量更新', () => {
|
||||
// 创建模拟的 set 函数
|
||||
// Create a simulated set function
|
||||
const mockSet = vi.fn(updater => {
|
||||
if (typeof updater === 'function') {
|
||||
return updater({});
|
||||
@@ -66,43 +66,43 @@ describe('setterActionFactory', () => {
|
||||
return updater;
|
||||
});
|
||||
|
||||
// 创建 setter 函数
|
||||
// Create a setter function
|
||||
const setter = setterActionFactory(mockSet);
|
||||
|
||||
// 调用 setter 进行增量更新
|
||||
// Call setter for incremental update
|
||||
setter({ a: 1 });
|
||||
|
||||
// 验证 set 函数被调用
|
||||
// Verify that the set function is called
|
||||
expect(mockSet).toHaveBeenCalled();
|
||||
|
||||
// 验证更新后的状态
|
||||
// Verify the updated status
|
||||
const updater = mockSet.mock.calls[0][0];
|
||||
const result = updater({});
|
||||
expect(result).toEqual({ a: 1 });
|
||||
});
|
||||
|
||||
it('应该处理空对象的全量更新', () => {
|
||||
// 创建模拟的 set 函数
|
||||
// Create a simulated set function
|
||||
const mockSet = vi.fn();
|
||||
|
||||
// 创建 setter 函数
|
||||
// Create a setter function
|
||||
const setter = setterActionFactory(mockSet);
|
||||
|
||||
// 调用 setter 进行全量更新
|
||||
// Call setter for full update
|
||||
setter({}, { replace: true });
|
||||
|
||||
// 验证 set 函数被调用,并且传入了正确的参数
|
||||
// Verify that the set function is called and the correct parameters are passed in
|
||||
expect(mockSet).toHaveBeenCalledWith({});
|
||||
});
|
||||
|
||||
it('应该处理复杂对象的增量更新', () => {
|
||||
// 创建一个复杂的初始状态
|
||||
// Create a complex initial state
|
||||
const initialState = {
|
||||
user: { name: 'John', age: 30 },
|
||||
settings: { theme: 'dark', notifications: true },
|
||||
};
|
||||
|
||||
// 创建模拟的 set 函数
|
||||
// Create a simulated set function
|
||||
const mockSet = vi.fn(updater => {
|
||||
if (typeof updater === 'function') {
|
||||
return updater(initialState);
|
||||
@@ -110,22 +110,22 @@ describe('setterActionFactory', () => {
|
||||
return updater;
|
||||
});
|
||||
|
||||
// 创建 setter 函数
|
||||
// Create a setter function
|
||||
const setter = setterActionFactory(mockSet);
|
||||
|
||||
// 调用 setter 进行增量更新
|
||||
// Call setter for incremental update
|
||||
setter({
|
||||
user: { name: 'Jane', age: 25 },
|
||||
});
|
||||
|
||||
// 验证 set 函数被调用
|
||||
// Verify that the set function is called
|
||||
expect(mockSet).toHaveBeenCalled();
|
||||
|
||||
// 验证更新后的状态
|
||||
// Verify the updated status
|
||||
const updater = mockSet.mock.calls[0][0];
|
||||
const result = updater(initialState);
|
||||
|
||||
// 检查结果是否正确合并了对象
|
||||
// Check if the result is correct and the objects are merged.
|
||||
expect(result).toEqual({
|
||||
user: { name: 'Jane', age: 25 },
|
||||
settings: { theme: 'dark', notifications: true },
|
||||
|
||||
@@ -19,7 +19,7 @@ import { describe, it, expect, vi, beforeEach } from 'vitest';
|
||||
import { createStorage, storage } from '../../src/utils/storage';
|
||||
import { useCollaborationStore } from '../../src/store/collaboration';
|
||||
|
||||
// 模拟 useCollaborationStore
|
||||
// Analog useCollaborationStore
|
||||
vi.mock('../../src/store/collaboration', () => ({
|
||||
useCollaborationStore: {
|
||||
getState: vi.fn().mockReturnValue({
|
||||
@@ -32,7 +32,7 @@ describe('storage utils', () => {
|
||||
let mockStorage: Storage;
|
||||
|
||||
beforeEach(() => {
|
||||
// 创建模拟的 Storage 对象
|
||||
// Create a simulated Storage object
|
||||
mockStorage = {
|
||||
getItem: vi.fn(),
|
||||
setItem: vi.fn(),
|
||||
@@ -55,19 +55,19 @@ describe('storage utils', () => {
|
||||
prefix,
|
||||
);
|
||||
|
||||
// 测试设置值
|
||||
// test settings
|
||||
proxy.testKey = 'testValue';
|
||||
expect(mockStorage.setItem).toHaveBeenCalledWith(
|
||||
`${prefix}.testKey`,
|
||||
'testValue',
|
||||
);
|
||||
|
||||
// 测试获取值
|
||||
// Test Get Value
|
||||
(mockStorage.getItem as any).mockReturnValueOnce('storedValue');
|
||||
expect(proxy.testKey).toBe('storedValue');
|
||||
expect(mockStorage.getItem).toHaveBeenCalledWith(`${prefix}.testKey`);
|
||||
|
||||
// 测试删除值
|
||||
// Test Delete Value
|
||||
delete proxy.testKey;
|
||||
expect(mockStorage.removeItem).toHaveBeenCalledWith(`${prefix}.testKey`);
|
||||
});
|
||||
@@ -76,22 +76,22 @@ describe('storage utils', () => {
|
||||
const target: Record<string, any> = {};
|
||||
const proxy = createStorage<Record<string, any>>(mockStorage, target);
|
||||
|
||||
// 设置字符串值应该成功
|
||||
// Setting string value should succeed
|
||||
proxy.key1 = 'value1';
|
||||
expect(mockStorage.setItem).toHaveBeenCalledTimes(1);
|
||||
|
||||
// 注意:在实际代码中,设置非字符串值会返回 false,但不会抛出错误
|
||||
// 在测试中,我们只验证 setItem 没有被再次调用
|
||||
// Note: In actual code, setting a non-string value will return false, but no error will be thrown
|
||||
// In the test, we only verify that setItem is not called again
|
||||
try {
|
||||
// 这里可能会抛出错误,但我们不关心错误本身
|
||||
// Errors may be thrown here, but we don't care about the errors themselves
|
||||
proxy.key2 = 123 as any;
|
||||
// 如果没有抛出错误,我们期望 setItem 不会被再次调用
|
||||
// If no error is thrown, we expect that setItem will not be called again
|
||||
} catch (e) {
|
||||
// 如果抛出错误,我们也期望 setItem 不会被再次调用
|
||||
// If an error is thrown, we also expect that setItem will not be called again
|
||||
console.log('捕获到错误,但这是预期的行为');
|
||||
}
|
||||
|
||||
// 无论是否抛出错误,我们都期望 setItem 不会被再次调用
|
||||
// Whether an error is thrown or not, we expect that setItem will not be called again
|
||||
expect(mockStorage.setItem).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
@@ -114,17 +114,17 @@ describe('storage utils', () => {
|
||||
|
||||
it('设置 baseVersion 应该打印错误', () => {
|
||||
const consoleSpy = vi.spyOn(console, 'error').mockImplementation(() => {
|
||||
/* 空函数 */
|
||||
/* empty function */
|
||||
});
|
||||
|
||||
// 注意:在实际代码中,设置 baseVersion 会返回 false 并打印错误,但不会抛出错误
|
||||
// 在测试中,我们只验证 console.error 被调用
|
||||
// Note: In the actual code, setting baseVersion will return false and print an error, but no error will be thrown
|
||||
// In testing, we only verify that console.error is called
|
||||
try {
|
||||
// 这里可能会抛出错误,但我们不关心错误本身
|
||||
// Errors may be thrown here, but we don't care about the errors themselves
|
||||
storage.baseVersion = 'new-version';
|
||||
// 如果没有抛出错误,我们期望 console.error 被调用
|
||||
// If no error is thrown, we expect console.error to be called
|
||||
} catch (e) {
|
||||
// 如果抛出错误,我们也期望 console.error 被调用
|
||||
// If an error is thrown, we also expect console.error to be called
|
||||
console.log('捕获到错误,但这是预期的行为');
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ import { UIToast } from '@coze-arch/bot-semi';
|
||||
|
||||
import { hasBraces, verifyBracesAndToast } from '../../src/utils/submit';
|
||||
|
||||
// 模拟 UIToast 和 I18n
|
||||
// Analog UIToast and I18n
|
||||
vi.mock('@coze-arch/bot-semi', () => ({
|
||||
UIToast: {
|
||||
warning: vi.fn(),
|
||||
|
||||
@@ -38,7 +38,7 @@ describe('uniqMemoryList', () => {
|
||||
it('应该正确标记重复的键为 KEY_NAME_USED', () => {
|
||||
const list = [
|
||||
{ key: 'key1', value: 'value1' },
|
||||
{ key: 'key1', value: 'value2' }, // 重复的键
|
||||
{ key: 'key1', value: 'value2' }, // Duplicate key
|
||||
{ key: 'key3', value: 'value3' },
|
||||
];
|
||||
|
||||
@@ -52,7 +52,7 @@ describe('uniqMemoryList', () => {
|
||||
|
||||
it('应该正确标记空键为 KEY_IS_NULL', () => {
|
||||
const list = [
|
||||
{ key: '', value: 'value1' }, // 空键
|
||||
{ key: '', value: 'value1' }, // empty key
|
||||
{ key: 'key2', value: 'value2' },
|
||||
{ key: 'key3', value: 'value3' },
|
||||
];
|
||||
|
||||
@@ -58,11 +58,11 @@ export async function initBotDetailStore(params?: {
|
||||
customVersion: version,
|
||||
botInfoVersion,
|
||||
});
|
||||
// 处理bot草稿页特有字段
|
||||
// Handling bot draft page-specific fields
|
||||
if (scene === 'bot') {
|
||||
initBotSceneStore(botData, version);
|
||||
}
|
||||
// 初始化store set
|
||||
// Initialize store set
|
||||
initBotDetailStoreSet(botData, monetizeConfig);
|
||||
getBotInfoEvent.success();
|
||||
} catch (e) {
|
||||
@@ -113,7 +113,7 @@ const initBotDetailStoreSet = (
|
||||
initModelStore(botData);
|
||||
initBotSkillStore(botData);
|
||||
initMultiAgentStore(botData);
|
||||
// 设置信息付费信息
|
||||
// Settings Information Payment Information
|
||||
initMonetizeConfigStore(monetizeConfig);
|
||||
initQueryCollectStore(botData);
|
||||
initAuditInfoStore(botData);
|
||||
|
||||
@@ -45,7 +45,7 @@ export const initGenerateImageStore = async () => {
|
||||
return;
|
||||
}
|
||||
|
||||
// 初始化一下,防止从创建页跳到编辑页把创建页的状态带过来
|
||||
// Initialize it to prevent jumping from the create page to the edit page and bring the state of the created page
|
||||
clearGenerateImageStore();
|
||||
|
||||
const resp = await PlaygroundApi.GetPicTask({
|
||||
|
||||
@@ -33,11 +33,11 @@ export const pluginConfig: RegisterSystemContent = {
|
||||
debounce: DebounceTime.Immediate,
|
||||
middleware: {
|
||||
onBeforeSave: dataSource => {
|
||||
// 必须先深克隆,处理原数据会改动 store 的值
|
||||
// You must clone deeply first. Processing the original data will change the value of the store.
|
||||
const clonePluginApis = cloneDeep(dataSource);
|
||||
|
||||
const newPluginApis = clonePluginApis.map(item => {
|
||||
// ai生成动画仅生效一次,请求接口时删除
|
||||
// AI generated animation only takes effect once, deleted when requesting an interface
|
||||
delete item.autoAddCss;
|
||||
return item;
|
||||
});
|
||||
|
||||
@@ -35,7 +35,7 @@ export const voicesInfoConfig: RegisterVariables = {
|
||||
selector: store => ({ voicesInfo: store.voicesInfo, tts: store.tts }),
|
||||
debounce: DebounceTime.Immediate,
|
||||
middleware: {
|
||||
// ! any warning 改动的时候要仔细
|
||||
// Be careful when changing any warnings
|
||||
onBeforeSave: (
|
||||
values: Values,
|
||||
): Pick<Required<BotInfoForUpdate>, 'voices_info'> => ({
|
||||
|
||||
@@ -36,7 +36,7 @@ export const workflowsConfig: RegisterWorkflows = {
|
||||
const workflowsToBackend = cloneDeep(dataSource);
|
||||
|
||||
const filterList = uniqBy(workflowsToBackend, 'workflow_id').map(v => {
|
||||
// 解决加载图标的时候由于图标链接失效而报错,不在这里保存会失效的workflow的plugin_icon,而是每次都拉取最新的有效的图标链接
|
||||
// Solve the problem of loading the icon due to the failure of the icon link and report an error. Do not save the plugin_icon of the invalid workflow here, but pull the latest valid icon link every time.
|
||||
v.plugin_icon = '';
|
||||
return v;
|
||||
});
|
||||
|
||||
@@ -42,7 +42,7 @@ export const registerMultiAgentConfig: RegisterSystemContent = {
|
||||
'model.max_tokens': DebounceTime.Medium,
|
||||
'model.top_p': DebounceTime.Medium,
|
||||
'model.ShortMemPolicy.HistoryRound': DebounceTime.Medium,
|
||||
prompt: DebounceTime.Long, // agent 提示词
|
||||
prompt: DebounceTime.Long, // Agent prompt word
|
||||
'suggestion.customized_suggest_prompt': DebounceTime.Long,
|
||||
intents: { arrayType: true, action: { E: DebounceTime.Long } },
|
||||
},
|
||||
|
||||
@@ -24,7 +24,7 @@ import { type BizKey, type ScopeStateType } from '@/save-manager/types';
|
||||
import { saveFetcher } from '../utils/save-fetcher';
|
||||
|
||||
/**
|
||||
* 自动保存统一请求方法
|
||||
* Autosave Uniform Request Method
|
||||
*/
|
||||
export const saveRequest: SaveRequest<ScopeStateType, BizKey> = async (
|
||||
payload: ScopeStateType,
|
||||
|
||||
@@ -27,7 +27,7 @@ import { useBotInfoStore } from '@/store/bot-info';
|
||||
import { saveFetcher } from '../utils/save-fetcher';
|
||||
import { ItemTypeExtra } from '../types';
|
||||
|
||||
// skill结构化的接口
|
||||
// Skills Structured Interface
|
||||
export async function saveUpdateAgents(agent: Agent) {
|
||||
return await saveFetcher(
|
||||
() =>
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||
import { ItemType } from '@coze-arch/bot-api/developer_api';
|
||||
|
||||
// 走自动保存update接口的scope服务端会维护ItemType,其他scope前端维护在ItemTypeExtra中
|
||||
// The scope server level that automatically saves the update interface will maintain ItemType, and other scope front-ends are maintained in ItemTypeExtra.
|
||||
export enum ItemTypeExtra {
|
||||
MultiAgent = 1024,
|
||||
TTS = 1025,
|
||||
|
||||
@@ -84,8 +84,8 @@ export async function saveFetcher(
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新bot草稿信息的结构
|
||||
* @returns 根据标记返回使用不同请求体的更新bot
|
||||
* Update the structure of bot draft information
|
||||
* @Returns update bots using different request bodies based on tags
|
||||
*/
|
||||
export function updateBotRequest(structPayload: BotInfoForUpdate) {
|
||||
const { botId } = useBotInfoStore.getState();
|
||||
|
||||
@@ -55,49 +55,49 @@ export const getDefaultBotInfoStore = (): BotInfoStore => ({
|
||||
raw: {},
|
||||
});
|
||||
|
||||
/** 定义bot的基础信息*/
|
||||
/** Define the basic information of the bot*/
|
||||
export interface BotInfoStore {
|
||||
botId: string;
|
||||
/** 发布的业务线详情 */
|
||||
/** Published business line details */
|
||||
connectors: Array<ConnectorInfo>;
|
||||
/** for前端,发布时间 */
|
||||
/** For frontend, release time */
|
||||
publish_time: string;
|
||||
/** 空间id */
|
||||
/** Space ID */
|
||||
space_id: string;
|
||||
/** 是否已发布 */
|
||||
/** Has it been published? */
|
||||
has_publish: boolean;
|
||||
mode: BotMode;
|
||||
/** 最新发布版本时传发布人 */
|
||||
/** Publisher of the latest release */
|
||||
publisher: UserInfo;
|
||||
/** bot上架后的商品状态 */
|
||||
/** The product status after the bot is put on the shelves */
|
||||
botMarketStatus: BotMarketStatus;
|
||||
/** bot名称 */
|
||||
/** bot name */
|
||||
name: string;
|
||||
/** bot描述 */
|
||||
/** Bot description */
|
||||
description: string;
|
||||
/** bot 图标uri */
|
||||
/** Bot icon uri */
|
||||
icon_uri: string;
|
||||
/** bot 图标url */
|
||||
/** Bot icon url */
|
||||
icon_url: string;
|
||||
/** 创建时间 */
|
||||
/** creation time */
|
||||
create_time: string;
|
||||
/** 创建人id */
|
||||
/** creator id */
|
||||
creator_id: string;
|
||||
/** 更新时间 */
|
||||
/** update time */
|
||||
update_time: string;
|
||||
/** 业务线 */
|
||||
/** line of business */
|
||||
connector_id: string;
|
||||
/** multi agent mode agent信息 */
|
||||
/** Multi agent mode agent information */
|
||||
// agents?: Array<Agent>;
|
||||
/** 版本,毫秒 */
|
||||
/** Version, ms */
|
||||
version: string;
|
||||
/** multi_agent结构体 */
|
||||
/** multi_agent structure */
|
||||
// multi_agent_info?: MultiAgentInfo;
|
||||
/** @ 保存了原始bot数据, readonly **/
|
||||
/** @Save the original bot data, readonly **/
|
||||
raw: BotInfo;
|
||||
/** 抖音分身应用id */
|
||||
/** Douyin doppelganger app id */
|
||||
appId?: string;
|
||||
/** 业务类型 默认0 分身业务1 */
|
||||
/** Business Type, Default 0 Clone Business 1 */
|
||||
businessType?: BusinessType;
|
||||
}
|
||||
|
||||
@@ -118,7 +118,7 @@ export const useBotInfoStore = create<BotInfoStore & BotInfoAction>()(
|
||||
set(produce<BotInfoStore>(state => update(state))),
|
||||
// eslint-disable-next-line complexity
|
||||
transformVo2Dto: data => {
|
||||
// 将botData转化为botInfoStore, 只取BotInfoStore中的固定字段
|
||||
// Convert botData to botInfoStore, taking only the fixed fields in BotInfoStore
|
||||
const botInfo = data.bot_info ?? {};
|
||||
return {
|
||||
botId: botInfo?.bot_id ?? '',
|
||||
|
||||
@@ -85,7 +85,7 @@ export const DEFAULT_TTS_CONFIG = (): TTSInfo => ({
|
||||
|
||||
export const DEFAULT_TIME_CAPSULE_CONFIG = (): TimeCapsuleConfig => ({
|
||||
time_capsule_mode: 0,
|
||||
disable_prompt_calling: 0, // 默认支持在prompt调用
|
||||
disable_prompt_calling: 0, // Default support for prompt calls
|
||||
time_capsule_time_to_live: '0',
|
||||
});
|
||||
|
||||
|
||||
@@ -96,57 +96,57 @@ export const getDefaultBotSkillStore = (): BotSkillStore => ({
|
||||
devHooks: {},
|
||||
});
|
||||
|
||||
/** Persona & Prompt 区域 */
|
||||
/** Persona & Prompted Areas */
|
||||
export interface BotSkillStore {
|
||||
// region Bot 和 Agent 维度共有 skills
|
||||
/** 已选的 plugin api */
|
||||
// Region Bot and Agent dimension common skills
|
||||
/** Selected plugin api */
|
||||
pluginApis: EnabledPluginApi[];
|
||||
/** 已选 workflow */
|
||||
/** Selected workflow */
|
||||
workflows: WorkFlowItemType[];
|
||||
/** Knowledge 配置 */
|
||||
/** Knowledge Allocation */
|
||||
knowledge: KnowledgeConfig;
|
||||
// endregion
|
||||
|
||||
// region Bot 维度独有 skills
|
||||
// Region Bot Dimension Unique skills
|
||||
/**
|
||||
* task 配置
|
||||
* Task configuration
|
||||
*
|
||||
* 不含已添加的 task,已添加的在组件内独立管理
|
||||
* No added tasks are included, and those added are managed independently within the component
|
||||
*/
|
||||
taskInfo: TaskManageInfo;
|
||||
/**
|
||||
* variable 默认值配置
|
||||
* Variable default configuration
|
||||
*
|
||||
* 不含右上角现值,现值为打开弹窗后请求获得的组件状态
|
||||
* The present value in the upper right corner is not included. The present value is the component state requested after opening the pop-up window.
|
||||
*/
|
||||
variables: VariableItem[];
|
||||
/**
|
||||
* database 默认值配置
|
||||
* Database default configuration
|
||||
*
|
||||
* 不含右上角现值,现值为打开弹窗后请求获得的组件状态
|
||||
* The present value in the upper right corner is not included. The present value is the component state requested after opening the pop-up window.
|
||||
*/
|
||||
database: DatabaseInfo;
|
||||
/**
|
||||
* database 多表默认值配置
|
||||
* Database multi-table default configuration
|
||||
*
|
||||
* 不含右上角现值,现值为打开弹窗后请求获得的组件状态
|
||||
* The present value in the upper right corner is not included. The present value is the component state requested after opening the pop-up window.
|
||||
*/
|
||||
databaseList: DatabaseList;
|
||||
/** 开场白配置 */
|
||||
/** Opener configuration */
|
||||
onboardingContent: ExtendOnboardingContent;
|
||||
/** 用户问题建议配置 */
|
||||
/** User Questions Suggested Configuration */
|
||||
suggestionConfig: BotSuggestionConfig;
|
||||
// endregion
|
||||
/** 文字转语音 */
|
||||
/** Text to Speech */
|
||||
tts: TTSInfo;
|
||||
/** 语音设置 上面 tts 在命名和含义划分上已经不准确了 但是牵扯甚广 */
|
||||
/** Voice settings, the above tts are no longer accurate in naming and meaning division, but they are very involved */
|
||||
voicesInfo: VoicesInfo;
|
||||
// 时间胶囊
|
||||
// Time Capsule
|
||||
timeCapsule: TimeCapsuleConfig;
|
||||
filebox: FileboxConfig;
|
||||
// 聊天背景图
|
||||
// Chat background cover
|
||||
backgroundImageInfoList: BackgroundImageInfo[];
|
||||
// 快捷指令
|
||||
// Quick Instruction
|
||||
shortcut: ShortCutStruct;
|
||||
// hooks
|
||||
devHooks?: HookInfo;
|
||||
|
||||
@@ -74,7 +74,7 @@ import {
|
||||
DEFAULT_TTS_CONFIG,
|
||||
} from './defaults';
|
||||
|
||||
// 结构化 BotInfo 接口后的 数据转换
|
||||
// After the structured BotInfo interface, data transformation
|
||||
export const transformDto2Vo = {
|
||||
plugin: (
|
||||
data?: PluginInfo[],
|
||||
@@ -96,12 +96,12 @@ export const transformDto2Vo = {
|
||||
parameters:
|
||||
api?.parameters?.map(i => ({
|
||||
...i,
|
||||
// 兼容开源页接口字段命名不同
|
||||
// Compatible with open-source pages. Interface fields are named differently
|
||||
desc: i.description,
|
||||
required: i.is_required,
|
||||
})) || [],
|
||||
is_official: plugin?.is_official,
|
||||
// 这个类型历史原因 在服务端侧各服务不统一,实际业务使用为 枚举类型
|
||||
// The historical reason for this type is that each service on the server level is not unified, and the actual business use is the enumeration type
|
||||
plugin_type: plugin?.plugin_type as unknown as PluginType,
|
||||
status: plugin?.plugin_status as unknown as PluginStatus,
|
||||
};
|
||||
@@ -130,7 +130,7 @@ export const transformDto2Vo = {
|
||||
})) || [],
|
||||
};
|
||||
}) ?? [],
|
||||
// 知识库
|
||||
// Knowledge Base
|
||||
knowledge: (
|
||||
data?: Knowledge,
|
||||
config?: Record<string, KnowledgeDetail>,
|
||||
@@ -212,7 +212,7 @@ export const transformDto2Vo = {
|
||||
i => ({
|
||||
...i,
|
||||
nanoid: nanoid(),
|
||||
// 服务端 rpc 已使用 string 的 id 难以修改,这里兼容一下后续链路需要的 number
|
||||
// Server level rpc has used the id of the string, which is difficult to modify. Here is compatible with the number required for subsequent links.
|
||||
id: Number(i.id),
|
||||
}),
|
||||
),
|
||||
@@ -224,7 +224,7 @@ export const transformDto2Vo = {
|
||||
},
|
||||
|
||||
timeCapsule: (data?: TimeCapsuleInfo): TimeCapsuleConfig => ({
|
||||
//@ts-expect-error 接口枚举类型取值重定义
|
||||
// @ts-expect-error interface enumeration type value redefinition
|
||||
time_capsule_mode: data?.time_capsule_mode ?? TimeCapsuleMode.Off,
|
||||
disable_prompt_calling:
|
||||
data?.disable_prompt_calling ?? DisablePromptCalling.Off,
|
||||
@@ -253,7 +253,7 @@ export const transformDto2Vo = {
|
||||
const defaultSuggestionConfig: BotSuggestionConfig = isBotNode
|
||||
? DEFAULT_BOT_NODE_SUGGESTION_CONFIG()
|
||||
: DEFAULT_SUGGESTION_CONFIG();
|
||||
//@ts-expect-error xxxxxxxxxxxxx SuggestReplyMode 两个文件定义不一致
|
||||
// @ts-expect-error xxxxxxxxxxx SuggestReplyMode The two file definitions are inconsistent
|
||||
const suggestionConfig: BotSuggestionConfig = isNumber(
|
||||
data?.suggest_reply_mode,
|
||||
)
|
||||
@@ -301,7 +301,7 @@ export const transformDto2Vo = {
|
||||
config?: ShortcutCommand[],
|
||||
): ShortCutStruct => ({
|
||||
shortcut_sort: shortcutSortList,
|
||||
//@ts-expect-error ShortCutCommand 前后端定义不一致,前端分化做了类型约束
|
||||
// @ts-expect-error ShortCutCommand The definition of the front and back ends is inconsistent, and the front-end differentiation is subject to type constraints
|
||||
shortcut_list: config,
|
||||
}),
|
||||
|
||||
@@ -427,6 +427,6 @@ export const transformVo2Dto = {
|
||||
shortcut.shortcut_sort,
|
||||
|
||||
layoutInfo: (info: LayoutInfo): BotInfoForUpdate['layout_info'] =>
|
||||
// undefined 会被 axios 过滤,这里后端需要有 key
|
||||
// Undefined will be filtered by axios, where the backend needs to have a key.
|
||||
mapValues(info, (val?: string) => val ?? ''),
|
||||
};
|
||||
|
||||
@@ -42,13 +42,13 @@ export const collaborateQuota = async () => {
|
||||
bot_id: botId,
|
||||
});
|
||||
setCollaboration({
|
||||
// 多人协作模式,或非多人协作模式有额度时可启用
|
||||
// Multiplayer collaboration mode, or non-multiplayer collaboration mode can be enabled when there is a quota
|
||||
openCollaboratorsEnable:
|
||||
(!inCollaboration && collaborationQuota?.open_collaborators_enable) ||
|
||||
inCollaboration,
|
||||
// 非多人协作模式 && 可以升级套餐,则展示升级套餐按钮
|
||||
// Non-multiplayer collaboration mode & & If the package can be upgraded, the upgrade package button will be displayed.
|
||||
canUpgrade: collaborationQuota?.can_upgrade || false,
|
||||
// 用户最大开启多人协作bot的数量限制
|
||||
// Limit on the maximum number of user-enabled multiplayer collaborative bots
|
||||
maxCollaborationBotCount:
|
||||
collaborationQuota?.max_collaboration_bot_count || 0,
|
||||
maxCollaboratorsCount: collaborationQuota?.max_collaborators_count || 0,
|
||||
|
||||
@@ -49,33 +49,33 @@ export const getDefaultCollaborationStore = (): CollaborationStore => ({
|
||||
maxCollaboratorsCount: 0,
|
||||
});
|
||||
export enum EditLockStatus {
|
||||
Lose, // 无编辑锁
|
||||
Holder, // 有编辑锁
|
||||
Offline, // 断网状态,可编辑,但是不可保存。避免联网后覆盖掉断网期间其他页面的编辑
|
||||
Lose, // No edit lock
|
||||
Holder, // There is edit lock.
|
||||
Offline, // The network disconnection status can be edited, but cannot be saved. Avoid overwriting the editing of other pages during the disconnection period after networking.
|
||||
}
|
||||
/**多人协作*/
|
||||
/**multiplayer collaboration*/
|
||||
export interface CollaborationStore {
|
||||
editLockStatus: EditLockStatus;
|
||||
inCollaboration: boolean;
|
||||
collaboratorStatus: BotCollaboratorStatus;
|
||||
sameWithOnline: boolean;
|
||||
baseVersion: string;
|
||||
/** for前端,最近一次的提交人 */
|
||||
/** For the front end, the most recent author */
|
||||
committer_name: string;
|
||||
/** 获取的是什么分支的内容 */
|
||||
/** What branch did you get the content of? */
|
||||
branch?: Branch;
|
||||
/** for前端,提交时间 */
|
||||
/** For frontend, commit time */
|
||||
commit_time: string;
|
||||
commit_version: string;
|
||||
/** 能否开启协作开关 false不可开启 */
|
||||
/** Can it be turned on? The cooperation switch is false and cannot be turned on. */
|
||||
openCollaboratorsEnable: boolean;
|
||||
/** 是否可升级套餐 顶级付费账号不可升级 */
|
||||
/** Whether the package can be upgraded, the top paid account cannot be upgraded */
|
||||
canUpgrade: boolean;
|
||||
// 当前开启的协作bot数量
|
||||
// The current number of active collaboration bots
|
||||
currentCollaborationBotCount: number;
|
||||
/** 用户最大开启多人协作bot的数量限制 */
|
||||
/** Limit on the maximum number of user-enabled multiplayer collaborative bots */
|
||||
maxCollaborationBotCount: number;
|
||||
/** 协作者数量上限 */
|
||||
/** maximum number of collaborators */
|
||||
maxCollaboratorsCount: number;
|
||||
}
|
||||
|
||||
@@ -100,7 +100,7 @@ export const useCollaborationStore = create<
|
||||
set(produce<CollaborationStore>(state => update(state))),
|
||||
getBaseVersion: () => {
|
||||
const { baseVersion, inCollaboration } = get();
|
||||
// FG开启且单人模式下,不提供 base_version
|
||||
// FG is on and in single mode, no base_version is provided
|
||||
if (!inCollaboration) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
@@ -36,15 +36,15 @@ export const getDefaultDiffTaskStore = (): DiffTaskStore => ({
|
||||
},
|
||||
});
|
||||
|
||||
/** diff任务相关信息 */
|
||||
/** Diff task related information */
|
||||
export interface DiffTaskStore {
|
||||
/** 当前diff任务类型 */
|
||||
/** Current diff task type */
|
||||
diffTask: DiffTaskType;
|
||||
/** 是否有继续任务 */
|
||||
/** Is there a continuation mission? */
|
||||
hasContinueTask: boolean;
|
||||
/** 继续任务信息 */
|
||||
/** Continue task information */
|
||||
continueTask: DiffTaskType;
|
||||
/** 当前diff任务信息 */
|
||||
/** Current diff task information */
|
||||
promptDiffInfo: {
|
||||
diffPromptResourceId: string;
|
||||
diffPrompt: string;
|
||||
|
||||
@@ -15,15 +15,15 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* 用来满足一个神奇的功能
|
||||
* multi agent 模式下 正在回复中
|
||||
* 用户手动切换了 agent
|
||||
* 基于新的 agent 重新生成对话
|
||||
* 需要记录 agent 的切换是「手动」|「自动」
|
||||
* To fulfill a miraculous function
|
||||
* In multi agent mode, replying.
|
||||
* The user switched agents manually
|
||||
* Regenerate the conversation based on the new agent
|
||||
* It is necessary to record that the switch of the agent is "manual" | "automatic"
|
||||
*/
|
||||
|
||||
/**
|
||||
* !! 不和 Bot Detail 搅合在一起了。
|
||||
* !! Not mixed with Bot Details.
|
||||
*/
|
||||
|
||||
import { devtools } from 'zustand/middleware';
|
||||
|
||||
@@ -64,10 +64,10 @@ export const getDefaultModelStore = (): ModelStore => ({
|
||||
modelList: [],
|
||||
});
|
||||
|
||||
/** Persona & Prompt 区域 */
|
||||
/** Persona & Prompted Areas */
|
||||
export interface ModelStore {
|
||||
config: ModelInfoConfig;
|
||||
/** 全部可选模型 */
|
||||
/** All optional models */
|
||||
modelList: Model[];
|
||||
}
|
||||
|
||||
|
||||
@@ -23,11 +23,11 @@ import {
|
||||
} from '@coze-arch/idl/benefit';
|
||||
|
||||
export interface MonetizeConfigState {
|
||||
/** 是否开启付费 */
|
||||
/** Whether to start payment */
|
||||
isOn: boolean;
|
||||
/** 开启付费后,用户免费体验的次数 */
|
||||
/** The number of free user experiences after starting payment */
|
||||
freeCount: number;
|
||||
/** 刷新周期 */
|
||||
/** refresh cycle */
|
||||
refreshCycle: BotMonetizationRefreshPeriod;
|
||||
}
|
||||
|
||||
|
||||
@@ -68,16 +68,16 @@ export interface MultiAgentStore {
|
||||
agents: Agent[];
|
||||
edges: WorkflowEdgeJSON[];
|
||||
connector_type: LineType;
|
||||
/** 用于保存 bot 类型节点的 bot 信息 */
|
||||
/** Use to save bot information for bot type nodes */
|
||||
botAgentInfos: DraftBotVo[];
|
||||
/**
|
||||
* 会话接管方式配置
|
||||
* 默认为 flow 模式
|
||||
* Session takeover configuration
|
||||
* Default to flow mode
|
||||
*/
|
||||
chatModeConfig: ChatModeConfig;
|
||||
/** 当前agent id **/
|
||||
/** Current agent id **/
|
||||
currentAgentID: string;
|
||||
/**muti 左右展开状态**/
|
||||
/**Muti left and right expanded state **/
|
||||
multiSheetViewOpen: MultiSheetViewOpenState;
|
||||
}
|
||||
|
||||
@@ -102,12 +102,12 @@ export interface MultiAgentAction {
|
||||
setMultiAgentByImmer: (update: (state: MultiAgentStore) => void) => void;
|
||||
setMultiSheetViewOpen: (state: Partial<MultiSheetViewOpenState>) => void;
|
||||
updatedCurrentAgentIdWithConnectStart: () => void;
|
||||
/** 重置 host 节点为 start 相连的节点 */
|
||||
/** Reset host node to start connected node */
|
||||
resetHostAgent: () => void;
|
||||
/**
|
||||
* 设置sourceAgentId的portId的intent的next_agent_id为nextAgentId
|
||||
* Set the intent of sourceAgentId's portId to next_agent_id nextAgentId
|
||||
*
|
||||
* @deprecated 这是旧版画布的方法,新版为 addAgentIntent
|
||||
* @Deprecated This is the method of the old canvas, the new version is addAgentIntent
|
||||
*/
|
||||
setAgentIntentNextID: (
|
||||
sourceAgentId?: string,
|
||||
@@ -117,8 +117,8 @@ export interface MultiAgentAction {
|
||||
addAgentIntent: (sourceAgentId: string, targetAgentId: string) => void;
|
||||
deleteAgentIntent: (sourceAgentId: string, targetAgentId: string) => void;
|
||||
/**
|
||||
* 根据agentId找到当前agent的source的agent,也就是上游agent
|
||||
* 将上游agent中找到某个intent,next_agent_id === agentId。将该intent的next_agent_id清空
|
||||
* The agent that finds the source of the current agent according to the agentId, that is, the upstream agent
|
||||
* Find an intent in the upstream agent, next_agent_id === agentId. Clear the next_agent_id of the intent
|
||||
*/
|
||||
clearEdgesByTargetAgentId: (agentId?: string) => void;
|
||||
updateAgentSkillKnowledgeDatasetInfo: (
|
||||
@@ -137,13 +137,13 @@ export interface MultiAgentAction {
|
||||
/** @default AgentType.LLM_Agent */
|
||||
type?: AgentType;
|
||||
position?: IPoint;
|
||||
/** 是否使用struct版本 - 便于写单测即将删除*/
|
||||
/** Whether to use the struct version - easy to write single test will be deleted soon*/
|
||||
structFlag?: boolean;
|
||||
}) => Promise<Agent | undefined>;
|
||||
batchAddBotAgent: (config: {
|
||||
bots: AgentReferenceInfo[];
|
||||
positions: IPoint[];
|
||||
/** 是否使用struct版本 - 便于写单测即将删除*/
|
||||
/** Whether to use the struct version - easy to write single test will be deleted soon*/
|
||||
structFlag?: boolean;
|
||||
}) => Promise<Agent[]>;
|
||||
updateBotNodeInfo: (
|
||||
@@ -156,16 +156,16 @@ export interface MultiAgentAction {
|
||||
apiId?: string,
|
||||
) => void;
|
||||
/**
|
||||
* 清除一条 intent 的 next_id(也就是 edge)
|
||||
* Clears the next_id of an intent (i.e. edge)
|
||||
*
|
||||
* - Q1:为什么不直接使用 intent id 来找 intent?
|
||||
* - A1:将一条已有的连线拖拽连接到另一个节点时,SDK 会先触发这个 intent 的 addEdge 事件,随后再触发 deleteEdge 事件。
|
||||
* 导致 deleteEdge 事件会通过 intent id 覆盖 addEdge 刚刚更新过的 intent。
|
||||
* - Q1: Why not use the intent id directly to find the intent?
|
||||
* A1: When dragging and dropping an existing connection to another node, the SDK fires the addEdge event for that intent first, followed by the deleteEdge event.
|
||||
* Causes the deleteEdge event to overwrite the newly updated intent of addEdge with the intent id.
|
||||
*
|
||||
* - Q2:那通过 targetAgentId 来找 intent 不够吗,为什么还需要 intent id?
|
||||
* - A2:当同一个节点的两个 intent 都指向同一个目标,这时删除其中一条连线,无法确定删除的是哪条,必须配合 intent id 来判断
|
||||
* - Q2: Is it not enough to find the intent by the target AgentId, why do you need the intent id?
|
||||
* - A2: When both intents of the same node point to the same target, one of the connections is deleted. It is impossible to determine which one is deleted. It must be judged with the intent id.
|
||||
*
|
||||
* @deprecated 旧版画布的方法,新版为 deleteAgentIntent
|
||||
* @Deprecated the method of the old canvas, the new version is deleteAgentIntent
|
||||
*/
|
||||
clearIntentNextId: (
|
||||
sourceAgentId: string,
|
||||
@@ -321,7 +321,7 @@ export const useMultiAgentStore = create<MultiAgentStore & MultiAgentAction>()(
|
||||
if (sourceAgent) {
|
||||
const { intents } = sourceAgent;
|
||||
|
||||
// 执行第一步指令。将上游agent的next_agent_id清空
|
||||
// Execute the first step instruction. Clear the upstream agent's next_agent_id
|
||||
intents?.forEach(item => {
|
||||
if (item.next_agent_id === targetAgentId) {
|
||||
item.next_agent_id = undefined;
|
||||
@@ -554,9 +554,9 @@ export const useMultiAgentStore = create<MultiAgentStore & MultiAgentAction>()(
|
||||
);
|
||||
const isMultiAgent = botInfo?.bot_mode === BotMode.MultiMode;
|
||||
if (isMultiAgent) {
|
||||
// 设置初始的对话agent id
|
||||
// Set the initial conversation agent id
|
||||
updatedCurrentAgentIdWithConnectStart();
|
||||
// 获取agent节点为子bot的子bot信息,并赋值入store
|
||||
// Get the information of the sub-bot whose agent node is a child bot, and assign it to the store.
|
||||
updateBotNodeInfo(botInfo?.agents || []);
|
||||
}
|
||||
},
|
||||
|
||||
@@ -76,7 +76,7 @@ export const transformDto2Vo = {
|
||||
model,
|
||||
prompt,
|
||||
description: data?.description || DEFAULT_AGENT_DESCRIPTION(),
|
||||
// 默认的业务状态bizInfo
|
||||
// Default business state bizInfo
|
||||
bizInfo: DEFAULT_AGENT_BIZ_INFO(),
|
||||
system_info_all: [],
|
||||
skills: {
|
||||
@@ -188,7 +188,7 @@ export const transformVo2Dto = {
|
||||
|
||||
current_version:
|
||||
targetAgent.update_type === ReferenceUpdateType.AutoUpdate
|
||||
? // 如果当前agent是自动更新,则将current_version置为"0"
|
||||
? // If the current agent is automatically updated, set the current_version to "0"
|
||||
'0'
|
||||
: targetAgent.current_version,
|
||||
};
|
||||
|
||||
@@ -60,28 +60,28 @@ export const getDefaultPageRuntimeStore = (): PageRuntime => ({
|
||||
hasUnpublishChange: false,
|
||||
});
|
||||
|
||||
// bot的编辑器状态控制
|
||||
// Editor state control for bot
|
||||
export interface PageRuntime {
|
||||
/** 初始化 **/
|
||||
/** Initialization **/
|
||||
init: boolean;
|
||||
/** 当前用户是否是bot的创建者 **/
|
||||
/** Is the current user the creator of the bot?*/
|
||||
isSelf: boolean;
|
||||
/** 是否是预览状态isPreview = typeof version !== 'undefined'; **/
|
||||
/** Is it preview status isPreview = typeof version! == 'undefined'; **/
|
||||
isPreview: boolean;
|
||||
/** 服务端透传 **/
|
||||
/** Server level passthrough **/
|
||||
editable: boolean;
|
||||
/**控制bot 历史版本展示 **/
|
||||
/**Control bot history version display **/
|
||||
historyVisible?: boolean;
|
||||
|
||||
/** 记录用户主动展开/收起bot能力模块的状态 **/
|
||||
/** Record the status of the user actively expanding/retracting the bot capability module **/
|
||||
botSkillBlockCollapsibleState: TabDisplayItems;
|
||||
/** 页面来源 **/
|
||||
/** Page Source **/
|
||||
pageFrom?: BotPageFromEnum;
|
||||
/** 保存信息 **/
|
||||
/** Save information **/
|
||||
savingInfo: SavingInfo;
|
||||
/** 划词插件id, 一个chat-area一个 **/
|
||||
/** Dashword plugin id, one chat-area one **/
|
||||
grabPluginId: string;
|
||||
/** 是否有未发布的修改, header头部展示**/
|
||||
/** Are there any unpublished changes, header display **/
|
||||
hasUnpublishChange: boolean;
|
||||
}
|
||||
|
||||
@@ -108,8 +108,8 @@ export const usePageRuntimeStore = create<PageRuntime & PageRuntimeAction>()(
|
||||
set(produce<PageRuntime>(state => update(state))),
|
||||
|
||||
/**
|
||||
* 获取用户主动展开/收起bot能力模块的状态
|
||||
* ⚠️ 仅在首次打开本人 bot 编辑页时调用
|
||||
* Get the status of the user's active expand/collapse bot capability module
|
||||
* ⚠️ Called only when opening my bot edit page for the first time
|
||||
* @see
|
||||
*/
|
||||
getBotSkillBlockCollapsibleState: async () => {
|
||||
@@ -136,8 +136,8 @@ export const usePageRuntimeStore = create<PageRuntime & PageRuntimeAction>()(
|
||||
}
|
||||
},
|
||||
/**
|
||||
* 存储用户主动展开/收起bot能力模块的状态
|
||||
* ⚠️ 仅限主动操作时记录
|
||||
* Stores the status of the user's active expand/retract bot capability module
|
||||
* ⚠️ Only record when active
|
||||
* @see
|
||||
*/
|
||||
setBotSkillBlockCollapsibleState: (
|
||||
@@ -145,7 +145,7 @@ export const usePageRuntimeStore = create<PageRuntime & PageRuntimeAction>()(
|
||||
disableUpdateService?: boolean,
|
||||
) => {
|
||||
if (size($params) > 0) {
|
||||
// 记录到本地状态机
|
||||
// Record to local finite-state machine
|
||||
set({
|
||||
...get(),
|
||||
botSkillBlockCollapsibleState: {
|
||||
@@ -158,7 +158,7 @@ export const usePageRuntimeStore = create<PageRuntime & PageRuntimeAction>()(
|
||||
return;
|
||||
}
|
||||
|
||||
// 同步到服务端
|
||||
// Synchronize to server level
|
||||
DeveloperApi.UpdateDraftBotDisplayInfo({
|
||||
bot_id: useBotInfoStore.getState().botId,
|
||||
display_info: { tab_display_info: $params },
|
||||
|
||||
@@ -47,7 +47,7 @@ export interface RequiredBotPrompt extends BotPrompt {
|
||||
record_id?: string;
|
||||
}
|
||||
|
||||
/** Persona & Prompt 区域 */
|
||||
/** Persona & Prompted Areas */
|
||||
export interface PersonaStore {
|
||||
systemMessage: RequiredBotPrompt;
|
||||
optimizePrompt: string;
|
||||
|
||||
@@ -30,20 +30,20 @@ import type {
|
||||
import type { BotDetailSkill, BotSuggestionConfig } from './skill';
|
||||
import type { RequiredBotPrompt } from './persona';
|
||||
|
||||
/** multi agent 相关数据 */
|
||||
/** Multi agent related data */
|
||||
export interface BotMultiAgent {
|
||||
agents: Agent[];
|
||||
edges: WorkflowEdgeJSON[];
|
||||
connector_type: LineType;
|
||||
/** 用于保存 bot 类型节点的 bot 信息 */
|
||||
/** Use to save bot information for bot type nodes */
|
||||
botAgentInfos: DraftBotVo[];
|
||||
/**
|
||||
* 会话接管方式配置
|
||||
* 默认为 flow 模式
|
||||
* Session takeover configuration
|
||||
* Default to flow mode
|
||||
*/
|
||||
chatModeConfig: ChatModeConfig;
|
||||
}
|
||||
/** 业务用到的 */
|
||||
/** For business use */
|
||||
export interface AgentBizInfo {
|
||||
focused?: boolean;
|
||||
}
|
||||
@@ -61,7 +61,7 @@ export type Agent = PartialRequired<Omit<AgentInfo, 'work_info'>, 'id'> & {
|
||||
suggestion: BotSuggestionConfig;
|
||||
};
|
||||
|
||||
/** api 返回的 bot 信息中,部分字段是 json,本类型是 parse 后的类型 */
|
||||
/** In the bot information returned by the api, some fields are json, and this type is the parse type. */
|
||||
export type DraftBotVo = Omit<DraftBotApi, 'work_info'> & {
|
||||
work_info: {
|
||||
suggest_reply: BotSuggestionConfig;
|
||||
@@ -70,13 +70,13 @@ export type DraftBotVo = Omit<DraftBotApi, 'work_info'> & {
|
||||
|
||||
export type ChatModeConfig =
|
||||
| {
|
||||
/** 会话接管方式 */
|
||||
/** Session takeover */
|
||||
type: MultiAgentSessionType.Flow;
|
||||
}
|
||||
| {
|
||||
/** 会话接管方式 */
|
||||
/** Session takeover */
|
||||
type: MultiAgentSessionType.Host;
|
||||
/** 当前的 host 节点 id */
|
||||
/** Current host node id */
|
||||
currentHostId: string;
|
||||
};
|
||||
|
||||
|
||||
@@ -65,15 +65,15 @@ export interface GenerateBackGroundModal {
|
||||
};
|
||||
}
|
||||
|
||||
// 异步生成图片的状态
|
||||
// The state of generating images asynchronously
|
||||
export interface GenerateImageState {
|
||||
// 候选图列表信息
|
||||
// Candidate image list information
|
||||
imageList: PicTask[];
|
||||
// 生成图片消息信息
|
||||
// Generate image message information
|
||||
noticeList: TaskNotice[];
|
||||
// 头像弹窗内生成图片的状态
|
||||
// The status of generating pictures in the avatar pop-up window
|
||||
generateAvatarModal: GenerateAvatarModal;
|
||||
// 背景图弹窗内生成图片的状态
|
||||
// The status of the generated image in the background cover pop-up window
|
||||
generateBackGroundModal: GenerateBackGroundModal;
|
||||
}
|
||||
|
||||
|
||||
@@ -16,9 +16,9 @@
|
||||
|
||||
import type { Model, ModelInfo } from '@coze-arch/bot-api/developer_api';
|
||||
|
||||
/** 模型设置 */
|
||||
/** Model Settings */
|
||||
export interface BotDetailModel {
|
||||
config: ModelInfo;
|
||||
/** 全部可选模型 */
|
||||
/** All optional models */
|
||||
modelList: Model[];
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ import type {
|
||||
interface DefaultPluginApi extends PluginApi {
|
||||
isAuto?: boolean;
|
||||
autoAddCss?: boolean;
|
||||
// #region api所在的 plugin 维度字段
|
||||
// #The plugin dimension field where the region api is located
|
||||
plugin_type?: PluginType;
|
||||
is_official?: boolean;
|
||||
plugin_icon?: string;
|
||||
@@ -56,53 +56,53 @@ interface DefaultPluginApi extends PluginApi {
|
||||
export type EnabledPluginApi = Omit<DefaultPluginApi, 'debug_example'>;
|
||||
|
||||
export interface BotDetailSkill {
|
||||
// region Bot 和 Agent 维度共有 skills
|
||||
/** 已选的 plugin api */
|
||||
// Region Bot and Agent dimension common skills
|
||||
/** Selected plugin api */
|
||||
pluginApis: EnabledPluginApi[];
|
||||
/** 已选 workflow */
|
||||
/** Selected workflow */
|
||||
workflows: WorkFlowItemType[];
|
||||
/** Knowledge 配置 */
|
||||
/** Knowledge Allocation */
|
||||
knowledge: KnowledgeConfig;
|
||||
// endregion
|
||||
|
||||
// region Bot 维度独有 skills
|
||||
// Region Bot Dimension Unique skills
|
||||
/**
|
||||
* task 配置
|
||||
* Task configuration
|
||||
*
|
||||
* 不含已添加的 task,已添加的在组件内独立管理
|
||||
* No added tasks are included, and those added are managed independently within the component
|
||||
*/
|
||||
taskInfo: TaskManageInfo;
|
||||
/**
|
||||
* variable 默认值配置
|
||||
* Variable default configuration
|
||||
*
|
||||
* 不含右上角现值,现值为打开弹窗后请求获得的组件状态
|
||||
* The present value in the upper right corner is not included. The present value is the component state requested after opening the pop-up window.
|
||||
*/
|
||||
variables: VariableItem[];
|
||||
/**
|
||||
* database 默认值配置
|
||||
* Database default configuration
|
||||
*
|
||||
* 不含右上角现值,现值为打开弹窗后请求获得的组件状态
|
||||
* The present value in the upper right corner is not included. The present value is the component state requested after opening the pop-up window.
|
||||
*/
|
||||
database: DatabaseInfo;
|
||||
/**
|
||||
* database 多表默认值配置
|
||||
* Database multi-table default configuration
|
||||
*
|
||||
* 不含右上角现值,现值为打开弹窗后请求获得的组件状态
|
||||
* The present value in the upper right corner is not included. The present value is the component state requested after opening the pop-up window.
|
||||
*/
|
||||
databaseList: DatabaseList;
|
||||
/** 开场白配置 */
|
||||
/** Opener configuration */
|
||||
onboardingContent: ExtendOnboardingContent;
|
||||
/** 用户问题建议配置 */
|
||||
/** User Questions Suggested Configuration */
|
||||
suggestionConfig: BotSuggestionConfig;
|
||||
// endregion
|
||||
/** 文字转语音 */
|
||||
/** Text to Speech */
|
||||
tts: TTSInfo;
|
||||
// 时间胶囊
|
||||
// Time Capsule
|
||||
timeCapsule: TimeCapsuleConfig;
|
||||
filebox: FileboxConfig;
|
||||
// 聊天背景图
|
||||
// Chat background cover
|
||||
backgroundImageInfoList: BackgroundImageInfo[];
|
||||
// 快捷指令
|
||||
// Quick Instruction
|
||||
shortcut: ShortCutStruct;
|
||||
// hooks
|
||||
devHooks?: HookInfo;
|
||||
@@ -111,19 +111,19 @@ export interface BotDetailSkill {
|
||||
|
||||
export interface TaskManageInfo {
|
||||
user_task_allowed: boolean;
|
||||
/** 请求task loading状态,业务使用 */
|
||||
/** Request task loading status, business usage */
|
||||
loading: boolean;
|
||||
/** task接口数据,业务使用 */
|
||||
/** Task interface data, business use */
|
||||
data: TaskInfoData[];
|
||||
/** 新版task接口数据,业务使用 */
|
||||
/** New task interface data for business use */
|
||||
task_list: TaskInfo[];
|
||||
}
|
||||
|
||||
export enum VariableKeyErrType {
|
||||
KEY_CHECK_PASS = 0, // 检查通过
|
||||
KEY_NAME_USED = 1, // 名称被占用
|
||||
KEY_CHECK_PASS = 0, // Check passed
|
||||
KEY_NAME_USED = 1, // Name is occupied
|
||||
|
||||
KEY_IS_NULL = 2, // 为空值
|
||||
KEY_IS_NULL = 2, // is null
|
||||
}
|
||||
|
||||
export interface TableMemoryItem extends FieldItem {
|
||||
@@ -131,8 +131,8 @@ export interface TableMemoryItem extends FieldItem {
|
||||
disableMustRequired?: boolean;
|
||||
nanoid?: string;
|
||||
/**
|
||||
* 是否是内置字段
|
||||
* @description 内置字段: 仅作展示用,用户不可修改,不可创建同名字段
|
||||
* Is it a built-in field?
|
||||
* @Description Built-in field: For display only, users cannot modify it, and fields with the same name cannot be created
|
||||
*/
|
||||
isSystemField?: boolean;
|
||||
}
|
||||
@@ -219,7 +219,7 @@ export interface WorkFlowItemType {
|
||||
}
|
||||
|
||||
export interface KnowledgeConfig {
|
||||
/** 已选的 knowledge */
|
||||
/** Selected knowledge */
|
||||
dataSetList: Array<Dataset>;
|
||||
dataSetInfo: {
|
||||
min_score: number;
|
||||
@@ -246,7 +246,7 @@ export interface ExtendOnboardingContent {
|
||||
}
|
||||
|
||||
export interface BotSuggestionConfig {
|
||||
/** 0 开启; 1 自定义; 2 关闭; 3 跟随 bot(仅 agentflow bot 节点) */
|
||||
/** 0 on; 1 custom; 2 off; 3 follow bot (agentflow bot nodes only) */
|
||||
suggest_reply_mode: SuggestReplyMode;
|
||||
customized_suggest_prompt: string;
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ class AvatarBackgroundWebSocket {
|
||||
});
|
||||
this.addWSEventListener();
|
||||
} catch (error) {
|
||||
// 重试一次
|
||||
// Try again.
|
||||
if (retry) {
|
||||
this.createConnection(false);
|
||||
}
|
||||
@@ -126,7 +126,7 @@ class AvatarBackgroundWebSocket {
|
||||
image: { dotStatus: backgroundStaticImageDotStatus },
|
||||
} = generateBackGroundModal;
|
||||
const { status } = task;
|
||||
// 收到消息后更新头像或背景
|
||||
// Update avatar or background after receiving message
|
||||
const updateState = (
|
||||
key: string,
|
||||
setImmer:
|
||||
@@ -141,7 +141,7 @@ class AvatarBackgroundWebSocket {
|
||||
? DotStatus.Success
|
||||
: DotStatus.Fail;
|
||||
} else {
|
||||
// 标为已读
|
||||
// Mark as read
|
||||
if (taskBotId !== '0') {
|
||||
PlaygroundApi.MarkReadNotice({
|
||||
bot_id: taskBotId,
|
||||
@@ -213,7 +213,7 @@ class AvatarBackgroundWebSocket {
|
||||
}
|
||||
|
||||
const getPluginServiceId = () => {
|
||||
// region/service_id映射
|
||||
// Region/service_id mapping
|
||||
const regionServiceIdMap = {
|
||||
boe: 16778137,
|
||||
cn: 33554636,
|
||||
@@ -230,7 +230,7 @@ export const avatarBackgroundWebSocket = new AvatarBackgroundWebSocket(
|
||||
);
|
||||
|
||||
export function initAvatarBackgroundWebSocket() {
|
||||
// 创建连接
|
||||
// Create connection
|
||||
setTimeout(() => {
|
||||
const {
|
||||
generateAvatarModal: {
|
||||
|
||||
@@ -52,7 +52,7 @@ export const findTargetAgent = (agents: Agent[], agentId?: string) => {
|
||||
return agents.find(item => item.id === agentId);
|
||||
};
|
||||
|
||||
/** 寻找某个agent,其中该agent的intent的next_agent_id是当前的agent id */
|
||||
/** Find an agent whose intent next_agent_id the current agent id. */
|
||||
export const findAgentByNextIntentID = (
|
||||
agents: Agent[],
|
||||
nextAgentID?: string,
|
||||
@@ -73,7 +73,7 @@ export const findTargetAgentIndex = (agents: Agent[], agentId?: string) => {
|
||||
};
|
||||
|
||||
/**
|
||||
* start 节点指向的节点 id
|
||||
* The node id pointed to by the start node
|
||||
*/
|
||||
export const findFirstAgentId = ({
|
||||
agents,
|
||||
|
||||
@@ -35,7 +35,7 @@ export const getInitBackgroundInfo = (
|
||||
) => {
|
||||
const { tasks = [] } = data;
|
||||
const { backgroundImageInfoList = [] } = useBotSkillStore.getState();
|
||||
// 当前渲染的背景图
|
||||
// Currently rendering background cover
|
||||
const uri =
|
||||
backgroundImageInfoList[0]?.mobile_background_image?.origin_image_uri;
|
||||
|
||||
@@ -51,7 +51,7 @@ export const getInitBackgroundInfo = (
|
||||
) as DotStatus;
|
||||
const gifDotStatus = getDotStatus(data, PicType.BackgroundGif) as DotStatus;
|
||||
|
||||
// 动图相关state
|
||||
// Graph related state
|
||||
state.gif.loading = backgroundGifList.some(
|
||||
item => item.status === GenPicStatus.Generating,
|
||||
);
|
||||
@@ -61,7 +61,7 @@ export const getInitBackgroundInfo = (
|
||||
|
||||
state.gif.dotStatus = gifDotStatus;
|
||||
const image = backgroundGifList.find(item => item.img_info?.ori_url);
|
||||
// 第一帧信息
|
||||
// first frame information
|
||||
if (image) {
|
||||
state.gif.image = {
|
||||
img_info: {
|
||||
@@ -71,7 +71,7 @@ export const getInitBackgroundInfo = (
|
||||
};
|
||||
}
|
||||
|
||||
// 静图相关state
|
||||
// Static graph correlation state
|
||||
state.image.loading = backgroundStaticList.some(
|
||||
item => item.status === GenPicStatus.Generating,
|
||||
);
|
||||
@@ -84,21 +84,21 @@ export const getInitBackgroundInfo = (
|
||||
tasks.find(item => item.type === PicType.BackgroundStatic) ?? {};
|
||||
const lastGifTask =
|
||||
tasks.find(item => item.type === PicType.BackgroundGif) ?? {};
|
||||
// 当前选中的图片: 生成成功的 展示 成功的那个图, 否则找 背景图一致的
|
||||
// Currently selected image: generate a successful display, the successful image, otherwise find the same background cover
|
||||
if (gifDotStatus === DotStatus.Success) {
|
||||
state.selectedImage = lastGifTask;
|
||||
} else if (imageDotStatus === DotStatus.Success) {
|
||||
state.selectedImage = lastImageTask;
|
||||
} else {
|
||||
// 手动上传的 找不到
|
||||
// Uploaded manually, can't find it.
|
||||
state.selectedImage =
|
||||
tasks.find(item => item.img_info?.tar_uri === uri) ?? {};
|
||||
}
|
||||
// 当前tab:只有在 仅gif在状态不为done时 在gif tab
|
||||
// Current tab: only if, only gif when the state is not done, in the gif tab
|
||||
if (gifDotStatus !== DotStatus.None) {
|
||||
state.activeKey = GenerateType.Gif;
|
||||
}
|
||||
// 当前正在生成的taskId
|
||||
// The taskId currently being generated
|
||||
if (
|
||||
gifDotStatus === DotStatus.Generating ||
|
||||
imageDotStatus === DotStatus.Generating
|
||||
|
||||
@@ -18,7 +18,7 @@ import { usePageRuntimeStore } from '../store/page-runtime';
|
||||
import { useCollaborationStore, EditLockStatus } from '../store/collaboration';
|
||||
|
||||
/**
|
||||
* 非响应式;参考 useBotDetailIsReadonly 方法
|
||||
* Non-responsive; reference useBotDetailIsReadonly method
|
||||
*/
|
||||
export function getBotDetailIsReadonly() {
|
||||
const pageRuntime = usePageRuntimeStore.getState();
|
||||
|
||||
@@ -24,7 +24,7 @@ import { saveDeleteAgents } from '../save-manager/manual-save/multi-agent';
|
||||
import { findTargetAgentIndex } from './find-agent';
|
||||
|
||||
/**
|
||||
* FG全量后,默认用结构化的新接口
|
||||
* After the full amount of FG, a structured new interface is used by default
|
||||
*/
|
||||
export const deleteAgent = async (agentId?: string) => {
|
||||
if (!agentId) {
|
||||
@@ -33,21 +33,21 @@ export const deleteAgent = async (agentId?: string) => {
|
||||
await saveDeleteAgents(agentId);
|
||||
useMultiAgentStore.getState().setMultiAgentByImmer(multiAgent => {
|
||||
const { agents } = multiAgent;
|
||||
// 找到要删除的位置
|
||||
// Find the location to delete
|
||||
const targetAgentIndex = findTargetAgentIndex(agents, agentId);
|
||||
if (targetAgentIndex < 0) {
|
||||
Toast.error(I18n.t('chatflow_error_delete_failed'));
|
||||
return;
|
||||
}
|
||||
// 删除当前的agent
|
||||
// Delete the current agent
|
||||
agents.splice(targetAgentIndex, 1);
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* 用户手动切换 chatting 节点
|
||||
* Users manually switch chatting nodes
|
||||
*
|
||||
* host 模式下会一并切换 host 节点
|
||||
* In host mode, the host node will be switched together.
|
||||
*/
|
||||
export const manuallySwitchAgent = (agentID: string) => {
|
||||
const { setMultiAgentByImmer } = useMultiAgentStore.getState();
|
||||
|
||||
@@ -19,7 +19,7 @@ import type { PluginApi } from '@coze-arch/bot-api/playground_api';
|
||||
|
||||
import { type EnabledPluginApi } from '../types/skill';
|
||||
|
||||
// 过滤 debug_example 字段 以免超出模型解析长度
|
||||
// Filter debug_example fields to avoid exceeding model resolution length
|
||||
export const getPluginApisFilterExample = (
|
||||
pluginApis: PluginApi[],
|
||||
): EnabledPluginApi[] => pluginApis.map(item => omit(item, 'debug_example'));
|
||||
|
||||
@@ -18,7 +18,7 @@ import { type create } from 'zustand';
|
||||
|
||||
export interface SetterAction<T> {
|
||||
/**
|
||||
* 增量更新
|
||||
* incremental update
|
||||
*
|
||||
* @example
|
||||
* // store.x: { a: 1, b: 2 }
|
||||
@@ -27,7 +27,7 @@ export interface SetterAction<T> {
|
||||
*/
|
||||
(state: Partial<T>): void;
|
||||
/**
|
||||
* 全量更新
|
||||
* full update
|
||||
*
|
||||
* @example
|
||||
* // store.x: { a: 1, b: 2 }
|
||||
|
||||
@@ -43,7 +43,7 @@ export const storageLocal = createStorage<Record<string, string | undefined>>(
|
||||
{},
|
||||
);
|
||||
|
||||
// NOTICE: 定制逻辑: baseVersion转从 bot_detail_store中获取
|
||||
// NOTICE: Custom logic: baseVersion to get from bot_detail_store
|
||||
export const storage = new Proxy(storageLocal, {
|
||||
get: (target, prop: string, receiver) => {
|
||||
if (prop === 'baseVersion') {
|
||||
|
||||
@@ -21,7 +21,7 @@ export const hasBraces = (str: string) => {
|
||||
const pattern = /{{/g;
|
||||
return pattern.test(str);
|
||||
};
|
||||
// 判断是所有环境还是 只是release 环境限制{{}} 并弹出toast提示
|
||||
// Determine whether it is all environments or just release the environment restriction {{}} and pop up the toast prompt
|
||||
export const verifyBracesAndToast = (str: string, isAll = false) => {
|
||||
if (isAll && hasBraces(str)) {
|
||||
UIToast.warning({
|
||||
|
||||
@@ -157,7 +157,7 @@ export const createPluginStore = (options: {
|
||||
|
||||
setUpdatedInfo({
|
||||
updated_api_names: res?.updated_api_names || [],
|
||||
created_api_names: res?.created_api_names || [], //暂时只判断新增的tool的mockset权限
|
||||
created_api_names: res?.created_api_names || [], //For the time being, only the mockset permission of the newly added tool is judged.
|
||||
});
|
||||
},
|
||||
init: async () => {
|
||||
@@ -185,7 +185,7 @@ export const createPluginStore = (options: {
|
||||
const user = data?.user;
|
||||
|
||||
/**
|
||||
* 有人占用 & 不是自己
|
||||
* Someone occupies & not themselves
|
||||
*/
|
||||
if (data?.Occupied && user && !user.self) {
|
||||
UIModal.info({
|
||||
|
||||
@@ -13,8 +13,8 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/* eslint-disable @coze-arch/no-batch-import-or-export -- 内部均为具名export */
|
||||
|
||||
/* eslint-disable @coze-arch/no-batch-import-or-export -- all internally named exports */
|
||||
export * from './auth';
|
||||
export * from './user';
|
||||
export * from './tool';
|
||||
|
||||
@@ -36,7 +36,7 @@ export const checkOutPluginContext = async (pluginId: string) => {
|
||||
const user = data?.user;
|
||||
|
||||
/**
|
||||
* 有人占用 & 不是自己
|
||||
* Someone occupies & not themselves
|
||||
*/
|
||||
if (data?.Occupied && user && !user.self) {
|
||||
UIModal.info({
|
||||
|
||||
Reference in New Issue
Block a user