@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.
@@ -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>;
@@ -0,0 +1,5 @@
1
+ // Type declarations for .sql file imports (Bun-specific)
2
+ declare module '*.sql' {
3
+ const content: string;
4
+ export default content;
5
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,7 @@
1
+ {
2
+ "extends": "../../tsconfig.base.json",
3
+ "compilerOptions": {
4
+ "outDir": "./dist"
5
+ },
6
+ "include": ["src/**/*"]
7
+ }