吸收数字员工安全服务重启入口

This commit is contained in:
baiyanyun
2026-06-09 23:10:01 +08:00
parent 0d2008b35c
commit 91540dec0c
13 changed files with 717 additions and 155 deletions

View File

@@ -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 } {