Files
lingxi-ai/packages/client/src/components/hermes/group-chat/mention-options.ts
T
yi 7d10320a82
Build / build (push) Has been cancelled
NPM Lockfile Check / npm ci --ignore-scripts (push) Has been cancelled
Playwright / e2e (push) Has been cancelled
feat: 灵犀 Studio Web UI 定制版
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-05 11:29:11 +08:00

47 lines
1.2 KiB
TypeScript

export type MentionOption = {
key: string
type: 'all' | 'agent'
name: string
label: string
description: string
}
type MentionAgent = {
name: string
profile?: string
}
function isReservedMentionName(name: string): boolean {
return name.trim().toLowerCase() === 'all'
}
export function buildMentionOptions(agents: MentionAgent[], query: string): MentionOption[] {
const normalizedQuery = query.trim().toLowerCase()
const options: MentionOption[] = []
if (!normalizedQuery || 'all'.includes(normalizedQuery)) {
options.push({
key: 'special:all',
type: 'all',
name: 'all',
label: '@all',
description: 'All agents',
})
}
for (const agent of agents) {
const agentName = agent.name || ''
if (isReservedMentionName(agentName)) continue
if (!agentName.toLowerCase().includes(normalizedQuery)) continue
options.push({
key: `agent:${agentName}`,
type: 'agent',
name: agentName,
label: `@${agentName}`,
description: agent.profile || '',
})
}
return options
}