✨ feat: implement comprehensive CRUD APIs for agent management with type support
This commit is contained in:
@@ -1,6 +1,13 @@
|
||||
import { Client, createClient } from '@libsql/client'
|
||||
import { loggerService } from '@logger'
|
||||
import type { AgentEntity, AgentSessionEntity, PermissionMode, SessionLogEntity, SessionStatus } from '@types'
|
||||
import type {
|
||||
AgentEntity,
|
||||
AgentSessionEntity,
|
||||
AgentType,
|
||||
PermissionMode,
|
||||
SessionLogEntity,
|
||||
SessionStatus
|
||||
} from '@types'
|
||||
import { app } from 'electron'
|
||||
import path from 'path'
|
||||
|
||||
@@ -9,6 +16,7 @@ import { AgentQueries } from './db'
|
||||
const logger = loggerService.withContext('AgentService')
|
||||
|
||||
export interface CreateAgentRequest {
|
||||
type: AgentType
|
||||
name: string
|
||||
description?: string
|
||||
avatar?: string
|
||||
@@ -201,6 +209,7 @@ export class AgentService {
|
||||
|
||||
const values = [
|
||||
id,
|
||||
serializedData.type,
|
||||
serializedData.name,
|
||||
serializedData.description || null,
|
||||
serializedData.avatar || null,
|
||||
|
||||
@@ -8,6 +8,7 @@ export const AgentQueries = {
|
||||
agents: `
|
||||
CREATE TABLE IF NOT EXISTS agents (
|
||||
id TEXT PRIMARY KEY,
|
||||
type TEXT NOT NULL DEFAULT 'custom', -- 'claudeCode', 'codex', 'custom'
|
||||
name TEXT NOT NULL,
|
||||
description TEXT,
|
||||
avatar TEXT,
|
||||
@@ -72,6 +73,7 @@ export const AgentQueries = {
|
||||
// Index creation queries
|
||||
createIndexes: {
|
||||
agentsName: 'CREATE INDEX IF NOT EXISTS idx_agents_name ON agents(name)',
|
||||
agentsType: 'CREATE INDEX IF NOT EXISTS idx_agents_type ON agents(type)',
|
||||
agentsModel: 'CREATE INDEX IF NOT EXISTS idx_agents_model ON agents(model)',
|
||||
agentsPlanModel: 'CREATE INDEX IF NOT EXISTS idx_agents_plan_model ON agents(plan_model)',
|
||||
agentsSmallModel: 'CREATE INDEX IF NOT EXISTS idx_agents_small_model ON agents(small_model)',
|
||||
@@ -99,8 +101,8 @@ export const AgentQueries = {
|
||||
// Agent operations
|
||||
agents: {
|
||||
insert: `
|
||||
INSERT INTO agents (id, name, description, avatar, instructions, model, plan_model, small_model, built_in_tools, mcps, knowledges, configuration, accessible_paths, permission_mode, max_steps, created_at, updated_at)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||
INSERT INTO agents (id, type, name, description, avatar, instructions, model, plan_model, small_model, built_in_tools, mcps, knowledges, configuration, accessible_paths, permission_mode, max_steps, created_at, updated_at)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||
`,
|
||||
|
||||
update: `
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
export type SessionStatus = 'idle' | 'running' | 'completed' | 'failed' | 'stopped'
|
||||
export type PermissionMode = 'readOnly' | 'acceptEdits' | 'bypassPermissions'
|
||||
export type SessionLogRole = 'user' | 'agent' | 'system' | 'tool'
|
||||
export type AgentType = 'claude-code' | 'codex' | 'qwen-cli' | 'gemini-cli' | 'custom'
|
||||
|
||||
export type SessionLogType =
|
||||
| 'message' // User or agent message
|
||||
@@ -38,6 +39,7 @@ export interface AgentConfiguration {
|
||||
// Agent entity representing an autonomous agent configuration
|
||||
export interface AgentEntity extends AgentConfiguration {
|
||||
id: string
|
||||
type: AgentType
|
||||
name: string
|
||||
description?: string
|
||||
avatar?: string
|
||||
|
||||
Reference in New Issue
Block a user