29 lines
821 B
JavaScript
29 lines
821 B
JavaScript
import * as searchRepo from '../../../db/repos/search.js';
|
|
|
|
export const searchTool = {
|
|
name: 'search',
|
|
description: 'Full-text search across pages, refs, source docs and messages in the current Space. Use to find information before answering.',
|
|
input_schema: {
|
|
type: 'object',
|
|
properties: {
|
|
q: { type: 'string', description: 'search query' },
|
|
kinds: {
|
|
type: 'array',
|
|
items: { type: 'string', enum: ['page', 'ref', 'source_doc', 'message'] },
|
|
description: 'optional filter of result kinds'
|
|
}
|
|
},
|
|
required: ['q']
|
|
},
|
|
async handler({ q, kinds }, ctx) {
|
|
const results = await searchRepo.fts({
|
|
q,
|
|
space_id: ctx.space_id ?? null,
|
|
kinds: kinds?.length ? kinds : null,
|
|
limit: 8,
|
|
offset: 0
|
|
});
|
|
return { results };
|
|
}
|
|
};
|