/ easyshell-web / src / types / index.ts
index.ts
  1  export interface ApiResponse<T> {
  2    code: number;
  3    message: string;
  4    data: T;
  5  }
  6  
  7  export interface PageResponse<T> {
  8    content: T[];
  9    totalElements: number;
 10    totalPages: number;
 11    size: number;
 12    number: number;
 13  }
 14  
 15  export interface LoginRequest {
 16    username: string;
 17    password: string;
 18  }
 19  
 20  export interface LoginResponse {
 21    accessToken: string;
 22    refreshToken: string;
 23  }
 24  
 25  export interface UserVO {
 26    id: number;
 27    username: string;
 28    email: string;
 29    role: string;
 30    status: number;
 31    lastLoginAt: string;
 32    createdAt: string;
 33  }
 34  
 35  export interface UserCreateRequest {
 36    username: string;
 37    password: string;
 38    email?: string;
 39    role: string;
 40  }
 41  
 42  export interface UserUpdateRequest {
 43    email?: string;
 44    role?: string;
 45    status?: number;
 46  }
 47  
 48  export interface PasswordResetRequest {
 49    newPassword: string;
 50  }
 51  
 52  export interface SystemConfigVO {
 53    id: number;
 54    configKey: string;
 55    configValue: string;
 56    description: string;
 57    configGroup: string;
 58    updatedAt: string;
 59  }
 60  
 61  export interface SystemConfigRequest {
 62    configKey: string;
 63    configValue: string;
 64    description?: string;
 65    configGroup?: string;
 66  }
 67  
 68  export interface Agent {
 69    id: string;
 70    hostname: string;
 71    ip: string;
 72    os: string;
 73    arch: string;
 74    kernel: string;
 75    cpuModel: string;
 76    cpuCores: number;
 77    memTotal: number;
 78    agentVersion: string;
 79    status: number;
 80    lastHeartbeat: string;
 81    cpuUsage: number;
 82    memUsage: number;
 83    diskUsage: number;
 84    registeredAt: string;
 85    createdAt: string;
 86    updatedAt: string;
 87  }
 88  
 89  export interface Script {
 90    id: number;
 91    name: string;
 92    description: string;
 93    content: string;
 94    scriptType: string;
 95    isPublic: boolean;
 96    isTemplate: boolean;
 97    createdBy: string;
 98    version: number;
 99    createdAt: string;
100    updatedAt: string;
101  }
102  
103  export interface ScriptRequest {
104    name: string;
105    description: string;
106    content: string;
107    scriptType: string;
108    isPublic: boolean;
109  }
110  
111  export interface Task {
112    id: string;
113    name: string;
114    scriptId: number;
115    scriptContent: string;
116    scriptType: string;
117    timeoutSeconds: number;
118    status: number;
119    totalCount: number;
120    successCount: number;
121    failedCount: number;
122    createdBy: string;
123    startedAt: string;
124    finishedAt: string;
125    createdAt: string;
126    riskLevel?: string;
127    approvalStatus?: string;
128    source?: string;
129    targetAgentIds?: string;
130  }
131  
132  export interface TaskCreateRequest {
133    name: string;
134    scriptId?: number;
135    scriptContent?: string;
136    agentIds?: string[];
137    clusterIds?: number[];
138    tagIds?: number[];
139    timeoutSeconds: number;
140    parameters?: Record<string, string>;
141  }
142  
143  export interface Job {
144    id: string;
145    taskId: string;
146    agentId: string;
147    status: number;
148    exitCode: number;
149    output: string;
150    startedAt: string;
151    finishedAt: string;
152  }
153  
154  export interface TaskDetail {
155    task: Task;
156    jobs: Job[];
157  }
158  
159  export interface AgentBriefVO {
160    id: string;
161    hostname: string;
162    ip: string;
163    cpuUsage: number;
164    memUsage: number;
165    diskUsage: number;
166    lastHeartbeat: string;
167  }
168  
169  export interface DashboardStats {
170    totalAgents: number;
171    onlineAgents: number;
172    offlineAgents: number;
173    totalScripts: number;
174    totalTasks: number;
175    avgCpuUsage: number;
176    avgMemUsage: number;
177    avgDiskUsage: number;
178    recentTasks: Task[];
179    onlineAgentDetails: AgentBriefVO[];
180    unstableAgents: number;
181    todayTasks: number;
182    todaySuccessTasks: number;
183    todayFailedTasks: number;
184    taskSuccessRate: number | null;
185    highCpuAgents: number;
186    highMemAgents: number;
187    highDiskAgents: number;
188  }
189  
190  export interface MetricSnapshot {
191    id: number;
192    agentId: string;
193    cpuUsage: number;
194    memUsage: number;
195    diskUsage: number;
196    recordedAt: string;
197  }
198  
199  export interface ClusterVO {
200    id: number;
201    name: string;
202    description: string;
203    agentCount: number;
204    createdBy: number;
205    createdAt: string;
206  }
207  
208  export interface ClusterDetailVO {
209    id: number;
210    name: string;
211    description: string;
212    createdBy: number;
213    agents: Agent[];
214  }
215  
216  export interface ClusterRequest {
217    name: string;
218    description?: string;
219  }
220  
221  export interface TagVO {
222    id: number;
223    name: string;
224    color: string;
225    agentCount: number;
226  }
227  
228  export interface TagRequest {
229    name: string;
230    color?: string;
231  }
232  
233  export interface AuditLog {
234    id: number;
235    userId: number;
236    username: string;
237    action: string;
238    resourceType: string;
239    resourceId: string;
240    detail: string;
241    ip: string;
242    result: string;
243    createdAt: string;
244  }
245  
246  export interface HostProvisionRequest {
247    ip: string;
248    sshPort: number;
249    sshUsername: string;
250    sshPassword?: string;
251    authType?: 'password' | 'key';
252    sshPrivateKey?: string;
253    hostName?: string;
254    deployNow?: boolean;
255  }
256  
257  export interface HostCredentialVO {
258    id: number | null;
259    ip: string;
260    sshPort: number;
261    sshUsername: string;
262    authType: string;
263    hostName: string | null;
264    agentId: string | null;
265    provisionStatus: string;
266    provisionLog: string;
267    errorMessage: string | null;
268    createdAt: string;
269    updatedAt: string;
270    // Agent-merged fields (from unified list)
271    hostname: string | null;
272    os: string | null;
273    arch: string | null;
274    kernel: string | null;
275    cpuModel: string | null;
276    cpuCores: number | null;
277    memTotal: number | null;
278    agentVersion: string | null;
279    agentStatus: number | null;
280    lastHeartbeat: string | null;
281    cpuUsage: number | null;
282    memUsage: number | null;
283    diskUsage: number | null;
284    registeredAt: string | null;
285  }
286  
287  export type HostInfo = Agent;
288  
289  export interface AiProviderConfig {
290    provider: string;
291    apiKey: string;
292    baseUrl: string;
293    model: string;
294    temperature?: number;
295    topP?: number;
296    maxTokens?: number;
297  }
298  
299  export interface AiEmbeddingConfig {
300    provider: string;
301    model: string;
302    apiKey: string;
303    baseUrl: string;
304  }
305  
306  export interface AiOrchestratorConfig {
307    maxIterations: number;
308    maxToolCalls: number;
309    maxConsecutiveErrors: number;
310    sopEnabled: boolean;
311    memoryEnabled: boolean;
312    dangerousCommands: string[];
313    systemPromptOverride: string;
314  }
315  
316  export interface AiChannelConfig {
317    channel: string;
318    enabled: boolean;
319    settings: Record<string, string>;
320  }
321  
322  
323  export interface AiChannelContextConfig {
324    contextMode: string;
325    sessionTimeout: number;
326    defaultProvider: string;
327    defaultModel: string;
328  }
329  
330  export interface AiConfigVO {
331    enabled: boolean;
332    defaultProvider: string;
333    providers: Record<string, AiProviderConfig>;
334    quota: {
335      dailyLimit: number;
336      maxTokens: number;
337      chatTimeout: number;
338    };
339    channels: Record<string, AiChannelConfig>;
340    channelContext?: AiChannelContextConfig;
341    embedding?: AiEmbeddingConfig;
342    orchestrator?: AiOrchestratorConfig;
343  }
344  
345  export interface AiConfigSaveRequest {
346    enabled: boolean;
347    defaultProvider?: string;
348    providers?: Record<string, { apiKey?: string; baseUrl?: string; model?: string; temperature?: number; topP?: number; maxTokens?: number }>;
349    quota?: { dailyLimit?: number; maxTokens?: number; chatTimeout?: number };
350    channels?: Record<string, { enabled?: boolean; settings?: Record<string, string> }>;
351    channelContext?: { contextMode?: string; sessionTimeout?: number; defaultProvider?: string; defaultModel?: string };
352    embedding?: { provider?: string; model?: string; apiKey?: string; baseUrl?: string };
353    orchestrator?: { maxIterations?: number; maxToolCalls?: number; maxConsecutiveErrors?: number; sopEnabled?: boolean; memoryEnabled?: boolean; systemPromptOverride?: string };
354  }
355  
356  export interface AiTestRequest {
357    provider: string;
358    apiKey?: string;
359    baseUrl?: string;
360    model?: string;
361  }
362  
363  export interface AiTestResult {
364    success: boolean;
365    message: string;
366    responseTimeMs: number;
367    modelInfo: string;
368  }
369  
370  export type RiskLevel = 'LOW' | 'MEDIUM' | 'HIGH' | 'BANNED';
371  
372  export interface CommandRisk {
373    command: string;
374    level: RiskLevel;
375    reason: string;
376  }
377  
378  export interface RiskAssessment {
379    overallRisk: RiskLevel;
380    commandRisks: CommandRisk[];
381    bannedMatches: string[];
382    autoExecutable: boolean;
383    explanation: string;
384  }
385  
386  export interface AiRiskRulesVO {
387    bannedCommands: string[];
388    highCommands: string[];
389    lowCommands: string[];
390  }
391  
392  export interface AiRiskRulesSaveRequest {
393    bannedCommands?: string[];
394    highCommands?: string[];
395    lowCommands?: string[];
396  }
397  
398  export interface AiRiskAssessRequest {
399    scriptContent: string;
400  }
401  
402  export interface AiChatSession {
403    id: string;
404    title: string;
405    provider: string;
406    messageCount: number;
407    createdAt: string;
408    updatedAt: string;
409  }
410  
411  export interface AiChatMessage {
412    id: number;
413    sessionId: string;
414    role: 'user' | 'assistant' | 'system' | 'tool';
415    content: string;
416    toolName?: string;
417    processData?: string;
418    createdAt: string;
419  }
420  
421  export interface AiChatRequest {
422    sessionId?: string;
423    message: string;
424    provider?: string;
425    model?: string;
426    enableTools?: boolean;
427    targetAgentIds?: string[];
428  }
429  
430  export interface AiChatResponse {
431    sessionId: string;
432    content: string;
433  }
434  
435  export type AgentEventType =
436    | 'SESSION'
437    | 'PLAN'
438    | 'STEP_START'
439    | 'THINKING'
440    | 'TOOL_CALL'
441    | 'TOOL_RESULT'
442    | 'CONTENT'
443    | 'STEP_COMPLETE'
444    | 'APPROVAL'
445    | 'DONE'
446    | 'ERROR'
447    // Phase 1 agentic additions
448    | 'ITERATION_START'
449    | 'REFLECTION'
450    | 'SUBTASK_STARTED'
451    | 'SUBTASK_COMPLETED'
452    | 'SUBTASK_PROGRESS'
453    // Phase 2 planning additions
454    | 'PLAN_AWAIT_CONFIRMATION'
455    | 'PLAN_CONFIRMED'
456    | 'PLAN_REJECTED'
457    | 'STEP_RETRY'
458    | 'PLAN_SUMMARY'
459    | 'REVIEW_START'
460    | 'REVIEW_COMPLETE'
461    | 'PARALLEL_START'
462    | 'PARALLEL_PROGRESS'
463    | 'PARALLEL_COMPLETE'
464    // Phase 3 advanced capabilities additions
465    | 'MEMORY_RETRIEVED'
466    | 'SOP_MATCHED'
467    | 'SOP_APPLIED'
468    | 'TASK_CLASSIFIED'
469    | 'STEP_CHECKPOINT'
470    | 'STEP_CONDITION_EVAL'
471    | 'VARIABLE_SET';
472  
473  export interface PlanStep {
474    index: number;
475    description: string;
476    agent: string;
477    status: 'pending' | 'running' | 'completed' | 'failed' | 'skipped' | 'waiting_approval';
478    tools?: string[];
479    hosts?: string[];
480    parallelGroup?: number;
481    rollbackHint?: string;
482    result?: string;
483    error?: string;
484    dependsOn?: number[];
485    condition?: string;
486    checkpoint?: boolean;
487    outputVar?: string;
488    timeoutSec?: number;
489    onFailure?: string;
490    inputVars?: Record<string, string>;
491  }
492  
493  export interface ExecutionPlan {
494    summary: string;
495    steps: PlanStep[];
496    requiresConfirmation?: boolean;
497    estimatedRisk?: string;
498  }
499  
500  export interface AgentEvent {
501    type: AgentEventType;
502    agent?: string;
503    stepIndex?: number;
504    stepDescription?: string;
505    content?: string;
506    toolName?: string;
507    toolArgs?: string;
508    toolResult?: string;
509    plan?: ExecutionPlan;
510    sessionId?: string;
511    approvalData?: Record<string, unknown>;
512    metadata?: Record<string, string>;
513    maxIterations?: number;
514    iterationNumber?: number;
515    // Phase 2 additions
516    iteration?: number;
517    parallelGroup?: number;
518    totalTasks?: number;
519    completedTasks?: number;
520  }
521  
522  // Phase 3 — Memory and SOP types
523  export interface AiSessionSummary {
524    id: number;
525    sessionId: string;
526    userId: number;
527    summary: string;
528    keyOperations: string;
529    hostsInvolved: string;
530    servicesInvolved: string;
531    outcome: string;
532    tags: string;
533    embeddingId: string;
534    createdAt: string;
535    updatedAt: string;
536  }
537  
538  export interface AiSopTemplate {
539    id: number;
540    title: string;
541    description: string;
542    stepsJson: string;
543    triggerPattern: string;
544    category: string;
545    confidence: number;
546    enabled: boolean;
547    usageCount: number;
548    createdAt: string;
549    updatedAt: string;
550  }
551  
552  export interface AiSopTemplateRequest {
553    title?: string;
554    description?: string;
555    stepsJson?: string;
556    triggerPattern?: string;
557    category?: string;
558    enabled?: boolean;
559  }
560  
561  export interface HostSoftwareInventory {
562    id: number;
563    agentId: string;
564    softwareName: string;
565    softwareVersion: string | null;
566    softwareType: string;
567    processId: number | null;
568    listeningPorts: string | null;
569    detectedAt: string;
570    isDockerContainer: boolean;
571    dockerImage: string | null;
572    dockerContainerName: string | null;
573    dockerContainerStatus: string | null;
574    dockerPorts: string | null;
575  }
576  
577  export interface AiScheduledTask {
578    id: number;
579    name: string;
580    description: string;
581    taskType: string;
582    cronExpression: string;
583    targetType: string;
584    targetIds: string;
585    scriptTemplate: string | null;
586    aiPrompt: string | null;
587    enabled: boolean;
588    lastRunAt: string | null;
589    nextRunAt: string | null;
590    createdBy: number;
591    createdAt: string;
592    updatedAt: string;
593    notifyStrategy: string | null;
594    notifyChannels: string | null;
595    notifyAiPrompt: string | null;
596  }
597  
598  export interface AiScheduledTaskRequest {
599    name: string;
600    description?: string;
601    taskType: string;
602    cronExpression: string;
603    targetType: string;
604    targetIds: string;
605    scriptTemplate?: string;
606    aiPrompt?: string;
607    enabled?: boolean;
608    notifyStrategy?: string;
609    notifyChannels?: string;
610    notifyAiPrompt?: string;
611  }
612  
613  export interface AiInspectReport {
614    id: number;
615    scheduledTaskId: number;
616    taskType: string;
617    taskName: string;
618    targetSummary: string;
619    scriptOutput: string;
620    aiAnalysis: string | null;
621    status: string;
622    createdBy: number;
623    createdAt: string;
624  }
625  
626  export interface AiAlertRequest {
627    alertDescription: string;
628    agentId?: string;
629    alertSource?: string;
630    severity?: string;
631  }
632  
633  export interface AiAlertAnalysis {
634    analysis: string;
635    suggestedAction: string;
636    riskLevel: string;
637    autoFixAvailable: boolean;
638    autoFixScript: string | null;
639  }
640  
641  export interface BuiltInTemplate {
642    type: string;
643    name: string;
644    description: string;
645    script: string;
646    aiPrompt: string;
647  }