🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.
TypeScript agentagent-collaborationagent-harnessloop-engineeringmcppersonal-assistantproactive-agentskillssuper-agenttask-management
import { describe, expect, it } from 'vitest';
import {
buildGoalAgents,
buildGoalCreateInput,
buildReviewedGoalContent,
deriveInitialGoalCriterionTitle,
} from './goalConfig';
describe('deriveInitialGoalCriterionTitle', () => {
it('uses the instruction when a free-form goal has no dedicated requirement', () => {
expect(deriveInitialGoalCriterionTitle(' ship the quarterly report ')).toBe(
'ship the quarterly report',
);
});
it('prefers a seeded requirement when one is available', () => {
expect(
deriveInitialGoalCriterionTitle('ship the quarterly report', ' include all source links '),
).toBe('include all source links');
});
});
describe('buildGoalCreateInput', () => {
it('never sets a graph-wide round cap', () => {
// The modal's only iteration field means "attempts on one Task". `maxRounds`
// counts runs across every Task in the graph, so deriving it from that field
// stranded the fourth task of a goal whose limit was three attempts.
expect(buildGoalCreateInput({ instruction: 'ship it' })).not.toHaveProperty('maxRounds');
});
it('writes a positive cost budget', () => {
expect(buildGoalCreateInput({ costBudget: 2.5, instruction: 'x' }).maxTotalCost).toBe(2.5);
});
it('maps a blank or non-positive cost budget to uncapped (null)', () => {
// The coordinator reads `null` as "no cap"; an empty or 0 input must not
// become a 0-dollar budget that would stop the goal before its first run.
expect(buildGoalCreateInput({ instruction: 'x' }).maxTotalCost).toBeNull();
expect(buildGoalCreateInput({ costBudget: 0, instruction: 'x' }).maxTotalCost).toBeNull();
expect(buildGoalCreateInput({ costBudget: -3, instruction: 'x' }).maxTotalCost).toBeNull();
});
it('falls back to the instruction when no requirement was drafted', () => {
expect(buildGoalCreateInput({ instruction: ' ship it ' }).requirement).toBe('ship it');
expect(
buildGoalCreateInput({ instruction: 'ship it', requirement: ' all links resolve ' })
.requirement,
).toBe('all links resolve');
});
});
describe('buildReviewedGoalContent', () => {
it('uses the reviewed instruction verbatim as the goal document and planning context', () => {
const instruction =
'创建、读取、修改并导出可继续编辑的 PPT、XLSX 和 Word;保留中文和原有格式。';
expect(buildReviewedGoalContent(instruction)).toEqual({
problemDescription: instruction,
requirement: instruction,
});
});
});
describe('buildGoalAgents', () => {
it('routes Tasks to a dedicated executor', () => {
expect(buildGoalAgents('agt_plan', 'agt_exec')).toEqual({
agentId: 'agt_plan',
taskAgentId: 'agt_exec',
});
});
it('leaves Tasks with the main agent when no other executor is picked', () => {
expect(buildGoalAgents('agt_plan')).toEqual({ agentId: 'agt_plan', taskAgentId: undefined });
expect(buildGoalAgents('agt_plan', 'agt_plan')).toEqual({
agentId: 'agt_plan',
taskAgentId: undefined,
});
});
});