feat: add agent search config and system assistant defaults

Adds a config jsonb column to agents for per-agent search settings
(enabled, rerank, maxResults). Types systemAssistants with rename and
rerank sub-objects. Backfills missing systemAssistants keys on settings
fetch. Includes generated drizzle migrations.
This commit is contained in:
Zoe
2026-04-27 12:05:27 -05:00
parent 1ed2bd8b16
commit 90d5698e76
10 changed files with 5565 additions and 19 deletions
+18 -2
View File
@@ -23,7 +23,16 @@ export enum ToolCallType {
export const settings = pgTable('settings', {
id: text('id').primaryKey().$defaultFn(nanoid),
userId: text('user_id').notNull(),
systemAssistants: jsonb('system_assistants').$type<Record<string, any>>().notNull().default({}),
systemAssistants: jsonb('system_assistants').$type<{
rename: {
enabled: boolean;
modelId: string | null;
};
rerank: {
enabled: boolean;
modelId: string | null;
};
}>().notNull().default({} as any),
appearance: jsonb('appearance').$type<{
colorScheme?: 'light' | 'dark' | 'system';
accent?: string;
@@ -93,6 +102,13 @@ export const agents = pgTable('agents', {
systemPrompt: text('system_prompt'),
imageUrl: text('image_url'),
defaultModelId: text('default_model_id').references(() => models.id, { onDelete: 'set null' }),
config: jsonb('config').$type<{
search?: {
enabled: boolean;
rerank: boolean;
maxResults: number;
}
}>().default({}),
createdAt: timestamp('created_at').notNull().defaultNow(),
}, (table) => [
index('agents_userId_idx').on(table.userId),
@@ -215,7 +231,7 @@ export const embeddings = pgTable('embeddings', {
export const attachments = pgTable('attachments', {
id: text('id').primaryKey().$defaultFn(nanoid),
userId: text('user_id').notNull(),
topicId: text('topic_id').notNull().references(() => topics.id),
topicId: text('topic_id').notNull().references(() => topics.id, { onDelete: 'cascade' }),
messageId: text('message_id').notNull().references(() => messages.id, { onDelete: 'cascade' }),
fileId: text('file_id').notNull().references(() => files.id, { onDelete: 'cascade' }),
createdAt: timestamp('created_at').notNull().defaultNow(),