吸收数字员工管理端通知视图

This commit is contained in:
baiyanyun
2026-06-10 17:05:57 +08:00
parent 5b2f14123e
commit 1271e4967b
7 changed files with 234 additions and 46 deletions

View File

@@ -568,6 +568,7 @@ function eventSpecificBusinessView(
}
if (kind.startsWith("skill_call_")) return skillCallBusinessView(payload);
if (kind.startsWith("plan_step_dispatch_")) return planStepDispatchBusinessView(payload);
if (isNotificationEvent(kind)) return notificationBusinessView(payload);
return {};
}
@@ -637,16 +638,46 @@ function planStepDispatchBusinessView(payload: Record<string, unknown>): Record<
};
}
function notificationBusinessView(payload: Record<string, unknown>): Record<string, unknown> {
const metadata = objectRecord(payload.metadata) ?? {};
const state = objectRecord(payload.state) ?? {};
const preferences = objectRecord(metadata.notification_preferences) ?? objectRecord(state.notificationPreferences) ?? {};
const overlays = objectRecord(state.notificationStateById) ?? {};
const notificationId = stringField(metadata.notification_id ?? payload.notification_id ?? payload.notificationId) || null;
const overlay = notificationId ? objectRecord(overlays[notificationId]) ?? {} : {};
const reply = stringField(overlay.reply ?? metadata.reply ?? payload.reply);
return {
notification_id: notificationId,
action: stringField(metadata.action ?? payload.action) || null,
status: stringField(overlay.status ?? payload.status) || null,
read_at: stringField(overlay.read_at ?? payload.read_at ?? payload.readAt) || null,
dismissed_at: stringField(overlay.dismissed_at ?? payload.dismissed_at ?? payload.dismissedAt) || null,
replied_at: stringField(overlay.replied_at ?? payload.replied_at ?? payload.repliedAt) || null,
reply_length: reply ? reply.length : null,
preferences_enabled: typeof preferences.enabled === "boolean" ? preferences.enabled : null,
muted_kinds: stringArrayField(preferences.muted_kinds ?? preferences.mutedKinds),
muted_levels: stringArrayField(preferences.muted_levels ?? preferences.mutedLevels),
};
}
function eventBusinessCategory(kind: string): string {
if (kind === "route_decision") return "route";
if (kind.startsWith("approval_")) return "approval";
if (kind.startsWith("artifact_")) return "artifact";
if (kind.startsWith("skill_call_")) return "skill";
if (kind.startsWith("plan_step_dispatch_")) return "dispatch";
if (isNotificationEvent(kind)) return "notification";
if (kind.startsWith("governance_")) return "governance";
return "runtime";
}
function isNotificationEvent(kind: string): boolean {
return kind === "digital_workday_update_notification_preferences"
|| kind === "digital_workday_notification_read"
|| kind === "digital_workday_notification_dismiss"
|| kind === "digital_workday_notification_reply";
}
function routeDecisionAttentionLevel(policyResult: string, reasonCodes: string[], createdCommandId: string | null): "info" | "action" | "warn" | "error" {
if (policyResult && policyResult !== "accepted") return "error";
if (reasonCodes.includes("candidate_skills_disabled") || reasonCodes.includes("route_action_missing_context")) return "warn";