@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,1056 @@
1
+ {
2
+ "id": "3bfcf4f0-e4b0-4e35-bcae-c5fcc5599a88",
3
+ "prevId": "fa5d9414-6f2f-4a75-9354-8e2c4622a413",
4
+ "version": "7",
5
+ "dialect": "postgresql",
6
+ "tables": {
7
+ "agent_chat.branch_selections": {
8
+ "name": "branch_selections",
9
+ "schema": "agent_chat",
10
+ "columns": {
11
+ "seq": {
12
+ "name": "seq",
13
+ "type": "bigint",
14
+ "primaryKey": false,
15
+ "notNull": true,
16
+ "identity": {
17
+ "type": "always",
18
+ "name": "branch_selections_seq_seq",
19
+ "schema": "agent_chat",
20
+ "increment": "1",
21
+ "startWith": "1",
22
+ "minValue": "1",
23
+ "maxValue": "9223372036854775807",
24
+ "cache": "1",
25
+ "cycle": false
26
+ }
27
+ },
28
+ "id": {
29
+ "name": "id",
30
+ "type": "text",
31
+ "primaryKey": true,
32
+ "notNull": true
33
+ },
34
+ "chat_id": {
35
+ "name": "chat_id",
36
+ "type": "text",
37
+ "primaryKey": false,
38
+ "notNull": true
39
+ },
40
+ "message_id": {
41
+ "name": "message_id",
42
+ "type": "text",
43
+ "primaryKey": false,
44
+ "notNull": true
45
+ },
46
+ "selected_at": {
47
+ "name": "selected_at",
48
+ "type": "text",
49
+ "primaryKey": false,
50
+ "notNull": true
51
+ }
52
+ },
53
+ "indexes": {
54
+ "branch_selections_chat_seq_idx": {
55
+ "name": "branch_selections_chat_seq_idx",
56
+ "columns": [
57
+ {
58
+ "expression": "chat_id",
59
+ "isExpression": false,
60
+ "asc": true,
61
+ "nulls": "last"
62
+ },
63
+ {
64
+ "expression": "seq",
65
+ "isExpression": false,
66
+ "asc": true,
67
+ "nulls": "last"
68
+ }
69
+ ],
70
+ "isUnique": false,
71
+ "concurrently": false,
72
+ "method": "btree",
73
+ "with": {}
74
+ }
75
+ },
76
+ "foreignKeys": {
77
+ "branch_selections_chat_id_chats_id_fk": {
78
+ "name": "branch_selections_chat_id_chats_id_fk",
79
+ "tableFrom": "branch_selections",
80
+ "tableTo": "chats",
81
+ "schemaTo": "agent_chat",
82
+ "columnsFrom": [
83
+ "chat_id"
84
+ ],
85
+ "columnsTo": [
86
+ "id"
87
+ ],
88
+ "onDelete": "cascade",
89
+ "onUpdate": "no action"
90
+ }
91
+ },
92
+ "compositePrimaryKeys": {},
93
+ "uniqueConstraints": {},
94
+ "policies": {},
95
+ "checkConstraints": {},
96
+ "isRLSEnabled": false
97
+ },
98
+ "agent_chat.chat_turn_leases": {
99
+ "name": "chat_turn_leases",
100
+ "schema": "agent_chat",
101
+ "columns": {
102
+ "chat_id": {
103
+ "name": "chat_id",
104
+ "type": "text",
105
+ "primaryKey": true,
106
+ "notNull": true
107
+ },
108
+ "holder": {
109
+ "name": "holder",
110
+ "type": "text",
111
+ "primaryKey": false,
112
+ "notNull": true
113
+ },
114
+ "until": {
115
+ "name": "until",
116
+ "type": "timestamp with time zone",
117
+ "primaryKey": false,
118
+ "notNull": true
119
+ }
120
+ },
121
+ "indexes": {},
122
+ "foreignKeys": {},
123
+ "compositePrimaryKeys": {},
124
+ "uniqueConstraints": {},
125
+ "policies": {},
126
+ "checkConstraints": {},
127
+ "isRLSEnabled": false
128
+ },
129
+ "agent_chat.chats": {
130
+ "name": "chats",
131
+ "schema": "agent_chat",
132
+ "columns": {
133
+ "id": {
134
+ "name": "id",
135
+ "type": "text",
136
+ "primaryKey": true,
137
+ "notNull": true
138
+ },
139
+ "owner_id": {
140
+ "name": "owner_id",
141
+ "type": "text",
142
+ "primaryKey": false,
143
+ "notNull": true
144
+ },
145
+ "model_id": {
146
+ "name": "model_id",
147
+ "type": "text",
148
+ "primaryKey": false,
149
+ "notNull": true
150
+ },
151
+ "provider_id": {
152
+ "name": "provider_id",
153
+ "type": "text",
154
+ "primaryKey": false,
155
+ "notNull": true
156
+ },
157
+ "reasoning": {
158
+ "name": "reasoning",
159
+ "type": "text",
160
+ "primaryKey": false,
161
+ "notNull": false
162
+ },
163
+ "title": {
164
+ "name": "title",
165
+ "type": "text",
166
+ "primaryKey": false,
167
+ "notNull": false
168
+ },
169
+ "origin": {
170
+ "name": "origin",
171
+ "type": "text",
172
+ "primaryKey": false,
173
+ "notNull": false
174
+ },
175
+ "subject_key": {
176
+ "name": "subject_key",
177
+ "type": "text",
178
+ "primaryKey": false,
179
+ "notNull": false
180
+ },
181
+ "subject_data": {
182
+ "name": "subject_data",
183
+ "type": "json",
184
+ "primaryKey": false,
185
+ "notNull": false
186
+ },
187
+ "closed": {
188
+ "name": "closed",
189
+ "type": "json",
190
+ "primaryKey": false,
191
+ "notNull": false
192
+ },
193
+ "created_at": {
194
+ "name": "created_at",
195
+ "type": "text",
196
+ "primaryKey": false,
197
+ "notNull": true
198
+ },
199
+ "updated_at": {
200
+ "name": "updated_at",
201
+ "type": "text",
202
+ "primaryKey": false,
203
+ "notNull": true
204
+ }
205
+ },
206
+ "indexes": {
207
+ "chats_owner_updated_idx": {
208
+ "name": "chats_owner_updated_idx",
209
+ "columns": [
210
+ {
211
+ "expression": "owner_id",
212
+ "isExpression": false,
213
+ "asc": true,
214
+ "nulls": "last"
215
+ },
216
+ {
217
+ "expression": "updated_at",
218
+ "isExpression": false,
219
+ "asc": true,
220
+ "nulls": "last"
221
+ }
222
+ ],
223
+ "isUnique": false,
224
+ "concurrently": false,
225
+ "method": "btree",
226
+ "with": {}
227
+ },
228
+ "chats_owner_subject_idx": {
229
+ "name": "chats_owner_subject_idx",
230
+ "columns": [
231
+ {
232
+ "expression": "owner_id",
233
+ "isExpression": false,
234
+ "asc": true,
235
+ "nulls": "last"
236
+ },
237
+ {
238
+ "expression": "subject_key",
239
+ "isExpression": false,
240
+ "asc": true,
241
+ "nulls": "last"
242
+ }
243
+ ],
244
+ "isUnique": true,
245
+ "concurrently": false,
246
+ "method": "btree",
247
+ "with": {}
248
+ }
249
+ },
250
+ "foreignKeys": {},
251
+ "compositePrimaryKeys": {},
252
+ "uniqueConstraints": {},
253
+ "policies": {},
254
+ "checkConstraints": {},
255
+ "isRLSEnabled": false
256
+ },
257
+ "agent_chat.compactions": {
258
+ "name": "compactions",
259
+ "schema": "agent_chat",
260
+ "columns": {
261
+ "seq": {
262
+ "name": "seq",
263
+ "type": "bigint",
264
+ "primaryKey": false,
265
+ "notNull": true,
266
+ "identity": {
267
+ "type": "always",
268
+ "name": "compactions_seq_seq",
269
+ "schema": "agent_chat",
270
+ "increment": "1",
271
+ "startWith": "1",
272
+ "minValue": "1",
273
+ "maxValue": "9223372036854775807",
274
+ "cache": "1",
275
+ "cycle": false
276
+ }
277
+ },
278
+ "id": {
279
+ "name": "id",
280
+ "type": "text",
281
+ "primaryKey": true,
282
+ "notNull": true
283
+ },
284
+ "chat_id": {
285
+ "name": "chat_id",
286
+ "type": "text",
287
+ "primaryKey": false,
288
+ "notNull": true
289
+ },
290
+ "from_message_id": {
291
+ "name": "from_message_id",
292
+ "type": "text",
293
+ "primaryKey": false,
294
+ "notNull": true
295
+ },
296
+ "through_message_id": {
297
+ "name": "through_message_id",
298
+ "type": "text",
299
+ "primaryKey": false,
300
+ "notNull": true
301
+ },
302
+ "summary": {
303
+ "name": "summary",
304
+ "type": "text",
305
+ "primaryKey": false,
306
+ "notNull": true
307
+ },
308
+ "summary_tokens": {
309
+ "name": "summary_tokens",
310
+ "type": "integer",
311
+ "primaryKey": false,
312
+ "notNull": true
313
+ },
314
+ "model_id": {
315
+ "name": "model_id",
316
+ "type": "text",
317
+ "primaryKey": false,
318
+ "notNull": true
319
+ },
320
+ "provider_id": {
321
+ "name": "provider_id",
322
+ "type": "text",
323
+ "primaryKey": false,
324
+ "notNull": true
325
+ },
326
+ "usage": {
327
+ "name": "usage",
328
+ "type": "json",
329
+ "primaryKey": false,
330
+ "notNull": false
331
+ },
332
+ "created_at": {
333
+ "name": "created_at",
334
+ "type": "text",
335
+ "primaryKey": false,
336
+ "notNull": true
337
+ }
338
+ },
339
+ "indexes": {
340
+ "compactions_chat_seq_idx": {
341
+ "name": "compactions_chat_seq_idx",
342
+ "columns": [
343
+ {
344
+ "expression": "chat_id",
345
+ "isExpression": false,
346
+ "asc": true,
347
+ "nulls": "last"
348
+ },
349
+ {
350
+ "expression": "seq",
351
+ "isExpression": false,
352
+ "asc": true,
353
+ "nulls": "last"
354
+ }
355
+ ],
356
+ "isUnique": false,
357
+ "concurrently": false,
358
+ "method": "btree",
359
+ "with": {}
360
+ }
361
+ },
362
+ "foreignKeys": {
363
+ "compactions_chat_id_chats_id_fk": {
364
+ "name": "compactions_chat_id_chats_id_fk",
365
+ "tableFrom": "compactions",
366
+ "tableTo": "chats",
367
+ "schemaTo": "agent_chat",
368
+ "columnsFrom": [
369
+ "chat_id"
370
+ ],
371
+ "columnsTo": [
372
+ "id"
373
+ ],
374
+ "onDelete": "cascade",
375
+ "onUpdate": "no action"
376
+ }
377
+ },
378
+ "compositePrimaryKeys": {},
379
+ "uniqueConstraints": {},
380
+ "policies": {},
381
+ "checkConstraints": {},
382
+ "isRLSEnabled": false
383
+ },
384
+ "agent_chat.memory_notes": {
385
+ "name": "memory_notes",
386
+ "schema": "agent_chat",
387
+ "columns": {
388
+ "id": {
389
+ "name": "id",
390
+ "type": "text",
391
+ "primaryKey": true,
392
+ "notNull": true
393
+ },
394
+ "owner_id": {
395
+ "name": "owner_id",
396
+ "type": "text",
397
+ "primaryKey": false,
398
+ "notNull": true
399
+ },
400
+ "categories": {
401
+ "name": "categories",
402
+ "type": "jsonb",
403
+ "primaryKey": false,
404
+ "notNull": true
405
+ },
406
+ "content": {
407
+ "name": "content",
408
+ "type": "text",
409
+ "primaryKey": false,
410
+ "notNull": true
411
+ },
412
+ "version": {
413
+ "name": "version",
414
+ "type": "integer",
415
+ "primaryKey": false,
416
+ "notNull": true,
417
+ "default": 1
418
+ },
419
+ "created_at": {
420
+ "name": "created_at",
421
+ "type": "timestamp with time zone",
422
+ "primaryKey": false,
423
+ "notNull": true
424
+ },
425
+ "updated_at": {
426
+ "name": "updated_at",
427
+ "type": "timestamp with time zone",
428
+ "primaryKey": false,
429
+ "notNull": true
430
+ },
431
+ "merged_into": {
432
+ "name": "merged_into",
433
+ "type": "text",
434
+ "primaryKey": false,
435
+ "notNull": false
436
+ }
437
+ },
438
+ "indexes": {
439
+ "memory_notes_owner_updated_idx": {
440
+ "name": "memory_notes_owner_updated_idx",
441
+ "columns": [
442
+ {
443
+ "expression": "owner_id",
444
+ "isExpression": false,
445
+ "asc": true,
446
+ "nulls": "last"
447
+ },
448
+ {
449
+ "expression": "updated_at",
450
+ "isExpression": false,
451
+ "asc": true,
452
+ "nulls": "last"
453
+ }
454
+ ],
455
+ "isUnique": false,
456
+ "concurrently": false,
457
+ "method": "btree",
458
+ "with": {}
459
+ },
460
+ "memory_notes_merged_into_idx": {
461
+ "name": "memory_notes_merged_into_idx",
462
+ "columns": [
463
+ {
464
+ "expression": "merged_into",
465
+ "isExpression": false,
466
+ "asc": true,
467
+ "nulls": "last"
468
+ }
469
+ ],
470
+ "isUnique": false,
471
+ "concurrently": false,
472
+ "method": "btree",
473
+ "with": {}
474
+ }
475
+ },
476
+ "foreignKeys": {},
477
+ "compositePrimaryKeys": {},
478
+ "uniqueConstraints": {},
479
+ "policies": {},
480
+ "checkConstraints": {},
481
+ "isRLSEnabled": false
482
+ },
483
+ "agent_chat.memory_optimization_runs": {
484
+ "name": "memory_optimization_runs",
485
+ "schema": "agent_chat",
486
+ "columns": {
487
+ "id": {
488
+ "name": "id",
489
+ "type": "text",
490
+ "primaryKey": true,
491
+ "notNull": true
492
+ },
493
+ "owner_id": {
494
+ "name": "owner_id",
495
+ "type": "text",
496
+ "primaryKey": false,
497
+ "notNull": true
498
+ },
499
+ "started_at": {
500
+ "name": "started_at",
501
+ "type": "timestamp with time zone",
502
+ "primaryKey": false,
503
+ "notNull": true
504
+ },
505
+ "finished_at": {
506
+ "name": "finished_at",
507
+ "type": "timestamp with time zone",
508
+ "primaryKey": false,
509
+ "notNull": false
510
+ },
511
+ "status": {
512
+ "name": "status",
513
+ "type": "text",
514
+ "primaryKey": false,
515
+ "notNull": true
516
+ },
517
+ "groups": {
518
+ "name": "groups",
519
+ "type": "jsonb",
520
+ "primaryKey": false,
521
+ "notNull": true,
522
+ "default": "'[]'::jsonb"
523
+ },
524
+ "error": {
525
+ "name": "error",
526
+ "type": "text",
527
+ "primaryKey": false,
528
+ "notNull": false
529
+ },
530
+ "usage_record_id": {
531
+ "name": "usage_record_id",
532
+ "type": "text",
533
+ "primaryKey": false,
534
+ "notNull": false
535
+ }
536
+ },
537
+ "indexes": {
538
+ "memory_optimization_runs_owner_started_idx": {
539
+ "name": "memory_optimization_runs_owner_started_idx",
540
+ "columns": [
541
+ {
542
+ "expression": "owner_id",
543
+ "isExpression": false,
544
+ "asc": true,
545
+ "nulls": "last"
546
+ },
547
+ {
548
+ "expression": "started_at",
549
+ "isExpression": false,
550
+ "asc": true,
551
+ "nulls": "last"
552
+ }
553
+ ],
554
+ "isUnique": false,
555
+ "concurrently": false,
556
+ "method": "btree",
557
+ "with": {}
558
+ },
559
+ "memory_optimization_runs_one_running_idx": {
560
+ "name": "memory_optimization_runs_one_running_idx",
561
+ "columns": [
562
+ {
563
+ "expression": "owner_id",
564
+ "isExpression": false,
565
+ "asc": true,
566
+ "nulls": "last"
567
+ }
568
+ ],
569
+ "isUnique": true,
570
+ "where": "\"agent_chat\".\"memory_optimization_runs\".\"status\" = 'running'",
571
+ "concurrently": false,
572
+ "method": "btree",
573
+ "with": {}
574
+ }
575
+ },
576
+ "foreignKeys": {},
577
+ "compositePrimaryKeys": {},
578
+ "uniqueConstraints": {},
579
+ "policies": {},
580
+ "checkConstraints": {},
581
+ "isRLSEnabled": false
582
+ },
583
+ "agent_chat.messages": {
584
+ "name": "messages",
585
+ "schema": "agent_chat",
586
+ "columns": {
587
+ "seq": {
588
+ "name": "seq",
589
+ "type": "bigint",
590
+ "primaryKey": false,
591
+ "notNull": true,
592
+ "identity": {
593
+ "type": "always",
594
+ "name": "messages_seq_seq",
595
+ "schema": "agent_chat",
596
+ "increment": "1",
597
+ "startWith": "1",
598
+ "minValue": "1",
599
+ "maxValue": "9223372036854775807",
600
+ "cache": "1",
601
+ "cycle": false
602
+ }
603
+ },
604
+ "id": {
605
+ "name": "id",
606
+ "type": "text",
607
+ "primaryKey": true,
608
+ "notNull": true
609
+ },
610
+ "chat_id": {
611
+ "name": "chat_id",
612
+ "type": "text",
613
+ "primaryKey": false,
614
+ "notNull": true
615
+ },
616
+ "parent_id": {
617
+ "name": "parent_id",
618
+ "type": "text",
619
+ "primaryKey": false,
620
+ "notNull": false
621
+ },
622
+ "role": {
623
+ "name": "role",
624
+ "type": "text",
625
+ "primaryKey": false,
626
+ "notNull": true
627
+ },
628
+ "parts": {
629
+ "name": "parts",
630
+ "type": "json",
631
+ "primaryKey": false,
632
+ "notNull": true
633
+ },
634
+ "format_version": {
635
+ "name": "format_version",
636
+ "type": "integer",
637
+ "primaryKey": false,
638
+ "notNull": true
639
+ },
640
+ "status": {
641
+ "name": "status",
642
+ "type": "text",
643
+ "primaryKey": false,
644
+ "notNull": true
645
+ },
646
+ "model_id": {
647
+ "name": "model_id",
648
+ "type": "text",
649
+ "primaryKey": false,
650
+ "notNull": false
651
+ },
652
+ "provider_id": {
653
+ "name": "provider_id",
654
+ "type": "text",
655
+ "primaryKey": false,
656
+ "notNull": false
657
+ },
658
+ "usage": {
659
+ "name": "usage",
660
+ "type": "json",
661
+ "primaryKey": false,
662
+ "notNull": false
663
+ },
664
+ "reasoning_durations_ms": {
665
+ "name": "reasoning_durations_ms",
666
+ "type": "json",
667
+ "primaryKey": false,
668
+ "notNull": true
669
+ },
670
+ "error": {
671
+ "name": "error",
672
+ "type": "json",
673
+ "primaryKey": false,
674
+ "notNull": false
675
+ },
676
+ "voice_cut": {
677
+ "name": "voice_cut",
678
+ "type": "json",
679
+ "primaryKey": false,
680
+ "notNull": false
681
+ },
682
+ "after_turn": {
683
+ "name": "after_turn",
684
+ "type": "text",
685
+ "primaryKey": false,
686
+ "notNull": false
687
+ },
688
+ "created_at": {
689
+ "name": "created_at",
690
+ "type": "text",
691
+ "primaryKey": false,
692
+ "notNull": true
693
+ },
694
+ "alive_at": {
695
+ "name": "alive_at",
696
+ "type": "text",
697
+ "primaryKey": false,
698
+ "notNull": false
699
+ }
700
+ },
701
+ "indexes": {
702
+ "messages_chat_created_idx": {
703
+ "name": "messages_chat_created_idx",
704
+ "columns": [
705
+ {
706
+ "expression": "chat_id",
707
+ "isExpression": false,
708
+ "asc": true,
709
+ "nulls": "last"
710
+ },
711
+ {
712
+ "expression": "created_at",
713
+ "isExpression": false,
714
+ "asc": true,
715
+ "nulls": "last"
716
+ },
717
+ {
718
+ "expression": "seq",
719
+ "isExpression": false,
720
+ "asc": true,
721
+ "nulls": "last"
722
+ }
723
+ ],
724
+ "isUnique": false,
725
+ "concurrently": false,
726
+ "method": "btree",
727
+ "with": {}
728
+ },
729
+ "messages_streaming_idx": {
730
+ "name": "messages_streaming_idx",
731
+ "columns": [
732
+ {
733
+ "expression": "status",
734
+ "isExpression": false,
735
+ "asc": true,
736
+ "nulls": "last"
737
+ }
738
+ ],
739
+ "isUnique": false,
740
+ "where": "\"agent_chat\".\"messages\".\"status\" = 'streaming'",
741
+ "concurrently": false,
742
+ "method": "btree",
743
+ "with": {}
744
+ },
745
+ "messages_after_turn_pending_idx": {
746
+ "name": "messages_after_turn_pending_idx",
747
+ "columns": [
748
+ {
749
+ "expression": "after_turn",
750
+ "isExpression": false,
751
+ "asc": true,
752
+ "nulls": "last"
753
+ }
754
+ ],
755
+ "isUnique": false,
756
+ "where": "\"agent_chat\".\"messages\".\"after_turn\" = 'pending'",
757
+ "concurrently": false,
758
+ "method": "btree",
759
+ "with": {}
760
+ }
761
+ },
762
+ "foreignKeys": {
763
+ "messages_chat_id_chats_id_fk": {
764
+ "name": "messages_chat_id_chats_id_fk",
765
+ "tableFrom": "messages",
766
+ "tableTo": "chats",
767
+ "schemaTo": "agent_chat",
768
+ "columnsFrom": [
769
+ "chat_id"
770
+ ],
771
+ "columnsTo": [
772
+ "id"
773
+ ],
774
+ "onDelete": "cascade",
775
+ "onUpdate": "no action"
776
+ }
777
+ },
778
+ "compositePrimaryKeys": {},
779
+ "uniqueConstraints": {},
780
+ "policies": {},
781
+ "checkConstraints": {},
782
+ "isRLSEnabled": false
783
+ },
784
+ "agent_chat.spending_limit_states": {
785
+ "name": "spending_limit_states",
786
+ "schema": "agent_chat",
787
+ "columns": {
788
+ "key": {
789
+ "name": "key",
790
+ "type": "text",
791
+ "primaryKey": true,
792
+ "notNull": true
793
+ },
794
+ "value": {
795
+ "name": "value",
796
+ "type": "text",
797
+ "primaryKey": false,
798
+ "notNull": true
799
+ },
800
+ "version": {
801
+ "name": "version",
802
+ "type": "integer",
803
+ "primaryKey": false,
804
+ "notNull": true
805
+ },
806
+ "updated_at": {
807
+ "name": "updated_at",
808
+ "type": "text",
809
+ "primaryKey": false,
810
+ "notNull": true
811
+ }
812
+ },
813
+ "indexes": {},
814
+ "foreignKeys": {},
815
+ "compositePrimaryKeys": {},
816
+ "uniqueConstraints": {},
817
+ "policies": {},
818
+ "checkConstraints": {},
819
+ "isRLSEnabled": false
820
+ },
821
+ "agent_chat.usage_records": {
822
+ "name": "usage_records",
823
+ "schema": "agent_chat",
824
+ "columns": {
825
+ "id": {
826
+ "name": "id",
827
+ "type": "text",
828
+ "primaryKey": true,
829
+ "notNull": true
830
+ },
831
+ "owner_id": {
832
+ "name": "owner_id",
833
+ "type": "text",
834
+ "primaryKey": false,
835
+ "notNull": true
836
+ },
837
+ "chat_id": {
838
+ "name": "chat_id",
839
+ "type": "text",
840
+ "primaryKey": false,
841
+ "notNull": true
842
+ },
843
+ "message_id": {
844
+ "name": "message_id",
845
+ "type": "text",
846
+ "primaryKey": false,
847
+ "notNull": false
848
+ },
849
+ "source": {
850
+ "name": "source",
851
+ "type": "text",
852
+ "primaryKey": false,
853
+ "notNull": true
854
+ },
855
+ "model_id": {
856
+ "name": "model_id",
857
+ "type": "text",
858
+ "primaryKey": false,
859
+ "notNull": true
860
+ },
861
+ "provider_id": {
862
+ "name": "provider_id",
863
+ "type": "text",
864
+ "primaryKey": false,
865
+ "notNull": true
866
+ },
867
+ "input_tokens": {
868
+ "name": "input_tokens",
869
+ "type": "bigint",
870
+ "primaryKey": false,
871
+ "notNull": true
872
+ },
873
+ "cached_input_tokens": {
874
+ "name": "cached_input_tokens",
875
+ "type": "bigint",
876
+ "primaryKey": false,
877
+ "notNull": true
878
+ },
879
+ "cache_write_tokens": {
880
+ "name": "cache_write_tokens",
881
+ "type": "bigint",
882
+ "primaryKey": false,
883
+ "notNull": true
884
+ },
885
+ "output_tokens": {
886
+ "name": "output_tokens",
887
+ "type": "bigint",
888
+ "primaryKey": false,
889
+ "notNull": true
890
+ },
891
+ "reasoning_tokens": {
892
+ "name": "reasoning_tokens",
893
+ "type": "bigint",
894
+ "primaryKey": false,
895
+ "notNull": true
896
+ },
897
+ "cost_usd": {
898
+ "name": "cost_usd",
899
+ "type": "double precision",
900
+ "primaryKey": false,
901
+ "notNull": true
902
+ },
903
+ "created_at": {
904
+ "name": "created_at",
905
+ "type": "text",
906
+ "primaryKey": false,
907
+ "notNull": true
908
+ },
909
+ "estimated": {
910
+ "name": "estimated",
911
+ "type": "boolean",
912
+ "primaryKey": false,
913
+ "notNull": true,
914
+ "default": false
915
+ }
916
+ },
917
+ "indexes": {
918
+ "usage_records_owner_created_idx": {
919
+ "name": "usage_records_owner_created_idx",
920
+ "columns": [
921
+ {
922
+ "expression": "owner_id",
923
+ "isExpression": false,
924
+ "asc": true,
925
+ "nulls": "last"
926
+ },
927
+ {
928
+ "expression": "created_at",
929
+ "isExpression": false,
930
+ "asc": true,
931
+ "nulls": "last"
932
+ }
933
+ ],
934
+ "isUnique": false,
935
+ "concurrently": false,
936
+ "method": "btree",
937
+ "with": {}
938
+ },
939
+ "usage_records_chat_created_idx": {
940
+ "name": "usage_records_chat_created_idx",
941
+ "columns": [
942
+ {
943
+ "expression": "chat_id",
944
+ "isExpression": false,
945
+ "asc": true,
946
+ "nulls": "last"
947
+ },
948
+ {
949
+ "expression": "created_at",
950
+ "isExpression": false,
951
+ "asc": true,
952
+ "nulls": "last"
953
+ }
954
+ ],
955
+ "isUnique": false,
956
+ "concurrently": false,
957
+ "method": "btree",
958
+ "with": {}
959
+ }
960
+ },
961
+ "foreignKeys": {},
962
+ "compositePrimaryKeys": {},
963
+ "uniqueConstraints": {},
964
+ "policies": {},
965
+ "checkConstraints": {},
966
+ "isRLSEnabled": false
967
+ },
968
+ "agent_chat.user_model_choices": {
969
+ "name": "user_model_choices",
970
+ "schema": "agent_chat",
971
+ "columns": {
972
+ "owner_id": {
973
+ "name": "owner_id",
974
+ "type": "text",
975
+ "primaryKey": true,
976
+ "notNull": true
977
+ },
978
+ "model_id": {
979
+ "name": "model_id",
980
+ "type": "text",
981
+ "primaryKey": false,
982
+ "notNull": true
983
+ },
984
+ "provider_id": {
985
+ "name": "provider_id",
986
+ "type": "text",
987
+ "primaryKey": false,
988
+ "notNull": true
989
+ },
990
+ "reasoning": {
991
+ "name": "reasoning",
992
+ "type": "text",
993
+ "primaryKey": false,
994
+ "notNull": false
995
+ },
996
+ "updated_at": {
997
+ "name": "updated_at",
998
+ "type": "text",
999
+ "primaryKey": false,
1000
+ "notNull": true
1001
+ }
1002
+ },
1003
+ "indexes": {},
1004
+ "foreignKeys": {},
1005
+ "compositePrimaryKeys": {},
1006
+ "uniqueConstraints": {},
1007
+ "policies": {},
1008
+ "checkConstraints": {},
1009
+ "isRLSEnabled": false
1010
+ },
1011
+ "agent_chat.voice_choices": {
1012
+ "name": "voice_choices",
1013
+ "schema": "agent_chat",
1014
+ "columns": {
1015
+ "owner_id": {
1016
+ "name": "owner_id",
1017
+ "type": "text",
1018
+ "primaryKey": true,
1019
+ "notNull": true
1020
+ },
1021
+ "voice_id": {
1022
+ "name": "voice_id",
1023
+ "type": "text",
1024
+ "primaryKey": false,
1025
+ "notNull": true
1026
+ },
1027
+ "updated_at": {
1028
+ "name": "updated_at",
1029
+ "type": "text",
1030
+ "primaryKey": false,
1031
+ "notNull": true
1032
+ }
1033
+ },
1034
+ "indexes": {},
1035
+ "foreignKeys": {},
1036
+ "compositePrimaryKeys": {},
1037
+ "uniqueConstraints": {},
1038
+ "policies": {},
1039
+ "checkConstraints": {},
1040
+ "isRLSEnabled": false
1041
+ }
1042
+ },
1043
+ "enums": {},
1044
+ "schemas": {
1045
+ "agent_chat": "agent_chat"
1046
+ },
1047
+ "sequences": {},
1048
+ "roles": {},
1049
+ "policies": {},
1050
+ "views": {},
1051
+ "_meta": {
1052
+ "columns": {},
1053
+ "schemas": {},
1054
+ "tables": {}
1055
+ }
1056
+ }