@ykurilov/agent-chat-storage-postgres 0.0.0-stage → 0.56.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.
Files changed (46) hide show
  1. package/CHANGELOG.md +1220 -0
  2. package/LICENSE +21 -0
  3. package/README.md +37 -2
  4. package/dist/index.js +801 -0
  5. package/dist/index.js.map +1 -0
  6. package/dist/types/drizzle-chat-storage.d.ts +1604 -0
  7. package/dist/types/index.d.ts +2 -0
  8. package/dist/types/migrate.d.ts +6 -0
  9. package/dist/types/postgres-storage.d.ts +18 -0
  10. package/dist/types/schema.d.ts +1678 -0
  11. package/drizzle/0000_init.sql +32 -0
  12. package/drizzle/0001_chat_reasoning.sql +1 -0
  13. package/drizzle/0002_compactions.sql +16 -0
  14. package/drizzle/0003_branch_selections.sql +10 -0
  15. package/drizzle/0004_chat_title.sql +22 -0
  16. package/drizzle/0005_usage_records.sql +19 -0
  17. package/drizzle/0006_user_model_choices.sql +7 -0
  18. package/drizzle/0007_voice_dialog.sql +7 -0
  19. package/drizzle/0008_memory_notes.sql +11 -0
  20. package/drizzle/0009_memory_optimization.sql +15 -0
  21. package/drizzle/0010_usage_estimated.sql +1 -0
  22. package/drizzle/0011_message_alive_at.sql +1 -0
  23. package/drizzle/0012_spending_limit_states.sql +6 -0
  24. package/drizzle/0013_chat_origin.sql +1 -0
  25. package/drizzle/0014_chat_subject_after_turn.sql +5 -0
  26. package/drizzle/0015_chat_closed.sql +1 -0
  27. package/drizzle/0016_chat_turn_leases.sql +5 -0
  28. package/drizzle/meta/0000_snapshot.json +259 -0
  29. package/drizzle/meta/0001_snapshot.json +265 -0
  30. package/drizzle/meta/0002_snapshot.json +392 -0
  31. package/drizzle/meta/0003_snapshot.json +483 -0
  32. package/drizzle/meta/0004_snapshot.json +489 -0
  33. package/drizzle/meta/0005_snapshot.json +629 -0
  34. package/drizzle/meta/0006_snapshot.json +672 -0
  35. package/drizzle/meta/0007_snapshot.json +709 -0
  36. package/drizzle/meta/0008_snapshot.json +787 -0
  37. package/drizzle/meta/0009_snapshot.json +908 -0
  38. package/drizzle/meta/0010_snapshot.json +915 -0
  39. package/drizzle/meta/0011_snapshot.json +921 -0
  40. package/drizzle/meta/0012_snapshot.json +958 -0
  41. package/drizzle/meta/0013_snapshot.json +964 -0
  42. package/drizzle/meta/0014_snapshot.json +1019 -0
  43. package/drizzle/meta/0015_snapshot.json +1025 -0
  44. package/drizzle/meta/0016_snapshot.json +1056 -0
  45. package/drizzle/meta/_journal.json +125 -0
  46. package/package.json +46 -3
@@ -0,0 +1,265 @@
1
+ {
2
+ "id": "2c43c5d4-0f86-46d7-b559-d0c801241440",
3
+ "prevId": "6599f9f0-aaf7-46ab-afa5-2b2397ee8b8d",
4
+ "version": "7",
5
+ "dialect": "postgresql",
6
+ "tables": {
7
+ "agent_chat.chats": {
8
+ "name": "chats",
9
+ "schema": "agent_chat",
10
+ "columns": {
11
+ "id": {
12
+ "name": "id",
13
+ "type": "text",
14
+ "primaryKey": true,
15
+ "notNull": true
16
+ },
17
+ "owner_id": {
18
+ "name": "owner_id",
19
+ "type": "text",
20
+ "primaryKey": false,
21
+ "notNull": true
22
+ },
23
+ "model_id": {
24
+ "name": "model_id",
25
+ "type": "text",
26
+ "primaryKey": false,
27
+ "notNull": true
28
+ },
29
+ "provider_id": {
30
+ "name": "provider_id",
31
+ "type": "text",
32
+ "primaryKey": false,
33
+ "notNull": true
34
+ },
35
+ "reasoning": {
36
+ "name": "reasoning",
37
+ "type": "text",
38
+ "primaryKey": false,
39
+ "notNull": false
40
+ },
41
+ "created_at": {
42
+ "name": "created_at",
43
+ "type": "text",
44
+ "primaryKey": false,
45
+ "notNull": true
46
+ },
47
+ "updated_at": {
48
+ "name": "updated_at",
49
+ "type": "text",
50
+ "primaryKey": false,
51
+ "notNull": true
52
+ }
53
+ },
54
+ "indexes": {
55
+ "chats_owner_updated_idx": {
56
+ "name": "chats_owner_updated_idx",
57
+ "columns": [
58
+ {
59
+ "expression": "owner_id",
60
+ "isExpression": false,
61
+ "asc": true,
62
+ "nulls": "last"
63
+ },
64
+ {
65
+ "expression": "updated_at",
66
+ "isExpression": false,
67
+ "asc": true,
68
+ "nulls": "last"
69
+ }
70
+ ],
71
+ "isUnique": false,
72
+ "concurrently": false,
73
+ "method": "btree",
74
+ "with": {}
75
+ }
76
+ },
77
+ "foreignKeys": {},
78
+ "compositePrimaryKeys": {},
79
+ "uniqueConstraints": {},
80
+ "policies": {},
81
+ "checkConstraints": {},
82
+ "isRLSEnabled": false
83
+ },
84
+ "agent_chat.messages": {
85
+ "name": "messages",
86
+ "schema": "agent_chat",
87
+ "columns": {
88
+ "seq": {
89
+ "name": "seq",
90
+ "type": "bigint",
91
+ "primaryKey": false,
92
+ "notNull": true,
93
+ "identity": {
94
+ "type": "always",
95
+ "name": "messages_seq_seq",
96
+ "schema": "agent_chat",
97
+ "increment": "1",
98
+ "startWith": "1",
99
+ "minValue": "1",
100
+ "maxValue": "9223372036854775807",
101
+ "cache": "1",
102
+ "cycle": false
103
+ }
104
+ },
105
+ "id": {
106
+ "name": "id",
107
+ "type": "text",
108
+ "primaryKey": true,
109
+ "notNull": true
110
+ },
111
+ "chat_id": {
112
+ "name": "chat_id",
113
+ "type": "text",
114
+ "primaryKey": false,
115
+ "notNull": true
116
+ },
117
+ "parent_id": {
118
+ "name": "parent_id",
119
+ "type": "text",
120
+ "primaryKey": false,
121
+ "notNull": false
122
+ },
123
+ "role": {
124
+ "name": "role",
125
+ "type": "text",
126
+ "primaryKey": false,
127
+ "notNull": true
128
+ },
129
+ "parts": {
130
+ "name": "parts",
131
+ "type": "json",
132
+ "primaryKey": false,
133
+ "notNull": true
134
+ },
135
+ "format_version": {
136
+ "name": "format_version",
137
+ "type": "integer",
138
+ "primaryKey": false,
139
+ "notNull": true
140
+ },
141
+ "status": {
142
+ "name": "status",
143
+ "type": "text",
144
+ "primaryKey": false,
145
+ "notNull": true
146
+ },
147
+ "model_id": {
148
+ "name": "model_id",
149
+ "type": "text",
150
+ "primaryKey": false,
151
+ "notNull": false
152
+ },
153
+ "provider_id": {
154
+ "name": "provider_id",
155
+ "type": "text",
156
+ "primaryKey": false,
157
+ "notNull": false
158
+ },
159
+ "usage": {
160
+ "name": "usage",
161
+ "type": "json",
162
+ "primaryKey": false,
163
+ "notNull": false
164
+ },
165
+ "reasoning_durations_ms": {
166
+ "name": "reasoning_durations_ms",
167
+ "type": "json",
168
+ "primaryKey": false,
169
+ "notNull": true
170
+ },
171
+ "error": {
172
+ "name": "error",
173
+ "type": "json",
174
+ "primaryKey": false,
175
+ "notNull": false
176
+ },
177
+ "created_at": {
178
+ "name": "created_at",
179
+ "type": "text",
180
+ "primaryKey": false,
181
+ "notNull": true
182
+ }
183
+ },
184
+ "indexes": {
185
+ "messages_chat_created_idx": {
186
+ "name": "messages_chat_created_idx",
187
+ "columns": [
188
+ {
189
+ "expression": "chat_id",
190
+ "isExpression": false,
191
+ "asc": true,
192
+ "nulls": "last"
193
+ },
194
+ {
195
+ "expression": "created_at",
196
+ "isExpression": false,
197
+ "asc": true,
198
+ "nulls": "last"
199
+ },
200
+ {
201
+ "expression": "seq",
202
+ "isExpression": false,
203
+ "asc": true,
204
+ "nulls": "last"
205
+ }
206
+ ],
207
+ "isUnique": false,
208
+ "concurrently": false,
209
+ "method": "btree",
210
+ "with": {}
211
+ },
212
+ "messages_streaming_idx": {
213
+ "name": "messages_streaming_idx",
214
+ "columns": [
215
+ {
216
+ "expression": "status",
217
+ "isExpression": false,
218
+ "asc": true,
219
+ "nulls": "last"
220
+ }
221
+ ],
222
+ "isUnique": false,
223
+ "where": "\"agent_chat\".\"messages\".\"status\" = 'streaming'",
224
+ "concurrently": false,
225
+ "method": "btree",
226
+ "with": {}
227
+ }
228
+ },
229
+ "foreignKeys": {
230
+ "messages_chat_id_chats_id_fk": {
231
+ "name": "messages_chat_id_chats_id_fk",
232
+ "tableFrom": "messages",
233
+ "tableTo": "chats",
234
+ "schemaTo": "agent_chat",
235
+ "columnsFrom": [
236
+ "chat_id"
237
+ ],
238
+ "columnsTo": [
239
+ "id"
240
+ ],
241
+ "onDelete": "cascade",
242
+ "onUpdate": "no action"
243
+ }
244
+ },
245
+ "compositePrimaryKeys": {},
246
+ "uniqueConstraints": {},
247
+ "policies": {},
248
+ "checkConstraints": {},
249
+ "isRLSEnabled": false
250
+ }
251
+ },
252
+ "enums": {},
253
+ "schemas": {
254
+ "agent_chat": "agent_chat"
255
+ },
256
+ "sequences": {},
257
+ "roles": {},
258
+ "policies": {},
259
+ "views": {},
260
+ "_meta": {
261
+ "columns": {},
262
+ "schemas": {},
263
+ "tables": {}
264
+ }
265
+ }
@@ -0,0 +1,392 @@
1
+ {
2
+ "id": "e2fdc40f-ef47-4bfe-aa45-ce7b92e9f62f",
3
+ "prevId": "2c43c5d4-0f86-46d7-b559-d0c801241440",
4
+ "version": "7",
5
+ "dialect": "postgresql",
6
+ "tables": {
7
+ "agent_chat.chats": {
8
+ "name": "chats",
9
+ "schema": "agent_chat",
10
+ "columns": {
11
+ "id": {
12
+ "name": "id",
13
+ "type": "text",
14
+ "primaryKey": true,
15
+ "notNull": true
16
+ },
17
+ "owner_id": {
18
+ "name": "owner_id",
19
+ "type": "text",
20
+ "primaryKey": false,
21
+ "notNull": true
22
+ },
23
+ "model_id": {
24
+ "name": "model_id",
25
+ "type": "text",
26
+ "primaryKey": false,
27
+ "notNull": true
28
+ },
29
+ "provider_id": {
30
+ "name": "provider_id",
31
+ "type": "text",
32
+ "primaryKey": false,
33
+ "notNull": true
34
+ },
35
+ "reasoning": {
36
+ "name": "reasoning",
37
+ "type": "text",
38
+ "primaryKey": false,
39
+ "notNull": false
40
+ },
41
+ "created_at": {
42
+ "name": "created_at",
43
+ "type": "text",
44
+ "primaryKey": false,
45
+ "notNull": true
46
+ },
47
+ "updated_at": {
48
+ "name": "updated_at",
49
+ "type": "text",
50
+ "primaryKey": false,
51
+ "notNull": true
52
+ }
53
+ },
54
+ "indexes": {
55
+ "chats_owner_updated_idx": {
56
+ "name": "chats_owner_updated_idx",
57
+ "columns": [
58
+ {
59
+ "expression": "owner_id",
60
+ "isExpression": false,
61
+ "asc": true,
62
+ "nulls": "last"
63
+ },
64
+ {
65
+ "expression": "updated_at",
66
+ "isExpression": false,
67
+ "asc": true,
68
+ "nulls": "last"
69
+ }
70
+ ],
71
+ "isUnique": false,
72
+ "concurrently": false,
73
+ "method": "btree",
74
+ "with": {}
75
+ }
76
+ },
77
+ "foreignKeys": {},
78
+ "compositePrimaryKeys": {},
79
+ "uniqueConstraints": {},
80
+ "policies": {},
81
+ "checkConstraints": {},
82
+ "isRLSEnabled": false
83
+ },
84
+ "agent_chat.compactions": {
85
+ "name": "compactions",
86
+ "schema": "agent_chat",
87
+ "columns": {
88
+ "seq": {
89
+ "name": "seq",
90
+ "type": "bigint",
91
+ "primaryKey": false,
92
+ "notNull": true,
93
+ "identity": {
94
+ "type": "always",
95
+ "name": "compactions_seq_seq",
96
+ "schema": "agent_chat",
97
+ "increment": "1",
98
+ "startWith": "1",
99
+ "minValue": "1",
100
+ "maxValue": "9223372036854775807",
101
+ "cache": "1",
102
+ "cycle": false
103
+ }
104
+ },
105
+ "id": {
106
+ "name": "id",
107
+ "type": "text",
108
+ "primaryKey": true,
109
+ "notNull": true
110
+ },
111
+ "chat_id": {
112
+ "name": "chat_id",
113
+ "type": "text",
114
+ "primaryKey": false,
115
+ "notNull": true
116
+ },
117
+ "from_message_id": {
118
+ "name": "from_message_id",
119
+ "type": "text",
120
+ "primaryKey": false,
121
+ "notNull": true
122
+ },
123
+ "through_message_id": {
124
+ "name": "through_message_id",
125
+ "type": "text",
126
+ "primaryKey": false,
127
+ "notNull": true
128
+ },
129
+ "summary": {
130
+ "name": "summary",
131
+ "type": "text",
132
+ "primaryKey": false,
133
+ "notNull": true
134
+ },
135
+ "summary_tokens": {
136
+ "name": "summary_tokens",
137
+ "type": "integer",
138
+ "primaryKey": false,
139
+ "notNull": true
140
+ },
141
+ "model_id": {
142
+ "name": "model_id",
143
+ "type": "text",
144
+ "primaryKey": false,
145
+ "notNull": true
146
+ },
147
+ "provider_id": {
148
+ "name": "provider_id",
149
+ "type": "text",
150
+ "primaryKey": false,
151
+ "notNull": true
152
+ },
153
+ "usage": {
154
+ "name": "usage",
155
+ "type": "json",
156
+ "primaryKey": false,
157
+ "notNull": false
158
+ },
159
+ "created_at": {
160
+ "name": "created_at",
161
+ "type": "text",
162
+ "primaryKey": false,
163
+ "notNull": true
164
+ }
165
+ },
166
+ "indexes": {
167
+ "compactions_chat_seq_idx": {
168
+ "name": "compactions_chat_seq_idx",
169
+ "columns": [
170
+ {
171
+ "expression": "chat_id",
172
+ "isExpression": false,
173
+ "asc": true,
174
+ "nulls": "last"
175
+ },
176
+ {
177
+ "expression": "seq",
178
+ "isExpression": false,
179
+ "asc": true,
180
+ "nulls": "last"
181
+ }
182
+ ],
183
+ "isUnique": false,
184
+ "concurrently": false,
185
+ "method": "btree",
186
+ "with": {}
187
+ }
188
+ },
189
+ "foreignKeys": {
190
+ "compactions_chat_id_chats_id_fk": {
191
+ "name": "compactions_chat_id_chats_id_fk",
192
+ "tableFrom": "compactions",
193
+ "tableTo": "chats",
194
+ "schemaTo": "agent_chat",
195
+ "columnsFrom": [
196
+ "chat_id"
197
+ ],
198
+ "columnsTo": [
199
+ "id"
200
+ ],
201
+ "onDelete": "cascade",
202
+ "onUpdate": "no action"
203
+ }
204
+ },
205
+ "compositePrimaryKeys": {},
206
+ "uniqueConstraints": {},
207
+ "policies": {},
208
+ "checkConstraints": {},
209
+ "isRLSEnabled": false
210
+ },
211
+ "agent_chat.messages": {
212
+ "name": "messages",
213
+ "schema": "agent_chat",
214
+ "columns": {
215
+ "seq": {
216
+ "name": "seq",
217
+ "type": "bigint",
218
+ "primaryKey": false,
219
+ "notNull": true,
220
+ "identity": {
221
+ "type": "always",
222
+ "name": "messages_seq_seq",
223
+ "schema": "agent_chat",
224
+ "increment": "1",
225
+ "startWith": "1",
226
+ "minValue": "1",
227
+ "maxValue": "9223372036854775807",
228
+ "cache": "1",
229
+ "cycle": false
230
+ }
231
+ },
232
+ "id": {
233
+ "name": "id",
234
+ "type": "text",
235
+ "primaryKey": true,
236
+ "notNull": true
237
+ },
238
+ "chat_id": {
239
+ "name": "chat_id",
240
+ "type": "text",
241
+ "primaryKey": false,
242
+ "notNull": true
243
+ },
244
+ "parent_id": {
245
+ "name": "parent_id",
246
+ "type": "text",
247
+ "primaryKey": false,
248
+ "notNull": false
249
+ },
250
+ "role": {
251
+ "name": "role",
252
+ "type": "text",
253
+ "primaryKey": false,
254
+ "notNull": true
255
+ },
256
+ "parts": {
257
+ "name": "parts",
258
+ "type": "json",
259
+ "primaryKey": false,
260
+ "notNull": true
261
+ },
262
+ "format_version": {
263
+ "name": "format_version",
264
+ "type": "integer",
265
+ "primaryKey": false,
266
+ "notNull": true
267
+ },
268
+ "status": {
269
+ "name": "status",
270
+ "type": "text",
271
+ "primaryKey": false,
272
+ "notNull": true
273
+ },
274
+ "model_id": {
275
+ "name": "model_id",
276
+ "type": "text",
277
+ "primaryKey": false,
278
+ "notNull": false
279
+ },
280
+ "provider_id": {
281
+ "name": "provider_id",
282
+ "type": "text",
283
+ "primaryKey": false,
284
+ "notNull": false
285
+ },
286
+ "usage": {
287
+ "name": "usage",
288
+ "type": "json",
289
+ "primaryKey": false,
290
+ "notNull": false
291
+ },
292
+ "reasoning_durations_ms": {
293
+ "name": "reasoning_durations_ms",
294
+ "type": "json",
295
+ "primaryKey": false,
296
+ "notNull": true
297
+ },
298
+ "error": {
299
+ "name": "error",
300
+ "type": "json",
301
+ "primaryKey": false,
302
+ "notNull": false
303
+ },
304
+ "created_at": {
305
+ "name": "created_at",
306
+ "type": "text",
307
+ "primaryKey": false,
308
+ "notNull": true
309
+ }
310
+ },
311
+ "indexes": {
312
+ "messages_chat_created_idx": {
313
+ "name": "messages_chat_created_idx",
314
+ "columns": [
315
+ {
316
+ "expression": "chat_id",
317
+ "isExpression": false,
318
+ "asc": true,
319
+ "nulls": "last"
320
+ },
321
+ {
322
+ "expression": "created_at",
323
+ "isExpression": false,
324
+ "asc": true,
325
+ "nulls": "last"
326
+ },
327
+ {
328
+ "expression": "seq",
329
+ "isExpression": false,
330
+ "asc": true,
331
+ "nulls": "last"
332
+ }
333
+ ],
334
+ "isUnique": false,
335
+ "concurrently": false,
336
+ "method": "btree",
337
+ "with": {}
338
+ },
339
+ "messages_streaming_idx": {
340
+ "name": "messages_streaming_idx",
341
+ "columns": [
342
+ {
343
+ "expression": "status",
344
+ "isExpression": false,
345
+ "asc": true,
346
+ "nulls": "last"
347
+ }
348
+ ],
349
+ "isUnique": false,
350
+ "where": "\"agent_chat\".\"messages\".\"status\" = 'streaming'",
351
+ "concurrently": false,
352
+ "method": "btree",
353
+ "with": {}
354
+ }
355
+ },
356
+ "foreignKeys": {
357
+ "messages_chat_id_chats_id_fk": {
358
+ "name": "messages_chat_id_chats_id_fk",
359
+ "tableFrom": "messages",
360
+ "tableTo": "chats",
361
+ "schemaTo": "agent_chat",
362
+ "columnsFrom": [
363
+ "chat_id"
364
+ ],
365
+ "columnsTo": [
366
+ "id"
367
+ ],
368
+ "onDelete": "cascade",
369
+ "onUpdate": "no action"
370
+ }
371
+ },
372
+ "compositePrimaryKeys": {},
373
+ "uniqueConstraints": {},
374
+ "policies": {},
375
+ "checkConstraints": {},
376
+ "isRLSEnabled": false
377
+ }
378
+ },
379
+ "enums": {},
380
+ "schemas": {
381
+ "agent_chat": "agent_chat"
382
+ },
383
+ "sequences": {},
384
+ "roles": {},
385
+ "policies": {},
386
+ "views": {},
387
+ "_meta": {
388
+ "columns": {},
389
+ "schemas": {},
390
+ "tables": {}
391
+ }
392
+ }