feat(group-chat): add @all mention routing (#857)
Add modular group-chat mention routing helpers for the reserved @all token, route it to every non-sender agent, and strip routing tokens before model input. Expose @all in mention autocomplete, highlight it in group messages, reserve literal all agent names, and cover boundary/partial-match regressions with tests.
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import Router from '@koa/router'
|
||||
import type { GroupChatServer } from '../../services/hermes/group-chat'
|
||||
import { isReservedMentionName } from '../../services/hermes/group-chat/mention-routing'
|
||||
|
||||
export const groupChatRoutes = new Router()
|
||||
|
||||
@@ -45,6 +46,12 @@ groupChatRoutes.post('/api/hermes/group-chat/rooms', async (ctx) => {
|
||||
ctx.body = { error: 'name and inviteCode are required' }
|
||||
return
|
||||
}
|
||||
const reservedAgent = (agents || []).find(a => isReservedMentionName(a.name || a.profile))
|
||||
if (reservedAgent) {
|
||||
ctx.status = 400
|
||||
ctx.body = { error: '`all` is reserved for @all mentions' }
|
||||
return
|
||||
}
|
||||
|
||||
const roomId = generateId()
|
||||
const storage = chatServer.getStorage()
|
||||
@@ -213,6 +220,11 @@ groupChatRoutes.post('/api/hermes/group-chat/rooms/:roomId/agents', async (ctx)
|
||||
ctx.body = { error: 'profile is required' }
|
||||
return
|
||||
}
|
||||
if (isReservedMentionName(name || profile)) {
|
||||
ctx.status = 400
|
||||
ctx.body = { error: '`all` is reserved for @all mentions' }
|
||||
return
|
||||
}
|
||||
|
||||
// Prevent duplicate agent in same room
|
||||
const existing = chatServer.getStorage().getRoomAgents(ctx.params.roomId)
|
||||
|
||||
Reference in New Issue
Block a user