opensentinel 2.1.1 → 3.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +354 -283
- package/dist/archiver-AVNBYCKQ.js +15340 -0
- package/dist/archiver-AVNBYCKQ.js.map +1 -0
- package/dist/audit-logger-OBPR7CRO.js +22 -0
- package/dist/auth-UOX5K2BE.js +18 -0
- package/dist/autonomy-ZXDBDQUJ.js +86 -0
- package/dist/autonomy-ZXDBDQUJ.js.map +1 -0
- package/dist/aws-s3-Q4LLZZPD.js +146 -0
- package/dist/aws-s3-Q4LLZZPD.js.map +1 -0
- package/dist/backup-restore-PZ7CYYB7.js +16 -0
- package/dist/blocks-R3PODY47.js +23 -0
- package/dist/bot-QRARP4UN.js +36 -0
- package/dist/brain-7XLLM3KC.js +56 -0
- package/dist/camera-monitor-M5CYKUU4.js +335 -0
- package/dist/camera-monitor-M5CYKUU4.js.map +1 -0
- package/dist/{charts-MMXM6BWW.js → charts-V7ARZNKF.js} +2 -2
- package/dist/chunk-22VGGA7S.js +330 -0
- package/dist/chunk-22VGGA7S.js.map +1 -0
- package/dist/chunk-35WYTA3C.js +382 -0
- package/dist/chunk-35WYTA3C.js.map +1 -0
- package/dist/chunk-3E2PSU2C.js +146 -0
- package/dist/chunk-3E2PSU2C.js.map +1 -0
- package/dist/{chunk-L3F43VPB.js → chunk-4GLYY4NN.js} +2 -2
- package/dist/{chunk-L3F43VPB.js.map → chunk-4GLYY4NN.js.map} +1 -1
- package/dist/{chunk-L3PDU3XN.js → chunk-4UOE5TUZ.js} +4 -4
- package/dist/{chunk-6SNHU3CY.js → chunk-66OJ3WB4.js} +2 -2
- package/dist/chunk-6KONMXQ6.js +297 -0
- package/dist/chunk-6KONMXQ6.js.map +1 -0
- package/dist/chunk-6PMVAAA7.js +196 -0
- package/dist/chunk-6PMVAAA7.js.map +1 -0
- package/dist/chunk-766ASQWE.js +32620 -0
- package/dist/chunk-766ASQWE.js.map +1 -0
- package/dist/chunk-7WQO5J2M.js +29 -0
- package/dist/chunk-7WQO5J2M.js.map +1 -0
- package/dist/chunk-APHSRMBS.js +148 -0
- package/dist/chunk-APHSRMBS.js.map +1 -0
- package/dist/{chunk-4LVWXUNC.js → chunk-AYUKPTSM.js} +57 -39
- package/dist/chunk-AYUKPTSM.js.map +1 -0
- package/dist/chunk-BIPYADGB.js +84 -0
- package/dist/chunk-BIPYADGB.js.map +1 -0
- package/dist/chunk-BRBWNV65.js +457 -0
- package/dist/chunk-BRBWNV65.js.map +1 -0
- package/dist/chunk-BXZ6EA52.js +382 -0
- package/dist/chunk-BXZ6EA52.js.map +1 -0
- package/dist/chunk-EVE7MIIY.js +290 -0
- package/dist/chunk-EVE7MIIY.js.map +1 -0
- package/dist/chunk-F3TTNID2.js +138 -0
- package/dist/chunk-F3TTNID2.js.map +1 -0
- package/dist/chunk-H5RQOFO2.js +190 -0
- package/dist/chunk-H5RQOFO2.js.map +1 -0
- package/dist/chunk-HN3F4WSW.js +145 -0
- package/dist/chunk-HN3F4WSW.js.map +1 -0
- package/dist/{chunk-6DRDKB45.js → chunk-I6BDYQIG.js} +20 -9
- package/dist/chunk-I6BDYQIG.js.map +1 -0
- package/dist/chunk-IZJMVV7O.js +347 -0
- package/dist/chunk-IZJMVV7O.js.map +1 -0
- package/dist/chunk-KM22GV7G.js +211 -0
- package/dist/chunk-KM22GV7G.js.map +1 -0
- package/dist/chunk-MGFBLVR7.js +103 -0
- package/dist/chunk-MGFBLVR7.js.map +1 -0
- package/dist/chunk-MQJ2ECQT.js +228 -0
- package/dist/chunk-MQJ2ECQT.js.map +1 -0
- package/dist/{chunk-F6QUZQGI.js → chunk-MXAPLSJ5.js} +2 -2
- package/dist/{chunk-GK3E2I7A.js → chunk-NHMBTUMW.js} +2 -2
- package/dist/chunk-NPRTSZIF.js +131 -0
- package/dist/chunk-NPRTSZIF.js.map +1 -0
- package/dist/chunk-O7IH7JTI.js +1898 -0
- package/dist/chunk-O7IH7JTI.js.map +1 -0
- package/dist/chunk-OCVQGBJK.js +293 -0
- package/dist/chunk-OCVQGBJK.js.map +1 -0
- package/dist/chunk-P6QINGFL.js +332 -0
- package/dist/chunk-P6QINGFL.js.map +1 -0
- package/dist/chunk-PHDZKPNE.js +91 -0
- package/dist/chunk-PHDZKPNE.js.map +1 -0
- package/dist/chunk-PLDDJCW6.js +49 -0
- package/dist/chunk-PTGTGXV2.js +164 -0
- package/dist/chunk-PTGTGXV2.js.map +1 -0
- package/dist/chunk-REMIY4U2.js +171 -0
- package/dist/chunk-REMIY4U2.js.map +1 -0
- package/dist/chunk-RZ4YESBG.js +141 -0
- package/dist/chunk-RZ4YESBG.js.map +1 -0
- package/dist/chunk-SAX5MHK4.js +111 -0
- package/dist/chunk-SAX5MHK4.js.map +1 -0
- package/dist/{chunk-GVJVEWHI.js → chunk-SJSUSJ47.js} +2 -2
- package/dist/chunk-SPPMCAKG.js +777 -0
- package/dist/chunk-SPPMCAKG.js.map +1 -0
- package/dist/chunk-SVAPX2XN.js +2441 -0
- package/dist/chunk-SVAPX2XN.js.map +1 -0
- package/dist/chunk-TVEWKIK3.js +452 -0
- package/dist/chunk-TVEWKIK3.js.map +1 -0
- package/dist/{chunk-HH2HBTQM.js → chunk-TYAGMJNV.js} +5 -5
- package/dist/{chunk-JXUP2X7V.js → chunk-VEHFVBLI.js} +2 -2
- package/dist/chunk-VNX5GMTN.js +128 -0
- package/dist/chunk-VNX5GMTN.js.map +1 -0
- package/dist/chunk-VRD5CYRL.js +1568 -0
- package/dist/chunk-VRD5CYRL.js.map +1 -0
- package/dist/chunk-WLUHNG6X.js +122 -0
- package/dist/chunk-WLUHNG6X.js.map +1 -0
- package/dist/chunk-WRAKK6K6.js +265 -0
- package/dist/chunk-WRAKK6K6.js.map +1 -0
- package/dist/chunk-XKYRH4FM.js +681 -0
- package/dist/chunk-XKYRH4FM.js.map +1 -0
- package/dist/{chunk-GUBEEYDW.js → chunk-XMCVRVTF.js} +2 -2
- package/dist/{chunk-GUBEEYDW.js.map → chunk-XMCVRVTF.js.map} +1 -1
- package/dist/chunk-ZLZKF2PM.js +310 -0
- package/dist/chunk-ZLZKF2PM.js.map +1 -0
- package/dist/cli.js +5 -1
- package/dist/cli.js.map +1 -1
- package/dist/client-ZQSFPMOB.js +21 -0
- package/dist/clipboard-manager-TEO2GEDN.js +24 -0
- package/dist/commands/setup.js +3 -3
- package/dist/commands/setup.js.map +1 -1
- package/dist/commands/start.js +3 -3
- package/dist/commands/status.js +2 -2
- package/dist/commands/stop.js +2 -2
- package/dist/commands/utils.js +2 -2
- package/dist/cron-explain-HHQKPD3M.js +16 -0
- package/dist/crypto-4AP47IKC.js +14 -0
- package/dist/crypto-4AP47IKC.js.map +1 -0
- package/dist/databases-37X4CI2Y.js +21 -0
- package/dist/databases-37X4CI2Y.js.map +1 -0
- package/dist/discord-B3HUPGQ6.js +70 -0
- package/dist/discord-B3HUPGQ6.js.map +1 -0
- package/dist/dist-UISMLMFN.js +21847 -0
- package/dist/dist-UISMLMFN.js.map +1 -0
- package/dist/email-K7LO2IPB.js +268 -0
- package/dist/email-K7LO2IPB.js.map +1 -0
- package/dist/enhanced-retrieval-DNLLEM4Z.js +753 -0
- package/dist/enhanced-retrieval-DNLLEM4Z.js.map +1 -0
- package/dist/enrichment-pipeline-MNHNW65K.js +13 -0
- package/dist/enrichment-pipeline-MNHNW65K.js.map +1 -0
- package/dist/entity-resolution-Y3IUWEAT.js +24 -0
- package/dist/entity-resolution-Y3IUWEAT.js.map +1 -0
- package/dist/env-IWXUVTCB.js +12 -0
- package/dist/env-IWXUVTCB.js.map +1 -0
- package/dist/google-workspace-DKWUVNGC.js +169 -0
- package/dist/google-workspace-DKWUVNGC.js.map +1 -0
- package/dist/hash-tool-ULQYD7B5.js +22 -0
- package/dist/hash-tool-ULQYD7B5.js.map +1 -0
- package/dist/heartbeat-monitor-GCISLXI3.js +22 -0
- package/dist/heartbeat-monitor-GCISLXI3.js.map +1 -0
- package/dist/image-generation-OSU7FP6F.js +486 -0
- package/dist/image-generation-OSU7FP6F.js.map +1 -0
- package/dist/imessage-NGA2XF2V.js +35 -0
- package/dist/imessage-NGA2XF2V.js.map +1 -0
- package/dist/inbox-summarizer-NRI4S7IF.js +47 -0
- package/dist/inbox-summarizer-NRI4S7IF.js.map +1 -0
- package/dist/incident-response-C5J7Q6DT.js +244 -0
- package/dist/incident-response-C5J7Q6DT.js.map +1 -0
- package/dist/inventory-manager-352OHXWD.js +24 -0
- package/dist/inventory-manager-352OHXWD.js.map +1 -0
- package/dist/jira-GSGDBMIG.js +199 -0
- package/dist/jira-GSGDBMIG.js.map +1 -0
- package/dist/json-tool-QE2SYHEG.js +26 -0
- package/dist/json-tool-QE2SYHEG.js.map +1 -0
- package/dist/key-rotation-DPHU4ZTB.js +18 -0
- package/dist/key-rotation-DPHU4ZTB.js.map +1 -0
- package/dist/lib.d.ts +603 -11
- package/dist/lib.js +161 -35
- package/dist/lib.js.map +1 -1
- package/dist/mailchimp-KKNF6QJ7.js +152 -0
- package/dist/mailchimp-KKNF6QJ7.js.map +1 -0
- package/dist/matrix-QVHG76I7.js +279 -0
- package/dist/matrix-QVHG76I7.js.map +1 -0
- package/dist/{mcp-LS7Q3Z5W.js → mcp-3JI6W7ZE.js} +3 -3
- package/dist/mcp-3JI6W7ZE.js.map +1 -0
- package/dist/microsoft365-UCBKJHNX.js +164 -0
- package/dist/microsoft365-UCBKJHNX.js.map +1 -0
- package/dist/ocr-AC7NPX33.js +22 -0
- package/dist/ocr-AC7NPX33.js.map +1 -0
- package/dist/ollama-BOAMSPLJ.js +8 -0
- package/dist/ollama-BOAMSPLJ.js.map +1 -0
- package/dist/pages-MI523RB7.js +26 -0
- package/dist/pages-MI523RB7.js.map +1 -0
- package/dist/pair-JDFTERIK.js +24 -0
- package/dist/pair-JDFTERIK.js.map +1 -0
- package/dist/pairing-IFQYCPNS.js +10 -0
- package/dist/pairing-IFQYCPNS.js.map +1 -0
- package/dist/pdf-ALQVOEJR.js +17 -0
- package/dist/pdf-ALQVOEJR.js.map +1 -0
- package/dist/presentations-DSV5IHG5.js +1002 -0
- package/dist/presentations-DSV5IHG5.js.map +1 -0
- package/dist/prometheus-JNT2BD4L.js +10 -0
- package/dist/prometheus-JNT2BD4L.js.map +1 -0
- package/dist/providers-J4LYPHDR.js +19 -0
- package/dist/providers-J4LYPHDR.js.map +1 -0
- package/dist/qr-code-WIX4PB4U.js +16 -0
- package/dist/qr-code-WIX4PB4U.js.map +1 -0
- package/dist/quickbooks-XB4NII2S.js +190 -0
- package/dist/quickbooks-XB4NII2S.js.map +1 -0
- package/dist/regex-tool-W4ABRKGK.js +24 -0
- package/dist/regex-tool-W4ABRKGK.js.map +1 -0
- package/dist/scheduler-VK4WFERV.js +63 -0
- package/dist/scheduler-VK4WFERV.js.map +1 -0
- package/dist/search-BCLBO5E3.js +25 -0
- package/dist/search-BCLBO5E3.js.map +1 -0
- package/dist/sendgrid-RNXCAFKM.js +152 -0
- package/dist/sendgrid-RNXCAFKM.js.map +1 -0
- package/dist/shopify-NCXYJB4R.js +171 -0
- package/dist/shopify-NCXYJB4R.js.map +1 -0
- package/dist/signal-6CGDFYL2.js +35 -0
- package/dist/signal-6CGDFYL2.js.map +1 -0
- package/dist/slack-IZQWIKOH.js +75 -0
- package/dist/slack-IZQWIKOH.js.map +1 -0
- package/dist/sms-M3JIOTCW.js +23 -0
- package/dist/sms-M3JIOTCW.js.map +1 -0
- package/dist/{src-K7GASHRH.js → src-VYUE6LRA.js} +138 -32
- package/dist/src-VYUE6LRA.js.map +1 -0
- package/dist/stocks-XXWBPOCU.js +14 -0
- package/dist/stocks-XXWBPOCU.js.map +1 -0
- package/dist/text-transform-6SGUA5Z4.js +22 -0
- package/dist/text-transform-6SGUA5Z4.js.map +1 -0
- package/dist/tools-2RLEI2N6.js +38 -0
- package/dist/tools-2RLEI2N6.js.map +1 -0
- package/dist/tunnel-IWMXUML4.js +301 -0
- package/dist/tunnel-IWMXUML4.js.map +1 -0
- package/dist/twilio-53GEW5JT.js +139 -0
- package/dist/twilio-53GEW5JT.js.map +1 -0
- package/dist/unit-converter-ZYXMEZOE.js +14 -0
- package/dist/unit-converter-ZYXMEZOE.js.map +1 -0
- package/dist/whatsapp-LFX6YKCM.js +35 -0
- package/dist/whatsapp-LFX6YKCM.js.map +1 -0
- package/dist/word-document-7B6SJMAY.js +902 -0
- package/dist/word-document-7B6SJMAY.js.map +1 -0
- package/dist/xero-QYO66D45.js +162 -0
- package/dist/xero-QYO66D45.js.map +1 -0
- package/dist/zapier-webhook-TBZ5YF2A.js +106 -0
- package/dist/zapier-webhook-TBZ5YF2A.js.map +1 -0
- package/drizzle/0002_mushy_master_mold.sql +140 -0
- package/drizzle/meta/0002_snapshot.json +3637 -0
- package/drizzle/meta/_journal.json +7 -0
- package/package.json +100 -98
- package/dist/bot-KJ26BG56.js +0 -15
- package/dist/chunk-4LVWXUNC.js.map +0 -1
- package/dist/chunk-4TG2IG5K.js +0 -5249
- package/dist/chunk-4TG2IG5K.js.map +0 -1
- package/dist/chunk-6DRDKB45.js.map +0 -1
- package/dist/chunk-CI6Q63MM.js +0 -1613
- package/dist/chunk-CI6Q63MM.js.map +0 -1
- package/dist/chunk-KHNYJY2Z.js +0 -178
- package/dist/chunk-KHNYJY2Z.js.map +0 -1
- package/dist/chunk-NSBPE2FW.js +0 -17
- package/dist/discord-ZOJFTVTB.js +0 -49
- package/dist/imessage-JFRB6EJ7.js +0 -14
- package/dist/scheduler-EZ7CZMCS.js +0 -42
- package/dist/signal-T3MCSULM.js +0 -14
- package/dist/slack-N2M4FHAJ.js +0 -54
- package/dist/src-K7GASHRH.js.map +0 -1
- package/dist/tools-24GZHYRF.js +0 -16
- package/dist/whatsapp-VCRUPAO5.js +0 -14
- /package/dist/{bot-KJ26BG56.js.map → audit-logger-OBPR7CRO.js.map} +0 -0
- /package/dist/{chunk-NSBPE2FW.js.map → auth-UOX5K2BE.js.map} +0 -0
- /package/dist/{discord-ZOJFTVTB.js.map → backup-restore-PZ7CYYB7.js.map} +0 -0
- /package/dist/{imessage-JFRB6EJ7.js.map → blocks-R3PODY47.js.map} +0 -0
- /package/dist/{mcp-LS7Q3Z5W.js.map → bot-QRARP4UN.js.map} +0 -0
- /package/dist/{scheduler-EZ7CZMCS.js.map → brain-7XLLM3KC.js.map} +0 -0
- /package/dist/{charts-MMXM6BWW.js.map → charts-V7ARZNKF.js.map} +0 -0
- /package/dist/{chunk-L3PDU3XN.js.map → chunk-4UOE5TUZ.js.map} +0 -0
- /package/dist/{chunk-6SNHU3CY.js.map → chunk-66OJ3WB4.js.map} +0 -0
- /package/dist/{chunk-F6QUZQGI.js.map → chunk-MXAPLSJ5.js.map} +0 -0
- /package/dist/{chunk-GK3E2I7A.js.map → chunk-NHMBTUMW.js.map} +0 -0
- /package/dist/{signal-T3MCSULM.js.map → chunk-PLDDJCW6.js.map} +0 -0
- /package/dist/{chunk-GVJVEWHI.js.map → chunk-SJSUSJ47.js.map} +0 -0
- /package/dist/{chunk-HH2HBTQM.js.map → chunk-TYAGMJNV.js.map} +0 -0
- /package/dist/{chunk-JXUP2X7V.js.map → chunk-VEHFVBLI.js.map} +0 -0
- /package/dist/{slack-N2M4FHAJ.js.map → client-ZQSFPMOB.js.map} +0 -0
- /package/dist/{tools-24GZHYRF.js.map → clipboard-manager-TEO2GEDN.js.map} +0 -0
- /package/dist/{whatsapp-VCRUPAO5.js.map → cron-explain-HHQKPD3M.js.map} +0 -0
|
@@ -0,0 +1,681 @@
|
|
|
1
|
+
import {
|
|
2
|
+
env
|
|
3
|
+
} from "./chunk-ZLZKF2PM.js";
|
|
4
|
+
import {
|
|
5
|
+
__export
|
|
6
|
+
} from "./chunk-PLDDJCW6.js";
|
|
7
|
+
|
|
8
|
+
// src/db/schema.ts
|
|
9
|
+
var schema_exports = {};
|
|
10
|
+
__export(schema_exports, {
|
|
11
|
+
achievements: () => achievements,
|
|
12
|
+
agentMessages: () => agentMessages,
|
|
13
|
+
agentProgress: () => agentProgress,
|
|
14
|
+
apiKeys: () => apiKeys,
|
|
15
|
+
archivedMemories: () => archivedMemories,
|
|
16
|
+
auditLogs: () => auditLogs,
|
|
17
|
+
calendarTriggers: () => calendarTriggers,
|
|
18
|
+
conversations: () => conversations,
|
|
19
|
+
documentChunks: () => documentChunks,
|
|
20
|
+
documents: () => documents,
|
|
21
|
+
errorLogs: () => errorLogs,
|
|
22
|
+
evolutionModes: () => evolutionModes,
|
|
23
|
+
graphEntities: () => graphEntities,
|
|
24
|
+
graphRelationships: () => graphRelationships,
|
|
25
|
+
incidentTimeline: () => incidentTimeline,
|
|
26
|
+
memories: () => memories,
|
|
27
|
+
messages: () => messages,
|
|
28
|
+
metrics: () => metrics,
|
|
29
|
+
organizationMembers: () => organizationMembers,
|
|
30
|
+
organizations: () => organizations,
|
|
31
|
+
personas: () => personas,
|
|
32
|
+
rateLimits: () => rateLimits,
|
|
33
|
+
scheduledTasks: () => scheduledTasks,
|
|
34
|
+
securityIncidents: () => securityIncidents,
|
|
35
|
+
sessions: () => sessions,
|
|
36
|
+
sharedMemories: () => sharedMemories,
|
|
37
|
+
subAgents: () => subAgents,
|
|
38
|
+
toolLogs: () => toolLogs,
|
|
39
|
+
twoFactorAuth: () => twoFactorAuth,
|
|
40
|
+
usagePatterns: () => usagePatterns,
|
|
41
|
+
usageQuotas: () => usageQuotas,
|
|
42
|
+
userAchievements: () => userAchievements,
|
|
43
|
+
users: () => users
|
|
44
|
+
});
|
|
45
|
+
import {
|
|
46
|
+
pgTable,
|
|
47
|
+
text,
|
|
48
|
+
timestamp,
|
|
49
|
+
uuid,
|
|
50
|
+
integer,
|
|
51
|
+
jsonb,
|
|
52
|
+
boolean,
|
|
53
|
+
vector,
|
|
54
|
+
index,
|
|
55
|
+
customType
|
|
56
|
+
} from "drizzle-orm/pg-core";
|
|
57
|
+
var tsvector = customType({
|
|
58
|
+
dataType() {
|
|
59
|
+
return "tsvector";
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
var users = pgTable("users", {
|
|
63
|
+
id: uuid("id").primaryKey().defaultRandom(),
|
|
64
|
+
telegramId: text("telegram_id").unique(),
|
|
65
|
+
name: text("name"),
|
|
66
|
+
preferences: jsonb("preferences").$type(),
|
|
67
|
+
createdAt: timestamp("created_at").defaultNow().notNull(),
|
|
68
|
+
updatedAt: timestamp("updated_at").defaultNow().notNull()
|
|
69
|
+
});
|
|
70
|
+
var conversations = pgTable("conversations", {
|
|
71
|
+
id: uuid("id").primaryKey().defaultRandom(),
|
|
72
|
+
userId: uuid("user_id").references(() => users.id),
|
|
73
|
+
title: text("title"),
|
|
74
|
+
source: text("source").notNull().default("telegram"),
|
|
75
|
+
// telegram, web, api
|
|
76
|
+
metadata: jsonb("metadata"),
|
|
77
|
+
createdAt: timestamp("created_at").defaultNow().notNull(),
|
|
78
|
+
updatedAt: timestamp("updated_at").defaultNow().notNull()
|
|
79
|
+
});
|
|
80
|
+
var messages = pgTable(
|
|
81
|
+
"messages",
|
|
82
|
+
{
|
|
83
|
+
id: uuid("id").primaryKey().defaultRandom(),
|
|
84
|
+
conversationId: uuid("conversation_id").references(() => conversations.id).notNull(),
|
|
85
|
+
role: text("role").notNull().$type(),
|
|
86
|
+
content: text("content").notNull(),
|
|
87
|
+
tokenCount: integer("token_count"),
|
|
88
|
+
metadata: jsonb("metadata"),
|
|
89
|
+
encrypted: boolean("encrypted").default(false).notNull(),
|
|
90
|
+
createdAt: timestamp("created_at").defaultNow().notNull()
|
|
91
|
+
},
|
|
92
|
+
(table) => [index("messages_conversation_idx").on(table.conversationId)]
|
|
93
|
+
);
|
|
94
|
+
var memories = pgTable(
|
|
95
|
+
"memories",
|
|
96
|
+
{
|
|
97
|
+
id: uuid("id").primaryKey().defaultRandom(),
|
|
98
|
+
userId: uuid("user_id").references(() => users.id),
|
|
99
|
+
type: text("type").notNull().$type(),
|
|
100
|
+
content: text("content").notNull(),
|
|
101
|
+
embedding: vector("embedding", { dimensions: 1536 }),
|
|
102
|
+
// OpenAI embedding size
|
|
103
|
+
searchVector: tsvector("search_vector"),
|
|
104
|
+
// Full-text search vector (GIN indexed)
|
|
105
|
+
importance: integer("importance").default(5),
|
|
106
|
+
// 1-10 scale
|
|
107
|
+
source: text("source"),
|
|
108
|
+
// Where this memory came from
|
|
109
|
+
provenance: text("provenance"),
|
|
110
|
+
// Origin tracking: "conversation:id", "api:manual", "extraction:auto"
|
|
111
|
+
metadata: jsonb("metadata"),
|
|
112
|
+
encrypted: boolean("encrypted").default(false).notNull(),
|
|
113
|
+
lastAccessed: timestamp("last_accessed").defaultNow(),
|
|
114
|
+
createdAt: timestamp("created_at").defaultNow().notNull()
|
|
115
|
+
},
|
|
116
|
+
(table) => [index("memories_user_idx").on(table.userId)]
|
|
117
|
+
);
|
|
118
|
+
var scheduledTasks = pgTable("scheduled_tasks", {
|
|
119
|
+
id: uuid("id").primaryKey().defaultRandom(),
|
|
120
|
+
userId: uuid("user_id").references(() => users.id),
|
|
121
|
+
name: text("name").notNull(),
|
|
122
|
+
description: text("description"),
|
|
123
|
+
cronExpression: text("cron_expression"),
|
|
124
|
+
nextRunAt: timestamp("next_run_at"),
|
|
125
|
+
lastRunAt: timestamp("last_run_at"),
|
|
126
|
+
enabled: boolean("enabled").default(true),
|
|
127
|
+
action: jsonb("action").$type(),
|
|
128
|
+
createdAt: timestamp("created_at").defaultNow().notNull()
|
|
129
|
+
});
|
|
130
|
+
var toolLogs = pgTable(
|
|
131
|
+
"tool_logs",
|
|
132
|
+
{
|
|
133
|
+
id: uuid("id").primaryKey().defaultRandom(),
|
|
134
|
+
conversationId: uuid("conversation_id").references(() => conversations.id),
|
|
135
|
+
toolName: text("tool_name").notNull(),
|
|
136
|
+
input: jsonb("input"),
|
|
137
|
+
output: jsonb("output"),
|
|
138
|
+
success: boolean("success").notNull(),
|
|
139
|
+
durationMs: integer("duration_ms"),
|
|
140
|
+
createdAt: timestamp("created_at").defaultNow().notNull()
|
|
141
|
+
},
|
|
142
|
+
(table) => [index("tool_logs_conversation_idx").on(table.conversationId)]
|
|
143
|
+
);
|
|
144
|
+
var sessions = pgTable(
|
|
145
|
+
"sessions",
|
|
146
|
+
{
|
|
147
|
+
id: uuid("id").primaryKey().defaultRandom(),
|
|
148
|
+
userId: uuid("user_id").references(() => users.id).notNull(),
|
|
149
|
+
token: text("token").notNull().unique(),
|
|
150
|
+
deviceInfo: jsonb("device_info").$type(),
|
|
151
|
+
ipAddress: text("ip_address"),
|
|
152
|
+
createdAt: timestamp("created_at").defaultNow().notNull(),
|
|
153
|
+
expiresAt: timestamp("expires_at").notNull(),
|
|
154
|
+
lastActiveAt: timestamp("last_active_at").defaultNow()
|
|
155
|
+
},
|
|
156
|
+
(table) => [index("sessions_user_idx").on(table.userId)]
|
|
157
|
+
);
|
|
158
|
+
var auditLogs = pgTable(
|
|
159
|
+
"audit_logs",
|
|
160
|
+
{
|
|
161
|
+
id: uuid("id").primaryKey().defaultRandom(),
|
|
162
|
+
userId: uuid("user_id").references(() => users.id),
|
|
163
|
+
sessionId: uuid("session_id").references(() => sessions.id),
|
|
164
|
+
action: text("action").notNull(),
|
|
165
|
+
// 'tool_use', 'login', 'settings_change', etc.
|
|
166
|
+
resource: text("resource"),
|
|
167
|
+
// 'shell', 'file', 'memory', etc.
|
|
168
|
+
resourceId: text("resource_id"),
|
|
169
|
+
// ID of the affected resource
|
|
170
|
+
details: jsonb("details"),
|
|
171
|
+
ipAddress: text("ip_address"),
|
|
172
|
+
userAgent: text("user_agent"),
|
|
173
|
+
success: boolean("success").default(true),
|
|
174
|
+
createdAt: timestamp("created_at").defaultNow().notNull(),
|
|
175
|
+
// Tamper-proof chain fields (SOC 2)
|
|
176
|
+
sequenceNumber: integer("sequence_number"),
|
|
177
|
+
entryHash: text("entry_hash"),
|
|
178
|
+
previousHash: text("previous_hash")
|
|
179
|
+
},
|
|
180
|
+
(table) => [
|
|
181
|
+
index("audit_logs_user_idx").on(table.userId),
|
|
182
|
+
index("audit_logs_action_idx").on(table.action),
|
|
183
|
+
index("audit_logs_created_idx").on(table.createdAt),
|
|
184
|
+
index("audit_logs_sequence_idx").on(table.sequenceNumber)
|
|
185
|
+
]
|
|
186
|
+
);
|
|
187
|
+
var apiKeys = pgTable(
|
|
188
|
+
"api_keys",
|
|
189
|
+
{
|
|
190
|
+
id: uuid("id").primaryKey().defaultRandom(),
|
|
191
|
+
userId: uuid("user_id").references(() => users.id).notNull(),
|
|
192
|
+
name: text("name").notNull(),
|
|
193
|
+
keyHash: text("key_hash").notNull(),
|
|
194
|
+
// bcrypt hash of the key
|
|
195
|
+
keyPrefix: text("key_prefix").notNull(),
|
|
196
|
+
// First 8 chars for identification (e.g., "mb_live_")
|
|
197
|
+
permissions: jsonb("permissions").$type(),
|
|
198
|
+
// ['chat:basic', 'tools:shell', etc.]
|
|
199
|
+
lastUsedAt: timestamp("last_used_at"),
|
|
200
|
+
expiresAt: timestamp("expires_at"),
|
|
201
|
+
createdAt: timestamp("created_at").defaultNow().notNull(),
|
|
202
|
+
revokedAt: timestamp("revoked_at")
|
|
203
|
+
},
|
|
204
|
+
(table) => [index("api_keys_user_idx").on(table.userId)]
|
|
205
|
+
);
|
|
206
|
+
var rateLimits = pgTable(
|
|
207
|
+
"rate_limits",
|
|
208
|
+
{
|
|
209
|
+
id: uuid("id").primaryKey().defaultRandom(),
|
|
210
|
+
identifier: text("identifier").notNull(),
|
|
211
|
+
// userId, IP, or API key prefix
|
|
212
|
+
endpoint: text("endpoint").notNull(),
|
|
213
|
+
// 'api/chat', 'tool/shell', etc.
|
|
214
|
+
windowStart: timestamp("window_start").notNull(),
|
|
215
|
+
requestCount: integer("request_count").default(0),
|
|
216
|
+
lastRequest: timestamp("last_request")
|
|
217
|
+
},
|
|
218
|
+
(table) => [
|
|
219
|
+
index("rate_limits_identifier_endpoint_idx").on(
|
|
220
|
+
table.identifier,
|
|
221
|
+
table.endpoint
|
|
222
|
+
)
|
|
223
|
+
]
|
|
224
|
+
);
|
|
225
|
+
var metrics = pgTable(
|
|
226
|
+
"metrics",
|
|
227
|
+
{
|
|
228
|
+
id: uuid("id").primaryKey().defaultRandom(),
|
|
229
|
+
name: text("name").notNull(),
|
|
230
|
+
// 'response_latency', 'token_usage', 'tool_duration', etc.
|
|
231
|
+
value: integer("value").notNull(),
|
|
232
|
+
unit: text("unit"),
|
|
233
|
+
// 'ms', 'tokens', 'bytes', etc.
|
|
234
|
+
tags: jsonb("tags").$type(),
|
|
235
|
+
// { tool: 'shell', status: 'success' }
|
|
236
|
+
timestamp: timestamp("timestamp").defaultNow().notNull()
|
|
237
|
+
},
|
|
238
|
+
(table) => [
|
|
239
|
+
index("metrics_name_timestamp_idx").on(table.name, table.timestamp)
|
|
240
|
+
]
|
|
241
|
+
);
|
|
242
|
+
var errorLogs = pgTable(
|
|
243
|
+
"error_logs",
|
|
244
|
+
{
|
|
245
|
+
id: uuid("id").primaryKey().defaultRandom(),
|
|
246
|
+
source: text("source").notNull(),
|
|
247
|
+
// 'brain', 'tool', 'telegram', 'api', 'scheduler'
|
|
248
|
+
errorType: text("error_type").notNull(),
|
|
249
|
+
// 'ApiError', 'ValidationError', etc.
|
|
250
|
+
errorCode: text("error_code"),
|
|
251
|
+
// Application-specific error codes
|
|
252
|
+
message: text("message").notNull(),
|
|
253
|
+
stack: text("stack"),
|
|
254
|
+
context: jsonb("context"),
|
|
255
|
+
// Additional context like request data
|
|
256
|
+
userId: uuid("user_id").references(() => users.id),
|
|
257
|
+
conversationId: uuid("conversation_id").references(() => conversations.id),
|
|
258
|
+
resolved: boolean("resolved").default(false),
|
|
259
|
+
createdAt: timestamp("created_at").defaultNow().notNull()
|
|
260
|
+
},
|
|
261
|
+
(table) => [
|
|
262
|
+
index("error_logs_source_idx").on(table.source),
|
|
263
|
+
index("error_logs_created_idx").on(table.createdAt)
|
|
264
|
+
]
|
|
265
|
+
);
|
|
266
|
+
var usagePatterns = pgTable(
|
|
267
|
+
"usage_patterns",
|
|
268
|
+
{
|
|
269
|
+
id: uuid("id").primaryKey().defaultRandom(),
|
|
270
|
+
userId: uuid("user_id").references(() => users.id).notNull(),
|
|
271
|
+
patternType: text("pattern_type").notNull(),
|
|
272
|
+
// 'tool_usage', 'topic', 'time_of_day', 'complexity'
|
|
273
|
+
patternKey: text("pattern_key").notNull(),
|
|
274
|
+
// e.g., 'shell', 'morning', 'coding'
|
|
275
|
+
patternData: jsonb("pattern_data"),
|
|
276
|
+
confidence: integer("confidence").default(0),
|
|
277
|
+
// 0-100
|
|
278
|
+
firstSeen: timestamp("first_seen").defaultNow().notNull(),
|
|
279
|
+
lastSeen: timestamp("last_seen").defaultNow(),
|
|
280
|
+
occurrences: integer("occurrences").default(1)
|
|
281
|
+
},
|
|
282
|
+
(table) => [
|
|
283
|
+
index("usage_patterns_user_idx").on(table.userId),
|
|
284
|
+
index("usage_patterns_type_idx").on(table.patternType)
|
|
285
|
+
]
|
|
286
|
+
);
|
|
287
|
+
var achievements = pgTable("achievements", {
|
|
288
|
+
id: uuid("id").primaryKey().defaultRandom(),
|
|
289
|
+
code: text("code").notNull().unique(),
|
|
290
|
+
// 'first_tool_use', 'power_user', 'researcher'
|
|
291
|
+
name: text("name").notNull(),
|
|
292
|
+
description: text("description"),
|
|
293
|
+
iconEmoji: text("icon_emoji"),
|
|
294
|
+
// Emoji to display
|
|
295
|
+
category: text("category"),
|
|
296
|
+
// 'exploration', 'productivity', 'mastery'
|
|
297
|
+
criteria: jsonb("criteria").$type(),
|
|
298
|
+
points: integer("points").default(10),
|
|
299
|
+
createdAt: timestamp("created_at").defaultNow().notNull()
|
|
300
|
+
});
|
|
301
|
+
var userAchievements = pgTable(
|
|
302
|
+
"user_achievements",
|
|
303
|
+
{
|
|
304
|
+
id: uuid("id").primaryKey().defaultRandom(),
|
|
305
|
+
userId: uuid("user_id").references(() => users.id).notNull(),
|
|
306
|
+
achievementId: uuid("achievement_id").references(() => achievements.id).notNull(),
|
|
307
|
+
unlockedAt: timestamp("unlocked_at").defaultNow().notNull(),
|
|
308
|
+
progress: integer("progress").default(100),
|
|
309
|
+
// For progressive achievements
|
|
310
|
+
notified: boolean("notified").default(false)
|
|
311
|
+
},
|
|
312
|
+
(table) => [index("user_achievements_user_idx").on(table.userId)]
|
|
313
|
+
);
|
|
314
|
+
var evolutionModes = pgTable(
|
|
315
|
+
"molt_modes",
|
|
316
|
+
{
|
|
317
|
+
id: uuid("id").primaryKey().defaultRandom(),
|
|
318
|
+
userId: uuid("user_id").references(() => users.id).notNull(),
|
|
319
|
+
mode: text("mode").notNull().$type(),
|
|
320
|
+
activatedAt: timestamp("activated_at").defaultNow().notNull(),
|
|
321
|
+
deactivatedAt: timestamp("deactivated_at"),
|
|
322
|
+
metadata: jsonb("metadata")
|
|
323
|
+
},
|
|
324
|
+
(table) => [index("molt_modes_user_idx").on(table.userId)]
|
|
325
|
+
);
|
|
326
|
+
var archivedMemories = pgTable(
|
|
327
|
+
"archived_memories",
|
|
328
|
+
{
|
|
329
|
+
id: uuid("id").primaryKey().defaultRandom(),
|
|
330
|
+
originalMemoryId: uuid("original_memory_id").notNull(),
|
|
331
|
+
userId: uuid("user_id").references(() => users.id),
|
|
332
|
+
type: text("type").notNull().$type(),
|
|
333
|
+
content: text("content").notNull(),
|
|
334
|
+
reason: text("reason"),
|
|
335
|
+
// 'stale', 'duplicate', 'low_importance', 'user_request'
|
|
336
|
+
originalCreatedAt: timestamp("original_created_at"),
|
|
337
|
+
archivedAt: timestamp("archived_at").defaultNow().notNull()
|
|
338
|
+
},
|
|
339
|
+
(table) => [index("archived_memories_user_idx").on(table.userId)]
|
|
340
|
+
);
|
|
341
|
+
var calendarTriggers = pgTable(
|
|
342
|
+
"calendar_triggers",
|
|
343
|
+
{
|
|
344
|
+
id: uuid("id").primaryKey().defaultRandom(),
|
|
345
|
+
userId: uuid("user_id").references(() => users.id).notNull(),
|
|
346
|
+
name: text("name").notNull(),
|
|
347
|
+
calendarSource: text("calendar_source").notNull(),
|
|
348
|
+
// 'google', 'outlook', 'ical'
|
|
349
|
+
calendarId: text("calendar_id"),
|
|
350
|
+
triggerType: text("trigger_type").notNull(),
|
|
351
|
+
// 'event_start', 'event_end', 'daily_briefing'
|
|
352
|
+
offsetMinutes: integer("offset_minutes").default(0),
|
|
353
|
+
// Trigger X minutes before/after
|
|
354
|
+
action: jsonb("action").$type(),
|
|
355
|
+
enabled: boolean("enabled").default(true),
|
|
356
|
+
lastTriggered: timestamp("last_triggered"),
|
|
357
|
+
createdAt: timestamp("created_at").defaultNow().notNull()
|
|
358
|
+
},
|
|
359
|
+
(table) => [index("calendar_triggers_user_idx").on(table.userId)]
|
|
360
|
+
);
|
|
361
|
+
var subAgents = pgTable(
|
|
362
|
+
"sub_agents",
|
|
363
|
+
{
|
|
364
|
+
id: uuid("id").primaryKey().defaultRandom(),
|
|
365
|
+
parentConversationId: uuid("parent_conversation_id").references(
|
|
366
|
+
() => conversations.id
|
|
367
|
+
),
|
|
368
|
+
userId: uuid("user_id").references(() => users.id).notNull(),
|
|
369
|
+
type: text("type").notNull().$type(),
|
|
370
|
+
name: text("name").notNull(),
|
|
371
|
+
status: text("status").notNull().$type(),
|
|
372
|
+
objective: text("objective").notNull(),
|
|
373
|
+
context: jsonb("context"),
|
|
374
|
+
result: jsonb("result"),
|
|
375
|
+
tokenBudget: integer("token_budget").default(5e4),
|
|
376
|
+
tokensUsed: integer("tokens_used").default(0),
|
|
377
|
+
timeBudgetMs: integer("time_budget_ms").default(36e5),
|
|
378
|
+
// 1 hour default
|
|
379
|
+
startedAt: timestamp("started_at"),
|
|
380
|
+
completedAt: timestamp("completed_at"),
|
|
381
|
+
createdAt: timestamp("created_at").defaultNow().notNull()
|
|
382
|
+
},
|
|
383
|
+
(table) => [
|
|
384
|
+
index("sub_agents_user_idx").on(table.userId),
|
|
385
|
+
index("sub_agents_status_idx").on(table.status)
|
|
386
|
+
]
|
|
387
|
+
);
|
|
388
|
+
var agentMessages = pgTable(
|
|
389
|
+
"agent_messages",
|
|
390
|
+
{
|
|
391
|
+
id: uuid("id").primaryKey().defaultRandom(),
|
|
392
|
+
agentId: uuid("agent_id").references(() => subAgents.id).notNull(),
|
|
393
|
+
role: text("role").notNull().$type(),
|
|
394
|
+
content: text("content").notNull(),
|
|
395
|
+
metadata: jsonb("metadata"),
|
|
396
|
+
createdAt: timestamp("created_at").defaultNow().notNull()
|
|
397
|
+
},
|
|
398
|
+
(table) => [index("agent_messages_agent_idx").on(table.agentId)]
|
|
399
|
+
);
|
|
400
|
+
var agentProgress = pgTable(
|
|
401
|
+
"agent_progress",
|
|
402
|
+
{
|
|
403
|
+
id: uuid("id").primaryKey().defaultRandom(),
|
|
404
|
+
agentId: uuid("agent_id").references(() => subAgents.id).notNull(),
|
|
405
|
+
step: integer("step").notNull(),
|
|
406
|
+
description: text("description").notNull(),
|
|
407
|
+
status: text("status").notNull().$type(),
|
|
408
|
+
output: jsonb("output"),
|
|
409
|
+
createdAt: timestamp("created_at").defaultNow().notNull()
|
|
410
|
+
},
|
|
411
|
+
(table) => [index("agent_progress_agent_idx").on(table.agentId)]
|
|
412
|
+
);
|
|
413
|
+
var personas = pgTable(
|
|
414
|
+
"personas",
|
|
415
|
+
{
|
|
416
|
+
id: uuid("id").primaryKey().defaultRandom(),
|
|
417
|
+
userId: uuid("user_id").references(() => users.id),
|
|
418
|
+
// null = system persona
|
|
419
|
+
name: text("name").notNull(),
|
|
420
|
+
description: text("description"),
|
|
421
|
+
basePrompt: text("base_prompt").notNull(),
|
|
422
|
+
isDefault: boolean("is_default").default(false),
|
|
423
|
+
isSystem: boolean("is_system").default(false),
|
|
424
|
+
// Built-in personas
|
|
425
|
+
settings: jsonb("settings").$type(),
|
|
426
|
+
createdAt: timestamp("created_at").defaultNow().notNull()
|
|
427
|
+
},
|
|
428
|
+
(table) => [index("personas_user_idx").on(table.userId)]
|
|
429
|
+
);
|
|
430
|
+
var organizations = pgTable("organizations", {
|
|
431
|
+
id: uuid("id").primaryKey().defaultRandom(),
|
|
432
|
+
name: text("name").notNull(),
|
|
433
|
+
slug: text("slug").unique(),
|
|
434
|
+
settings: jsonb("settings"),
|
|
435
|
+
createdAt: timestamp("created_at").defaultNow().notNull(),
|
|
436
|
+
updatedAt: timestamp("updated_at").defaultNow()
|
|
437
|
+
});
|
|
438
|
+
var organizationMembers = pgTable(
|
|
439
|
+
"organization_members",
|
|
440
|
+
{
|
|
441
|
+
id: uuid("id").primaryKey().defaultRandom(),
|
|
442
|
+
organizationId: uuid("organization_id").references(() => organizations.id).notNull(),
|
|
443
|
+
userId: uuid("user_id").references(() => users.id).notNull(),
|
|
444
|
+
role: text("role").notNull().$type(),
|
|
445
|
+
joinedAt: timestamp("joined_at").defaultNow().notNull()
|
|
446
|
+
},
|
|
447
|
+
(table) => [
|
|
448
|
+
index("org_members_org_idx").on(table.organizationId),
|
|
449
|
+
index("org_members_user_idx").on(table.userId)
|
|
450
|
+
]
|
|
451
|
+
);
|
|
452
|
+
var sharedMemories = pgTable(
|
|
453
|
+
"shared_memories",
|
|
454
|
+
{
|
|
455
|
+
id: uuid("id").primaryKey().defaultRandom(),
|
|
456
|
+
organizationId: uuid("organization_id").references(() => organizations.id).notNull(),
|
|
457
|
+
memoryId: uuid("memory_id").references(() => memories.id).notNull(),
|
|
458
|
+
sharedBy: uuid("shared_by").references(() => users.id).notNull(),
|
|
459
|
+
sharedAt: timestamp("shared_at").defaultNow().notNull()
|
|
460
|
+
},
|
|
461
|
+
(table) => [index("shared_memories_org_idx").on(table.organizationId)]
|
|
462
|
+
);
|
|
463
|
+
var usageQuotas = pgTable(
|
|
464
|
+
"usage_quotas",
|
|
465
|
+
{
|
|
466
|
+
id: uuid("id").primaryKey().defaultRandom(),
|
|
467
|
+
userId: uuid("user_id").references(() => users.id),
|
|
468
|
+
organizationId: uuid("organization_id").references(() => organizations.id),
|
|
469
|
+
quotaType: text("quota_type").notNull(),
|
|
470
|
+
// 'tokens_daily', 'tokens_monthly', 'agents_concurrent'
|
|
471
|
+
limitValue: integer("limit_value").notNull(),
|
|
472
|
+
currentValue: integer("current_value").default(0),
|
|
473
|
+
resetAt: timestamp("reset_at"),
|
|
474
|
+
updatedAt: timestamp("updated_at").defaultNow()
|
|
475
|
+
},
|
|
476
|
+
(table) => [
|
|
477
|
+
index("usage_quotas_user_idx").on(table.userId),
|
|
478
|
+
index("usage_quotas_org_idx").on(table.organizationId)
|
|
479
|
+
]
|
|
480
|
+
);
|
|
481
|
+
var graphEntities = pgTable(
|
|
482
|
+
"graph_entities",
|
|
483
|
+
{
|
|
484
|
+
id: uuid("id").primaryKey().defaultRandom(),
|
|
485
|
+
userId: uuid("user_id").references(() => users.id),
|
|
486
|
+
type: text("type").notNull().$type(),
|
|
487
|
+
name: text("name").notNull(),
|
|
488
|
+
aliases: jsonb("aliases").$type().default([]),
|
|
489
|
+
description: text("description"),
|
|
490
|
+
attributes: jsonb("attributes").$type().default({}),
|
|
491
|
+
importance: integer("importance").default(50),
|
|
492
|
+
// 0-100
|
|
493
|
+
mentionCount: integer("mention_count").default(1),
|
|
494
|
+
embedding: vector("embedding", { dimensions: 1536 }),
|
|
495
|
+
createdAt: timestamp("created_at").defaultNow().notNull(),
|
|
496
|
+
updatedAt: timestamp("updated_at").defaultNow().notNull()
|
|
497
|
+
},
|
|
498
|
+
(table) => [
|
|
499
|
+
index("graph_entities_user_idx").on(table.userId),
|
|
500
|
+
index("graph_entities_type_idx").on(table.type),
|
|
501
|
+
index("graph_entities_name_idx").on(table.name)
|
|
502
|
+
]
|
|
503
|
+
);
|
|
504
|
+
var graphRelationships = pgTable(
|
|
505
|
+
"graph_relationships",
|
|
506
|
+
{
|
|
507
|
+
id: uuid("id").primaryKey().defaultRandom(),
|
|
508
|
+
sourceEntityId: uuid("source_entity_id").references(() => graphEntities.id, { onDelete: "cascade" }).notNull(),
|
|
509
|
+
targetEntityId: uuid("target_entity_id").references(() => graphEntities.id, { onDelete: "cascade" }).notNull(),
|
|
510
|
+
type: text("type").notNull().$type(),
|
|
511
|
+
strength: integer("strength").default(50),
|
|
512
|
+
// 0-100
|
|
513
|
+
bidirectional: boolean("bidirectional").default(false),
|
|
514
|
+
context: text("context"),
|
|
515
|
+
attributes: jsonb("attributes").$type().default({}),
|
|
516
|
+
createdAt: timestamp("created_at").defaultNow().notNull(),
|
|
517
|
+
updatedAt: timestamp("updated_at").defaultNow().notNull()
|
|
518
|
+
},
|
|
519
|
+
(table) => [
|
|
520
|
+
index("graph_rel_source_idx").on(table.sourceEntityId),
|
|
521
|
+
index("graph_rel_target_idx").on(table.targetEntityId),
|
|
522
|
+
index("graph_rel_type_idx").on(table.type)
|
|
523
|
+
]
|
|
524
|
+
);
|
|
525
|
+
var documents = pgTable(
|
|
526
|
+
"documents",
|
|
527
|
+
{
|
|
528
|
+
id: uuid("id").primaryKey().defaultRandom(),
|
|
529
|
+
name: text("name").notNull(),
|
|
530
|
+
filename: text("filename"),
|
|
531
|
+
mimeType: text("mime_type"),
|
|
532
|
+
fileSize: integer("file_size"),
|
|
533
|
+
source: text("source"),
|
|
534
|
+
// 'upload', 'url', 'api'
|
|
535
|
+
sourceUrl: text("source_url"),
|
|
536
|
+
metadata: jsonb("metadata"),
|
|
537
|
+
status: text("status").notNull().$type().default("pending"),
|
|
538
|
+
errorMessage: text("error_message"),
|
|
539
|
+
chunkCount: integer("chunk_count").default(0),
|
|
540
|
+
totalTokens: integer("total_tokens").default(0),
|
|
541
|
+
userId: uuid("user_id").references(() => users.id),
|
|
542
|
+
createdAt: timestamp("created_at").defaultNow().notNull(),
|
|
543
|
+
updatedAt: timestamp("updated_at").defaultNow().notNull(),
|
|
544
|
+
processedAt: timestamp("processed_at")
|
|
545
|
+
},
|
|
546
|
+
(table) => [
|
|
547
|
+
index("documents_user_idx").on(table.userId),
|
|
548
|
+
index("documents_status_idx").on(table.status)
|
|
549
|
+
]
|
|
550
|
+
);
|
|
551
|
+
var documentChunks = pgTable(
|
|
552
|
+
"document_chunks",
|
|
553
|
+
{
|
|
554
|
+
id: uuid("id").primaryKey().defaultRandom(),
|
|
555
|
+
documentId: uuid("document_id").references(() => documents.id, { onDelete: "cascade" }).notNull(),
|
|
556
|
+
chunkIndex: integer("chunk_index").notNull(),
|
|
557
|
+
content: text("content").notNull(),
|
|
558
|
+
embedding: vector("embedding", { dimensions: 1536 }),
|
|
559
|
+
tokenCount: integer("token_count"),
|
|
560
|
+
metadata: jsonb("metadata"),
|
|
561
|
+
createdAt: timestamp("created_at").defaultNow().notNull()
|
|
562
|
+
},
|
|
563
|
+
(table) => [
|
|
564
|
+
index("document_chunks_document_idx").on(table.documentId)
|
|
565
|
+
]
|
|
566
|
+
);
|
|
567
|
+
var twoFactorAuth = pgTable(
|
|
568
|
+
"two_factor_auth",
|
|
569
|
+
{
|
|
570
|
+
id: uuid("id").primaryKey().defaultRandom(),
|
|
571
|
+
userId: uuid("user_id").references(() => users.id, { onDelete: "cascade" }).notNull().unique(),
|
|
572
|
+
secretEncrypted: text("secret_encrypted").notNull(),
|
|
573
|
+
recoveryCodes: jsonb("recovery_codes").$type().notNull(),
|
|
574
|
+
enabledAt: timestamp("enabled_at").notNull(),
|
|
575
|
+
lastVerifiedAt: timestamp("last_verified_at"),
|
|
576
|
+
keyVersion: integer("key_version").default(1).notNull(),
|
|
577
|
+
metadata: jsonb("metadata"),
|
|
578
|
+
createdAt: timestamp("created_at").defaultNow().notNull(),
|
|
579
|
+
updatedAt: timestamp("updated_at").defaultNow().notNull()
|
|
580
|
+
},
|
|
581
|
+
(table) => [index("two_factor_auth_user_idx").on(table.userId)]
|
|
582
|
+
);
|
|
583
|
+
var securityIncidents = pgTable(
|
|
584
|
+
"security_incidents",
|
|
585
|
+
{
|
|
586
|
+
id: uuid("id").primaryKey().defaultRandom(),
|
|
587
|
+
incidentNumber: text("incident_number").notNull().unique(),
|
|
588
|
+
title: text("title").notNull(),
|
|
589
|
+
description: text("description").notNull(),
|
|
590
|
+
type: text("type").notNull().$type(),
|
|
591
|
+
severity: text("severity").notNull().$type(),
|
|
592
|
+
status: text("status").notNull().$type().default("open"),
|
|
593
|
+
userId: uuid("user_id").references(() => users.id),
|
|
594
|
+
assignedTo: uuid("assigned_to").references(() => users.id),
|
|
595
|
+
source: text("source").notNull(),
|
|
596
|
+
sourceData: jsonb("source_data"),
|
|
597
|
+
impactAssessment: text("impact_assessment"),
|
|
598
|
+
containmentActions: jsonb("containment_actions"),
|
|
599
|
+
resolutionNotes: text("resolution_notes"),
|
|
600
|
+
relatedIncidents: jsonb("related_incidents").$type(),
|
|
601
|
+
metadata: jsonb("metadata"),
|
|
602
|
+
createdAt: timestamp("created_at").defaultNow().notNull(),
|
|
603
|
+
updatedAt: timestamp("updated_at").defaultNow().notNull(),
|
|
604
|
+
investigatedAt: timestamp("investigated_at"),
|
|
605
|
+
containedAt: timestamp("contained_at"),
|
|
606
|
+
resolvedAt: timestamp("resolved_at"),
|
|
607
|
+
closedAt: timestamp("closed_at")
|
|
608
|
+
},
|
|
609
|
+
(table) => [
|
|
610
|
+
index("security_incidents_status_idx").on(table.status),
|
|
611
|
+
index("security_incidents_severity_idx").on(table.severity),
|
|
612
|
+
index("security_incidents_created_idx").on(table.createdAt)
|
|
613
|
+
]
|
|
614
|
+
);
|
|
615
|
+
var incidentTimeline = pgTable(
|
|
616
|
+
"incident_timeline",
|
|
617
|
+
{
|
|
618
|
+
id: uuid("id").primaryKey().defaultRandom(),
|
|
619
|
+
incidentId: uuid("incident_id").references(() => securityIncidents.id, { onDelete: "cascade" }).notNull(),
|
|
620
|
+
eventType: text("event_type").notNull().$type(),
|
|
621
|
+
description: text("description").notNull(),
|
|
622
|
+
performedBy: uuid("performed_by").references(() => users.id),
|
|
623
|
+
metadata: jsonb("metadata"),
|
|
624
|
+
createdAt: timestamp("created_at").defaultNow().notNull()
|
|
625
|
+
},
|
|
626
|
+
(table) => [index("incident_timeline_incident_idx").on(table.incidentId)]
|
|
627
|
+
);
|
|
628
|
+
|
|
629
|
+
// src/db/index.ts
|
|
630
|
+
import { drizzle } from "drizzle-orm/postgres-js";
|
|
631
|
+
import postgres from "postgres";
|
|
632
|
+
var _client = null;
|
|
633
|
+
var _db = null;
|
|
634
|
+
function getDb() {
|
|
635
|
+
if (!_db) {
|
|
636
|
+
_client = postgres(env.DATABASE_URL);
|
|
637
|
+
_db = drizzle(_client, { schema: schema_exports });
|
|
638
|
+
}
|
|
639
|
+
return _db;
|
|
640
|
+
}
|
|
641
|
+
var db = new Proxy(
|
|
642
|
+
{},
|
|
643
|
+
{
|
|
644
|
+
get(_target, prop) {
|
|
645
|
+
const instance = getDb();
|
|
646
|
+
const value = instance[prop];
|
|
647
|
+
if (typeof value === "function") {
|
|
648
|
+
return value.bind(instance);
|
|
649
|
+
}
|
|
650
|
+
return value;
|
|
651
|
+
}
|
|
652
|
+
}
|
|
653
|
+
);
|
|
654
|
+
|
|
655
|
+
export {
|
|
656
|
+
conversations,
|
|
657
|
+
messages,
|
|
658
|
+
memories,
|
|
659
|
+
toolLogs,
|
|
660
|
+
sessions,
|
|
661
|
+
auditLogs,
|
|
662
|
+
apiKeys,
|
|
663
|
+
metrics,
|
|
664
|
+
errorLogs,
|
|
665
|
+
usagePatterns,
|
|
666
|
+
achievements,
|
|
667
|
+
userAchievements,
|
|
668
|
+
evolutionModes,
|
|
669
|
+
archivedMemories,
|
|
670
|
+
calendarTriggers,
|
|
671
|
+
subAgents,
|
|
672
|
+
agentMessages,
|
|
673
|
+
agentProgress,
|
|
674
|
+
personas,
|
|
675
|
+
graphEntities,
|
|
676
|
+
graphRelationships,
|
|
677
|
+
securityIncidents,
|
|
678
|
+
incidentTimeline,
|
|
679
|
+
db
|
|
680
|
+
};
|
|
681
|
+
//# sourceMappingURL=chunk-XKYRH4FM.js.map
|