| |
| |
| |
| |
|
|
| import { getDefaultSubagentModel } from '../../utils/model/agent.js' |
| import { |
| getSourceDisplayName, |
| type SettingSource, |
| } from '../../utils/settings/constants.js' |
| import type { AgentDefinition } from './loadAgentsDir.js' |
|
|
| type AgentSource = SettingSource | 'built-in' | 'plugin' |
|
|
| export type AgentSourceGroup = { |
| label: string |
| source: AgentSource |
| } |
|
|
| |
| |
| |
| |
| export const AGENT_SOURCE_GROUPS: AgentSourceGroup[] = [ |
| { label: 'User agents', source: 'userSettings' }, |
| { label: 'Project agents', source: 'projectSettings' }, |
| { label: 'Local agents', source: 'localSettings' }, |
| { label: 'Managed agents', source: 'policySettings' }, |
| { label: 'Plugin agents', source: 'plugin' }, |
| { label: 'CLI arg agents', source: 'flagSettings' }, |
| { label: 'Built-in agents', source: 'built-in' }, |
| ] |
|
|
| export type ResolvedAgent = AgentDefinition & { |
| overriddenBy?: AgentSource |
| } |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| export function resolveAgentOverrides( |
| allAgents: AgentDefinition[], |
| activeAgents: AgentDefinition[], |
| ): ResolvedAgent[] { |
| const activeMap = new Map<string, AgentDefinition>() |
| for (const agent of activeAgents) { |
| activeMap.set(agent.agentType, agent) |
| } |
|
|
| const seen = new Set<string>() |
| const resolved: ResolvedAgent[] = [] |
|
|
| |
| |
| for (const agent of allAgents) { |
| const key = `${agent.agentType}:${agent.source}` |
| if (seen.has(key)) continue |
| seen.add(key) |
|
|
| const active = activeMap.get(agent.agentType) |
| const overriddenBy = |
| active && active.source !== agent.source ? active.source : undefined |
| resolved.push({ ...agent, overriddenBy }) |
| } |
|
|
| return resolved |
| } |
|
|
| |
| |
| |
| |
| export function resolveAgentModelDisplay( |
| agent: AgentDefinition, |
| ): string | undefined { |
| const model = agent.model || getDefaultSubagentModel() |
| if (!model) return undefined |
| return model === 'inherit' ? 'inherit' : model |
| } |
|
|
| |
| |
| |
| |
| export function getOverrideSourceLabel(source: AgentSource): string { |
| return getSourceDisplayName(source).toLowerCase() |
| } |
|
|
| |
| |
| |
| export function compareAgentsByName( |
| a: AgentDefinition, |
| b: AgentDefinition, |
| ): number { |
| return a.agentType.localeCompare(b.agentType, undefined, { |
| sensitivity: 'base', |
| }) |
| } |
|
|