1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[86476],{5667:(e,t,n)=>{"use strict";n.d(t,{ZM:()=>d,Z_:()=>E});var s=n(20319),i=n(63496);let a={agents:"agt",files:"file",knowledgeBases:"kb",messages:"msg",plugins:"plg",sessionGroups:"sg",sessions:"ssn",threads:"thd",topics:"tpc",user:"user"},d=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:12,n=(0,i.cA)(t),s=a[e];if(!s)throw Error("Invalid namespace: ".concat(e,", please check your code."));return"".concat(s,"_").concat(n())},E=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:2;return(0,s.generate)(e).join("-")}},13151:(e,t,n)=>{"use strict";n.d(t,{Lw:()=>u,eD:()=>T,vp:()=>r});var s=n(42407),i=n(73568),a=n(77653),d=n(45169),E=n(98316),l=n(65677),_=n(5667),N=n(75466),o=n(88748),c=n(39691);let r=(0,s.cJ)("topics",{id:(0,i.Qq)("id").$defaultFn(()=>(0,_.ZM)("topics")).primaryKey(),title:(0,i.Qq)("title"),favorite:(0,a.zM)("favorite").default(!1),sessionId:(0,i.Qq)("session_id").references(()=>o.Mf.id,{onDelete:"cascade"}),userId:(0,i.Qq)("user_id").references(()=>c.VV.id,{onDelete:"cascade"}).notNull(),clientId:(0,i.Qq)("client_id"),historySummary:(0,i.Qq)("history_summary"),metadata:(0,d.Fx)("metadata").$type(),...N.AP},e=>({clientIdUnique:(0,E.Am)("topic_client_id_user_id_unique").on(e.clientId,e.userId)})),T=(0,s.cJ)("threads",{id:(0,i.Qq)("id").$defaultFn(()=>(0,_.ZM)("threads",16)).primaryKey(),title:(0,i.Qq)("title"),type:(0,i.Qq)("type",{enum:["continuation","standalone"]}).notNull(),status:(0,i.Qq)("status",{enum:["active","deprecated","archived"]}).default("active"),topicId:(0,i.Qq)("topic_id").references(()=>r.id,{onDelete:"cascade"}).notNull(),sourceMessageId:(0,i.Qq)("source_message_id").notNull(),parentThreadId:(0,i.Qq)("parent_thread_id").references(()=>T.id,{onDelete:"set null"}),userId:(0,i.Qq)("user_id").references(()=>c.VV.id,{onDelete:"cascade"}).notNull(),lastActiveAt:(0,N.dE)("last_active_at").defaultNow(),...N.AP}),u=(0,l.r)(T)},16970:(e,t,n)=>{"use strict";n.d(t,{n:()=>s});var s=function(e){return e.ByTime="byTime",e.Flat="flat",e}({})},33835:(e,t,n)=>{"use strict";n.d(t,{Q:()=>N,QK:()=>r,jA:()=>c,pR:()=>o});var s=n(42407),i=n(73568),a=n(62207),d=n(59882),E=n(14145),l=n(77653),_=n(39691);let N=(0,s.cJ)("nextauth_accounts",{access_token:(0,i.Qq)("access_token"),expires_at:(0,a.nd)("expires_at"),id_token:(0,i.Qq)("id_token"),provider:(0,i.Qq)("provider").notNull(),providerAccountId:(0,i.Qq)("providerAccountId").notNull(),refresh_token:(0,i.Qq)("refresh_token"),scope:(0,i.Qq)("scope"),session_state:(0,i.Qq)("session_state"),token_type:(0,i.Qq)("token_type"),type:(0,i.Qq)("type").$type().notNull(),userId:(0,i.Qq)("userId").notNull().references(()=>_.VV.id,{onDelete:"cascade"})},e=>({compositePk:(0,d.ie)({columns:[e.provider,e.providerAccountId]})})),o=(0,s.cJ)("nextauth_sessions",{expires:(0,E.vE)("expires",{mode:"date"}).notNull(),sessionToken:(0,i.Qq)("sessionToken").primaryKey(),userId:(0,i.Qq)("userId").notNull().references(()=>_.VV.id,{onDelete:"cascade"})}),c=(0,s.cJ)("nextauth_verificationtokens",{expires:(0,E.vE)("expires",{mode:"date"}).notNull(),identifier:(0,i.Qq)("identifier").notNull(),token:(0,i.Qq)("token").notNull()},e=>({compositePk:(0,d.ie)({columns:[e.identifier,e.token]})})),r=(0,s.cJ)("nextauth_authenticators",{counter:(0,a.nd)("counter").notNull(),credentialBackedUp:(0,l.zM)("credentialBackedUp").notNull(),credentialDeviceType:(0,i.Qq)("credentialDeviceType").notNull(),credentialID:(0,i.Qq)("credentialID").notNull().unique(),credentialPublicKey:(0,i.Qq)("credentialPublicKey").notNull(),providerAccountId:(0,i.Qq)("providerAccountId").notNull(),transports:(0,i.Qq)("transports"),userId:(0,i.Qq)("userId").notNull().references(()=>_.VV.id,{onDelete:"cascade"})},e=>({compositePK:(0,d.ie)({columns:[e.userId,e.credentialID]})}))},35406:(e,t,n)=>{"use strict";n.d(t,{VN:()=>r,VV:()=>u,mh:()=>T});var s=n(42407),i=n(23116),a=n(73568),d=n(45169),E=n(62207),l=n(63228),_=n(72068),N=n(75466),o=n(49958),c=n(39691);let r=(0,s.cJ)("chunks",{id:(0,i.uR)("id").defaultRandom().primaryKey(),text:(0,a.Qq)("text"),abstract:(0,a.Qq)("abstract"),metadata:(0,d.Fx)("metadata"),index:(0,E.nd)("index"),type:(0,l.yf)("type"),userId:(0,a.Qq)("user_id").references(()=>
1c.VV.id,{onDelete:"cascade"}),...N.AP}),T=(0,s.cJ)("unstructured_chunks",{id:(0,i.uR)("id").defaultRandom().primaryKey(),text:(0,a.Qq)("text"),metadata:(0,d.Fx)("metadata"),index:(0,E.nd)("index"),type:(0,l.yf)("type"),...N.AP,parentId:(0,l.yf)("parent_id"),compositeId:(0,i.uR)("composite_id").references(()=>r.id,{onDelete:"cascade"}),userId:(0,a.Qq)("user_id").references(()=>c.VV.id,{onDelete:"cascade"}),fileId:(0,l.yf)("file_id").references(()=>o.aq.id,{onDelete:"cascade"})}),u=(0,s.cJ)("embeddings",{id:(0,i.uR)("id").defaultRandom().primaryKey(),chunkId:(0,i.uR)("chunk_id").references(()=>r.id,{onDelete:"cascade"}).unique(),embeddings:(0,_.i1)("embeddings",{dimensions:1024}),model:(0,a.Qq)("model"),userId:(0,a.Qq)("user_id").references(()=>c.VV.id,{onDelete:"cascade"})})},39691:(e,t,n)=>{"use strict";n.d(t,{Lq:()=>o,SI:()=>c,VV:()=>N});var s=n(42407),i=n(73568),a=n(77653),d=n(45169),E=n(59882),l=n(57334),_=n(75466);let N=(0,s.cJ)("users",{id:(0,i.Qq)("id").primaryKey().notNull(),username:(0,i.Qq)("username").unique(),email:(0,i.Qq)("email"),avatar:(0,i.Qq)("avatar"),phone:(0,i.Qq)("phone"),firstName:(0,i.Qq)("first_name"),lastName:(0,i.Qq)("last_name"),fullName:(0,i.Qq)("full_name"),isOnboarded:(0,a.zM)("is_onboarded").default(!1),clerkCreatedAt:(0,_.dE)("clerk_created_at"),emailVerifiedAt:(0,_.dE)("email_verified_at"),preference:(0,d.Fx)("preference").$defaultFn(()=>l.I),..._.AP}),o=(0,s.cJ)("user_settings",{id:(0,i.Qq)("id").references(()=>N.id,{onDelete:"cascade"}).primaryKey(),tts:(0,d.Fx)("tts"),keyVaults:(0,i.Qq)("key_vaults"),general:(0,d.Fx)("general"),languageModel:(0,d.Fx)("language_model"),systemAgent:(0,d.Fx)("system_agent"),defaultAgent:(0,d.Fx)("default_agent"),tool:(0,d.Fx)("tool")}),c=(0,s.cJ)("user_installed_plugins",{userId:(0,i.Qq)("user_id").references(()=>N.id,{onDelete:"cascade"}).notNull(),identifier:(0,i.Qq)("identifier").notNull(),type:(0,i.Qq)("type",{enum:["plugin","customPlugin"]}).notNull(),manifest:(0,d.Fx)("manifest").$type(),settings:(0,d.Fx)("settings"),customParams:(0,d.Fx)("custom_params").$type(),..._.AP},e=>({id:(0,E.ie)({columns:[e.userId,e.identifier]})}))},41041:(e,t,n)=>{"use strict";n.d(t,{b:()=>N});var s=n(42407),i=n(23116),a=n(73568),d=n(45169),E=n(62207),l=n(75466),_=n(39691);let N=(0,s.cJ)("async_tasks",{id:(0,i.uR)("id").defaultRandom().primaryKey(),type:(0,a.Qq)("type"),status:(0,a.Qq)("status"),error:(0,d.Fx)("error"),userId:(0,a.Qq)("user_id").references(()=>_.VV.id,{onDelete:"cascade"}).notNull(),duration:(0,E.nd)("duration"),...l.AP})},41234:()=>{},41617:(e,t,n)=>{"use strict";n.d(t,{D1:()=>A,I4:()=>L,Q2:()=>u,X6:()=>T});var s=n(42407),i=n(73568),a=n(63228),d=n(45169),E=n(77653),l=n(59882),_=n(65677),N=n(5667),o=n(75466),c=n(49958),r=n(39691);let T=(0,s.cJ)("agents",{id:(0,i.Qq)("id").primaryKey().$defaultFn(()=>(0,N.ZM)("agents")).notNull(),slug:(0,a.yf)("slug",{length:100}).$defaultFn(()=>(0,N.Z_)(4)).unique(),title:(0,i.Qq)("title"),description:(0,i.Qq)("description"),tags:(0,d.Fx)("tags").$type().default([]),avatar:(0,i.Qq)("avatar"),backgroundColor:(0,i.Qq)("background_color"),plugins:(0,d.Fx)("plugins").$type().default([]),userId:(0,i.Qq)("user_id").references(()=>r.VV.id,{onDelete:"cascade"}).notNull(),chatConfig:(0,d.Fx)("chat_config").$type(),fewShots:(0,d.Fx)("few_shots"),model:(0,i.Qq)("model"),params:(0,d.Fx)("params").default({}),provider:(0,i.Qq)("provider"),systemRole:(0,i.Qq)("system_role"),tts:(0,d.Fx)("tts").$type(),...o.AP}),u=(0,_.r)(T),A=(0,s.cJ)("agents_knowledge_bases",{agentId:(0,i.Qq)("agent_id").references(()=>T.id,{onDelete:"cascade"}).notNull(),knowledgeBaseId:(0,i.Qq)("knowledge_base_id").references(()=>c.NX.id,{onDelete:"cascade"}).notNull(),userId:(0,i.Qq)("user_id").references(()=>r.VV.id,{onDelete:"cascade"}).notNull(),enabled:(0,E.zM)("enabled").default(!0),...o.AP},e=>({pk:(0,l.ie)({columns:[e.agentId,e.knowledgeBaseId]})})),L=(0,s.cJ)("agents_files",{fileId:(0,i.Qq)("file_id").notNull().references(()=>c.aq.id,{onDelete:"cascade"}),agentId:(0,i.Qq)("agent_id").notNull().references(()=>T.id,{onDelete:"cascade"}),enabled:(0,E.zM)("enabled").default(!0),userId:(0,i.Qq)("user_id").references(()=>
1r.VV.id,{onDelete:"cascade"}).notNull(),...o.AP},e=>({pk:(0,l.ie)({columns:[e.fileId,e.agentId,e.userId]})}))},49958:(e,t,n)=>{"use strict";n.d(t,{N2:()=>O,NX:()=>D,V_:()=>A,aq:()=>L,rx:()=>g});var s=n(42407),i=n(63228),a=n(62207),d=n(73568),E=n(45169),l=n(23116),_=n(77653),N=n(59882),o=n(65677),c=n(5667),r=n(75466),T=n(41041),u=n(39691);let A=(0,s.cJ)("global_files",{hashId:(0,i.yf)("hash_id",{length:64}).primaryKey(),fileType:(0,i.yf)("file_type",{length:255}).notNull(),size:(0,a.nd)("size").notNull(),url:(0,d.Qq)("url").notNull(),metadata:(0,E.Fx)("metadata"),createdAt:(0,r.CT)(),accessedAt:(0,r.fu)()}),L=(0,s.cJ)("files",{id:(0,d.Qq)("id").$defaultFn(()=>(0,c.ZM)("files")).primaryKey(),userId:(0,d.Qq)("user_id").references(()=>u.VV.id,{onDelete:"cascade"}).notNull(),fileType:(0,i.yf)("file_type",{length:255}).notNull(),fileHash:(0,i.yf)("file_hash",{length:64}).references(()=>A.hashId,{onDelete:"no action"}),name:(0,d.Qq)("name").notNull(),size:(0,a.nd)("size").notNull(),url:(0,d.Qq)("url").notNull(),metadata:(0,E.Fx)("metadata"),chunkTaskId:(0,l.uR)("chunk_task_id").references(()=>T.b.id,{onDelete:"set null"}),embeddingTaskId:(0,l.uR)("embedding_task_id").references(()=>T.b.id,{onDelete:"set null"}),...r.AP}),D=(0,s.cJ)("knowledge_bases",{id:(0,d.Qq)("id").$defaultFn(()=>(0,c.ZM)("knowledgeBases")).primaryKey(),name:(0,d.Qq)("name").notNull(),description:(0,d.Qq)("description"),avatar:(0,d.Qq)("avatar"),type:(0,d.Qq)("type"),userId:(0,d.Qq)("user_id").references(()=>u.VV.id,{onDelete:"cascade"}).notNull(),isPublic:(0,_.zM)("is_public").default(!1),settings:(0,E.Fx)("settings"),...r.AP}),O=(0,o.r)(D),g=(0,s.cJ)("knowledge_base_files",{knowledgeBaseId:(0,d.Qq)("knowledge_base_id").references(()=>D.id,{onDelete:"cascade"}).notNull(),fileId:(0,d.Qq)("file_id").references(()=>L.id,{onDelete:"cascade"}).notNull(),createdAt:(0,r.CT)()},e=>({pk:(0,N.ie)({columns:[e.knowledgeBaseId,e.fileId]})}))},57334:(e,t,n)=>{"use strict";n.d(t,{I:()=>s});let s={guide:{moveSettingsToAvatar:!0,topic:!0},telemetry:null,topicDisplayMode:n(16970).n.ByTime,useCmdEnterToSend:!1}},63496:(e,t,n)=>{"use strict";n.d(t,{Ak:()=>a,cA:()=>i});var s=n(89045);let i=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:8;return(0,s.d)("1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",e)},a=i()},64091:(e,t,n)=>{"use strict";n.d(t,{s:()=>x,initializeDB:()=>P});var s={};n.r(s),n.d(s,{agents:()=>l.X6,agentsFiles:()=>l.I4,agentsKnowledgeBases:()=>l.D1,agentsKnowledgeBasesRelations:()=>h.UG,agentsRelations:()=>h.Gc,agentsToSessions:()=>h.pz,agentsToSessionsRelations:()=>h.cd,aiModels:()=>_.T,aiProviders:()=>_.J,asyncTasks:()=>N.b,chunks:()=>T.VN,chunksRelations:()=>h.Yb,embeddings:()=>T.VV,evalDatasetRecords:()=>f,evalDatasets:()=>p,evalEvaluation:()=>b,evaluationRecords:()=>U,fileChunks:()=>h.T9,files:()=>o.aq,filesRelations:()=>h.BU,filesToSessions:()=>h.GK,globalFiles:()=>o.V_,insertAgentSchema:()=>l.Q2,insertKnowledgeBasesSchema:()=>o.N2,insertSessionGroupSchema:()=>C.OG,insertSessionSchema:()=>C.F1,insertThreadSchema:()=>F.Lw,knowledgeBaseFiles:()=>o.rx,knowledgeBases:()=>o.NX,messageChunks:()=>c.yZ,messagePlugins:()=>c.g9,messageQueries:()=>c.AR,messageQueryChunks:()=>c.yX,messageTTS:()=>c.DV,messageTranslates:()=>c.lX,messages:()=>c.DZ,messagesFiles:()=>c.M$,messagesRelations:()=>h.SH,nextauthAccounts:()=>r.Q,nextauthAuthenticators:()=>r.QK,nextauthSessions:()=>r.pR,nextauthVerificationTokens:()=>r.jA,sessionGroups:()=>C.B$,sessions:()=>C.Mf,sessionsRelations:()=>h.Ru,threads:()=>F.eD,threadsRelations:()=>h.rU,topicRelations:()=>h.dK,topics:()=>F.vp,unstructuredChunks:()=>T.mh,updateMessagePluginSchema:()=>c.vM,userInstalledPlugins:()=>m.SI,userSettings:()=>m.Lq,users:()=>m.VV});var i=n(52938),a=n(17953),d=n(66386),E=n(96334),l=n(41617),_=n(82596),N=n(41041),o=n(49958),c=n(89751),r=n(33835),T=n(35406),u=n(42407),A=n(62207),L=n(73568),D=n(45169),O=n(23116),g=n(70164),I=n(71532),R=n(75466),m=n(39691);let p=(0,u.cJ)("rag_eval_datasets",{id:(0,A.nd)("id").generatedAlwaysAsIdentity({startWith:3e4}).primaryKey(),description:(0,L.Qq)("description"),name:(0,L.Qq)("name").notNull(),knowledgeBaseId:(0,L.Qq)("knowledge_base_id").references(()=>
1o.NX.id,{onDelete:"cascade"}),userId:(0,L.Qq)("user_id").references(()=>m.VV.id,{onDelete:"cascade"}),...R.AP}),f=(0,u.cJ)("rag_eval_dataset_records",{id:(0,A.nd)("id").generatedAlwaysAsIdentity().primaryKey(),datasetId:(0,A.nd)("dataset_id").references(()=>p.id,{onDelete:"cascade"}).notNull(),ideal:(0,L.Qq)("ideal"),question:(0,L.Qq)("question"),referenceFiles:(0,L.Qq)("reference_files").array(),metadata:(0,D.Fx)("metadata"),userId:(0,L.Qq)("user_id").references(()=>m.VV.id,{onDelete:"cascade"}),...R.AP}),b=(0,u.cJ)("rag_eval_evaluations",{id:(0,A.nd)("id").generatedAlwaysAsIdentity().primaryKey(),name:(0,L.Qq)("name").notNull(),description:(0,L.Qq)("description"),evalRecordsUrl:(0,L.Qq)("eval_records_url"),status:(0,L.Qq)("status").$defaultFn(()=>I.x1.Pending),error:(0,D.Fx)("error"),datasetId:(0,A.nd)("dataset_id").references(()=>p.id,{onDelete:"cascade"}).notNull(),knowledgeBaseId:(0,L.Qq)("knowledge_base_id").references(()=>o.NX.id,{onDelete:"cascade"}),languageModel:(0,L.Qq)("language_model").$defaultFn(()=>g.UB),embeddingModel:(0,L.Qq)("embedding_model"),userId:(0,L.Qq)("user_id").references(()=>m.VV.id,{onDelete:"cascade"}),...R.AP}),U=(0,u.cJ)("rag_eval_evaluation_records",{id:(0,A.nd)("id").generatedAlwaysAsIdentity().primaryKey(),question:(0,L.Qq)("question").notNull(),answer:(0,L.Qq)("answer"),context:(0,L.Qq)("context").array(),ideal:(0,L.Qq)("ideal"),status:(0,L.Qq)("status").$defaultFn(()=>I.x1.Pending),error:(0,D.Fx)("error"),languageModel:(0,L.Qq)("language_model"),embeddingModel:(0,L.Qq)("embedding_model"),questionEmbeddingId:(0,O.uR)("question_embedding_id").references(()=>T.VV.id,{onDelete:"set null"}),duration:(0,A.nd)("duration"),datasetRecordId:(0,A.nd)("dataset_record_id").references(()=>f.id,{onDelete:"cascade"}).notNull(),evaluationId:(0,A.nd)("evaluation_id").references(()=>b.id,{onDelete:"cascade"}).notNull(),userId:(0,L.Qq)("user_id").references(()=>m.VV.id,{onDelete:"cascade"}),...R.AP});var h=n(75453),C=n(88748),F=n(13151);let S=JSON.parse('[{"sql":["CREATE TABLE IF NOT EXISTS \\"agents\\" (\\n\\t\\"id\\" text PRIMARY KEY NOT NULL,\\n\\t\\"slug\\" varchar(100),\\n\\t\\"title\\" text,\\n\\t\\"description\\" text,\\n\\t\\"tags\\" jsonb DEFAULT \'[]\'::jsonb,\\n\\t\\"avatar\\" text,\\n\\t\\"background_color\\" text,\\n\\t\\"plugins\\" jsonb DEFAULT \'[]\'::jsonb,\\n\\t\\"user_id\\" text NOT NULL,\\n\\t\\"chat_config\\" jsonb,\\n\\t\\"few_shots\\" jsonb,\\n\\t\\"model\\" text,\\n\\t\\"params\\" jsonb DEFAULT \'{}\'::jsonb,\\n\\t\\"provider\\" text,\\n\\t\\"system_role\\" text,\\n\\t\\"tts\\" jsonb,\\n\\t\\"created_at\\" timestamp with time zone DEFAULT now() NOT NULL,\\n\\t\\"updated_at\\" timestamp with time zone DEFAULT now() NOT NULL,\\n\\tCONSTRAINT \\"agents_slug_unique\\" UNIQUE(\\"slug\\")\\n);\\n","\\nCREATE TABLE IF NOT EXISTS \\"agents_tags\\" (\\n\\t\\"agent_id\\" text NOT NULL,\\n\\t\\"tag_id\\" integer NOT NULL,\\n\\tCONSTRAINT \\"agents_tags_agent_id_tag_id_pk\\" PRIMARY KEY(\\"agent_id\\",\\"tag_id\\")\\n);\\n","\\nCREATE TABLE IF NOT EXISTS \\"agents_to_sessions\\" (\\n\\t\\"agent_id\\" text NOT NULL,\\n\\t\\"session_id\\" text NOT NULL,\\n\\tCONSTRAINT \\"agents_to_sessions_agent_id_session_id_pk\\" PRIMARY KEY(\\"agent_id\\",\\"session_id\\")\\n);\\n","\\nCREATE TABLE IF NOT EXISTS \\"files\\" (\\n\\t\\"id\\" text PRIMARY KEY NOT NULL,\\n\\t\\"user_id\\" text NOT NULL,\\n\\t\\"file_type\\" varchar(255) NOT NULL,\\n\\t\\"name\\" text NOT NULL,\\n\\t\\"size\\" integer NOT NULL,\\n\\t\\"url\\" text NOT NULL,\\n\\t\\"metadata\\" jsonb,\\n\\t\\"created_at\\" timestamp with time zone DEFAULT now() NOT NULL,\\n\\t\\"updated_at\\" timestamp with time zone DEFAULT now() NOT NULL\\n);\\n","\\nCREATE TABLE IF NOT EXISTS \\"files_to_agents\\" (\\n\\t\\"file_id\\" text NOT NULL,\\n\\t\\"agent_id\\" text NOT NULL,\\n\\tCONSTRAINT \\"files_to_agents_file_id_agent_id_pk\\" PRIMARY KEY(\\"file_id\\",\\"agent_id\\")\\n);\\n","\\nCREATE TABLE IF NOT EXISTS \\"files_to_messages\\" (\\n\\t\\"file_id\\" text NOT NULL,\\n\\t\\"message_id\\" text NOT NULL,\\n\\tCONSTRAINT \\"files_to_messages_file_id_message_id_pk\\" PRIMARY KEY(\\"file_id\\",\\"message_id\\")\\n);\\n","\\nCREATE TABLE IF NOT EXISTS \\"files_to_sessions\\" (\\n\\t\\"file_id\\" text NOT NULL,\\n\\t\\"session_id\\" text NOT NULL,\\n\\tCONSTRAINT \\"files_to_sessions_file_id_session_id_pk\\" PRIMARY KEY(\\"file_id\\",\\"session_id\\")\\n);\\n","\\nCREATE TABLE IF NOT EXISTS \\"user_installed_plugins\\" (\\n\\t\\"user_id\\" text NOT NULL,\\n\\t\\"identifier\\" text NOT NULL,\\n\\t\\"type\\" text NOT NULL,\\n\\t\\"manifest\\" jsonb,\\n\\t\\"settings\\" jsonb,\\n\\t\\"custom_params\\" jsonb,\\n\\t\\"created_at\\" timestamp with time zone DEFAULT now() NOT NULL,\\n\\t\\"updated_at\\" timestamp with time zone DEFAULT now() NOT NULL,\\n\\tCONSTRAINT \\"user_installed_plugins_user_id_identifier_pk\\" PRIMARY KEY(\\"user_id\\",\\"identifier\\")\\n);\\n","\\nCREATE TABLE IF NOT EXISTS \\"market\\" (\\n\\t\\"id\\" seri
1al PRIMARY KEY NOT NULL,\\n\\t\\"agent_id\\" text,\\n\\t\\"plugin_id\\" integer,\\n\\t\\"type\\" text NOT NULL,\\n\\t\\"view\\" integer DEFAULT 0,\\n\\t\\"like\\" integer DEFAULT 0,\\n\\t\\"used\\" integer DEFAULT 0,\\n\\t\\"user_id\\" text NOT NULL,\\n\\t\\"created_at\\" timestamp with time zone DEFAULT now() NOT NULL,\\n\\t\\"updated_at\\" timestamp with time zone DEFAULT now() NOT NULL\\n);\\n","\\nCREATE TABLE IF NOT EXISTS \\"message_plugins\\" (\\n\\t\\"id\\" text PRIMARY KEY NOT NULL,\\n\\t\\"tool_call_id\\" text,\\n\\t\\"type\\" text DEFAULT \'default\',\\n\\t\\"api_name\\" text,\\n\\t\\"arguments\\" text,\\n\\t\\"identifier\\" text,\\n\\t\\"state\\" jsonb,\\n\\t\\"error\\" jsonb\\n);\\n","\\nCREATE TABLE IF NOT EXISTS \\"message_tts\\" (\\n\\t\\"id\\" text PRIMARY KEY NOT NULL,\\n\\t\\"content_md5\\" text,\\n\\t\\"file_id\\" text,\\n\\t\\"voice\\" text\\n);\\n","\\nCREATE TABLE IF NOT EXISTS \\"message_translates\\" (\\n\\t\\"id\\" text PRIMARY KEY NOT NULL,\\n\\t\\"content\\" text,\\n\\t\\"from\\" text,\\n\\t\\"to\\" text\\n);\\n","\\nCREATE TABLE IF NOT EXISTS \\"messages\\" (\\n\\t\\"id\\" text PRIMARY KEY NOT NULL,\\n\\t\\"role\\" text NOT NULL,\\n\\t\\"content\\" text,\\n\\t\\"model\\" text,\\n\\t\\"provider\\" text,\\n\\t\\"favorite\\" boolean DEFAULT false,\\n\\t\\"error\\" jsonb,\\n\\t\\"tools\\" jsonb,\\n\\t\\"trace_id\\" text,\\n\\t\\"observation_id\\" text,\\n\\t\\"user_id\\" text NOT NULL,\\n\\t\\"session_id\\" text,\\n\\t\\"topic_id\\" text,\\n\\t\\"parent_id\\" text,\\n\\t\\"quota_id\\" text,\\n\\t\\"agent_id\\" text,\\n\\t\\"created_at\\" timestamp with time zone DEFAULT now() NOT NULL,\\n\\t\\"updated_at\\" timestamp with time zone DEFAULT now() NOT NULL\\n);\\n","\\nCREATE TABLE IF NOT EXISTS \\"plugins\\" (\\n\\t\\"id\\" serial PRIMARY KEY NOT NULL,\\n\\t\\"identifier\\" text NOT NULL,\\n\\t\\"title\\" text NOT NULL,\\n\\t\\"description\\" text,\\n\\t\\"avatar\\" text,\\n\\t\\"author\\" text,\\n\\t\\"manifest\\" text NOT NULL,\\n\\t\\"locale\\" text NOT NULL,\\n\\t\\"created_at\\" timestamp with time zone DEFAULT now() NOT NULL,\\n\\t\\"updated_at\\" timestamp with time zone DEFAULT now() NOT NULL,\\n\\tCONSTRAINT \\"plugins_identifier_unique\\" UNIQUE(\\"identifier\\")\\n);\\n","\\nCREATE TABLE IF NOT EXISTS \\"plugins_tags\\" (\\n\\t\\"plugin_id\\" integer NOT NULL,\\n\\t\\"tag_id\\" integer NOT NULL,\\n\\tCONSTRAINT \\"plugins_tags_plugin_id_tag_id_pk\\" PRIMARY KEY(\\"plugin_id\\",\\"tag_id\\")\\n);\\n","\\nCREATE TABLE IF NOT EXISTS \\"session_groups\\" (\\n\\t\\"id\\" text PRIMARY KEY NOT NULL,\\n\\t\\"name\\" text NOT NULL,\\n\\t\\"sort\\" integer,\\n\\t\\"user_id\\" text NOT NULL,\\n\\t\\"created_at\\" timestamp with time zone DEFAULT now() NOT NULL,\\n\\t\\"updated_at\\" timestamp with time zone DEFAULT now() NOT NULL\\n);\\n","\\nCREATE TABLE IF NOT EXISTS \\"sessions\\" (\\n\\t\\"id\\" text PRIMARY KEY NOT NULL,\\n\\t\\"slug\\" varchar(100) NOT NULL,\\n\\t\\"title\\" text,\\n\\t\\"description\\" text,\\n\\t\\"avatar\\" text,\\n\\t\\"background_color\\" text,\\n\\t\\"type\\" text DEFAULT \'agent\',\\n\\t\\"user_id\\" text NOT NULL,\\n\\t\\"group_id\\" text,\\n\\t\\"pinned\\" boolean DEFAULT false,\\n\\t\\"created_at\\" timestamp with time zone DEFAULT now() NOT NULL,\\n\\t\\"updated_at\\" timestamp with time zone DEFAULT now() NOT NULL\\n);\\n","\\nCREATE TABLE IF NOT EXISTS \\"tags\\" (\\n\\t\\"id\\" serial PRIMARY KEY NOT NULL,\\n\\t\\"slug\\" text NOT NULL,\\n\\t\\"name\\" text,\\n\\t\\"user_id\\" text NOT NULL,\\n\\t\\"created_at\\" timestamp with time zone DEFAULT now() NOT NULL,\\n\\t\\"updated_at\\" timestamp with time zone DEFAULT now() NOT NULL,\\n\\tCONSTRAINT \\"tags_slug_unique\\" UNIQUE(\\"slug\\")\\n);\\n","\\nCREATE TABLE IF NOT EXISTS \\"topics\\" (\\n\\t\\"id\\" text PRIMARY KEY NOT NULL,\\n\\t\\"session_id\\" text,\\n\\t\\"user_id\\" text NOT NULL,\\n\\t\\"favorite\\" boolean DEFAULT false,\\n\\t\\"title\\" text,\\n\\t\\"created_at\\" timestamp with time zone DEFAULT now() NOT NULL,\\n\\t\\"updated_at\\" timestamp with time zone DEFAULT now() NOT NULL\\n);
1\\n","\\nCREATE TABLE IF NOT EXISTS \\"user_settings\\" (\\n\\t\\"id\\" text PRIMARY KEY NOT NULL,\\n\\t\\"tts\\" jsonb,\\n\\t\\"key_vaults\\" text,\\n\\t\\"general\\" jsonb,\\n\\t\\"language_model\\" jsonb,\\n\\t\\"system_agent\\" jsonb,\\n\\t\\"default_agent\\" jsonb,\\n\\t\\"tool\\" jsonb\\n);\\n","\\nCREATE TABLE IF NOT EXISTS \\"users\\" (\\n\\t\\"id\\" text PRIMARY KEY NOT NULL,\\n\\t\\"username\\" text,\\n\\t\\"email\\" text,\\n\\t\\"avatar\\" text,\\n\\t\\"phone\\" text,\\n\\t\\"first_name\\" text,\\n\\t\\"last_name\\" text,\\n\\t\\"is_onboarded\\" boolean DEFAULT false,\\n\\t\\"clerk_created_at\\" timestamp with time zone,\\n\\t\\"preference\\" jsonb DEFAULT \'{\\"guide\\":{\\"moveSettingsToAvatar\\":true,\\"topic\\":true},\\"telemetry\\":null,\\"useCmdEnterToSend\\":false}\'::jsonb,\\n\\t\\"created_at\\" timestamp with time zone DEFAULT now() NOT NULL,\\n\\t\\"updated_at\\" timestamp with time zone DEFAULT now() NOT NULL,\\n\\t\\"key\\" text,\\n\\tCONSTRAINT \\"users_username_unique\\" UNIQUE(\\"username\\")\\n);\\n","\\nDO $$ BEGIN\\n ALTER TABLE \\"agents\\" ADD CONSTRAINT \\"agents_user_id_users_id_fk\\" FOREIGN KEY (\\"user_id\\") REFERENCES \\"public\\".\\"users\\"(\\"id\\") ON DELETE cascade ON UPDATE no action;\\nEXCEPTION\\n WHEN duplicate_object THEN null;\\nEND $$;\\n","\\nDO $$ BEGIN\\n ALTER TABLE \\"agents_tags\\" ADD CONSTRAINT \\"agents_tags_agent_id_agents_id_fk\\" FOREIGN KEY (\\"agent_id\\") REFERENCES \\"public\\".\\"agents\\"(\\"id\\") ON DELETE cascade ON UPDATE no action;\\nEXCEPTION\\n WHEN duplicate_object THEN null;\\nEND $$;\\n","\\nDO $$ BEGIN\\n ALTER TABLE \\"agents_tags\\" ADD CONSTRAINT \\"agents_tags_tag_id_tags_id_fk\\" FOREIGN KEY (\\"tag_id\\") REFERENCES \\"public\\".\\"tags\\"(\\"id\\") ON DELETE cascade ON UPDATE no action;\\nEXCEPTION\\n WHEN duplicate_object THEN null;\\nEND $$;\\n","\\nDO $$ BEGIN\\n ALTER TABLE \\"agents_to_sessions\\" ADD CONSTRAINT \\"agents_to_sessions_agent_id_agents_id_fk\\" FOREIGN KEY (\\"agent_id\\") REFERENCES \\"public\\".\\"agents\\"(\\"id\\") ON DELETE cascade ON UPDATE no action;\\nEXCEPTION\\n WHEN duplicate_object THEN null;\\nEND $$;\\n","\\nDO $$ BEGIN\\n ALTER TABLE \\"agents_to_sessions\\" ADD CONSTRAINT \\"agents_to_sessions_session_id_sessions_id_fk\\" FOREIGN KEY (\\"session_id\\") REFERENCES \\"public\\".\\"sessions\\"(\\"id\\") ON DELETE cascade ON UPDATE no action;\\nEXCEPTION\\n WHEN duplicate_object THEN null;\\nEND $$;\\n","\\nDO $$ BEGIN\\n ALTER TABLE \\"files\\" ADD CONSTRAINT \\"files_user_id_users_id_fk\\" FOREIGN KEY (\\"user_id\\") REFERENCES \\"public\\".\\"users\\"(\\"id\\") ON DELETE cascade ON UPDATE no action;\\nEXCEPTION\\n WHEN duplicate_object THEN null;\\nEND $$;\\n","\\nDO $$ BEGIN\\n ALTER TABLE \\"files_to_agents\\" ADD CONSTRAINT \\"files_to_agents_file_id_files_id_fk\\" FOREIGN KEY (\\"file_id\\") REFERENCES \\"public\\".\\"files\\"(\\"id\\") ON DELETE cascade ON UPDATE no action;\\nEXCEPTION\\n WHEN duplicate_object THEN null;\\nEND $$;\\n","\\nDO $$ BEGIN\\n ALTER TABLE \\"files_to_agents\\" ADD CONSTRAINT \\"files_to_agents_agent_id_agents_id_fk\\" FOREIGN KEY (\\"agent_id\\") REFERENCES \\"public\\".\\"agents\\"(\\"id\\") ON DELETE cascade ON UPDATE no action;\\nEXCEPTION\\n WHEN duplicate_object THEN null;\\nEND $$;\\n","\\nDO $$ BEGIN\\n ALTER TABLE \\"files_to_messages\\" ADD CONSTRAINT \\"files_to_messages_file_id_files_id_fk\\" FOREIGN KEY (\\"file_id\\") REFERENCES \\"public\\".\\"files\\"(\\"id\\") ON DELETE cascade ON UPDATE no action;\\nEXCEPTION\\n WHEN duplicate_object THEN null;\\nEND $$;\\n","\\nDO $$ BEGIN\\n ALTER TABLE \\"files_to_messages\\" ADD CONSTRAINT \\"files_to_messages_message_id_messages_id_fk\\" FOREIGN KEY (\\"message_id\\") REFERENCES \\"public\\".\\"messages\\"(\\"id\\") ON DELETE cascade ON UPDATE no action;\\nEXCEPTION\\n WHEN duplicate_object THEN null;\\nEND $$;\\n","\\nDO $$ BEGIN\\n ALTER TABLE \\"files_to_sessions\\" ADD CONSTRAINT \\"files_to_sessions_file_id_files_id_fk\\" FOREIGN KEY (\\"file_id\\") REFERENCES \\"public\\".\\"files\\"(\\"id\\") ON DELETE cascade ON UPDATE no action;\\nEXCEPTION\\n WHEN duplicate_object THEN null;\\nEND $$;\\n","\\nDO $$ BEGIN\\n ALTER TABLE \\"files_to_sessions\\" ADD CONSTRAINT \\"files_to_sessions_session_id_sessions_id_fk\\" FOREIGN KEY (\\"session_id\\") REFERENCES \\"public\\".\\"sessions\\"(\\"id\\") ON DELETE cascade ON UPDATE no action;\\nEXCEPTION\\n WHEN duplicate_object THEN null;\\nEND $$;\\n","\\nDO $$ BEGIN\\n ALTER TABLE \\"user_installed_plugins\\" ADD CONSTRAINT \\"user_installed_plugins_user_id_users_id_fk\\" FOREIGN KEY (\\"user_id\\") REFERENCES \\"public\\".\\"users\\"(\\"id\\") ON DELETE cascade ON UPDATE no action;\\nEXCEPTION\\n WHEN duplicate_object THEN null;\\nEND $$;\\n","\\nDO $$ BEGIN\\n ALTER TABLE \\"market\\" ADD CONSTRAINT \\"market_agent_id_agents_id_fk\\" FOREIGN KEY (\\"agent_id\\") REFERENCES \\"public\\".\\"agents\\"(\\"id\\") ON DELETE cascade ON UPDATE no action;\\nEXCEPTION\\n WHEN duplicate_object THEN null;\\nEND $$;\\n","\\nDO $$ BEGIN\\n ALTER TABLE \\"market\\" ADD CONSTRAINT \\"market_plugin_id_plugins_id_fk\\" FOREIGN KEY (\\"plugin_id\\") REFERENCES \\"public\\".\\"plugins\\"(\\"id\\") ON DELETE cascade ON UPDATE no action;\\nEXCEPTION\\n WHEN duplicate_object THEN null;\\nEND $$;\\n","\\nDO $$ BEGIN\\n ALTER TABLE \\"market\\" ADD CONSTRAINT \\"market_user_id_users_id_fk\\" FOREIGN KEY (\\"user_id\\") REFERENCES \\"public\\".\\"users\\"(\\"id\\") ON DELETE cascade ON UPDATE no action;\\nEXCEPTION\\n WHEN duplicate_object THEN null;\\nEND $$;\\n","\\nDO $$ BEGIN\\n ALTER TABLE \\"message_plugins\\" ADD CONSTRAINT \\"message_plugins_id_messages_id_fk\\" FOREIGN KEY (\\"id\\") REFERENCES \\"public\\".\\"messages\\"(\\"id\\") ON DELETE cascade ON UPDATE no action;\\nEXCEPTION\\n WHEN duplicate_object THEN null;\\nEND $$;\\n","\\nDO $$ BEGIN\\n ALTER TABLE \\"message_tts\\" ADD CONSTRAINT \\"message_tts_id_messages_id_fk\\" FOREIGN KEY (\\"id\\") REFERENCES \\"public\\".\\"messages\\"(\\"id\\") ON DELETE cascade ON UPDATE no action;\\nEXCEPTION\\n WHEN duplicate_object THEN null;\\nEND $$;\\n","\\nDO $$ BEGIN\\n ALTER TABLE \\"message_tts\\" ADD CONSTRAINT \\"message_tts_file_id_files_id_fk\\" FOREIGN KEY (\\"file_id\\") REFERENCES \\"public\\".\\"files\\"(\\"id\\") ON DELETE cascade ON UPDATE no action;\\nEXCEPTION\\n WHEN duplicate_object THEN null;\\nEND $$;\\n","\\nDO $$ BEGIN\\n ALTER TABLE \\"message_translates\\" ADD CONSTRAINT \\"message_translates_id_messages_id_fk\\" FOREIGN KEY (\\"id\\") REFERENCES \\"public\\".\\"messages\\"(\\"id\\") ON DELETE cascade ON UPDATE no action;\\nEXCEPTION\\n WHEN duplicate_object THEN null;\\nEND $$;\\n","\\nDO $$ BEGIN\\n ALTER TABLE \\"messages\\" ADD CONSTRAINT \\"messages_user_id_users_id_fk\\" FOREIGN KEY (\\"user_id\\") REFERENCES \\"public\\".\\"users\\"(\\"id\\") ON DELETE cascade ON UPDATE no action;\\nEXCEPTION\\n WHEN duplicate_object THEN null;\\nEND $$;\\n","\\nDO $$ BEGIN\\n ALTER TABLE \\"messages\\" ADD CONSTRAINT \\"messages_session_id_sessions_id_fk\\" FOREIGN KEY (\\"session_id\\") REFERENCES \\"public\\".\\"sessions\\"(\\"id\\") ON DELETE cascade ON UPDATE no action;\\nEXCEPTION\\n WHEN duplicate_object THEN null;\\nEND $$;\\n","\\nDO $$ BEGIN\\n ALTER TABLE \\"messages\\" ADD CONSTRAINT \\"messages_topic_id_topics_id_fk\\" FOREIGN KEY (\\"topic_id\\") REFERENCES \\"public\\".\\"topics\\"(\\"id\\") ON DELETE cascade ON UPDATE no action;\\nEXCEPTION\\n WHEN duplicate_object THEN null;\\nEND $$;\\n","\\nDO $$ BEGIN\\n ALTER TABLE \\"messages\\" ADD CONSTRAINT \\"messages_parent_id_messages_id_fk\\" FOREIGN KEY (\\"parent_id\\") REFERENCES \\"public\\".\\"messages\\"(\\"id\\") ON DELETE set null ON UPDATE no action;\\nEXCEPTION\\n WHEN duplicate_object THEN null;\\nEND $$;\\n","\\nDO $$ BEGIN\\n ALTER TABLE \\"messages\\" ADD CONSTRAINT \\"messages_quota_id_messages_id_fk\\" FOREIGN KEY (\\"quota_id\\") REFERENCES \\"public\\".\\"messages\\"(\\"id\\") ON DELETE set null ON UPDATE no action;\\nEXCEPTION\\n WHEN duplicate_object THEN null;\\nEND $$;\\n","\\nDO $$ BEGIN\\n ALTER TABLE \\"messages\\" ADD CONSTRAINT \\"messages_agent_id_agents_id_fk\\" FOREIGN KEY (\\"agent_id\\") REFERENCES \\"public\\".\\"agents\\"(\\"id\\") ON DELETE set null ON UPDATE no action;\\nEXCEPTION\\n WHEN duplicate_object THEN null;\\nEND $$;\\n","\\nDO $$ BEGIN\\n ALTER TABLE \\"plugins_tags\\" ADD CONSTRAINT \\"plugins_tags_plugin_id_plugins_id_fk\\" FOREIGN KEY (\\"plugin_id\\") REFERENCES \\"public\\".\\"plugins\\"(\\"id\\") ON DELETE cascade ON UPDATE no action;\\nEXCEPTION\\n WHEN duplicate_object THEN null;\\nEND $$;\\n","\\nDO $$ BEGIN\\n ALTER TABLE \\"plugins_tags\\" ADD CONSTRAINT \\"plugins_tags_tag_id_tags_id_fk\\" FOREIGN KEY (\\"tag_id\\") REFERENCES \\"public\\".\\"tags\\"(\\"id\\") ON DELETE cascade ON UPDATE no action;\\nEXCEPTION\\n WHEN duplicate_object THEN null;\\nEND $$;\\n","\\nDO $$ BEGIN\\n ALTER TABLE \\"session_groups\\" ADD CONSTRAINT \\"session_groups_user_id_users_id_fk\\" FOREIGN KEY (\\"user_id\\") REFERENCES \\"public\\".\\"users\\"(\\"id\\") ON DELETE cascade ON UPDATE no action;\\nEXCEPTION\\n WHEN duplicate_object THEN null;\\nEND $$;\\n","\\nDO $$ BEGIN\\n ALTER TABLE \\"sessions\\" ADD CONSTRAINT \\"sessions_user_id_users_id_fk\\" FOREIGN KEY (\\"user_id\\") REFERENCES \\"public\\".\\"users\\"(\\"id\\") ON DELETE cascade ON UPDATE no action;\\nEXCEPTION\\n WHEN duplicate_object THEN null;\\nEND $$;\\n","\\nDO $$ BEGIN\\n ALTER TABLE \\"sessions\\" ADD CONSTRAINT \\"sessions_group_id_session_groups_id_fk\\" FOREIGN KEY (\\"group_id\\") REFERENCES \\"public\\".\\"session_groups\\"(\\"id\\") ON DELETE set null ON UPDATE no action;\\nEXCEPTION\\n WHEN duplicate_object THEN null;\\nEND $$;\\n","\\nDO $$ BEGIN\\n ALTER TABLE \\"tags\\" ADD CONSTRAINT \\"tags_user_id_users_id_fk\\" FOREIGN KEY (\\"user_id\\") REFERENCES \\"public\\".\\"users\\"(\\"id\\") ON DELETE cascade ON UPDATE no action;\\nEXCEPTION\\n WHEN duplicate_object THEN null;\\nEND $$;\\n","\\nDO $$ BEGIN\\n ALTER TABLE \\"topics\\" ADD CONSTRAINT \\"to
1pics_session_id_sessions_id_fk\\" FOREIGN KEY (\\"session_id\\") REFERENCES \\"public\\".\\"sessions\\"(\\"id\\") ON DELETE cascade ON UPDATE no action;\\nEXCEPTION\\n WHEN duplicate_object THEN null;\\nEND $$;\\n","\\nDO $$ BEGIN\\n ALTER TABLE \\"topics\\" ADD CONSTRAINT \\"topics_user_id_users_id_fk\\" FOREIGN KEY (\\"user_id\\") REFERENCES \\"public\\".\\"users\\"(\\"id\\") ON DELETE cascade ON UPDATE no action;\\nEXCEPTION\\n WHEN duplicate_object THEN null;\\nEND $$;\\n","\\nDO $$ BEGIN\\n ALTER TABLE \\"user_settings\\" ADD CONSTRAINT \\"user_settings_id_users_id_fk\\" FOREIGN KEY (\\"id\\") REFERENCES \\"public\\".\\"users\\"(\\"id\\") ON DELETE cascade ON UPDATE no action;\\nEXCEPTION\\n WHEN duplicate_object THEN null;\\nEND $$;\\n","\\nCREATE INDEX IF NOT EXISTS \\"messages_created_at_idx\\" ON \\"messages\\" (\\"created_at\\");","\\nCREATE UNIQUE INDEX IF NOT EXISTS \\"slug_user_id_unique\\" ON \\"sessions\\" (\\"slug\\",\\"user_id\\");\\n"],"bps":true,"folderMillis":1716982944425,"hash":"1513c1da50dc083fc0bd9783fe88c60e4fa80b60db645aa87bfda54332252c65"},{"sql":["ALTER TABLE \\"messages\\" ADD COLUMN \\"client_id\\" text;","\\nALTER TABLE \\"session_groups\\" ADD COLUMN \\"client_id\\" text;","\\nALTER TABLE \\"sessions\\" ADD COLUMN \\"client_id\\" text;","\\nALTER TABLE \\"topics\\" ADD COLUMN \\"client_id\\" text;","\\nCREATE INDEX IF NOT EXISTS \\"messages_client_id_idx\\" ON \\"messages\\" (\\"client_id\\");","\\nALTER TABLE \\"messages\\" ADD CONSTRAINT \\"messages_client_id_unique\\" UNIQUE(\\"client_id\\");","\\nALTER TABLE \\"session_groups\\" ADD CONSTRAINT \\"session_groups_client_id_unique\\" UNIQUE(\\"client_id\\");","\\nALTER TABLE \\"sessions\\" ADD CONSTRAINT \\"sessions_client_id_unique\\" UNIQUE(\\"client_id\\");","\\nALTER TABLE \\"topics\\" ADD CONSTRAINT \\"topics_client_id_unique\\" UNIQUE(\\"client_id\\");\\n"],"bps":true,"folderMillis":1717153686544,"hash":"ddb29ee7e7a675c12b44996e4be061b1736e8f785052242801f4cdfb2a94f258"},{"sql":["ALTER TABLE \\"messages\\" DROP CONSTRAINT \\"messages_client_id_unique\\";","\\nALTER TABLE \\"session_groups\\" DROP CONSTRAINT \\"session_groups_client_id_unique\\";","\\nALTER TABLE \\"sessions\\" DROP CONSTRAINT \\"sessions_client_id_unique\\";","\\nALTER TABLE \\"topics\\" DROP CONSTRAINT \\"topics_client_id_unique\\";","\\nDROP INDEX IF EXISTS \\"messages_client_id_idx\\";","\\nCREATE UNIQUE INDEX IF NOT EXISTS \\"message_client_id_user_unique\\" ON \\"messages\\" (\\"client_id\\",\\"user_id\\");","\\nALTER TABLE \\"session_groups\\" ADD CONSTRAINT \\"session_group_client_id_user_unique\\" UNIQUE(\\"client_id\\",\\"user_id\\");","\\nALTER TABLE \\"sessions\\" ADD CONSTRAINT \\"sessions_client_id_user_id_unique\\" UNIQUE(\\"client_id\\",\\"user_id\\");","\\nALTER TABLE \\"topics\\" ADD CONSTRAINT \\"topic_client_id_user_id_unique\\" UNIQUE(\\"client_id\\",\\"user_id\\");"],"bps":true,"folderMillis":1717587734458,"hash":"90b61fc3e744d8e2609418d9e25274ff07af4caf87370bb614db511d67900d73"},{"sql":["CREATE TABLE IF NOT EXISTS \\"user_budgets\\" (\\n\\t\\"id\\" text PRIMARY KEY NOT NULL,\\n\\t\\"free_budget_id\\" text,\\n\\t\\"free_budget_key\\" text,\\n\\t\\"subscription_budget_id\\" text,\\n\\t\\"subscription_budget_key\\" text,\\n\\t\\"package_budget_id\\" text,\\n\\t\\"package_budget_key\\" text,\\n\\t\\"created_at\\" timestamp with time zone DEFAULT now() NOT NULL,\\n\\t\\"updated_at\\" timestamp with time zone DEFAULT now() NOT NULL\\n);\\n","\\nCREATE TABLE IF NOT EXISTS \\"user_subscriptions\\" (\\n\\t\\"id\\" text PRIMARY KEY NOT NULL,\\n\\t\\"user_id\\" text NOT NULL,\\n\\t\\"stripe_id\\" text,\\n\\t\\"currency\\" text,\\n\\t\\"pricing\\" integer,\\n\\t\\"billing_paid_at\\" integer,\\n\\t\\"billing_cycle_start\\" integer,\\n\\t\\"billing_cycle_end\\" integer,\\n\\t\\"cancel_at_period_end\\" boolean,\\n\\t\\"cancel_at\\" integer,\\n\\t\\"next_billing\\" jsonb,\\n\\t\\"plan\\" text,\\n\\t\\"recurring\\" text,\\n\\t\\"storage_limit\\" integer,\\n\\t\\"status\\" integer,\\n\\t\\"created_at\\" timestamp with time zone DEFAULT now() NOT NULL,\\n\\t\\"updated_at\\" timestamp with time zone DEFAULT now() NOT NULL\\n);\\n","\\nALTER TABLE \\"users\\" ALTER COLUMN \\"preference\\" DROP DEFAULT;","\\nDO $$ BEGIN\\n ALTER TABLE \\"user_budgets\\" ADD CONSTRAINT \\"user_budgets_id_users_id_fk\\" FOREIGN KEY (\\"id\\") REFERENCES \\"public\\".\\"users\\"(\\"id\\") ON DELETE cascade ON UPDATE no action;\\nEXCEPTION\\n WHEN duplicate_object THEN null;\\nEND $$;\\n","\\nDO $$ BEGIN\\n ALTER TABLE \\"user_subscriptions\\" ADD CONSTRAINT \\"user_subscriptions_user_id_users_id_fk\\" FOREIGN KEY (\\"user_id\\") REFERENCES \\"public\\".\\"users\\"(\\"id\\") ON DELETE cascade ON UPDATE no action;\\nEXCEPTION\\n WHEN duplicate_object THEN null;\\nEND $$;\\n","\\nALTER TABLE \\"users\\" DROP COLUMN IF EXISTS \\"key\\";\\n"],"bps":true,"folderMillis":1718460779230,"hash":"535a9aba48be3d75762f29bbb195736f17abfe51f41a548debe925949dd0caf2"},{"sql":["CREATE TABLE IF NOT EXISTS \\"nextauth_accounts\\" (\\
1n\\t\\"access_token\\" text,\\n\\t\\"expires_at\\" integer,\\n\\t\\"id_token\\" text,\\n\\t\\"provider\\" text NOT NULL,\\n\\t\\"providerAccountId\\" text NOT NULL,\\n\\t\\"refresh_token\\" text,\\n\\t\\"scope\\" text,\\n\\t\\"session_state\\" text,\\n\\t\\"token_type\\" text,\\n\\t\\"type\\" text NOT NULL,\\n\\t\\"userId\\" text NOT NULL,\\n\\tCONSTRAINT \\"nextauth_accounts_provider_providerAccountId_pk\\" PRIMARY KEY(\\"provider\\",\\"providerAccountId\\")\\n);\\n","\\nCREATE TABLE IF NOT EXISTS \\"nextauth_authenticators\\" (\\n\\t\\"counter\\" integer NOT NULL,\\n\\t\\"credentialBackedUp\\" boolean NOT NULL,\\n\\t\\"credentialDeviceType\\" text NOT NULL,\\n\\t\\"credentialID\\" text NOT NULL,\\n\\t\\"credentialPublicKey\\" text NOT NULL,\\n\\t\\"providerAccountId\\" text NOT NULL,\\n\\t\\"transports\\" text,\\n\\t\\"userId\\" text NOT NULL,\\n\\tCONSTRAINT \\"nextauth_authenticators_userId_credentialID_pk\\" PRIMARY KEY(\\"userId\\",\\"credentialID\\"),\\n\\tCONSTRAINT \\"nextauth_authenticators_credentialID_unique\\" UNIQUE(\\"credentialID\\")\\n);\\n","\\nCREATE TABLE IF NOT EXISTS \\"nextauth_sessions\\" (\\n\\t\\"expires\\" timestamp NOT NULL,\\n\\t\\"sessionToken\\" text PRIMARY KEY NOT NULL,\\n\\t\\"userId\\" text NOT NULL\\n);\\n","\\nCREATE TABLE IF NOT EXISTS \\"nextauth_verificationtokens\\" (\\n\\t\\"expires\\" timestamp NOT NULL,\\n\\t\\"identifier\\" text NOT NULL,\\n\\t\\"token\\" text NOT NULL,\\n\\tCONSTRAINT \\"nextauth_verificationtokens_identifier_token_pk\\" PRIMARY KEY(\\"identifier\\",\\"token\\")\\n);\\n","\\nALTER TABLE \\"users\\" ADD COLUMN \\"full_name\\" text;","\\nALTER TABLE \\"users\\" ADD COLUMN \\"email_verified_at\\" timestamp with time zone;","\\nDO $$ BEGIN\\n ALTER TABLE \\"nextauth_accounts\\" ADD CONSTRAINT \\"nextauth_accounts_userId_users_id_fk\\" FOREIGN KEY (\\"userId\\") REFERENCES \\"public\\".\\"users\\"(\\"id\\") ON DELETE cascade ON UPDATE no action;\\nEXCEPTION\\n WHEN duplicate_object THEN null;\\nEND $$;\\n","\\nDO $$ BEGIN\\n ALTER TABLE \\"nextauth_authenticators\\" ADD CONSTRAINT \\"nextauth_authenticators_userId_users_id_fk\\" FOREIGN KEY (\\"userId\\") REFERENCES \\"public\\".\\"users\\"(\\"id\\") ON DELETE cascade ON UPDATE no action;\\nEXCEPTION\\n WHEN duplicate_object THEN null;\\nEND $$;\\n","\\nDO $$ BEGIN\\n ALTER TABLE \\"nextauth_sessions\\" ADD CONSTRAINT \\"nextauth_sessions_userId_users_id_fk\\" FOREIGN KEY (\\"userId\\") REFERENCES \\"public\\".\\"users\\"(\\"id\\") ON DELETE cascade ON UPDATE no action;\\nEXCEPTION\\n WHEN duplicate_object THEN null;\\nEND $$;\\n"],"bps":true,"folderMillis":1721724512422,"hash":"c63c5819d73414632ea32c543cfb997be31a2be3fad635c148c97e726c57fd16"},{"sql":["-- Custom SQL migration file, put you code below! --\\nCREATE EXTENSION IF NOT EXISTS vector;\\n"],"bps":true,"folderMillis":1722944166657,"hash":"c112a4eb471fa4efe791b250057a1e33040515a0c60361c7d7a59044ec9e1667"},{"sql":["CREATE TABLE IF NOT EXISTS \\"agents_files\\" (\\n\\t\\"file_id\\" text NOT NULL,\\n\\t\\"agent_id\\" text NOT NULL,\\n\\t\\"enabled\\" boolean DEFAULT true,\\n\\t\\"user_id\\" text NOT NULL,\\n\\t\\"created_at\\" timestamp with time zone DEFAULT now() NOT NULL,\\n\\t\\"updated_at\\" timestamp with time zone DEFAULT now() NOT NULL,\\n\\tCONSTRAINT \\"agents_files_f
1ile_id_agent_id_user_id_pk\\" PRIMARY KEY(\\"file_id\\",\\"agent_id\\",\\"user_id\\")\\n);\\n","\\nCREATE TABLE IF NOT EXISTS \\"agents_knowledge_bases\\" (\\n\\t\\"agent_id\\" text NOT NULL,\\n\\t\\"knowledge_base_id\\" text NOT NULL,\\n\\t\\"user_id\\" text NOT NULL,\\n\\t\\"enabled\\" boolean DEFAULT true,\\n\\t\\"created_at\\" timestamp with time zone DEFAULT now() NOT NULL,\\n\\t\\"updated_at\\" timestamp with time zone DEFAULT now() NOT NULL,\\n\\tCONSTRAINT \\"agents_knowledge_bases_agent_id_knowledge_base_id_pk\\" PRIMARY KEY(\\"agent_id\\",\\"knowledge_base_id\\")\\n);\\n","\\nCREATE TABLE IF NOT EXISTS \\"async_tasks\\" (\\n\\t\\"id\\" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,\\n\\t\\"type\\" text,\\n\\t\\"status\\" text,\\n\\t\\"error\\" jsonb,\\n\\t\\"user_id\\" text NOT NULL,\\n\\t\\"duration\\" integer,\\n\\t\\"created_at\\" timestamp with time zone DEFAULT now() NOT NULL,\\n\\t\\"updated_at\\" timestamp with time zone DEFAULT now() NOT NULL\\n);\\n","\\nCREATE TABLE IF NOT EXISTS \\"file_chunks\\" (\\n\\t\\"file_id\\" varchar,\\n\\t\\"chunk_id\\" uuid,\\n\\t\\"created_at\\" timestamp with time zone DEFAULT now() NOT NULL,\\n\\tCONSTRAINT \\"file_chunks_file_id_chunk_id_pk\\" PRIMARY KEY(\\"file_id\\",\\"chunk_id\\")\\n);\\n","\\nCREATE TABLE IF NOT EXISTS \\"global_files\\" (\\n\\t\\"hash_id\\" varchar(64) PRIMARY KEY NOT NULL,\\n\\t\\"file_type\\" varchar(255) NOT NULL,\\n\\t\\"size\\" integer NOT NULL,\\n\\t\\"url\\" text NOT NULL,\\n\\t\\"metadata\\" jsonb,\\n\\t\\"created_at\\" timestamp with time zone DEFAULT now() NOT NULL\\n);\\n","\\nCREATE TABLE IF NOT EXISTS \\"knowledge_base_files\\" (\\n\\t\\"knowledge_base_id\\" text NOT NULL,\\n\\t\\"file_id\\" text NOT NULL,\\n\\t\\"created_at\\" timestamp with time zone DEFAULT now() NOT NULL,\\n\\tCONSTRAINT \\"knowledge_base_files_knowledge_base_id_file_id_pk\\" PRIMARY KEY(\\"knowledge_base_id\\",\\"file_id\\")\\n);\\n","\\nCREATE TABLE IF NOT EXISTS \\"knowledge_bases\\" (\\n\\t\\"id\\" text PRIMARY KEY NOT NULL,\\n\\t\\"name\\" text NOT NULL,\\n\\t\\"description\\" text,\\n\\t\\"avatar\\" text,\\n\\t\\"type\\" text,\\n\\t\\"user_id\\" text NOT NULL,\\n\\t\\"is_public\\" boolean DEFAULT false,\\n\\t\\"settings\\" jsonb,\\n\\t\\"created_at\\" timestamp with time zone DEFAULT now() NOT NULL,\\n\\t\\"updated_at\\" timestamp with time zone DEFAULT now() NOT NULL\\n);\\n","\\nCREATE TABLE IF NOT EXISTS \\"message_chunks\\" (\\n\\t\\"message_id\\" text,\\n\\t\\"chunk_id\\" uuid,\\n\\tCONSTRAINT \\"message_chunks_chunk_id_message_id_pk\\" PRIMARY KEY(\\"chunk_id\\",\\"message_id\\")\\n);\\n","\\nCREATE TABLE IF NOT EXISTS \\"message_queries\\" (\\n\\t\\"id\\" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,\\n\\t\\"message_id\\" text NOT NULL,\\n\\t\\"rewrite_query\\" text,\\n\\t\\"user_query\\" text,\\n\\t\\"embeddings_id\\" uuid\\n);\\n","\\nCREATE TABLE IF NOT EXISTS \\"message_query_chunks\\" (\\n\\t\\"id\\" text,\\n\\t\\"query_id\\" uuid,\\n\\t\\"chunk_id\\" uuid,\\n\\t\\"similarity\\" numeric(6, 5),\\n\\tCONSTRAINT \\"message_query_chunks_chunk_id_id_query_id_pk\\" PRIMARY KEY(\\"chunk_id\\",\\"id\\",\\"query_id\\")\\n);\\n","\\nCREATE TABLE IF NOT EXISTS \\"chunks\\" (\\n\\t\\"id\\" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,\\n\\t\\"text\\" text,\\n\\t\\"abstract\\" text,\\n\\t\\"metadata\\" jsonb,\\n\\t\\"index\\" integer,\\n\\t\\"type\\" varchar,\\n\\t\\"created_at\\" timestamp with time zone DEFAULT now() NOT NULL,\\n\\t\\"updated_at\\" timestamp with time zone DEFAULT now() NOT NULL,\\n\\t\\"user_id\\" text\\n);\\n","\\nCREATE TABLE IF NOT EXISTS \\"embeddings\\" (\\n\\t\\"id\\" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,\\n\\t\\"chunk_id\\" uuid,\\n\\t\\"embeddings\\" vector(1024),\\n\\t\\"model\\" text,\\n\\t\\"user_id\\" text\\n);\\n","\\nCREATE TABLE IF NOT EXISTS \\"unstructured_chunks\\" (\\n\\t\\"id\\" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,\\n\\t\\"text\\" text,\\n\\t\\"metadata\\" jsonb,\\n\\t\\"index\\" integer,\\n\\t\\"type\\" varchar,\\n\\t\\"created_at\\" timestamp with time zone DEFAULT now() NOT NULL,\\n\\t\\"updated_at\\" timestamp with time zone DEFAULT now() NOT NULL,\\n\\t\\"parent_id\\" varchar,\\n\\t\\"composite_id\\" uuid,\\n\\t\\"user_id\\" text,\\n\\t\\"file_id\\" varchar\\n);\\n","\\nALTER TABLE \\"files_to_messages\\" RENAME TO \\"messages_files\\";","\\nDROP TABLE \\"files_to_agents\\";","\\nALTER TABLE \\"files\\" ADD COLUMN \\"file_hash\\" varchar(64);","\\nALTER TABLE \\"files\\" ADD COLUMN \\"chunk_task_id\\" uuid;","\\nALTER TABLE \\"files\\" ADD COLUMN \\"embedding_task_id\\" uuid;","\\nDO $$ BEGIN\\n ALTER TABLE \\"agents_files\\" ADD CONSTRAINT \\"agents_files_f
1ile_id_files_id_fk\\" FOREIGN KEY (\\"file_id\\") REFERENCES \\"public\\".\\"files\\"(\\"id\\") ON DELETE cascade ON UPDATE no action;\\nEXCEPTION\\n WHEN duplicate_object THEN null;\\nEND $$;\\n","\\nDO $$ BEGIN\\n ALTER TABLE \\"agents_files\\" ADD CONSTRAINT \\"agents_files_agent_id_agents_id_fk\\" FOREIGN KEY (\\"agent_id\\") REFERENCES \\"public\\".\\"agents\\"(\\"id\\") ON DELETE cascade ON UPDATE no action;\\nEXCEPTION\\n WHEN duplicate_object THEN null;\\nEND $$;\\n","\\nDO $$ BEGIN\\n ALTER TABLE \\"agents_files\\" ADD CONSTRAINT \\"agents_files_user_id_users_id_fk\\" FOREIGN KEY (\\"user_id\\") REFERENCES \\"public\\".\\"users\\"(\\"id\\") ON DELETE cascade ON UPDATE no action;\\nEXCEPTION\\n WHEN duplicate_object THEN null;\\nEND $$;\\n","\\nDO $$ BEGIN\\n ALTER TABLE \\"agents_knowledge_bases\\" ADD CONSTRAINT \\"agents_knowledge_bases_agent_id_agents_id_fk\\" FOREIGN KEY (\\"agent_id\\") REFERENCES \\"public\\".\\"agents\\"(\\"id\\") ON DELETE cascade ON UPDATE no action;\\nEXCEPTION\\n WHEN duplicate_object THEN null;\\nEND $$;\\n","\\nDO $$ BEGIN\\n ALTER TABLE \\"agents_knowledge_bases\\" ADD CONSTRAINT \\"agents_knowledge_bases_knowledge_base_id_knowledge_bases_id_fk\\" FOREIGN KEY (\\"knowledge_base_id\\") REFERENCES \\"public\\".\\"knowledge_bases\\"(\\"id\\") ON DELETE cascade ON UPDATE no action;\\nEXCEPTION\\n WHEN duplicate_object THEN null;\\nEND $$;\\n","\\nDO $$ BEGIN\\n ALTER TABLE \\"agents_knowledge_bases\\" ADD CONSTRAINT \\"agents_knowledge_bases_user_id_users_id_fk\\" FOREIGN KEY (\\"user_id\\") REFERENCES \\"public\\".\\"users\\"(\\"id\\") ON DELETE cascade ON UPDATE no action;\\nEXCEPTION\\n WHEN duplicate_object THEN null;\\nEND $$;\\n","\\nDO $$ BEGIN\\n ALTER TABLE \\"async_tasks\\" ADD CONSTRAINT \\"async_tasks_user_id_users_id_fk\\" FOREIGN KEY (\\"user_id\\") REFERENCES \\"public\\".\\"users\\"(\\"id\\") ON DELETE cascade ON UPDATE no action;\\nEXCEPTION\\n WHEN duplicate_object THEN null;\\nEND $$;\\n","\\nDO $$ BEGIN\\n ALTER TABLE \\"file_chunks\\" ADD CONSTRAINT \\"file_chunks_file_id_files_id_fk\\" FOREIGN KEY (\\"file_id\\") REFERENCES \\"public\\".\\"files\\"(\\"id\\") ON DELETE cascade ON UPDATE no action;\\nEXCEPTION\\n WHEN duplicate_object THEN null;\\nEND $$;\\n","\\nDO $$ BEGIN\\n ALTER TABLE \\"file_chunks\\" ADD CONSTRAINT \\"file_chunks_chunk_id_chunks_id_fk\\" FOREIGN KEY (\\"chunk_id\\") REFERENCES \\"public\\".\\"chunks\\"(\\"id\\") ON DELETE cascade ON UPDATE no action;\\nEXCEPTION\\n WHEN duplicate_object THEN null;\\nEND $$;\\n","\\nDO $$ BEGIN\\n ALTER TABLE \\"knowledge_base_files\\" ADD CONSTRAINT \\"knowledge_base_files_knowledge_base_id_knowledge_bases_id_fk\\" FOREIGN KEY (\\"knowledge_base_id\\") REFERENCES \\"public\\".\\"knowledge_bases\\"(\\"id\\") ON DELETE cascade ON UPDATE no action;\\nEXCEPTION\\n WHEN duplicate_object THEN null;\\nEND $$;\\n","\\nDO $$ BEGIN\\n ALTER TABLE \\"knowledge_base_files\\" ADD CONSTRAINT \\"knowledge_base_files_file_id_files_id_fk\\" FOREIGN KEY (\\"file_id\\") REFERENCES \\"public\\".\\"files\\"(\\"id\\") ON DELETE cascade ON UPDATE no action;\\nEXCEPTION\\n WHEN duplicate_object THEN null;\\nEND $$;\\n","\\nDO $$ BEGIN\\n ALTER TABLE \\"knowledge_bases\\" ADD CONSTRAINT \\"knowledge_bases_user_id_users_id_fk\\" FOREIGN KEY (\\"user_id\\") REFERENCES \\"public\\".\\"users\\"(\\"id\\") ON DELETE cascade ON UPDATE no action;\\nEXCEPTION\\n WHEN duplicate_object THEN null;\\nEND $$;\\n","\\nDO $$ BEGIN\\n ALTER TABLE \\"message_chunks\\" ADD CONSTRAINT \\"message_chunks_message_id_messages_id_fk\\" FOREIGN KEY (\\"message_id\\") REFERENCES \\"public\\".\\"messages\\"(\\"id\\") ON DELETE cascade ON UPDATE no action;\\nEXCEPTION\\n WHEN duplicate_object THEN null;\\nEND $$;\\n","\\nDO $$ BEGIN\\n ALTER TABLE \\"message_chunks\\" ADD CONSTRAINT \\"message_chunks_chunk_id_chunks_id_fk\\" FOREIGN KEY (\\"chunk_id\\") REFERENCES \\"public\\".\\"chunks\\"(\\"id\\") ON DELETE cascade ON UPDATE no action;\\nEXCEPTION\\n WHEN duplicate_object THEN null;\\nEND $$;\\n","\\nDO $$ BEGIN\\n ALTER TABLE \\"message_queries\\" ADD CONSTRAINT \\"message_queries_message_id_messages_id_fk\\" FOREIGN KEY (\\"message_id\\") REFERENCES \\"public\\".\\"messages\\"(\\"id\\") ON DELETE cascade ON UPDATE no action;\\nEXCEPTION\\n WHEN duplicate_object THEN null;\\nEND $$;\\n","\\nDO $$ BEGIN\\n ALTER TABLE \\"message_queries\\" ADD CONSTRAINT \\"message_queries_embeddings_id_embeddings_id_fk\\" FOREIGN KEY (\\"embeddings_id\\") REFERENCES \\"public\\".\\"embeddings\\"(\\"id\\") ON DELETE set null ON UPDATE no action;\\nEXCEPTION\\n WHEN duplicate_object THEN null;\\nEND $$;\\n","\\nDO $$ BEGIN\\n ALTER TABLE \\"message_query_chunks\\" ADD CONSTRAINT \\"message_query_chunks_id_messages_id_fk\\" FOREIGN KEY (\\"id\\") REFERENCES \\"public\\".\\"messages\\"(\\"id\\") ON DELETE cascade ON UPDATE no action;\\nEXCEPTION\\n WHEN duplicate_object THEN null;\\nEND $$;\\n","\\nDO $$ BEGIN\\n ALTER TABLE \\"message_query_chunks\\" ADD CONSTRAINT \\"message_query_chunks_query_id_message_queries_id_fk\\" FOREIGN KEY (\\"query_id\\") REFERENCES \\"public\\".\\"message_queries\\"(\\"id\\") ON DELETE cascade ON UPDATE no action;\\nEXCEPTION\\n WHEN duplicate_object THEN null;\\nEND $$;\\n","\\nDO $$ BEGIN\\n ALTER TABLE \\"message_query_chunks\\" ADD CONSTRAINT \\"message_query_chunks_chunk_id_chunks_id_fk\\" FOREIGN KEY (\\"chunk_id\\") REFERENCES \\"public\\".\\"chunks\\"(\\"id\\") ON DELETE cascade ON UPDATE no action;\\nEXCEPTION\\n WHEN duplicate_object THEN null;\\nEND $$;\\n","\\nDO $$ BEGIN\\n ALTER TABLE \\"messages_files\\" ADD CONSTRAINT \\"messages_files_f
1ile_id_files_id_fk\\" FOREIGN KEY (\\"file_id\\") REFERENCES \\"public\\".\\"files\\"(\\"id\\") ON DELETE cascade ON UPDATE no action;\\nEXCEPTION\\n WHEN duplicate_object THEN null;\\nEND $$;\\n","\\nDO $$ BEGIN\\n ALTER TABLE \\"messages_files\\" ADD CONSTRAINT \\"messages_files_message_id_messages_id_fk\\" FOREIGN KEY (\\"message_id\\") REFERENCES \\"public\\".\\"messages\\"(\\"id\\") ON DELETE cascade ON UPDATE no action;\\nEXCEPTION\\n WHEN duplicate_object THEN null;\\nEND $$;\\n","\\nDO $$ BEGIN\\n ALTER TABLE \\"chunks\\" ADD CONSTRAINT \\"chunks_user_id_users_id_fk\\" FOREIGN KEY (\\"user_id\\") REFERENCES \\"public\\".\\"users\\"(\\"id\\") ON DELETE cascade ON UPDATE no action;\\nEXCEPTION\\n WHEN duplicate_object THEN null;\\nEND $$;\\n","\\nDO $$ BEGIN\\n ALTER TABLE \\"embeddings\\" ADD CONSTRAINT \\"embeddings_chunk_id_chunks_id_fk\\" FOREIGN KEY (\\"chunk_id\\") REFERENCES \\"public\\".\\"chunks\\"(\\"id\\") ON DELETE cascade ON UPDATE no action;\\nEXCEPTION\\n WHEN duplicate_object THEN null;\\nEND $$;\\n","\\nDO $$ BEGIN\\n ALTER TABLE \\"embeddings\\" ADD CONSTRAINT \\"embeddings_user_id_users_id_fk\\" FOREIGN KEY (\\"user_id\\") REFERENCES \\"public\\".\\"users\\"(\\"id\\") ON DELETE cascade ON UPDATE no action;\\nEXCEPTION\\n WHEN duplicate_object THEN null;\\nEND $$;\\n","\\nDO $$ BEGIN\\n ALTER TABLE \\"unstructured_chunks\\" ADD CONSTRAINT \\"unstructured_chunks_composite_id_chunks_id_fk\\" FOREIGN KEY (\\"composite_id\\") REFERENCES \\"public\\".\\"chunks\\"(\\"id\\") ON DELETE cascade ON UPDATE no action;\\nEXCEPTION\\n WHEN duplicate_object THEN null;\\nEND $$;\\n","\\nDO $$ BEGIN\\n ALTER TABLE \\"unstructured_chunks\\" ADD CONSTRAINT \\"unstructured_chunks_user_id_users_id_fk\\" FOREIGN KEY (\\"user_id\\") REFERENCES \\"public\\".\\"users\\"(\\"id\\") ON DELETE cascade ON UPDATE no action;\\nEXCEPTION\\n WHEN duplicate_object THEN null;\\nEND $$;\\n","\\nDO $$ BEGIN\\n ALTER TABLE \\"unstructured_chunks\\" ADD CONSTRAINT \\"unstructured_chunks_file_id_files_id_fk\\" FOREIGN KEY (\\"file_id\\") REFERENCES \\"public\\".\\"files\\"(\\"id\\") ON DELETE cascade ON UPDATE no action;\\nEXCEPTION\\n WHEN duplicate_object THEN null;\\nEND $$;\\n","\\nDO $$ BEGIN\\n ALTER TABLE \\"files\\" ADD CONSTRAINT \\"files_file_hash_global_files_hash_id_fk\\" FOREIGN KEY (\\"file_hash\\") REFERENCES \\"public\\".\\"global_files\\"(\\"hash_id\\") ON DELETE no action ON UPDATE no action;\\nEXCEPTION\\n WHEN duplicate_object THEN null;\\nEND $$;\\n","\\nDO $$ BEGIN\\n ALTER TABLE \\"files\\" ADD CONSTRAINT \\"files_chunk_task_id_async_tasks_id_fk\\" FOREIGN KEY (\\"chunk_task_id\\") REFERENCES \\"public\\".\\"async_tasks\\"(\\"id\\") ON DELETE set null ON UPDATE no action;\\nEXCEPTION\\n WHEN duplicate_object THEN null;\\nEND $$;\\n","\\nDO $$ BEGIN\\n ALTER TABLE \\"files\\" ADD CONSTRAINT \\"files_embedding_task_id_async_tasks_id_fk\\" FOREIGN KEY (\\"embedding_task_id\\") REFERENCES \\"public\\".\\"async_tasks\\"(\\"id\\") ON DELETE set null ON UPDATE no action;\\nEXCEPTION\\n WHEN duplicate_object THEN null;\\nEND $$;\\n"],"bps":true,"folderMillis":1724089032064,"hash":"bc4e36664868d14888b9e9aef180b3e02c563fa3c253111787e68b8ea4cd995f"},{"sql":["-- step 1: create a temporary table to store the rows we want to keep\\nCREATE TEMP TABLE embeddings_temp AS\\nSELECT DISTINCT ON (chunk_id) *\\nFROM embeddings\\nORDER BY chunk_id, random();\\n","\\n\\n-- step 2: delete all rows from the original table\\nDELETE FROM embeddings;\\n","\\n\\n-- step 3: insert the rows we want to keep back into the original table\\nINSERT INTO embeddings\\nSELECT * FROM embeddings_temp;\\n","\\n\\n-- step 4: drop the temporary table\\nDROP TABLE embeddings_temp;\\n","\\n\\n-- step 5: now it\'s safe to add the unique constraint\\nALTER TABLE \\"embeddings\\" ADD CONSTRAINT \\"embeddings_chunk_id_unique\\" UNIQUE(\\"chunk_id\\");\\n"],"bps":true,"folderMillis":1724254147447,"hash":"e99840848ffbb33ca4d7ead6158f02b8d12cb4ff5706d4529d7fa586afa4c2a9"},{"sql":["CREATE TABLE IF NOT EXISTS \\"rag_eval_dataset_records\\" (\\n\\t\\"id\\" integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name \\"rag_eval_dataset_records_id_seq\\" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1),\\n\\t\\"dataset_id\\" integer NOT NULL,\\n\\t\\"ideal\\" text,\\n\\t\\"question\\" text,\\n\\t\\"reference_files\\" text[],\\n\\t\\"metadata\\" jsonb,\\n\\t\\"user_id\\" text,\\n\\t\\"created_at\\" timestamp with time zone DEFAULT now() NOT NULL\\n);
1\\n","\\nCREATE TABLE IF NOT EXISTS \\"rag_eval_datasets\\" (\\n\\t\\"id\\" integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name \\"rag_eval_datasets_id_seq\\" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 30000 CACHE 1),\\n\\t\\"description\\" text,\\n\\t\\"name\\" text NOT NULL,\\n\\t\\"knowledge_base_id\\" text,\\n\\t\\"user_id\\" text,\\n\\t\\"updated_at\\" timestamp with time zone DEFAULT now() NOT NULL,\\n\\t\\"created_at\\" timestamp with time zone DEFAULT now() NOT NULL\\n);\\n","\\nCREATE TABLE IF NOT EXISTS \\"rag_eval_evaluations\\" (\\n\\t\\"id\\" integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name \\"rag_eval_evaluations_id_seq\\" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1),\\n\\t\\"name\\" text NOT NULL,\\n\\t\\"description\\" text,\\n\\t\\"eval_records_url\\" text,\\n\\t\\"status\\" text,\\n\\t\\"error\\" jsonb,\\n\\t\\"dataset_id\\" integer NOT NULL,\\n\\t\\"knowledge_base_id\\" text,\\n\\t\\"language_model\\" text,\\n\\t\\"embedding_model\\" text,\\n\\t\\"user_id\\" text,\\n\\t\\"created_at\\" timestamp with time zone DEFAULT now() NOT NULL,\\n\\t\\"updated_at\\" timestamp with time zone DEFAULT now() NOT NULL\\n);\\n","\\nCREATE TABLE IF NOT EXISTS \\"rag_eval_evaluation_records\\" (\\n\\t\\"id\\" integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name \\"rag_eval_evaluation_records_id_seq\\" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1),\\n\\t\\"question\\" text NOT NULL,\\n\\t\\"answer\\" text,\\n\\t\\"context\\" text[],\\n\\t\\"ideal\\" text,\\n\\t\\"status\\" text,\\n\\t\\"error\\" jsonb,\\n\\t\\"language_model\\" text,\\n\\t\\"embedding_model\\" text,\\n\\t\\"question_embedding_id\\" uuid,\\n\\t\\"duration\\" integer,\\n\\t\\"dataset_record_id\\" integer NOT NULL,\\n\\t\\"evaluation_id\\" integer NOT NULL,\\n\\t\\"user_id\\" text,\\n\\t\\"created_at\\" timestamp with time zone DEFAULT now() NOT NULL\\n);\\n","\\nDO $$ BEGIN\\n ALTER TABLE \\"rag_eval_dataset_records\\" ADD CONSTRAINT \\"rag_eval_dataset_records_dataset_id_rag_eval_datasets_id_fk\\" FOREIGN KEY (\\"dataset_id\\") REFERENCES \\"public\\".\\"rag_eval_datasets\\"(\\"id\\") ON DELETE cascade ON UPDATE no action;\\nEXCEPTION\\n WHEN duplicate_object THEN null;\\nEND $$;\\n","\\nDO $$ BEGIN\\n ALTER TABLE \\"rag_eval_dataset_records\\" ADD CONSTRAINT \\"rag_eval_dataset_records_user_id_users_id_fk\\" FOREIGN KEY (\\"user_id\\") REFERENCES \\"public\\".\\"users\\"(\\"id\\") ON DELETE cascade ON UPDATE no action;\\nEXCEPTION\\n WHEN duplicate_object THEN null;\\nEND $$;\\n","\\nDO $$ BEGIN\\n ALTER TABLE \\"rag_eval_datasets\\" ADD CONSTRAINT \\"rag_eval_datasets_knowledge_base_id_knowledge_bases_id_fk\\" FOREIGN KEY (\\"knowledge_base_id\\") REFERENCES \\"public\\".\\"knowledge_bases\\"(\\"id\\") ON DELETE cascade ON UPDATE no action;\\nEXCEPTION\\n WHEN duplicate_object THEN null;\\nEND $$;\\n","\\nDO $$ BEGIN\\n ALTER TABLE \\"rag_eval_datasets\\" ADD CONSTRAINT \\"rag_eval_datasets_user_id_users_id_fk\\" FOREIGN KEY (\\"user_id\\") REFERENCES \\"public\\".\\"users\\"(\\"id\\") ON DELETE cascade ON UPDATE no action;\\nEXCEPTION\\n WHEN duplicate_object THEN null;\\nEND $$;\\n","\\nDO $$ BEGIN\\n ALTER TABLE \\"rag_eval_evaluations\\" ADD CONSTRAINT \\"rag_eval_evaluations_dataset_id_rag_eval_datasets_id_fk\\" FOREIGN KEY (\\"dataset_id\\") REFERENCES \\"public\\".\\"rag_eval_datasets\\"(\\"id\\") ON DELETE cascade ON UPDATE no action;\\nEXCEPTION\\n WHEN duplicate_object THEN null;\\nEND $$;\\n","\\nDO $$ BEGIN\\n ALTER TABLE \\"rag_eval_evaluations\\" ADD CONSTRAINT \\"rag_eval_evaluations_knowledge_base_id_knowledge_bases_id_fk\\" FOREIGN KEY (\\"knowledge_base_id\\") REFERENCES \\"public\\".\\"knowledge_bases\\"(\\"id\\") ON DELETE cascade ON UPDATE no action;\\nEXCEPTION\\n WHEN duplicate_object THEN null;\\nEND $$;\\n","\\nDO $$ BEGIN\\n ALTER TABLE \\"rag_eval_evaluations\\" ADD CONSTRAINT \\"rag_eval_evaluations_user_id_users_id_fk\\" FOREIGN KEY (\\"user_id\\") REFERENCES \\"public\\".\\"users\\"(\\"id\\") ON DELETE cascade ON UPDATE no action;\\nEXCEPTION\\n WHEN duplicate_object THEN null;\\nEND $$;\\n","\\nDO $$ BEGIN\\n ALTER TABLE \\"rag_eval_evaluation_records\\" ADD CONSTRAINT \\"rag_eval_evaluation_records_question_embedding_id_embeddings_id_fk\\" FOREIGN KEY (\\"question_embedding_id\\") REFERENCES \\"public\\".\\"embeddings\\"(\\"id\\") ON DELETE set null ON UPDATE no action;\\nEXCEPTION\\n WHEN duplicate_object THEN null;\\nEND $$;\\n","\\nDO $$ BEGIN\\n ALTER TABLE \\"rag_eval_evaluation_records\\" ADD CONSTRAINT \\"rag_eval_evaluation_records_dataset_record_id_rag_eval_dataset_records_id_fk\\" FOREIGN KEY (\\"dataset_record_id\\") REFERENCES \\"public\\".\\"rag_eval_dataset_records\\"(\\"id\\") ON DELETE cascade ON UPDATE no action;\\nEXCEPTION\\n WHEN duplicate_object THEN null;\\nEND $$;\\n","\\nDO $$ BEGIN\\n ALTER TABLE \\"rag_eval_evaluation_records\\" ADD CONSTRAINT \\"rag_eval_evaluation_records_evaluation_id_rag_eval_evaluations_id_fk\\" FOREIGN KEY (\\"evaluation_id\\") REFERENCES \\"public\\".\\"rag_eval_evaluations\\"(\\"id\\") ON DELETE cascade ON UPDATE no action;\\nEXCEPTION\\n WHEN duplicate_object THEN null;\\nEND $$;\\n","\\nDO $$ BEGIN\\n ALTER TABLE \\"rag_eval_evaluation_records\\" ADD CONSTRAINT \\"rag_eval_evaluation_records_user_id_users_id_fk\\" FOREIGN KEY (\\"user_id\\") REFERENCES \\"public\\".\\"users\\"(\\"id\\") ON DELETE cascade ON UPDATE no action;\\nEXCEPTION\\n WHEN duplicate_object THEN null;\\nEND $$;\\n"],"bps":true,"folderMillis":1725366565650,"hash":"9646161fa041354714f823d726af27247bcd6e60fa3be5698c0d69f337a5700b"},{"sql":["DROP TABLE \\"user_budgets\\";","\\nDROP TABLE \\"user_subscriptions\\";"],"bps":true,"folderMillis":1729699958471,"hash":"7dad43a2a25d1aec82124a4e53f8d82f8505c3073f23606c1dc5d2a4598eacf9"},{"sql":["DROP TABLE \\"agents_tags\\" CASCADE;","\\nDROP TABLE \\"market\\" CASCADE;","\\nDROP TABLE \\"plugins\\" CASCADE;","\\nDROP TABLE \\"plugins_tags\\" CASCADE;","\\nDROP TABLE \\"tags\\" CASCADE;","\\nALTER TABLE \\"agents\\" ADD COLUMN \\"accessed_at\\" timestamp with time zone DEFAULT now() NOT NULL;","\\nALTER TABLE \\"agents_files\\" ADD COLUMN \\"accessed_at\\" timestamp with time zone DEFAULT now() NOT NULL;","\\nALTER TABLE \\"agents_knowledge_bases\\" ADD COLUMN \\"accessed_at\\" timestamp with time zone DEFAULT now() NOT NULL;","\\nALTER TABLE \\"async_tasks\\" ADD COLUMN \\"accessed_at\\" timestamp with time zone DEFAULT now() NOT NULL;","\\nALTER TABLE \\"files\\" ADD COLUMN \\"accessed_at\\" timestamp with time zone DEFAULT now() NOT NULL;","\\nALTER TABLE \\"global_files\\" ADD COLUMN \\"accessed_at\\" timestamp with time zone DEFAULT now() NOT NULL;","\\nALTER TABLE \\"knowledge_bases\\" ADD COLUMN \\"accessed_at\\" timestamp with time zone DEFAULT now() NOT NULL;","\\nALTER TABLE \\"messages\\" ADD COLUMN \\"accessed_at\\" timestamp with time zone DEFAULT now() NOT NULL;","\\nALTER TABLE \\"chunks\\" ADD COLUMN \\"accessed_at\\" timestamp with time zone DEFAULT now() NOT NULL;","\\nALTER TABLE \\"unstructured_chunks\\" ADD COLUMN \\"accessed_at\\" timestamp with time zone DEFAULT now() NOT NULL;","\\nALTER TABLE \\"rag_eval_dataset_records\\" ADD COLUMN \\"accessed_at\\" timestamp with time zone DEFAULT now() NOT NULL;","\\nALTER TABLE \\"rag_eval_dataset_records\\" ADD COLUMN \\"updated_at\\" timestamp with time zone DEFAULT now() NOT NULL;","\\nALTER TABLE \\"rag_eval_datasets\\" ADD COLUMN \\"accessed_at\\" timestamp with time zone DEFAULT now() NOT NULL;","\\nALTER TABLE \\"rag_eval_evaluations\\" ADD COLUMN \\"accessed_at\\" timestamp with time zone DEFAULT now() NOT NULL;","\\nALTER TABLE \\"rag_eval_evaluation_records\\" ADD COLUMN \\"accessed_at\\" timestamp with time zone DEFAULT now() NOT NULL;","\\nALTER TABLE \\"rag_eval_evaluation_records\\" ADD COLUMN \\"updated_at\\" timestamp with time zone DEFAULT now() NOT NULL;","\\nALTER TABLE \\"session_groups\\" ADD COLUMN \\"accessed_at\\" timestamp with time zone DEFAULT now() NOT NULL;","\\nALTER TABLE \\"sessions\\" ADD COLUMN \\"accessed_at\\" timestamp with time zone DEFAULT now() NOT NULL;","\\nALTER TABLE \\"topics\\" ADD COLUMN \\"accessed_at\\" timestamp with time zone DEFAULT now() NOT NULL;","\\nALTER TABLE \\"user_installed_plugins\\" ADD COLUMN \\"accessed_at\\" timestamp with time zone DEFAULT now() NOT NULL;","\\nALTER TABLE \\"users\\" ADD COLUMN \\"accessed_at\\" timestamp with time zone DEFAULT now() NOT NULL;"],"bps":true,"folderMillis":1730900133049,"hash":"a7d801b679e25ef3ffda343366992b2835c089363e9d7c09074336d40e438004"},{"sql":["ALTER TABLE \\"topics\\" ADD COLUMN \\"history_summary\\" text;","\\nALTER TABLE \\"topics\\" ADD COLUMN \\"metadata\\" jsonb;\\n"],"bps":true,"folderMillis":1731138670427,"hash":"80c2eae0600190b354e4fd6b619687a66186b992ec687495bb55c6c163a98fa6"},{"sql":["CREATE TABLE IF NOT EXISTS \\"threads\\" (\\n\\t\\"id\\" text PRIMARY KEY NOT NULL,\\n\\t\\"title\\" text,\\n\\t\\"type\\" text NOT NULL,\\n\\t\\"status\\" text DEFAULT \'active\',\\n\\t\\"topic_id\\" text NOT NULL,\\n\\t\\"source_message_id\\" text NOT NULL,\\n\\t\\"parent_thread_id\\" text,\\n\\t\\"user_id\\" text NOT NULL,\\n\\t\\"last_active_at\\" timestamp with time zone DEFAULT now(),\\n\\t\\"accessed_at\\" timestamp with time zone DEFAULT now() NOT NULL,\\n\\t\\"created_at\\" timestamp with time zone DEFAULT now() NOT NULL,\\n\\t\\"updated_at\\" timestamp with time zone DEFAULT now() NOT NULL\\n);\\n","\\nALTER TABLE \\"messages\\" ADD COLUMN \\"thread_id\\" text;","\\nDO $$ BEGIN\\n ALTER TABLE \\"threads\\" ADD CONSTRAINT \\"threads_topic_id_topics_id_fk\\" FOREIGN KEY (\\"topic_id\\") REFERENCES \\"public\\".\\"topics\\"(\\"id\\") ON DELETE cascade ON UPDATE no action;\\nEXCEPTION\\n WHEN duplicate_object THEN null;\\nEND $$;\\n","\\nDO $$ BEGIN\\n ALTER TABLE \\"threads\\" ADD CONSTRAINT \\"threads_parent_thread_id_threads_id_fk\\" FOREIGN KEY (\\"parent_thread_id\\") REFERENCES \\"public\\".\\"threads\\"(\\"id\\") ON DELETE set null ON UPDATE no action;\\nEXCEPTION\\n WHEN duplicate_object THEN null;\\nEND $$;\\n","\\nDO $$ BEGIN\\n ALTER TABLE \\"threads\\" ADD CONSTRAINT \\"threads_user_id_users_id_fk\\" FOREIGN KEY (\\"user_id\\") REFERENCES \\"public\\".\\"users\\"(\\"id\\") ON DELETE cascade ON UPDATE no action;\\nEXCEPTION\\n WHEN duplicate_object THEN null;\\nEND $$;\\n","\\nDO $$ BEGIN\\n ALTER TABLE \\"messages\\" ADD CONSTRAINT \\"messages_thread_id_threads_id_fk\\" FOREIGN KEY (\\"thread_id\\") REFERENCES \\"public\\".\\"threads\\"(\\"id\\") ON DELETE cascade ON UPDATE no action;\\nEXCEPTION\\n WHEN duplicate_object THEN null;\\nEND $$;\\n"],"bps":true,"folderMillis":1731858381716,"hash":"d8263bfefe296ed366379c7b7fc65195d12e6a1c0a9f1c96097ea28f2123fe50"}
1,{"sql":["CREATE TABLE \\"ai_models\\" (\\n\\t\\"id\\" varchar(150) NOT NULL,\\n\\t\\"display_name\\" varchar(200),\\n\\t\\"description\\" text,\\n\\t\\"organization\\" varchar(100),\\n\\t\\"enabled\\" boolean,\\n\\t\\"provider_id\\" varchar(64) NOT NULL,\\n\\t\\"type\\" varchar(20) DEFAULT \'chat\' NOT NULL,\\n\\t\\"sort\\" integer,\\n\\t\\"user_id\\" text NOT NULL,\\n\\t\\"pricing\\" jsonb,\\n\\t\\"parameters\\" jsonb DEFAULT \'{}\'::jsonb,\\n\\t\\"config\\" jsonb,\\n\\t\\"abilities\\" jsonb DEFAULT \'{}\'::jsonb,\\n\\t\\"context_window_tokens\\" integer,\\n\\t\\"source\\" varchar(20),\\n\\t\\"released_at\\" varchar(10),\\n\\t\\"accessed_at\\" timestamp with time zone DEFAULT now() NOT NULL,\\n\\t\\"created_at\\" timestamp with time zone DEFAULT now() NOT NULL,\\n\\t\\"updated_at\\" timestamp with time zone DEFAULT now() NOT NULL,\\n\\tCONSTRAINT \\"ai_models_id_provider_id_user_id_pk\\" PRIMARY KEY(\\"id\\",\\"provider_id\\",\\"user_id\\")\\n);\\n","\\nCREATE TABLE \\"ai_providers\\" (\\n\\t\\"id\\" varchar(64) NOT NULL,\\n\\t\\"name\\" text,\\n\\t\\"user_id\\" text NOT NULL,\\n\\t\\"sort\\" integer,\\n\\t\\"enabled\\" boolean,\\n\\t\\"fetch_on_client\\" boolean,\\n\\t\\"check_model\\" text,\\n\\t\\"logo\\" text,\\n\\t\\"description\\" text,\\n\\t\\"key_vaults\\" text,\\n\\t\\"source\\" varchar(20),\\n\\t\\"settings\\" jsonb,\\n\\t\\"accessed_at\\" timestamp with time zone DEFAULT now() NOT NULL,\\n\\t\\"created_at\\" timestamp with time zone DEFAULT now() NOT NULL,\\n\\t\\"updated_at\\" timestamp with time zone DEFAULT now() NOT NULL,\\n\\tCONSTRAINT \\"ai_providers_id_user_id_pk\\" PRIMARY KEY(\\"id\\",\\"user_id\\")\\n);\\n","\\nALTER TABLE \\"ai_models\\" ADD CONSTRAINT \\"ai_models_user_id_users_id_fk\\" FOREIGN KEY (\\"user_id\\") REFERENCES \\"public\\".\\"users\\"(\\"id\\") ON DELETE cascade ON UPDATE no action;","\\nALTER TABLE \\"ai_providers\\" ADD CONSTRAINT \\"ai_providers_user_id_users_id_fk\\" FOREIGN KEY (\\"user_id\\") REFERENCES \\"public\\".\\"users\\"(\\"id\\") ON DELETE cascade ON UPDATE no action;"],"bps":true,"folderMillis":1735834653361,"hash":"845a692ceabbfc3caf252a97d3e19a213bc0c433df2689900135f9cfded2cf49"},{"sql":["ALTER TABLE \\"messages\\" ADD COLUMN \\"reasoning\\" jsonb;"],"bps":true,"folderMillis":1737609172353,"hash":"2cb36ae4fcdd7b7064767e04bfbb36ae34518ff4bb1b39006f2dd394d1893868"},{"sql":["ALTER TABLE \\"messages\\" ADD COLUMN \\"search\\" jsonb;","\\nALTER TABLE \\"messages\\" ADD COLUMN \\"metadata\\" jsonb;"],"bps":true,"folderMillis":1739901891891,"hash":"78d8fefd8c58938d7bc3da2295a73b35ce2e8d7cb2820f8e817acdb8dd5bebb2"},{"sql":["CREATE INDEX IF NOT EXISTS \\"messages_topic_id_idx\\" ON \\"messages\\" USING btree (\\"topic_id\\");","\\nCREATE INDEX IF NOT EXISTS \\"messages_parent_id_idx\\" ON \\"messages\\" USING btree (\\"parent_id\\");","\\nCREATE INDEX IF NOT EXISTS \\"messages_quota_id_idx\\" ON \\"messages\\" USING btree (\\"quota_id\\");\\n"],"bps":true,"folderMillis":1741844738677,"hash":"2a7a98be2e49361391444d6fabf3fb5db0bcb6a65e5540e9c3d426ceeb1f7f3a"}]'),k="LOBE_CHAT_PGLITE_SCHEMA_HASH";class ${static getInstance(){return $.instance||($.instance=new $),$.instance}async loadWasmModule(){var e,t,n,s,i,a,E;let l=Date.now();null===(t=this.callbacks)||void 0===t||null===(e=t.onStateChange)||void 0===e||e.call(t,d.D.LoadingWasm);let _=await fetch($.WASM_CDN_URL),N=Number(_.headers.get("Content-Length"))||0,o=null===(n=_.body)||void 0===n?void 0:n.getReader();if(!o)throw Error("Failed to start WASM download");let c=0,r=[];for(;;){let{done:e,value:t}=await o.read();if(e)break;r.push(t);let n=Math.min(Math.round((c+=t.length)/N*100),100);null===(E=this.callbacks)||void 0===E||null===(a=E.onProgress)||void 0===a||a.call(E,{phase:"wasm",progress:n})}let T=new Uint8Array(c),u=0;
1for(let e of r)T.set(e,u),u+=e.length;return null===(i=this.callbacks)||void 0===i||null===(s=i.onProgress)||void 0===s||s.call(i,{costTime:Date.now()-l,phase:"wasm",progress:100}),WebAssembly.compile(T)}async loadDependencies(){var e,t,s,i;let a=Date.now();null===(t=this.callbacks)||void 0===t||null===(e=t.onStateChange)||void 0===e||e.call(t,d.D.LoadingDependencies);let E=[Promise.resolve().then(n.bind(n,49613)).then(e=>({IdbFs:e.IdbFs,MemoryFS:e.MemoryFS,PGlite:e.PGlite})),n.e(71387).then(n.bind(n,71387)),this.fetchFsBundle()],l=0,_=await Promise.all(E.map(async e=>{var t,n;let s=await e;return l+=1,null===(n=this.callbacks)||void 0===n||null===(t=n.onProgress)||void 0===t||t.call(n,{phase:"dependencies",progress:Math.min(Math.round(l/E.length*100),100)}),s}));null===(i=this.callbacks)||void 0===i||null===(s=i.onProgress)||void 0===s||s.call(i,{costTime:Date.now()-a,phase:"dependencies",progress:100});let[{PGlite:N,IdbFs:o,MemoryFS:c},{vector:r},T]=_;return{IdbFs:o,MemoryFS:c,PGlite:N,fsBundle:T,vector:r}}async migrate(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(this.isLocalDBSchemaSynced&&e)return this.db;let t=localStorage.getItem(k),n=a.VV.hashStr(JSON.stringify(S));if(n===t)return this.isLocalDBSchemaSynced=!0,this.db;let s=Date.now();try{var i,E;null===(E=this.callbacks)||void 0===E||null===(i=E.onStateChange)||void 0===i||i.call(E,d.D.Migrating),await this.db.dialect.migrate(S,this.db.session,{}),localStorage.setItem(k,n),this.isLocalDBSchemaSynced=!0,console.info("\uD83D\uDDC2 Migration success, take ".concat(Date.now()-s,"ms"))}catch(e){throw console.error("â Local database schema migration failed",e),e}return this.db}async initialize(e){return this.initPromise||(this.callbacks=e,this.initPromise=(async()=>{var e,t,a,l,_,N,o,c,r,T;try{let o;if(this.dbInstance)return this.dbInstance;let c=Date.now();null===(t=this.callbacks)||void 0===t||null===(e=t.onStateChange)||void 0===e||e.call(t,d.D.Initializing);let{fsBundle:r,PGlite:T,MemoryFS:u,IdbFs:A,vector:L}=await this.loadDependencies(),D=await this.loadWasmModule(),{initPgliteWorker:O}=await n.e(73823).then(n.bind(n,73823)),g="lobechat";return o="undefined"!=typeof Worker&&void 0!==navigator.locks?await O({dbName:g,fsBundle:r,vectorBundlePath:$.VECTOR_CDN_URL,wasmModule:D}):new T({extensions:{vector:L},fs:new A(g),relaxedDurability:!0,wasmModule:D}),this.dbInstance=(0,i.fd)({client:o,schema:s}),await this.migrate(!0),null===(l=this.callbacks)||void 0===l||null===(a=l.onStateChange)||void 0===a||a.call(l,d.D.Finished),console.log("â
Database initialized in ".concat(Date.now()-c,"ms")),await (0,E.y)(50),null===(N=this.callbacks)||void 0===N||null===(_=N.onStateChange)||void 0===_||_.call(N,d.D.Ready),this.dbInstance}catch(e){throw this.initPromise=null,null===(c=this.callbacks)||void 0===c||null===(o=c.onStateChange)||void 0===o||o.call(c,d.D.Error),null===(T=this.callbacks)||void 0===T||null===(r=T.onError)||void 0===r||r.call(T,{message:e.message,name:e.name,stack:e.stack}),console.error(e),e}})()),this.initPromise}get db(){if(!this.dbInstance)throw Error("Database not initialized. Please call initialize() first.");return this.dbInstance}createProxy(){return new Proxy({},{get:(e,t)=>this.db[t]})}constructor(){this.dbInstance=null,this.initPromise=null,this.isLocalDBSchemaSynced=!1,this.fetchFsBundle=async()=>{let e=await fetch($.FSBUNDLER_CDN_URL);return await e.blob()}}}$.WASM_CDN_URL="https://registry.npmmirror.com/@electric-sql/pglite/0.2.17/files/dist/postgres.wasm",$.FSBUNDLER_CDN_URL="https://registry.npmmirror.com/@electric-sql/pglite/0.2.17/files/dist/postgres.data",$.VECTOR_CDN_URL="https://registry.npmmirror.com/@electric-sql/pglite/0.2.17/files/dist/vector.tar.gz";let B=$.getInstance(),x=B.createProxy(),P=e=>B.initialize(e)},71532:(e,t,n)=>{"use strict";n.d(t,{x1:()=>i});var s=n(75452),i=function(e){return e.Error="Error",e.Pending="Pending",e.Processing="Processing",e.Success="Success",e}({});s.z.object({ideal:s.z.string().optional(),question:s.z.string(),referenceFiles:s.z.string().or(s.z.array(s.z.string())).optional()}),s.z.object({datasetId:s.z.number(),description:s.z.string().optional(),knowledgeBaseId:s.z.string(),name:s.z.string()})},75453:(e,t,n)=>{"use strict";n.d(t,{BU:()=>h,GK:()=>D,Gc:()=>m,Ru:()=>b,SH:()=>R,T9:()=>O,UG:()=>f,Yb:()=>U,cd:()=>p,dK:()=>g,pz:()=>L,rU:()=>I});var s=n(13432),i=n(42407),a=n(73568),d=n(59882),E=n(63228),l=n(23116),_=n(75466),N=n(41617),o=n(41041),c=n(49958),r=n(89751),T=n(35406),u=n(88748),A=n(13151);let L=(0,i.cJ)("agents_to_sessions",{agentId:(0,a.Qq)("agent_id").notNull().references(()=>
1N.X6.id,{onDelete:"cascade"}),sessionId:(0,a.Qq)("session_id").notNull().references(()=>u.Mf.id,{onDelete:"cascade"})},e=>({pk:(0,d.ie)({columns:[e.agentId,e.sessionId]})})),D=(0,i.cJ)("files_to_sessions",{fileId:(0,a.Qq)("file_id").notNull().references(()=>c.aq.id,{onDelete:"cascade"}),sessionId:(0,a.Qq)("session_id").notNull().references(()=>u.Mf.id,{onDelete:"cascade"})},e=>({pk:(0,d.ie)({columns:[e.fileId,e.sessionId]})})),O=(0,i.cJ)("file_chunks",{fileId:(0,E.yf)("file_id").references(()=>c.aq.id,{onDelete:"cascade"}),chunkId:(0,l.uR)("chunk_id").references(()=>T.VN.id,{onDelete:"cascade"}),createdAt:(0,_.CT)()},e=>({pk:(0,d.ie)({columns:[e.fileId,e.chunkId]})})),g=(0,s.K1)(A.vp,e=>{let{one:t}=e;return{session:t(u.Mf,{fields:[A.vp.sessionId],references:[u.Mf.id]})}}),I=(0,s.K1)(A.eD,e=>{let{one:t}=e;return{sourceMessage:t(r.DZ,{fields:[A.eD.sourceMessageId],references:[r.DZ.id]})}}),R=(0,s.K1)(r.DZ,e=>{let{many:t,one:n}=e;return{filesToMessages:t(r.M$),session:n(u.Mf,{fields:[r.DZ.sessionId],references:[u.Mf.id]}),parent:n(r.DZ,{fields:[r.DZ.parentId],references:[r.DZ.id]}),topic:n(A.vp,{fields:[r.DZ.topicId],references:[A.vp.id]}),thread:n(A.eD,{fields:[r.DZ.threadId],references:[A.eD.id]})}}),m=(0,s.K1)(N.X6,e=>{let{many:t}=e;return{agentsToSessions:t(L),knowledgeBases:t(N.D1),files:t(N.I4)}}),p=(0,s.K1)(L,e=>{let{one:t}=e;return{session:t(u.Mf,{fields:[L.sessionId],references:[u.Mf.id]}),agent:t(N.X6,{fields:[L.agentId],references:[N.X6.id]})}}),f=(0,s.K1)(N.D1,e=>{let{one:t}=e;return{knowledgeBase:t(c.NX,{fields:[N.D1.knowledgeBaseId],references:[c.NX.id]}),agent:t(N.X6,{fields:[N.D1.agentId],references:[N.X6.id]})}}),b=(0,s.K1)(u.Mf,e=>{let{many:t,one:n}=e;return{filesToSessions:t(D),agentsToSessions:t(L),group:n(u.B$,{fields:[u.Mf.groupId],references:[u.B$.id]})}}),U=(0,s.K1)(T.mh,e=>{let{one:t}=e;return{file:t(c.aq,{fields:[T.mh.fileId],references:[c.aq.id]})}}),h=(0,s.K1)(c.aq,e=>{let{many:t,one:n}=e;return{messages:t(r.M$),sessions:t(D),agents:t(N.I4),chunkingTask:n(o.b,{fields:[c.aq.chunkTaskId],references:[o.b.id]}),embeddingTask:n(o.b,{fields:[c.aq.embeddingTaskId],references:[o.b.id]})}})},75466:(e,t,n)=>{"use strict";n.d(t,{AP:()=>E,CT:()=>a,dE:()=>i,fu:()=>d});var s=n(14145);let i=e=>(0,s.vE)(e,{withTimezone:!0}),a=()=>i("created_at").notNull().defaultNow(),d=()=>i("accessed_at").notNull().defaultNow(),E={accessedAt:d(),createdAt:a(),updatedAt:i("updated_at").notNull().defaultNow()}},82596:(e,t,n)=>{"use strict";n.d(t,{J:()=>c,T:()=>r});var s=n(42407),i=n(63228),a=n(73568),d=n(62207),E=n(77653),l=n(45169),_=n(59882),N=n(75466),o=n(39691);let c=(0,s.cJ)("ai_providers",{id:(0,i.yf)("id",{length:64}).notNull(),name:(0,a.Qq)("name"),userId:(0,a.Qq)("user_id").references(()=>o.VV.id,{onDelete:"cascade"}).notNull(),sort:(0,d.nd)("sort"),enabled:(0,E.zM)("enabled"),fetchOnClient:(0,E.zM)("fetch_on_client"),checkModel:(0,a.Qq)("check_model"),logo:(0,a.Qq)("logo"),description:(0,a.Qq)("description"),keyVaults:(0,a.Qq)("key_vaults"),source:(0,i.yf)("source",{enum:["builtin","custom"],length:20}),settings:(0,l.Fx)("settings").$defaultFn(()=>({})).$type(),...N.AP},e=>[(0,_.ie)({columns:[e.id,e.userId]})]),r=(0,s.cJ)("ai_models",{id:(0,i.yf)("id",{length:150}).notNull(),displayName:(0,i.yf)("display_name",{length:200}),description:(0,a.Qq)("description"),organization:(0,i.yf)("organization",{length:100}),enabled:(0,E.zM)("enabled"),providerId:(0,i.yf)("provider_id",{length:64}).notNull(),type:(0,i.yf)("type",{length:20}).default("chat").notNull(),sort:(0,d.nd)("sort"),userId:(0,a.Qq)("user_id").references(()=>o.VV.id,{onDelete:"cascade"}).notNull(),pricing:(0,l.Fx)("pricing"),parameters:(0,l.Fx)("parameters").default({}),config:(0,l.Fx)("config"),abilities:(0,l.Fx)("abilities").default({}),contextWindowTokens:(0,d.nd)("context_window_tokens"),source:(0,i.yf)("source",{enum:["remote","custom","builtin"],length:20}),releasedAt:(0,i.yf)("released_at",{length:10}),...N.AP},e=>[(0,_.ie)({columns:[e.id,e.providerId,e.userId]})])},88748:(e,t,n)=>{"use strict";n.d(t,{B$:()=>T,F1:()=>L,Mf:()=>A,OG:()=>u});var s=n(42407),i=n(73568),a=n(62207),d=n(98316),E=n(63228),l=n(77653),_=n(84341),N=n(65677),o=n(5667),c=n(75466),r=n(39691);let T=(0,s.cJ)("session_groups",{id:(0,i.Qq)("id").$defaultFn(()=>(0,o.ZM)("sessionGroups")).primaryKey(),name:(0,i.Qq)("name").notNull(),sort:(0,a.nd)("sort"),userId:(0,i.Qq)("user_id").references(()=>
1r.VV.id,{onDelete:"cascade"}).notNull(),clientId:(0,i.Qq)("client_id"),...c.AP},e=>({clientIdUnique:(0,d.Am)("session_group_client_id_user_unique").on(e.clientId,e.userId)})),u=(0,N.r)(T),A=(0,s.cJ)("sessions",{id:(0,i.Qq)("id").$defaultFn(()=>(0,o.ZM)("sessions")).primaryKey(),slug:(0,E.yf)("slug",{length:100}).notNull().$defaultFn(()=>(0,o.Z_)()),title:(0,i.Qq)("title"),description:(0,i.Qq)("description"),avatar:(0,i.Qq)("avatar"),backgroundColor:(0,i.Qq)("background_color"),type:(0,i.Qq)("type",{enum:["agent","group"]}).default("agent"),userId:(0,i.Qq)("user_id").references(()=>r.VV.id,{onDelete:"cascade"}).notNull(),groupId:(0,i.Qq)("group_id").references(()=>T.id,{onDelete:"set null"}),clientId:(0,i.Qq)("client_id"),pinned:(0,l.zM)("pinned").default(!1),...c.AP},e=>({slugUserIdUnique:(0,_.GL)("slug_user_id_unique").on(e.slug,e.userId),clientIdUnique:(0,d.Am)("sessions_client_id_user_id_unique").on(e.clientId,e.userId)})),L=(0,N.r)(A)},89751:(e,t,n)=>{"use strict";n.d(t,{AR:()=>b,DV:()=>m,DZ:()=>g,M$:()=>f,g9:()=>I,lX:()=>p,vM:()=>R,yX:()=>U,yZ:()=>h});var s=n(42407),i=n(73568),a=n(45169),d=n(77653),E=n(84341),l=n(59882),_=n(23116),N=n(23966),o=n(65677),c=n(5667),r=n(75466),T=n(41617),u=n(49958),A=n(35406),L=n(88748),D=n(13151),O=n(39691);let g=(0,s.cJ)("messages",{id:(0,i.Qq)("id").$defaultFn(()=>(0,c.ZM)("messages")).primaryKey(),role:(0,i.Qq)("role",{enum:["user","system","assistant","tool"]}).notNull(),content:(0,i.Qq)("content"),reasoning:(0,a.Fx)("reasoning").$type(),search:(0,a.Fx)("search").$type(),metadata:(0,a.Fx)("metadata"),model:(0,i.Qq)("model"),provider:(0,i.Qq)("provider"),favorite:(0,d.zM)("favorite").default(!1),error:(0,a.Fx)("error"),tools:(0,a.Fx)("tools"),traceId:(0,i.Qq)("trace_id"),observationId:(0,i.Qq)("observation_id"),clientId:(0,i.Qq)("client_id"),userId:(0,i.Qq)("user_id").references(()=>O.VV.id,{onDelete:"cascade"}).notNull(),sessionId:(0,i.Qq)("session_id").references(()=>L.Mf.id,{onDelete:"cascade"}),topicId:(0,i.Qq)("topic_id").references(()=>D.vp.id,{onDelete:"cascade"}),threadId:(0,i.Qq)("thread_id").references(()=>D.eD.id,{onDelete:"cascade"}),parentId:(0,i.Qq)("parent_id").references(()=>g.id,{onDelete:"set null"}),quotaId:(0,i.Qq)("quota_id").references(()=>g.id,{onDelete:"set null"}),agentId:(0,i.Qq)("agent_id").references(()=>T.X6.id,{onDelete:"set null"}),...r.AP},e=>({createdAtIdx:(0,E.Pe)("messages_created_at_idx").on(e.createdAt),messageClientIdUnique:(0,E.GL)("message_client_id_user_unique").on(e.clientId,e.userId),topicIdIdx:(0,E.Pe)("messages_topic_id_idx").on(e.topicId),parentIdIdx:(0,E.Pe)("messages_parent_id_idx").on(e.parentId),quotaIdIdx:(0,E.Pe)("messages_quota_id_idx").on(e.quotaId)})),I=(0,s.cJ)("message_plugins",{id:(0,i.Qq)("id").references(()=>g.id,{onDelete:"cascade"}).primaryKey(),toolCallId:(0,i.Qq)("tool_call_id"),type:(0,i.Qq)("type",{enum:["default","markdown","standalone","builtin"]}).default("default"),apiName:(0,i.Qq)("api_name"),arguments:(0,i.Qq)("arguments"),identifier:(0,i.Qq)("identifier"),state:(0,a.Fx)("state"),error:(0,a.Fx)("error")}),R=(0,o.aJ)(I),m=(0,s.cJ)("message_tts",{id:(0,i.Qq)("id").references(()=>g.id,{onDelete:"cascade"}).primaryKey(),contentMd5:(0,i.Qq)("content_md5"),fileId:(0,i.Qq)("file_id").references(()=>u.aq.id,{onDelete:"cascade"}),voice:(0,i.Qq)("voice")}),p=(0,s.cJ)("message_translates",{id:(0,i.Qq)("id").references(()=>g.id,{onDelete:"cascade"}).primaryKey(),content:(0,i.Qq)("content"),from:(0,i.Qq)("from"),to:(0,i.Qq)("to")}),f=(0,s.cJ)("messages_files",{fileId:(0,i.Qq)("file_id").notNull().references(()=>u.aq.id,{onDelete:"cascade"}),messageId:(0,i.Qq)("message_id").notNull().references(()=>g.id,{onDelete:"cascade"})},e=>({pk:(0,l.ie)({columns:[e.fileId,e.messageId]})})),b=(0,s.cJ)("message_queries",{id:(0,_.uR)("id").defaultRandom().primaryKey(),messageId:(0,i.Qq)("message_id").references(()=>g.id,{onDelete:"cascade"}).notNull(),rewriteQuery:(0,i.Qq)("rewrite_query"),userQuery:(0,i.Qq)("user_query"),embeddingsId:(0,_.uR)("embeddings_id").references(()=>A.VV.id,{onDelete:"set null"})}),U=(0,s.cJ)("message_query_chunks",{messageId:(0,i.Qq)("id").references(()=>
1g.id,{onDelete:"cascade"}),queryId:(0,_.uR)("query_id").references(()=>b.id,{onDelete:"cascade"}),chunkId:(0,_.uR)("chunk_id").references(()=>A.VN.id,{onDelete:"cascade"}),similarity:(0,N.sH)("similarity",{precision:6,scale:5})},e=>({pk:(0,l.ie)({columns:[e.chunkId,e.messageId,e.queryId]})})),h=(0,s.cJ)("message_chunks",{messageId:(0,i.Qq)("message_id").references(()=>g.id,{onDelete:"cascade"}),chunkId:(0,_.uR)("chunk_id").references(()=>A.VN.id,{onDelete:"cascade"})},e=>({pk:(0,l.ie)({columns:[e.chunkId,e.messageId]})}))},96334:(e,t,n)=>{"use strict";n.d(t,{y:()=>s});let s=async e=>await new Promise(t=>{setTimeout(t,e)})}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.