weaver-work-cli 0.1.60 → 0.1.62

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.
Files changed (139) hide show
  1. package/dist/chunks/{archive-4SQAVTIB.js → archive-S2VKZWQ3.js} +2 -2
  2. package/dist/chunks/{archive-oa-W2UEJ67L.js → archive-oa-HEDSIUUY.js} +2 -2
  3. package/dist/chunks/{asset-EGZEABBI.js → asset-HYH4W357.js} +2 -2
  4. package/dist/chunks/{asset-idle-EBUZBB6M.js → asset-idle-N7REBNGL.js} +2 -2
  5. package/dist/chunks/{attachment-content-I6WHKGR2.js → attachment-content-VYYA75FR.js} +3 -3
  6. package/dist/chunks/{blog-2YKMWOWI.js → blog-SLMZZICV.js} +2 -2
  7. package/dist/chunks/{caizhilian-5NM4X5HG.js → caizhilian-RV43KKBT.js} +4 -4
  8. package/dist/chunks/{calendar-H4QTJCUY.js → calendar-DMVZ4OLY.js} +2 -2
  9. package/dist/chunks/{chunk-VLL6JOB4.js → chunk-6XSSAUNW.js} +4 -4
  10. package/dist/chunks/{chunk-VQWPQTEY.js → chunk-BIA2NKUG.js} +4 -4
  11. package/dist/chunks/{chunk-VMCCRWFO.js → chunk-BQYX2UX5.js} +2 -2
  12. package/dist/chunks/{chunk-XF7S6FQW.js → chunk-DTCQFTHW.js} +1 -1
  13. package/dist/chunks/{chunk-CPG6NLN4.js → chunk-E5YD5JWR.js} +1 -1
  14. package/dist/chunks/{chunk-PH7N4UFT.js → chunk-EGANE35F.js} +1 -1
  15. package/dist/chunks/{chunk-Z4IPY5GV.js → chunk-H6YOMI3U.js} +2 -2
  16. package/dist/chunks/{chunk-HHH4K3YY.js → chunk-ILALC2N6.js} +1 -1
  17. package/dist/chunks/{chunk-WINR2Q6K.js → chunk-KXJA42EA.js} +86 -19
  18. package/dist/chunks/{chunk-CQ4OVCKG.js → chunk-KY3R42RS.js} +2 -2
  19. package/dist/chunks/{chunk-WVH5ESDA.js → chunk-NRYDJN4J.js} +1 -1
  20. package/dist/chunks/{chunk-TGM7BWEH.js → chunk-P6TXQK75.js} +2 -2
  21. package/dist/chunks/{chunk-6YWHRXEQ.js → chunk-QBDXJS2W.js} +119 -9
  22. package/dist/chunks/{chunk-2IGZUMNG.js → chunk-SHX7XBYR.js} +180 -18
  23. package/dist/chunks/{chunk-P7RXQDCA.js → chunk-T2KVJFWJ.js} +4 -4
  24. package/dist/chunks/{chunk-FMNCSYIG.js → chunk-TEZHIB6T.js} +2 -2
  25. package/dist/chunks/{chunk-HMIIVM2L.js → chunk-UBGWIXU3.js} +97 -45
  26. package/dist/chunks/{chunk-5N222HK6.js → chunk-UBRWONP4.js} +2 -2
  27. package/dist/chunks/{chunk-7U5YHCW7.js → chunk-UQFPF4EX.js} +2 -2
  28. package/dist/chunks/{chunk-4GG72JAT.js → chunk-V2LASYKO.js} +2 -2
  29. package/dist/chunks/{chunk-BDBTZVYA.js → chunk-VBFBMM7G.js} +55 -55
  30. package/dist/chunks/{chunk-YHSOCGKO.js → chunk-VNYOUAWV.js} +11 -11
  31. package/dist/chunks/{chunk-SFM3M2L3.js → chunk-WIWDVETN.js} +19 -3
  32. package/dist/chunks/{chunk-44KJ7WFA.js → chunk-XT77MP54.js} +2 -2
  33. package/dist/chunks/{chunk-JFKMPRZB.js → chunk-YI2YMW5N.js} +50 -3
  34. package/dist/chunks/{conflict-QMDLS2EW.js → conflict-GFJRS6I7.js} +2 -2
  35. package/dist/chunks/{contract-LLRKMLQQ.js → contract-U3ZGNRWB.js} +2 -2
  36. package/dist/chunks/{cowork-2RDFBZWB.js → cowork-EX7PKIDK.js} +2 -2
  37. package/dist/chunks/{create-flow-5ODJ7WJO.js → create-flow-EJZD434E.js} +6 -6
  38. package/dist/chunks/{data-LVDFIRNG.js → data-FOODGAMF.js} +278 -121
  39. package/dist/chunks/{ebuilder-form-7WA6X6ZI.js → ebuilder-form-I2EOKODG.js} +3 -3
  40. package/dist/chunks/{ehr-52GBKNJR.js → ehr-TE4RFNID.js} +2 -2
  41. package/dist/chunks/{entry-mode-73BJML22.js → entry-mode-ZOLSXEGX.js} +9 -5
  42. package/dist/chunks/{env-OHFS76HV.js → env-TID5NFR6.js} +2 -2
  43. package/dist/chunks/{esb-HJSXCEOM.js → esb-7L6MHYLB.js} +4 -4
  44. package/dist/chunks/{factory-FRTA2LP4.js → factory-OG7BPMH5.js} +1 -1
  45. package/dist/chunks/{fna-OBACRT3J.js → fna-6V2ENR3Y.js} +2 -2
  46. package/dist/chunks/{group-chat-KBFRPCR2.js → group-chat-5DKPWIHL.js} +3 -3
  47. package/dist/chunks/{host-TTSGY5NZ.js → host-3DLYA54R.js} +3 -3
  48. package/dist/chunks/{host-KJT3G5D2.js → host-GOJHHTPY.js} +3 -3
  49. package/dist/chunks/{host-KOWUMNAY.js → host-OGBHL75G.js} +3 -3
  50. package/dist/chunks/{host-MFXRA2MY.js → host-ONZC6AE7.js} +3 -3
  51. package/dist/chunks/{host-W4JCNRFS.js → host-TJ5VVHM7.js} +3 -3
  52. package/dist/chunks/{host-2BKMPWDH.js → host-VTPAWDZV.js} +3 -3
  53. package/dist/chunks/{hrm-AK3WGBMN.js → hrm-2N7NFQDZ.js} +3 -3
  54. package/dist/chunks/{im-JZSBPO4Z.js → im-XCH47ZBN.js} +3 -3
  55. package/dist/chunks/{invoice-6XDMPCWB.js → invoice-5KJ7T774.js} +198 -331
  56. package/dist/chunks/{jiuchuanhui-K4EQU6GK.js → jiuchuanhui-PL6DRPBM.js} +2 -2
  57. package/dist/chunks/{lazy-dispatch-GCA6HDOB.js → lazy-dispatch-UATEN7H7.js} +5 -5
  58. package/dist/chunks/{mail-IKVCQCVZ.js → mail-Q7Z4CQ4D.js} +2 -2
  59. package/dist/chunks/{meeting-ARHVWK7G.js → meeting-5E3BNARL.js} +13 -13
  60. package/dist/chunks/{minute-doc-547KSYKR.js → minute-doc-NXRE5C77.js} +4 -4
  61. package/dist/chunks/{okr-KV43FPPX.js → okr-3O3XNYOK.js} +2 -2
  62. package/dist/chunks/{operations-6NXJ7RTE.js → operations-EZWG72FH.js} +4 -4
  63. package/dist/chunks/performance-Y7CPNSOR.js +1295 -0
  64. package/dist/chunks/{plan-WOYR4WEG.js → plan-BLGPZF5M.js} +2 -2
  65. package/dist/chunks/{project-CQJKBUIL.js → project-6MZMLJMP.js} +2 -2
  66. package/dist/chunks/{reception-MPBU3JXC.js → reception-F2VT2X52.js} +2 -2
  67. package/dist/chunks/{recruit-stage-USTTRHOX.js → recruit-stage-4ETIBMIW.js} +2 -2
  68. package/dist/chunks/{registry-GURQG4ZV.js → registry-3FYSWV3U.js} +3 -3
  69. package/dist/chunks/{registry-SS5J2FZQ.js → registry-7RS74TCK.js} +4 -4
  70. package/dist/chunks/{registry-H5HQ5QNH.js → registry-I4DVPDMU.js} +11 -11
  71. package/dist/chunks/{room-recommend-3UBROMZE.js → room-recommend-GWCVKCXW.js} +4 -4
  72. package/dist/chunks/{schedule-FTUQML6O.js → schedule-6AN63MJQ.js} +4 -4
  73. package/dist/chunks/{smart-extract-APX2PNIN.js → smart-extract-SR4SJJKN.js} +3 -3
  74. package/dist/chunks/{workflow-WMPW3WSB.js → workflow-KF7FA2UQ.js} +7 -7
  75. package/dist/cmd/refs/index.js +124 -4
  76. package/dist/core/output.js +199 -26
  77. package/dist/core/refs.js +36 -0
  78. package/dist/index.js +38 -33
  79. package/dist/internal/e10/auth/xiaoe.js +25 -3
  80. package/dist/shortcuts/caizhilian/operations/files.js +86 -15
  81. package/dist/shortcuts/data/index.js +12 -2
  82. package/dist/shortcuts/data/manifest.js +4 -2
  83. package/dist/shortcuts/data/operations/attribution.js +229 -0
  84. package/dist/shortcuts/data/operations/ds.js +87 -90
  85. package/dist/shortcuts/data/operations/index.js +3 -1
  86. package/dist/shortcuts/index.js +5 -0
  87. package/dist/shortcuts/invoice/manifest.js +30 -62
  88. package/dist/shortcuts/invoice/operations/registry.js +2 -2
  89. package/dist/shortcuts/invoice/operations/reim-customer.js +111 -0
  90. package/dist/shortcuts/invoice/operations/shared.js +0 -204
  91. package/dist/shortcuts/meeting/operations/eb/create-flow.js +84 -16
  92. package/dist/shortcuts/meeting/operations/eb/entry-mode.js +61 -7
  93. package/dist/shortcuts/performance/continuation.js +74 -0
  94. package/dist/shortcuts/performance/errors.js +65 -0
  95. package/dist/shortcuts/performance/host.js +105 -0
  96. package/dist/shortcuts/performance/index.js +109 -0
  97. package/dist/shortcuts/performance/manifest.js +30 -0
  98. package/dist/shortcuts/performance/operations/hrm-resolve.js +114 -0
  99. package/dist/shortcuts/performance/operations/registry.js +44 -0
  100. package/dist/shortcuts/performance/operations/scheme-detail.js +70 -0
  101. package/dist/shortcuts/performance/operations/scheme-draft.js +116 -0
  102. package/dist/shortcuts/performance/operations/scheme-publish.js +158 -0
  103. package/dist/shortcuts/performance/operations/types.js +32 -0
  104. package/dist/shortcuts/performance/scheme-validate.js +307 -0
  105. package/dist/shortcuts/performance/shared.js +158 -0
  106. package/docs/agent-invoice.md +1 -1
  107. package/docs/agent-io-channel-design.md +67 -3
  108. package/docs/data.md +2 -1
  109. package/docs/invoice.md +0 -2
  110. package/package.json +1 -1
  111. package/scripts/xiaoe_env.py +6 -1
  112. package/skill-template/business-info.json +19 -0
  113. package/skill-template/domains/performance.md +18 -0
  114. package/skill-template/domains/yepiaotong.md +0 -1
  115. package/skills/weaver-e10-caizhilian/SKILL.md +1 -1
  116. package/skills/weaver-e10-data/references/datasource.md +2 -1
  117. package/skills/weaver-e10-meeting/SKILL.md +5 -3
  118. package/skills/weaver-e10-performance/SKILL.md +202 -0
  119. package/skills/weaver-e10-performance/agents/openai.yaml +74 -0
  120. package/skills/weaver-e10-performance/references/default-assembly.md +108 -0
  121. package/skills/weaver-e10-performance/references/entity-resolution.md +69 -0
  122. package/skills/weaver-e10-performance/references/enums-and-normalization.md +80 -0
  123. package/skills/weaver-e10-performance/references/examples.md +146 -0
  124. package/skills/weaver-e10-performance/references/extraction-guide.md +144 -0
  125. package/skills/weaver-e10-performance/references/scheme-edit-req-fields.md +185 -0
  126. package/skills/weaver-e10-performance/references/scheme-setting-page.md +62 -0
  127. package/skills/weaver-e10-performance/scripts/parse_appraisal_doc.py +483 -0
  128. package/skills/weaver-e10-shared/references/json-output-contract.md +5 -0
  129. package/skills/weaver-e10-yepiaotong/SKILL.md +16 -9
  130. package/skills/weaver-e10-yepiaotong/references/invoice-reim-relation.md +9 -7
  131. package/skills/weaver-e10-yepiaotong/references/invoice-reim.md +15 -11
  132. package/skills/weaver-e10-yepiaotong/references/reim-api-reference.md +29 -25
  133. package/skills/weaver-e10-yepiaotong/references/reim-customer-search.md +89 -0
  134. package/skills/weaver-e10-yepiaotong/references/reim-examples.md +35 -37
  135. package/skills/weaver-e10-yepiaotong/references/reim-form-fill-rules.md +66 -63
  136. package/skills/weaver-e10-yepiaotong/references/reim-workflow.md +50 -71
  137. package/skills/weaver-e10-yepiaotong/references/source-manifest.json +34 -95
  138. package/dist/shortcuts/invoice/operations/browse-field.js +0 -17
  139. package/skills/weaver-e10-yepiaotong/references/invoice-browse-field-data.md +0 -204
@@ -0,0 +1,1295 @@
1
+ import { createRequire as __esbuildCreateRequire } from 'node:module';
2
+ const require = __esbuildCreateRequire(import.meta.url);
3
+ import {
4
+ CONTINUATION_TTL_MS
5
+ } from "./chunk-7BDPM5ST.js";
6
+ import {
7
+ E10ApiError,
8
+ createE10RequestRuntime,
9
+ isE10SessionExpiredResponse,
10
+ requireE10Session
11
+ } from "./chunk-NRYDJN4J.js";
12
+ import {
13
+ E10_SESSION_EXPIRED_MESSAGE,
14
+ getActiveProfile
15
+ } from "./chunk-WIWDVETN.js";
16
+ import "./chunk-SHYQUBY3.js";
17
+ import {
18
+ CliError,
19
+ isCliError,
20
+ toErrorEnvelope
21
+ } from "./chunk-UG5G54VL.js";
22
+ import "./chunk-BUSC6UAE.js";
23
+
24
+ // src/shortcuts/performance/index.ts
25
+ import { readFile as readFile2 } from "node:fs/promises";
26
+
27
+ // src/shortcuts/performance/continuation.ts
28
+ import { createHmac, randomBytes, timingSafeEqual } from "node:crypto";
29
+ import { existsSync } from "node:fs";
30
+ import { chmod, mkdir, readFile, writeFile } from "node:fs/promises";
31
+ import { homedir } from "node:os";
32
+ import { resolve } from "node:path";
33
+
34
+ // src/shortcuts/performance/errors.ts
35
+ var PerformanceCliError = class extends CliError {
36
+ type;
37
+ subtype;
38
+ code;
39
+ retryable;
40
+ stage;
41
+ details;
42
+ partialData;
43
+ constructor(type, subtype, message, options = {}) {
44
+ super(message, options.exitCode ?? 5 /* InternalError */);
45
+ this.name = "PerformanceCliError";
46
+ this.type = type;
47
+ this.subtype = subtype;
48
+ this.code = options.code;
49
+ this.retryable = options.retryable ?? false;
50
+ this.stage = options.stage;
51
+ this.details = options.details;
52
+ this.partialData = options.partialData;
53
+ }
54
+ };
55
+ function pfValidationError(subtype, message, details) {
56
+ return new PerformanceCliError("validation", subtype, message, {
57
+ details,
58
+ exitCode: 2 /* UsageError */
59
+ });
60
+ }
61
+ function pfAuthError(subtype, message, details) {
62
+ return new PerformanceCliError("authentication", subtype, message, {
63
+ details,
64
+ exitCode: 3 /* AuthError */
65
+ });
66
+ }
67
+ function pfNetworkError(subtype, message, options = {}) {
68
+ return new PerformanceCliError("network", subtype, message, {
69
+ ...options,
70
+ retryable: options.retryable ?? true,
71
+ exitCode: 4 /* NetworkError */
72
+ });
73
+ }
74
+ function pfConfirmationError(action, details) {
75
+ return new PerformanceCliError("confirmation", "required", "\u8BE5\u64CD\u4F5C\u9700\u8981\u660E\u786E\u786E\u8BA4", {
76
+ details: { action, ...details },
77
+ exitCode: 10 /* ConfirmationRequired */
78
+ });
79
+ }
80
+ function pfFail(message, details) {
81
+ return new PerformanceCliError("api", "business_error", message, {
82
+ details,
83
+ exitCode: 1 /* GeneralError */
84
+ });
85
+ }
86
+
87
+ // src/shortcuts/performance/continuation.ts
88
+ function stateRoot(ctx) {
89
+ const configured = ctx?.config?.path();
90
+ if (configured) return resolve(configured, "..");
91
+ return process.env.WEAVER_WORK_CLI_HOME || process.env.WORK_CLI_HOME || resolve(homedir(), ".weaver-work-cli");
92
+ }
93
+ async function loadKey(ctx) {
94
+ const keysDir = resolve(stateRoot(ctx), "keys");
95
+ const filename = resolve(keysDir, "performance-continuation.key");
96
+ await mkdir(keysDir, { recursive: true, mode: 448 });
97
+ if (existsSync(filename)) return readFile(filename);
98
+ const key = randomBytes(32);
99
+ try {
100
+ await writeFile(filename, key, { flag: "wx", mode: 384 });
101
+ if (process.platform !== "win32") await chmod(filename, 384).catch(() => void 0);
102
+ return key;
103
+ } catch {
104
+ return readFile(filename);
105
+ }
106
+ }
107
+ function encode(value) {
108
+ return Buffer.from(JSON.stringify(value)).toString("base64url");
109
+ }
110
+ function signature(payload, key) {
111
+ return createHmac("sha256", key).update(payload).digest("base64url");
112
+ }
113
+ function createPerformanceContinuationSigner(ctx) {
114
+ return {
115
+ async issue(payload, ttlMs = CONTINUATION_TTL_MS) {
116
+ const issuedAt = Date.now();
117
+ const body = encode({ ...payload, issuedAt, expiresAt: issuedAt + ttlMs });
118
+ const sig = signature(body, await loadKey(ctx));
119
+ return `${body}.${sig}`;
120
+ },
121
+ async verify(token, expectedOperation) {
122
+ if (typeof token !== "string" || !token.includes(".")) {
123
+ throw pfValidationError("continuation_invalid", "continuation \u65E0\u6548");
124
+ }
125
+ const [body, provided] = token.split(".");
126
+ const expected = signature(body, await loadKey(ctx));
127
+ const valid = provided.length === expected.length && timingSafeEqual(Buffer.from(provided), Buffer.from(expected));
128
+ if (!valid) throw pfValidationError("continuation_invalid", "continuation \u7B7E\u540D\u6821\u9A8C\u5931\u8D25");
129
+ let payload;
130
+ try {
131
+ payload = JSON.parse(Buffer.from(body, "base64url").toString("utf8"));
132
+ } catch {
133
+ throw pfValidationError("continuation_invalid", "continuation \u8F7D\u8377\u89E3\u6790\u5931\u8D25");
134
+ }
135
+ if (!payload || typeof payload !== "object") {
136
+ throw pfValidationError("continuation_invalid", "continuation \u8F7D\u8377\u5FC5\u987B\u662F\u5BF9\u8C61");
137
+ }
138
+ if (typeof payload.expiresAt === "number" && Date.now() > payload.expiresAt) {
139
+ throw pfValidationError("continuation_expired", "continuation \u5DF2\u8FC7\u671F\uFF0C\u8BF7\u91CD\u65B0 prepare");
140
+ }
141
+ if (payload.operation && String(payload.operation) !== String(expectedOperation)) {
142
+ throw pfValidationError(
143
+ "continuation_operation_mismatch",
144
+ `continuation \u5C5E\u4E8E\u64CD\u4F5C ${String(payload.operation)}\uFF0C\u4E0D\u80FD\u7528\u4E8E ${expectedOperation}`
145
+ );
146
+ }
147
+ return payload;
148
+ }
149
+ };
150
+ }
151
+
152
+ // src/shortcuts/performance/host.ts
153
+ function inferProfile(ctx) {
154
+ const options = ctx.getGlobalOptions();
155
+ return options.profile || getActiveProfile();
156
+ }
157
+ function assertPath(requestPath) {
158
+ if (typeof requestPath !== "string" || !requestPath.startsWith("/") || requestPath.startsWith("//")) {
159
+ throw pfValidationError("path_invalid", "\u8BF7\u6C42\u8DEF\u5F84\u5FC5\u987B\u662F\u76F8\u5BF9\u7EDD\u5BF9\u8DEF\u5F84");
160
+ }
161
+ if (/^https?:/i.test(requestPath) || /[\r\n]/.test(requestPath) || requestPath.includes("/../")) {
162
+ throw pfValidationError("path_invalid", "\u8BF7\u6C42\u8DEF\u5F84\u4E0D\u5141\u8BB8\u8DE8\u57DF\u6216\u8DEF\u5F84\u9003\u9038");
163
+ }
164
+ if (!requestPath.startsWith("/api/")) {
165
+ throw pfValidationError("path_not_allowed", "\u53EA\u80FD\u8C03\u7528 /api/ \u8DEF\u5F84");
166
+ }
167
+ }
168
+ function createPerformanceHost(ctx, dependencies = {}) {
169
+ let e10Session = null;
170
+ let sessionContext = null;
171
+ const requireSession = dependencies.requireSession || ((innerCtx) => requireE10Session(innerCtx, { skipProfileEnrichment: true }));
172
+ async function ensureSession() {
173
+ if (!e10Session) {
174
+ e10Session = await requireSession(ctx);
175
+ sessionContext = {
176
+ baseUrl: e10Session.getBaseUrl(),
177
+ profile: inferProfile(ctx),
178
+ userId: e10Session.userId,
179
+ tenantKey: e10Session.tenantKey,
180
+ eteamsId: e10Session.eteamsId
181
+ };
182
+ }
183
+ return e10Session;
184
+ }
185
+ async function getSession() {
186
+ await ensureSession();
187
+ return sessionContext;
188
+ }
189
+ async function runtime() {
190
+ return createE10RequestRuntime(ctx, await ensureSession(), {
191
+ interceptors: dependencies.interceptors,
192
+ fetch: dependencies.fetch
193
+ });
194
+ }
195
+ async function request(request2) {
196
+ const {
197
+ method,
198
+ path,
199
+ query,
200
+ body,
201
+ operation,
202
+ headers: extraHeaders = {},
203
+ timeoutMs = 3e4
204
+ } = request2;
205
+ assertPath(path);
206
+ const resolvedMethod = method || (body === void 0 ? "GET" : "POST");
207
+ let response;
208
+ try {
209
+ response = await (await runtime()).requestJson({
210
+ module: "performance",
211
+ operation,
212
+ method: resolvedMethod,
213
+ path,
214
+ query,
215
+ body,
216
+ headers: { "X-Requested-With": "XMLHttpRequest", ...extraHeaders },
217
+ timeoutMs
218
+ });
219
+ } catch (error) {
220
+ if (error instanceof E10ApiError && error.type === "network") {
221
+ throw pfNetworkError(error.subtype, error.message, {
222
+ retryable: error.retryable,
223
+ details: error.details
224
+ });
225
+ }
226
+ throw error;
227
+ }
228
+ if (isE10SessionExpiredResponse(response)) {
229
+ throw pfAuthError("session_expired", E10_SESSION_EXPIRED_MESSAGE, { httpStatus: response.status });
230
+ }
231
+ if (response.parseError) {
232
+ if (response.status < 200 || response.status >= 300) {
233
+ throw new PerformanceCliError("api", "http_error", `\u6CDB\u5FAE\u63A5\u53E3 HTTP ${response.status}`, {
234
+ code: response.status,
235
+ details: { status: response.status },
236
+ exitCode: 1
237
+ });
238
+ }
239
+ throw pfNetworkError("protocol", `\u63A5\u53E3\u8FD4\u56DE\u4E0D\u662F\u5408\u6CD5 JSON\uFF08HTTP ${response.status}\uFF09`, { retryable: false });
240
+ }
241
+ if (response.status < 200 || response.status >= 300) {
242
+ throw new PerformanceCliError("api", "http_error", `\u6CDB\u5FAE\u63A5\u53E3 HTTP ${response.status}`, {
243
+ code: response.status,
244
+ details: { status: response.status, message: response.value?.msg },
245
+ exitCode: 1
246
+ });
247
+ }
248
+ return response.value;
249
+ }
250
+ return { request, getSession };
251
+ }
252
+
253
+ // src/shortcuts/performance/shared.ts
254
+ function assertWeaResult(response, context) {
255
+ if (!response || typeof response !== "object") {
256
+ throw pfFail(`${context}\uFF1A\u63A5\u53E3\u8FD4\u56DE\u4E0D\u662F\u5BF9\u8C61`, { response });
257
+ }
258
+ const failed = response.fail === true || response.status !== void 0 && response.status !== true || response.code !== void 0 && response.code !== 200;
259
+ if (failed) {
260
+ throw pfFail(`${context}\uFF1A${response.msg || "\u63A5\u53E3\u8FD4\u56DE\u5931\u8D25"}`, {
261
+ code: response.code,
262
+ msg: response.msg
263
+ });
264
+ }
265
+ return response.data;
266
+ }
267
+ var stringField = { type: "string" };
268
+ var numberField = { type: "number" };
269
+ var booleanField = { type: "boolean" };
270
+ var nullableNumber = { type: ["number", "null"] };
271
+ var objectItems = (properties) => ({ type: "array", items: { type: "object", properties, additionalProperties: true } });
272
+ var indicatorFields = {
273
+ dataRow: { type: "integer" },
274
+ indicatorMode: { type: "string", enum: ["qualitative", "quantify"] },
275
+ indicatorType: stringField,
276
+ indicatorDescription: stringField,
277
+ weight: stringField,
278
+ defaultTarget: stringField,
279
+ scoreScope: stringField,
280
+ checkType: stringField,
281
+ customInputScope: stringField,
282
+ appointScoreData: stringField,
283
+ targetId: nullableNumber,
284
+ targetHasEdit: booleanField,
285
+ dataSource: stringField,
286
+ dataSourceMode: stringField,
287
+ scoreFormula: stringField,
288
+ unit: stringField
289
+ };
290
+ var itemFields = {
291
+ name: stringField,
292
+ description: stringField,
293
+ maxScore: numberField,
294
+ sort: { type: "integer" },
295
+ scoreScope: stringField,
296
+ lockTarget: booleanField,
297
+ newTarget: booleanField,
298
+ targetId: nullableNumber,
299
+ targetHasEdit: booleanField
300
+ };
301
+ var stepFields = {
302
+ sort: { type: "integer" },
303
+ stepType: stringField,
304
+ raterType: stringField,
305
+ checkKps: booleanField,
306
+ checkSignature: booleanField,
307
+ stepWeight: numberField,
308
+ scoreMinNum: nullableNumber,
309
+ scoreMaxNum: nullableNumber,
310
+ interviewOrder: { type: ["string", "null"] },
311
+ stepOperators: objectItems({ operateType: stringField, operater: { type: ["integer", "string", "null"] } })
312
+ };
313
+ var schemeEditReqSchema = {
314
+ id: { type: "string", description: "\u65B9\u6848 id\uFF0C\u5B57\u7B26\u4E32\u5F62\u5F0F\uFF0818 \u4F4D Long \u8F6C JSON \u6570\u5B57\u4F1A\u4E22\u7CBE\u5EA6\uFF09\u3002\u9996\u6B21\u6682\u5B58\u4E0D\u4F20\uFF1B\u518D\u6B21\u6682\u5B58/\u53D1\u5E03\u5FC5\u4F20\uFF08\u8986\u76D6\u5F0F\u66F4\u65B0\uFF09" },
315
+ detailId: { type: "string", description: "\u6307\u6807\u660E\u7EC6 id\uFF0C\u5B57\u7B26\u4E32\u5F62\u5F0F\uFF08\u53D1\u5E03\u65F6\u5FC5\u4F20\uFF1B\u7F3A\u5931\u4F1A\u5BFC\u81F4 hr_kpi_details \u91CD\u590D\u63D2\u5165\u3001detail \u6C38\u4E45 500\uFF09" },
316
+ name: { type: "string", description: "\u65B9\u6848\u540D\u79F0\uFF08\u5FC5\u586B\uFF09" },
317
+ dateType: { type: "string", enum: ["year", "halfyear", "quarter", "month"], description: "\u8003\u6838\u5468\u671F" },
318
+ total: { type: ["number", "string"], description: "\u603B\u5206\u5236\uFF08\u5982 100\uFF09" },
319
+ type: { type: "integer", description: "\u65B9\u6848\u7C7B\u578B\uFF08\u5DE5\u4F5C\u8003\u6838=1\uFF09" },
320
+ weightMode: { type: "string", enum: ["simple", "advanced"], description: "\u6743\u91CD\u6A21\u5F0F\uFF0C\u9ED8\u8BA4 simple" },
321
+ schemeLinkList: {
322
+ type: "array",
323
+ description: "\u8003\u6838\u5BF9\u8C61\uFF08\u5FC5\u586B\uFF0C\u591A\u6761\u6309\u5E76\u96C6\u5904\u7406\uFF09\u3002targetType\uFF1A1\u4EBA\u5458/2,3\u90E8\u95E8/5,6\u5206\u90E8/10\u89D2\u8272/11\u6240\u6709\u4EBA(id=0)/12,13,1311\u5C97\u4F4D",
324
+ items: {
325
+ type: "object",
326
+ additionalProperties: false,
327
+ properties: {
328
+ id: { type: "string", description: '\u5B9E\u4F53 id\uFF0C\u5B57\u7B26\u4E32\u5F62\u5F0F\uFF0C\u539F\u6837\u900F\u4F20 hrm.resolve \u8FD4\u56DE\u503C\uFF08targetType=11 \u65F6\u56FA\u5B9A "0"\uFF09' },
329
+ targetType: { type: "integer", description: "\u5BF9\u8C61\u7C7B\u578B\uFF08\u89C1 entity-resolution.md\uFF09" },
330
+ name: { type: "string", description: "\u540D\u79F0\uFF08\u4EC5\u5C55\u793A\u7528\uFF0C\u53EF\u9009\uFF09" },
331
+ role_level: { type: "integer", description: "\u89D2\u8272\u7EA7\u522B\uFF08targetType=10 \u65F6\u9700\u786E\u8BA4\uFF09" },
332
+ position_level: { type: "integer", description: "\u5C97\u4F4D\u7EA7\u522B\uFF08targetType=12/13/1311 \u53EF\u9009\uFF09" },
333
+ seclevel: { type: "object", description: "\u5B89\u5168\u7EA7\u522B\u533A\u95F4 {max,min}\uFF0C\u4E00\u822C\u4E0D\u586B" }
334
+ },
335
+ required: ["id", "targetType"]
336
+ }
337
+ },
338
+ basicData: objectItems(indicatorFields),
339
+ includePlusItem: booleanField,
340
+ includeMinusItem: booleanField,
341
+ includeInterviewItem: booleanField,
342
+ plusList: objectItems(itemFields),
343
+ minusList: objectItems(itemFields),
344
+ kpsStepList: objectItems(stepFields),
345
+ plusStepList: objectItems(stepFields),
346
+ minusStepList: objectItems(stepFields),
347
+ flowStepList: objectItems(stepFields),
348
+ interviewStepList: objectItems(stepFields),
349
+ stepWeightList: objectItems({ indicatorMode: stringField, indicatorRow: { type: "integer" }, stepIndex: { type: "integer" }, weight: numberField }),
350
+ checkType: objectItems({ id: stringField, typeName: stringField, weight: numberField, rowLine: stringField, scoreLimit: nullableNumber }),
351
+ basicHeader: objectItems({ title: stringField, dataIndex: stringField, comKey: stringField, width: stringField }),
352
+ countType: { type: "integer", description: "\u8BA1\u5206\u65B9\u5F0F" },
353
+ assessmentDescription: stringField,
354
+ assessmentStatus: booleanField,
355
+ forbidApproveTime: { type: "integer" },
356
+ remark: booleanField,
357
+ reward: booleanField,
358
+ rewardName: stringField,
359
+ showTargetColumn: booleanField,
360
+ openCheckType: booleanField,
361
+ weightSum: booleanField,
362
+ typeWeightSum: booleanField,
363
+ eachWeightSum: booleanField,
364
+ openNextTarget: booleanField,
365
+ openCorrection: booleanField,
366
+ openCorrectionScope: { type: "object", properties: { min: numberField, max: numberField }, additionalProperties: true },
367
+ scoreLimit: booleanField,
368
+ priority: booleanField,
369
+ seeTotal: booleanField,
370
+ seeScoreDetail: booleanField,
371
+ seePlusItem: booleanField,
372
+ seeMinusItem: booleanField,
373
+ seeDistributionAdjust: booleanField,
374
+ seeAfterFinish: booleanField,
375
+ commitContent: stringField,
376
+ commitDay: { type: "integer" },
377
+ commitRemindTime: stringField,
378
+ overtimeContent: stringField,
379
+ overtimeDay: { type: "integer" },
380
+ overRemindTime: stringField,
381
+ kpsDistributeType: stringField,
382
+ flowDistributeType: stringField,
383
+ createMode: stringField,
384
+ fieldFilters: { type: "array", items: { type: "object", additionalProperties: true } },
385
+ operatingTargetList: { type: "array", items: { type: "object", additionalProperties: true } },
386
+ remindOrdinaryData: { description: "\u81EA\u5B9A\u4E49\u63D0\u9192\u914D\u7F6E\uFF0C\u7ED3\u6784\u4EE5\u63A5\u53E3\u4E3A\u51C6" },
387
+ remindTimeData: { description: "\u81EA\u5B9A\u4E49\u63D0\u9192\u65F6\u95F4\u914D\u7F6E\uFF0C\u7ED3\u6784\u4EE5\u63A5\u53E3\u4E3A\u51C6" },
388
+ teffectTime: { type: "string", description: "\u751F\u6548\u65E5\u671F yyyy-MM-dd\uFF08\u6587\u6863\u672A\u63D0\u53CA\u65F6\u9ED8\u8BA4\u5F53\u5929\uFF09" },
389
+ failureTime: { type: "string", description: "\u5931\u6548\u65E5\u671F yyyy-MM-dd\uFF08\u53EF\u9009\uFF09" },
390
+ dateTypeSet: { type: "string", enum: ["setting", "custom"], description: "\u81EA\u52A8\u65F6\u95F4\u9879\u6A21\u5F0F\uFF1B\u586B distributeTime/forbidTime \u65F6\u5E94\u4E3A custom" },
391
+ distributeTime: { type: "integer", description: "\u4E0B\u53D1\u65F6\u95F4\uFF08\u6BEB\u79D2\u65F6\u95F4\u6233\uFF0C\u53EF\u9009\uFF09" },
392
+ forbidTime: { type: "integer", description: "\u622A\u6B62\u65F6\u95F4\uFF08\u6BEB\u79D2\u65F6\u95F4\u6233\uFF0C\u53EF\u9009\uFF09" },
393
+ seeSetting: { type: "string", enum: ["default", "custom"], description: "\u53EF\u89C1\u6027\u8BBE\u7F6E\uFF0C\u9ED8\u8BA4 default" },
394
+ remindSetting: { type: "string", enum: ["default", "custom"], description: "\u63D0\u9192\u8BBE\u7F6E\uFF0C\u9ED8\u8BA4 default" }
395
+ };
396
+ function normalizeId(value, field) {
397
+ if (typeof value === "string") {
398
+ const trimmed = value.trim();
399
+ if (!trimmed) throw pfFail(`${field} \u4E0D\u80FD\u4E3A\u7A7A\u5B57\u7B26\u4E32`);
400
+ return trimmed;
401
+ }
402
+ if (typeof value === "number" && Number.isFinite(value)) {
403
+ if (!Number.isSafeInteger(value)) {
404
+ throw pfValidationError(
405
+ "id_precision_loss",
406
+ `${field} \u4F20\u4E86\u6570\u5B57 ${value}\uFF0C\u5DF2\u8D85\u51FA JS \u5B89\u5168\u6574\u6570\u8303\u56F4\uFF0818 \u4F4D id \u4F1A\u4E22\u7CBE\u5EA6\u3001\u6307\u5411\u9519\u8BEF\u8BB0\u5F55\uFF09\u3002\u8BF7\u6539\u5199\u4E3A\u5B57\u7B26\u4E32\u5F62\u5F0F\u4F20\u5165\u3002`
407
+ );
408
+ }
409
+ return String(value);
410
+ }
411
+ throw pfValidationError("id_invalid", `${field} \u5FC5\u987B\u662F\u5B57\u7B26\u4E32\uFF08\u5F53\u524D ${typeof value}\uFF09`);
412
+ }
413
+ var DETAIL_PATH = "/api/workrelate/performance/scheme/detail";
414
+ async function ensureDetailIdForUpdate(host, body, operation) {
415
+ if (body.id === void 0 || body.id === null || body.id === "") return body;
416
+ if (body.detailId !== void 0 && body.detailId !== null && body.detailId !== "") return body;
417
+ const id = normalizeId(body.id, "id");
418
+ let detailData;
419
+ try {
420
+ const response = await host.request({
421
+ path: `${DETAIL_PATH}/${encodeURIComponent(id)}`,
422
+ method: "GET",
423
+ operation
424
+ });
425
+ detailData = assertWeaResult(response, "\u8BFB\u53D6\u65B9\u6848\u8BE6\u60C5\uFF08\u8865 detailId\uFF09");
426
+ } catch (error) {
427
+ throw pfValidationError(
428
+ "detail_unreadable",
429
+ `\u65B9\u6848 ${id} \u7684\u8BE6\u60C5\u65E0\u6CD5\u56DE\u8BFB\uFF08\u53EF\u80FD\u660E\u7EC6\u5DF2\u635F\u574F\uFF09\uFF1A\u4E0D\u80FD\u8986\u76D6\u6682\u5B58\uFF0C\u5426\u5219\u4F1A\u7EE7\u7EED\u5199\u5165\u91CD\u590D\u660E\u7EC6\u3002\u8BF7\u65B0\u5EFA\u65B9\u6848\uFF0C\u6216\u5148\u5728\u65B9\u6848\u8BBE\u7F6E\u9875\u6838\u5BF9\u8BE5\u65B9\u6848\u3002`,
430
+ { id }
431
+ );
432
+ }
433
+ if (!detailData || detailData.detailId === void 0 || detailData.detailId === null || detailData.detailId === "") {
434
+ throw pfValidationError(
435
+ "detail_id_missing",
436
+ `\u65B9\u6848 ${id} \u56DE\u8BFB\u4E0D\u5230 detailId\uFF1A\u8986\u76D6\u6682\u5B58\u4F1A\u5BFC\u81F4\u91CD\u590D\u660E\u7EC6\uFF0C\u5DF2\u62D2\u7EDD\u5199\u5165\u3002\u8BF7\u65B0\u5EFA\u65B9\u6848\u6216\u5148\u5728\u65B9\u6848\u8BBE\u7F6E\u9875\u6838\u67E5\u3002`,
437
+ { id }
438
+ );
439
+ }
440
+ return { ...body, id, detailId: normalizeId(detailData.detailId, "detailId") };
441
+ }
442
+
443
+ // src/shortcuts/performance/scheme-validate.ts
444
+ import { createHash } from "node:crypto";
445
+ var DATE_RE = /^\d{4}-\d{2}-\d{2}$/;
446
+ var TARGET_TYPE_LABELS = {
447
+ 1: "\u4EBA\u5458",
448
+ 2: "\u90E8\u95E8",
449
+ 3: "\u90E8\u95E8(\u542B\u4E0B\u7EA7)",
450
+ 5: "\u5206\u90E8",
451
+ 6: "\u5206\u90E8(\u542B\u4E0B\u7EA7)",
452
+ 10: "\u89D2\u8272",
453
+ 11: "\u6240\u6709\u4EBA",
454
+ 12: "\u5C97\u4F4D+\u6307\u5B9A\u90E8\u95E8",
455
+ 13: "\u5C97\u4F4D+\u6307\u5B9A\u5206\u90E8",
456
+ 1311: "\u5C97\u4F4D+\u603B\u90E8",
457
+ 14: "\u7FA4\u7EC4+\u5B89\u5168\u7EA7\u522B",
458
+ 1411: "\u7FA4\u7EC4"
459
+ };
460
+ var OPERATE_TYPE_LABELS = {
461
+ fixedMan: "\u6307\u5B9A\u4EBA",
462
+ directSuperior: "\u76F4\u63A5\u4E0A\u7EA7",
463
+ indirectSuperior: "\u95F4\u63A5\u4E0A\u7EA7",
464
+ otherSuperior: "\u5176\u4ED6\u4E0A\u7EA7",
465
+ assessmentMan: "\u88AB\u8003\u6838\u4EBA",
466
+ subordinates: "\u4E0B\u7EA7",
467
+ samePositionMan: "\u540C\u5C97\u4F4D\u4EBA\u5458",
468
+ sameGradeMan: "\u540C\u804C\u7EA7\u4EBA\u5458",
469
+ sameDepartmentMan: "\u540C\u90E8\u95E8\u4EBA\u5458"
470
+ };
471
+ var STEP_TYPE_LABELS = {
472
+ kpsStepList: "\u8BC4\u5206",
473
+ plusStepList: "\u52A0\u5206\u8BC4\u5206",
474
+ minusStepList: "\u51CF\u5206\u8BC4\u5206",
475
+ flowStepList: "\u5BA1\u6279",
476
+ interviewStepList: "\u9762\u8C08"
477
+ };
478
+ function num(v) {
479
+ if (v === null || v === void 0) return null;
480
+ const parsed = parseFloat(String(v).replace("%", "").trim());
481
+ return Number.isFinite(parsed) ? parsed : null;
482
+ }
483
+ function stepsOf(req) {
484
+ const steps = [];
485
+ for (const [key, label] of Object.entries(STEP_TYPE_LABELS)) {
486
+ const list = req[key];
487
+ if (!Array.isArray(list)) continue;
488
+ for (const step of list) {
489
+ const operators = Array.isArray(step?.stepOperators) ? step.stepOperators : [];
490
+ const who = operators.map((op) => OPERATE_TYPE_LABELS[String(op?.operateType)] || String(op?.operateType || "?")).join("/");
491
+ steps.push(`${label}${who ? `(${who})` : ""}`);
492
+ }
493
+ }
494
+ return steps;
495
+ }
496
+ function summarizeScheme(req) {
497
+ const basicData = Array.isArray(req.basicData) ? req.basicData : [];
498
+ const weights = basicData.map((row) => num(row?.weight)).filter((w) => w !== null);
499
+ return {
500
+ name: typeof req.name === "string" && req.name ? req.name : null,
501
+ dateType: req.dateType ?? null,
502
+ total: req.total ?? null,
503
+ targetCount: Array.isArray(req.schemeLinkList) ? req.schemeLinkList.length : 0,
504
+ indicatorCount: basicData.length,
505
+ weightSum: weights.length ? weights.reduce((a, b) => a + b, 0) : null,
506
+ plusCount: Array.isArray(req.plusList) ? req.plusList.length : 0,
507
+ minusCount: Array.isArray(req.minusList) ? req.minusList.length : 0,
508
+ steps: stepsOf(req),
509
+ teffectTime: req.teffectTime ?? null,
510
+ failureTime: req.failureTime ?? null
511
+ };
512
+ }
513
+ function describeTargets(req) {
514
+ const links = Array.isArray(req.schemeLinkList) ? req.schemeLinkList : [];
515
+ return links.map((link) => {
516
+ const label = TARGET_TYPE_LABELS[Number(link?.targetType)] || `targetType=${link?.targetType}`;
517
+ return `${link?.name || "(\u672A\u547D\u540D)"}[${label}]`;
518
+ });
519
+ }
520
+ function validateScheme(req) {
521
+ const issues = [];
522
+ if (!req.name || typeof req.name !== "string" || !req.name.trim()) {
523
+ issues.push({ level: "error", message: "name\uFF08\u65B9\u6848\u540D\u79F0\uFF09\u7F3A\u5931\u6216\u4E3A\u7A7A" });
524
+ }
525
+ if (!Array.isArray(req.schemeLinkList) || req.schemeLinkList.length === 0) {
526
+ issues.push({ level: "error", message: "schemeLinkList\uFF08\u8003\u6838\u5BF9\u8C61\uFF09\u4E3A\u7A7A\u2014\u2014\u8003\u6838\u5BF9\u8C61\u6CA1\u6709\u9ED8\u8BA4\u503C\uFF0C\u5FC5\u987B\u7531\u7528\u6237\u63D0\u4F9B" });
527
+ }
528
+ if (!Array.isArray(req.basicData) || req.basicData.length === 0) {
529
+ issues.push({ level: "warn", message: "basicData\uFF08\u6307\u6807\uFF09\u4E3A\u7A7A\uFF0C\u5C06\u521B\u5EFA\u65E0\u6307\u6807\u65B9\u6848" });
530
+ }
531
+ if (!Array.isArray(req.flowStepList) || req.flowStepList.length === 0) {
532
+ issues.push({ level: "warn", message: "flowStepList\uFF08\u5BA1\u6279\u8282\u70B9\uFF09\u4E3A\u7A7A\uFF1A\u65B9\u6848\u5C06\u6CA1\u6709\u5BA1\u6279\u73AF\u8282\uFF0C\u786E\u8BA4\u662F\u5426\u7B26\u5408\u6587\u6863" });
533
+ }
534
+ for (const field of ["includePlusItem", "includeMinusItem", "includeInterviewItem"]) {
535
+ if (req[field] !== void 0 && typeof req[field] !== "boolean") {
536
+ issues.push({ level: "error", message: `${field} \u5FC5\u987B\u662F\u5E03\u5C14 true/false\uFF0C\u5F97\u5230 ${JSON.stringify(req[field])}` });
537
+ }
538
+ }
539
+ if (Array.isArray(req.plusList) && req.plusList.length > 0 && req.includePlusItem !== true) {
540
+ issues.push({ level: "error", message: "plusList \u975E\u7A7A\u65F6\u5FC5\u987B includePlusItem=true" });
541
+ }
542
+ if (Array.isArray(req.minusList) && req.minusList.length > 0 && req.includeMinusItem !== true) {
543
+ issues.push({ level: "error", message: "minusList \u975E\u7A7A\u65F6\u5FC5\u987B includeMinusItem=true" });
544
+ }
545
+ if (req.includeInterviewItem === true && (!Array.isArray(req.interviewStepList) || req.interviewStepList.length === 0)) {
546
+ issues.push({ level: "error", message: "includeInterviewItem=true \u65F6 interviewStepList \u81F3\u5C11\u4E00\u4E2A\u8282\u70B9" });
547
+ }
548
+ const basicData = Array.isArray(req.basicData) ? req.basicData : [];
549
+ const weights = basicData.map((row) => num(row?.weight)).filter((w) => w !== null);
550
+ if (basicData.length && weights.length === basicData.length) {
551
+ const sum = weights.reduce((a, b) => a + b, 0);
552
+ if (Math.abs(sum - 100) > 0.01) {
553
+ issues.push({ level: "warn", message: `\u5E38\u89C4\u6307\u6807\u6743\u91CD\u5408\u8BA1 ${sum} \u2260 100\uFF08\u5DEE\u989D ${100 - sum}\uFF09\uFF0C\u7531\u7528\u6237\u51B3\u5B9A\u662F\u5426\u63A5\u53D7\u3002\u6CE8\u610F\uFF1A\u6743\u91CD\u6309\u767E\u5206\u6BD4\u53E3\u5F84\uFF0C\u4E0E\u5206\u5236(total)\u76F8\u4E92\u72EC\u7ACB\uFF0C\u4E0D\u56E0\u5206\u5236\u6362\u7B97` });
554
+ }
555
+ }
556
+ for (const field of ["teffectTime", "failureTime"]) {
557
+ if (req[field] !== void 0 && req[field] !== null && !DATE_RE.test(String(req[field]))) {
558
+ issues.push({ level: "error", message: `${field} \u683C\u5F0F\u5E94\u4E3A yyyy-MM-dd\uFF0C\u5F97\u5230 ${JSON.stringify(req[field])}` });
559
+ }
560
+ }
561
+ if (req.teffectTime && req.failureTime && String(req.teffectTime) >= String(req.failureTime)) {
562
+ issues.push({ level: "error", message: `\u751F\u6548\u65E5\u671F(${req.teffectTime})\u5FC5\u987B\u65E9\u4E8E\u5931\u6548\u65E5\u671F(${req.failureTime})` });
563
+ }
564
+ if (req.failureTime && DATE_RE.test(String(req.failureTime)) && String(req.failureTime) < (/* @__PURE__ */ new Date()).toISOString().slice(0, 10)) {
565
+ issues.push({ level: "warn", message: `\u5931\u6548\u65E5\u671F(${req.failureTime})\u5DF2\u65E9\u4E8E\u5F53\u524D\u65E5\u671F\uFF1A\u53D1\u5E03\u540E\u65B9\u6848\u4F1A\u88AB\u81EA\u52A8\u7F6E\u4E3A\u300C\u5DF2\u5931\u6548\u300D\uFF0C\u8BF7\u786E\u8BA4\u662F\u5426\u6539\u4E3A\u672A\u6765\u65E5\u671F` });
566
+ }
567
+ if (req.teffectTime && DATE_RE.test(String(req.teffectTime))) {
568
+ const twoYearsLater = /* @__PURE__ */ new Date();
569
+ twoYearsLater.setFullYear(twoYearsLater.getFullYear() + 2);
570
+ if (String(req.teffectTime) > twoYearsLater.toISOString().slice(0, 10)) {
571
+ issues.push({ level: "warn", message: `\u751F\u6548\u65E5\u671F(${req.teffectTime})\u8DDD\u4ECA\u8D85\u8FC7\u4E24\u5E74\uFF0C\u8BF7\u786E\u8BA4\u5E74\u4EFD\u662F\u5426\u62BD\u53D6\u9519\u8BEF` });
572
+ }
573
+ }
574
+ const links = Array.isArray(req.schemeLinkList) ? req.schemeLinkList : [];
575
+ for (const link of links) {
576
+ if (Number(link?.targetType) === 11) continue;
577
+ if (link?.id === void 0 || link?.id === null || link?.id === "") {
578
+ issues.push({ level: "error", message: `\u8003\u6838\u5BF9\u8C61\u300C${link?.name || "(\u672A\u547D\u540D)"}\u300D\u7F3A id\uFF08targetType=${link?.targetType}\uFF09\u2014\u2014\u5148\u7528 hrm.resolve \u89E3\u6790\u771F\u5B9E id` });
579
+ }
580
+ }
581
+ return issues;
582
+ }
583
+ function assertNoErrors(issues) {
584
+ const errors = issues.filter((issue) => issue.level === "error");
585
+ if (errors.length > 0) {
586
+ throw pfValidationError("scheme_validation_failed", "\u65B9\u6848\u53C2\u6570\u6821\u9A8C\u672A\u901A\u8FC7", {
587
+ errors: errors.map((issue) => issue.message)
588
+ });
589
+ }
590
+ return issues;
591
+ }
592
+ function schemeFingerprint(req) {
593
+ return createHash("sha256").update(JSON.stringify(req)).digest("hex");
594
+ }
595
+ var MODE_LABELS = { qualitative: "\u5B9A\u6027", quantify: "\u5B9A\u91CF" };
596
+ function categoryNameMap(req) {
597
+ const map = {};
598
+ const list = Array.isArray(req.checkType) ? req.checkType : [];
599
+ for (const item of list) {
600
+ if (item && item.id !== void 0 && item.typeName) map[String(item.id)] = String(item.typeName);
601
+ }
602
+ return map;
603
+ }
604
+ function buildIndicatorRows(req) {
605
+ const rows = Array.isArray(req.basicData) ? req.basicData : [];
606
+ const categories = categoryNameMap(req);
607
+ return rows.map((row, index) => {
608
+ const weight = num(row?.weight);
609
+ return {
610
+ index: index + 1,
611
+ name: row?.indicatorType ?? null,
612
+ mode: row?.indicatorMode ? MODE_LABELS[String(row.indicatorMode)] ?? null : null,
613
+ weight: weight === null ? "\u672A\u586B" : `${weight}%`,
614
+ target: row?.defaultTarget ? String(row.defaultTarget) : null,
615
+ category: row?.checkType ? categories[String(row.checkType)] ?? null : null,
616
+ description: row?.indicatorDescription ? String(row.indicatorDescription) : null
617
+ };
618
+ });
619
+ }
620
+ function buildBonusPenaltyRows(req, kind) {
621
+ const rows = Array.isArray(kind === "plus" ? req.plusList : req.minusList) ? kind === "plus" ? req.plusList : req.minusList : [];
622
+ const stepList = kind === "plus" ? req.plusStepList : req.minusStepList;
623
+ const raters = Array.isArray(stepList) ? stepList.flatMap((step) => Array.isArray(step?.stepOperators) ? step.stepOperators : []).map((op) => OPERATE_TYPE_LABELS[String(op?.operateType)] || null).filter((x) => Boolean(x)) : [];
624
+ const rater = raters.length ? [...new Set(raters)].join("/") : null;
625
+ return rows.map((row, index) => {
626
+ const max = num(row?.maxScore);
627
+ return {
628
+ index: index + 1,
629
+ name: row?.name ?? null,
630
+ rule: row?.description ? String(row.description) : null,
631
+ limit: max === null ? null : `${max} \u5206`,
632
+ rater,
633
+ note: null
634
+ };
635
+ });
636
+ }
637
+ function normalizeSchemeBody(input) {
638
+ const body = JSON.parse(JSON.stringify(input));
639
+ const issues = [];
640
+ if (Array.isArray(body.basicData)) {
641
+ body.basicData = body.basicData.map((row, index) => {
642
+ if (!row || typeof row !== "object") return row;
643
+ const raw = row.defaultTarget;
644
+ if (typeof raw !== "string" || !raw.trim()) return row;
645
+ const text = raw.trim();
646
+ const numeric = num(text);
647
+ if (numeric !== null) {
648
+ return { ...row, defaultTarget: numeric };
649
+ }
650
+ const prefix = `\u76EE\u6807\uFF1A${text}`;
651
+ const desc = typeof row.indicatorDescription === "string" ? row.indicatorDescription.trim() : "";
652
+ issues.push({
653
+ level: "warn",
654
+ message: `\u7B2C ${index + 1} \u884C\u300C${row.indicatorType || "\u672A\u547D\u540D"}\u300D\u7684\u76EE\u6807\u503C\u662F\u6587\u5B57\uFF08${text}\uFF09\uFF0C\u7CFB\u7EDF\u76EE\u6807\u503C\u5B57\u6BB5\u53EA\u63A5\u53D7\u6570\u5B57\uFF0C\u5DF2\u6539\u5199\u8FDB\u6307\u6807\u63CF\u8FF0`
655
+ });
656
+ return {
657
+ ...row,
658
+ defaultTarget: void 0,
659
+ indicatorDescription: desc ? `${desc}\uFF1B${prefix}` : prefix
660
+ };
661
+ });
662
+ body.basicData = body.basicData.map((row) => {
663
+ if (row && typeof row === "object" && "defaultTarget" in row && row.defaultTarget === void 0) {
664
+ const { defaultTarget: _drop, ...rest } = row;
665
+ return rest;
666
+ }
667
+ return row;
668
+ });
669
+ }
670
+ const fillStep = (listKey, stepKey, stepType) => {
671
+ const list = Array.isArray(body[listKey]) ? body[listKey] : [];
672
+ const steps = Array.isArray(body[stepKey]) ? body[stepKey] : [];
673
+ if (list.length === 0 || steps.length > 0) return;
674
+ body[stepKey] = [{ stepType, stepOperators: [{ operateType: "directSuperior" }] }];
675
+ issues.push({
676
+ level: "warn",
677
+ message: `${listKey} \u6709 ${list.length} \u9879\u4F46\u672A\u63D0\u4F9B ${stepKey}\uFF0C\u5DF2\u6309\u9ED8\u8BA4\u300C\u76F4\u63A5\u4E0A\u7EA7\u300D\u8865\u9F50\u8BC4\u5206\u4EBA\uFF08\u5426\u5219\u8BC4\u5206\u4EBA\u4E0D\u4F1A\u843D\u5E93\uFF09`
678
+ });
679
+ };
680
+ fillStep("plusList", "plusStepList", "kpiplus");
681
+ fillStep("minusList", "minusStepList", "kpiminus");
682
+ return { body, issues };
683
+ }
684
+
685
+ // src/shortcuts/performance/operations/types.ts
686
+ function pfSuccess(action, data, meta) {
687
+ const payload = { ok: true, action, data };
688
+ if (meta && Object.keys(meta).length > 0) payload.meta = meta;
689
+ const cont = meta?.continuation;
690
+ if (typeof cont === "string" && data && typeof data === "object" && !Array.isArray(data)) {
691
+ const obj = data;
692
+ if (!(typeof obj.continuation === "string" && obj.continuation)) obj.continuation = cont;
693
+ }
694
+ return payload;
695
+ }
696
+ function schemaOf(properties, options = {}) {
697
+ return {
698
+ type: "object",
699
+ additionalProperties: false,
700
+ properties,
701
+ ...options.required?.length ? { required: options.required } : {},
702
+ ...options.description ? { description: options.description } : {}
703
+ };
704
+ }
705
+
706
+ // src/shortcuts/performance/operations/scheme-draft.ts
707
+ var EDIT_PATH = "/api/workrelate/performance/scheme/edit";
708
+ var REQ_FIELDS = [...Object.keys(schemeEditReqSchema)];
709
+ function pickRequestBody(args) {
710
+ const body = {};
711
+ for (const field of REQ_FIELDS) {
712
+ if (args[field] !== void 0) body[field] = args[field];
713
+ }
714
+ if (Array.isArray(body.schemeLinkList)) {
715
+ body.schemeLinkList = body.schemeLinkList.map((link, index) => {
716
+ if (!link || typeof link !== "object") return link;
717
+ if (Number(link.targetType) === 11) return { ...link, id: "0" };
718
+ return { ...link, id: normalizeId(link.id, `schemeLinkList[${index}].id`) };
719
+ });
720
+ }
721
+ return body;
722
+ }
723
+ async function prepare(args, env) {
724
+ const normalized = normalizeSchemeBody(pickRequestBody(args));
725
+ const body = await ensureDetailIdForUpdate(env.host, normalized.body, "performance.scheme.draft.prepare");
726
+ const issues = assertNoErrors([...normalized.issues, ...validateScheme(body)]);
727
+ const summary = summarizeScheme(body);
728
+ const fingerprint = schemeFingerprint(body);
729
+ const continuation = await env.continuation.issue({
730
+ operation: "performance.scheme.draft.apply",
731
+ fingerprint
732
+ });
733
+ const preview = {
734
+ action: "\u6682\u5B58\u8349\u7A3F\uFF08POST /scheme/edit\uFF1B\u8986\u76D6\u5F0F\u5168\u91CF\u91CD\u5EFA\u6307\u6807/\u6D41\u7A0B/\u52A0\u51CF\u5206\u9879\uFF0C\u4E0D\u89E6\u53D1\u53D1\u5E03\u52A8\u4F5C\uFF09",
735
+ scheme: summary,
736
+ targets: describeTargets(body),
737
+ indicatorRows: buildIndicatorRows(body),
738
+ plusRows: buildBonusPenaltyRows(body, "plus"),
739
+ minusRows: buildBonusPenaltyRows(body, "minus"),
740
+ issues: issues.map((issue) => `[${issue.level === "warn" ? "WARN" : "ERROR"}] ${issue.message}`)
741
+ };
742
+ return pfSuccess("performance.scheme.draft.prepare", { continuation, fingerprint, preview }, {
743
+ continuation,
744
+ fingerprint,
745
+ confirmHint: "\u5411\u7528\u6237\u5C55\u793A preview \u6458\u8981\u5E76\u786E\u8BA4\u540E\uFF0C\u643A\u5E26 confirm=true \u4E0E\u672C continuation \u8C03\u7528 performance.scheme.draft.apply"
746
+ });
747
+ }
748
+ async function apply(args, env) {
749
+ if (args.confirm !== true) {
750
+ throw pfConfirmationError("performance.scheme.draft.apply", { hint: "\u5FC5\u987B\u5148\u5411\u7528\u6237\u5C55\u793A prepare \u6458\u8981\u5E76\u83B7\u5F97\u660E\u786E\u786E\u8BA4" });
751
+ }
752
+ if (typeof args.continuation !== "string" || !args.continuation) {
753
+ throw pfValidationError("continuation_missing", "\u7F3A\u5C11 continuation\uFF08\u5148\u8FD0\u884C performance.scheme.draft.prepare\uFF09");
754
+ }
755
+ const verified = await env.continuation.verify(args.continuation, "performance.scheme.draft.apply");
756
+ const normalized = normalizeSchemeBody(pickRequestBody(args));
757
+ const body = await ensureDetailIdForUpdate(env.host, normalized.body, "performance.scheme.draft.apply");
758
+ assertNoErrors([...normalized.issues, ...validateScheme(body)]);
759
+ const fingerprint = schemeFingerprint(body);
760
+ if (String(verified.fingerprint) !== fingerprint) {
761
+ throw pfValidationError("fingerprint_mismatch", "\u63D0\u4EA4\u5185\u5BB9\u4E0E\u786E\u8BA4\u6458\u8981\u4E0D\u4E00\u81F4\uFF08\u53C2\u6570\u5728 prepare \u4E4B\u540E\u88AB\u4FEE\u6539\uFF09\uFF0C\u8BF7\u91CD\u65B0 prepare \u5E76\u518D\u6B21\u786E\u8BA4", {
762
+ expected: verified.fingerprint,
763
+ actual: fingerprint
764
+ });
765
+ }
766
+ const response = await env.host.request({
767
+ path: EDIT_PATH,
768
+ body,
769
+ operation: "performance.scheme.draft.apply"
770
+ });
771
+ const schemeId = assertWeaResult(response, "\u6682\u5B58\u8349\u7A3F");
772
+ return pfSuccess("performance.scheme.draft.apply", {
773
+ schemeId,
774
+ status: args.id ? "draft-updated" : "draft-created",
775
+ next: "\u7528 performance.scheme.detail \u56DE\u8BFB\u6838\u5BF9\uFF1B\u53D1\u5E03\u987B\u7528\u6237\u660E\u786E\u540C\u610F\u540E\u8D70 performance.scheme.publish.prepare"
776
+ });
777
+ }
778
+ var schemeDraftOperations = [
779
+ {
780
+ name: "performance.scheme.draft.prepare",
781
+ resource: "performance.scheme",
782
+ method: "prepare",
783
+ action: "scheme.draft",
784
+ summary: "\u6682\u5B58\u8349\u7A3F\u524D\u6821\u9A8C\u5E76\u751F\u6210\u786E\u8BA4\u6458\u8981\uFF08\u4E0D\u843D\u5E93\uFF09\uFF1B\u8FD4\u56DE continuation \u4E0E\u63D0\u4EA4\u6307\u7EB9",
785
+ capability: "performance.scheme.draft",
786
+ risk: "write",
787
+ requiresConfirmation: true,
788
+ inputSchema: schemaOf(schemeEditReqSchema, { required: ["name", "schemeLinkList"] }),
789
+ handler: prepare
790
+ },
791
+ {
792
+ name: "performance.scheme.draft.apply",
793
+ resource: "performance.scheme",
794
+ method: "apply",
795
+ action: "scheme.draft",
796
+ summary: "\u786E\u8BA4\u540E\u6682\u5B58\u8349\u7A3F\uFF08POST /scheme/edit\uFF0C\u8986\u76D6\u5F0F\u5168\u91CF\u6682\u5B58\uFF0C\u4E0D\u89E6\u53D1\u53D1\u5E03\uFF09",
797
+ capability: "performance.scheme.draft",
798
+ risk: "write",
799
+ requiresConfirmation: true,
800
+ inputSchema: schemaOf(
801
+ {
802
+ ...schemeEditReqSchema,
803
+ confirm: { type: "boolean", description: "\u5FC5\u987B true\uFF08\u7528\u6237\u5DF2\u786E\u8BA4 prepare \u6458\u8981\uFF09" },
804
+ continuation: { type: "string", description: "prepare \u8FD4\u56DE\u7684 continuation" }
805
+ },
806
+ { required: ["name", "schemeLinkList", "confirm", "continuation"] }
807
+ ),
808
+ handler: apply
809
+ }
810
+ ];
811
+
812
+ // src/shortcuts/performance/operations/scheme-publish.ts
813
+ var APPLY_PATH = "/api/workrelate/performance/scheme/applyScheme";
814
+ var DETAIL_PATH2 = "/api/workrelate/performance/scheme/detail";
815
+ var REQ_FIELDS2 = [...Object.keys(schemeEditReqSchema)];
816
+ function pickRequestBody2(args) {
817
+ const body = {};
818
+ for (const field of REQ_FIELDS2) {
819
+ if (args[field] !== void 0) body[field] = args[field];
820
+ }
821
+ return body;
822
+ }
823
+ function requireId(args) {
824
+ if (args.id === void 0 || args.id === null || args.id === "") {
825
+ throw pfValidationError("id_missing", "\u53D1\u5E03\u5DF2\u6709\u65B9\u6848\u5FC5\u987B\u4F20 id\uFF08\u4E0D\u5E26 id \u4F1A\u76F4\u63A5\u521B\u5EFA\u5E76\u53D1\u5E03\u65B0\u65B9\u6848\uFF09");
826
+ }
827
+ return normalizeId(args.id, "id");
828
+ }
829
+ var DETAIL_REQ_FIELDS = REQ_FIELDS2;
830
+ function readBackScheme(detailData) {
831
+ const body = {};
832
+ for (const field of DETAIL_REQ_FIELDS) {
833
+ if (detailData[field] !== void 0 && detailData[field] !== null) body[field] = detailData[field];
834
+ }
835
+ body.id = normalizeId(detailData.id, "detail.id");
836
+ body.detailId = normalizeId(detailData.detailId, "detail.detailId");
837
+ return body;
838
+ }
839
+ async function prepare2(args, env) {
840
+ const id = requireId(args);
841
+ const detailResponse = await env.host.request({
842
+ path: `${DETAIL_PATH2}/${encodeURIComponent(String(id))}`,
843
+ method: "GET",
844
+ operation: "performance.scheme.publish.prepare"
845
+ });
846
+ const detailData = assertWeaResult(detailResponse, "\u8BFB\u53D6\u65B9\u6848\u8BE6\u60C5");
847
+ if (!detailData || typeof detailData !== "object") {
848
+ throw pfFail("\u8BFB\u53D6\u65B9\u6848\u8BE6\u60C5\uFF1A\u8FD4\u56DE data \u4E0D\u662F\u5BF9\u8C61", { id });
849
+ }
850
+ if (detailData.detailId === void 0 || detailData.detailId === null || detailData.detailId === "") {
851
+ throw pfValidationError("detail_id_missing", "\u65B9\u6848\u8BE6\u60C5\u56DE\u8BFB\u4E0D\u5230 detailId\u2014\u2014\u4E3A\u9632\u91CD\u590D\u660E\u7EC6\u4E8B\u6545\uFF0C\u7981\u6B62\u53D1\u5E03\uFF1B\u8BF7\u5728\u65B9\u6848\u7F16\u8F91\u9875\u6838\u5BF9\u8BE5\u65B9\u6848", { id });
852
+ }
853
+ const overrides = pickRequestBody2(args);
854
+ delete overrides.confirm;
855
+ const detailId = normalizeId(detailData.detailId, "detail.detailId");
856
+ const body = { ...readBackScheme(detailData), ...overrides, id: String(id), detailId };
857
+ const issues = assertNoErrors(validateScheme(body));
858
+ const summary = summarizeScheme(body);
859
+ const fingerprint = schemeFingerprint(body);
860
+ const continuation = await env.continuation.issue({
861
+ operation: "performance.scheme.publish.apply",
862
+ fingerprint
863
+ });
864
+ const preview = {
865
+ action: "\u53D1\u5E03\u65B9\u6848\uFF08POST /scheme/applyScheme\uFF09\u2014\u2014\u6B63\u5F0F\u52A8\u4F5C\uFF1A\u89E6\u53D1\u7248\u672C\u7BA1\u7406\u3001ESB \u52A8\u4F5C\u6D41\u3001\u63D0\u9192\uFF0C\u65B9\u6848\u7ACB\u5373\u751F\u6548",
866
+ currentStatus: detailData.status ?? null,
867
+ scheme: summary,
868
+ targets: describeTargets(body),
869
+ issues: issues.map((issue) => `[${issue.level === "warn" ? "WARN" : "ERROR"}] ${issue.message}`),
870
+ fatalNote: "id \u4E0E detailId \u5DF2\u4ECE detail \u56DE\u8BFB\u5E76\u5F3A\u5236\u5E26\u4E0A\uFF08detailId \u4E22\u5931\u4F1A\u5BFC\u81F4\u65B9\u6848\u6570\u636E\u635F\u574F\uFF0C\u7981\u6B62\u5254\u9664\uFF09"
871
+ };
872
+ return pfSuccess("performance.scheme.publish.prepare", { continuation, fingerprint, preview }, {
873
+ continuation,
874
+ fingerprint,
875
+ confirmHint: "\u53D1\u5E03\u5FC5\u987B\u7528\u6237\u660E\u786E\u540C\u610F\u3002\u5C55\u793A preview\uFF08\u542B\u53D1\u5E03\u8BED\u4E49\u63D0\u793A\uFF09\u786E\u8BA4\u540E\uFF0C\u643A\u5E26 confirm=true \u4E0E continuation \u8C03\u7528 performance.scheme.publish.apply"
876
+ });
877
+ }
878
+ async function apply2(args, env) {
879
+ if (args.confirm !== true) {
880
+ throw pfConfirmationError("performance.scheme.publish.apply", { hint: "\u53D1\u5E03\u662F\u6B63\u5F0F\u52A8\u4F5C\uFF0C\u5FC5\u987B\u7528\u6237\u660E\u786E\u540C\u610F" });
881
+ }
882
+ if (typeof args.continuation !== "string" || !args.continuation) {
883
+ throw pfValidationError("continuation_missing", "\u7F3A\u5C11 continuation\uFF08\u5148\u8FD0\u884C performance.scheme.publish.prepare\uFF09");
884
+ }
885
+ const verified = await env.continuation.verify(args.continuation, "performance.scheme.publish.apply");
886
+ const id = requireId(args);
887
+ const detailResponse = await env.host.request({
888
+ path: `${DETAIL_PATH2}/${encodeURIComponent(String(id))}`,
889
+ method: "GET",
890
+ operation: "performance.scheme.publish.apply"
891
+ });
892
+ const detailData = assertWeaResult(detailResponse, "\u8BFB\u53D6\u65B9\u6848\u8BE6\u60C5");
893
+ if (detailData?.detailId === void 0 || detailData?.detailId === null || detailData?.detailId === "") {
894
+ throw pfValidationError("detail_id_missing", "\u65B9\u6848\u8BE6\u60C5\u56DE\u8BFB\u4E0D\u5230 detailId\u2014\u2014\u4E3A\u9632\u91CD\u590D\u660E\u7EC6\u4E8B\u6545\uFF0C\u7981\u6B62\u53D1\u5E03", { id });
895
+ }
896
+ const overrides = pickRequestBody2(args);
897
+ delete overrides.confirm;
898
+ const detailId = normalizeId(detailData.detailId, "detail.detailId");
899
+ const body = { ...readBackScheme(detailData), ...overrides, id: String(id), detailId };
900
+ assertNoErrors(validateScheme(body));
901
+ const fingerprint = schemeFingerprint(body);
902
+ if (String(verified.fingerprint) !== fingerprint) {
903
+ throw pfValidationError("fingerprint_mismatch", "\u63D0\u4EA4\u5185\u5BB9\u4E0E\u786E\u8BA4\u6458\u8981\u4E0D\u4E00\u81F4\uFF08\u65B9\u6848\u6570\u636E\u6216\u53C2\u6570\u5728 prepare \u4E4B\u540E\u53D1\u751F\u53D8\u5316\uFF09\uFF0C\u8BF7\u91CD\u65B0 prepare \u5E76\u518D\u6B21\u786E\u8BA4", {
904
+ expected: verified.fingerprint,
905
+ actual: fingerprint
906
+ });
907
+ }
908
+ const response = await env.host.request({
909
+ path: APPLY_PATH,
910
+ body,
911
+ operation: "performance.scheme.publish.apply"
912
+ });
913
+ const schemeId = assertWeaResult(response, "\u53D1\u5E03\u65B9\u6848");
914
+ return pfSuccess("performance.scheme.publish.apply", {
915
+ schemeId,
916
+ status: "published",
917
+ next: "\u7528 performance.scheme.detail \u6838\u5BF9 status=finished / applyStatus\uFF1B\u65B9\u6848\u8BBE\u7F6E\u9875\u53EF\u5728 E10 \u524D\u7AEF\u7EE7\u7EED\u5B8C\u5584"
918
+ });
919
+ }
920
+ var schemePublishOperations = [
921
+ {
922
+ name: "performance.scheme.publish.prepare",
923
+ resource: "performance.scheme",
924
+ method: "prepare",
925
+ action: "scheme.publish",
926
+ summary: "\u53D1\u5E03\u524D\u81EA\u52A8 detail \u56DE\u8BFB\u7EC4\u88C5\u5B8C\u6574\u53C2\u6570\uFF08\u5F3A\u5236\u5E26 id+detailId\uFF09\u5E76\u751F\u6210\u786E\u8BA4\u6458\u8981\uFF1B\u4E0D\u843D\u5E93",
927
+ capability: "performance.scheme.publish",
928
+ risk: "write",
929
+ requiresConfirmation: true,
930
+ inputSchema: schemaOf(
931
+ {
932
+ ...schemeEditReqSchema
933
+ // 发布推荐只传 id(其余参数自动回读);显式传入的字段会覆盖回读值。
934
+ },
935
+ { required: ["id"], description: "\u63A8\u8350\u53EA\u4F20 id\uFF1A\u53C2\u6570\u81EA\u52A8\u4ECE detail \u56DE\u8BFB\u7EC4\u88C5\uFF08detailId \u9632\u4E22\uFF09\uFF1B\u4E5F\u53EF\u663E\u5F0F\u8986\u76D6\u4E2A\u522B\u5B57\u6BB5" }
936
+ ),
937
+ handler: prepare2
938
+ },
939
+ {
940
+ name: "performance.scheme.publish.apply",
941
+ resource: "performance.scheme",
942
+ method: "apply",
943
+ action: "scheme.publish",
944
+ summary: "\u786E\u8BA4\u540E\u53D1\u5E03\u65B9\u6848\uFF08POST /scheme/applyScheme\uFF1B\u6B63\u5F0F\u52A8\u4F5C\uFF0C\u89E6\u53D1\u7248\u672C/ESB/\u63D0\u9192\uFF09",
945
+ capability: "performance.scheme.publish",
946
+ risk: "write",
947
+ requiresConfirmation: true,
948
+ inputSchema: schemaOf(
949
+ {
950
+ ...schemeEditReqSchema,
951
+ confirm: { type: "boolean", description: "\u5FC5\u987B true\uFF08\u7528\u6237\u5DF2\u660E\u786E\u540C\u610F\u53D1\u5E03\uFF09" },
952
+ continuation: { type: "string", description: "prepare \u8FD4\u56DE\u7684 continuation" }
953
+ },
954
+ { required: ["id", "confirm", "continuation"] }
955
+ ),
956
+ handler: apply2
957
+ }
958
+ ];
959
+
960
+ // src/shortcuts/performance/operations/scheme-detail.ts
961
+ var DETAIL_PATH3 = "/api/workrelate/performance/scheme/detail";
962
+ async function detail(args, env) {
963
+ if (args.id === void 0 || args.id === null || args.id === "") {
964
+ throw pfValidationError("id_missing", "\u7F3A\u5C11\u65B9\u6848 id");
965
+ }
966
+ const id = normalizeId(args.id, "id");
967
+ const response = await env.host.request({
968
+ path: `${DETAIL_PATH3}/${encodeURIComponent(id)}`,
969
+ method: "GET",
970
+ operation: "performance.scheme.detail"
971
+ });
972
+ const data = assertWeaResult(response, "\u8BFB\u53D6\u65B9\u6848\u8BE6\u60C5");
973
+ if (!data || typeof data !== "object") {
974
+ throw pfValidationError("detail_not_object", "\u65B9\u6848\u8BE6\u60C5\u8FD4\u56DE data \u4E0D\u662F\u5BF9\u8C61", { id });
975
+ }
976
+ const summary = summarizeScheme(data);
977
+ const missing = [];
978
+ if (!summary.indicatorCount) missing.push("\u5E38\u89C4\u6307\u6807");
979
+ if (!summary.plusCount) missing.push("\u52A0\u5206\u9879");
980
+ if (!summary.minusCount) missing.push("\u51CF\u5206\u9879");
981
+ if (!summary.steps.length) missing.push("\u8BC4\u5206/\u5BA1\u6279\u8282\u70B9");
982
+ if (!summary.teffectTime) missing.push("\u751F\u6548\u65E5\u671F");
983
+ if (!data.detailId) missing.push("detailId\uFF08\u5F02\u5E38\uFF1A\u53D1\u5E03\u524D\u5FC5\u987B\u5148\u4FEE\u590D\uFF0C\u89C1 publish.prepare\uFF09");
984
+ return pfSuccess("performance.scheme.detail", {
985
+ schemeId: String(id),
986
+ status: data.status ?? null,
987
+ applyStatus: data.applyStatus ?? null,
988
+ detailId: data.detailId === void 0 || data.detailId === null ? null : String(data.detailId),
989
+ summary,
990
+ targets: describeTargets(data),
991
+ // 业务行:Agent 直接按此渲染表格,禁止只报计数
992
+ indicatorRows: buildIndicatorRows(data),
993
+ plusRows: buildBonusPenaltyRows(data, "plus"),
994
+ minusRows: buildBonusPenaltyRows(data, "minus"),
995
+ missing,
996
+ targetTypeLegend: TARGET_TYPE_LABELS,
997
+ data
998
+ });
999
+ }
1000
+ var schemeDetailOperations = [
1001
+ {
1002
+ name: "performance.scheme.detail",
1003
+ resource: "performance.scheme",
1004
+ method: "query",
1005
+ action: "scheme.detail",
1006
+ summary: "\u56DE\u8BFB\u65B9\u6848\u8BE6\u60C5\uFF08\u8349\u7A3F\u6001\u6B63\u5E38\uFF09\uFF0C\u8FD4\u56DE\u7CBE\u7B80\u6838\u5BF9\u89C6\u56FE + \u7F3A\u5931\u9879\u63D0\u793A + \u5B8C\u6574\u539F\u6587",
1007
+ capability: "performance.scheme.detail",
1008
+ risk: "read",
1009
+ inputSchema: schemaOf(
1010
+ {
1011
+ id: { type: "string", description: "\u65B9\u6848 id\uFF0C\u5B57\u7B26\u4E32\u5F62\u5F0F\uFF0818 \u4F4D Long \u7528\u6570\u5B57\u4F1A\u4E22\u7CBE\u5EA6\uFF09" }
1012
+ },
1013
+ { required: ["id"] }
1014
+ ),
1015
+ handler: detail
1016
+ }
1017
+ ];
1018
+
1019
+ // src/shortcuts/performance/operations/hrm-resolve.ts
1020
+ var ENTITY_TYPES = {
1021
+ resource: {
1022
+ path: "/api/hrm/common/browser/complete/resource",
1023
+ label: "\u4EBA\u5458",
1024
+ targetTypes: [{ targetType: 1, when: "\u8003\u6838\u5BF9\u8C61\u6216\u5177\u540D\u8BC4\u5206\u4EBA\uFF08fixedMan \u7684 operater\uFF09" }],
1025
+ body: {
1026
+ browserMultiple: true,
1027
+ authWecahtBook: false,
1028
+ wxDepNeedConvertCount: 0,
1029
+ wxEmpNeedConvertCount: 0,
1030
+ wxTotalNeedConvertCount: 0,
1031
+ hideParttime: true,
1032
+ newly: 0
1033
+ }
1034
+ },
1035
+ department: {
1036
+ path: "/api/hrm/common/browser/complete/department",
1037
+ label: "\u90E8\u95E8",
1038
+ targetTypes: [
1039
+ { targetType: 2, when: "\u4EC5\u672C\u90E8\u95E8" },
1040
+ { targetType: 3, when: "\u300C\u542B\u4E0B\u7EA7/\u542B\u5B50\u90E8\u95E8\u300D" }
1041
+ ],
1042
+ body: { browserMultiple: true, virtualType: "ALL", newly: 0 }
1043
+ },
1044
+ subcompany: {
1045
+ path: "/api/hrm/common/browser/complete/subcompany",
1046
+ label: "\u5206\u90E8",
1047
+ targetTypes: [
1048
+ { targetType: 5, when: "\u4EC5\u672C\u5206\u90E8" },
1049
+ { targetType: 6, when: "\u300C\u542B\u4E0B\u7EA7\u300D" }
1050
+ ],
1051
+ body: { browserMultiple: true, virtualType: "ALL", newly: 0 }
1052
+ },
1053
+ role: {
1054
+ path: "/api/hrm/common/browser/complete/role",
1055
+ label: "\u89D2\u8272",
1056
+ targetTypes: [{ targetType: 10, when: "\u89D2\u8272\uFF08\u8FD8\u9700\u5411\u7528\u6237\u786E\u8BA4 role_level \u89D2\u8272\u7EA7\u522B\uFF09" }],
1057
+ body: { browserMultiple: true, newly: 0 }
1058
+ },
1059
+ position: {
1060
+ path: "/api/hrm/common/browser/complete/position",
1061
+ label: "\u5C97\u4F4D",
1062
+ targetTypes: [
1063
+ { targetType: 12, when: "\u5C97\u4F4D+\u6307\u5B9A\u90E8\u95E8\uFF08\u6587\u6863\u5199\u660E\u5177\u4F53\u90E8\u95E8\uFF09" },
1064
+ { targetType: 13, when: "\u5C97\u4F4D+\u6307\u5B9A\u5206\u90E8\uFF08\u6587\u6863\u5199\u660E\u5177\u4F53\u5206\u90E8\uFF09" },
1065
+ { targetType: 1311, when: "\u5C97\u4F4D+\u603B\u90E8\uFF08\u9ED8\u8BA4\uFF0C\u4E0D\u9650\u8303\u56F4\u65F6\u7528\u8FD9\u4E2A\uFF09" }
1066
+ ],
1067
+ body: { browserMultiple: true, newly: 0 }
1068
+ }
1069
+ };
1070
+ async function resolve2(args, env) {
1071
+ const entityType = String(args.entityType || "");
1072
+ const spec = ENTITY_TYPES[entityType];
1073
+ if (!spec) {
1074
+ throw pfValidationError("entity_type_unknown", `\u4E0D\u652F\u6301\u7684\u5B9E\u4F53\u7C7B\u578B\uFF1A${entityType || "(\u7A7A)"}\u3002\u652F\u6301\uFF1A${Object.keys(ENTITY_TYPES).join("/")}`, {
1075
+ supported: Object.keys(ENTITY_TYPES)
1076
+ });
1077
+ }
1078
+ const keyword = String(args.keyword ?? "").trim();
1079
+ if (!keyword) {
1080
+ throw pfValidationError("keyword_missing", "\u7F3A\u5C11\u641C\u7D22\u5173\u952E\u5B57 keyword");
1081
+ }
1082
+ const response = await env.host.request({
1083
+ path: spec.path,
1084
+ body: { ...spec.body, searchValue: keyword },
1085
+ operation: "performance.hrm.resolve"
1086
+ });
1087
+ const list = Array.isArray(response?.data?.data) ? response.data.data : [];
1088
+ const candidates = list.map((item) => ({
1089
+ id: item?.id,
1090
+ name: item?.name ?? null,
1091
+ title: item?.title ?? null,
1092
+ contentDesc: item?.contentDesc ?? null,
1093
+ statusCode: item?.statusCode ?? null
1094
+ }));
1095
+ return pfSuccess("performance.hrm.resolve", {
1096
+ entityType,
1097
+ entityLabel: spec.label,
1098
+ keyword,
1099
+ candidateCount: candidates.length,
1100
+ exactMatch: candidates.length === 1 && candidates[0]?.name === keyword ? candidates[0] : null,
1101
+ candidates,
1102
+ suggestedTargetTypes: spec.targetTypes,
1103
+ usage: [
1104
+ "\u547D\u4E2D\u552F\u4E00\u4E14 name \u4E0E\u6587\u6863\u540D\u79F0\u5B8C\u5168\u4E00\u81F4 \u2192 \u53EF\u76F4\u63A5\u91C7\u7528\u5176 id",
1105
+ "\u8003\u6838\u8303\u56F4\u5DF2\u786E\u5B9A\u4E14\u591A\u4E2A\u5019\u9009\u540D\u79F0\u5B8C\u5168\u4E00\u81F4 \u2192 \u9009\u8FD4\u56DE\u987A\u5E8F\u7B2C\u4E00\u4E2A\uFF0C\u6458\u8981\u5C55\u793A\u540D\u79F0\u3001id \u548C\u8303\u56F4\uFF1B\u65E0\u7CBE\u786E\u5339\u914D\u6216\u5177\u540D\u8BC4\u5206\u4EBA\u6709\u6B67\u4E49 \u2192 \u8BF7\u7528\u6237\u9009\u62E9",
1106
+ "statusCode \u975E normal \u7684\u4EBA\u5458\u5019\u9009\u6807\u6CE8\u72B6\u6001\uFF0C\u9ED8\u8BA4\u4E0D\u9009\u7528",
1107
+ "id \u4E3A\u5B57\u7B26\u4E32\uFF1B\u5199\u5165 SchemeEditReq \u65F6\u6309 targetType \u7EC4\u88C5 schemeLinkList \u6761\u76EE"
1108
+ ]
1109
+ });
1110
+ }
1111
+ var hrmResolveOperations = [
1112
+ {
1113
+ name: "performance.hrm.resolve",
1114
+ resource: "performance.hrm",
1115
+ method: "query",
1116
+ action: "hrm.resolve",
1117
+ summary: "\u6309\u5173\u952E\u5B57\u641C\u7D22\u7EC4\u7EC7\u5B9E\u4F53\uFF08\u4EBA\u5458/\u90E8\u95E8/\u5206\u90E8/\u89D2\u8272/\u5C97\u4F4D\uFF09\uFF0C\u8FD4\u56DE\u5019\u9009\u4E0E\u5EFA\u8BAE targetType",
1118
+ capability: "performance.hrm.resolve",
1119
+ risk: "read",
1120
+ inputSchema: schemaOf(
1121
+ {
1122
+ entityType: { type: "string", enum: Object.keys(ENTITY_TYPES), description: "\u5B9E\u4F53\u7C7B\u578B\uFF1Aresource=\u4EBA\u5458/department=\u90E8\u95E8/subcompany=\u5206\u90E8/role=\u89D2\u8272/position=\u5C97\u4F4D" },
1123
+ keyword: { type: "string", description: "\u641C\u7D22\u5173\u952E\u5B57\uFF08\u6A21\u7CCA\u5339\u914D\uFF09" }
1124
+ },
1125
+ { required: ["entityType", "keyword"] }
1126
+ ),
1127
+ handler: resolve2
1128
+ }
1129
+ ];
1130
+
1131
+ // src/shortcuts/performance/operations/registry.ts
1132
+ var definitions = [
1133
+ ...hrmResolveOperations,
1134
+ ...schemeDetailOperations,
1135
+ ...schemeDraftOperations,
1136
+ ...schemePublishOperations
1137
+ ];
1138
+ var registry = /* @__PURE__ */ new Map();
1139
+ for (const definition of definitions) {
1140
+ if (registry.has(definition.name)) {
1141
+ throw new Error(`duplicate performance operation: ${definition.name}`);
1142
+ }
1143
+ registry.set(definition.name, definition);
1144
+ }
1145
+ function performanceOperationDefinitions() {
1146
+ return [...registry.values()];
1147
+ }
1148
+ function getPerformanceOperation(operation) {
1149
+ const definition = registry.get(operation);
1150
+ if (!definition) {
1151
+ throw new PerformanceCliError("validation", "operation_unknown", `\u7EE9\u6548\u65B9\u6848\u6A21\u5757\u4E0D\u652F\u6301\u64CD\u4F5C\uFF1A${operation}`, {
1152
+ exitCode: 1
1153
+ });
1154
+ }
1155
+ return definition;
1156
+ }
1157
+ async function executePerformanceOperation(operation, input, env) {
1158
+ const definition = getPerformanceOperation(operation);
1159
+ const schema = definition.inputSchema;
1160
+ if (schema && schema.additionalProperties === false) {
1161
+ const known = Object.keys(schema.properties || {});
1162
+ const unknown = Object.keys(input || {}).filter((key) => !known.includes(key));
1163
+ if (unknown.length > 0) {
1164
+ throw new PerformanceCliError(
1165
+ "validation",
1166
+ "unknown_argument",
1167
+ `\u672A\u77E5\u53C2\u6570\uFF1A${unknown.join("\u3001")}\u3002\u672C\u64CD\u4F5C\u652F\u6301\u7684\u53C2\u6570\uFF1A${known.length ? known.join("\u3001") : "\uFF08\u65E0\uFF09"}\u3002\u53C2\u6570\u540D\u5199\u9519\u4F1A\u88AB\u9759\u9ED8\u5FFD\u7565\u5E76\u8FD4\u56DE\u770B\u4F3C\u6B63\u5E38\u7684\u7ED3\u679C\uFF0C\u8BF7\u6309\u4E0A\u9762\u7684\u53C2\u6570\u540D\u91CD\u4F20\u3002`,
1168
+ { exitCode: 1 }
1169
+ );
1170
+ }
1171
+ }
1172
+ return definition.handler(input, env);
1173
+ }
1174
+
1175
+ // src/shortcuts/performance/manifest.ts
1176
+ function buildOperations() {
1177
+ return performanceOperationDefinitions().map((definition) => ({
1178
+ name: definition.name,
1179
+ resource: definition.resource,
1180
+ summary: definition.summary,
1181
+ ...definition.capability ? { capability: definition.capability } : {},
1182
+ risk: definition.risk,
1183
+ ...definition.requiresConfirmation ? { requiresConfirmation: true } : {},
1184
+ inputSchema: definition.inputSchema
1185
+ }));
1186
+ }
1187
+ var performanceManifest = {
1188
+ schemaVersion: 1,
1189
+ name: "performance",
1190
+ title: "\u6CDB\u5FAEE10\u7EE9\u6548\u65B9\u6848\uFF08\u6587\u6863\u5BFC\u5165 \u2192 \u8349\u7A3F \u2192 \u786E\u8BA4\u53D1\u5E03\uFF09",
1191
+ version: "0.1.0",
1192
+ host: "e10-performance",
1193
+ status: "builtin",
1194
+ sourceSkill: "weaver-e10-performance",
1195
+ capabilities: ["performance.hrm.resolve", "performance.scheme.detail", "performance.scheme.draft", "performance.scheme.publish"],
1196
+ operations: buildOperations(),
1197
+ withheldOperations: []
1198
+ };
1199
+
1200
+ // src/shortcuts/performance/index.ts
1201
+ function asOptions(value) {
1202
+ return value && typeof value === "object" && !Array.isArray(value) ? value : {};
1203
+ }
1204
+ async function readStdin() {
1205
+ const chunks = [];
1206
+ for await (const chunk of process.stdin) {
1207
+ chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk));
1208
+ }
1209
+ return Buffer.concat(chunks).toString("utf8");
1210
+ }
1211
+ function stripBom(value) {
1212
+ return value.replace(/^\uFEFF+/, "");
1213
+ }
1214
+ async function inputFrom(options) {
1215
+ const opts = asOptions(options);
1216
+ let input = {};
1217
+ if (opts.input && opts.inputJson) {
1218
+ throw pfValidationError("input_conflict", "\u4E0D\u80FD\u540C\u65F6\u4F20 --input \u548C --input-json");
1219
+ }
1220
+ if (opts.inputJson) {
1221
+ input = parseJsonInput(String(opts.inputJson), "--input-json");
1222
+ }
1223
+ if (opts.input) {
1224
+ let raw;
1225
+ try {
1226
+ raw = stripBom(opts.input === "-" ? await readStdin() : await readFile2(String(opts.input), "utf8"));
1227
+ } catch {
1228
+ throw pfValidationError("input_unreadable", `\u65E0\u6CD5\u8BFB\u53D6 --input\uFF1A${String(opts.input)}`);
1229
+ }
1230
+ input = parseJsonInput(raw, "--input");
1231
+ }
1232
+ return input;
1233
+ }
1234
+ function parseJsonInput(raw, label) {
1235
+ try {
1236
+ const parsed = JSON.parse(stripBom(raw));
1237
+ if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
1238
+ throw new Error("input must be an object");
1239
+ }
1240
+ return parsed;
1241
+ } catch {
1242
+ throw pfValidationError("input_invalid", `${label} \u4E0D\u662F\u5408\u6CD5 JSON \u5BF9\u8C61`);
1243
+ }
1244
+ }
1245
+ function successEnvelope(operation, result) {
1246
+ return {
1247
+ schemaVersion: 1,
1248
+ ok: true,
1249
+ operation,
1250
+ data: result.data === void 0 ? null : result.data,
1251
+ ...result.meta ? { meta: result.meta } : {},
1252
+ warnings: []
1253
+ };
1254
+ }
1255
+ function failureEnvelope(error) {
1256
+ const structured = error;
1257
+ return {
1258
+ schemaVersion: 1,
1259
+ ok: false,
1260
+ ...structured?.partialData === void 0 ? {} : { data: structured.partialData },
1261
+ error: toErrorEnvelope(error)
1262
+ };
1263
+ }
1264
+ async function executeAndPrint(ctx, operation, input) {
1265
+ try {
1266
+ const host = createPerformanceHost(ctx);
1267
+ const result = await executePerformanceOperation(operation, input, {
1268
+ ctx,
1269
+ host,
1270
+ continuation: createPerformanceContinuationSigner(ctx)
1271
+ });
1272
+ ctx.output.write(successEnvelope(operation, result), { json: true });
1273
+ } catch (error) {
1274
+ console.error(JSON.stringify(failureEnvelope(error), null, 2));
1275
+ process.exitCode = isCliError(error) ? error.exitCode : 1 /* GeneralError */;
1276
+ }
1277
+ }
1278
+ var performanceShortcut = {
1279
+ name: "performance",
1280
+ description: "\u6CDB\u5FAEE10\u7EE9\u6548\u65B9\u6848\uFF08\u6587\u6863\u5BFC\u5165 \u2192 \u8349\u7A3F \u2192 \u786E\u8BA4\u53D1\u5E03\uFF09CLI",
1281
+ category: "shortcut",
1282
+ register({ program, action }) {
1283
+ const pf = program.command("performance").description("\u6CDB\u5FAEE10\u7EE9\u6548\u65B9\u6848\uFF08\u5B9E\u4F53\u89E3\u6790/\u843D\u8349\u7A3F/\u56DE\u8BFB\u6838\u5BF9/\u786E\u8BA4\u53D1\u5E03\uFF09");
1284
+ pf.command("schema").description("Print performance operation manifest for agents").action(action((ctx) => {
1285
+ ctx.output.write(performanceManifest, { json: true });
1286
+ }));
1287
+ pf.command("run").description("Run a performance operation with JSON input").argument("<operation>", "operation name, e.g. performance.scheme.draft.prepare").option("--input <path>", "JSON input file, or - for stdin").option("--input-json <json>", "inline JSON input object").action(action(async (ctx, operation, options) => {
1288
+ await executeAndPrint(ctx, String(operation), await inputFrom(options));
1289
+ }));
1290
+ }
1291
+ };
1292
+ export {
1293
+ performanceShortcut,
1294
+ successEnvelope
1295
+ };