吸收数字员工安全服务重启入口
This commit is contained in:
@@ -417,6 +417,21 @@ export interface DigitalEmployeeDailyReportRecordResult {
|
||||
eventId: string;
|
||||
}
|
||||
|
||||
export interface DigitalEmployeeManagedServiceActionInput {
|
||||
serviceId: string;
|
||||
action: "restart";
|
||||
status: "success" | "failed" | "rejected";
|
||||
reason?: string | null;
|
||||
actor?: string | null;
|
||||
result?: Record<string, unknown> | null;
|
||||
allowlisted: boolean;
|
||||
recordedAt?: string | null;
|
||||
}
|
||||
|
||||
export interface DigitalEmployeeManagedServiceActionResult {
|
||||
eventId: string;
|
||||
}
|
||||
|
||||
export interface DigitalEmployeeGovernanceCommandRecord {
|
||||
commandKind: string;
|
||||
commandId: string;
|
||||
@@ -1559,6 +1574,39 @@ export function recordDigitalEmployeeDailyReport(
|
||||
return { reportId, planId, taskId, runId, artifactId, eventId };
|
||||
}
|
||||
|
||||
export function recordDigitalEmployeeManagedServiceAction(
|
||||
input: DigitalEmployeeManagedServiceActionInput,
|
||||
): DigitalEmployeeManagedServiceActionResult | null {
|
||||
const db = getDigitalEmployeeDb();
|
||||
if (!db) return null;
|
||||
const now = input.recordedAt || new Date().toISOString();
|
||||
const normalizedServiceId = safeId(input.serviceId || "unknown-service");
|
||||
const eventId = `managed-service:${normalizedServiceId}:${input.action}:${input.status}:${safeId(now)}`;
|
||||
const kind = input.status === "rejected"
|
||||
? "managed_service_restart_rejected"
|
||||
: "managed_service_restart";
|
||||
const payload = {
|
||||
service_id: input.serviceId,
|
||||
action: input.action,
|
||||
status: input.status,
|
||||
reason: input.reason ?? null,
|
||||
actor: input.actor ?? null,
|
||||
result: input.result ?? null,
|
||||
allowlisted: input.allowlisted,
|
||||
};
|
||||
insertEvent({
|
||||
event_id: eventId,
|
||||
kind,
|
||||
occurred_at: now,
|
||||
message: input.status === "rejected"
|
||||
? `服务重启已拒绝:${input.serviceId}`
|
||||
: `服务重启${input.status === "success" ? "成功" : "失败"}:${input.serviceId}`,
|
||||
plan_id: null,
|
||||
task_id: null,
|
||||
}, null, payload);
|
||||
return { eventId };
|
||||
}
|
||||
|
||||
export function recordDigitalEmployeeGovernanceCommand(
|
||||
command: DigitalEmployeeGovernanceCommandRecord,
|
||||
): { planId: string; taskId: string; runId: string } {
|
||||
|
||||
Reference in New Issue
Block a user