diff --git a/src/db/schema.ts b/src/db/schema.ts index 5b24960..c0b13d9 100644 --- a/src/db/schema.ts +++ b/src/db/schema.ts @@ -168,3 +168,32 @@ export const taskDependenciesRelations = relations(taskDependencies, ({ one }) = export type TaskDependency = InferSelectModel; export type NewTaskDependency = InferInsertModel; + +// ============================================================================ +// AGENTS +// ============================================================================ + +export const agents = sqliteTable('agents', { + id: text('id').primaryKey(), + name: text('name').notNull().unique(), // Human-readable name (e.g., 'gastown', 'chinatown') + taskId: text('task_id').references(() => tasks.id, { onDelete: 'set null' }), // Task may be deleted + sessionId: text('session_id'), // Claude CLI session ID for resumption (null until first run completes) + worktreeId: text('worktree_id').notNull(), // WorktreeManager worktree ID + status: text('status', { + enum: ['idle', 'running', 'waiting_for_input', 'stopped', 'crashed'], + }) + .notNull() + .default('idle'), + createdAt: integer('created_at', { mode: 'timestamp' }).notNull(), + updatedAt: integer('updated_at', { mode: 'timestamp' }).notNull(), +}); + +export const agentsRelations = relations(agents, ({ one }) => ({ + task: one(tasks, { + fields: [agents.taskId], + references: [tasks.id], + }), +})); + +export type Agent = InferSelectModel; +export type NewAgent = InferInsertModel;