71 lines
2.2 KiB
TypeScript
71 lines
2.2 KiB
TypeScript
import { describe, it, expect } from 'vitest';
|
|
import { AgentConfigRegistry, type AgentConfig } from './registry.js';
|
|
|
|
describe('AgentConfigRegistry', () => {
|
|
describe('register()', () => {
|
|
it('registers a named agent config', () => {
|
|
const registry = new AgentConfigRegistry();
|
|
const config: AgentConfig = { name: 'assistant', systemPrompt: 'Be helpful.' };
|
|
registry.register(config);
|
|
|
|
expect(registry.get('assistant')).toEqual(config);
|
|
});
|
|
|
|
it('throws on duplicate name', () => {
|
|
const registry = new AgentConfigRegistry();
|
|
registry.register({ name: 'assistant' });
|
|
expect(() => registry.register({ name: 'assistant' })).toThrow('already registered');
|
|
});
|
|
});
|
|
|
|
describe('get()', () => {
|
|
it('returns undefined for unknown name', () => {
|
|
const registry = new AgentConfigRegistry();
|
|
expect(registry.get('nonexistent')).toBeUndefined();
|
|
});
|
|
});
|
|
|
|
describe('list()', () => {
|
|
it('returns all registered configs', () => {
|
|
const registry = new AgentConfigRegistry();
|
|
registry.register({ name: 'a' });
|
|
registry.register({ name: 'b' });
|
|
expect(registry.list().map(c => c.name).sort()).toEqual(['a', 'b']);
|
|
});
|
|
});
|
|
|
|
describe('loadFromConfig()', () => {
|
|
it('loads configs from a raw config object', () => {
|
|
const registry = new AgentConfigRegistry();
|
|
registry.loadFromConfig({
|
|
assistant: {
|
|
system_prompt: 'Be helpful.',
|
|
model_tier: 'default',
|
|
tool_profile: 'messaging',
|
|
sandbox: false,
|
|
},
|
|
coder: {
|
|
model_tier: 'complex',
|
|
tool_profile: 'coding',
|
|
sandbox: true,
|
|
},
|
|
});
|
|
|
|
expect(registry.list()).toHaveLength(2);
|
|
const assistant = registry.get('assistant');
|
|
if (!assistant) {
|
|
throw new Error('Expected assistant config');
|
|
}
|
|
expect(assistant.systemPrompt).toBe('Be helpful.');
|
|
expect(assistant.modelTier).toBe('default');
|
|
expect(assistant.toolProfile).toBe('messaging');
|
|
|
|
const coder = registry.get('coder');
|
|
if (!coder) {
|
|
throw new Error('Expected coder config');
|
|
}
|
|
expect(coder.sandbox).toBe(true);
|
|
});
|
|
});
|
|
});
|