feat(#29): implement cron job configuration

- Add CronSchedule model to Prisma schema
- Implement CronService with CRUD operations
- Add REST API endpoints for cron management
- Create MoltBot plugin skill definition (SKILL.md)
- TDD: 9 passing tests for CronService
This commit is contained in:
2026-01-29 23:00:48 -06:00
parent 9de0b2f92f
commit 2e6b7d4070
10 changed files with 562 additions and 56 deletions

View File

@@ -187,6 +187,7 @@ model Workspace {
userLayouts UserLayout[]
knowledgeEntries KnowledgeEntry[]
knowledgeTags KnowledgeTag[]
cronSchedules CronSchedule[]
@@index([ownerId])
@@map("workspaces")
@@ -808,3 +809,31 @@ model KnowledgeEmbedding {
@@index([entryId])
@@map("knowledge_embeddings")
}
// ============================================
// CRON JOBS
// ============================================
model CronSchedule {
id String @id @default(uuid()) @db.Uuid
workspaceId String @map("workspace_id") @db.Uuid
workspace Workspace @relation(fields: [workspaceId], references: [id], onDelete: Cascade)
// Cron configuration
expression String // Standard cron: "0 9 * * *" = 9am daily
command String // MoltBot command to trigger
// State
enabled Boolean @default(true)
lastRun DateTime? @map("last_run") @db.Timestamptz
nextRun DateTime? @map("next_run") @db.Timestamptz
// Audit
createdAt DateTime @default(now()) @map("created_at") @db.Timestamptz
updatedAt DateTime @updatedAt @map("updated_at") @db.Timestamptz
@@index([workspaceId])
@@index([workspaceId, enabled])
@@index([nextRun])
@@map("cron_schedules")
}