- add external retrieval and confirmation-gated writeback tools across MCP surfaces - port direct-search-first retrieval support and supporting ranking/query updates - update MCP docs and skills to treat agent memory files as optional reinforcement Generated with Claude Code
36 lines
1.1 KiB
TypeScript
36 lines
1.1 KiB
TypeScript
import { NextRequest, NextResponse } from 'next/server';
|
|
import { retrieveQueryContext } from '@/services/retrieval/queryContext';
|
|
|
|
export const runtime = 'nodejs';
|
|
|
|
export async function POST(request: NextRequest) {
|
|
try {
|
|
const body = await request.json();
|
|
const query = typeof body.query === 'string' ? body.query : '';
|
|
|
|
if (!query.trim()) {
|
|
return NextResponse.json({
|
|
success: false,
|
|
error: 'Missing required field: query',
|
|
}, { status: 400 });
|
|
}
|
|
|
|
const result = await retrieveQueryContext({
|
|
query,
|
|
focused_node_id: typeof body.focused_node_id === 'number' ? body.focused_node_id : null,
|
|
active_context_id: typeof body.active_context_id === 'number' ? body.active_context_id : null,
|
|
limit: typeof body.limit === 'number' ? body.limit : undefined,
|
|
});
|
|
|
|
return NextResponse.json({
|
|
success: true,
|
|
data: result,
|
|
});
|
|
} catch (error) {
|
|
return NextResponse.json({
|
|
success: false,
|
|
error: error instanceof Error ? error.message : 'Failed to retrieve query context',
|
|
}, { status: 500 });
|
|
}
|
|
}
|