@ykurilov/agent-chat-storage-sqlite 0.0.0-stage → 0.55.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/CHANGELOG.md +1293 -0
- package/LICENSE +21 -0
- package/README.md +33 -2
- package/dist/index.js +817 -0
- package/dist/index.js.map +1 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/schema.d.ts +1797 -0
- package/dist/types/sqlite-storage.d.ts +15 -0
- package/drizzle/0000_init.sql +29 -0
- package/drizzle/0001_message_seq.sql +5 -0
- package/drizzle/0002_chat_reasoning.sql +1 -0
- package/drizzle/0003_compactions.sql +17 -0
- package/drizzle/0004_branch_selections.sql +11 -0
- package/drizzle/0005_chat_title.sql +22 -0
- package/drizzle/0006_usage_records.sql +19 -0
- package/drizzle/0007_user_model_choices.sql +7 -0
- package/drizzle/0008_voice_dialog.sql +7 -0
- package/drizzle/0009_memory_notes.sql +11 -0
- package/drizzle/0010_memory_optimization.sql +15 -0
- package/drizzle/0011_usage_estimated.sql +1 -0
- package/drizzle/0012_message_alive_at.sql +1 -0
- package/drizzle/0013_spending_limit_states.sql +6 -0
- package/drizzle/0014_chat_origin.sql +1 -0
- package/drizzle/0015_chat_subject_after_turn.sql +5 -0
- package/drizzle/0016_chat_closed.sql +1 -0
- package/drizzle/0017_chat_turn_leases.sql +5 -0
- package/drizzle/meta/0000_snapshot.json +211 -0
- package/drizzle/meta/0001_snapshot.json +227 -0
- package/drizzle/meta/0002_snapshot.json +234 -0
- package/drizzle/meta/0003_snapshot.json +352 -0
- package/drizzle/meta/0004_snapshot.json +428 -0
- package/drizzle/meta/0005_snapshot.json +435 -0
- package/drizzle/meta/0006_snapshot.json +560 -0
- package/drizzle/meta/0007_snapshot.json +605 -0
- package/drizzle/meta/0008_snapshot.json +643 -0
- package/drizzle/meta/0009_snapshot.json +712 -0
- package/drizzle/meta/0010_snapshot.json +810 -0
- package/drizzle/meta/0011_snapshot.json +818 -0
- package/drizzle/meta/0012_snapshot.json +825 -0
- package/drizzle/meta/0013_snapshot.json +863 -0
- package/drizzle/meta/0014_snapshot.json +870 -0
- package/drizzle/meta/0015_snapshot.json +907 -0
- package/drizzle/meta/0016_snapshot.json +914 -0
- package/drizzle/meta/0017_snapshot.json +945 -0
- package/drizzle/meta/_journal.json +132 -0
- package/package.json +44 -3
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ChatStorage } from "@ykurilov/agent-chat-core";
|
|
2
|
+
export interface SqliteChatStorage extends ChatStorage {
|
|
3
|
+
/** Закрывает файл базы. */
|
|
4
|
+
close(): void;
|
|
5
|
+
}
|
|
6
|
+
/** В файле таблицы `chats` или `messages` создал не SDK: открывать такой файл нельзя, миграции испортили бы чужие данные. */
|
|
7
|
+
export declare class ForeignChatTablesError extends Error {
|
|
8
|
+
readonly filePath: string;
|
|
9
|
+
readonly tables: readonly string[];
|
|
10
|
+
constructor(filePath: string, tables: readonly string[]);
|
|
11
|
+
}
|
|
12
|
+
/** Хранилище в файле SQLite. Схема приводится к последней миграции при открытии. */
|
|
13
|
+
export declare function createSqliteChatStorage(options: {
|
|
14
|
+
filePath: string;
|
|
15
|
+
}): SqliteChatStorage;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
CREATE TABLE `chats` (
|
|
2
|
+
`id` text PRIMARY KEY NOT NULL,
|
|
3
|
+
`owner_id` text NOT NULL,
|
|
4
|
+
`model_id` text NOT NULL,
|
|
5
|
+
`provider_id` text NOT NULL,
|
|
6
|
+
`created_at` text NOT NULL,
|
|
7
|
+
`updated_at` text NOT NULL
|
|
8
|
+
);
|
|
9
|
+
--> statement-breakpoint
|
|
10
|
+
CREATE INDEX `chats_owner_updated_idx` ON `chats` (`owner_id`,`updated_at`);--> statement-breakpoint
|
|
11
|
+
CREATE TABLE `messages` (
|
|
12
|
+
`id` text PRIMARY KEY NOT NULL,
|
|
13
|
+
`chat_id` text NOT NULL,
|
|
14
|
+
`parent_id` text,
|
|
15
|
+
`role` text NOT NULL,
|
|
16
|
+
`parts` text NOT NULL,
|
|
17
|
+
`format_version` integer NOT NULL,
|
|
18
|
+
`status` text NOT NULL,
|
|
19
|
+
`model_id` text,
|
|
20
|
+
`provider_id` text,
|
|
21
|
+
`usage` text,
|
|
22
|
+
`reasoning_durations_ms` text NOT NULL,
|
|
23
|
+
`error` text,
|
|
24
|
+
`created_at` text NOT NULL,
|
|
25
|
+
FOREIGN KEY (`chat_id`) REFERENCES `chats`(`id`) ON UPDATE no action ON DELETE cascade
|
|
26
|
+
);
|
|
27
|
+
--> statement-breakpoint
|
|
28
|
+
CREATE INDEX `messages_chat_created_idx` ON `messages` (`chat_id`,`created_at`);--> statement-breakpoint
|
|
29
|
+
CREATE INDEX `messages_streaming_idx` ON `messages` (`status`) WHERE "messages"."status" = 'streaming';
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
ALTER TABLE `messages` ADD `seq` integer DEFAULT 0 NOT NULL;--> statement-breakpoint
|
|
2
|
+
UPDATE `messages` SET `seq` = `rowid`;--> statement-breakpoint
|
|
3
|
+
DROP INDEX `messages_chat_created_idx`;--> statement-breakpoint
|
|
4
|
+
CREATE UNIQUE INDEX `messages_seq_idx` ON `messages` (`seq`);--> statement-breakpoint
|
|
5
|
+
CREATE INDEX `messages_chat_created_idx` ON `messages` (`chat_id`,`created_at`,`seq`);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
ALTER TABLE `chats` ADD `reasoning` text;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
CREATE TABLE `compactions` (
|
|
2
|
+
`id` text PRIMARY KEY NOT NULL,
|
|
3
|
+
`chat_id` text NOT NULL,
|
|
4
|
+
`from_message_id` text NOT NULL,
|
|
5
|
+
`through_message_id` text NOT NULL,
|
|
6
|
+
`summary` text NOT NULL,
|
|
7
|
+
`summary_tokens` integer NOT NULL,
|
|
8
|
+
`model_id` text NOT NULL,
|
|
9
|
+
`provider_id` text NOT NULL,
|
|
10
|
+
`usage` text,
|
|
11
|
+
`created_at` text NOT NULL,
|
|
12
|
+
`seq` integer DEFAULT 0 NOT NULL,
|
|
13
|
+
FOREIGN KEY (`chat_id`) REFERENCES `chats`(`id`) ON UPDATE no action ON DELETE cascade
|
|
14
|
+
);
|
|
15
|
+
--> statement-breakpoint
|
|
16
|
+
CREATE INDEX `compactions_chat_seq_idx` ON `compactions` (`chat_id`,`seq`);--> statement-breakpoint
|
|
17
|
+
CREATE UNIQUE INDEX `compactions_seq_idx` ON `compactions` (`seq`);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
CREATE TABLE `branch_selections` (
|
|
2
|
+
`id` text PRIMARY KEY NOT NULL,
|
|
3
|
+
`chat_id` text NOT NULL,
|
|
4
|
+
`message_id` text NOT NULL,
|
|
5
|
+
`selected_at` text NOT NULL,
|
|
6
|
+
`seq` integer DEFAULT 0 NOT NULL,
|
|
7
|
+
FOREIGN KEY (`chat_id`) REFERENCES `chats`(`id`) ON UPDATE no action ON DELETE cascade
|
|
8
|
+
);
|
|
9
|
+
--> statement-breakpoint
|
|
10
|
+
CREATE INDEX `branch_selections_chat_seq_idx` ON `branch_selections` (`chat_id`,`seq`);--> statement-breakpoint
|
|
11
|
+
CREATE UNIQUE INDEX `branch_selections_seq_idx` ON `branch_selections` (`seq`);
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
ALTER TABLE `chats` ADD `title` text;--> statement-breakpoint
|
|
2
|
+
-- Названия у прежних чатов: из первого текста первого сообщения собеседника, как это делает ядро
|
|
3
|
+
-- (пробелы схлопнуты, не длиннее 60 знаков и «…»). Очень длинные ряды пробелов (больше 64) схлопываются не до конца.
|
|
4
|
+
UPDATE `chats` SET `title` = (
|
|
5
|
+
SELECT CASE
|
|
6
|
+
WHEN length(t) = 0 THEN NULL
|
|
7
|
+
WHEN length(t) > 60 THEN rtrim(substr(t, 1, 60)) || '…'
|
|
8
|
+
ELSE t
|
|
9
|
+
END
|
|
10
|
+
FROM (
|
|
11
|
+
SELECT trim(replace(replace(replace(replace(replace(replace(replace(replace(replace(x, char(13), ' '), char(10), ' '), char(9), ' '), ' ', ' '), ' ', ' '), ' ', ' '), ' ', ' '), ' ', ' '), ' ', ' ')) AS t
|
|
12
|
+
FROM (
|
|
13
|
+
SELECT (
|
|
14
|
+
SELECT json_extract(p.value, '$.text') FROM json_each(m.parts) AS p
|
|
15
|
+
WHERE json_extract(p.value, '$.type') = 'text' LIMIT 1
|
|
16
|
+
) AS x
|
|
17
|
+
FROM `messages` AS m
|
|
18
|
+
WHERE m.chat_id = `chats`.id AND m.role = 'user'
|
|
19
|
+
ORDER BY m.created_at, m.seq LIMIT 1
|
|
20
|
+
)
|
|
21
|
+
)
|
|
22
|
+
);
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
CREATE TABLE `usage_records` (
|
|
2
|
+
`id` text PRIMARY KEY NOT NULL,
|
|
3
|
+
`owner_id` text NOT NULL,
|
|
4
|
+
`chat_id` text NOT NULL,
|
|
5
|
+
`message_id` text,
|
|
6
|
+
`source` text NOT NULL,
|
|
7
|
+
`model_id` text NOT NULL,
|
|
8
|
+
`provider_id` text NOT NULL,
|
|
9
|
+
`input_tokens` integer NOT NULL,
|
|
10
|
+
`cached_input_tokens` integer NOT NULL,
|
|
11
|
+
`cache_write_tokens` integer NOT NULL,
|
|
12
|
+
`output_tokens` integer NOT NULL,
|
|
13
|
+
`reasoning_tokens` integer NOT NULL,
|
|
14
|
+
`cost_usd` real NOT NULL,
|
|
15
|
+
`created_at` text NOT NULL
|
|
16
|
+
);
|
|
17
|
+
--> statement-breakpoint
|
|
18
|
+
CREATE INDEX `usage_records_owner_created_idx` ON `usage_records` (`owner_id`,`created_at`);--> statement-breakpoint
|
|
19
|
+
CREATE INDEX `usage_records_chat_created_idx` ON `usage_records` (`chat_id`,`created_at`);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
CREATE TABLE `memory_notes` (
|
|
2
|
+
`id` text PRIMARY KEY NOT NULL,
|
|
3
|
+
`owner_id` text NOT NULL,
|
|
4
|
+
`categories` text NOT NULL,
|
|
5
|
+
`content` text NOT NULL,
|
|
6
|
+
`version` integer DEFAULT 1 NOT NULL,
|
|
7
|
+
`created_at` integer NOT NULL,
|
|
8
|
+
`updated_at` integer NOT NULL
|
|
9
|
+
);
|
|
10
|
+
--> statement-breakpoint
|
|
11
|
+
CREATE INDEX `memory_notes_owner_updated_idx` ON `memory_notes` (`owner_id`,`updated_at`);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
CREATE TABLE `memory_optimization_runs` (
|
|
2
|
+
`id` text PRIMARY KEY NOT NULL,
|
|
3
|
+
`owner_id` text NOT NULL,
|
|
4
|
+
`started_at` integer NOT NULL,
|
|
5
|
+
`finished_at` integer,
|
|
6
|
+
`status` text NOT NULL,
|
|
7
|
+
`groups` text DEFAULT '[]' NOT NULL,
|
|
8
|
+
`error` text,
|
|
9
|
+
`usage_record_id` text
|
|
10
|
+
);
|
|
11
|
+
--> statement-breakpoint
|
|
12
|
+
CREATE INDEX `memory_optimization_runs_owner_started_idx` ON `memory_optimization_runs` (`owner_id`,`started_at`);--> statement-breakpoint
|
|
13
|
+
CREATE UNIQUE INDEX `memory_optimization_runs_one_running_idx` ON `memory_optimization_runs` (`owner_id`) WHERE "memory_optimization_runs"."status" = 'running';--> statement-breakpoint
|
|
14
|
+
ALTER TABLE `memory_notes` ADD `merged_into` text;--> statement-breakpoint
|
|
15
|
+
CREATE INDEX `memory_notes_merged_into_idx` ON `memory_notes` (`merged_into`);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
ALTER TABLE `usage_records` ADD `estimated` integer DEFAULT false NOT NULL;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
ALTER TABLE `messages` ADD `alive_at` text;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
ALTER TABLE `chats` ADD `origin` text;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
ALTER TABLE `chats` ADD `subject_key` text;--> statement-breakpoint
|
|
2
|
+
ALTER TABLE `chats` ADD `subject_data` text;--> statement-breakpoint
|
|
3
|
+
CREATE UNIQUE INDEX `chats_owner_subject_idx` ON `chats` (`owner_id`,`subject_key`);--> statement-breakpoint
|
|
4
|
+
ALTER TABLE `messages` ADD `after_turn` text;--> statement-breakpoint
|
|
5
|
+
CREATE INDEX `messages_after_turn_pending_idx` ON `messages` (`after_turn`) WHERE "messages"."after_turn" = 'pending';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
ALTER TABLE `chats` ADD `closed` text;
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": "6",
|
|
3
|
+
"dialect": "sqlite",
|
|
4
|
+
"id": "f2d80f29-e609-42a0-a0f1-ad7a9340ce70",
|
|
5
|
+
"prevId": "00000000-0000-0000-0000-000000000000",
|
|
6
|
+
"tables": {
|
|
7
|
+
"chats": {
|
|
8
|
+
"name": "chats",
|
|
9
|
+
"columns": {
|
|
10
|
+
"id": {
|
|
11
|
+
"name": "id",
|
|
12
|
+
"type": "text",
|
|
13
|
+
"primaryKey": true,
|
|
14
|
+
"notNull": true,
|
|
15
|
+
"autoincrement": false
|
|
16
|
+
},
|
|
17
|
+
"owner_id": {
|
|
18
|
+
"name": "owner_id",
|
|
19
|
+
"type": "text",
|
|
20
|
+
"primaryKey": false,
|
|
21
|
+
"notNull": true,
|
|
22
|
+
"autoincrement": false
|
|
23
|
+
},
|
|
24
|
+
"model_id": {
|
|
25
|
+
"name": "model_id",
|
|
26
|
+
"type": "text",
|
|
27
|
+
"primaryKey": false,
|
|
28
|
+
"notNull": true,
|
|
29
|
+
"autoincrement": false
|
|
30
|
+
},
|
|
31
|
+
"provider_id": {
|
|
32
|
+
"name": "provider_id",
|
|
33
|
+
"type": "text",
|
|
34
|
+
"primaryKey": false,
|
|
35
|
+
"notNull": true,
|
|
36
|
+
"autoincrement": false
|
|
37
|
+
},
|
|
38
|
+
"created_at": {
|
|
39
|
+
"name": "created_at",
|
|
40
|
+
"type": "text",
|
|
41
|
+
"primaryKey": false,
|
|
42
|
+
"notNull": true,
|
|
43
|
+
"autoincrement": false
|
|
44
|
+
},
|
|
45
|
+
"updated_at": {
|
|
46
|
+
"name": "updated_at",
|
|
47
|
+
"type": "text",
|
|
48
|
+
"primaryKey": false,
|
|
49
|
+
"notNull": true,
|
|
50
|
+
"autoincrement": false
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
"indexes": {
|
|
54
|
+
"chats_owner_updated_idx": {
|
|
55
|
+
"name": "chats_owner_updated_idx",
|
|
56
|
+
"columns": [
|
|
57
|
+
"owner_id",
|
|
58
|
+
"updated_at"
|
|
59
|
+
],
|
|
60
|
+
"isUnique": false
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
"foreignKeys": {},
|
|
64
|
+
"compositePrimaryKeys": {},
|
|
65
|
+
"uniqueConstraints": {},
|
|
66
|
+
"checkConstraints": {}
|
|
67
|
+
},
|
|
68
|
+
"messages": {
|
|
69
|
+
"name": "messages",
|
|
70
|
+
"columns": {
|
|
71
|
+
"id": {
|
|
72
|
+
"name": "id",
|
|
73
|
+
"type": "text",
|
|
74
|
+
"primaryKey": true,
|
|
75
|
+
"notNull": true,
|
|
76
|
+
"autoincrement": false
|
|
77
|
+
},
|
|
78
|
+
"chat_id": {
|
|
79
|
+
"name": "chat_id",
|
|
80
|
+
"type": "text",
|
|
81
|
+
"primaryKey": false,
|
|
82
|
+
"notNull": true,
|
|
83
|
+
"autoincrement": false
|
|
84
|
+
},
|
|
85
|
+
"parent_id": {
|
|
86
|
+
"name": "parent_id",
|
|
87
|
+
"type": "text",
|
|
88
|
+
"primaryKey": false,
|
|
89
|
+
"notNull": false,
|
|
90
|
+
"autoincrement": false
|
|
91
|
+
},
|
|
92
|
+
"role": {
|
|
93
|
+
"name": "role",
|
|
94
|
+
"type": "text",
|
|
95
|
+
"primaryKey": false,
|
|
96
|
+
"notNull": true,
|
|
97
|
+
"autoincrement": false
|
|
98
|
+
},
|
|
99
|
+
"parts": {
|
|
100
|
+
"name": "parts",
|
|
101
|
+
"type": "text",
|
|
102
|
+
"primaryKey": false,
|
|
103
|
+
"notNull": true,
|
|
104
|
+
"autoincrement": false
|
|
105
|
+
},
|
|
106
|
+
"format_version": {
|
|
107
|
+
"name": "format_version",
|
|
108
|
+
"type": "integer",
|
|
109
|
+
"primaryKey": false,
|
|
110
|
+
"notNull": true,
|
|
111
|
+
"autoincrement": false
|
|
112
|
+
},
|
|
113
|
+
"status": {
|
|
114
|
+
"name": "status",
|
|
115
|
+
"type": "text",
|
|
116
|
+
"primaryKey": false,
|
|
117
|
+
"notNull": true,
|
|
118
|
+
"autoincrement": false
|
|
119
|
+
},
|
|
120
|
+
"model_id": {
|
|
121
|
+
"name": "model_id",
|
|
122
|
+
"type": "text",
|
|
123
|
+
"primaryKey": false,
|
|
124
|
+
"notNull": false,
|
|
125
|
+
"autoincrement": false
|
|
126
|
+
},
|
|
127
|
+
"provider_id": {
|
|
128
|
+
"name": "provider_id",
|
|
129
|
+
"type": "text",
|
|
130
|
+
"primaryKey": false,
|
|
131
|
+
"notNull": false,
|
|
132
|
+
"autoincrement": false
|
|
133
|
+
},
|
|
134
|
+
"usage": {
|
|
135
|
+
"name": "usage",
|
|
136
|
+
"type": "text",
|
|
137
|
+
"primaryKey": false,
|
|
138
|
+
"notNull": false,
|
|
139
|
+
"autoincrement": false
|
|
140
|
+
},
|
|
141
|
+
"reasoning_durations_ms": {
|
|
142
|
+
"name": "reasoning_durations_ms",
|
|
143
|
+
"type": "text",
|
|
144
|
+
"primaryKey": false,
|
|
145
|
+
"notNull": true,
|
|
146
|
+
"autoincrement": false
|
|
147
|
+
},
|
|
148
|
+
"error": {
|
|
149
|
+
"name": "error",
|
|
150
|
+
"type": "text",
|
|
151
|
+
"primaryKey": false,
|
|
152
|
+
"notNull": false,
|
|
153
|
+
"autoincrement": false
|
|
154
|
+
},
|
|
155
|
+
"created_at": {
|
|
156
|
+
"name": "created_at",
|
|
157
|
+
"type": "text",
|
|
158
|
+
"primaryKey": false,
|
|
159
|
+
"notNull": true,
|
|
160
|
+
"autoincrement": false
|
|
161
|
+
}
|
|
162
|
+
},
|
|
163
|
+
"indexes": {
|
|
164
|
+
"messages_chat_created_idx": {
|
|
165
|
+
"name": "messages_chat_created_idx",
|
|
166
|
+
"columns": [
|
|
167
|
+
"chat_id",
|
|
168
|
+
"created_at"
|
|
169
|
+
],
|
|
170
|
+
"isUnique": false
|
|
171
|
+
},
|
|
172
|
+
"messages_streaming_idx": {
|
|
173
|
+
"name": "messages_streaming_idx",
|
|
174
|
+
"columns": [
|
|
175
|
+
"status"
|
|
176
|
+
],
|
|
177
|
+
"isUnique": false,
|
|
178
|
+
"where": "\"messages\".\"status\" = 'streaming'"
|
|
179
|
+
}
|
|
180
|
+
},
|
|
181
|
+
"foreignKeys": {
|
|
182
|
+
"messages_chat_id_chats_id_fk": {
|
|
183
|
+
"name": "messages_chat_id_chats_id_fk",
|
|
184
|
+
"tableFrom": "messages",
|
|
185
|
+
"tableTo": "chats",
|
|
186
|
+
"columnsFrom": [
|
|
187
|
+
"chat_id"
|
|
188
|
+
],
|
|
189
|
+
"columnsTo": [
|
|
190
|
+
"id"
|
|
191
|
+
],
|
|
192
|
+
"onDelete": "cascade",
|
|
193
|
+
"onUpdate": "no action"
|
|
194
|
+
}
|
|
195
|
+
},
|
|
196
|
+
"compositePrimaryKeys": {},
|
|
197
|
+
"uniqueConstraints": {},
|
|
198
|
+
"checkConstraints": {}
|
|
199
|
+
}
|
|
200
|
+
},
|
|
201
|
+
"views": {},
|
|
202
|
+
"enums": {},
|
|
203
|
+
"_meta": {
|
|
204
|
+
"schemas": {},
|
|
205
|
+
"tables": {},
|
|
206
|
+
"columns": {}
|
|
207
|
+
},
|
|
208
|
+
"internal": {
|
|
209
|
+
"indexes": {}
|
|
210
|
+
}
|
|
211
|
+
}
|
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": "6",
|
|
3
|
+
"dialect": "sqlite",
|
|
4
|
+
"id": "69158484-74d3-4857-a2b0-782512dadeb1",
|
|
5
|
+
"prevId": "f2d80f29-e609-42a0-a0f1-ad7a9340ce70",
|
|
6
|
+
"tables": {
|
|
7
|
+
"chats": {
|
|
8
|
+
"name": "chats",
|
|
9
|
+
"columns": {
|
|
10
|
+
"id": {
|
|
11
|
+
"name": "id",
|
|
12
|
+
"type": "text",
|
|
13
|
+
"primaryKey": true,
|
|
14
|
+
"notNull": true,
|
|
15
|
+
"autoincrement": false
|
|
16
|
+
},
|
|
17
|
+
"owner_id": {
|
|
18
|
+
"name": "owner_id",
|
|
19
|
+
"type": "text",
|
|
20
|
+
"primaryKey": false,
|
|
21
|
+
"notNull": true,
|
|
22
|
+
"autoincrement": false
|
|
23
|
+
},
|
|
24
|
+
"model_id": {
|
|
25
|
+
"name": "model_id",
|
|
26
|
+
"type": "text",
|
|
27
|
+
"primaryKey": false,
|
|
28
|
+
"notNull": true,
|
|
29
|
+
"autoincrement": false
|
|
30
|
+
},
|
|
31
|
+
"provider_id": {
|
|
32
|
+
"name": "provider_id",
|
|
33
|
+
"type": "text",
|
|
34
|
+
"primaryKey": false,
|
|
35
|
+
"notNull": true,
|
|
36
|
+
"autoincrement": false
|
|
37
|
+
},
|
|
38
|
+
"created_at": {
|
|
39
|
+
"name": "created_at",
|
|
40
|
+
"type": "text",
|
|
41
|
+
"primaryKey": false,
|
|
42
|
+
"notNull": true,
|
|
43
|
+
"autoincrement": false
|
|
44
|
+
},
|
|
45
|
+
"updated_at": {
|
|
46
|
+
"name": "updated_at",
|
|
47
|
+
"type": "text",
|
|
48
|
+
"primaryKey": false,
|
|
49
|
+
"notNull": true,
|
|
50
|
+
"autoincrement": false
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
"indexes": {
|
|
54
|
+
"chats_owner_updated_idx": {
|
|
55
|
+
"name": "chats_owner_updated_idx",
|
|
56
|
+
"columns": [
|
|
57
|
+
"owner_id",
|
|
58
|
+
"updated_at"
|
|
59
|
+
],
|
|
60
|
+
"isUnique": false
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
"foreignKeys": {},
|
|
64
|
+
"compositePrimaryKeys": {},
|
|
65
|
+
"uniqueConstraints": {},
|
|
66
|
+
"checkConstraints": {}
|
|
67
|
+
},
|
|
68
|
+
"messages": {
|
|
69
|
+
"name": "messages",
|
|
70
|
+
"columns": {
|
|
71
|
+
"id": {
|
|
72
|
+
"name": "id",
|
|
73
|
+
"type": "text",
|
|
74
|
+
"primaryKey": true,
|
|
75
|
+
"notNull": true,
|
|
76
|
+
"autoincrement": false
|
|
77
|
+
},
|
|
78
|
+
"chat_id": {
|
|
79
|
+
"name": "chat_id",
|
|
80
|
+
"type": "text",
|
|
81
|
+
"primaryKey": false,
|
|
82
|
+
"notNull": true,
|
|
83
|
+
"autoincrement": false
|
|
84
|
+
},
|
|
85
|
+
"parent_id": {
|
|
86
|
+
"name": "parent_id",
|
|
87
|
+
"type": "text",
|
|
88
|
+
"primaryKey": false,
|
|
89
|
+
"notNull": false,
|
|
90
|
+
"autoincrement": false
|
|
91
|
+
},
|
|
92
|
+
"role": {
|
|
93
|
+
"name": "role",
|
|
94
|
+
"type": "text",
|
|
95
|
+
"primaryKey": false,
|
|
96
|
+
"notNull": true,
|
|
97
|
+
"autoincrement": false
|
|
98
|
+
},
|
|
99
|
+
"parts": {
|
|
100
|
+
"name": "parts",
|
|
101
|
+
"type": "text",
|
|
102
|
+
"primaryKey": false,
|
|
103
|
+
"notNull": true,
|
|
104
|
+
"autoincrement": false
|
|
105
|
+
},
|
|
106
|
+
"format_version": {
|
|
107
|
+
"name": "format_version",
|
|
108
|
+
"type": "integer",
|
|
109
|
+
"primaryKey": false,
|
|
110
|
+
"notNull": true,
|
|
111
|
+
"autoincrement": false
|
|
112
|
+
},
|
|
113
|
+
"status": {
|
|
114
|
+
"name": "status",
|
|
115
|
+
"type": "text",
|
|
116
|
+
"primaryKey": false,
|
|
117
|
+
"notNull": true,
|
|
118
|
+
"autoincrement": false
|
|
119
|
+
},
|
|
120
|
+
"model_id": {
|
|
121
|
+
"name": "model_id",
|
|
122
|
+
"type": "text",
|
|
123
|
+
"primaryKey": false,
|
|
124
|
+
"notNull": false,
|
|
125
|
+
"autoincrement": false
|
|
126
|
+
},
|
|
127
|
+
"provider_id": {
|
|
128
|
+
"name": "provider_id",
|
|
129
|
+
"type": "text",
|
|
130
|
+
"primaryKey": false,
|
|
131
|
+
"notNull": false,
|
|
132
|
+
"autoincrement": false
|
|
133
|
+
},
|
|
134
|
+
"usage": {
|
|
135
|
+
"name": "usage",
|
|
136
|
+
"type": "text",
|
|
137
|
+
"primaryKey": false,
|
|
138
|
+
"notNull": false,
|
|
139
|
+
"autoincrement": false
|
|
140
|
+
},
|
|
141
|
+
"reasoning_durations_ms": {
|
|
142
|
+
"name": "reasoning_durations_ms",
|
|
143
|
+
"type": "text",
|
|
144
|
+
"primaryKey": false,
|
|
145
|
+
"notNull": true,
|
|
146
|
+
"autoincrement": false
|
|
147
|
+
},
|
|
148
|
+
"error": {
|
|
149
|
+
"name": "error",
|
|
150
|
+
"type": "text",
|
|
151
|
+
"primaryKey": false,
|
|
152
|
+
"notNull": false,
|
|
153
|
+
"autoincrement": false
|
|
154
|
+
},
|
|
155
|
+
"created_at": {
|
|
156
|
+
"name": "created_at",
|
|
157
|
+
"type": "text",
|
|
158
|
+
"primaryKey": false,
|
|
159
|
+
"notNull": true,
|
|
160
|
+
"autoincrement": false
|
|
161
|
+
},
|
|
162
|
+
"seq": {
|
|
163
|
+
"name": "seq",
|
|
164
|
+
"type": "integer",
|
|
165
|
+
"primaryKey": false,
|
|
166
|
+
"notNull": true,
|
|
167
|
+
"autoincrement": false,
|
|
168
|
+
"default": 0
|
|
169
|
+
}
|
|
170
|
+
},
|
|
171
|
+
"indexes": {
|
|
172
|
+
"messages_chat_created_idx": {
|
|
173
|
+
"name": "messages_chat_created_idx",
|
|
174
|
+
"columns": [
|
|
175
|
+
"chat_id",
|
|
176
|
+
"created_at",
|
|
177
|
+
"seq"
|
|
178
|
+
],
|
|
179
|
+
"isUnique": false
|
|
180
|
+
},
|
|
181
|
+
"messages_seq_idx": {
|
|
182
|
+
"name": "messages_seq_idx",
|
|
183
|
+
"columns": [
|
|
184
|
+
"seq"
|
|
185
|
+
],
|
|
186
|
+
"isUnique": true
|
|
187
|
+
},
|
|
188
|
+
"messages_streaming_idx": {
|
|
189
|
+
"name": "messages_streaming_idx",
|
|
190
|
+
"columns": [
|
|
191
|
+
"status"
|
|
192
|
+
],
|
|
193
|
+
"isUnique": false,
|
|
194
|
+
"where": "\"messages\".\"status\" = 'streaming'"
|
|
195
|
+
}
|
|
196
|
+
},
|
|
197
|
+
"foreignKeys": {
|
|
198
|
+
"messages_chat_id_chats_id_fk": {
|
|
199
|
+
"name": "messages_chat_id_chats_id_fk",
|
|
200
|
+
"tableFrom": "messages",
|
|
201
|
+
"tableTo": "chats",
|
|
202
|
+
"columnsFrom": [
|
|
203
|
+
"chat_id"
|
|
204
|
+
],
|
|
205
|
+
"columnsTo": [
|
|
206
|
+
"id"
|
|
207
|
+
],
|
|
208
|
+
"onDelete": "cascade",
|
|
209
|
+
"onUpdate": "no action"
|
|
210
|
+
}
|
|
211
|
+
},
|
|
212
|
+
"compositePrimaryKeys": {},
|
|
213
|
+
"uniqueConstraints": {},
|
|
214
|
+
"checkConstraints": {}
|
|
215
|
+
}
|
|
216
|
+
},
|
|
217
|
+
"views": {},
|
|
218
|
+
"enums": {},
|
|
219
|
+
"_meta": {
|
|
220
|
+
"schemas": {},
|
|
221
|
+
"tables": {},
|
|
222
|
+
"columns": {}
|
|
223
|
+
},
|
|
224
|
+
"internal": {
|
|
225
|
+
"indexes": {}
|
|
226
|
+
}
|
|
227
|
+
}
|