File size: 10,050 Bytes
8b02e7c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
"""Agent capability profiles and routing presets.

This module defines factual capability profiles for known agents and
routing presets for different delegation strategies.
"""

from typing import TypedDict, Literal, Any


class AgentAttributes(TypedDict):
    """Factual attributes for an agent."""
    cost_tier: Literal["free", "subscription", "pay-per-token"]
    deployment: Literal["local", "cloud"]
    context_window: int  # approximate tokens
    has_git_integration: bool
    has_browser_tools: bool
    response_speed: Literal["fast", "medium", "slow"]
    primary_strength: str
    description: str
    capabilities: dict[str, float]


# Default profile for unknown agents
DEFAULT_ATTRIBUTES: AgentAttributes = {
    "cost_tier": "pay-per-token",
    "deployment": "cloud",
    "context_window": 8192,
    "has_git_integration": False,
    "has_browser_tools": False,
    "response_speed": "medium",
    "primary_strength": "general",
    "description": "General purpose agent",
    "capabilities": {
        "security_audit": 0.5,
        "vulnerability_scan": 0.5,
        "code_review": 0.5,
        "architecture": 0.5,
        "refactoring": 0.5,
        "quick_fix": 0.5,
        "documentation": 0.5,
        "testing": 0.5,
        "performance": 0.5,
        "git_workflow": 0.5,
        "github_operations": 0.5,
        "general": 0.5,
    },
}

# Factual profiles for known agents
AGENT_PROFILES: dict[str, AgentAttributes] = {
    "claude": {
        "cost_tier": "pay-per-token",
        "deployment": "cloud",
        "context_window": 200000,
        "has_git_integration": False,
        "has_browser_tools": False,
        "response_speed": "medium",
        "primary_strength": "complex reasoning",
        "description": "Best for complex reasoning, architecture, and code review",
        "capabilities": {
            "security_audit": 0.8,
            "vulnerability_scan": 0.7,
            "code_review": 0.9,
            "architecture": 0.9,
            "refactoring": 0.8,
            "quick_fix": 0.7,
            "documentation": 0.9,
            "testing": 0.8,
            "performance": 0.7,
            "git_workflow": 0.1,
            "github_operations": 0.1,
            "general": 0.9,
        },
    },
    "gemini": {
        "cost_tier": "pay-per-token",
        "deployment": "cloud",
        "context_window": 1000000,
        "has_git_integration": False,
        "has_browser_tools": True,
        "response_speed": "medium",
        "primary_strength": "security & performance",
        "description": "Strong security analysis, performance optimization, and browser tools",
        "capabilities": {
            "security_audit": 0.9,
            "vulnerability_scan": 0.9,
            "code_review": 0.8,
            "architecture": 0.8,
            "refactoring": 0.7,
            "quick_fix": 0.7,
            "documentation": 0.8,
            "testing": 0.8,
            "performance": 0.9,
            "git_workflow": 0.1,
            "github_operations": 0.1,
            "general": 0.8,
        },
    },
    "aider": {
        "cost_tier": "free",  # The tool itself is free, uses BYO keys or local models
        "deployment": "local",
        "context_window": 32000, # Depends on model, but tool manages context
        "has_git_integration": True,
        "has_browser_tools": False,
        "response_speed": "fast",
        "primary_strength": "git & refactoring",
        "description": "Excellent for rapid code editing, refactoring, and git operations",
        "capabilities": {
            "security_audit": 0.4,
            "vulnerability_scan": 0.4,
            "code_review": 0.7,
            "architecture": 0.6,
            "refactoring": 0.9,
            "quick_fix": 0.9,
            "documentation": 0.6,
            "testing": 0.7,
            "performance": 0.5,
            "git_workflow": 0.9,
            "github_operations": 0.8,
            "general": 0.7,
        },
    },
    "copilot": {
        "cost_tier": "subscription",
        "deployment": "cloud",
        "context_window": 32000,
        "has_git_integration": False,
        "has_browser_tools": False,
        "response_speed": "fast",
        "primary_strength": "quick fixes",
        "description": "Balanced capabilities with strong quick fixes and testing",
        "capabilities": {
            "security_audit": 0.5,
            "vulnerability_scan": 0.5,
            "code_review": 0.7,
            "architecture": 0.6,
            "refactoring": 0.8,
            "quick_fix": 0.9,
            "documentation": 0.7,
            "testing": 0.9,
            "performance": 0.6,
            "git_workflow": 0.3,
            "github_operations": 0.3,
            "general": 0.7,
        },
    },
    "qwen": {
        "cost_tier": "free", # Usually run locally
        "deployment": "local",
        "context_window": 32000,
        "has_git_integration": False,
        "has_browser_tools": False,
        "response_speed": "medium",
        "primary_strength": "code review",
        "description": "Code-focused with strong review and architecture capabilities",
        "capabilities": {
            "security_audit": 0.6,
            "vulnerability_scan": 0.6,
            "code_review": 0.8,
            "architecture": 0.7,
            "refactoring": 0.7,
            "quick_fix": 0.7,
            "documentation": 0.6,
            "testing": 0.7,
            "performance": 0.6,
            "git_workflow": 0.2,
            "github_operations": 0.2,
            "general": 0.7,
        },
    },
}


class RoutingPreset(TypedDict):
    """Configuration for a routing strategy."""
    name: str
    description: str
    strategy_description: str
    cost_priority: Literal["low", "medium", "high"]
    quality_priority: Literal["low", "medium", "high"]


ROUTING_PRESETS: dict[str, RoutingPreset] = {
    "best_in_class": {
        "name": "Best in Class",
        "description": "Highest quality, cost is secondary",
        "strategy_description": "Prefer Claude for architecture/review, Gemini for security, Aider for git",
        "cost_priority": "low",
        "quality_priority": "high",
    },
    "cost_optimized": {
        "name": "Cost Optimized",
        "description": "Minimize API costs, prefer local",
        "strategy_description": "Prefer local models and Aider, use cloud agents only when necessary",
        "cost_priority": "high",
        "quality_priority": "medium",
    },
    "token_saver": {
        "name": "Token Saver",
        "description": "Minimize token usage",
        "strategy_description": "Use agents with large context windows, prefer concise responders",
        "cost_priority": "high",
        "quality_priority": "medium",
    },
    "speed_first": {
        "name": "Speed First",
        "description": "Fastest iteration, good for dev",
        "strategy_description": "Prefer faster models like Aider and quick cloud APIs",
        "cost_priority": "low",
        "quality_priority": "medium",
    },
    "specialized": {
        "name": "Specialized Routing",
        "description": "Match tasks to native capabilities",
        "strategy_description": "Match tasks to agents with native tool support (e.g. Browser -> Gemini)",
        "cost_priority": "medium",
        "quality_priority": "high",
    },
    "balanced": {
        "name": "Balanced (Recommended)",
        "description": "Good mix of quality, speed, cost",
        "strategy_description": "Distribute work sensibly across all available agents",
        "cost_priority": "medium",
        "quality_priority": "medium",
    },
}


class RoutingRule(TypedDict):
    """Rule for routing a specific task category."""
    preferred: list[str]
    reason: str


# Default routing rules for "Best in Class" / "Balanced" baseline
# These are modified by the strategy logic in task_mapper.py
DEFAULT_ROUTING_RULES: dict[str, RoutingRule] = {
    "architecture": {
        "preferred": ["claude"],
        "reason": "Marketed for complex reasoning",
    },
    "code_review": {
        "preferred": ["claude", "qwen"],
        "reason": "Strong reasoning capabilities",
    },
    "security_audit": {
        "preferred": ["gemini"],
        "reason": "Strong security analysis capabilities",
    },
    "refactoring": {
        "preferred": ["aider"],
        "reason": "Optimized for code editing",
    },
    "quick_fix": {
        "preferred": ["aider", "copilot"],
        "reason": "Optimized for speed and small edits",
    },
    "documentation": {
        "preferred": ["claude"],
        "reason": "Strong long-form writing capabilities",
    },
    "testing": {
        "preferred": ["copilot", "claude"],
        "reason": "Balanced testing capabilities",
    },
    "performance": {
        "preferred": ["gemini"],
        "reason": "Strong analytical capabilities",
    },
    "browser_interaction": {
        "preferred": ["gemini"],
        "reason": "Has browser automation tools",
    },
    "git_operations": {
        "preferred": ["aider"],
        "reason": "Native git integration",
    },
    "shell_tasks": {
        "preferred": ["aider"],
        "reason": "Strong command line capabilities",
    },
    "exploration": {
        "preferred": ["claude"],
        "reason": "Large context window for codebase understanding",
    },
    "debugging": {
        "preferred": ["claude"],
        "reason": "Complex reasoning for root cause analysis",
    },
    "impact_analysis": {
        "preferred": ["claude"],
        "reason": "Complex reasoning for dependency analysis",
    },
    "general": {
        "preferred": ["claude"],
        "reason": "General purpose reasoning",
    },
}


def get_agent_profile(agent_name: str) -> AgentAttributes:
    """
    Get factual profile for an agent.
    
    Args:
        agent_name: Name of the agent (case-insensitive)
        
    Returns:
        AgentAttributes with factual metadata
    """
    agent_key = agent_name.lower().strip()
    return AGENT_PROFILES.get(agent_key, DEFAULT_ATTRIBUTES)