feat(core, ui): Add /agents refresh command. (#16204)

This commit is contained in:
joshualitt
2026-01-09 09:33:59 -08:00
committed by GitHub
parent c1401682ed
commit 041463d112
7 changed files with 154 additions and 6 deletions
+32 -1
View File
@@ -99,7 +99,7 @@ describe('AgentRegistry', () => {
const agentCount = debugRegistry.getAllDefinitions().length;
expect(debugLogSpy).toHaveBeenCalledWith(
`[AgentRegistry] Initialized with ${agentCount} agents.`,
`[AgentRegistry] Loaded with ${agentCount} agents.`,
);
});
@@ -444,6 +444,37 @@ describe('AgentRegistry', () => {
});
});
describe('reload', () => {
it('should clear existing agents and reload from directories', async () => {
const config = makeFakeConfig({ enableAgents: true });
const registry = new TestableAgentRegistry(config);
const initialAgent = { ...MOCK_AGENT_V1, name: 'InitialAgent' };
await registry.testRegisterAgent(initialAgent);
expect(registry.getDefinition('InitialAgent')).toBeDefined();
const newAgent = { ...MOCK_AGENT_V1, name: 'NewAgent' };
vi.mocked(tomlLoader.loadAgentsFromDirectory).mockResolvedValue({
agents: [newAgent],
errors: [],
});
const clearCacheSpy = vi.fn();
vi.mocked(A2AClientManager.getInstance).mockReturnValue({
clearCache: clearCacheSpy,
} as unknown as A2AClientManager);
const emitSpy = vi.spyOn(coreEvents, 'emitAgentsRefreshed');
await registry.reload();
expect(clearCacheSpy).toHaveBeenCalled();
expect(registry.getDefinition('InitialAgent')).toBeUndefined();
expect(registry.getDefinition('NewAgent')).toBeDefined();
expect(emitSpy).toHaveBeenCalled();
});
});
describe('inheritance and refresh', () => {
it('should resolve "inherit" to the current model from configuration', async () => {
const config = makeFakeConfig({ model: 'current-model' });