refactor(core): 重命名 agent_output 为 task_output
- 删除 agent_output.ts,新增 task_output.ts - 更新工具导出、注册和描述映射 - 更新 build/plan agent 预设的工具列表 - 更新 task 工具中的相关引用
This commit is contained in:
+19
-19
@@ -1,5 +1,5 @@
|
||||
import { describe, it, expect, beforeEach, vi } from 'vitest';
|
||||
import { agentOutputTool } from '../../../../src/tools/task/agent_output.js';
|
||||
import { taskOutputTool } from '../../../../src/tools/task/task_output.js';
|
||||
import { getAgentManager, resetAgentManager } from '../../../../src/agent/manager.js';
|
||||
|
||||
// Mock AgentExecutor - 使用延迟执行让测试更可控
|
||||
@@ -17,7 +17,7 @@ vi.mock('../../../../src/agent/executor.js', () => ({
|
||||
})),
|
||||
}));
|
||||
|
||||
describe('agentOutputTool - Agent 输出工具', () => {
|
||||
describe('taskOutputTool - Task 输出工具', () => {
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
resetAgentManager();
|
||||
@@ -25,30 +25,30 @@ describe('agentOutputTool - Agent 输出工具', () => {
|
||||
|
||||
describe('工具定义', () => {
|
||||
it('有正确的名称', () => {
|
||||
expect(agentOutputTool.name).toBe('agent_output');
|
||||
expect(taskOutputTool.name).toBe('task_output');
|
||||
});
|
||||
|
||||
it('有正确的元数据', () => {
|
||||
expect(agentOutputTool.metadata.category).toBe('agent');
|
||||
expect(agentOutputTool.metadata.keywords).toContain('agent');
|
||||
expect(agentOutputTool.metadata.keywords).toContain('output');
|
||||
expect(agentOutputTool.metadata.keywords).toContain('background');
|
||||
expect(taskOutputTool.metadata.category).toBe('agent');
|
||||
expect(taskOutputTool.metadata.keywords).toContain('task');
|
||||
expect(taskOutputTool.metadata.keywords).toContain('output');
|
||||
expect(taskOutputTool.metadata.keywords).toContain('background');
|
||||
});
|
||||
|
||||
it('agent_id 参数是必须的', () => {
|
||||
expect(agentOutputTool.parameters.agent_id.required).toBe(true);
|
||||
it('task_id 参数是必须的', () => {
|
||||
expect(taskOutputTool.parameters.task_id.required).toBe(true);
|
||||
});
|
||||
|
||||
it('block 和 timeout 参数是可选的', () => {
|
||||
expect(agentOutputTool.parameters.block.required).toBe(false);
|
||||
expect(agentOutputTool.parameters.timeout.required).toBe(false);
|
||||
expect(taskOutputTool.parameters.block.required).toBe(false);
|
||||
expect(taskOutputTool.parameters.timeout.required).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('execute - 执行', () => {
|
||||
it('Agent 不存在时返回错误', async () => {
|
||||
const result = await agentOutputTool.execute({
|
||||
agent_id: 'non-existent-id',
|
||||
const result = await taskOutputTool.execute({
|
||||
task_id: 'non-existent-id',
|
||||
});
|
||||
|
||||
expect(result.success).toBe(false);
|
||||
@@ -77,8 +77,8 @@ describe('agentOutputTool - Agent 输出工具', () => {
|
||||
);
|
||||
|
||||
// 立即查询(不阻塞)
|
||||
const result = await agentOutputTool.execute({
|
||||
agent_id: agentId,
|
||||
const result = await taskOutputTool.execute({
|
||||
task_id: agentId,
|
||||
block: false,
|
||||
});
|
||||
|
||||
@@ -109,8 +109,8 @@ describe('agentOutputTool - Agent 输出工具', () => {
|
||||
);
|
||||
|
||||
// 使用阻塞模式等待
|
||||
const result = await agentOutputTool.execute({
|
||||
agent_id: agentId,
|
||||
const result = await taskOutputTool.execute({
|
||||
task_id: agentId,
|
||||
block: true,
|
||||
timeout: 5,
|
||||
});
|
||||
@@ -144,8 +144,8 @@ describe('agentOutputTool - Agent 输出工具', () => {
|
||||
// 等待完成
|
||||
await new Promise((r) => setTimeout(r, 200));
|
||||
|
||||
const result = await agentOutputTool.execute({
|
||||
agent_id: agentId,
|
||||
const result = await taskOutputTool.execute({
|
||||
task_id: agentId,
|
||||
block: false,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user