( agents: AgentDefinition[], query: string, showOnEmpty = false, )
| 75 | } |
| 76 | |
| 77 | function generateAgentSuggestions( |
| 78 | agents: AgentDefinition[], |
| 79 | query: string, |
| 80 | showOnEmpty = false, |
| 81 | ): AgentSuggestionSource[] { |
| 82 | if (!query && !showOnEmpty) { |
| 83 | return [] |
| 84 | } |
| 85 | |
| 86 | try { |
| 87 | const agentSources: AgentSuggestionSource[] = agents.map(agent => ({ |
| 88 | type: 'agent' as const, |
| 89 | displayText: `${agent.agentType} (agent)`, |
| 90 | description: truncateDescription(agent.whenToUse), |
| 91 | agentType: agent.agentType, |
| 92 | color: getAgentColor(agent.agentType), |
| 93 | })) |
| 94 | |
| 95 | if (!query) { |
| 96 | return agentSources |
| 97 | } |
| 98 | |
| 99 | const queryLower = query.toLowerCase() |
| 100 | return agentSources.filter( |
| 101 | agent => |
| 102 | agent.agentType.toLowerCase().includes(queryLower) || |
| 103 | agent.displayText.toLowerCase().includes(queryLower), |
| 104 | ) |
| 105 | } catch (error) { |
| 106 | logError(error as Error) |
| 107 | return [] |
| 108 | } |
| 109 | } |
| 110 | |
| 111 | export async function generateUnifiedSuggestions( |
| 112 | query: string, |
no test coverage detected