weaver-work-cli 0.1.63 → 0.1.65

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 (159) hide show
  1. package/dist/chunks/{archive-BLDYBZDX.js → archive-WUZKAEZ6.js} +2 -2
  2. package/dist/chunks/{archive-oa-3GJ3TWXR.js → archive-oa-PN46RTI2.js} +2 -2
  3. package/dist/chunks/{asset-AFXJN4CK.js → asset-ZPC5VWZM.js} +2 -2
  4. package/dist/chunks/{asset-idle-VUJXWGWJ.js → asset-idle-DHGP3NYY.js} +2 -2
  5. package/dist/chunks/{attachment-content-VMJA7NSQ.js → attachment-content-QUM27QNB.js} +3 -3
  6. package/dist/chunks/{blog-EREB35VU.js → blog-JC47AIXK.js} +2 -2
  7. package/dist/chunks/{caizhilian-ATM2JO5S.js → caizhilian-IKIHM77A.js} +4 -4
  8. package/dist/chunks/{calendar-E26ZIH7S.js → calendar-GZTSJ57Y.js} +2 -2
  9. package/dist/chunks/{chunk-OMAGCLUE.js → chunk-26FCCU5O.js} +2 -2
  10. package/dist/chunks/{chunk-EOZHSNND.js → chunk-3W5NMGDS.js} +2 -2
  11. package/dist/chunks/{chunk-SHBDXEUE.js → chunk-6AW5LW4T.js} +4 -4
  12. package/dist/chunks/{chunk-C5PIGPGX.js → chunk-6T5X6YWX.js} +2 -2
  13. package/dist/chunks/{chunk-WPBZQVLS.js → chunk-AFZTMYGC.js} +1 -1
  14. package/dist/chunks/{chunk-LOVAIGM2.js → chunk-CUY64WP4.js} +50 -50
  15. package/dist/chunks/{chunk-IGICM3WJ.js → chunk-D6SWOUUP.js} +2 -2
  16. package/dist/chunks/{chunk-BY3WDJO5.js → chunk-E3OQSNF5.js} +1 -1
  17. package/dist/chunks/{chunk-G3ZM57PD.js → chunk-F4ME3CGS.js} +2 -2
  18. package/dist/chunks/{chunk-6VCQLZXE.js → chunk-FDBAFANU.js} +1 -0
  19. package/dist/chunks/{chunk-RV2JAA5I.js → chunk-FJUOUSV3.js} +1 -1
  20. package/dist/chunks/{chunk-6G2JARDK.js → chunk-HLT6B26P.js} +1 -1
  21. package/dist/chunks/{chunk-THMBDCRA.js → chunk-HWA2A25Y.js} +2 -2
  22. package/dist/chunks/{chunk-HEJPVXD3.js → chunk-IJDZ7VDC.js} +4 -4
  23. package/dist/chunks/{chunk-GOBNIGWS.js → chunk-IT3SB7RV.js} +89 -16
  24. package/dist/chunks/{chunk-TNFIUZ4H.js → chunk-JDZOYHAL.js} +1 -1
  25. package/dist/chunks/{chunk-QZYKZ7MQ.js → chunk-K7QKQRSL.js} +155 -57
  26. package/dist/chunks/{chunk-QAMIIFP6.js → chunk-LRK7YND4.js} +11 -11
  27. package/dist/chunks/{chunk-4OB22YKE.js → chunk-NZLFKBEM.js} +6 -6
  28. package/dist/chunks/{chunk-RR45ELVE.js → chunk-Q6D6PSMH.js} +2 -2
  29. package/dist/chunks/{chunk-5CY37VLS.js → chunk-QT7GGCSY.js} +45 -43
  30. package/dist/chunks/{chunk-GQK6WLOS.js → chunk-VLY5RTVO.js} +2 -2
  31. package/dist/chunks/{chunk-SDPC7BG2.js → chunk-WSHIOSGM.js} +2 -2
  32. package/dist/chunks/{chunk-I4C2KR2G.js → chunk-ZV3TYANI.js} +1 -1
  33. package/dist/chunks/{conflict-AMNTM3FV.js → conflict-76ZUL3E7.js} +2 -2
  34. package/dist/chunks/{contract-PLO2V2NO.js → contract-INMS7SYQ.js} +846 -199
  35. package/dist/chunks/{cowork-FZAXE6FO.js → cowork-34CBYVQP.js} +2 -2
  36. package/dist/chunks/{create-flow-2DAUN7HU.js → create-flow-7WGKLRHH.js} +8 -6
  37. package/dist/chunks/{data-7NXMWET4.js → data-QKWI5325.js} +13 -2
  38. package/dist/chunks/{ebuilder-form-DEYHX6M7.js → ebuilder-form-ZONRROK4.js} +3 -3
  39. package/dist/chunks/{ehr-QQH2DYYA.js → ehr-2CONM7R6.js} +2 -2
  40. package/dist/chunks/{entry-mode-2JTVEKMP.js → entry-mode-3UMMMK6Z.js} +3 -3
  41. package/dist/chunks/{env-2JZMXC6I.js → env-7EGXNZR2.js} +2 -2
  42. package/dist/chunks/{esb-I5ZFHJUK.js → esb-FQASCY2H.js} +4 -4
  43. package/dist/chunks/{factory-XIATYHU6.js → factory-BDERKTYX.js} +1 -1
  44. package/dist/chunks/{fna-3V2TL6B2.js → fna-FCLVIWAS.js} +2 -2
  45. package/dist/chunks/{group-chat-CVYUZCOQ.js → group-chat-4E7EZMTJ.js} +3 -3
  46. package/dist/chunks/{host-CBONEAZS.js → host-2ED2KC4X.js} +3 -3
  47. package/dist/chunks/{host-4DP7C7YQ.js → host-2UYZEY2V.js} +3 -3
  48. package/dist/chunks/{host-4KQCAEWA.js → host-46NYKDQP.js} +3 -3
  49. package/dist/chunks/{host-BD7NAM33.js → host-7IPZKIM4.js} +3 -3
  50. package/dist/chunks/{host-L37QVNIV.js → host-P7G22WNM.js} +3 -3
  51. package/dist/chunks/{host-4X2F3JPQ.js → host-XLCBLNJD.js} +3 -3
  52. package/dist/chunks/{hrm-OL3IKN7C.js → hrm-XKL27NX2.js} +3 -3
  53. package/dist/chunks/{im-YXQWUF3R.js → im-NDYIMASG.js} +3 -3
  54. package/dist/chunks/{invoice-4WY32PR2.js → invoice-MOGNB6HN.js} +3 -3
  55. package/dist/chunks/{jiuchuanhui-L6SHLONH.js → jiuchuanhui-3T5X7SB7.js} +2 -2
  56. package/dist/chunks/{lazy-dispatch-OYE6QV24.js → lazy-dispatch-4WOIL3ZQ.js} +4 -4
  57. package/dist/chunks/{mail-PZV2KNRU.js → mail-P7VMUKQW.js} +2 -2
  58. package/dist/chunks/{meeting-6SOBCC6N.js → meeting-2FMYZXG5.js} +13 -13
  59. package/dist/chunks/{minute-doc-KSJSJNOH.js → minute-doc-3DHMYMBE.js} +4 -4
  60. package/dist/chunks/{okr-B76FW5M2.js → okr-VZXRQGS4.js} +2 -2
  61. package/dist/chunks/{operations-YOMEGFLV.js → operations-MI2BSKZX.js} +4 -4
  62. package/dist/chunks/{performance-4VBKUPFO.js → performance-OPEQNW7Y.js} +870 -15
  63. package/dist/chunks/{plan-HBNZRQTI.js → plan-TJAS4N5X.js} +2 -2
  64. package/dist/chunks/{project-IV6FWK74.js → project-CYBGU6K6.js} +2 -2
  65. package/dist/chunks/{reception-BR5YURT6.js → reception-3FT2F66K.js} +2 -2
  66. package/dist/chunks/{recruit-stage-4HQ6OGXT.js → recruit-stage-WPGB5BDJ.js} +2 -2
  67. package/dist/chunks/{registry-JFQEFC7E.js → registry-6UGQO35C.js} +2 -2
  68. package/dist/chunks/{registry-MZJQX65Q.js → registry-QRMXRSCT.js} +4 -4
  69. package/dist/chunks/{registry-7LICMV5J.js → registry-XXFMYPBM.js} +12 -12
  70. package/dist/chunks/{room-recommend-43GLLE7Y.js → room-recommend-7LD2OHL5.js} +4 -4
  71. package/dist/chunks/{schedule-ZQ42BEW6.js → schedule-ZAYMZKTQ.js} +4 -4
  72. package/dist/chunks/{smart-extract-QKAEAZGM.js → smart-extract-FOBSVNYW.js} +2 -2
  73. package/dist/chunks/{workflow-6HV7H5PC.js → workflow-NYJJIT3D.js} +4 -4
  74. package/dist/index.js +33 -33
  75. package/dist/internal/e10/auth/commands.js +182 -43
  76. package/dist/shortcuts/contract/error-actions.js +112 -0
  77. package/dist/shortcuts/contract/errors.js +9 -1
  78. package/dist/shortcuts/contract/manifest.js +18 -7
  79. package/dist/shortcuts/contract/operations/docx-slots.js +112 -5
  80. package/dist/shortcuts/contract/operations/docx-verify.js +2 -70
  81. package/dist/shortcuts/contract/operations/elements-build.js +82 -56
  82. package/dist/shortcuts/contract/operations/elements-spec.js +140 -3
  83. package/dist/shortcuts/contract/operations/ledger-card.js +25 -2
  84. package/dist/shortcuts/contract/operations/ledger.js +33 -5
  85. package/dist/shortcuts/contract/operations/money.js +90 -0
  86. package/dist/shortcuts/contract/operations/placeholder-scan.js +104 -0
  87. package/dist/shortcuts/contract/operations/quote-recognize.js +54 -17
  88. package/dist/shortcuts/contract/operations/quote-ref.js +179 -0
  89. package/dist/shortcuts/contract/operations/quote-submit.js +20 -3
  90. package/dist/shortcuts/contract/operations/quote.js +66 -12
  91. package/dist/shortcuts/contract/operations/solutions-spec.js +79 -0
  92. package/dist/shortcuts/contract/operations/triage.js +55 -9
  93. package/dist/shortcuts/data/operations/shared.js +14 -1
  94. package/dist/shortcuts/meeting/operations/eb/create-flow.js +25 -11
  95. package/dist/shortcuts/performance/flow-utils.js +363 -0
  96. package/dist/shortcuts/performance/manifest.js +2 -2
  97. package/dist/shortcuts/performance/operations/flow-detail.js +85 -0
  98. package/dist/shortcuts/performance/operations/flow-list.js +213 -0
  99. package/dist/shortcuts/performance/operations/flow-score.js +241 -0
  100. package/dist/shortcuts/performance/operations/registry.js +6 -0
  101. package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.categoryCounts.js +64 -0
  102. package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.collect.js +15 -0
  103. package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.core.js +4 -0
  104. package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.js +4 -0
  105. package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.prepareQuery.js +4 -0
  106. package/docs/e10-auth.md +27 -2
  107. package/package.json +1 -1
  108. package/skills/weaver-e10-jinchengda/SKILL.md +87 -39
  109. package/skills/weaver-e10-jinchengda/references/contract-ai-review.md +29 -29
  110. package/skills/weaver-e10-jinchengda/references/contract-clause-insert.md +2 -2
  111. package/skills/weaver-e10-jinchengda/references/contract-clause-library-crud.md +1 -1
  112. package/skills/weaver-e10-jinchengda/references/contract-command-index.md +29 -7
  113. package/skills/weaver-e10-jinchengda/references/contract-compare-report.md +3 -3
  114. package/skills/weaver-e10-jinchengda/references/contract-credit-page.md +5 -5
  115. package/skills/weaver-e10-jinchengda/references/contract-disabled-capabilities.md +1 -1
  116. package/skills/weaver-e10-jinchengda/references/contract-doc-compare.md +22 -25
  117. package/skills/weaver-e10-jinchengda/references/contract-doc-triage.md +53 -314
  118. package/skills/weaver-e10-jinchengda/references/contract-element-extract.md +6 -5
  119. package/skills/weaver-e10-jinchengda/references/contract-element-save-record.md +19 -11
  120. package/skills/weaver-e10-jinchengda/references/contract-execution-rules.md +3 -3
  121. package/skills/weaver-e10-jinchengda/references/contract-field-extract-new-customer.md +43 -25
  122. package/skills/weaver-e10-jinchengda/references/contract-field-extract-other-flows.md +103 -212
  123. package/skills/weaver-e10-jinchengda/references/contract-flow-launch.md +7 -7
  124. package/skills/weaver-e10-jinchengda/references/contract-ledger-catalog.md +7 -6
  125. package/skills/weaver-e10-jinchengda/references/contract-ledger-query-playbook.md +34 -21
  126. package/skills/weaver-e10-jinchengda/references/contract-ledger-rules.md +6 -6
  127. package/skills/weaver-e10-jinchengda/references/contract-modeltext-library.md +3 -3
  128. package/skills/weaver-e10-jinchengda/references/contract-multi-file.md +6 -6
  129. package/skills/weaver-e10-jinchengda/references/contract-object-detect.md +22 -22
  130. package/skills/weaver-e10-jinchengda/references/contract-open-web-pages.md +21 -19
  131. package/skills/weaver-e10-jinchengda/references/contract-performance-query.md +6 -5
  132. package/skills/weaver-e10-jinchengda/references/contract-quote-to-contract.md +132 -95
  133. package/skills/weaver-e10-jinchengda/references/contract-request-status.md +1 -1
  134. package/skills/weaver-e10-jinchengda/references/contract-request-write.md +1 -1
  135. package/skills/weaver-e10-jinchengda/references/contract-template-recommend.md +1 -1
  136. package/skills/weaver-e10-jinchengda/references/contract-type-fingerprints.md +12 -12
  137. package/skills/weaver-e10-jinchengda/references/contract-workflow-discovery.md +1 -1
  138. package/skills/weaver-e10-jinchengda/references/orchestration.md +5 -5
  139. package/skills/weaver-e10-meeting/SKILL.md +8 -7
  140. package/skills/weaver-e10-meeting/references/create-commands.md +2 -2
  141. package/skills/weaver-e10-meeting/references/create-flow.md +6 -6
  142. package/skills/weaver-e10-meeting/references/create-guardrails.md +10 -10
  143. package/skills/weaver-e10-meeting/references/invitation.md +1 -1
  144. package/skills/weaver-e10-meeting/references/meeting-eb.md +26 -26
  145. package/skills/weaver-e10-meeting/references/meeting-invitation.md +2 -2
  146. package/skills/weaver-e10-meeting/references/meeting-minute-file.md +2 -2
  147. package/skills/weaver-e10-meeting/references/meeting-verification.md +1 -1
  148. package/skills/weaver-e10-performance/SKILL.md +45 -5
  149. package/skills/weaver-e10-performance/agents/openai.yaml +26 -2
  150. package/skills/weaver-e10-performance/references/flow-api.md +128 -0
  151. package/skills/weaver-e10-performance/references/flow-assess.md +149 -0
  152. package/skills/weaver-e10-workflow/SKILL.md +40 -16
  153. package/skills/weaver-e10-workflow/aigroup/default.json +1 -1
  154. package/skills/weaver-e10-workflow/references/todo-dialogue.md +30 -27
  155. package/skills/weaver-e10-workflow/references/todo-smart-convert.md +90 -22
  156. package/skills/weaver-e10-workflow/references/workflow-view.md +18 -2
  157. package/skills/weaver-e10-workflow/tools/todo-summary.cjs +240 -43
  158. package/skills/weaver-e10-yimiaoban/SKILL.md +8 -5
  159. package/skills/weaver-e10-yimiaoban/references/source-manifest.json +3 -3
@@ -1254,6 +1254,20 @@ async function buildCrmSelection(args, env) {
1254
1254
  hint: '用户点选后把 value 原样回传(crm_members 为 [{id,name}]),不要再追问客户。',
1255
1255
  };
1256
1256
  }
1257
+ /**
1258
+ * 入口结论(纯规则):声明必须带令牌才算数。
1259
+ * - `entryMode` + 令牌校验通过 → 采信(用户刚在选项里点过);
1260
+ * - 只有声明、没有令牌 → 视为模型自填,**不采信**,交回入口选项让用户选;
1261
+ * - 完全没声明 → 由调用方再去看上游标记(流程工具可能已经问过)。
1262
+ */
1263
+ export function decideEntryMode(input) {
1264
+ const declared = String(input.declared ?? '').trim();
1265
+ if (declared !== 'assist' && declared !== 'direct_form')
1266
+ return { mode: '', reason: 'none' };
1267
+ if (input.tokenOk === true)
1268
+ return { mode: declared, reason: 'token' };
1269
+ return { mode: '', reason: 'unverified' };
1270
+ }
1257
1271
  const ebMeetingCreateFlowPrepare = {
1258
1272
  name: 'meeting.eb.meeting.create.flow.prepare',
1259
1273
  resource: 'eb',
@@ -1389,25 +1403,25 @@ const ebMeetingCreateFlowPrepare = {
1389
1403
  // 预检各阶段耗时(debugTimings:true 时随结果返回)
1390
1404
  // 发起流程优先:明确要"发起/创建流程"时不做预检与推荐,只填单。
1391
1405
  let skipPreflight = args.skipPreflight === true;
1392
- // 上游流程工具已让用户选过「直接发起表单」时,模型会带 entryMode=direct_form,等价于 skipPreflight。
1393
- if (args.entryMode === 'direct_form') {
1394
- args = { ...args, skipPreflight: true };
1395
- skipPreflight = true;
1396
- }
1406
+ // ⛔ 不要在这里凭 entryMode 直接置 skipPreflight:那会让模型自填的 direct_form 一票绕过入口询问。
1407
+ // 令牌校验通过后,下面 `entryResolved === 'direct_form'` 分支再置 skipPreflight。
1397
1408
  // 会话内入口标记:流程工具已问过时,这里不再弹入口选项。
1398
- // entryMode 必须带本轮令牌(由下面的选项 value 下发),否则视为模型自填,无效。
1409
+ // ⛔ 2026-11-20 真机:同一句「预定个明天下午的会议」发 4 次,2 次直接出表单、2 次弹选项 ——
1410
+ // 原因是模型有时自己填 entryMode=direct_form,而 e812212 之后"声明即采信",自填值直接放行。
1411
+ // 恢复本意:**声明必须带本轮令牌才算数**;没令牌就当没声明,回到入口选项让用户选。
1399
1412
  let entryResolved = '';
1400
1413
  const rawEntry = String(args.entryMode ?? '').trim();
1401
1414
  if (rawEntry === 'assist' || rawEntry === 'direct_form') {
1402
- // 显式 entryMode 以调用方为准;令牌只做审计,不再因为"没带 token"回退到旧标记。
1403
1415
  const { verifyEntryToken } = await import('./entry-mode.js');
1404
1416
  const tokenOk = await verifyEntryToken(env, String(args.entryToken ?? ''), rawEntry).catch(() => false);
1405
- entryResolved = rawEntry;
1406
- if (!tokenOk) {
1417
+ const decision = decideEntryMode({ declared: rawEntry, tokenOk });
1418
+ if (decision.mode)
1419
+ entryResolved = decision.mode;
1420
+ else
1407
1421
  env.__entryTokenMissing = 1;
1408
- }
1409
1422
  }
1410
- if (!entryResolved) {
1423
+ // 旧标记只在"调用方没声明入口"时才参考;声明了但令牌不对 → 直接问用户,不拿旧标记顶替。
1424
+ if (!entryResolved && rawEntry === '') {
1411
1425
  const { readEntryChoice } = await import('./entry-mode.js');
1412
1426
  const mark = await readEntryChoice(env).catch(() => null);
1413
1427
  if (mark?.choice)
@@ -0,0 +1,363 @@
1
+ import { pfFail, pfValidationError } from './errors.js';
2
+ /**
3
+ * 考核流程(flow)相关公共工具:评分列解析、评分行组装、详情页链接、总分估算。
4
+ * 契约来源:e10-kpi-assess 的 references/api-contracts.md(2026-11-11 抓包 + 后端源码核验)。
5
+ */
6
+ /** 考核流程状态中文名(FlowStatus 枚举)。 */
7
+ export const FLOW_STATUS_LABELS = {
8
+ audit: '待审核',
9
+ score: '评分中',
10
+ noScore: '不可评分',
11
+ frozen: '冻结',
12
+ approve: '审批中',
13
+ noApprove: '不可审批',
14
+ drawback: '退回',
15
+ noDrawback: '不可退回',
16
+ finished: '已结束',
17
+ scoreOverTime: '已超时',
18
+ waitArchive: '已评分待归档',
19
+ interviewing: '面谈中',
20
+ };
21
+ export const DATE_TYPE_LABELS = {
22
+ year: '年度',
23
+ halfyear: '半年',
24
+ quarter: '季度',
25
+ month: '月度',
26
+ };
27
+ export const INDICATOR_MODE_LABELS = {
28
+ quantify: '定量',
29
+ qualitative: '定性',
30
+ };
31
+ /**
32
+ * 从 basicHeader 解析可编辑评分列(dataIndex 形如 `kps{stepId}-{userId}`,canEdit=true)。
33
+ * 找不到说明当前用户不是评分操作人,或考核不在评分阶段。
34
+ */
35
+ export function parseScoreColumn(detailData) {
36
+ const cols = (detailData?.basicHeader || []).filter((c) => c?.canEdit && /^kps.+-.+$/.test(String(c?.dataIndex || '')));
37
+ if (!cols.length)
38
+ return null;
39
+ const dataIndex = String(cols[0].dataIndex);
40
+ const m = dataIndex.match(/^kps(.+)-([^-.]+)$/);
41
+ return m ? { scoreColumn: dataIndex, stepId: m[1], scoreUserId: m[2] } : null;
42
+ }
43
+ /** 行级取值键:targetValue{stepId}-{userId} / actualValue… / kps… */
44
+ export function rowValueKeys(stepId, userId) {
45
+ return {
46
+ targetKey: `targetValue${stepId}-${userId}`,
47
+ actualKey: `actualValue${stepId}-${userId}`,
48
+ kpsKey: `kps${stepId}-${userId}`,
49
+ };
50
+ }
51
+ /** 数据源配置里表单/字段的显示名(配置里存的是 JSON 字符串)。 */
52
+ export function parseDatasourceText(jsonStr) {
53
+ if (!jsonStr)
54
+ return null;
55
+ try {
56
+ const parsed = typeof jsonStr === 'string' ? JSON.parse(jsonStr) : jsonStr;
57
+ return parsed?.text ?? parsed?.config?.title ?? null;
58
+ }
59
+ catch {
60
+ return null;
61
+ }
62
+ }
63
+ /** 数据源聚合取数(只读,纯查询无副作用)。 */
64
+ export async function fetchAggregated(host, config, operation) {
65
+ const response = await host.request({
66
+ path: '/api/workrelate/performance/flow/getDataSourceData',
67
+ body: config,
68
+ operation,
69
+ });
70
+ const data = unwrapWeaData(response, '数据源取数');
71
+ return typeof data === 'number' ? data : String(data);
72
+ }
73
+ export function unwrapWeaData(response, context) {
74
+ if (!response || typeof response !== 'object') {
75
+ throw pfFail(`${context}:接口返回不是对象`);
76
+ }
77
+ const failed = response.fail === true
78
+ || (response.status !== undefined && response.status !== true)
79
+ || (response.code !== undefined && response.code !== 200);
80
+ if (failed) {
81
+ throw pfFail(`${context}:${response.msg || '接口返回失败'}`, { code: response.code, msg: response.msg });
82
+ }
83
+ return response.data;
84
+ }
85
+ /** 单个指标的补充分类与数据源信息(assess 用)。 */
86
+ async function describeDatasource(host, cfg, operation) {
87
+ if (!cfg)
88
+ return null;
89
+ const view = {
90
+ formName: parseDatasourceText(cfg.dataSet),
91
+ fieldName: parseDatasourceText(cfg.target),
92
+ countType: cfg.targetCountType ?? null,
93
+ startDate: cfg.startDate ?? null,
94
+ endDate: cfg.endDate ?? null,
95
+ };
96
+ try {
97
+ view.aggregated = await fetchAggregated(host, cfg, operation);
98
+ }
99
+ catch (error) {
100
+ // 取数失败不阻断整体评估,按「无法取数」标注交给 AI 与用户
101
+ view.error = error?.message ?? String(error);
102
+ }
103
+ return view;
104
+ }
105
+ /**
106
+ * 组装 AI 评分上下文(对应原 kpi-cli `assess`):
107
+ * 评分元信息 + 逐指标(类型/描述/权重/模式/目标值/实际值/当前评分)+ 数据源聚合值。
108
+ */
109
+ export async function buildAssessContext(host, flowId, operation) {
110
+ const detailData = unwrapWeaData(await host.request({
111
+ path: `/api/workrelate/performance/flow/detail/${encodeURIComponent(flowId)}`,
112
+ method: 'GET',
113
+ operation,
114
+ }), '考核详情');
115
+ if (!detailData || !Array.isArray(detailData.basicData)) {
116
+ throw pfFail('考核详情缺少指标数据(basicData)', { keys: detailData ? Object.keys(detailData) : [] });
117
+ }
118
+ const column = parseScoreColumn(detailData);
119
+ if (!column) {
120
+ throw pfValidationError('not_scorable', '当前用户对该考核不可评分(找不到可编辑评分列):可能不是本轮评分人,或考核不在评分阶段', { flowStatus: detailData.flowStatus ?? null, canScore: detailData.canScore ?? null });
121
+ }
122
+ const keys = rowValueKeys(column.stepId, column.scoreUserId);
123
+ const indicators = [];
124
+ for (let i = 0; i < detailData.basicData.length; i += 1) {
125
+ const row = detailData.basicData[i];
126
+ const isQuantitative = String(row?.indicatorMode) === 'quantify';
127
+ const item = {
128
+ index: i + 1,
129
+ dataRow: row?.dataRow,
130
+ name: row?.type ?? null,
131
+ description: row?.describe ?? row?.indicatorDescription ?? null,
132
+ weight: row?.weight ?? null,
133
+ mode: INDICATOR_MODE_LABELS[String(row?.indicatorMode)] ?? null,
134
+ scoreType: row?.scoreType ?? null,
135
+ currentTarget: row?.[keys.targetKey] ?? null,
136
+ currentActual: row?.[keys.actualKey] ?? null,
137
+ currentScore: row?.[keys.kpsKey] ?? null,
138
+ // 后端为 AI 预留的镜像字段(FlowServiceImpl 796-809,注释「AI创建使用」)
139
+ aiTarget: row?.targetAIValue ?? null,
140
+ aiActual: row?.actualAIValue ?? null,
141
+ };
142
+ if (isQuantitative && Number(row?.targetSource) === 2 && row?.targetDatasourceData) {
143
+ item.targetDatasource = await describeDatasource(host, row.targetDatasourceData, operation);
144
+ }
145
+ if (isQuantitative && Number(row?.dataSource) === 2
146
+ && String(row?.dataModule || '').toLowerCase() === 'datasource' && row?.datasourceData) {
147
+ item.actualDatasource = await describeDatasource(host, row.datasourceData, operation);
148
+ }
149
+ indicators.push(item);
150
+ }
151
+ return {
152
+ flowId,
153
+ meta: {
154
+ name: detailData.name ?? null,
155
+ schemeName: detailData.schemeName ?? null,
156
+ kpiUserName: detailData.kpiUserName ?? null,
157
+ assessmentCycle: detailData.assessmentCycle ?? null,
158
+ periodStart: detailData.periodStartDate ?? null,
159
+ periodEnd: detailData.periodEndDate ?? null,
160
+ flowStatus: detailData.flowStatus ?? null,
161
+ flowStatusLabel: FLOW_STATUS_LABELS[String(detailData.flowStatus)] ?? null,
162
+ currentScore: detailData.score ?? null,
163
+ maxScore: detailData.total ?? null,
164
+ scoreLimit: detailData.scoreLimit ?? null,
165
+ canScore: detailData.canScore ?? null,
166
+ stepId: column.stepId,
167
+ scoreUserId: column.scoreUserId,
168
+ },
169
+ indicators,
170
+ detailUrl: buildDetailUrl(flowId, []),
171
+ };
172
+ }
173
+ /** 考核详情页链接;带 kpiext/aikps 时页面展示 AI 评分列。 */
174
+ export function buildDetailUrl(flowId, rows = []) {
175
+ const base = `/sp/performance/flow/deal/detail/${flowId}`;
176
+ if (!rows.length)
177
+ return base;
178
+ const aikps = [...rows]
179
+ .sort((a, b) => Number(a.dataRow) - Number(b.dataRow))
180
+ .map((row) => {
181
+ const value = Number(row.kps);
182
+ return Number.isFinite(value) ? String(value) : '';
183
+ })
184
+ .join(',');
185
+ return `${base}?kpiext=1&aikps=${aikps}`;
186
+ }
187
+ /**
188
+ * 组装评分请求体并做与前端同源的前置校验。
189
+ * 校验规则(对齐 weapp detailItem.tsx:2108-2159):
190
+ * - 每行 kps 必填(公式行可取行内计算值)
191
+ * - 超出满分(scoreLimit 未关闭)→ 直接拒绝,不静默截断
192
+ * - 定量指标 targetValue 必填;actualValue 在 dataSource=1 或(dataSource=2 且 editActualValue)时必填
193
+ */
194
+ export function buildScoreRequest(detailData, payloadRows, column) {
195
+ if (detailData?.canScore === false) {
196
+ throw pfValidationError('not_scorable', '当前用户对该考核不可评分(canScore=false)', {
197
+ flowStatus: detailData?.flowStatus ?? null,
198
+ });
199
+ }
200
+ if (!Array.isArray(payloadRows) || payloadRows.length === 0) {
201
+ throw pfValidationError('payload_empty', '评分行不能为空(每行至少提供 dataRow 与 kps)');
202
+ }
203
+ const keys = rowValueKeys(column.stepId, column.scoreUserId);
204
+ const maxScore = Number(detailData?.total);
205
+ const basicData = Array.isArray(detailData?.basicData) ? detailData.basicData : [];
206
+ const linkList = [];
207
+ for (const payloadRow of payloadRows) {
208
+ if (!payloadRow || typeof payloadRow !== 'object' || payloadRow.dataRow === undefined) {
209
+ throw pfValidationError('payload_invalid', '每行必须包含 dataRow', { row: payloadRow });
210
+ }
211
+ const row = basicData.find((r) => Number(r?.dataRow) === Number(payloadRow.dataRow));
212
+ if (!row) {
213
+ throw pfValidationError('data_row_unknown', `dataRow=${payloadRow.dataRow} 在指标表中不存在`, {
214
+ valid: basicData.map((r) => r?.dataRow),
215
+ });
216
+ }
217
+ const rowName = row?.type ?? `第 ${row?.dataRow} 行`;
218
+ let kpsValue = payloadRow.kps;
219
+ if ((kpsValue === undefined || kpsValue === null || kpsValue === '') && row?.scoreType === 'formula') {
220
+ const inline = row?.[keys.kpsKey];
221
+ if (inline !== undefined && inline !== null && inline !== '')
222
+ kpsValue = inline;
223
+ }
224
+ if (kpsValue === undefined || kpsValue === null || kpsValue === '') {
225
+ throw pfValidationError('kps_missing', `「${rowName}」缺少评分(kps)`, {
226
+ dataRow: row?.dataRow,
227
+ hint: '每行必填;公式行可省略但详情里需已有计算值',
228
+ });
229
+ }
230
+ const kpsNumber = Number(kpsValue);
231
+ if (!Number.isFinite(kpsNumber) || kpsNumber < 0) {
232
+ throw pfValidationError('kps_invalid', `「${rowName}」评分非法:${kpsValue}`, { dataRow: row?.dataRow });
233
+ }
234
+ if (detailData?.scoreLimit !== false && Number.isFinite(maxScore) && maxScore > 0 && kpsNumber > maxScore) {
235
+ throw pfValidationError('kps_exceeds_max', `「${rowName}」评分 ${kpsNumber} 超出满分 ${maxScore}`, {
236
+ dataRow: row?.dataRow,
237
+ hint: '不做静默截断,请调整评分',
238
+ });
239
+ }
240
+ const isQuantitative = String(row?.indicatorMode) === 'quantify';
241
+ let targetValue = payloadRow.targetValue !== undefined ? payloadRow.targetValue : row?.[keys.targetKey];
242
+ if (isQuantitative && (targetValue === undefined || targetValue === null || targetValue === '')) {
243
+ throw pfValidationError('target_missing', `定量指标「${rowName}」缺少目标值(targetValue)`, {
244
+ dataRow: row?.dataRow,
245
+ hint: '可在 payload 提供,或确认详情中已有目标值',
246
+ });
247
+ }
248
+ const targetNumber = targetValue === undefined || targetValue === null || targetValue === ''
249
+ ? 0
250
+ : Number(targetValue);
251
+ if (!Number.isFinite(targetNumber)) {
252
+ throw pfValidationError('target_invalid', `「${rowName}」目标值非数字:${targetValue}`, { dataRow: row?.dataRow });
253
+ }
254
+ let actualValue = null;
255
+ if (payloadRow.actualValue !== undefined && payloadRow.actualValue !== null && payloadRow.actualValue !== '') {
256
+ actualValue = String(payloadRow.actualValue);
257
+ }
258
+ else if (row?.[keys.actualKey] !== undefined && row?.[keys.actualKey] !== null && row?.[keys.actualKey] !== '') {
259
+ actualValue = String(row?.[keys.actualKey]);
260
+ }
261
+ if (isQuantitative && actualValue === null) {
262
+ const needsActual = Number(row?.dataSource) === 1
263
+ || (Number(row?.dataSource) === 2 && row?.editActualValue === true);
264
+ if (needsActual) {
265
+ throw pfValidationError('actual_missing', `定量指标「${rowName}」缺少实际值(actualValue)`, {
266
+ dataRow: row?.dataRow,
267
+ dataSource: row?.dataSource ?? null,
268
+ editActualValue: row?.editActualValue === true,
269
+ hint: '该指标需评分人提供实际值(dataSource=1 手动录入,或数据源模式但允许编辑实际值)',
270
+ });
271
+ }
272
+ }
273
+ linkList.push({
274
+ weight: row?.weight ?? null,
275
+ dataRow: row?.dataRow,
276
+ operater: column.scoreUserId,
277
+ kps: kpsNumber.toFixed(2),
278
+ kpiFlowStep: column.stepId,
279
+ targetValue: targetNumber,
280
+ actualValue: actualValue === null ? '' : actualValue,
281
+ ...(payloadRow.remark !== undefined && payloadRow.remark !== null && payloadRow.remark !== ''
282
+ ? { name: String(payloadRow.remark) }
283
+ : {}),
284
+ });
285
+ }
286
+ const rows = linkList.map((link) => ({ dataRow: link.dataRow, kps: link.kps, actualValue: link.actualValue }));
287
+ return {
288
+ body: {
289
+ flowid: String(detailData?.id ?? ''),
290
+ stepId: column.stepId,
291
+ operater: column.scoreUserId,
292
+ rewardMoney: 0,
293
+ kpiFlowStepLinkList: linkList,
294
+ distributeCheck: true,
295
+ },
296
+ rows,
297
+ meta: {
298
+ name: detailData?.name ?? null,
299
+ kpiUserName: detailData?.kpiUserName ?? null,
300
+ assessmentCycle: detailData?.assessmentCycle ?? null,
301
+ flowStatus: detailData?.flowStatus ?? null,
302
+ maxScore: detailData?.total ?? null,
303
+ },
304
+ };
305
+ }
306
+ /** 本地加权总分估算(不写库,用于 prepare 展示)。 */
307
+ export function estimateTotal(detailData, linkList) {
308
+ const basicData = Array.isArray(detailData?.basicData) ? detailData.basicData : [];
309
+ let weighted = 0;
310
+ let weightSum = 0;
311
+ for (const link of linkList) {
312
+ const row = basicData.find((r) => Number(r?.dataRow) === Number(link.dataRow));
313
+ const weight = Number(row?.weight);
314
+ const kps = Number(link.kps);
315
+ if (!Number.isFinite(weight) || !Number.isFinite(kps))
316
+ continue;
317
+ weighted += kps * weight;
318
+ weightSum += weight;
319
+ }
320
+ if (weightSum === 0)
321
+ return null;
322
+ return Math.round((weighted / weightSum) * 100) / 100;
323
+ }
324
+ /** 考核列表行 → 业务视图(不露英文字段名/枚举值)。 */
325
+ export function toFlowRowView(row) {
326
+ return {
327
+ flowId: row?.id === undefined || row?.id === null ? null : String(row.id),
328
+ name: row?.name ?? null,
329
+ kpiUserName: row?.kpiUserName ?? null,
330
+ kpiSchemeName: row?.kpiSchemeName ?? null,
331
+ department: row?.departmentDesc ?? null,
332
+ subcompany: row?.subcompanyDesc ?? null,
333
+ dateType: DATE_TYPE_LABELS[String(row?.dateType)] ?? null,
334
+ assessmentCycle: row?.assessmentCycle ?? null,
335
+ status: FLOW_STATUS_LABELS[String(row?.flowStatus)] ?? (row?.flowStatusDesc ?? null),
336
+ score: row?.score ?? null,
337
+ scoreDesc: row?.scoreDesc ?? null,
338
+ createTime: row?.createTime ?? null,
339
+ finishTime: row?.finishTime ?? null,
340
+ detailUrl: row?.id === undefined || row?.id === null
341
+ ? null
342
+ : `/sp/performance/flow/deal/detail/${row.id}`,
343
+ };
344
+ }
345
+ /**
346
+ * 兼容两种列表返回形态:
347
+ * - 纯数组(getPortalRecently → List<FlowPortalRecentlyRes>)
348
+ * - WeaTable(pendinglist / dealDonelist / list → { columns, data: [...], total })
349
+ */
350
+ export function extractRows(data) {
351
+ if (Array.isArray(data))
352
+ return data;
353
+ if (data && Array.isArray(data.data))
354
+ return data.data;
355
+ return [];
356
+ }
357
+ /** WeaTable 的 total(纯数组返回时为 null;后端对 pendinglist 恒为 0,不可当作总数)。 */
358
+ export function extractTotal(data) {
359
+ if (data && typeof data === 'object' && !Array.isArray(data) && typeof data.total === 'number') {
360
+ return data.total;
361
+ }
362
+ return null;
363
+ }
@@ -19,12 +19,12 @@ function buildOperations() {
19
19
  export const performanceManifest = {
20
20
  schemaVersion: 1,
21
21
  name: 'performance',
22
- title: '泛微E10绩效方案(文档导入 → 草稿 → 确认发布)',
22
+ title: '泛微E10绩效考核(方案导入 + 考核查询与 AI 评分)',
23
23
  version: '0.1.0',
24
24
  host: 'e10-performance',
25
25
  status: 'builtin',
26
26
  sourceSkill: 'weaver-e10-performance',
27
- capabilities: ['performance.hrm.resolve', 'performance.scheme.detail', 'performance.scheme.draft', 'performance.scheme.publish'],
27
+ capabilities: ['performance.hrm.resolve', 'performance.scheme.detail', 'performance.scheme.draft', 'performance.scheme.publish', 'performance.flow.query', 'performance.flow.score'],
28
28
  operations: buildOperations(),
29
29
  withheldOperations: [],
30
30
  };
@@ -0,0 +1,85 @@
1
+ import { buildAssessContext, buildDetailUrl, FLOW_STATUS_LABELS, INDICATOR_MODE_LABELS, parseScoreColumn, rowValueKeys, unwrapWeaData, } from '../flow-utils.js';
2
+ import { pfValidationError } from '../errors.js';
3
+ import { pfSuccess, schemaOf } from './types.js';
4
+ /**
5
+ * 考核详情:业务化视图 + 完整原文。
6
+ * 原文含评分列(kps{stepId}-{userId})与 AI 镜像字段,供评分与排查使用。
7
+ */
8
+ async function detail(args, env) {
9
+ if (args.flowId === undefined || args.flowId === null || args.flowId === '') {
10
+ throw pfValidationError('flow_id_missing', '缺少考核流程 id(flowId)');
11
+ }
12
+ const flowId = String(args.flowId);
13
+ const data = unwrapWeaData(await env.host.request({
14
+ path: `/api/workrelate/performance/flow/detail/${encodeURIComponent(flowId)}`,
15
+ method: 'GET',
16
+ operation: 'performance.flow.detail',
17
+ }), '考核详情');
18
+ const column = parseScoreColumn(data);
19
+ const keys = column ? rowValueKeys(column.stepId, column.scoreUserId) : null;
20
+ const indicatorRows = (Array.isArray(data?.basicData) ? data.basicData : []).map((row, index) => ({
21
+ index: index + 1,
22
+ dataRow: row?.dataRow,
23
+ name: row?.type ?? null,
24
+ mode: INDICATOR_MODE_LABELS[String(row?.indicatorMode)] ?? null,
25
+ weight: row?.weight === undefined || row?.weight === null ? null : `${row.weight}%`,
26
+ targetValue: keys ? (row?.[keys.targetKey] ?? null) : null,
27
+ actualValue: keys ? (row?.[keys.actualKey] ?? null) : null,
28
+ score: keys ? (row?.[keys.kpsKey] ?? null) : null,
29
+ description: row?.describe ?? row?.indicatorDescription ?? null,
30
+ }));
31
+ return pfSuccess('performance.flow.detail', {
32
+ flowId,
33
+ name: data?.name ?? null,
34
+ kpiUserName: data?.kpiUserName ?? null,
35
+ assessmentCycle: data?.assessmentCycle ?? null,
36
+ status: FLOW_STATUS_LABELS[String(data?.flowStatus)] ?? (data?.flowStatus ?? null),
37
+ score: data?.score ?? null,
38
+ maxScore: data?.total ?? null,
39
+ canScore: data?.canScore ?? false,
40
+ currentStep: data?.kpiCurrentStep ?? null,
41
+ indicatorRows,
42
+ detailUrl: buildDetailUrl(flowId),
43
+ data,
44
+ });
45
+ }
46
+ /** AI 评分上下文:评分元信息 + 逐指标(含数据源聚合值)。 */
47
+ async function assess(args, env) {
48
+ if (args.flowId === undefined || args.flowId === null || args.flowId === '') {
49
+ throw pfValidationError('flow_id_missing', '缺少考核流程 id(flowId)');
50
+ }
51
+ const context = await buildAssessContext(env.host, String(args.flowId), 'performance.flow.assess');
52
+ return pfSuccess('performance.flow.assess', {
53
+ ...context,
54
+ scoringHints: [
55
+ '定量指标:以目标值与实际值(数据源聚合结果)为依据,先算达成率再映射分数',
56
+ '定性指标:基于指标说明与可用数据给出可追溯的判断依据,不空泛',
57
+ '数据源 error 字段非空的指标标注「无法取数」,不强行打分',
58
+ '评分上限为满分(maxScore);超出会被拒绝,不做静默截断',
59
+ ],
60
+ });
61
+ }
62
+ export const flowDetailOperations = [
63
+ {
64
+ name: 'performance.flow.detail',
65
+ resource: 'performance.flow',
66
+ method: 'query',
67
+ action: 'flow.detail',
68
+ summary: '考核详情(指标行 + 当前评分 + 完整原文)',
69
+ capability: 'performance.flow.query',
70
+ risk: 'read',
71
+ inputSchema: schemaOf({ flowId: { type: 'string', description: '考核流程 id(flowId,字符串)' } }, { required: ['flowId'] }),
72
+ handler: detail,
73
+ },
74
+ {
75
+ name: 'performance.flow.assess',
76
+ resource: 'performance.flow',
77
+ method: 'query',
78
+ action: 'flow.assess',
79
+ summary: '组装 AI 评分上下文(逐指标目标/实际/当前评分 + 数据源聚合值)',
80
+ capability: 'performance.flow.score',
81
+ risk: 'read',
82
+ inputSchema: schemaOf({ flowId: { type: 'string', description: '考核流程 id(flowId,字符串)' } }, { required: ['flowId'] }),
83
+ handler: assess,
84
+ },
85
+ ];