@agi-cli/database 0.1.138 → 0.1.140

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.
@@ -0,0 +1,13 @@
1
+ CREATE TABLE `shares` (
2
+ `session_id` text PRIMARY KEY NOT NULL,
3
+ `share_id` text NOT NULL,
4
+ `secret` text NOT NULL,
5
+ `url` text NOT NULL,
6
+ `title` text,
7
+ `description` text,
8
+ `created_at` integer NOT NULL,
9
+ `last_synced_at` integer NOT NULL,
10
+ `last_synced_message_id` text NOT NULL
11
+ );
12
+ --> statement-breakpoint
13
+ CREATE UNIQUE INDEX `shares_share_id_unique` ON `shares` (`share_id`);
@@ -0,0 +1,608 @@
1
+ {
2
+ "version": "6",
3
+ "dialect": "sqlite",
4
+ "id": "8142f304-3a05-4eac-96e5-3301e1fe99f1",
5
+ "prevId": "cb773c80-eb96-4a98-9bc5-0df2343dd327",
6
+ "tables": {
7
+ "artifacts": {
8
+ "name": "artifacts",
9
+ "columns": {
10
+ "id": {
11
+ "name": "id",
12
+ "type": "text",
13
+ "primaryKey": true,
14
+ "notNull": true,
15
+ "autoincrement": false
16
+ },
17
+ "message_part_id": {
18
+ "name": "message_part_id",
19
+ "type": "text",
20
+ "primaryKey": false,
21
+ "notNull": false,
22
+ "autoincrement": false
23
+ },
24
+ "kind": {
25
+ "name": "kind",
26
+ "type": "text",
27
+ "primaryKey": false,
28
+ "notNull": true,
29
+ "autoincrement": false
30
+ },
31
+ "path": {
32
+ "name": "path",
33
+ "type": "text",
34
+ "primaryKey": false,
35
+ "notNull": false,
36
+ "autoincrement": false
37
+ },
38
+ "mime": {
39
+ "name": "mime",
40
+ "type": "text",
41
+ "primaryKey": false,
42
+ "notNull": false,
43
+ "autoincrement": false
44
+ },
45
+ "size": {
46
+ "name": "size",
47
+ "type": "integer",
48
+ "primaryKey": false,
49
+ "notNull": false,
50
+ "autoincrement": false
51
+ },
52
+ "sha256": {
53
+ "name": "sha256",
54
+ "type": "text",
55
+ "primaryKey": false,
56
+ "notNull": false,
57
+ "autoincrement": false
58
+ }
59
+ },
60
+ "indexes": {
61
+ "artifacts_message_part_id_unique": {
62
+ "name": "artifacts_message_part_id_unique",
63
+ "columns": ["message_part_id"],
64
+ "isUnique": true
65
+ }
66
+ },
67
+ "foreignKeys": {
68
+ "artifacts_message_part_id_message_parts_id_fk": {
69
+ "name": "artifacts_message_part_id_message_parts_id_fk",
70
+ "tableFrom": "artifacts",
71
+ "tableTo": "message_parts",
72
+ "columnsFrom": ["message_part_id"],
73
+ "columnsTo": ["id"],
74
+ "onDelete": "cascade",
75
+ "onUpdate": "no action"
76
+ }
77
+ },
78
+ "compositePrimaryKeys": {},
79
+ "uniqueConstraints": {},
80
+ "checkConstraints": {}
81
+ },
82
+ "message_parts": {
83
+ "name": "message_parts",
84
+ "columns": {
85
+ "id": {
86
+ "name": "id",
87
+ "type": "text",
88
+ "primaryKey": true,
89
+ "notNull": true,
90
+ "autoincrement": false
91
+ },
92
+ "message_id": {
93
+ "name": "message_id",
94
+ "type": "text",
95
+ "primaryKey": false,
96
+ "notNull": true,
97
+ "autoincrement": false
98
+ },
99
+ "index": {
100
+ "name": "index",
101
+ "type": "integer",
102
+ "primaryKey": false,
103
+ "notNull": true,
104
+ "autoincrement": false
105
+ },
106
+ "step_index": {
107
+ "name": "step_index",
108
+ "type": "integer",
109
+ "primaryKey": false,
110
+ "notNull": false,
111
+ "autoincrement": false
112
+ },
113
+ "type": {
114
+ "name": "type",
115
+ "type": "text",
116
+ "primaryKey": false,
117
+ "notNull": true,
118
+ "autoincrement": false
119
+ },
120
+ "content": {
121
+ "name": "content",
122
+ "type": "text",
123
+ "primaryKey": false,
124
+ "notNull": true,
125
+ "autoincrement": false
126
+ },
127
+ "agent": {
128
+ "name": "agent",
129
+ "type": "text",
130
+ "primaryKey": false,
131
+ "notNull": true,
132
+ "autoincrement": false
133
+ },
134
+ "provider": {
135
+ "name": "provider",
136
+ "type": "text",
137
+ "primaryKey": false,
138
+ "notNull": true,
139
+ "autoincrement": false
140
+ },
141
+ "model": {
142
+ "name": "model",
143
+ "type": "text",
144
+ "primaryKey": false,
145
+ "notNull": true,
146
+ "autoincrement": false
147
+ },
148
+ "started_at": {
149
+ "name": "started_at",
150
+ "type": "integer",
151
+ "primaryKey": false,
152
+ "notNull": false,
153
+ "autoincrement": false
154
+ },
155
+ "completed_at": {
156
+ "name": "completed_at",
157
+ "type": "integer",
158
+ "primaryKey": false,
159
+ "notNull": false,
160
+ "autoincrement": false
161
+ },
162
+ "compacted_at": {
163
+ "name": "compacted_at",
164
+ "type": "integer",
165
+ "primaryKey": false,
166
+ "notNull": false,
167
+ "autoincrement": false
168
+ },
169
+ "tool_name": {
170
+ "name": "tool_name",
171
+ "type": "text",
172
+ "primaryKey": false,
173
+ "notNull": false,
174
+ "autoincrement": false
175
+ },
176
+ "tool_call_id": {
177
+ "name": "tool_call_id",
178
+ "type": "text",
179
+ "primaryKey": false,
180
+ "notNull": false,
181
+ "autoincrement": false
182
+ },
183
+ "tool_duration_ms": {
184
+ "name": "tool_duration_ms",
185
+ "type": "integer",
186
+ "primaryKey": false,
187
+ "notNull": false,
188
+ "autoincrement": false
189
+ }
190
+ },
191
+ "indexes": {},
192
+ "foreignKeys": {
193
+ "message_parts_message_id_messages_id_fk": {
194
+ "name": "message_parts_message_id_messages_id_fk",
195
+ "tableFrom": "message_parts",
196
+ "tableTo": "messages",
197
+ "columnsFrom": ["message_id"],
198
+ "columnsTo": ["id"],
199
+ "onDelete": "cascade",
200
+ "onUpdate": "no action"
201
+ }
202
+ },
203
+ "compositePrimaryKeys": {},
204
+ "uniqueConstraints": {},
205
+ "checkConstraints": {}
206
+ },
207
+ "messages": {
208
+ "name": "messages",
209
+ "columns": {
210
+ "id": {
211
+ "name": "id",
212
+ "type": "text",
213
+ "primaryKey": true,
214
+ "notNull": true,
215
+ "autoincrement": false
216
+ },
217
+ "session_id": {
218
+ "name": "session_id",
219
+ "type": "text",
220
+ "primaryKey": false,
221
+ "notNull": true,
222
+ "autoincrement": false
223
+ },
224
+ "role": {
225
+ "name": "role",
226
+ "type": "text",
227
+ "primaryKey": false,
228
+ "notNull": true,
229
+ "autoincrement": false
230
+ },
231
+ "status": {
232
+ "name": "status",
233
+ "type": "text",
234
+ "primaryKey": false,
235
+ "notNull": true,
236
+ "autoincrement": false
237
+ },
238
+ "agent": {
239
+ "name": "agent",
240
+ "type": "text",
241
+ "primaryKey": false,
242
+ "notNull": true,
243
+ "autoincrement": false
244
+ },
245
+ "provider": {
246
+ "name": "provider",
247
+ "type": "text",
248
+ "primaryKey": false,
249
+ "notNull": true,
250
+ "autoincrement": false
251
+ },
252
+ "model": {
253
+ "name": "model",
254
+ "type": "text",
255
+ "primaryKey": false,
256
+ "notNull": true,
257
+ "autoincrement": false
258
+ },
259
+ "created_at": {
260
+ "name": "created_at",
261
+ "type": "integer",
262
+ "primaryKey": false,
263
+ "notNull": true,
264
+ "autoincrement": false
265
+ },
266
+ "completed_at": {
267
+ "name": "completed_at",
268
+ "type": "integer",
269
+ "primaryKey": false,
270
+ "notNull": false,
271
+ "autoincrement": false
272
+ },
273
+ "latency_ms": {
274
+ "name": "latency_ms",
275
+ "type": "integer",
276
+ "primaryKey": false,
277
+ "notNull": false,
278
+ "autoincrement": false
279
+ },
280
+ "prompt_tokens": {
281
+ "name": "prompt_tokens",
282
+ "type": "integer",
283
+ "primaryKey": false,
284
+ "notNull": false,
285
+ "autoincrement": false
286
+ },
287
+ "completion_tokens": {
288
+ "name": "completion_tokens",
289
+ "type": "integer",
290
+ "primaryKey": false,
291
+ "notNull": false,
292
+ "autoincrement": false
293
+ },
294
+ "total_tokens": {
295
+ "name": "total_tokens",
296
+ "type": "integer",
297
+ "primaryKey": false,
298
+ "notNull": false,
299
+ "autoincrement": false
300
+ },
301
+ "cached_input_tokens": {
302
+ "name": "cached_input_tokens",
303
+ "type": "integer",
304
+ "primaryKey": false,
305
+ "notNull": false,
306
+ "autoincrement": false
307
+ },
308
+ "cache_creation_input_tokens": {
309
+ "name": "cache_creation_input_tokens",
310
+ "type": "integer",
311
+ "primaryKey": false,
312
+ "notNull": false,
313
+ "autoincrement": false
314
+ },
315
+ "reasoning_tokens": {
316
+ "name": "reasoning_tokens",
317
+ "type": "integer",
318
+ "primaryKey": false,
319
+ "notNull": false,
320
+ "autoincrement": false
321
+ },
322
+ "error": {
323
+ "name": "error",
324
+ "type": "text",
325
+ "primaryKey": false,
326
+ "notNull": false,
327
+ "autoincrement": false
328
+ },
329
+ "error_type": {
330
+ "name": "error_type",
331
+ "type": "text",
332
+ "primaryKey": false,
333
+ "notNull": false,
334
+ "autoincrement": false
335
+ },
336
+ "error_details": {
337
+ "name": "error_details",
338
+ "type": "text",
339
+ "primaryKey": false,
340
+ "notNull": false,
341
+ "autoincrement": false
342
+ },
343
+ "is_aborted": {
344
+ "name": "is_aborted",
345
+ "type": "integer",
346
+ "primaryKey": false,
347
+ "notNull": false,
348
+ "autoincrement": false
349
+ }
350
+ },
351
+ "indexes": {},
352
+ "foreignKeys": {
353
+ "messages_session_id_sessions_id_fk": {
354
+ "name": "messages_session_id_sessions_id_fk",
355
+ "tableFrom": "messages",
356
+ "tableTo": "sessions",
357
+ "columnsFrom": ["session_id"],
358
+ "columnsTo": ["id"],
359
+ "onDelete": "cascade",
360
+ "onUpdate": "no action"
361
+ }
362
+ },
363
+ "compositePrimaryKeys": {},
364
+ "uniqueConstraints": {},
365
+ "checkConstraints": {}
366
+ },
367
+ "sessions": {
368
+ "name": "sessions",
369
+ "columns": {
370
+ "id": {
371
+ "name": "id",
372
+ "type": "text",
373
+ "primaryKey": true,
374
+ "notNull": true,
375
+ "autoincrement": false
376
+ },
377
+ "title": {
378
+ "name": "title",
379
+ "type": "text",
380
+ "primaryKey": false,
381
+ "notNull": false,
382
+ "autoincrement": false
383
+ },
384
+ "agent": {
385
+ "name": "agent",
386
+ "type": "text",
387
+ "primaryKey": false,
388
+ "notNull": true,
389
+ "autoincrement": false
390
+ },
391
+ "provider": {
392
+ "name": "provider",
393
+ "type": "text",
394
+ "primaryKey": false,
395
+ "notNull": true,
396
+ "autoincrement": false
397
+ },
398
+ "model": {
399
+ "name": "model",
400
+ "type": "text",
401
+ "primaryKey": false,
402
+ "notNull": true,
403
+ "autoincrement": false
404
+ },
405
+ "project_path": {
406
+ "name": "project_path",
407
+ "type": "text",
408
+ "primaryKey": false,
409
+ "notNull": true,
410
+ "autoincrement": false
411
+ },
412
+ "created_at": {
413
+ "name": "created_at",
414
+ "type": "integer",
415
+ "primaryKey": false,
416
+ "notNull": true,
417
+ "autoincrement": false
418
+ },
419
+ "last_active_at": {
420
+ "name": "last_active_at",
421
+ "type": "integer",
422
+ "primaryKey": false,
423
+ "notNull": false,
424
+ "autoincrement": false
425
+ },
426
+ "total_input_tokens": {
427
+ "name": "total_input_tokens",
428
+ "type": "integer",
429
+ "primaryKey": false,
430
+ "notNull": false,
431
+ "autoincrement": false
432
+ },
433
+ "total_output_tokens": {
434
+ "name": "total_output_tokens",
435
+ "type": "integer",
436
+ "primaryKey": false,
437
+ "notNull": false,
438
+ "autoincrement": false
439
+ },
440
+ "total_cached_tokens": {
441
+ "name": "total_cached_tokens",
442
+ "type": "integer",
443
+ "primaryKey": false,
444
+ "notNull": false,
445
+ "autoincrement": false
446
+ },
447
+ "total_cache_creation_tokens": {
448
+ "name": "total_cache_creation_tokens",
449
+ "type": "integer",
450
+ "primaryKey": false,
451
+ "notNull": false,
452
+ "autoincrement": false
453
+ },
454
+ "total_reasoning_tokens": {
455
+ "name": "total_reasoning_tokens",
456
+ "type": "integer",
457
+ "primaryKey": false,
458
+ "notNull": false,
459
+ "autoincrement": false
460
+ },
461
+ "total_tool_time_ms": {
462
+ "name": "total_tool_time_ms",
463
+ "type": "integer",
464
+ "primaryKey": false,
465
+ "notNull": false,
466
+ "autoincrement": false
467
+ },
468
+ "tool_counts_json": {
469
+ "name": "tool_counts_json",
470
+ "type": "text",
471
+ "primaryKey": false,
472
+ "notNull": false,
473
+ "autoincrement": false
474
+ },
475
+ "context_summary": {
476
+ "name": "context_summary",
477
+ "type": "text",
478
+ "primaryKey": false,
479
+ "notNull": false,
480
+ "autoincrement": false
481
+ },
482
+ "last_compacted_at": {
483
+ "name": "last_compacted_at",
484
+ "type": "integer",
485
+ "primaryKey": false,
486
+ "notNull": false,
487
+ "autoincrement": false
488
+ },
489
+ "parent_session_id": {
490
+ "name": "parent_session_id",
491
+ "type": "text",
492
+ "primaryKey": false,
493
+ "notNull": false,
494
+ "autoincrement": false
495
+ },
496
+ "branch_point_message_id": {
497
+ "name": "branch_point_message_id",
498
+ "type": "text",
499
+ "primaryKey": false,
500
+ "notNull": false,
501
+ "autoincrement": false
502
+ },
503
+ "session_type": {
504
+ "name": "session_type",
505
+ "type": "text",
506
+ "primaryKey": false,
507
+ "notNull": false,
508
+ "autoincrement": false,
509
+ "default": "'main'"
510
+ }
511
+ },
512
+ "indexes": {},
513
+ "foreignKeys": {},
514
+ "compositePrimaryKeys": {},
515
+ "uniqueConstraints": {},
516
+ "checkConstraints": {}
517
+ },
518
+ "shares": {
519
+ "name": "shares",
520
+ "columns": {
521
+ "session_id": {
522
+ "name": "session_id",
523
+ "type": "text",
524
+ "primaryKey": true,
525
+ "notNull": true,
526
+ "autoincrement": false
527
+ },
528
+ "share_id": {
529
+ "name": "share_id",
530
+ "type": "text",
531
+ "primaryKey": false,
532
+ "notNull": true,
533
+ "autoincrement": false
534
+ },
535
+ "secret": {
536
+ "name": "secret",
537
+ "type": "text",
538
+ "primaryKey": false,
539
+ "notNull": true,
540
+ "autoincrement": false
541
+ },
542
+ "url": {
543
+ "name": "url",
544
+ "type": "text",
545
+ "primaryKey": false,
546
+ "notNull": true,
547
+ "autoincrement": false
548
+ },
549
+ "title": {
550
+ "name": "title",
551
+ "type": "text",
552
+ "primaryKey": false,
553
+ "notNull": false,
554
+ "autoincrement": false
555
+ },
556
+ "description": {
557
+ "name": "description",
558
+ "type": "text",
559
+ "primaryKey": false,
560
+ "notNull": false,
561
+ "autoincrement": false
562
+ },
563
+ "created_at": {
564
+ "name": "created_at",
565
+ "type": "integer",
566
+ "primaryKey": false,
567
+ "notNull": true,
568
+ "autoincrement": false
569
+ },
570
+ "last_synced_at": {
571
+ "name": "last_synced_at",
572
+ "type": "integer",
573
+ "primaryKey": false,
574
+ "notNull": true,
575
+ "autoincrement": false
576
+ },
577
+ "last_synced_message_id": {
578
+ "name": "last_synced_message_id",
579
+ "type": "text",
580
+ "primaryKey": false,
581
+ "notNull": true,
582
+ "autoincrement": false
583
+ }
584
+ },
585
+ "indexes": {
586
+ "shares_share_id_unique": {
587
+ "name": "shares_share_id_unique",
588
+ "columns": ["share_id"],
589
+ "isUnique": true
590
+ }
591
+ },
592
+ "foreignKeys": {},
593
+ "compositePrimaryKeys": {},
594
+ "uniqueConstraints": {},
595
+ "checkConstraints": {}
596
+ }
597
+ },
598
+ "views": {},
599
+ "enums": {},
600
+ "_meta": {
601
+ "schemas": {},
602
+ "tables": {},
603
+ "columns": {}
604
+ },
605
+ "internal": {
606
+ "indexes": {}
607
+ }
608
+ }
@@ -64,6 +64,13 @@
64
64
  "when": 1769321704801,
65
65
  "tag": "0008_chunky_miss_america",
66
66
  "breakpoints": true
67
+ },
68
+ {
69
+ "idx": 9,
70
+ "version": "6",
71
+ "when": 1769408237498,
72
+ "tag": "0009_natural_hellfire_club",
73
+ "breakpoints": true
67
74
  }
68
75
  ]
69
76
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agi-cli/database",
3
- "version": "0.1.138",
3
+ "version": "0.1.140",
4
4
  "description": "Database and persistence layer for AGI CLI",
5
5
  "type": "module",
6
6
  "main": "./src/index.ts",
@@ -22,7 +22,7 @@
22
22
  "typecheck": "tsc --noEmit"
23
23
  },
24
24
  "dependencies": {
25
- "@agi-cli/sdk": "0.1.138",
25
+ "@agi-cli/sdk": "0.1.140",
26
26
  "drizzle-orm": "^0.44.5"
27
27
  },
28
28
  "devDependencies": {
@@ -22,6 +22,9 @@ import mig0007 from '../../drizzle/0007_milky_rhodey.sql' with { type: 'text' };
22
22
  import mig0008 from '../../drizzle/0008_chunky_miss_america.sql' with {
23
23
  type: 'text',
24
24
  };
25
+ import mig0009 from '../../drizzle/0009_natural_hellfire_club.sql' with {
26
+ type: 'text',
27
+ };
25
28
 
26
29
  export const bundledMigrations: Array<{ name: string; content: string }> = [
27
30
  { name: '0000_tense_shadow_king.sql', content: mig0000 },
@@ -33,4 +36,5 @@ export const bundledMigrations: Array<{ name: string; content: string }> = [
33
36
  { name: '0006_jazzy_warlock.sql', content: mig0006 },
34
37
  { name: '0007_milky_rhodey.sql', content: mig0007 },
35
38
  { name: '0008_chunky_miss_america.sql', content: mig0008 },
39
+ { name: '0009_natural_hellfire_club.sql', content: mig0009 },
36
40
  ];
@@ -3,11 +3,13 @@ export { sessions } from './sessions.ts';
3
3
  export { messages } from './messages.ts';
4
4
  export { messageParts } from './message-parts.ts';
5
5
  export { artifacts } from './artifacts.ts';
6
+ export { shares } from './shares.ts';
6
7
 
7
8
  import { sessions } from './sessions.ts';
8
9
  import { messages } from './messages.ts';
9
10
  import { messageParts } from './message-parts.ts';
10
11
  import { artifacts } from './artifacts.ts';
12
+ import { shares } from './shares.ts';
11
13
 
12
14
  export const sessionsRelations = relations(sessions, ({ many }) => ({
13
15
  messages: many(messages),
@@ -34,3 +36,10 @@ export const artifactsRelations = relations(artifacts, ({ one }) => ({
34
36
  references: [messageParts.id],
35
37
  }),
36
38
  }));
39
+
40
+ export const sharesRelations = relations(shares, ({ one }) => ({
41
+ session: one(sessions, {
42
+ fields: [shares.sessionId],
43
+ references: [sessions.id],
44
+ }),
45
+ }));
@@ -15,8 +15,8 @@ export const messages = sqliteTable('messages', {
15
15
  // Metadata
16
16
  completedAt: integer('completed_at', { mode: 'number' }),
17
17
  latencyMs: integer('latency_ms'),
18
- promptTokens: integer('prompt_tokens'),
19
- completionTokens: integer('completion_tokens'),
18
+ inputTokens: integer('prompt_tokens'),
19
+ outputTokens: integer('completion_tokens'),
20
20
  totalTokens: integer('total_tokens'),
21
21
  cachedInputTokens: integer('cached_input_tokens'),
22
22
  cacheCreationInputTokens: integer('cache_creation_input_tokens'),
@@ -0,0 +1,13 @@
1
+ import { sqliteTable, text, integer } from 'drizzle-orm/sqlite-core';
2
+
3
+ export const shares = sqliteTable('shares', {
4
+ sessionId: text('session_id').primaryKey(),
5
+ shareId: text('share_id').notNull().unique(),
6
+ secret: text('secret').notNull(),
7
+ url: text('url').notNull(),
8
+ title: text('title'),
9
+ description: text('description'),
10
+ createdAt: integer('created_at', { mode: 'number' }).notNull(),
11
+ lastSyncedAt: integer('last_synced_at', { mode: 'number' }).notNull(),
12
+ lastSyncedMessageId: text('last_synced_message_id').notNull(),
13
+ });
package/sst-env.d.ts ADDED
@@ -0,0 +1,10 @@
1
+ /* This file is auto-generated by SST. Do not edit. */
2
+ /* tslint:disable */
3
+ /* eslint-disable */
4
+ /* deno-fmt-ignore-file */
5
+ /* biome-ignore-all lint: auto-generated */
6
+
7
+ /// <reference path="../../sst-env.d.ts" />
8
+
9
+ import 'sst';
10
+ export {};