src/main/services/agents/README.md
Simplified Drizzle ORM implementation for agent and session management in Cherry Studio.
agents.schema.ts - Agent definitionssessions.schema.ts - Session and message tablesmigrations.schema.ts - Migration trackingimport { agentService } from './services'
// Create agent - fully typed
const agent = await agentService.createAgent({
type: 'custom',
name: 'My Agent',
model: 'anthropic:claude-3-5-sonnet-20241022'
})
provider:model_id format (for example anthropic:claude-3-5-sonnet-20241022).model, plan_model, and small_model are validated against the configured providers before the database is touched.400 invalid_request_error response and the create/update operation is aborted.# Apply schema changes
pnpm agents:generate
# Quick development sync
pnpm agents:push
# Database tools
pnpm agents:studio # Open Drizzle Studio
pnpm agents:health # Health check
pnpm agents:drop # Reset database
/database/schema/pnpm agents:generatepnpm agents:healthAgentService - Agent CRUD operationsSessionService - Session managementSessionMessageService - Message loggingBaseService - Database utilitiesschemaSyncer - Migration handler# Check status
pnpm agents:health
# Apply migrations
pnpm agents:migrate
# Reset completely
pnpm agents:reset --yes
The simplified migration system reduced complexity from 463 to ~30 lines while maintaining all functionality through Drizzle's native migration system.