Add hybrid research copilot workspace

This commit is contained in:
2026-03-14 19:32:00 -04:00
parent 7a42d73a48
commit 2ee9a549a3
27 changed files with 2864 additions and 323 deletions

View File

@@ -296,6 +296,50 @@ function ensureResearchWorkspaceSchema(client: Database) {
`);
}
function ensureResearchCopilotSchema(client: Database) {
if (!hasTable(client, 'research_copilot_session')) {
client.exec(`
CREATE TABLE IF NOT EXISTS \`research_copilot_session\` (
\`id\` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
\`user_id\` text NOT NULL,
\`ticker\` text NOT NULL,
\`title\` text,
\`selected_sources\` text NOT NULL DEFAULT '["documents","filings","research"]',
\`pinned_artifact_ids\` text NOT NULL DEFAULT '[]',
\`created_at\` text NOT NULL,
\`updated_at\` text NOT NULL,
FOREIGN KEY (\`user_id\`) REFERENCES \`user\`(\`id\`) ON UPDATE no action ON DELETE cascade
);
`);
}
if (!hasTable(client, 'research_copilot_message')) {
client.exec(`
CREATE TABLE IF NOT EXISTS \`research_copilot_message\` (
\`id\` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
\`session_id\` integer NOT NULL,
\`user_id\` text NOT NULL,
\`role\` text NOT NULL,
\`content_markdown\` text NOT NULL,
\`citations\` text,
\`follow_ups\` text,
\`suggested_actions\` text,
\`selected_sources\` text,
\`pinned_artifact_ids\` text,
\`memo_section\` text,
\`created_at\` text NOT NULL,
FOREIGN KEY (\`session_id\`) REFERENCES \`research_copilot_session\`(\`id\`) ON UPDATE no action ON DELETE cascade,
FOREIGN KEY (\`user_id\`) REFERENCES \`user\`(\`id\`) ON UPDATE no action ON DELETE cascade
);
`);
}
client.exec('CREATE UNIQUE INDEX IF NOT EXISTS `research_copilot_session_ticker_uidx` ON `research_copilot_session` (`user_id`, `ticker`);');
client.exec('CREATE INDEX IF NOT EXISTS `research_copilot_session_updated_idx` ON `research_copilot_session` (`user_id`, `updated_at`);');
client.exec('CREATE INDEX IF NOT EXISTS `research_copilot_message_session_idx` ON `research_copilot_message` (`session_id`, `created_at`);');
client.exec('CREATE INDEX IF NOT EXISTS `research_copilot_message_user_idx` ON `research_copilot_message` (`user_id`, `created_at`);');
}
const TAXONOMY_SNAPSHOT_REQUIRED_COLUMNS = [
'parser_engine',
'parser_version',
@@ -548,6 +592,7 @@ WHERE resource_key IS NOT NULL AND status IN ('queued', 'running');`);
}
ensureResearchWorkspaceSchema(client);
ensureResearchCopilotSchema(client);
}
export const __sqliteSchemaCompatInternals = {