weaver-work-cli 0.1.59 → 0.1.61
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/dist/chunks/{archive-4SQAVTIB.js → archive-S2VKZWQ3.js} +2 -2
- package/dist/chunks/{archive-oa-W2UEJ67L.js → archive-oa-HEDSIUUY.js} +2 -2
- package/dist/chunks/{asset-EGZEABBI.js → asset-HYH4W357.js} +2 -2
- package/dist/chunks/{asset-idle-EBUZBB6M.js → asset-idle-N7REBNGL.js} +2 -2
- package/dist/chunks/{attachment-content-TP6WDNC6.js → attachment-content-VYYA75FR.js} +3 -3
- package/dist/chunks/{blog-2YKMWOWI.js → blog-SLMZZICV.js} +2 -2
- package/dist/chunks/{caizhilian-5NM4X5HG.js → caizhilian-RV43KKBT.js} +4 -4
- package/dist/chunks/{calendar-H4QTJCUY.js → calendar-DMVZ4OLY.js} +2 -2
- package/dist/chunks/{chunk-QNPIY5R6.js → chunk-6XSSAUNW.js} +4 -4
- package/dist/chunks/{chunk-AQOPPNTR.js → chunk-BIA2NKUG.js} +4 -4
- package/dist/chunks/{chunk-VMCCRWFO.js → chunk-BQYX2UX5.js} +2 -2
- package/dist/chunks/{chunk-CI2RF3AJ.js → chunk-DTCQFTHW.js} +1 -1
- package/dist/chunks/{chunk-I3BFBBP2.js → chunk-E5YD5JWR.js} +1 -1
- package/dist/chunks/{chunk-PH7N4UFT.js → chunk-EGANE35F.js} +1 -1
- package/dist/chunks/{chunk-Z4IPY5GV.js → chunk-H6YOMI3U.js} +2 -2
- package/dist/chunks/{chunk-U2DWV6JC.js → chunk-ILALC2N6.js} +1 -1
- package/dist/chunks/{chunk-WINR2Q6K.js → chunk-KXJA42EA.js} +86 -19
- package/dist/chunks/{chunk-CQ4OVCKG.js → chunk-KY3R42RS.js} +2 -2
- package/dist/chunks/{chunk-WVH5ESDA.js → chunk-NRYDJN4J.js} +1 -1
- package/dist/chunks/{chunk-TGM7BWEH.js → chunk-P6TXQK75.js} +2 -2
- package/dist/chunks/{chunk-6YWHRXEQ.js → chunk-QBDXJS2W.js} +119 -9
- package/dist/chunks/{chunk-2IGZUMNG.js → chunk-SHX7XBYR.js} +180 -18
- package/dist/chunks/{chunk-XR5BGFNT.js → chunk-T2KVJFWJ.js} +10 -4
- package/dist/chunks/{chunk-FMNCSYIG.js → chunk-TEZHIB6T.js} +2 -2
- package/dist/chunks/{chunk-2FHP4PYS.js → chunk-UBGWIXU3.js} +116 -40
- package/dist/chunks/{chunk-5N222HK6.js → chunk-UBRWONP4.js} +2 -2
- package/dist/chunks/{chunk-MQBMMJUV.js → chunk-UQFPF4EX.js} +2 -2
- package/dist/chunks/{chunk-4GG72JAT.js → chunk-V2LASYKO.js} +2 -2
- package/dist/chunks/{chunk-FM7B5BIR.js → chunk-VBFBMM7G.js} +61 -53
- package/dist/chunks/{chunk-ZHPCNM2S.js → chunk-VNYOUAWV.js} +11 -11
- package/dist/chunks/{chunk-SFM3M2L3.js → chunk-WIWDVETN.js} +19 -3
- package/dist/chunks/{chunk-44KJ7WFA.js → chunk-XT77MP54.js} +2 -2
- package/dist/chunks/chunk-YI2YMW5N.js +111 -0
- package/dist/chunks/{conflict-Y3ESXYIA.js → conflict-GFJRS6I7.js} +2 -2
- package/dist/chunks/{contract-LLRKMLQQ.js → contract-U3ZGNRWB.js} +2 -2
- package/dist/chunks/{cowork-2RDFBZWB.js → cowork-EX7PKIDK.js} +2 -2
- package/dist/chunks/{create-flow-JHQSA6JF.js → create-flow-EJZD434E.js} +6 -6
- package/dist/chunks/{data-ZVS3BWPT.js → data-FOODGAMF.js} +278 -123
- package/dist/chunks/{ebuilder-form-TWSXS5NA.js → ebuilder-form-I2EOKODG.js} +5 -5
- package/dist/chunks/{ehr-52GBKNJR.js → ehr-TE4RFNID.js} +2 -2
- package/dist/chunks/entry-mode-ZOLSXEGX.js +19 -0
- package/dist/chunks/{env-LQBLL3MZ.js → env-TID5NFR6.js} +2 -2
- package/dist/chunks/{esb-HJSXCEOM.js → esb-7L6MHYLB.js} +4 -4
- package/dist/chunks/{factory-X7PN6B3B.js → factory-OG7BPMH5.js} +1 -1
- package/dist/chunks/{fna-OBACRT3J.js → fna-6V2ENR3Y.js} +2 -2
- package/dist/chunks/{group-chat-PPFY7SPV.js → group-chat-5DKPWIHL.js} +3 -3
- package/dist/chunks/{host-TTSGY5NZ.js → host-3DLYA54R.js} +3 -3
- package/dist/chunks/{host-KJT3G5D2.js → host-GOJHHTPY.js} +3 -3
- package/dist/chunks/{host-KOWUMNAY.js → host-OGBHL75G.js} +3 -3
- package/dist/chunks/{host-MFXRA2MY.js → host-ONZC6AE7.js} +3 -3
- package/dist/chunks/{host-W4JCNRFS.js → host-TJ5VVHM7.js} +3 -3
- package/dist/chunks/{host-2BKMPWDH.js → host-VTPAWDZV.js} +3 -3
- package/dist/chunks/{hrm-AK3WGBMN.js → hrm-2N7NFQDZ.js} +3 -3
- package/dist/chunks/{im-JZSBPO4Z.js → im-XCH47ZBN.js} +3 -3
- package/dist/chunks/{invoice-6XDMPCWB.js → invoice-XQRKMGNY.js} +3 -3
- package/dist/chunks/{jiuchuanhui-K4EQU6GK.js → jiuchuanhui-PL6DRPBM.js} +2 -2
- package/dist/chunks/{lazy-dispatch-GCA6HDOB.js → lazy-dispatch-UATEN7H7.js} +5 -5
- package/dist/chunks/{mail-IKVCQCVZ.js → mail-Q7Z4CQ4D.js} +2 -2
- package/dist/chunks/{meeting-GMRQZFJP.js → meeting-5E3BNARL.js} +13 -12
- package/dist/chunks/{minute-doc-JXH3MNC7.js → minute-doc-NXRE5C77.js} +4 -4
- package/dist/chunks/{okr-KV43FPPX.js → okr-3O3XNYOK.js} +2 -2
- package/dist/chunks/{operations-6NXJ7RTE.js → operations-EZWG72FH.js} +4 -4
- package/dist/chunks/performance-Y7CPNSOR.js +1295 -0
- package/dist/chunks/{plan-WOYR4WEG.js → plan-BLGPZF5M.js} +2 -2
- package/dist/chunks/{project-CQJKBUIL.js → project-6MZMLJMP.js} +2 -2
- package/dist/chunks/{reception-MPBU3JXC.js → reception-F2VT2X52.js} +2 -2
- package/dist/chunks/{recruit-stage-USTTRHOX.js → recruit-stage-4ETIBMIW.js} +2 -2
- package/dist/chunks/{registry-GURQG4ZV.js → registry-3FYSWV3U.js} +3 -3
- package/dist/chunks/{registry-SS5J2FZQ.js → registry-7RS74TCK.js} +4 -4
- package/dist/chunks/{registry-WZCCBI5L.js → registry-I4DVPDMU.js} +11 -10
- package/dist/chunks/{room-recommend-CKU5NF2E.js → room-recommend-GWCVKCXW.js} +4 -4
- package/dist/chunks/{schedule-DEFAO2RY.js → schedule-6AN63MJQ.js} +4 -4
- package/dist/chunks/{smart-extract-APX2PNIN.js → smart-extract-SR4SJJKN.js} +3 -3
- package/dist/chunks/{workflow-WMPW3WSB.js → workflow-KF7FA2UQ.js} +7 -7
- package/dist/cmd/refs/index.js +124 -4
- package/dist/core/output.js +199 -26
- package/dist/core/refs.js +36 -0
- package/dist/index.js +38 -33
- package/dist/internal/e10/auth/xiaoe.js +25 -3
- package/dist/shortcuts/caizhilian/operations/files.js +86 -15
- package/dist/shortcuts/data/index.js +12 -2
- package/dist/shortcuts/data/manifest.js +4 -2
- package/dist/shortcuts/data/operations/attribution.js +229 -0
- package/dist/shortcuts/data/operations/ds.js +87 -92
- package/dist/shortcuts/data/operations/index.js +3 -1
- package/dist/shortcuts/index.js +5 -0
- package/dist/shortcuts/meeting/operations/eb/create-flow.js +111 -12
- package/dist/shortcuts/meeting/operations/eb/entry-mode.js +116 -0
- package/dist/shortcuts/meeting/operations/eb/index.js +2 -0
- package/dist/shortcuts/meeting/operations/eb/room-recommend.js +11 -0
- package/dist/shortcuts/meeting/operations/registry.js +4 -0
- package/dist/shortcuts/performance/continuation.js +74 -0
- package/dist/shortcuts/performance/errors.js +65 -0
- package/dist/shortcuts/performance/host.js +105 -0
- package/dist/shortcuts/performance/index.js +109 -0
- package/dist/shortcuts/performance/manifest.js +30 -0
- package/dist/shortcuts/performance/operations/hrm-resolve.js +114 -0
- package/dist/shortcuts/performance/operations/registry.js +44 -0
- package/dist/shortcuts/performance/operations/scheme-detail.js +70 -0
- package/dist/shortcuts/performance/operations/scheme-draft.js +116 -0
- package/dist/shortcuts/performance/operations/scheme-publish.js +158 -0
- package/dist/shortcuts/performance/operations/types.js +32 -0
- package/dist/shortcuts/performance/scheme-validate.js +307 -0
- package/dist/shortcuts/performance/shared.js +158 -0
- package/docs/agent-io-channel-design.md +67 -3
- package/docs/data.md +2 -1
- package/package.json +1 -1
- package/scripts/xiaoe_env.py +6 -1
- package/skill-template/business-info.json +19 -0
- package/skill-template/domains/performance.md +18 -0
- package/skills/weaver-e10-caizhilian/SKILL.md +1 -1
- package/skills/weaver-e10-data/references/datasource.md +2 -1
- package/skills/weaver-e10-meeting/SKILL.md +16 -3
- package/skills/weaver-e10-performance/SKILL.md +202 -0
- package/skills/weaver-e10-performance/agents/openai.yaml +74 -0
- package/skills/weaver-e10-performance/references/default-assembly.md +108 -0
- package/skills/weaver-e10-performance/references/entity-resolution.md +69 -0
- package/skills/weaver-e10-performance/references/enums-and-normalization.md +80 -0
- package/skills/weaver-e10-performance/references/examples.md +146 -0
- package/skills/weaver-e10-performance/references/extraction-guide.md +144 -0
- package/skills/weaver-e10-performance/references/scheme-edit-req-fields.md +185 -0
- package/skills/weaver-e10-performance/references/scheme-setting-page.md +62 -0
- package/skills/weaver-e10-performance/scripts/parse_appraisal_doc.py +483 -0
- package/skills/weaver-e10-shared/references/json-output-contract.md +5 -0
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 建会入口选择:解决"流程工具已经问过、会议 skill 又问一遍"的重复询问,
|
|
3
|
+
* 并给"用户选择"加一次性令牌,防止模型自己填 entryMode 绕过入口询问。
|
|
4
|
+
*
|
|
5
|
+
* 谁先问谁落标记(按租户 + 登录人,10 分钟过期)。
|
|
6
|
+
*/
|
|
7
|
+
import { join, dirname } from 'node:path';
|
|
8
|
+
import { mkdirSync, readFileSync, writeFileSync } from 'node:fs';
|
|
9
|
+
import { createHmac, randomBytes, timingSafeEqual } from 'node:crypto';
|
|
10
|
+
import { meetingSuccess } from '../types.js';
|
|
11
|
+
import { meetingValidationError } from '../../errors.js';
|
|
12
|
+
import { meetingStateDir } from '../env.js';
|
|
13
|
+
const TTL_MS = 10 * 60 * 1000;
|
|
14
|
+
async function entryFile(env) {
|
|
15
|
+
const session = await env.host.getSession();
|
|
16
|
+
const scope = String(session?.tenantKey || session?.baseUrl || 'default').replace(/[^\w.-]+/g, '_');
|
|
17
|
+
return join(meetingStateDir(env.ctx), 'entry-' + scope + '.json');
|
|
18
|
+
}
|
|
19
|
+
/** 读当前会话的入口选择;过期或无记录返回 null。 */
|
|
20
|
+
export async function readEntryChoice(env) {
|
|
21
|
+
try {
|
|
22
|
+
const raw = JSON.parse(readFileSync(await entryFile(env), 'utf8'));
|
|
23
|
+
if (Date.now() - Number(raw?.at ?? 0) > TTL_MS)
|
|
24
|
+
return null;
|
|
25
|
+
const choice = String(raw?.choice ?? '').trim();
|
|
26
|
+
return choice ? { choice, at: Number(raw.at), source: raw?.source } : null;
|
|
27
|
+
}
|
|
28
|
+
catch {
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
/** 令牌密钥:本机一次性生成,落 state 目录。 */
|
|
33
|
+
async function tokenSecret(env) {
|
|
34
|
+
const file = join(meetingStateDir(env.ctx), 'entry-secret');
|
|
35
|
+
try {
|
|
36
|
+
const value = readFileSync(file, 'utf8').trim();
|
|
37
|
+
if (value.length >= 32)
|
|
38
|
+
return value;
|
|
39
|
+
}
|
|
40
|
+
catch {
|
|
41
|
+
// 首次:生成并落盘
|
|
42
|
+
}
|
|
43
|
+
const secret = randomBytes(32).toString('hex');
|
|
44
|
+
mkdirSync(dirname(file), { recursive: true });
|
|
45
|
+
writeFileSync(file, secret, 'utf8');
|
|
46
|
+
return secret;
|
|
47
|
+
}
|
|
48
|
+
async function tokenUser(env) {
|
|
49
|
+
try {
|
|
50
|
+
const session = await env.host.getSession();
|
|
51
|
+
return String(session?.userId ?? '');
|
|
52
|
+
}
|
|
53
|
+
catch {
|
|
54
|
+
return '';
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
async function signToken(env, choice, ts) {
|
|
58
|
+
const secret = await tokenSecret(env);
|
|
59
|
+
const user = await tokenUser(env);
|
|
60
|
+
const payload = choice + '.' + ts + '.' + user;
|
|
61
|
+
return createHmac('sha256', secret).update(payload).digest('hex').slice(0, 32);
|
|
62
|
+
}
|
|
63
|
+
/** 生成入口令牌(随选项 value 下发,下一轮原样回传才有效)。 */
|
|
64
|
+
export async function createEntryToken(env, choice) {
|
|
65
|
+
const ts = Date.now();
|
|
66
|
+
return choice + '.' + ts + '.' + (await signToken(env, choice, ts));
|
|
67
|
+
}
|
|
68
|
+
/** 校验入口令牌:选择项一致、未过期、签名匹配。 */
|
|
69
|
+
export async function verifyEntryToken(env, token, choice) {
|
|
70
|
+
const parts = String(token ?? '').split('.');
|
|
71
|
+
if (parts.length !== 3)
|
|
72
|
+
return false;
|
|
73
|
+
const [tokenChoice, tsRaw, sig] = parts;
|
|
74
|
+
if (tokenChoice !== choice)
|
|
75
|
+
return false;
|
|
76
|
+
const ts = Number(tsRaw);
|
|
77
|
+
if (!Number.isFinite(ts) || Date.now() - ts > TTL_MS)
|
|
78
|
+
return false;
|
|
79
|
+
const expected = await signToken(env, choice, ts);
|
|
80
|
+
try {
|
|
81
|
+
return timingSafeEqual(Buffer.from(sig), Buffer.from(expected));
|
|
82
|
+
}
|
|
83
|
+
catch {
|
|
84
|
+
return false;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
const record = {
|
|
88
|
+
name: 'meeting.entry.record',
|
|
89
|
+
resource: 'eb',
|
|
90
|
+
method: 'meeting.entry.record',
|
|
91
|
+
action: 'meeting.entry.record',
|
|
92
|
+
summary: '记录建会入口选择(assist / direct_form),供 create.flow.* 判断是否还要弹入口选项',
|
|
93
|
+
capability: 'eb.meeting',
|
|
94
|
+
risk: 'read-before-write',
|
|
95
|
+
requiresConfirmation: false,
|
|
96
|
+
inputSchema: {
|
|
97
|
+
type: 'object',
|
|
98
|
+
additionalProperties: false,
|
|
99
|
+
properties: {
|
|
100
|
+
choice: { type: 'string', enum: ['assist', 'direct_form'] },
|
|
101
|
+
source: { type: 'string', description: '谁问的:flow_tool / meeting_skill' },
|
|
102
|
+
},
|
|
103
|
+
required: ['choice'],
|
|
104
|
+
},
|
|
105
|
+
handler: async (args, env) => {
|
|
106
|
+
const choice = String(args.choice ?? '').trim();
|
|
107
|
+
if (choice !== 'assist' && choice !== 'direct_form') {
|
|
108
|
+
throw meetingValidationError('invalid_choice', 'choice 只能是 assist 或 direct_form');
|
|
109
|
+
}
|
|
110
|
+
const file = await entryFile(env);
|
|
111
|
+
mkdirSync(dirname(file), { recursive: true });
|
|
112
|
+
writeFileSync(file, JSON.stringify({ choice, at: Date.now(), source: String(args.source ?? '') }), 'utf8');
|
|
113
|
+
return meetingSuccess('meeting.entry.record', { recorded: choice, ttlSeconds: TTL_MS / 1000 });
|
|
114
|
+
},
|
|
115
|
+
};
|
|
116
|
+
export const meetingEntryOperations = [record];
|
|
@@ -12,6 +12,7 @@ import { meetingEbGroupChatOperations } from './group-chat.js';
|
|
|
12
12
|
import { attachMeetingUrls } from './meeting-link.js';
|
|
13
13
|
import { meetingEbDecisionTaskBatchOperations } from './decision-task-batch.js';
|
|
14
14
|
import { meetingEbDecisionTaskReassignOperations } from './decision-task-reassign.js';
|
|
15
|
+
import { meetingEntryOperations } from './entry-mode.js';
|
|
15
16
|
/**
|
|
16
17
|
* 会议 EB 版(eBuilder)operations。
|
|
17
18
|
*
|
|
@@ -299,6 +300,7 @@ export const meetingEbOperations = [
|
|
|
299
300
|
...minuteCreateAliases,
|
|
300
301
|
...meetingEbDecisionTaskBatchOperations,
|
|
301
302
|
...meetingEbDecisionTaskReassignOperations,
|
|
303
|
+
...meetingEntryOperations,
|
|
302
304
|
...meetingEbScheduleOperations,
|
|
303
305
|
...meetingEbCrmOperations,
|
|
304
306
|
...meetingEbCreateFlowOperations,
|
|
@@ -248,6 +248,8 @@ export async function recommendRooms(env, input) {
|
|
|
248
248
|
const usable = roomData.rooms.filter((room) => room.status === '0');
|
|
249
249
|
let busyCount = 0;
|
|
250
250
|
const candidates = [];
|
|
251
|
+
/** 描述/名称命中「接待」定位的房间 id:带客户时作为硬筛选池,而不是加分项。 */
|
|
252
|
+
const purposeHitIds = new Set();
|
|
251
253
|
for (const room of usable) {
|
|
252
254
|
const isBusy = busy.ids.has(room.id);
|
|
253
255
|
if (isBusy) {
|
|
@@ -316,6 +318,8 @@ export async function recommendRooms(env, input) {
|
|
|
316
318
|
if (hostHit) {
|
|
317
319
|
reasons.push(`带客户优先:${descHit ? `描述含「${desc.slice(0, 30)}」` : `名称含「${hostHit[1]}」`}`);
|
|
318
320
|
score += 35;
|
|
321
|
+
if (!isBusy)
|
|
322
|
+
purposeHitIds.add(room.id);
|
|
319
323
|
}
|
|
320
324
|
}
|
|
321
325
|
if (isBusy) {
|
|
@@ -339,6 +343,13 @@ export async function recommendRooms(env, input) {
|
|
|
339
343
|
reasons,
|
|
340
344
|
});
|
|
341
345
|
}
|
|
346
|
+
// 定位优先(带客户场景):只要库里有「接待」定位的房间,就只在这些房间里排序。
|
|
347
|
+
// 常规/容量分再高也不能顶掉定位,否则会把客户安排到普通茶室。
|
|
348
|
+
if (requirement.hasCustomer === true && purposeHitIds.size > 0) {
|
|
349
|
+
const preferred = candidates.filter((candidate) => purposeHitIds.has(candidate.id));
|
|
350
|
+
if (preferred.length > 0)
|
|
351
|
+
candidates.splice(0, candidates.length, ...preferred);
|
|
352
|
+
}
|
|
342
353
|
candidates.sort((left, right) => {
|
|
343
354
|
if (right.score !== left.score)
|
|
344
355
|
return right.score - left.score;
|
|
@@ -66,6 +66,10 @@ function buildRegistry() {
|
|
|
66
66
|
handler: async (args, env) => {
|
|
67
67
|
const startedAt = Date.now();
|
|
68
68
|
const result = await original(args, env);
|
|
69
|
+
const entryResolved = env?.__entryResolved;
|
|
70
|
+
if (entryResolved && result && typeof result === 'object') {
|
|
71
|
+
result.data = { ...(result.data ?? {}), entryResolved };
|
|
72
|
+
}
|
|
69
73
|
if (args?.debugTimings === true && result && typeof result === 'object') {
|
|
70
74
|
const marks = { ...(env?.__meetingTimings ?? {}) };
|
|
71
75
|
result.data = { ...(result.data ?? {}), timings: { ...marks, totalMs: Date.now() - startedAt } };
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { CONTINUATION_TTL_MS } from '../../core/continuation-ttl.js';
|
|
2
|
+
import { createHmac, randomBytes, timingSafeEqual } from 'node:crypto';
|
|
3
|
+
import { existsSync } from 'node:fs';
|
|
4
|
+
import { chmod, mkdir, readFile, writeFile } from 'node:fs/promises';
|
|
5
|
+
import { homedir } from 'node:os';
|
|
6
|
+
import { resolve } from 'node:path';
|
|
7
|
+
import { pfValidationError } from './errors.js';
|
|
8
|
+
function stateRoot(ctx) {
|
|
9
|
+
const configured = ctx?.config?.path();
|
|
10
|
+
if (configured)
|
|
11
|
+
return resolve(configured, '..');
|
|
12
|
+
return process.env.WEAVER_WORK_CLI_HOME || process.env.WORK_CLI_HOME || resolve(homedir(), '.weaver-work-cli');
|
|
13
|
+
}
|
|
14
|
+
async function loadKey(ctx) {
|
|
15
|
+
const keysDir = resolve(stateRoot(ctx), 'keys');
|
|
16
|
+
const filename = resolve(keysDir, 'performance-continuation.key');
|
|
17
|
+
await mkdir(keysDir, { recursive: true, mode: 0o700 });
|
|
18
|
+
if (existsSync(filename))
|
|
19
|
+
return readFile(filename);
|
|
20
|
+
const key = randomBytes(32);
|
|
21
|
+
try {
|
|
22
|
+
await writeFile(filename, key, { flag: 'wx', mode: 0o600 });
|
|
23
|
+
if (process.platform !== 'win32')
|
|
24
|
+
await chmod(filename, 0o600).catch(() => undefined);
|
|
25
|
+
return key;
|
|
26
|
+
}
|
|
27
|
+
catch {
|
|
28
|
+
return readFile(filename);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
function encode(value) {
|
|
32
|
+
return Buffer.from(JSON.stringify(value)).toString('base64url');
|
|
33
|
+
}
|
|
34
|
+
function signature(payload, key) {
|
|
35
|
+
return createHmac('sha256', key).update(payload).digest('base64url');
|
|
36
|
+
}
|
|
37
|
+
export function createPerformanceContinuationSigner(ctx) {
|
|
38
|
+
return {
|
|
39
|
+
async issue(payload, ttlMs = CONTINUATION_TTL_MS) {
|
|
40
|
+
const issuedAt = Date.now();
|
|
41
|
+
const body = encode({ ...payload, issuedAt, expiresAt: issuedAt + ttlMs });
|
|
42
|
+
const sig = signature(body, await loadKey(ctx));
|
|
43
|
+
return `${body}.${sig}`;
|
|
44
|
+
},
|
|
45
|
+
async verify(token, expectedOperation) {
|
|
46
|
+
if (typeof token !== 'string' || !token.includes('.')) {
|
|
47
|
+
throw pfValidationError('continuation_invalid', 'continuation 无效');
|
|
48
|
+
}
|
|
49
|
+
const [body, provided] = token.split('.');
|
|
50
|
+
const expected = signature(body, await loadKey(ctx));
|
|
51
|
+
const valid = provided.length === expected.length
|
|
52
|
+
&& timingSafeEqual(Buffer.from(provided), Buffer.from(expected));
|
|
53
|
+
if (!valid)
|
|
54
|
+
throw pfValidationError('continuation_invalid', 'continuation 签名校验失败');
|
|
55
|
+
let payload;
|
|
56
|
+
try {
|
|
57
|
+
payload = JSON.parse(Buffer.from(body, 'base64url').toString('utf8'));
|
|
58
|
+
}
|
|
59
|
+
catch {
|
|
60
|
+
throw pfValidationError('continuation_invalid', 'continuation 载荷解析失败');
|
|
61
|
+
}
|
|
62
|
+
if (!payload || typeof payload !== 'object') {
|
|
63
|
+
throw pfValidationError('continuation_invalid', 'continuation 载荷必须是对象');
|
|
64
|
+
}
|
|
65
|
+
if (typeof payload.expiresAt === 'number' && Date.now() > payload.expiresAt) {
|
|
66
|
+
throw pfValidationError('continuation_expired', 'continuation 已过期,请重新 prepare');
|
|
67
|
+
}
|
|
68
|
+
if (payload.operation && String(payload.operation) !== String(expectedOperation)) {
|
|
69
|
+
throw pfValidationError('continuation_operation_mismatch', `continuation 属于操作 ${String(payload.operation)},不能用于 ${expectedOperation}`);
|
|
70
|
+
}
|
|
71
|
+
return payload;
|
|
72
|
+
},
|
|
73
|
+
};
|
|
74
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { CliError, ExitCode } from '../../core/errors.js';
|
|
2
|
+
/**
|
|
3
|
+
* performance 模块错误类型。
|
|
4
|
+
* 形态与 recruit-stage 模块一致(type/subtype/details/partialData),
|
|
5
|
+
* 前缀 pf 避免与其他模块的错误类型混淆。
|
|
6
|
+
*/
|
|
7
|
+
export class PerformanceCliError extends CliError {
|
|
8
|
+
type;
|
|
9
|
+
subtype;
|
|
10
|
+
code;
|
|
11
|
+
retryable;
|
|
12
|
+
stage;
|
|
13
|
+
details;
|
|
14
|
+
partialData;
|
|
15
|
+
constructor(type, subtype, message, options = {}) {
|
|
16
|
+
super(message, options.exitCode ?? ExitCode.InternalError);
|
|
17
|
+
this.name = 'PerformanceCliError';
|
|
18
|
+
this.type = type;
|
|
19
|
+
this.subtype = subtype;
|
|
20
|
+
this.code = options.code;
|
|
21
|
+
this.retryable = options.retryable ?? false;
|
|
22
|
+
this.stage = options.stage;
|
|
23
|
+
this.details = options.details;
|
|
24
|
+
this.partialData = options.partialData;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
export function pfValidationError(subtype, message, details) {
|
|
28
|
+
return new PerformanceCliError('validation', subtype, message, {
|
|
29
|
+
details,
|
|
30
|
+
exitCode: ExitCode.UsageError,
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
export function pfAuthError(subtype, message, details) {
|
|
34
|
+
return new PerformanceCliError('authentication', subtype, message, {
|
|
35
|
+
details,
|
|
36
|
+
exitCode: ExitCode.AuthError,
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
export function pfNetworkError(subtype, message, options = {}) {
|
|
40
|
+
return new PerformanceCliError('network', subtype, message, {
|
|
41
|
+
...options,
|
|
42
|
+
retryable: options.retryable ?? true,
|
|
43
|
+
exitCode: ExitCode.NetworkError,
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
export function pfConfirmationError(action, details) {
|
|
47
|
+
return new PerformanceCliError('confirmation', 'required', '该操作需要明确确认', {
|
|
48
|
+
details: { action, ...details },
|
|
49
|
+
exitCode: ExitCode.ConfirmationRequired,
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
/** 业务失败(接口 status/fail/code 判定失败的主通道)。 */
|
|
53
|
+
export function pfFail(message, details) {
|
|
54
|
+
return new PerformanceCliError('api', 'business_error', message, {
|
|
55
|
+
details,
|
|
56
|
+
exitCode: ExitCode.GeneralError,
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
export function pfPartialError(message, partialData, details) {
|
|
60
|
+
return new PerformanceCliError('partial', 'write_uncertain', message, {
|
|
61
|
+
details,
|
|
62
|
+
partialData,
|
|
63
|
+
exitCode: ExitCode.Partial,
|
|
64
|
+
});
|
|
65
|
+
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { E10_SESSION_EXPIRED_MESSAGE } from '../../internal/e10/auth/messages.js';
|
|
2
|
+
import { requireE10Session } from '../../internal/e10/context.js';
|
|
3
|
+
import { getActiveProfile } from '../../internal/e10/auth/session.js';
|
|
4
|
+
import { E10ApiError, createE10RequestRuntime } from '../../internal/e10/request-runtime.js';
|
|
5
|
+
import { isE10SessionExpiredResponse } from '../../internal/e10/auth-recovery.js';
|
|
6
|
+
import { pfAuthError, pfNetworkError, PerformanceCliError, pfValidationError } from './errors.js';
|
|
7
|
+
function inferProfile(ctx) {
|
|
8
|
+
const options = ctx.getGlobalOptions();
|
|
9
|
+
return options.profile || getActiveProfile();
|
|
10
|
+
}
|
|
11
|
+
export function assertPath(requestPath) {
|
|
12
|
+
if (typeof requestPath !== 'string' || !requestPath.startsWith('/') || requestPath.startsWith('//')) {
|
|
13
|
+
throw pfValidationError('path_invalid', '请求路径必须是相对绝对路径');
|
|
14
|
+
}
|
|
15
|
+
if (/^https?:/i.test(requestPath) || /[\r\n]/.test(requestPath) || requestPath.includes('/../')) {
|
|
16
|
+
throw pfValidationError('path_invalid', '请求路径不允许跨域或路径逃逸');
|
|
17
|
+
}
|
|
18
|
+
if (!requestPath.startsWith('/api/')) {
|
|
19
|
+
throw pfValidationError('path_not_allowed', '只能调用 /api/ 路径');
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* 绩效方案接口(/api/workrelate/performance/*)统一返回 WeaResult(code/msg/status/fail/data),
|
|
24
|
+
* 本 host 不做业务成功判定,业务判定在各 operation 内统一走 assertWeaResult。
|
|
25
|
+
*/
|
|
26
|
+
export function createPerformanceHost(ctx, dependencies = {}) {
|
|
27
|
+
let e10Session = null;
|
|
28
|
+
let sessionContext = null;
|
|
29
|
+
const requireSession = dependencies.requireSession
|
|
30
|
+
|| ((innerCtx) => requireE10Session(innerCtx, { skipProfileEnrichment: true }));
|
|
31
|
+
async function ensureSession() {
|
|
32
|
+
if (!e10Session) {
|
|
33
|
+
e10Session = await requireSession(ctx);
|
|
34
|
+
sessionContext = {
|
|
35
|
+
baseUrl: e10Session.getBaseUrl(),
|
|
36
|
+
profile: inferProfile(ctx),
|
|
37
|
+
userId: e10Session.userId,
|
|
38
|
+
tenantKey: e10Session.tenantKey,
|
|
39
|
+
eteamsId: e10Session.eteamsId,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
return e10Session;
|
|
43
|
+
}
|
|
44
|
+
async function getSession() {
|
|
45
|
+
await ensureSession();
|
|
46
|
+
return sessionContext;
|
|
47
|
+
}
|
|
48
|
+
async function runtime() {
|
|
49
|
+
return createE10RequestRuntime(ctx, await ensureSession(), {
|
|
50
|
+
interceptors: dependencies.interceptors,
|
|
51
|
+
fetch: dependencies.fetch,
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
async function request(request) {
|
|
55
|
+
const { method, path, query, body, operation, headers: extraHeaders = {}, timeoutMs = 30_000, } = request;
|
|
56
|
+
assertPath(path);
|
|
57
|
+
const resolvedMethod = method || (body === undefined ? 'GET' : 'POST');
|
|
58
|
+
let response;
|
|
59
|
+
try {
|
|
60
|
+
response = await (await runtime()).requestJson({
|
|
61
|
+
module: 'performance',
|
|
62
|
+
operation,
|
|
63
|
+
method: resolvedMethod,
|
|
64
|
+
path,
|
|
65
|
+
query,
|
|
66
|
+
body,
|
|
67
|
+
headers: { 'X-Requested-With': 'XMLHttpRequest', ...extraHeaders },
|
|
68
|
+
timeoutMs,
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
catch (error) {
|
|
72
|
+
if (error instanceof E10ApiError && error.type === 'network') {
|
|
73
|
+
throw pfNetworkError(error.subtype, error.message, {
|
|
74
|
+
retryable: error.retryable,
|
|
75
|
+
details: error.details,
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
throw error;
|
|
79
|
+
}
|
|
80
|
+
if (isE10SessionExpiredResponse(response)) {
|
|
81
|
+
throw pfAuthError('session_expired', E10_SESSION_EXPIRED_MESSAGE, { httpStatus: response.status });
|
|
82
|
+
}
|
|
83
|
+
if (response.parseError) {
|
|
84
|
+
if (response.status < 200 || response.status >= 300) {
|
|
85
|
+
throw new PerformanceCliError('api', 'http_error', `泛微接口 HTTP ${response.status}`, {
|
|
86
|
+
code: response.status,
|
|
87
|
+
details: { status: response.status },
|
|
88
|
+
exitCode: 1,
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
throw pfNetworkError('protocol', `接口返回不是合法 JSON(HTTP ${response.status})`, { retryable: false });
|
|
92
|
+
}
|
|
93
|
+
if (response.status < 200 || response.status >= 300) {
|
|
94
|
+
throw new PerformanceCliError('api', 'http_error', `泛微接口 HTTP ${response.status}`, {
|
|
95
|
+
code: response.status,
|
|
96
|
+
details: { status: response.status, message: response.value?.msg },
|
|
97
|
+
exitCode: 1,
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
// 运行时对响应做了 parseJsonPreservingBigInts(16+ 位整数加引号保精度),
|
|
101
|
+
// 业务代码拿到的长 id 已是字符串形态。
|
|
102
|
+
return response.value;
|
|
103
|
+
}
|
|
104
|
+
return { request, getSession };
|
|
105
|
+
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { readFile } from 'node:fs/promises';
|
|
2
|
+
import { ExitCode, isCliError, toErrorEnvelope } from '../../core/errors.js';
|
|
3
|
+
import { createPerformanceContinuationSigner } from './continuation.js';
|
|
4
|
+
import { createPerformanceHost } from './host.js';
|
|
5
|
+
import { performanceManifest } from './manifest.js';
|
|
6
|
+
import { executePerformanceOperation } from './operations/registry.js';
|
|
7
|
+
import { pfValidationError } from './errors.js';
|
|
8
|
+
function asOptions(value) {
|
|
9
|
+
return value && typeof value === 'object' && !Array.isArray(value) ? value : {};
|
|
10
|
+
}
|
|
11
|
+
async function readStdin() {
|
|
12
|
+
const chunks = [];
|
|
13
|
+
for await (const chunk of process.stdin) {
|
|
14
|
+
chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk));
|
|
15
|
+
}
|
|
16
|
+
return Buffer.concat(chunks).toString('utf8');
|
|
17
|
+
}
|
|
18
|
+
/** Windows PowerShell 管道可能写入 UTF-8 BOM,JSON.parse 不接受前导 BOM,先剥离。 */
|
|
19
|
+
function stripBom(value) {
|
|
20
|
+
return value.replace(/^\uFEFF+/, '');
|
|
21
|
+
}
|
|
22
|
+
async function inputFrom(options) {
|
|
23
|
+
const opts = asOptions(options);
|
|
24
|
+
let input = {};
|
|
25
|
+
if (opts.input && opts.inputJson) {
|
|
26
|
+
throw pfValidationError('input_conflict', '不能同时传 --input 和 --input-json');
|
|
27
|
+
}
|
|
28
|
+
if (opts.inputJson) {
|
|
29
|
+
input = parseJsonInput(String(opts.inputJson), '--input-json');
|
|
30
|
+
}
|
|
31
|
+
if (opts.input) {
|
|
32
|
+
let raw;
|
|
33
|
+
try {
|
|
34
|
+
raw = stripBom(opts.input === '-' ? await readStdin() : await readFile(String(opts.input), 'utf8'));
|
|
35
|
+
}
|
|
36
|
+
catch {
|
|
37
|
+
throw pfValidationError('input_unreadable', `无法读取 --input:${String(opts.input)}`);
|
|
38
|
+
}
|
|
39
|
+
input = parseJsonInput(raw, '--input');
|
|
40
|
+
}
|
|
41
|
+
return input;
|
|
42
|
+
}
|
|
43
|
+
function parseJsonInput(raw, label) {
|
|
44
|
+
try {
|
|
45
|
+
const parsed = JSON.parse(stripBom(raw));
|
|
46
|
+
if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) {
|
|
47
|
+
throw new Error('input must be an object');
|
|
48
|
+
}
|
|
49
|
+
return parsed;
|
|
50
|
+
}
|
|
51
|
+
catch {
|
|
52
|
+
throw pfValidationError('input_invalid', `${label} 不是合法 JSON 对象`);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
export function successEnvelope(operation, result) {
|
|
56
|
+
return {
|
|
57
|
+
schemaVersion: 1,
|
|
58
|
+
ok: true,
|
|
59
|
+
operation,
|
|
60
|
+
data: result.data === undefined ? null : result.data,
|
|
61
|
+
...(result.meta ? { meta: result.meta } : {}),
|
|
62
|
+
warnings: [],
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
function failureEnvelope(error) {
|
|
66
|
+
const structured = error;
|
|
67
|
+
return {
|
|
68
|
+
schemaVersion: 1,
|
|
69
|
+
ok: false,
|
|
70
|
+
...(structured?.partialData === undefined ? {} : { data: structured.partialData }),
|
|
71
|
+
error: toErrorEnvelope(error),
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
async function executeAndPrint(ctx, operation, input) {
|
|
75
|
+
try {
|
|
76
|
+
const host = createPerformanceHost(ctx);
|
|
77
|
+
const result = await executePerformanceOperation(operation, input, {
|
|
78
|
+
ctx,
|
|
79
|
+
host,
|
|
80
|
+
continuation: createPerformanceContinuationSigner(ctx),
|
|
81
|
+
});
|
|
82
|
+
ctx.output.write(successEnvelope(operation, result), { json: true });
|
|
83
|
+
}
|
|
84
|
+
catch (error) {
|
|
85
|
+
console.error(JSON.stringify(failureEnvelope(error), null, 2));
|
|
86
|
+
process.exitCode = isCliError(error) ? error.exitCode : ExitCode.GeneralError;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
export const performanceShortcut = {
|
|
90
|
+
name: 'performance',
|
|
91
|
+
description: '泛微E10绩效方案(文档导入 → 草稿 → 确认发布)CLI',
|
|
92
|
+
category: 'shortcut',
|
|
93
|
+
register({ program, action }) {
|
|
94
|
+
const pf = program.command('performance').description('泛微E10绩效方案(实体解析/落草稿/回读核对/确认发布)');
|
|
95
|
+
pf.command('schema')
|
|
96
|
+
.description('Print performance operation manifest for agents')
|
|
97
|
+
.action(action((ctx) => {
|
|
98
|
+
ctx.output.write(performanceManifest, { json: true });
|
|
99
|
+
}));
|
|
100
|
+
pf.command('run')
|
|
101
|
+
.description('Run a performance operation with JSON input')
|
|
102
|
+
.argument('<operation>', 'operation name, e.g. performance.scheme.draft.prepare')
|
|
103
|
+
.option('--input <path>', 'JSON input file, or - for stdin')
|
|
104
|
+
.option('--input-json <json>', 'inline JSON input object')
|
|
105
|
+
.action(action(async (ctx, operation, options) => {
|
|
106
|
+
await executeAndPrint(ctx, String(operation), await inputFrom(options));
|
|
107
|
+
}));
|
|
108
|
+
},
|
|
109
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { performanceOperationDefinitions } from './operations/registry.js';
|
|
2
|
+
/**
|
|
3
|
+
* 绩效方案(performance)模块清单。
|
|
4
|
+
* 面向「绩效考核文档 → 绩效方案」场景:实体解析 → 落草稿 → 回读核对 → 确认后发布。
|
|
5
|
+
* 文档解析(docx/xlsx/pdf → 结构化字段)保留在 Agent Skill 侧(scripts/parse_appraisal_doc.py),
|
|
6
|
+
* CLI 只承载需要登录态与写门禁的系统交互。
|
|
7
|
+
*/
|
|
8
|
+
function buildOperations() {
|
|
9
|
+
return performanceOperationDefinitions().map((definition) => ({
|
|
10
|
+
name: definition.name,
|
|
11
|
+
resource: definition.resource,
|
|
12
|
+
summary: definition.summary,
|
|
13
|
+
...(definition.capability ? { capability: definition.capability } : {}),
|
|
14
|
+
risk: definition.risk,
|
|
15
|
+
...(definition.requiresConfirmation ? { requiresConfirmation: true } : {}),
|
|
16
|
+
inputSchema: definition.inputSchema,
|
|
17
|
+
}));
|
|
18
|
+
}
|
|
19
|
+
export const performanceManifest = {
|
|
20
|
+
schemaVersion: 1,
|
|
21
|
+
name: 'performance',
|
|
22
|
+
title: '泛微E10绩效方案(文档导入 → 草稿 → 确认发布)',
|
|
23
|
+
version: '0.1.0',
|
|
24
|
+
host: 'e10-performance',
|
|
25
|
+
status: 'builtin',
|
|
26
|
+
sourceSkill: 'weaver-e10-performance',
|
|
27
|
+
capabilities: ['performance.hrm.resolve', 'performance.scheme.detail', 'performance.scheme.draft', 'performance.scheme.publish'],
|
|
28
|
+
operations: buildOperations(),
|
|
29
|
+
withheldOperations: [],
|
|
30
|
+
};
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { pfValidationError } from '../errors.js';
|
|
2
|
+
import { pfSuccess, schemaOf } from './types.js';
|
|
3
|
+
/** 实体类型 → 浏览器接口路径 + 建议 targetType(契约见 api-hrm-search.md,2026-10-28 实测)。 */
|
|
4
|
+
const ENTITY_TYPES = {
|
|
5
|
+
resource: {
|
|
6
|
+
path: '/api/hrm/common/browser/complete/resource',
|
|
7
|
+
label: '人员',
|
|
8
|
+
targetTypes: [{ targetType: 1, when: '考核对象或具名评分人(fixedMan 的 operater)' }],
|
|
9
|
+
body: {
|
|
10
|
+
browserMultiple: true,
|
|
11
|
+
authWecahtBook: false,
|
|
12
|
+
wxDepNeedConvertCount: 0,
|
|
13
|
+
wxEmpNeedConvertCount: 0,
|
|
14
|
+
wxTotalNeedConvertCount: 0,
|
|
15
|
+
hideParttime: true,
|
|
16
|
+
newly: 0,
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
department: {
|
|
20
|
+
path: '/api/hrm/common/browser/complete/department',
|
|
21
|
+
label: '部门',
|
|
22
|
+
targetTypes: [
|
|
23
|
+
{ targetType: 2, when: '仅本部门' },
|
|
24
|
+
{ targetType: 3, when: '「含下级/含子部门」' },
|
|
25
|
+
],
|
|
26
|
+
body: { browserMultiple: true, virtualType: 'ALL', newly: 0 },
|
|
27
|
+
},
|
|
28
|
+
subcompany: {
|
|
29
|
+
path: '/api/hrm/common/browser/complete/subcompany',
|
|
30
|
+
label: '分部',
|
|
31
|
+
targetTypes: [
|
|
32
|
+
{ targetType: 5, when: '仅本分部' },
|
|
33
|
+
{ targetType: 6, when: '「含下级」' },
|
|
34
|
+
],
|
|
35
|
+
body: { browserMultiple: true, virtualType: 'ALL', newly: 0 },
|
|
36
|
+
},
|
|
37
|
+
role: {
|
|
38
|
+
path: '/api/hrm/common/browser/complete/role',
|
|
39
|
+
label: '角色',
|
|
40
|
+
targetTypes: [{ targetType: 10, when: '角色(还需向用户确认 role_level 角色级别)' }],
|
|
41
|
+
body: { browserMultiple: true, newly: 0 },
|
|
42
|
+
},
|
|
43
|
+
position: {
|
|
44
|
+
path: '/api/hrm/common/browser/complete/position',
|
|
45
|
+
label: '岗位',
|
|
46
|
+
targetTypes: [
|
|
47
|
+
{ targetType: 12, when: '岗位+指定部门(文档写明具体部门)' },
|
|
48
|
+
{ targetType: 13, when: '岗位+指定分部(文档写明具体分部)' },
|
|
49
|
+
{ targetType: 1311, when: '岗位+总部(默认,不限范围时用这个)' },
|
|
50
|
+
],
|
|
51
|
+
body: { browserMultiple: true, newly: 0 },
|
|
52
|
+
},
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* hrm.resolve:按关键字搜索组织实体(人员/部门/分部/角色/岗位五合一个命令)。
|
|
56
|
+
* 搜索是模糊匹配;调用方应根据业务用途处理同名候选。
|
|
57
|
+
*/
|
|
58
|
+
async function resolve(args, env) {
|
|
59
|
+
const entityType = String(args.entityType || '');
|
|
60
|
+
const spec = ENTITY_TYPES[entityType];
|
|
61
|
+
if (!spec) {
|
|
62
|
+
throw pfValidationError('entity_type_unknown', `不支持的实体类型:${entityType || '(空)'}。支持:${Object.keys(ENTITY_TYPES).join('/')}`, {
|
|
63
|
+
supported: Object.keys(ENTITY_TYPES),
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
const keyword = String(args.keyword ?? '').trim();
|
|
67
|
+
if (!keyword) {
|
|
68
|
+
throw pfValidationError('keyword_missing', '缺少搜索关键字 keyword');
|
|
69
|
+
}
|
|
70
|
+
const response = await env.host.request({
|
|
71
|
+
path: spec.path,
|
|
72
|
+
body: { ...spec.body, searchValue: keyword },
|
|
73
|
+
operation: 'performance.hrm.resolve',
|
|
74
|
+
});
|
|
75
|
+
const list = Array.isArray(response?.data?.data) ? response.data.data : [];
|
|
76
|
+
const candidates = list.map((item) => ({
|
|
77
|
+
id: item?.id,
|
|
78
|
+
name: item?.name ?? null,
|
|
79
|
+
title: item?.title ?? null,
|
|
80
|
+
contentDesc: item?.contentDesc ?? null,
|
|
81
|
+
statusCode: item?.statusCode ?? null,
|
|
82
|
+
}));
|
|
83
|
+
return pfSuccess('performance.hrm.resolve', {
|
|
84
|
+
entityType,
|
|
85
|
+
entityLabel: spec.label,
|
|
86
|
+
keyword,
|
|
87
|
+
candidateCount: candidates.length,
|
|
88
|
+
exactMatch: candidates.length === 1 && candidates[0]?.name === keyword ? candidates[0] : null,
|
|
89
|
+
candidates,
|
|
90
|
+
suggestedTargetTypes: spec.targetTypes,
|
|
91
|
+
usage: [
|
|
92
|
+
'命中唯一且 name 与文档名称完全一致 → 可直接采用其 id',
|
|
93
|
+
'考核范围已确定且多个候选名称完全一致 → 选返回顺序第一个,摘要展示名称、id 和范围;无精确匹配或具名评分人有歧义 → 请用户选择',
|
|
94
|
+
'statusCode 非 normal 的人员候选标注状态,默认不选用',
|
|
95
|
+
'id 为字符串;写入 SchemeEditReq 时按 targetType 组装 schemeLinkList 条目',
|
|
96
|
+
],
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
export const hrmResolveOperations = [
|
|
100
|
+
{
|
|
101
|
+
name: 'performance.hrm.resolve',
|
|
102
|
+
resource: 'performance.hrm',
|
|
103
|
+
method: 'query',
|
|
104
|
+
action: 'hrm.resolve',
|
|
105
|
+
summary: '按关键字搜索组织实体(人员/部门/分部/角色/岗位),返回候选与建议 targetType',
|
|
106
|
+
capability: 'performance.hrm.resolve',
|
|
107
|
+
risk: 'read',
|
|
108
|
+
inputSchema: schemaOf({
|
|
109
|
+
entityType: { type: 'string', enum: Object.keys(ENTITY_TYPES), description: '实体类型:resource=人员/department=部门/subcompany=分部/role=角色/position=岗位' },
|
|
110
|
+
keyword: { type: 'string', description: '搜索关键字(模糊匹配)' },
|
|
111
|
+
}, { required: ['entityType', 'keyword'] }),
|
|
112
|
+
handler: resolve,
|
|
113
|
+
},
|
|
114
|
+
];
|