feat(assist): 支持协助身份与角色权限穿透呈现及高管防误用警示
- 实测澄清协助平台时长限制: 服务端 POST /api/assistPlatform/create 硬性单次上限为 24 小时 (1 天),超过直接报错 400,支持 --days/--hours 并在超限时清晰提示 - 协助直通会话生成及落盘时实时穿透解析组织架构: 提取人员姓名、工号、手机、所属部门、所配角色清单及核心系统权限 - 建立高管身份与特权角色风控评级体系 (analyzeStaffRoleRisk): 自动识别总监、主管理员、财务负责人、总经理等高危身份并输出安全风控警示框 - 将完整人员身份画像与风控元数据注入持久化企业配置 (enterprises/<corpId>.json) - 在 SKILL.md 追加 Rule 13 及更新 assist-platform.md 说明文档
This commit is contained in:
1 parent
60d0b8ffc1
commit
2ace4e2378
12 files changed
+957
-466
No files matched your search
@@ -5,6 +5,7 @@ import type {
|
||||
AssistPlatformStaff,
|
||||
AssistPlatformTicket,
|
||||
CorporationDetail,
|
||||
StaffRoleItem,
|
||||
} from "./types.js";
|
||||
|
||||
export interface SearchCorporationsApiParams {
|
||||
@@ -379,3 +380,99 @@ export async function approveAssistTicketApi(
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export async function getStaffMeAndRolesApi(
|
||||
client: KyInstance,
|
||||
corpId: string,
|
||||
staffId?: string
|
||||
): Promise<{
|
||||
staff: Record<string, unknown>;
|
||||
permissions: string[];
|
||||
roles: StaffRoleItem[];
|
||||
departmentName?: string;
|
||||
}> {
|
||||
let staff: Record<string, unknown> = {};
|
||||
let permissions: string[] = [];
|
||||
|
||||
try {
|
||||
const meRes = await client
|
||||
.get("api/v1/organization/staffs/me", {
|
||||
searchParams: { corpId },
|
||||
})
|
||||
.json<{
|
||||
value?: {
|
||||
staff?: Record<string, unknown>;
|
||||
permissions?: string[];
|
||||
};
|
||||
}>();
|
||||
if (meRes.value?.staff) {
|
||||
staff = meRes.value.staff;
|
||||
}
|
||||
if (Array.isArray(meRes.value?.permissions)) {
|
||||
permissions = meRes.value.permissions.map(String);
|
||||
}
|
||||
} catch {
|
||||
// 允许容错降级
|
||||
}
|
||||
|
||||
const effectiveStaffId = String(staff.id || staffId || "");
|
||||
|
||||
const roles: StaffRoleItem[] = [];
|
||||
if (effectiveStaffId) {
|
||||
try {
|
||||
const cleanStaffId = effectiveStaffId.startsWith("$") ? effectiveStaffId : `$${effectiveStaffId}`;
|
||||
const rolesRes = await client
|
||||
.get(`api/v1/organization/staffs/${cleanStaffId}/roles`, {
|
||||
searchParams: { corpId },
|
||||
})
|
||||
.json<{
|
||||
items?: Array<{
|
||||
roleDefId?: string;
|
||||
roleDefName?: string;
|
||||
roleDefCode?: string;
|
||||
}>;
|
||||
}>();
|
||||
|
||||
if (Array.isArray(rolesRes.items)) {
|
||||
for (const item of rolesRes.items) {
|
||||
if (item.roleDefName) {
|
||||
roles.push({
|
||||
id: String(item.roleDefId || ""),
|
||||
name: String(item.roleDefName),
|
||||
code: item.roleDefCode ? String(item.roleDefCode) : undefined,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
// 允许容错降级
|
||||
}
|
||||
}
|
||||
|
||||
let departmentName: string | undefined;
|
||||
const deptId = String(
|
||||
staff.defaultDepartment || (Array.isArray(staff.departments) ? staff.departments[0] : "") || ""
|
||||
);
|
||||
if (deptId) {
|
||||
try {
|
||||
const cleanDeptId = deptId.startsWith("$") ? deptId : `$${deptId}`;
|
||||
const deptRes = await client
|
||||
.get(`api/v1/organization/departments/${cleanDeptId}`, {
|
||||
searchParams: { corpId },
|
||||
})
|
||||
.json<{ value?: { name?: string } }>();
|
||||
if (deptRes.value?.name) {
|
||||
departmentName = deptRes.value.name;
|
||||
}
|
||||
} catch {
|
||||
// 允许容错降级
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
staff,
|
||||
permissions,
|
||||
roles,
|
||||
departmentName,
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user