export interface Agent { id: string; state: 'running' | 'starting' | 'error' | 'restarting' | 'stopped'; model: string; uptime: number; messageCount: number; restartCount: number; } export interface ChatMessage { id: string; from: string; text: string; timestamp: Date; thinking?: string; routedTo?: string; toolName?: string; toolInput?: Record; toolResult?: string; isError?: boolean; errorCode?: string; } let _msgSeq = 0; export function msgId(): string { return `m-${Date.now()}-${++_msgSeq}`; } export interface Schedule { id: string; cron: string; description: string; task: string; lastRun?: string; } export interface IfThenRule { condition: string; action: string; } export interface ScheduleRule { timing: string; task: string; } export interface Sanctum { path: string; readonly: boolean; } export interface AgentConfig { name: string; model: string; identity: string; ifThen: IfThenRule[]; schedule: ScheduleRule[]; skills: string[]; sanctums: Sanctum[]; sourcePath: string; maxIterations?: number; maxHistory?: number; memory?: string; cpus?: string; } export interface SSEEvent { type: 'text' | 'thinking' | 'tool_start' | 'tool_use' | 'tool_delta' | 'tool_result' | 'error' | 'done'; text?: string; error?: string; errorCode?: string; toolCallId?: string; toolName?: string; toolUse?: { id?: string; name: string; input: Record; }; } export interface InstalledSkill { name: string; description: string; } export interface BackgroundSSEEvent { source: string; conversationId: string; event?: SSEEvent; done?: boolean; type?: 'ping'; }