Add search and RAG workspace flows

This commit is contained in:
2026-03-07 20:34:00 -05:00
parent db01f207a5
commit e20aba998b
35 changed files with 3417 additions and 372 deletions

View File

@@ -0,0 +1,46 @@
import { indexSearchDocuments } from '@/lib/server/search';
function getArg(name: string) {
const prefix = `--${name}=`;
const entry = process.argv.find((value) => value.startsWith(prefix));
return entry ? entry.slice(prefix.length).trim() : null;
}
async function main() {
const source = (getArg('source') ?? 'all').toLowerCase();
const ticker = getArg('ticker')?.toUpperCase() ?? null;
const accessionNumber = getArg('accession') ?? null;
const userId = getArg('user') ?? 'system-backfill';
const sourceKinds: Array<'filing_document' | 'filing_brief' | 'research_note'> | null = source === 'all'
? ['filing_document', 'filing_brief', 'research_note'] as const
: source === 'documents'
? ['filing_document'] as const
: source === 'filings'
? ['filing_brief'] as const
: source === 'research'
? ['research_note'] as const
: null;
if (!sourceKinds) {
throw new Error('Unsupported --source value. Use all, documents, filings, or research.');
}
if (sourceKinds.includes('research_note') && !userId) {
throw new Error('--user is required when backfilling research notes.');
}
const result = await indexSearchDocuments({
userId,
ticker,
accessionNumber,
sourceKinds
});
console.log(JSON.stringify(result, null, 2));
}
main().catch((error) => {
console.error(error instanceof Error ? error.message : error);
process.exitCode = 1;
});