@m6d/cortex-server 1.7.0 → 2.0.0
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 +8 -3
- package/contracts/README.md +23 -0
- package/contracts/graph/embed.ts +50 -0
- package/{src → contracts}/graph/helpers.ts +4 -10
- package/{src → contracts}/graph/neo4j.ts +14 -27
- package/contracts/graph/schema.ts +65 -0
- package/{src → contracts}/graph/types.ts +2 -29
- package/contracts/graph.ts +36 -0
- package/contracts/runtime.ts +208 -0
- package/contracts/wire.ts +143 -0
- package/dist/contracts/graph/embed.d.ts +22 -0
- package/dist/{src → contracts}/graph/helpers.d.ts +14 -12
- package/dist/{src → contracts}/graph/neo4j.d.ts +5 -5
- package/dist/contracts/graph/schema.d.ts +62 -0
- package/dist/{src → contracts}/graph/types.d.ts +1 -1
- package/dist/contracts/graph.d.ts +14 -0
- package/dist/contracts/runtime.d.ts +278 -0
- package/dist/contracts/wire.d.ts +120 -0
- package/dist/index.d.ts +1 -1
- package/dist/src/lib/adapters/database/index.d.ts +61 -0
- package/dist/src/lib/adapters/database/message-content.d.ts +30 -0
- package/dist/src/lib/adapters/database/mssql/attachments.d.ts +100 -0
- package/dist/src/lib/adapters/database/mssql/client.d.ts +8 -0
- package/dist/src/lib/adapters/database/mssql/index.d.ts +194 -0
- package/dist/src/lib/adapters/database/mssql/llm-requests.d.ts +17 -0
- package/dist/src/lib/adapters/database/mssql/messages.d.ts +37 -0
- package/dist/src/lib/adapters/database/mssql/threads.d.ts +50 -0
- package/dist/src/lib/adapters/database/postgres/attachments.d.ts +113 -0
- package/dist/src/lib/adapters/database/postgres/client.d.ts +8 -0
- package/dist/src/lib/adapters/database/postgres/index.d.ts +207 -0
- package/dist/src/lib/adapters/database/postgres/llm-requests.d.ts +17 -0
- package/dist/src/lib/adapters/database/postgres/messages.d.ts +37 -0
- package/dist/src/lib/adapters/database/postgres/threads.d.ts +50 -0
- package/{src/adapters/storage.ts → dist/src/lib/adapters/storage/index.d.ts} +1 -1
- package/dist/src/{adapters → lib/adapters/storage}/minio.d.ts +1 -1
- package/dist/src/lib/ai/active-runs.d.ts +63 -0
- package/dist/src/lib/ai/attachments.d.ts +30 -0
- package/dist/src/lib/ai/backend-url.d.ts +16 -0
- package/dist/src/lib/ai/cc-runtime.d.ts +61 -0
- package/dist/src/lib/ai/commit-gate.d.ts +21 -0
- package/dist/src/{ai → lib/ai}/context/builder.d.ts +6 -7
- package/dist/src/lib/ai/context/compression-middleware.d.ts +15 -0
- package/dist/src/lib/ai/context/compressor.d.ts +7 -0
- package/dist/src/lib/ai/context/intra-turn-compressor.d.ts +24 -0
- package/dist/src/lib/ai/context/optimize-thread-context.d.ts +9 -0
- package/dist/src/lib/ai/context/summarizer.d.ts +5 -0
- package/dist/src/{ai → lib/ai}/context/token-estimator.d.ts +5 -8
- package/dist/src/{ai → lib/ai}/context/types.d.ts +2 -0
- package/dist/src/{ai → lib/ai}/fetch.d.ts +1 -1
- package/dist/src/lib/ai/finish-turn.d.ts +23 -0
- package/dist/src/lib/ai/helpers.d.ts +38 -0
- package/dist/src/lib/ai/index.d.ts +7 -0
- package/dist/src/lib/ai/inspector.d.ts +41 -0
- package/dist/src/lib/ai/interceptors/request-interceptor.d.ts +13 -0
- package/dist/src/{ai → lib/ai}/prompt.d.ts +5 -4
- package/dist/src/lib/ai/redis-runs.d.ts +41 -0
- package/dist/src/lib/ai/redis-stream-log.d.ts +39 -0
- package/dist/src/lib/ai/tools/execute-code.tool.d.ts +18 -0
- package/dist/src/lib/ai/tools/query-graph.tool.d.ts +13 -0
- package/dist/src/lib/ai/tools/read-attachment.tool.d.ts +21 -0
- package/dist/src/lib/ai/tools/search-common.d.ts +17 -0
- package/dist/src/lib/ai/tools/search-knowledge.tool.d.ts +15 -0
- package/dist/src/lib/ai/tools/search-services.tool.d.ts +12 -0
- package/dist/src/lib/ai/tools/search-tools.tool.d.ts +12 -0
- package/dist/src/lib/ai/turn-tools.d.ts +39 -0
- package/dist/src/lib/ai/vision/rasterize-pdf.d.ts +26 -0
- package/dist/src/lib/ai/vision/rasterize-pdf.worker.d.ts +1 -0
- package/dist/src/lib/ai/vision/vision-reader.d.ts +45 -0
- package/dist/src/lib/cc/client.d.ts +183 -0
- package/dist/src/lib/cc/config-cache.d.ts +20 -0
- package/dist/src/lib/cc/format.d.ts +23 -0
- package/dist/src/lib/cc/registry.d.ts +34 -0
- package/dist/src/lib/cc/types.d.ts +27 -0
- package/dist/src/lib/config.d.ts +170 -0
- package/dist/src/lib/db/drizzle.config.mssql.d.ts +2 -0
- package/dist/src/lib/db/drizzle.config.pg.d.ts +2 -0
- package/dist/src/lib/db/migrate.d.ts +7 -0
- package/dist/src/{db/schema.d.ts → lib/db/schema.mssql.d.ts} +236 -24
- package/dist/src/lib/db/schema.pg.d.ts +546 -0
- package/dist/src/{factory.d.ts → lib/factory.d.ts} +2 -12
- package/dist/src/lib/graph/index.d.ts +10 -0
- package/dist/src/{graph → lib/graph}/resolver.d.ts +2 -3
- package/dist/src/{index.d.ts → lib/index.d.ts} +3 -4
- package/dist/src/lib/redis.d.ts +19 -0
- package/dist/src/{routes → lib/routes}/chat.d.ts +1 -1
- package/dist/src/{routes → lib/routes}/files.d.ts +1 -1
- package/dist/src/lib/routes/owned-thread.d.ts +17 -0
- package/dist/src/{routes → lib/routes}/threads.d.ts +1 -1
- package/dist/src/{routes → lib/routes}/ws.d.ts +1 -1
- package/dist/src/lib/types.d.ts +58 -0
- package/dist/src/{ws → lib/ws}/connections.d.ts +2 -1
- package/index.ts +1 -1
- package/package.json +35 -15
- package/src/lib/adapters/database/index.ts +78 -0
- package/src/lib/adapters/database/message-content.ts +39 -0
- package/src/lib/adapters/database/mssql/attachments.ts +90 -0
- package/src/lib/adapters/database/mssql/client.ts +11 -0
- package/src/lib/adapters/database/mssql/index.ts +23 -0
- package/src/lib/adapters/database/mssql/llm-requests.ts +43 -0
- package/src/lib/adapters/database/mssql/messages.ts +92 -0
- package/src/lib/adapters/database/mssql/threads.ts +83 -0
- package/src/lib/adapters/database/postgres/attachments.ts +88 -0
- package/src/lib/adapters/database/postgres/client.ts +11 -0
- package/src/lib/adapters/database/postgres/index.ts +23 -0
- package/src/lib/adapters/database/postgres/llm-requests.ts +45 -0
- package/src/lib/adapters/database/postgres/messages.ts +92 -0
- package/src/lib/adapters/database/postgres/threads.ts +84 -0
- package/{dist/src/adapters/storage.d.ts → src/lib/adapters/storage/index.ts} +1 -1
- package/src/{adapters → lib/adapters/storage}/minio.ts +7 -6
- package/src/lib/ai/active-runs.ts +157 -0
- package/src/lib/ai/attachments.ts +144 -0
- package/src/lib/ai/backend-url.ts +27 -0
- package/src/lib/ai/cc-runtime.ts +63 -0
- package/src/lib/ai/commit-gate.ts +116 -0
- package/src/{ai → lib/ai}/context/builder.ts +12 -14
- package/src/lib/ai/context/compression-middleware.ts +44 -0
- package/src/lib/ai/context/compressor.ts +267 -0
- package/src/lib/ai/context/intra-turn-compressor.ts +181 -0
- package/src/lib/ai/context/optimize-thread-context.ts +50 -0
- package/src/lib/ai/context/summarizer.ts +48 -0
- package/src/lib/ai/context/token-estimator.ts +65 -0
- package/src/{ai → lib/ai}/context/types.ts +4 -1
- package/src/{ai → lib/ai}/fetch.ts +10 -5
- package/src/lib/ai/finish-turn.ts +75 -0
- package/src/lib/ai/helpers.ts +100 -0
- package/src/lib/ai/index.ts +408 -0
- package/src/lib/ai/inspector.ts +112 -0
- package/src/lib/ai/interceptors/request-interceptor.ts +89 -0
- package/src/lib/ai/prompt.ts +355 -0
- package/src/lib/ai/redis-runs.ts +167 -0
- package/src/lib/ai/redis-stream-log.ts +219 -0
- package/src/lib/ai/tools/execute-code.tool.ts +267 -0
- package/src/{ai → lib/ai}/tools/query-graph.tool.ts +7 -8
- package/src/lib/ai/tools/read-attachment.tool.ts +59 -0
- package/src/lib/ai/tools/search-common.ts +15 -0
- package/src/lib/ai/tools/search-knowledge.tool.ts +33 -0
- package/src/lib/ai/tools/search-services.tool.ts +31 -0
- package/src/lib/ai/tools/search-tools.tool.ts +29 -0
- package/src/lib/ai/turn-tools.ts +154 -0
- package/src/lib/ai/vision/rasterize-pdf.ts +69 -0
- package/src/lib/ai/vision/rasterize-pdf.worker.ts +81 -0
- package/src/lib/ai/vision/vision-reader.ts +130 -0
- package/src/{auth → lib/auth}/middleware.ts +12 -3
- package/src/lib/cc/client.ts +273 -0
- package/src/lib/cc/config-cache.ts +32 -0
- package/src/lib/cc/format.ts +96 -0
- package/src/lib/cc/registry.ts +62 -0
- package/src/lib/cc/types.ts +44 -0
- package/src/lib/config.ts +212 -0
- package/src/lib/db/drizzle.config.mssql.ts +9 -0
- package/src/lib/db/drizzle.config.pg.ts +9 -0
- package/src/lib/db/migrate.ts +56 -0
- package/src/{db/migrations/20260309012148_cloudy_maria_hill → lib/db/migrations/mssql/20260326231647_nice_speedball}/migration.sql +12 -0
- package/src/{db/migrations/20260309012148_cloudy_maria_hill → lib/db/migrations/mssql/20260326231647_nice_speedball}/snapshot.json +106 -1
- package/src/lib/db/migrations/mssql/20260729092726_talented_wilson_fisk/migration.sql +20 -0
- package/src/lib/db/migrations/mssql/20260729092726_talented_wilson_fisk/snapshot.json +497 -0
- package/src/lib/db/migrations/mssql/20260801003652_perpetual_blue_shield/migration.sql +1 -0
- package/src/lib/db/migrations/mssql/20260801003652_perpetual_blue_shield/snapshot.json +516 -0
- package/src/lib/db/migrations/mssql/20260812174642_user_id_text/migration.sql +2 -0
- package/src/lib/db/migrations/mssql/20260812174642_user_id_text/snapshot.json +516 -0
- package/src/lib/db/migrations/pg/20260801084117_thick_ben_grimm/migration.sql +53 -0
- package/src/lib/db/migrations/pg/20260801084117_thick_ben_grimm/snapshot.json +584 -0
- package/src/lib/db/migrations/pg/20260812174622_user_id_text/migration.sql +2 -0
- package/src/lib/db/migrations/pg/20260812174622_user_id_text/snapshot.json +584 -0
- package/src/lib/db/schema.mssql.ts +94 -0
- package/src/lib/db/schema.pg.ts +95 -0
- package/src/lib/factory.ts +127 -0
- package/src/lib/graph/index.ts +19 -0
- package/src/lib/graph/resolver.ts +387 -0
- package/src/{index.ts → lib/index.ts} +13 -5
- package/src/lib/redis.ts +44 -0
- package/src/lib/routes/chat.ts +115 -0
- package/src/lib/routes/files.ts +129 -0
- package/src/lib/routes/owned-thread.ts +17 -0
- package/src/{routes → lib/routes}/threads.ts +22 -31
- package/src/{routes → lib/routes}/ws.ts +9 -3
- package/src/lib/types.ts +76 -0
- package/src/{ws → lib/ws}/connections.ts +9 -1
- package/tsconfig.json +48 -0
- package/dist/src/adapters/database.d.ts +0 -30
- package/dist/src/adapters/mssql.d.ts +0 -3
- package/dist/src/ai/active-streams.d.ts +0 -14
- package/dist/src/ai/context/compressor.d.ts +0 -7
- package/dist/src/ai/context/index.d.ts +0 -15
- package/dist/src/ai/context/summarizer.d.ts +0 -5
- package/dist/src/ai/helpers.d.ts +0 -5
- package/dist/src/ai/index.d.ts +0 -4
- package/dist/src/ai/interceptors/request-interceptor.d.ts +0 -12
- package/dist/src/ai/tools/call-endpoint.tool.d.ts +0 -7
- package/dist/src/ai/tools/capture-files.tool.d.ts +0 -6
- package/dist/src/ai/tools/execute-code.tool.d.ts +0 -4
- package/dist/src/ai/tools/query-graph.tool.d.ts +0 -5
- package/dist/src/cli/extract-endpoints.d.ts +0 -6
- package/dist/src/config.d.ts +0 -165
- package/dist/src/db/migrate.d.ts +0 -1
- package/dist/src/graph/expand-domains.d.ts +0 -2
- package/dist/src/graph/generate-cypher.d.ts +0 -22
- package/dist/src/graph/index.d.ts +0 -11
- package/dist/src/graph/seed.d.ts +0 -19
- package/dist/src/graph/validate.d.ts +0 -2
- package/dist/src/routes/index.d.ts +0 -4
- package/dist/src/types.d.ts +0 -74
- package/dist/src/ws/events.d.ts +0 -39
- package/dist/src/ws/index.d.ts +0 -3
- package/dist/src/ws/notify.d.ts +0 -2
- package/src/adapters/database.ts +0 -29
- package/src/adapters/mssql.ts +0 -195
- package/src/ai/active-streams.ts +0 -123
- package/src/ai/context/compressor.ts +0 -47
- package/src/ai/context/index.ts +0 -75
- package/src/ai/context/summarizer.ts +0 -50
- package/src/ai/context/token-estimator.ts +0 -60
- package/src/ai/helpers.ts +0 -32
- package/src/ai/index.ts +0 -277
- package/src/ai/interceptors/request-interceptor.ts +0 -61
- package/src/ai/prompt.ts +0 -126
- package/src/ai/tools/call-endpoint.tool.ts +0 -89
- package/src/ai/tools/capture-files.tool.ts +0 -20
- package/src/ai/tools/execute-code.tool.ts +0 -153
- package/src/cli/extract-endpoints.ts +0 -550
- package/src/config.ts +0 -182
- package/src/db/migrate.ts +0 -21
- package/src/db/migrations/20260315000000_add_context_meta/migration.sql +0 -1
- package/src/db/schema.ts +0 -70
- package/src/factory.ts +0 -171
- package/src/graph/expand-domains.ts +0 -276
- package/src/graph/generate-cypher.ts +0 -192
- package/src/graph/index.ts +0 -47
- package/src/graph/resolver.ts +0 -357
- package/src/graph/seed.ts +0 -162
- package/src/graph/validate.ts +0 -78
- package/src/routes/chat.ts +0 -86
- package/src/routes/files.ts +0 -100
- package/src/routes/index.ts +0 -4
- package/src/types.ts +0 -74
- package/src/ws/events.ts +0 -39
- package/src/ws/index.ts +0 -11
- package/src/ws/notify.ts +0 -9
- /package/dist/src/{auth → lib/auth}/middleware.d.ts +0 -0
|
@@ -0,0 +1,516 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": "2",
|
|
3
|
+
"dialect": "mssql",
|
|
4
|
+
"id": "d4d870f7-f371-4bdc-a5b3-cb66902a9a10",
|
|
5
|
+
"prevIds": ["a0e8755a-30c5-4eb5-b98d-e8cad22bf3d4", "e44fb90a-d439-4851-9828-1bd6347ae146"],
|
|
6
|
+
"ddl": [
|
|
7
|
+
{
|
|
8
|
+
"name": "ai",
|
|
9
|
+
"entityType": "schemas"
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
"name": "attachments",
|
|
13
|
+
"entityType": "tables",
|
|
14
|
+
"schema": "ai"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"name": "llm_requests",
|
|
18
|
+
"entityType": "tables",
|
|
19
|
+
"schema": "ai"
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
"name": "messages",
|
|
23
|
+
"entityType": "tables",
|
|
24
|
+
"schema": "ai"
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"name": "threads",
|
|
28
|
+
"entityType": "tables",
|
|
29
|
+
"schema": "ai"
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
"type": "UNIQUEIDENTIFIER",
|
|
33
|
+
"notNull": true,
|
|
34
|
+
"generated": null,
|
|
35
|
+
"identity": null,
|
|
36
|
+
"name": "id",
|
|
37
|
+
"schema": "ai",
|
|
38
|
+
"entityType": "columns",
|
|
39
|
+
"table": "attachments"
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
"type": "UNIQUEIDENTIFIER",
|
|
43
|
+
"notNull": true,
|
|
44
|
+
"generated": null,
|
|
45
|
+
"identity": null,
|
|
46
|
+
"name": "thread_id",
|
|
47
|
+
"schema": "ai",
|
|
48
|
+
"entityType": "columns",
|
|
49
|
+
"table": "attachments"
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
"type": "nvarchar(255)",
|
|
53
|
+
"notNull": true,
|
|
54
|
+
"generated": null,
|
|
55
|
+
"identity": null,
|
|
56
|
+
"name": "user_id",
|
|
57
|
+
"schema": "ai",
|
|
58
|
+
"entityType": "columns",
|
|
59
|
+
"table": "attachments"
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
"type": "nvarchar(128)",
|
|
63
|
+
"notNull": false,
|
|
64
|
+
"generated": null,
|
|
65
|
+
"identity": null,
|
|
66
|
+
"name": "message_id",
|
|
67
|
+
"schema": "ai",
|
|
68
|
+
"entityType": "columns",
|
|
69
|
+
"table": "attachments"
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
"type": "nvarchar(2048)",
|
|
73
|
+
"notNull": true,
|
|
74
|
+
"generated": null,
|
|
75
|
+
"identity": null,
|
|
76
|
+
"name": "filename",
|
|
77
|
+
"schema": "ai",
|
|
78
|
+
"entityType": "columns",
|
|
79
|
+
"table": "attachments"
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
"type": "nvarchar(256)",
|
|
83
|
+
"notNull": true,
|
|
84
|
+
"generated": null,
|
|
85
|
+
"identity": null,
|
|
86
|
+
"name": "content_type",
|
|
87
|
+
"schema": "ai",
|
|
88
|
+
"entityType": "columns",
|
|
89
|
+
"table": "attachments"
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
"type": "int",
|
|
93
|
+
"notNull": true,
|
|
94
|
+
"generated": null,
|
|
95
|
+
"identity": null,
|
|
96
|
+
"name": "size_bytes",
|
|
97
|
+
"schema": "ai",
|
|
98
|
+
"entityType": "columns",
|
|
99
|
+
"table": "attachments"
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
"type": "nvarchar(512)",
|
|
103
|
+
"notNull": true,
|
|
104
|
+
"generated": null,
|
|
105
|
+
"identity": null,
|
|
106
|
+
"name": "storage_key",
|
|
107
|
+
"schema": "ai",
|
|
108
|
+
"entityType": "columns",
|
|
109
|
+
"table": "attachments"
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
"type": "nvarchar(16)",
|
|
113
|
+
"notNull": true,
|
|
114
|
+
"generated": null,
|
|
115
|
+
"identity": null,
|
|
116
|
+
"name": "status",
|
|
117
|
+
"schema": "ai",
|
|
118
|
+
"entityType": "columns",
|
|
119
|
+
"table": "attachments"
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
"type": "nvarchar(max)",
|
|
123
|
+
"notNull": false,
|
|
124
|
+
"generated": null,
|
|
125
|
+
"identity": null,
|
|
126
|
+
"name": "description",
|
|
127
|
+
"schema": "ai",
|
|
128
|
+
"entityType": "columns",
|
|
129
|
+
"table": "attachments"
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
"type": "datetime2",
|
|
133
|
+
"notNull": true,
|
|
134
|
+
"generated": null,
|
|
135
|
+
"identity": null,
|
|
136
|
+
"name": "created_at",
|
|
137
|
+
"schema": "ai",
|
|
138
|
+
"entityType": "columns",
|
|
139
|
+
"table": "attachments"
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
"type": "datetime2",
|
|
143
|
+
"notNull": true,
|
|
144
|
+
"generated": null,
|
|
145
|
+
"identity": null,
|
|
146
|
+
"name": "updated_at",
|
|
147
|
+
"schema": "ai",
|
|
148
|
+
"entityType": "columns",
|
|
149
|
+
"table": "attachments"
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
"type": "UNIQUEIDENTIFIER",
|
|
153
|
+
"notNull": true,
|
|
154
|
+
"generated": null,
|
|
155
|
+
"identity": null,
|
|
156
|
+
"name": "id",
|
|
157
|
+
"schema": "ai",
|
|
158
|
+
"entityType": "columns",
|
|
159
|
+
"table": "llm_requests"
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
"type": "nvarchar(128)",
|
|
163
|
+
"notNull": true,
|
|
164
|
+
"generated": null,
|
|
165
|
+
"identity": null,
|
|
166
|
+
"name": "message_id",
|
|
167
|
+
"schema": "ai",
|
|
168
|
+
"entityType": "columns",
|
|
169
|
+
"table": "llm_requests"
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
"type": "int",
|
|
173
|
+
"notNull": true,
|
|
174
|
+
"generated": null,
|
|
175
|
+
"identity": null,
|
|
176
|
+
"name": "step_number",
|
|
177
|
+
"schema": "ai",
|
|
178
|
+
"entityType": "columns",
|
|
179
|
+
"table": "llm_requests"
|
|
180
|
+
},
|
|
181
|
+
{
|
|
182
|
+
"type": "nvarchar(max)",
|
|
183
|
+
"notNull": true,
|
|
184
|
+
"generated": null,
|
|
185
|
+
"identity": null,
|
|
186
|
+
"name": "prompt",
|
|
187
|
+
"schema": "ai",
|
|
188
|
+
"entityType": "columns",
|
|
189
|
+
"table": "llm_requests"
|
|
190
|
+
},
|
|
191
|
+
{
|
|
192
|
+
"type": "nvarchar(max)",
|
|
193
|
+
"notNull": false,
|
|
194
|
+
"generated": null,
|
|
195
|
+
"identity": null,
|
|
196
|
+
"name": "output",
|
|
197
|
+
"schema": "ai",
|
|
198
|
+
"entityType": "columns",
|
|
199
|
+
"table": "llm_requests"
|
|
200
|
+
},
|
|
201
|
+
{
|
|
202
|
+
"type": "nvarchar(max)",
|
|
203
|
+
"notNull": false,
|
|
204
|
+
"generated": null,
|
|
205
|
+
"identity": null,
|
|
206
|
+
"name": "token_usage",
|
|
207
|
+
"schema": "ai",
|
|
208
|
+
"entityType": "columns",
|
|
209
|
+
"table": "llm_requests"
|
|
210
|
+
},
|
|
211
|
+
{
|
|
212
|
+
"type": "nvarchar(128)",
|
|
213
|
+
"notNull": true,
|
|
214
|
+
"generated": null,
|
|
215
|
+
"identity": null,
|
|
216
|
+
"name": "id",
|
|
217
|
+
"schema": "ai",
|
|
218
|
+
"entityType": "columns",
|
|
219
|
+
"table": "messages"
|
|
220
|
+
},
|
|
221
|
+
{
|
|
222
|
+
"type": "UNIQUEIDENTIFIER",
|
|
223
|
+
"notNull": true,
|
|
224
|
+
"generated": null,
|
|
225
|
+
"identity": null,
|
|
226
|
+
"name": "thread_id",
|
|
227
|
+
"schema": "ai",
|
|
228
|
+
"entityType": "columns",
|
|
229
|
+
"table": "messages"
|
|
230
|
+
},
|
|
231
|
+
{
|
|
232
|
+
"type": "nvarchar(max)",
|
|
233
|
+
"notNull": false,
|
|
234
|
+
"generated": null,
|
|
235
|
+
"identity": null,
|
|
236
|
+
"name": "text",
|
|
237
|
+
"schema": "ai",
|
|
238
|
+
"entityType": "columns",
|
|
239
|
+
"table": "messages"
|
|
240
|
+
},
|
|
241
|
+
{
|
|
242
|
+
"type": "nvarchar(max)",
|
|
243
|
+
"notNull": true,
|
|
244
|
+
"generated": null,
|
|
245
|
+
"identity": null,
|
|
246
|
+
"name": "content",
|
|
247
|
+
"schema": "ai",
|
|
248
|
+
"entityType": "columns",
|
|
249
|
+
"table": "messages"
|
|
250
|
+
},
|
|
251
|
+
{
|
|
252
|
+
"type": "int",
|
|
253
|
+
"notNull": true,
|
|
254
|
+
"generated": null,
|
|
255
|
+
"identity": null,
|
|
256
|
+
"name": "ordinal",
|
|
257
|
+
"schema": "ai",
|
|
258
|
+
"entityType": "columns",
|
|
259
|
+
"table": "messages"
|
|
260
|
+
},
|
|
261
|
+
{
|
|
262
|
+
"type": "nvarchar(16)",
|
|
263
|
+
"notNull": true,
|
|
264
|
+
"generated": null,
|
|
265
|
+
"identity": null,
|
|
266
|
+
"name": "role",
|
|
267
|
+
"schema": "ai",
|
|
268
|
+
"entityType": "columns",
|
|
269
|
+
"table": "messages"
|
|
270
|
+
},
|
|
271
|
+
{
|
|
272
|
+
"type": "datetime2",
|
|
273
|
+
"notNull": true,
|
|
274
|
+
"generated": null,
|
|
275
|
+
"identity": null,
|
|
276
|
+
"name": "created_at",
|
|
277
|
+
"schema": "ai",
|
|
278
|
+
"entityType": "columns",
|
|
279
|
+
"table": "messages"
|
|
280
|
+
},
|
|
281
|
+
{
|
|
282
|
+
"type": "datetime2",
|
|
283
|
+
"notNull": true,
|
|
284
|
+
"generated": null,
|
|
285
|
+
"identity": null,
|
|
286
|
+
"name": "updated_at",
|
|
287
|
+
"schema": "ai",
|
|
288
|
+
"entityType": "columns",
|
|
289
|
+
"table": "messages"
|
|
290
|
+
},
|
|
291
|
+
{
|
|
292
|
+
"type": "UNIQUEIDENTIFIER",
|
|
293
|
+
"notNull": true,
|
|
294
|
+
"generated": null,
|
|
295
|
+
"identity": null,
|
|
296
|
+
"name": "id",
|
|
297
|
+
"schema": "ai",
|
|
298
|
+
"entityType": "columns",
|
|
299
|
+
"table": "threads"
|
|
300
|
+
},
|
|
301
|
+
{
|
|
302
|
+
"type": "nvarchar(255)",
|
|
303
|
+
"notNull": true,
|
|
304
|
+
"generated": null,
|
|
305
|
+
"identity": null,
|
|
306
|
+
"name": "user_id",
|
|
307
|
+
"schema": "ai",
|
|
308
|
+
"entityType": "columns",
|
|
309
|
+
"table": "threads"
|
|
310
|
+
},
|
|
311
|
+
{
|
|
312
|
+
"type": "nvarchar(128)",
|
|
313
|
+
"notNull": true,
|
|
314
|
+
"generated": null,
|
|
315
|
+
"identity": null,
|
|
316
|
+
"name": "agent_id",
|
|
317
|
+
"schema": "ai",
|
|
318
|
+
"entityType": "columns",
|
|
319
|
+
"table": "threads"
|
|
320
|
+
},
|
|
321
|
+
{
|
|
322
|
+
"type": "nvarchar(256)",
|
|
323
|
+
"notNull": false,
|
|
324
|
+
"generated": null,
|
|
325
|
+
"identity": null,
|
|
326
|
+
"name": "title",
|
|
327
|
+
"schema": "ai",
|
|
328
|
+
"entityType": "columns",
|
|
329
|
+
"table": "threads"
|
|
330
|
+
},
|
|
331
|
+
{
|
|
332
|
+
"type": "nvarchar(max)",
|
|
333
|
+
"notNull": false,
|
|
334
|
+
"generated": null,
|
|
335
|
+
"identity": null,
|
|
336
|
+
"name": "session",
|
|
337
|
+
"schema": "ai",
|
|
338
|
+
"entityType": "columns",
|
|
339
|
+
"table": "threads"
|
|
340
|
+
},
|
|
341
|
+
{
|
|
342
|
+
"type": "nvarchar(max)",
|
|
343
|
+
"notNull": false,
|
|
344
|
+
"generated": null,
|
|
345
|
+
"identity": null,
|
|
346
|
+
"name": "context_meta",
|
|
347
|
+
"schema": "ai",
|
|
348
|
+
"entityType": "columns",
|
|
349
|
+
"table": "threads"
|
|
350
|
+
},
|
|
351
|
+
{
|
|
352
|
+
"type": "datetime2",
|
|
353
|
+
"notNull": true,
|
|
354
|
+
"generated": null,
|
|
355
|
+
"identity": null,
|
|
356
|
+
"name": "created_at",
|
|
357
|
+
"schema": "ai",
|
|
358
|
+
"entityType": "columns",
|
|
359
|
+
"table": "threads"
|
|
360
|
+
},
|
|
361
|
+
{
|
|
362
|
+
"type": "datetime2",
|
|
363
|
+
"notNull": true,
|
|
364
|
+
"generated": null,
|
|
365
|
+
"identity": null,
|
|
366
|
+
"name": "updated_at",
|
|
367
|
+
"schema": "ai",
|
|
368
|
+
"entityType": "columns",
|
|
369
|
+
"table": "threads"
|
|
370
|
+
},
|
|
371
|
+
{
|
|
372
|
+
"columns": [
|
|
373
|
+
{
|
|
374
|
+
"value": "thread_id",
|
|
375
|
+
"isExpression": false
|
|
376
|
+
}
|
|
377
|
+
],
|
|
378
|
+
"isUnique": false,
|
|
379
|
+
"where": null,
|
|
380
|
+
"name": "attachments_thread_id_index",
|
|
381
|
+
"entityType": "indexes",
|
|
382
|
+
"table": "attachments",
|
|
383
|
+
"schema": "ai"
|
|
384
|
+
},
|
|
385
|
+
{
|
|
386
|
+
"columns": ["thread_id"],
|
|
387
|
+
"nameExplicit": false,
|
|
388
|
+
"schemaTo": "ai",
|
|
389
|
+
"tableTo": "threads",
|
|
390
|
+
"columnsTo": ["id"],
|
|
391
|
+
"onUpdate": "NO ACTION",
|
|
392
|
+
"onDelete": "CASCADE",
|
|
393
|
+
"name": "attachments_thread_id_threads_id_fk",
|
|
394
|
+
"entityType": "fks",
|
|
395
|
+
"table": "attachments",
|
|
396
|
+
"schema": "ai"
|
|
397
|
+
},
|
|
398
|
+
{
|
|
399
|
+
"columns": ["message_id"],
|
|
400
|
+
"nameExplicit": false,
|
|
401
|
+
"schemaTo": "ai",
|
|
402
|
+
"tableTo": "messages",
|
|
403
|
+
"columnsTo": ["id"],
|
|
404
|
+
"onUpdate": "NO ACTION",
|
|
405
|
+
"onDelete": "NO ACTION",
|
|
406
|
+
"name": "attachments_message_id_messages_id_fk",
|
|
407
|
+
"entityType": "fks",
|
|
408
|
+
"table": "attachments",
|
|
409
|
+
"schema": "ai"
|
|
410
|
+
},
|
|
411
|
+
{
|
|
412
|
+
"columns": ["message_id"],
|
|
413
|
+
"nameExplicit": false,
|
|
414
|
+
"schemaTo": "ai",
|
|
415
|
+
"tableTo": "messages",
|
|
416
|
+
"columnsTo": ["id"],
|
|
417
|
+
"onUpdate": "NO ACTION",
|
|
418
|
+
"onDelete": "CASCADE",
|
|
419
|
+
"name": "llm_requests_message_id_messages_id_fk",
|
|
420
|
+
"entityType": "fks",
|
|
421
|
+
"table": "llm_requests",
|
|
422
|
+
"schema": "ai"
|
|
423
|
+
},
|
|
424
|
+
{
|
|
425
|
+
"columns": ["thread_id"],
|
|
426
|
+
"nameExplicit": false,
|
|
427
|
+
"schemaTo": "ai",
|
|
428
|
+
"tableTo": "threads",
|
|
429
|
+
"columnsTo": ["id"],
|
|
430
|
+
"onUpdate": "NO ACTION",
|
|
431
|
+
"onDelete": "CASCADE",
|
|
432
|
+
"name": "messages_thread_id_threads_id_fk",
|
|
433
|
+
"entityType": "fks",
|
|
434
|
+
"table": "messages",
|
|
435
|
+
"schema": "ai"
|
|
436
|
+
},
|
|
437
|
+
{
|
|
438
|
+
"nameExplicit": false,
|
|
439
|
+
"columns": ["id"],
|
|
440
|
+
"name": "attachments_pkey",
|
|
441
|
+
"table": "attachments",
|
|
442
|
+
"schema": "ai",
|
|
443
|
+
"entityType": "pks"
|
|
444
|
+
},
|
|
445
|
+
{
|
|
446
|
+
"nameExplicit": false,
|
|
447
|
+
"columns": ["id"],
|
|
448
|
+
"name": "llm_requests_pkey",
|
|
449
|
+
"table": "llm_requests",
|
|
450
|
+
"schema": "ai",
|
|
451
|
+
"entityType": "pks"
|
|
452
|
+
},
|
|
453
|
+
{
|
|
454
|
+
"nameExplicit": false,
|
|
455
|
+
"columns": ["id"],
|
|
456
|
+
"name": "messages_pkey",
|
|
457
|
+
"table": "messages",
|
|
458
|
+
"schema": "ai",
|
|
459
|
+
"entityType": "pks"
|
|
460
|
+
},
|
|
461
|
+
{
|
|
462
|
+
"nameExplicit": false,
|
|
463
|
+
"columns": ["id"],
|
|
464
|
+
"name": "threads_pkey",
|
|
465
|
+
"table": "threads",
|
|
466
|
+
"schema": "ai",
|
|
467
|
+
"entityType": "pks"
|
|
468
|
+
},
|
|
469
|
+
{
|
|
470
|
+
"column": "id",
|
|
471
|
+
"nameExplicit": false,
|
|
472
|
+
"default": "(NEWID())",
|
|
473
|
+
"name": "attachments_id_default",
|
|
474
|
+
"entityType": "defaults",
|
|
475
|
+
"schema": "ai",
|
|
476
|
+
"table": "attachments"
|
|
477
|
+
},
|
|
478
|
+
{
|
|
479
|
+
"column": "id",
|
|
480
|
+
"nameExplicit": false,
|
|
481
|
+
"default": "(NEWID())",
|
|
482
|
+
"name": "llm_requests_id_default",
|
|
483
|
+
"entityType": "defaults",
|
|
484
|
+
"schema": "ai",
|
|
485
|
+
"table": "llm_requests"
|
|
486
|
+
},
|
|
487
|
+
{
|
|
488
|
+
"column": "ordinal",
|
|
489
|
+
"nameExplicit": false,
|
|
490
|
+
"default": "((0))",
|
|
491
|
+
"name": "messages_ordinal_default",
|
|
492
|
+
"entityType": "defaults",
|
|
493
|
+
"schema": "ai",
|
|
494
|
+
"table": "messages"
|
|
495
|
+
},
|
|
496
|
+
{
|
|
497
|
+
"column": "id",
|
|
498
|
+
"nameExplicit": false,
|
|
499
|
+
"default": "(NEWID())",
|
|
500
|
+
"name": "threads_id_default",
|
|
501
|
+
"entityType": "defaults",
|
|
502
|
+
"schema": "ai",
|
|
503
|
+
"table": "threads"
|
|
504
|
+
},
|
|
505
|
+
{
|
|
506
|
+
"column": "agent_id",
|
|
507
|
+
"nameExplicit": false,
|
|
508
|
+
"default": "('default')",
|
|
509
|
+
"name": "threads_agent_id_default",
|
|
510
|
+
"entityType": "defaults",
|
|
511
|
+
"schema": "ai",
|
|
512
|
+
"table": "threads"
|
|
513
|
+
}
|
|
514
|
+
],
|
|
515
|
+
"renames": []
|
|
516
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
CREATE SCHEMA "ai";
|
|
2
|
+
--> statement-breakpoint
|
|
3
|
+
CREATE TABLE "ai"."attachments" (
|
|
4
|
+
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
5
|
+
"thread_id" uuid NOT NULL,
|
|
6
|
+
"user_id" uuid NOT NULL,
|
|
7
|
+
"message_id" varchar(128),
|
|
8
|
+
"filename" varchar(2048) NOT NULL,
|
|
9
|
+
"content_type" varchar(256) NOT NULL,
|
|
10
|
+
"size_bytes" integer NOT NULL,
|
|
11
|
+
"storage_key" varchar(512) NOT NULL,
|
|
12
|
+
"status" varchar(16) NOT NULL,
|
|
13
|
+
"description" text,
|
|
14
|
+
"created_at" timestamp with time zone NOT NULL,
|
|
15
|
+
"updated_at" timestamp with time zone NOT NULL
|
|
16
|
+
);
|
|
17
|
+
--> statement-breakpoint
|
|
18
|
+
CREATE TABLE "ai"."llm_requests" (
|
|
19
|
+
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
20
|
+
"message_id" varchar(128) NOT NULL,
|
|
21
|
+
"step_number" integer NOT NULL,
|
|
22
|
+
"prompt" text NOT NULL,
|
|
23
|
+
"output" text,
|
|
24
|
+
"token_usage" jsonb
|
|
25
|
+
);
|
|
26
|
+
--> statement-breakpoint
|
|
27
|
+
CREATE TABLE "ai"."messages" (
|
|
28
|
+
"id" varchar(128) PRIMARY KEY,
|
|
29
|
+
"thread_id" uuid NOT NULL,
|
|
30
|
+
"text" text,
|
|
31
|
+
"content" jsonb NOT NULL,
|
|
32
|
+
"ordinal" integer DEFAULT 0 NOT NULL,
|
|
33
|
+
"role" varchar(16) NOT NULL,
|
|
34
|
+
"created_at" timestamp with time zone NOT NULL,
|
|
35
|
+
"updated_at" timestamp with time zone NOT NULL
|
|
36
|
+
);
|
|
37
|
+
--> statement-breakpoint
|
|
38
|
+
CREATE TABLE "ai"."threads" (
|
|
39
|
+
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
40
|
+
"user_id" uuid NOT NULL,
|
|
41
|
+
"agent_id" varchar(128) DEFAULT 'default' NOT NULL,
|
|
42
|
+
"title" varchar(256),
|
|
43
|
+
"session" jsonb,
|
|
44
|
+
"context_meta" jsonb,
|
|
45
|
+
"created_at" timestamp with time zone NOT NULL,
|
|
46
|
+
"updated_at" timestamp with time zone NOT NULL
|
|
47
|
+
);
|
|
48
|
+
--> statement-breakpoint
|
|
49
|
+
CREATE INDEX "attachments_thread_id_index" ON "ai"."attachments" ("thread_id");--> statement-breakpoint
|
|
50
|
+
ALTER TABLE "ai"."attachments" ADD CONSTRAINT "attachments_thread_id_threads_id_fkey" FOREIGN KEY ("thread_id") REFERENCES "ai"."threads"("id") ON DELETE CASCADE;--> statement-breakpoint
|
|
51
|
+
ALTER TABLE "ai"."attachments" ADD CONSTRAINT "attachments_message_id_messages_id_fkey" FOREIGN KEY ("message_id") REFERENCES "ai"."messages"("id");--> statement-breakpoint
|
|
52
|
+
ALTER TABLE "ai"."llm_requests" ADD CONSTRAINT "llm_requests_message_id_messages_id_fkey" FOREIGN KEY ("message_id") REFERENCES "ai"."messages"("id") ON DELETE CASCADE;--> statement-breakpoint
|
|
53
|
+
ALTER TABLE "ai"."messages" ADD CONSTRAINT "messages_thread_id_threads_id_fkey" FOREIGN KEY ("thread_id") REFERENCES "ai"."threads"("id") ON DELETE CASCADE;
|