@sparkelf/dsh-dataops-managed 0.3.48 → 0.3.50
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/client.js +164 -167
- package/lib/client.js.map +1 -1
- package/lib/index.js +298 -0
- package/lib/types/tool-scope.d.ts +15 -0
- package/package.json +1 -1
- package/skills/skill-provisioning/SKILL.md +101 -0
package/lib/index.js
CHANGED
|
@@ -861,6 +861,11 @@ const AI_TOOL_ACCESS = {
|
|
|
861
861
|
skill_disable: { permission: "skill:manage" },
|
|
862
862
|
skill_unshare: { permission: "skill:manage" },
|
|
863
863
|
skill_delete: { permission: "skill:manage" },
|
|
864
|
+
skill_install_for_user: { permission: "skill:manage" },
|
|
865
|
+
department_skill_bind: { permission: "skill:manage" },
|
|
866
|
+
department_skill_unbind: { permission: "skill:manage" },
|
|
867
|
+
department_skill_apply: { permission: "skill:manage" },
|
|
868
|
+
department_skill_preview: { permission: "skill:manage" },
|
|
864
869
|
review_scan: {
|
|
865
870
|
permission: "skill:read",
|
|
866
871
|
reviewer: true
|
|
@@ -1675,6 +1680,30 @@ function rowsOf(body) {
|
|
|
1675
1680
|
return [];
|
|
1676
1681
|
}
|
|
1677
1682
|
const forbidden = (message) => /* @__PURE__ */ new Error("Forbidden (403): " + message);
|
|
1683
|
+
/** Validate one plaza skill id before a provisioning call. */
|
|
1684
|
+
const provisioningSkillId = (tool, value) => {
|
|
1685
|
+
if (!Number.isSafeInteger(value) || value <= 0) throw new Error(tool + ": skill_id must be a positive integer");
|
|
1686
|
+
return value;
|
|
1687
|
+
};
|
|
1688
|
+
/**
|
|
1689
|
+
* Normalize one explicit user list for a provisioning call.
|
|
1690
|
+
*
|
|
1691
|
+
* DataOps user ids are UUID strings, and the provisioning endpoints take a batch. An empty or
|
|
1692
|
+
* malformed list is a caller error: forwarding it would either match nobody or let the backend
|
|
1693
|
+
* answer a scope the caller never named, so it never reaches the API.
|
|
1694
|
+
*/
|
|
1695
|
+
const provisioningUserIds = (tool, values) => {
|
|
1696
|
+
if (!Array.isArray(values) || values.length === 0) throw new Error(tool + ": user_ids must be a non-empty array of DataOps user ids");
|
|
1697
|
+
const ids = values.map((value) => typeof value === "string" ? value.trim() : "");
|
|
1698
|
+
if (ids.some((id) => id === "")) throw new Error(tool + ": user_ids must contain non-empty DataOps user ids");
|
|
1699
|
+
return Array.from(new Set(ids));
|
|
1700
|
+
};
|
|
1701
|
+
/** Read one required department code from tool arguments. */
|
|
1702
|
+
const provisioningDepartmentCode = (tool, value) => {
|
|
1703
|
+
const code = typeof value === "string" ? value.trim() : "";
|
|
1704
|
+
if (code === "") throw new Error(tool + ": department_code is required");
|
|
1705
|
+
return code;
|
|
1706
|
+
};
|
|
1678
1707
|
/**
|
|
1679
1708
|
* Build every managed tool definition.
|
|
1680
1709
|
*
|
|
@@ -2038,6 +2067,238 @@ function buildAiManagementTools(ctx, reviewApi, readScope, collectHub) {
|
|
|
2038
2067
|
}
|
|
2039
2068
|
})
|
|
2040
2069
|
},
|
|
2070
|
+
{
|
|
2071
|
+
name: "skill_install_for_user",
|
|
2072
|
+
definition: defineTool({
|
|
2073
|
+
name: "skill_install_for_user",
|
|
2074
|
+
description: "Install one plaza skill directly into the workspaces of the listed users, optionally overwriting an existing installation of the same skill key (overwrite=true). Administrator scope only; DataOps validates every target user and the caller's permitted range on the call. ONLY the listed users are affected — nobody else — and the installation takes effect the next time each target opens their workspace (a running workspace may pick it up immediately). Never use this for a whole department; use department_skill_preview + department_skill_bind + department_skill_apply. Requires user approval; audited.",
|
|
2075
|
+
parameters: {
|
|
2076
|
+
skill_id: {
|
|
2077
|
+
type: "number",
|
|
2078
|
+
required: true,
|
|
2079
|
+
description: "Plaza skill id."
|
|
2080
|
+
},
|
|
2081
|
+
user_ids: {
|
|
2082
|
+
type: "array",
|
|
2083
|
+
items: { type: "string" },
|
|
2084
|
+
required: true,
|
|
2085
|
+
description: "DataOps user ids (UUID strings) that should receive the skill."
|
|
2086
|
+
},
|
|
2087
|
+
overwrite: {
|
|
2088
|
+
type: "boolean",
|
|
2089
|
+
description: "Overwrite an existing installation of the same skill key. Defaults to false, which leaves an existing installation unchanged."
|
|
2090
|
+
}
|
|
2091
|
+
},
|
|
2092
|
+
output: {
|
|
2093
|
+
schema: OPEN_OBJECT_SCHEMA,
|
|
2094
|
+
render: renderJson
|
|
2095
|
+
},
|
|
2096
|
+
execute: async (args, exec) => {
|
|
2097
|
+
const skillId = provisioningSkillId("skill_install_for_user", args.skill_id);
|
|
2098
|
+
const userIds = provisioningUserIds("skill_install_for_user", args.user_ids);
|
|
2099
|
+
const overwrite = args.overwrite === true;
|
|
2100
|
+
await approve("skill_install_for_user", exec, "Install skill " + skillId.toString() + " for " + userIds.length.toString() + " user(s)" + (overwrite ? " with overwrite" : ""));
|
|
2101
|
+
const value = await call("/api/ai/skill-plaza/admin/install-for-users", {
|
|
2102
|
+
method: "POST",
|
|
2103
|
+
body: JSON.stringify({
|
|
2104
|
+
skillId,
|
|
2105
|
+
userIds,
|
|
2106
|
+
...args.overwrite === void 0 ? {} : { overwrite: args.overwrite }
|
|
2107
|
+
})
|
|
2108
|
+
});
|
|
2109
|
+
audit("skill_install_for_user", exec, {
|
|
2110
|
+
skillId,
|
|
2111
|
+
userCount: userIds.length,
|
|
2112
|
+
overwrite,
|
|
2113
|
+
skillKey: typeof value.skillKey === "string" ? value.skillKey : null
|
|
2114
|
+
});
|
|
2115
|
+
return value;
|
|
2116
|
+
}
|
|
2117
|
+
})
|
|
2118
|
+
},
|
|
2119
|
+
{
|
|
2120
|
+
name: "department_skill_bind",
|
|
2121
|
+
definition: defineTool({
|
|
2122
|
+
name: "department_skill_bind",
|
|
2123
|
+
description: "Bind one plaza skill as a DEPARTMENT DEFAULT. This changes configuration only: it does NOT touch any existing user's workspace — run department_skill_apply to reconcile the department's users. The binding applies to the department and, on apply, its sub-departments; DataOps enforces the caller's department range. Call department_skill_preview first and show the user the affected tree and user count. Requires user approval; audited.",
|
|
2124
|
+
parameters: {
|
|
2125
|
+
department_code: {
|
|
2126
|
+
type: "string",
|
|
2127
|
+
required: true,
|
|
2128
|
+
description: "Department code from the DataOps department tree."
|
|
2129
|
+
},
|
|
2130
|
+
skill_id: {
|
|
2131
|
+
type: "number",
|
|
2132
|
+
required: true,
|
|
2133
|
+
description: "Plaza skill id."
|
|
2134
|
+
},
|
|
2135
|
+
enabled: {
|
|
2136
|
+
type: "boolean",
|
|
2137
|
+
description: "Whether the binding is active. Defaults to true."
|
|
2138
|
+
}
|
|
2139
|
+
},
|
|
2140
|
+
output: {
|
|
2141
|
+
schema: OPEN_OBJECT_SCHEMA,
|
|
2142
|
+
render: renderJson
|
|
2143
|
+
},
|
|
2144
|
+
execute: async (args, exec) => {
|
|
2145
|
+
const departmentCode = provisioningDepartmentCode("department_skill_bind", args.department_code);
|
|
2146
|
+
const skillId = provisioningSkillId("department_skill_bind", args.skill_id);
|
|
2147
|
+
const enabled = args.enabled !== false;
|
|
2148
|
+
await approve("department_skill_bind", exec, (enabled ? "Bind" : "Disable") + " skill " + skillId.toString() + " as a default for department " + departmentCode);
|
|
2149
|
+
const value = await call("/api/ai/skill-plaza/admin/department-skills/bind", {
|
|
2150
|
+
method: "POST",
|
|
2151
|
+
body: JSON.stringify({
|
|
2152
|
+
departmentCode,
|
|
2153
|
+
skillId,
|
|
2154
|
+
enabled
|
|
2155
|
+
})
|
|
2156
|
+
});
|
|
2157
|
+
audit("department_skill_bind", exec, {
|
|
2158
|
+
departmentCode,
|
|
2159
|
+
skillId,
|
|
2160
|
+
enabled,
|
|
2161
|
+
spread: false
|
|
2162
|
+
});
|
|
2163
|
+
return value;
|
|
2164
|
+
}
|
|
2165
|
+
})
|
|
2166
|
+
},
|
|
2167
|
+
{
|
|
2168
|
+
name: "department_skill_unbind",
|
|
2169
|
+
definition: defineTool({
|
|
2170
|
+
name: "department_skill_unbind",
|
|
2171
|
+
description: "Remove one plaza skill from a DEPARTMENT's default bindings. This changes configuration only: existing installations remain in the users' workspaces until the next department_skill_apply reconciles them. DataOps enforces the caller's department range. Call department_skill_preview first. Requires user approval; audited.",
|
|
2172
|
+
parameters: {
|
|
2173
|
+
department_code: {
|
|
2174
|
+
type: "string",
|
|
2175
|
+
required: true,
|
|
2176
|
+
description: "Department code from the DataOps department tree."
|
|
2177
|
+
},
|
|
2178
|
+
skill_id: {
|
|
2179
|
+
type: "number",
|
|
2180
|
+
required: true,
|
|
2181
|
+
description: "Plaza skill id."
|
|
2182
|
+
}
|
|
2183
|
+
},
|
|
2184
|
+
output: {
|
|
2185
|
+
schema: OPEN_OBJECT_SCHEMA,
|
|
2186
|
+
render: renderJson
|
|
2187
|
+
},
|
|
2188
|
+
execute: async (args, exec) => {
|
|
2189
|
+
const departmentCode = provisioningDepartmentCode("department_skill_unbind", args.department_code);
|
|
2190
|
+
const skillId = provisioningSkillId("department_skill_unbind", args.skill_id);
|
|
2191
|
+
await approve("department_skill_unbind", exec, "Unbind skill " + skillId.toString() + " from department " + departmentCode);
|
|
2192
|
+
const value = await call("/api/ai/skill-plaza/admin/department-skills/unbind", {
|
|
2193
|
+
method: "POST",
|
|
2194
|
+
body: JSON.stringify({
|
|
2195
|
+
departmentCode,
|
|
2196
|
+
skillId
|
|
2197
|
+
})
|
|
2198
|
+
});
|
|
2199
|
+
audit("department_skill_unbind", exec, {
|
|
2200
|
+
departmentCode,
|
|
2201
|
+
skillId,
|
|
2202
|
+
spread: false
|
|
2203
|
+
});
|
|
2204
|
+
return value;
|
|
2205
|
+
}
|
|
2206
|
+
})
|
|
2207
|
+
},
|
|
2208
|
+
{
|
|
2209
|
+
name: "department_skill_apply",
|
|
2210
|
+
definition: defineTool({
|
|
2211
|
+
name: "department_skill_apply",
|
|
2212
|
+
description: "Apply the department's CURRENT default-skill bindings to its users once: marks the affected users for reconciliation, which runs the next time each workspace starts (a running workspace may reconcile immediately). This is the step that makes earlier bind/unbind changes reach existing users. Target either a department (with optional sub-departments) or an explicit user list. Requires confirm=true plus user approval; audited. Preview the department tree and user count with department_skill_preview first, then show the user the exact scope and ask for explicit confirmation.",
|
|
2213
|
+
parameters: {
|
|
2214
|
+
department_code: {
|
|
2215
|
+
type: "string",
|
|
2216
|
+
description: "Department code to apply. Required unless user_ids is given."
|
|
2217
|
+
},
|
|
2218
|
+
include_descendants: {
|
|
2219
|
+
type: "boolean",
|
|
2220
|
+
description: "Also apply to sub-departments. Defaults to true when department_code is set."
|
|
2221
|
+
},
|
|
2222
|
+
user_ids: {
|
|
2223
|
+
type: "array",
|
|
2224
|
+
items: { type: "string" },
|
|
2225
|
+
description: "Explicit DataOps user ids; an alternative to department_code."
|
|
2226
|
+
},
|
|
2227
|
+
confirm: {
|
|
2228
|
+
type: "boolean",
|
|
2229
|
+
required: true,
|
|
2230
|
+
description: "Must be true: explicitly confirms applying the current bindings to the affected users."
|
|
2231
|
+
}
|
|
2232
|
+
},
|
|
2233
|
+
output: {
|
|
2234
|
+
schema: OPEN_OBJECT_SCHEMA,
|
|
2235
|
+
render: renderJson
|
|
2236
|
+
},
|
|
2237
|
+
execute: async (args, exec) => {
|
|
2238
|
+
if (args.confirm !== true) throw new Error("department_skill_apply requires confirm=true");
|
|
2239
|
+
const departmentCode = typeof args.department_code === "string" ? args.department_code.trim() : "";
|
|
2240
|
+
const userIds = args.user_ids === void 0 ? [] : provisioningUserIds("department_skill_apply", args.user_ids);
|
|
2241
|
+
if (departmentCode === "" && userIds.length === 0) throw new Error("department_skill_apply requires department_code or a non-empty user_ids list");
|
|
2242
|
+
if (departmentCode !== "" && userIds.length > 0) throw new Error("department_skill_apply accepts either department_code or user_ids, not both");
|
|
2243
|
+
const includeDescendants = args.include_descendants !== false;
|
|
2244
|
+
await approve("department_skill_apply", exec, departmentCode !== "" ? "Apply department default skills to " + departmentCode + (includeDescendants ? " including sub-departments" : "") : "Apply department default skills to " + userIds.length.toString() + " user(s)");
|
|
2245
|
+
const value = await call("/api/ai/skill-plaza/admin/department-skills/apply", {
|
|
2246
|
+
method: "POST",
|
|
2247
|
+
body: JSON.stringify({
|
|
2248
|
+
...departmentCode === "" ? {} : {
|
|
2249
|
+
departmentCode,
|
|
2250
|
+
includeDescendants
|
|
2251
|
+
},
|
|
2252
|
+
...userIds.length === 0 ? {} : { userIds }
|
|
2253
|
+
})
|
|
2254
|
+
});
|
|
2255
|
+
audit("department_skill_apply", exec, {
|
|
2256
|
+
departmentCode: departmentCode === "" ? null : departmentCode,
|
|
2257
|
+
includeDescendants: departmentCode === "" ? null : includeDescendants,
|
|
2258
|
+
userCount: userIds.length,
|
|
2259
|
+
confirmed: true
|
|
2260
|
+
});
|
|
2261
|
+
return value;
|
|
2262
|
+
}
|
|
2263
|
+
})
|
|
2264
|
+
},
|
|
2265
|
+
{
|
|
2266
|
+
name: "department_skill_preview",
|
|
2267
|
+
definition: defineTool({
|
|
2268
|
+
name: "department_skill_preview",
|
|
2269
|
+
description: "Read-only preview of a department-default skill binding: the department plus its sub-departments, the affected user count, the users, and current installation/conflict details. Call this BEFORE department_skill_bind, department_skill_unbind or department_skill_apply and show the department tree, user count and overwrite/skip details to the user. It writes nothing.",
|
|
2270
|
+
parameters: {
|
|
2271
|
+
department_code: {
|
|
2272
|
+
type: "string",
|
|
2273
|
+
required: true,
|
|
2274
|
+
description: "Department code from the DataOps department tree."
|
|
2275
|
+
},
|
|
2276
|
+
skill_id: {
|
|
2277
|
+
type: "number",
|
|
2278
|
+
required: true,
|
|
2279
|
+
description: "Plaza skill id."
|
|
2280
|
+
}
|
|
2281
|
+
},
|
|
2282
|
+
output: {
|
|
2283
|
+
schema: OPEN_OBJECT_SCHEMA,
|
|
2284
|
+
render: renderJson
|
|
2285
|
+
},
|
|
2286
|
+
execute: async (args, exec) => {
|
|
2287
|
+
const departmentCode = provisioningDepartmentCode("department_skill_preview", args.department_code);
|
|
2288
|
+
const skillId = provisioningSkillId("department_skill_preview", args.skill_id);
|
|
2289
|
+
const query = new URLSearchParams({
|
|
2290
|
+
departmentCode,
|
|
2291
|
+
skillId: skillId.toString()
|
|
2292
|
+
});
|
|
2293
|
+
const value = await call("/api/ai/skill-plaza/admin/department-skills/preview?" + query.toString());
|
|
2294
|
+
audit("department_skill_preview", exec, {
|
|
2295
|
+
departmentCode,
|
|
2296
|
+
skillId
|
|
2297
|
+
});
|
|
2298
|
+
return value;
|
|
2299
|
+
}
|
|
2300
|
+
})
|
|
2301
|
+
},
|
|
2041
2302
|
{
|
|
2042
2303
|
name: "review_scan",
|
|
2043
2304
|
definition: defineTool({
|
|
@@ -4111,6 +4372,38 @@ const prefectScriptSkillProvider = {
|
|
|
4111
4372
|
};
|
|
4112
4373
|
}
|
|
4113
4374
|
};
|
|
4375
|
+
const PROVISIONING_SKILL_NAME = "skill-provisioning";
|
|
4376
|
+
const PROVISIONING_SKILL_FILE = new URL("../skills/skill-provisioning/SKILL.md", import.meta.url);
|
|
4377
|
+
/** 该技能只对持有 `skill:manage` 的身份展示:它驱动的分配工具使用同一能力。 */
|
|
4378
|
+
const PROVISIONING_SKILL = {
|
|
4379
|
+
name: PROVISIONING_SKILL_NAME,
|
|
4380
|
+
metadata: { permissions: ["skill:manage"] },
|
|
4381
|
+
description: "给指定用户或部门批量分配技能时使用。先预览部门+子部门、受影响用户数与覆盖/冲突,用户明确确认后才绑定或应用;部门绑定只改配置,现有用户需 apply 才生效。",
|
|
4382
|
+
invocation: {
|
|
4383
|
+
modelInvocable: true,
|
|
4384
|
+
userInvocable: true
|
|
4385
|
+
},
|
|
4386
|
+
provider: PROVISIONING_SKILL_NAME,
|
|
4387
|
+
source: "bundled",
|
|
4388
|
+
resourceBase: {
|
|
4389
|
+
kind: "directory",
|
|
4390
|
+
path: fileURLToPath(new URL("../", import.meta.url))
|
|
4391
|
+
},
|
|
4392
|
+
rank: BUNDLED_SKILL_RANK,
|
|
4393
|
+
locator: PROVISIONING_SKILL_FILE
|
|
4394
|
+
};
|
|
4395
|
+
let provisioningSkillAllowed = () => false;
|
|
4396
|
+
const provisioningSkillProvider = {
|
|
4397
|
+
name: PROVISIONING_SKILL_NAME,
|
|
4398
|
+
list: () => Promise.resolve(provisioningSkillAllowed() ? [PROVISIONING_SKILL] : []),
|
|
4399
|
+
async get() {
|
|
4400
|
+
if (!provisioningSkillAllowed()) throw new Error("skill provisioning is not available for this account");
|
|
4401
|
+
return {
|
|
4402
|
+
...PROVISIONING_SKILL,
|
|
4403
|
+
content: await readFile(PROVISIONING_SKILL_FILE, "utf8")
|
|
4404
|
+
};
|
|
4405
|
+
}
|
|
4406
|
+
};
|
|
4114
4407
|
/** Serve the collection skill to the catalog. */
|
|
4115
4408
|
const collectSkillProvider = {
|
|
4116
4409
|
name: COLLECT_SKILL_NAME,
|
|
@@ -4136,6 +4429,7 @@ async function apply(ctx, config) {
|
|
|
4136
4429
|
ctx.skills.registerProvider(() => collectSkillProvider);
|
|
4137
4430
|
ctx.skills.registerProvider(() => connectorSkillProvider);
|
|
4138
4431
|
ctx.skills.registerProvider(() => prefectScriptSkillProvider);
|
|
4432
|
+
ctx.skills.registerProvider(() => provisioningSkillProvider);
|
|
4139
4433
|
const ensureMcp = async () => {
|
|
4140
4434
|
if (mcpFiber !== void 0 && mcpFiber.uid !== null) return;
|
|
4141
4435
|
const fiber = ctx.plugin(McpClient, {
|
|
@@ -4368,6 +4662,10 @@ async function apply(ctx, config) {
|
|
|
4368
4662
|
const scope = aiTools.currentScope();
|
|
4369
4663
|
return scope !== void 0 && isSuperAdmin(scope);
|
|
4370
4664
|
};
|
|
4665
|
+
provisioningSkillAllowed = () => {
|
|
4666
|
+
const scope = aiTools.currentScope();
|
|
4667
|
+
return scope !== void 0 && hasPermission(scope, "skill:manage");
|
|
4668
|
+
};
|
|
4371
4669
|
ctx.effect(() => () => aiTools.dispose(), "dataops-managed: skill and review tool disclosure");
|
|
4372
4670
|
/**
|
|
4373
4671
|
* Per-session disclosure.
|
|
@@ -114,6 +114,21 @@ export declare const AI_TOOL_ACCESS: {
|
|
|
114
114
|
readonly skill_delete: {
|
|
115
115
|
readonly permission: "skill:manage";
|
|
116
116
|
};
|
|
117
|
+
readonly skill_install_for_user: {
|
|
118
|
+
readonly permission: "skill:manage";
|
|
119
|
+
};
|
|
120
|
+
readonly department_skill_bind: {
|
|
121
|
+
readonly permission: "skill:manage";
|
|
122
|
+
};
|
|
123
|
+
readonly department_skill_unbind: {
|
|
124
|
+
readonly permission: "skill:manage";
|
|
125
|
+
};
|
|
126
|
+
readonly department_skill_apply: {
|
|
127
|
+
readonly permission: "skill:manage";
|
|
128
|
+
};
|
|
129
|
+
readonly department_skill_preview: {
|
|
130
|
+
readonly permission: "skill:manage";
|
|
131
|
+
};
|
|
117
132
|
readonly review_scan: {
|
|
118
133
|
readonly permission: "skill:read";
|
|
119
134
|
readonly reviewer: true;
|
package/package.json
CHANGED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: skill-provisioning
|
|
3
|
+
description: 给指定用户或部门批量分配技能时使用。先 preview 列出部门+子部门、受影响用户数、覆盖/冲突明细,得到用户明确确认后才 bind/apply;绑定只改配置,现有用户需 apply 才生效。仅超管、管理员与非超管的部门管理员可用。
|
|
4
|
+
metadata:
|
|
5
|
+
permissions:
|
|
6
|
+
- skill:manage
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# 技能分配(部门默认技能 / 指定用户安装)
|
|
10
|
+
|
|
11
|
+
用户说「把这个技能发给某个人 / 发给某部门」「给部门配默认技能」「批量装一下」时用本技能。
|
|
12
|
+
分配的是**别人**的工作区,不是你自己的;写操作一律先预览、再让用户明确确认。
|
|
13
|
+
|
|
14
|
+
## 一、工具与适用场景
|
|
15
|
+
|
|
16
|
+
| 工具 | 作用 | 是否写 |
|
|
17
|
+
|---|---|---|
|
|
18
|
+
| `department_skill_preview` | 预览部门+子部门、受影响用户数、用户列表、覆盖/冲突 | 只读 |
|
|
19
|
+
| `department_skill_bind` | 把技能设为部门默认(可禁用) | 写配置,不铺开 |
|
|
20
|
+
| `department_skill_unbind` | 移除部门默认绑定 | 写配置,不铺开 |
|
|
21
|
+
| `department_skill_apply` | 把当前绑定**执行一次**到部门/用户 | 写,逐用户生效 |
|
|
22
|
+
| `skill_install_for_user` | 给**指定用户**直接安装(可 overwrite) | 写,只影响这些用户 |
|
|
23
|
+
|
|
24
|
+
选择规则:
|
|
25
|
+
|
|
26
|
+
- 用户点名了具体人员 → `skill_install_for_user(skill_id, user_ids, overwrite?)`;
|
|
27
|
+
- 用户说的是「部门/团队默认要有什么」→ 先 `department_skill_bind`,确认后再 `department_skill_apply`;
|
|
28
|
+
- 只是调整部门默认、暂不影响任何人 → 只 bind/unbind,**不要**顺手 apply;
|
|
29
|
+
- 目标范围不清楚 → 先 `department_skill_preview`,或让用户给出部门 code / 用户 id。
|
|
30
|
+
|
|
31
|
+
## 二、强制顺序(不得跳步)
|
|
32
|
+
|
|
33
|
+
```text
|
|
34
|
+
preview(或用户给出明确人员名单 + skill_get 确认技能)
|
|
35
|
+
→ 把范围/人数/覆盖明细列给用户
|
|
36
|
+
→ 用户明确确认(“确认/执行/可以”)
|
|
37
|
+
→ bind / unbind / apply / install_for_user
|
|
38
|
+
→ 汇报逐用户结果
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
硬性要求:
|
|
42
|
+
|
|
43
|
+
1. **禁止未预览直接批量写**:任何部门级写操作(bind/unbind/apply)之前,必须先调用
|
|
44
|
+
`department_skill_preview`,并把「部门 + 子部门、受影响用户数、覆盖/跳过明细」列给用户。
|
|
45
|
+
只有一种例外:用户直接给出 userIds 且明确说「就这些人」,此时可用 `skill_get` 核对技能后
|
|
46
|
+
直接 `skill_install_for_user`,但仍要让用户确认名单。
|
|
47
|
+
2. **必须得到用户明确确认**:预览之后问一句「确认按这个范围执行吗?」,得到肯定答复才写。
|
|
48
|
+
用户沉默、改口、或只说「先看看」都不算确认。
|
|
49
|
+
3. `department_skill_apply` 还要求 `confirm=true`——这是工具层的第二道确认,不能替代
|
|
50
|
+
对话里的用户确认。
|
|
51
|
+
4. 一次只做一个范围。用户改范围就重新 preview,不要复用旧的预览结果。
|
|
52
|
+
|
|
53
|
+
## 三、部门默认技能:bind 与 apply 是两件事
|
|
54
|
+
|
|
55
|
+
- `department_skill_bind` / `department_skill_unbind` **只改配置**,不会自动影响现有用户;
|
|
56
|
+
- 现有用户要等 `department_skill_apply` 把部门/用户标记为待同步后,才会在工作区下次启动时
|
|
57
|
+
按绑定对齐(工作区正在运行时可立即 reconcile);
|
|
58
|
+
- 因此用户问「绑定后为什么没生效」时,先回答「还差一次 apply」,并先 preview 再执行;
|
|
59
|
+
- `include_descendants` 默认 true:父部门绑定会覆盖到子部门。执行前必须在预览里说明
|
|
60
|
+
「包含哪些子部门、共多少人」。
|
|
61
|
+
|
|
62
|
+
## 四、指定用户安装:只影响名单内的人
|
|
63
|
+
|
|
64
|
+
`skill_install_for_user` 的行为:
|
|
65
|
+
|
|
66
|
+
1. 只对 `user_ids` 里的用户生效,**不影响同部门其他人**;
|
|
67
|
+
2. 安装在该用户**下次打开工作区**时生效(运行中的工作区可能立即生效);
|
|
68
|
+
3. `overwrite=false`(默认)时,用户已装过同 key 技能则保持原样(状态 `unchanged`);
|
|
69
|
+
`overwrite=true` 才会覆盖(状态 `overwritten`),覆盖前要让用户知道会替换旧版本;
|
|
70
|
+
4. 返回 `results[]`,逐用户状态为 `installed | overwritten | unchanged | forbidden | failed`;
|
|
71
|
+
有 `forbidden/failed` 时如实汇报原因,不要只说「成功」。
|
|
72
|
+
|
|
73
|
+
## 五、权限范围(服务端每次都会校验)
|
|
74
|
+
|
|
75
|
+
| 身份 | 可操作范围 |
|
|
76
|
+
|---|---|
|
|
77
|
+
| 超级管理员 | 所有部门、所有用户 |
|
|
78
|
+
| 管理员(非超管) | 所有**非超管**用户;可管理部门绑定 |
|
|
79
|
+
| 部门管理员 / 持 `skill:manage` 者 | **本部门 + 所有子部门**,目标不能是超管 |
|
|
80
|
+
|
|
81
|
+
- 工具可见性只代表「你能发起」,最终范围由 DataOps 在每次调用时判定;被拒绝时把 403 原因
|
|
82
|
+
如实转述给用户,不要换身份重试、不要绕过工具直接调 HTTP。
|
|
83
|
+
- 目标用户不存在/停用会单条失败,其余用户继续;汇报时要区分「整体失败」与「单条失败」。
|
|
84
|
+
- 普通用户看不到这些工具;如果当前账号没有 `skill:manage`,说明没有分配权限,直接告知用户。
|
|
85
|
+
|
|
86
|
+
## 六、结果汇报
|
|
87
|
+
|
|
88
|
+
写操作完成后,按这个结构回复:
|
|
89
|
+
|
|
90
|
+
1. **做了什么**:技能名/ID、bind 还是 apply、目标部门(含子部门)或用户数;
|
|
91
|
+
2. **生效时间**:绑定只是配置;apply/install 在用户下次打开工作区时生效(运行中可能立即);
|
|
92
|
+
3. **逐用户结果**:`installed/overwritten/unchanged/forbidden/failed` 各多少,失败原因;
|
|
93
|
+
4. **未做的部分**:例如只 bind 未 apply、跳过的人、被拒绝的范围。
|
|
94
|
+
|
|
95
|
+
## 七、红线
|
|
96
|
+
|
|
97
|
+
- 不在未预览、未确认时批量写;
|
|
98
|
+
- 不把 `overwrite=true` 当默认值;覆盖别人已装的技能必须先说明;
|
|
99
|
+
- 不代替用户决定范围(「整个公司都装上」这类模糊指令必须先问清部门/名单);
|
|
100
|
+
- 不在回复里伪造逐用户结果;接口失败就报失败和错误信息;
|
|
101
|
+
- 不导出、不记录任何用户凭据;工具只接受用户 id / 部门 code / 技能 id。
|