@agi-cli/database 0.1.55
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/drizzle/.gitkeep +1 -0
- package/drizzle/0000_tense_shadow_king.sql +45 -0
- package/drizzle/0001_past_kabuki.sql +16 -0
- package/drizzle/0002_vengeful_warlock.sql +1 -0
- package/drizzle/0003_pale_violations.sql +3 -0
- package/drizzle/meta/0000_snapshot.json +304 -0
- package/drizzle/meta/0001_snapshot.json +416 -0
- package/drizzle/meta/0002_snapshot.json +423 -0
- package/drizzle/meta/0003_snapshot.json +444 -0
- package/drizzle/meta/_journal.json +34 -0
- package/drizzle.config.ts +14 -0
- package/package.json +33 -0
- package/src/index.ts +75 -0
- package/src/runtime/migrations-bundled.ts +20 -0
- package/src/schema/artifacts.ts +14 -0
- package/src/schema/index.ts +36 -0
- package/src/schema/message-parts.ts +23 -0
- package/src/schema/messages.ts +26 -0
- package/src/schema/sessions.ts +17 -0
- package/src/schema.ts +1 -0
- package/src/types/index.ts +8 -0
- package/src/types/sql-imports.d.ts +5 -0
- package/tsconfig.json +7 -0
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { sqliteTable, text, integer } from 'drizzle-orm/sqlite-core';
|
|
2
|
+
import { sessions } from './sessions.ts';
|
|
3
|
+
|
|
4
|
+
export const messages = sqliteTable('messages', {
|
|
5
|
+
id: text('id').primaryKey(),
|
|
6
|
+
sessionId: text('session_id')
|
|
7
|
+
.notNull()
|
|
8
|
+
.references(() => sessions.id, { onDelete: 'cascade' }),
|
|
9
|
+
role: text('role').notNull(), // 'system' | 'user' | 'assistant' | 'tool'
|
|
10
|
+
status: text('status').notNull(), // 'pending' | 'complete' | 'error'
|
|
11
|
+
agent: text('agent').notNull(),
|
|
12
|
+
provider: text('provider').notNull(),
|
|
13
|
+
model: text('model').notNull(),
|
|
14
|
+
createdAt: integer('created_at', { mode: 'number' }).notNull(),
|
|
15
|
+
// Metadata
|
|
16
|
+
completedAt: integer('completed_at', { mode: 'number' }),
|
|
17
|
+
latencyMs: integer('latency_ms'),
|
|
18
|
+
promptTokens: integer('prompt_tokens'),
|
|
19
|
+
completionTokens: integer('completion_tokens'),
|
|
20
|
+
totalTokens: integer('total_tokens'),
|
|
21
|
+
// Error fields
|
|
22
|
+
error: text('error'),
|
|
23
|
+
errorType: text('error_type'), // 'api_error', 'abort', 'validation_error', etc.
|
|
24
|
+
errorDetails: text('error_details'), // JSON string with full error object
|
|
25
|
+
isAborted: integer('is_aborted', { mode: 'boolean' }), // flag for user aborts
|
|
26
|
+
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { sqliteTable, text, integer } from 'drizzle-orm/sqlite-core';
|
|
2
|
+
|
|
3
|
+
export const sessions = sqliteTable('sessions', {
|
|
4
|
+
id: text('id').primaryKey(),
|
|
5
|
+
title: text('title'),
|
|
6
|
+
agent: text('agent').notNull(),
|
|
7
|
+
provider: text('provider').notNull(),
|
|
8
|
+
model: text('model').notNull(),
|
|
9
|
+
projectPath: text('project_path').notNull(),
|
|
10
|
+
createdAt: integer('created_at', { mode: 'number' }).notNull(),
|
|
11
|
+
// Metadata
|
|
12
|
+
lastActiveAt: integer('last_active_at', { mode: 'number' }),
|
|
13
|
+
totalInputTokens: integer('total_input_tokens'),
|
|
14
|
+
totalOutputTokens: integer('total_output_tokens'),
|
|
15
|
+
totalToolTimeMs: integer('total_tool_time_ms'),
|
|
16
|
+
toolCountsJson: text('tool_counts_json'), // JSON object of name->count
|
|
17
|
+
});
|
package/src/schema.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './schema/index.ts';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { InferSelectModel } from 'drizzle-orm';
|
|
2
|
+
import type { sessions } from '../schema/sessions.ts';
|
|
3
|
+
import type { messages } from '../schema/messages.ts';
|
|
4
|
+
import type { messageParts } from '../schema/message-parts.ts';
|
|
5
|
+
|
|
6
|
+
export type Session = InferSelectModel<typeof sessions>;
|
|
7
|
+
export type Message = InferSelectModel<typeof messages>;
|
|
8
|
+
export type MessagePart = InferSelectModel<typeof messageParts>;
|