Wire agent.delegate into TUI tool registry
This commit is contained in:
@@ -2,7 +2,6 @@ import { describe, it, expect, vi, beforeEach } from 'vitest';
|
||||
import { createAgentDelegateTool } from './agent-delegate.js';
|
||||
import type { AgentDelegateDeps } from './agent-delegate.js';
|
||||
import type { AgentConfigRegistry } from '../../agents/registry.js';
|
||||
import type { AgentOrchestrator } from '../../backends/native/orchestrator.js';
|
||||
|
||||
function createMockRegistry(configs: Record<string, { systemPrompt?: string; modelTier?: string }>): AgentConfigRegistry {
|
||||
const entries = Object.entries(configs).map(([name, cfg]) => ({
|
||||
@@ -17,19 +16,21 @@ function createMockRegistry(configs: Record<string, { systemPrompt?: string; mod
|
||||
} as unknown as AgentConfigRegistry;
|
||||
}
|
||||
|
||||
function createMockOrchestrator(response?: { content: string; usage: { inputTokens: number; outputTokens: number }; tier: string }): AgentOrchestrator {
|
||||
function createMockOrchestrator(
|
||||
response?: { content: string; usage: { inputTokens: number; outputTokens: number }; tier: 'fast' | 'default' | 'complex' | 'local' },
|
||||
): AgentDelegateDeps['orchestrator'] {
|
||||
return {
|
||||
delegate: vi.fn().mockResolvedValue(response ?? {
|
||||
content: 'Mock agent response',
|
||||
usage: { inputTokens: 100, outputTokens: 50 },
|
||||
tier: 'default',
|
||||
}),
|
||||
} as unknown as AgentOrchestrator;
|
||||
};
|
||||
}
|
||||
|
||||
describe('agent.delegate tool', () => {
|
||||
let deps: AgentDelegateDeps;
|
||||
let mockOrchestrator: AgentOrchestrator;
|
||||
let mockOrchestrator: AgentDelegateDeps['orchestrator'];
|
||||
|
||||
beforeEach(() => {
|
||||
mockOrchestrator = createMockOrchestrator();
|
||||
@@ -127,7 +128,7 @@ describe('agent.delegate tool', () => {
|
||||
it('handles orchestrator errors gracefully', async () => {
|
||||
const failingOrchestrator = {
|
||||
delegate: vi.fn().mockRejectedValue(new Error('Model provider unavailable')),
|
||||
} as unknown as AgentOrchestrator;
|
||||
} as AgentDelegateDeps['orchestrator'];
|
||||
|
||||
const tool = createAgentDelegateTool({ ...deps, orchestrator: failingOrchestrator });
|
||||
const result = await tool.execute({ agent: 'research', task: 'This will fail' });
|
||||
|
||||
@@ -1,11 +1,24 @@
|
||||
import type { Tool, ToolResult } from '../types.js';
|
||||
import type { AgentConfigRegistry } from '../../agents/registry.js';
|
||||
import type { AgentOrchestrator } from '../../backends/native/orchestrator.js';
|
||||
import type { ModelTier } from '../../models/router.js';
|
||||
import type { TokenUsage } from '../../models/types.js';
|
||||
|
||||
interface AgentDelegateRunner {
|
||||
delegate(request: {
|
||||
tier: ModelTier;
|
||||
systemPrompt: string;
|
||||
message: string;
|
||||
maxTokens?: number;
|
||||
}): Promise<{
|
||||
content: string;
|
||||
usage: TokenUsage;
|
||||
tier: ModelTier;
|
||||
}>;
|
||||
}
|
||||
|
||||
export interface AgentDelegateDeps {
|
||||
registry: AgentConfigRegistry;
|
||||
orchestrator: AgentOrchestrator;
|
||||
orchestrator: AgentDelegateRunner;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user