feat: enrich search with msglib display entities
This commit is contained in:
@@ -7,6 +7,7 @@ import (
|
||||
"github.com/modelcontextprotocol/go-sdk/mcp"
|
||||
|
||||
"isphere-ai-bridge/internal/isphere"
|
||||
"isphere-ai-bridge/internal/msglib"
|
||||
)
|
||||
|
||||
const ToolNameSearchGroups = "isphere_search_groups"
|
||||
@@ -20,6 +21,10 @@ type SearchGroupsArgs struct {
|
||||
}
|
||||
|
||||
func RegisterISphereGroupTools(server *mcp.Server, source ReceiveMessagesSource) {
|
||||
RegisterISphereGroupToolsWithDisplayEntities(server, source, nil)
|
||||
}
|
||||
|
||||
func RegisterISphereGroupToolsWithDisplayEntities(server *mcp.Server, source ReceiveMessagesSource, displaySource DisplayEntitySource) {
|
||||
if source == nil {
|
||||
source = isphere.EncryptedPacketLogSource{}
|
||||
}
|
||||
@@ -36,7 +41,19 @@ func RegisterISphereGroupTools(server *mcp.Server, source ReceiveMessagesSource)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
groups := isphere.SearchGroupsFromMessages(messages.Messages, isphere.SearchGroupsQuery{Query: input.Query, Limit: input.Limit})
|
||||
logGroups := isphere.SearchGroupsFromMessages(messages.Messages, isphere.SearchGroupsQuery{Query: input.Query, Limit: input.Limit})
|
||||
groups := logGroups
|
||||
if displaySource != nil {
|
||||
entities, err := displaySource.DisplayEntities(ctx, msglib.DisplayEntitiesOptions{
|
||||
EntityType: msglib.EntityTypeGroups,
|
||||
Query: input.Query,
|
||||
Limit: displayEntityQueryLimit(input.Limit),
|
||||
})
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
groups = mergeGroups(groupsFromDisplayEntities(entities), logGroups.Groups, input.Limit)
|
||||
}
|
||||
return nil, searchGroupsResultToMap(groups, started, time.Now().UTC()), nil
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user