feat(plan-management): implement alert-remediation-plan system v1.3
Some checks failed
AI automation / Route event (push) Has been cancelled
AI automation / Hand reopened issue to maintainers (push) Has been cancelled
AI automation / Clean source issue state (push) Has been cancelled
AI automation / Reconcile handoffs (push) Has been cancelled
AI automation / Classify issue (push) Has been cancelled
AI automation / Claude Code smoke (push) Has been cancelled
AI automation / Review issue follow-up (push) Has been cancelled
AI automation / Publish issue follow-up (push) Has been cancelled
AI automation / Implement with Claude Code (push) Has been cancelled
AI automation / Publish implement PR (push) Has been cancelled
AI automation / Continue queued issue comments (push) Has been cancelled
AI automation / Codex review loop (push) Has been cancelled
AI automation / Publish Codex fix (push) Has been cancelled
AI automation / Clear Codex dispatch marker (push) Has been cancelled
AI automation / Own PR re-request Codex (push) Has been cancelled
AI automation / External PR re-request Codex (push) Has been cancelled
AI automation / Poll Codex reaction / retry (push) Has been cancelled
Some checks failed
AI automation / Route event (push) Has been cancelled
AI automation / Hand reopened issue to maintainers (push) Has been cancelled
AI automation / Clean source issue state (push) Has been cancelled
AI automation / Reconcile handoffs (push) Has been cancelled
AI automation / Classify issue (push) Has been cancelled
AI automation / Claude Code smoke (push) Has been cancelled
AI automation / Review issue follow-up (push) Has been cancelled
AI automation / Publish issue follow-up (push) Has been cancelled
AI automation / Implement with Claude Code (push) Has been cancelled
AI automation / Publish implement PR (push) Has been cancelled
AI automation / Continue queued issue comments (push) Has been cancelled
AI automation / Codex review loop (push) Has been cancelled
AI automation / Publish Codex fix (push) Has been cancelled
AI automation / Clear Codex dispatch marker (push) Has been cancelled
AI automation / Own PR re-request Codex (push) Has been cancelled
AI automation / External PR re-request Codex (push) Has been cancelled
AI automation / Poll Codex reaction / retry (push) Has been cancelled
- 8 new store modules + matcher + initialResponse + aggregation + remediation + AlertStateMonitor + planGenerator - alert chain auto-integrated after runInspection: freeze snapshot + generate response + real-time agg + auto-start monitor - AlertAIPanel component + MonitoringDetailPanel expandable alert list - PlanManagementPage: full page with list/edit/AI generate/templates/commands
This commit is contained in:
@@ -106,6 +106,114 @@ export interface AlertRecord {
|
||||
resolved_at: number | null;
|
||||
resolved_reason: string | null;
|
||||
note: string | null;
|
||||
// v1.3 预案管理扩展字段
|
||||
alert_type?: string;
|
||||
alert_catalog?: string;
|
||||
matched_plan_id?: string | null;
|
||||
matched_template_id?: string | null;
|
||||
matched_plan_snapshot?: DevicePlan | null; // D9 匹配时刻冻结
|
||||
frozen_at?: number | null;
|
||||
initial_response?: InitialResponse | null;
|
||||
remediation?: RemediationRun | null;
|
||||
escalation?: {
|
||||
trigger: "aggregation" | "escalation_fallback_timeout";
|
||||
source_alert_ids: string[];
|
||||
target_level: string;
|
||||
escalated_at: number;
|
||||
} | null;
|
||||
audit_log?: Array<{
|
||||
ts: number;
|
||||
actor: string;
|
||||
action: string;
|
||||
detail?: string | null;
|
||||
}>;
|
||||
}
|
||||
|
||||
// ---------- v1.3 预案管理类型 ----------
|
||||
|
||||
export interface DevicePlan {
|
||||
id: string;
|
||||
template_id: string | null;
|
||||
device_type: string;
|
||||
level: AlertLevel;
|
||||
enabled: boolean;
|
||||
builtin: boolean;
|
||||
status: "active" | "draft" | "disabled";
|
||||
source: "manual" | "ai";
|
||||
ai_provider: string | null;
|
||||
ai_prompt_version: string | null;
|
||||
reject_reason: string | null;
|
||||
review_log: Array<{ ts: number; actor: string; action: "approve" | "reject" | "ai_generate"; reason: string | null }>;
|
||||
description: string;
|
||||
match: {
|
||||
metric_rules: Array<{ metric_key: string; op: string; value: string | number }>;
|
||||
alert_types: string[];
|
||||
device_tiers: string[];
|
||||
device_tags: string[];
|
||||
};
|
||||
scope: { host_ids: string[]; host_groups: string[] };
|
||||
human_action_guide: {
|
||||
receiving_alerts: string[];
|
||||
info_gathering: Array<{ priority: number; action: string; purpose: string }>;
|
||||
notification_chain: Array<{ role: string; channel: string; trigger: string; contact: string; auto: boolean }>;
|
||||
escalation_triggers: Array<{ condition: string; target_level: string }>;
|
||||
pre_remediation: string[];
|
||||
post_remediation: string[];
|
||||
};
|
||||
remediation: {
|
||||
steps: Array<{
|
||||
order: number;
|
||||
action: "command" | "checklist";
|
||||
command_id?: string;
|
||||
command_params?: Record<string, any>;
|
||||
timeout_sec?: number;
|
||||
execution: "auto" | "confirm" | "manual_only";
|
||||
on_success: "next" | "stop" | "skip";
|
||||
on_failure: "stop" | "escalate" | string;
|
||||
purpose?: string;
|
||||
}>;
|
||||
};
|
||||
security: {
|
||||
allowed_command_ids: string[];
|
||||
allowed_commands: string[];
|
||||
blocked_patterns: string[];
|
||||
};
|
||||
required_role: string;
|
||||
escalation_fallback: { auto_escalate_minutes: number; escalation_target_level: string } | null;
|
||||
created_at: number;
|
||||
updated_at: number;
|
||||
}
|
||||
|
||||
export interface InitialResponse {
|
||||
alert_id: string;
|
||||
generated_at: number;
|
||||
generator: "ai" | "fallback";
|
||||
status: string;
|
||||
quick_checklist: Array<{ priority: number; action: string; purpose: string }>;
|
||||
possible_causes?: Array<{ probability: string; label: string; hint: string }>;
|
||||
matched_plan: { name: string; level: string };
|
||||
auto_notifications_sent: Array<{ role: string; channel: string; status: string }>;
|
||||
pending_notifications: Array<Record<string, any>>;
|
||||
warnings: string[];
|
||||
}
|
||||
|
||||
export interface RemediationRun {
|
||||
status: "pending" | "running" | "completed" | "partial" | "failed" | "cancelled" | "paused";
|
||||
started_at: number;
|
||||
completed_at?: number;
|
||||
steps: Array<{
|
||||
order: number;
|
||||
status: "pending" | "running" | "success" | "failed" | "skipped" | "pending_manual";
|
||||
command_id?: string;
|
||||
execution: "auto" | "confirm" | "manual_only";
|
||||
stdout_preview?: string | null;
|
||||
exit_code?: number | null;
|
||||
error?: string | null;
|
||||
confirmed_by?: string | null;
|
||||
confirmed_at?: number | null;
|
||||
started_at?: number | null;
|
||||
finished_at?: number | null;
|
||||
}>;
|
||||
}
|
||||
|
||||
export interface AlertStats {
|
||||
@@ -627,3 +735,90 @@ export const inspectionSnapshotExportApi = {
|
||||
exportPdf: (snapshotId: string, aiSummary?: any): Promise<{ ok: boolean; filePath?: string; error?: string }> =>
|
||||
invoke("exportReportSnapshotPdf", aiSummary ? { snapshotId, aiSummary } : snapshotId),
|
||||
};
|
||||
|
||||
// =============== v1.3 预案管理 ===============
|
||||
|
||||
export interface PlanTemplate {
|
||||
id: string;
|
||||
name: string;
|
||||
level: AlertLevel;
|
||||
builtin: boolean;
|
||||
description: string;
|
||||
display: { color: string; icon: string; blink: boolean; sound: string | null };
|
||||
notification: { channels: string[]; recipients: any[]; repeat_interval_minutes: number; max_repeats: number };
|
||||
escalation_fallback: { auto_escalate_minutes: number; escalation_target_level: string } | null;
|
||||
remediation_defaults: { require_confirmation: boolean; auto_close_after_remediation_recovery: boolean; execution_timeout_sec: number };
|
||||
created_at: number;
|
||||
updated_at: number;
|
||||
}
|
||||
|
||||
export interface CommandCatalogItem {
|
||||
id: string;
|
||||
name: string;
|
||||
command: string;
|
||||
device_types: string[];
|
||||
risk_level: "low" | "medium" | "high";
|
||||
execution: "auto" | "confirm" | "manual_only";
|
||||
category: "diagnostic" | "config" | "security" | "backup" | "recovery";
|
||||
description: string;
|
||||
builtin: boolean;
|
||||
created_at: number;
|
||||
updated_at: number;
|
||||
}
|
||||
|
||||
export const planManagementApi = {
|
||||
// 预案模板
|
||||
listTemplates: (): Promise<PlanTemplate[]> => invoke("listPlanTemplates"),
|
||||
getTemplate: (id: string): Promise<PlanTemplate | null> => invoke("getPlanTemplate", id),
|
||||
createTemplate: (data: Partial<PlanTemplate>): Promise<PlanTemplate> => invoke("createPlanTemplate", data),
|
||||
updateTemplate: (id: string, updates: Partial<PlanTemplate>): Promise<PlanTemplate | null> =>
|
||||
invoke("updatePlanTemplate", id, updates),
|
||||
deleteTemplate: (id: string): Promise<boolean> => invoke("deletePlanTemplate", id),
|
||||
|
||||
// 设备预案
|
||||
listPlans: (filters?: { status?: string; device_type?: string; level?: string; enabled?: boolean }): Promise<DevicePlan[]> =>
|
||||
invoke("listDevicePlans", filters || {}),
|
||||
getPlan: (id: string): Promise<DevicePlan | null> => invoke("getDevicePlan", id),
|
||||
createPlan: (data: Partial<DevicePlan>): Promise<DevicePlan> => invoke("createDevicePlan", data),
|
||||
updatePlan: (id: string, updates: Partial<DevicePlan>): Promise<DevicePlan | null> =>
|
||||
invoke("updateDevicePlan", id, updates),
|
||||
deletePlan: (id: string): Promise<boolean> => invoke("deleteDevicePlan", id),
|
||||
approvePlan: (id: string, actor = "admin"): Promise<DevicePlan | null> =>
|
||||
invoke("approveDevicePlan", id, actor),
|
||||
rejectPlan: (id: string, reason: string, actor = "admin"): Promise<DevicePlan | null> =>
|
||||
invoke("rejectDevicePlan", id, reason, actor),
|
||||
matchPlan: (alert: any, deviceProfile: any): Promise<{ plan: DevicePlan; score: number } | null> =>
|
||||
invoke("matchPlanForAlert", alert, deviceProfile),
|
||||
|
||||
// 聚合规则
|
||||
listAggregationRules: (): Promise<any[]> => invoke("listAggregationRules"),
|
||||
createAggregationRule: (data: any): Promise<any> => invoke("createAggregationRule", data),
|
||||
updateAggregationRule: (id: string, updates: any): Promise<any | null> =>
|
||||
invoke("updateAggregationRule", id, updates),
|
||||
deleteAggregationRule: (id: string): Promise<boolean> => invoke("deleteAggregationRule", id),
|
||||
|
||||
// 命令目录
|
||||
listCommandCatalog: (filters?: { device_type?: string; execution?: string; risk_level?: string }): Promise<CommandCatalogItem[]> =>
|
||||
invoke("listCommandCatalog", filters || {}),
|
||||
getCommandCatalog: (id: string): Promise<CommandCatalogItem | null> => invoke("getCommandCatalog", id),
|
||||
|
||||
// AI 预案生成
|
||||
generatePlan: (description: string): Promise<{ ok: boolean; plan?: DevicePlan; warnings?: string[]; validation?: any; error?: string }> =>
|
||||
invoke("generatePlan", description),
|
||||
|
||||
// 初始响应包
|
||||
regenerateInitialResponse: (alertId: string): Promise<{ ok: boolean; response?: any; error?: string }> =>
|
||||
invoke("regenerateInitialResponse", alertId),
|
||||
|
||||
// 处置执行
|
||||
startRemediation: (alertId: string): Promise<{ ok: boolean; result?: any; error?: string }> =>
|
||||
invoke("startRemediation", alertId),
|
||||
pauseRemediation: (alertId: string): Promise<{ ok: boolean }> => invoke("pauseRemediation", alertId),
|
||||
resumeRemediation: (alertId: string): Promise<{ ok: boolean }> => invoke("resumeRemediation", alertId),
|
||||
cancelRemediation: (alertId: string): Promise<{ ok: boolean }> => invoke("cancelRemediation", alertId),
|
||||
getRemediationStatus: (alertId: string): Promise<any | null> => invoke("getRemediationStatus", alertId),
|
||||
|
||||
// AlertStateMonitor
|
||||
getAlertStateMonitorStatus: (): Promise<{ running: boolean; interval_minutes: number; remediation_timeout_minutes: number }> =>
|
||||
invoke("getAlertStateMonitorStatus"),
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user