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
@@ -0,0 +1,213 @@
1
+ import { extractRows, extractTotal, unwrapWeaData, toFlowRowView, FLOW_STATUS_LABELS } from '../flow-utils.js';
2
+ import { pfSuccess, schemaOf } from './types.js';
3
+ /** 考核流程类只读接口(全部为 POST/GET 查询,无写副作用)。 */
4
+ const API = {
5
+ recent: '/api/workrelate/performance/flow/getPortalRecently',
6
+ pending: '/api/workrelate/performance/flow/getPendingNums',
7
+ todo: '/api/workrelate/performance/flow/pendinglist',
8
+ done: '/api/workrelate/performance/flow/dealDonelist',
9
+ list: '/api/workrelate/performance/flow/list',
10
+ };
11
+ /** 最近已有考核(我作为被考核人的成绩)。 */
12
+ async function recent(_args, env) {
13
+ const data = unwrapWeaData(await env.host.request({ path: API.recent, body: {}, operation: 'performance.flow.recent' }), '最近考核列表');
14
+ // getPortalRecently 只返回 { id, score, assessmentCycle, linkUrl }:
15
+ // 单独映射,避免复用 toFlowRowView 造成 name/status 都是 null 的误导
16
+ const rows = extractRows(data).map((row) => ({
17
+ flowId: row?.id === undefined || row?.id === null ? null : String(row.id),
18
+ assessmentCycle: row?.assessmentCycle ?? null,
19
+ scoreText: row?.score ?? null,
20
+ detailUrl: row?.linkUrl
21
+ ? String(row.linkUrl)
22
+ : (row?.id === undefined || row?.id === null ? null : `/sp/performance/flow/deal/detail/${row.id}`),
23
+ }));
24
+ return pfSuccess('performance.flow.recent', {
25
+ count: rows.length,
26
+ rows,
27
+ note: '最近考核接口只返回考核 id、成绩文本与周期;名称/被考核人需用 performance.flow.detail 获取',
28
+ });
29
+ }
30
+ /** 待处理数量(待评分/待审批/面谈等)。 */
31
+ async function pending(_args, env) {
32
+ const data = unwrapWeaData(await env.host.request({ path: API.pending, body: {}, operation: 'performance.flow.pending' }), '待处理数量');
33
+ return pfSuccess('performance.flow.pending', {
34
+ scoreNum: data?.scoreNum ?? 0,
35
+ approveNum: data?.approveNum ?? 0,
36
+ interviewNum: data?.interviewNum ?? 0,
37
+ auditNum: data?.auditNum ?? 0,
38
+ frozenNum: data?.frozenNum ?? 0,
39
+ totalNum: data?.totalNum ?? 0,
40
+ hint: 'scoreNum>0 表示有待评分考核;取明细用 performance.flow.todo',
41
+ });
42
+ }
43
+ /** 待处理明细(默认待评分)。total/hasMore 后端恒不可信,只能翻页到空。 */
44
+ async function todo(args, env) {
45
+ const tab = String(args.tab || 'score');
46
+ const current = Number(args.current ?? 1);
47
+ const pageSize = Number(args.pageSize ?? 20);
48
+ const data = unwrapWeaData(await env.host.request({
49
+ path: API.todo,
50
+ body: { status: tab, current, pageSize },
51
+ operation: 'performance.flow.todo',
52
+ }), '待处理明细');
53
+ const rows = extractRows(data).map(toFlowRowView);
54
+ return pfSuccess('performance.flow.todo', {
55
+ tab,
56
+ current,
57
+ pageSize,
58
+ count: rows.length,
59
+ rows,
60
+ paging: {
61
+ note: '后端 total 恒为 0、hasMore 恒为 false,不能用于判断是否还有下一页;本页行数小于 pageSize 即到末页',
62
+ nextCurrent: rows.length < pageSize ? null : current + 1,
63
+ },
64
+ });
65
+ }
66
+ /** 已办明细(我作为评分/审批人已处理完的考核)。 */
67
+ async function done(args, env) {
68
+ const current = Number(args.current ?? 1);
69
+ const pageSize = Number(args.pageSize ?? 20);
70
+ const searchParams = {};
71
+ if (args.kpiUserName) {
72
+ // 被考核人过滤:browser 格式 formDatas.userIdList=[{userIdList:[{id}]}]
73
+ searchParams.formDatas = { userIdList: [{ userIdList: [{ id: String(args.kpiUserId ?? args.kpiUserName) }] }] };
74
+ }
75
+ if (args.keyword)
76
+ searchParams.formDatas = { ...(searchParams.formDatas || {}), name: String(args.keyword) };
77
+ const data = unwrapWeaData(await env.host.request({
78
+ path: API.done,
79
+ body: { searchParams, current, pageSize },
80
+ operation: 'performance.flow.done',
81
+ }), '已办列表');
82
+ const rows = extractRows(data).map(toFlowRowView);
83
+ return pfSuccess('performance.flow.done', { current, pageSize, count: rows.length, rows });
84
+ }
85
+ /** 考核成绩列表:我的 / 直接下属 / 间接下属 / 下属 / 全部 / 本人 / 待处理。 */
86
+ async function list(args, env) {
87
+ const dataTypes = Array.isArray(args.dataType) && args.dataType.length
88
+ ? args.dataType.map((x) => String(x))
89
+ : ['mine'];
90
+ const current = Number(args.current ?? 1);
91
+ const pageSize = Number(args.pageSize ?? 20);
92
+ const body = {
93
+ dataType: dataTypes,
94
+ // 前端同源写法:高级搜索侧也带同一份 dataType(flow/sub/list.tsx:127-136)
95
+ searchParams: { formDatas: { dataType: dataTypes.map((t) => ({ dataType: [t] })) } },
96
+ current,
97
+ pageSize,
98
+ dateType: args.dateType ?? null,
99
+ startTime: args.startTime ?? null,
100
+ endTime: args.endTime ?? null,
101
+ };
102
+ if (args.status !== undefined)
103
+ body.status = args.status;
104
+ if (args.keyword)
105
+ body.keywords = String(args.keyword);
106
+ if (args.schemeId !== undefined)
107
+ body.schemeId = args.schemeId;
108
+ const data = unwrapWeaData(await env.host.request({ path: API.list, body, operation: 'performance.flow.list' }), '考核成绩列表');
109
+ // WeaTable 结构:data.data 为行数组,data.total 视 pageUid 而定(不保证)
110
+ const rows = extractRows(data).map(toFlowRowView);
111
+ const scopeLabels = {
112
+ mine: '我的',
113
+ directsub: '直接下属',
114
+ indirectsub: '间接下属',
115
+ sub: '下属',
116
+ all: '全部',
117
+ myself: '本人',
118
+ pending: '待处理',
119
+ };
120
+ return pfSuccess('performance.flow.list', {
121
+ scope: dataTypes.map((t) => scopeLabels[t] || t).join('+'),
122
+ current,
123
+ pageSize,
124
+ count: rows.length,
125
+ rows,
126
+ total: extractTotal(data),
127
+ paging: {
128
+ note: '本接口的 total 由 pageUid 决定,可能为 0 或不准确;以本页行数判断是否到末页',
129
+ nextCurrent: rows.length < pageSize ? null : current + 1,
130
+ },
131
+ statusLegend: FLOW_STATUS_LABELS,
132
+ });
133
+ }
134
+ export const flowListOperations = [
135
+ {
136
+ name: 'performance.flow.recent',
137
+ resource: 'performance.flow',
138
+ method: 'query',
139
+ action: 'flow.recent',
140
+ summary: '最近已有考核成绩列表(我的)',
141
+ capability: 'performance.flow.query',
142
+ risk: 'read',
143
+ inputSchema: schemaOf({}),
144
+ handler: recent,
145
+ },
146
+ {
147
+ name: 'performance.flow.pending',
148
+ resource: 'performance.flow',
149
+ method: 'query',
150
+ action: 'flow.pending',
151
+ summary: '待处理数量(待评分/待审批/面谈/审核)',
152
+ capability: 'performance.flow.query',
153
+ risk: 'read',
154
+ inputSchema: schemaOf({}),
155
+ handler: pending,
156
+ },
157
+ {
158
+ name: 'performance.flow.todo',
159
+ resource: 'performance.flow',
160
+ method: 'query',
161
+ action: 'flow.todo',
162
+ summary: '待处理明细列表(默认待评分;total/hasMore 不可信)',
163
+ capability: 'performance.flow.query',
164
+ risk: 'read',
165
+ inputSchema: schemaOf({
166
+ tab: { type: 'string', enum: ['score', 'approve'], description: '待评分(score) 或 待审批(approve),默认 score' },
167
+ current: { type: 'integer', minimum: 1, description: '页码,默认 1' },
168
+ pageSize: { type: 'integer', minimum: 1, maximum: 100, description: '每页条数,默认 20' },
169
+ }),
170
+ handler: todo,
171
+ },
172
+ {
173
+ name: 'performance.flow.done',
174
+ resource: 'performance.flow',
175
+ method: 'query',
176
+ action: 'flow.done',
177
+ summary: '已办考核列表(我作为评分/审批人已处理的)',
178
+ capability: 'performance.flow.query',
179
+ risk: 'read',
180
+ inputSchema: schemaOf({
181
+ keyword: { type: 'string', description: '考核名称关键字' },
182
+ kpiUserId: { type: 'string', description: '被考核人 userId(字符串,按被考核人过滤)' },
183
+ current: { type: 'integer', minimum: 1, description: '页码,默认 1' },
184
+ pageSize: { type: 'integer', minimum: 1, maximum: 100, description: '每页条数,默认 20' },
185
+ }),
186
+ handler: done,
187
+ },
188
+ {
189
+ name: 'performance.flow.list',
190
+ resource: 'performance.flow',
191
+ method: 'query',
192
+ action: 'flow.list',
193
+ summary: '考核成绩列表:我的/直接下属/间接下属/下属/全部/本人/待处理(dataType 单选或组合)',
194
+ capability: 'performance.flow.query',
195
+ risk: 'read',
196
+ inputSchema: schemaOf({
197
+ dataType: {
198
+ type: 'array',
199
+ items: { type: 'string', enum: ['mine', 'directsub', 'indirectsub', 'sub', 'all', 'myself', 'pending'] },
200
+ description: '查询范围:mine=我的 / directsub=直接下属 / indirectsub=间接下属 / sub=下属 / all=全部 / myself=本人 / pending=待处理;默认 ["mine"]',
201
+ },
202
+ status: { type: 'array', items: { type: 'string' }, description: '流程状态过滤(可选)' },
203
+ dateType: { type: 'string', enum: ['year', 'halfyear', 'quarter', 'month'], description: '考核周期类型(可选)' },
204
+ startTime: { type: ['string', 'integer'], description: '开始时间(可选);按前端同源写法原样透传' },
205
+ endTime: { type: ['string', 'integer'], description: '结束时间(可选)' },
206
+ keyword: { type: 'string', description: '考核名称关键字(可选)' },
207
+ schemeId: { type: ['string', 'integer'], description: '限定某个方案(可选)' },
208
+ current: { type: 'integer', minimum: 1, description: '页码,默认 1' },
209
+ pageSize: { type: 'integer', minimum: 1, maximum: 100, description: '每页条数,默认 20' },
210
+ }),
211
+ handler: list,
212
+ },
213
+ ];
@@ -0,0 +1,241 @@
1
+ import { buildDetailUrl, buildScoreRequest, estimateTotal, parseScoreColumn, unwrapWeaData, } from '../flow-utils.js';
2
+ import { pfConfirmationError, pfFail, pfValidationError } from '../errors.js';
3
+ import { schemeFingerprint } from '../scheme-validate.js';
4
+ import { pfSuccess, schemaOf } from './types.js';
5
+ const DETAIL_PATH = '/api/workrelate/performance/flow/detail';
6
+ const STAGE_PATH = '/api/workrelate/performance/flow/countBasicFlowTotal';
7
+ const SUBMIT_PATH = '/api/workrelate/performance/flow/updateScore';
8
+ const PAYLOAD_SCHEMA = {
9
+ type: 'array',
10
+ description: '评分行数组:[{dataRow, kps, targetValue?, actualValue?, remark?}];dataRow 与 kps 必填(公式行 kps 可省略)',
11
+ items: {
12
+ type: 'object',
13
+ additionalProperties: false,
14
+ properties: {
15
+ dataRow: { type: 'integer', description: '指标行号(必填,取自 flow.assess 的 indicators[].dataRow)' },
16
+ kps: { type: ['string', 'number'], description: '评分(必填;不得超过满分)' },
17
+ targetValue: { type: ['string', 'number'], description: '目标值(定量指标必填,可省略取详情已有值)' },
18
+ actualValue: { type: ['string', 'number'], description: '实际值(dataSource=1 或数据源模式允许编辑时必填)' },
19
+ remark: { type: 'string', description: '评分备注(可选,页面备注框同源)' },
20
+ },
21
+ required: ['dataRow'],
22
+ },
23
+ };
24
+ async function loadDetail(env, flowId, operation) {
25
+ const data = unwrapWeaData(await env.host.request({
26
+ path: `${DETAIL_PATH}/${encodeURIComponent(flowId)}`,
27
+ method: 'GET',
28
+ operation,
29
+ }), '考核详情');
30
+ const column = parseScoreColumn(data);
31
+ if (!column) {
32
+ throw pfValidationError('not_scorable', '当前用户对该考核不可评分(找不到可编辑评分列):可能不是本轮评分人,或考核不在评分阶段', { flowStatus: data?.flowStatus ?? null, canScore: data?.canScore ?? null });
33
+ }
34
+ return { data, column };
35
+ }
36
+ /**
37
+ * stage:评分暂存到考核详情页(低风险预览写)。
38
+ * 后端 countBasicFlowTotal(type=1) 会真实写入 HR_KPI_FLOW_STEP_LINK:页面立即可见、不流转、可被提交覆盖。
39
+ * 副作用:若最终不提交,页面会残留 AI 预填分。
40
+ */
41
+ async function stage(args, env) {
42
+ if (args.confirm !== true) {
43
+ throw pfConfirmationError('performance.flow.score.stage', {
44
+ hint: '暂存会把评分写进考核详情页(不流转、可覆盖)。确认用户已知晓该副作用后,带 confirm=true 重试',
45
+ });
46
+ }
47
+ const flowId = String(args.flowId ?? '');
48
+ if (!flowId)
49
+ throw pfValidationError('flow_id_missing', '缺少考核流程 id(flowId)');
50
+ const { data, column } = await loadDetail(env, flowId, 'performance.flow.score.stage');
51
+ const built = buildScoreRequest(data, args.rows, column);
52
+ const response = await env.host.request({
53
+ path: STAGE_PATH,
54
+ body: {
55
+ stepId: column.stepId,
56
+ operater: column.scoreUserId,
57
+ flowid: flowId,
58
+ stepLinkData: built.body.kpiFlowStepLinkList,
59
+ type: '1',
60
+ },
61
+ operation: 'performance.flow.score.stage',
62
+ });
63
+ const computed = unwrapWeaData(response, '暂存评分');
64
+ const missingRemark = (Array.isArray(args.rows) ? args.rows : [])
65
+ .filter((row) => !row?.remark)
66
+ .map((row) => row?.dataRow);
67
+ return pfSuccess('performance.flow.score.stage', {
68
+ flowId,
69
+ staged: true,
70
+ computedTotal: computed?.score ?? computed?.finalScore ?? null,
71
+ backendTotalScore: computed?.totalScore ?? null,
72
+ estimatedTotal: estimateTotal(data, built.body.kpiFlowStepLinkList),
73
+ rows: built.rows,
74
+ detailUrl: buildDetailUrl(flowId, built.rows),
75
+ sideEffect: '评分已写入详情页(不流转、可覆盖);若不提交,页面会保留 AI 预填分,可在页面清除',
76
+ ...(missingRemark.length
77
+ ? { warnings: [`以下指标行未提供评分理由(remark),页面备注列会是空的:dataRow=${missingRemark.join('、')}——每行都应把评分理由写入 remark`] }
78
+ : {}),
79
+ next: '用户在详情页查看后,可自行点「确认并通过」,或让 AI 走 performance.flow.score.submit.prepare → apply',
80
+ });
81
+ }
82
+ /** submit.prepare:组装提交内容 + 前置校验 + 确认摘要(不落库)。 */
83
+ async function submitPrepare(args, env) {
84
+ const flowId = String(args.flowId ?? '');
85
+ if (!flowId)
86
+ throw pfValidationError('flow_id_missing', '缺少考核流程 id(flowId)');
87
+ const { data, column } = await loadDetail(env, flowId, 'performance.flow.score.submit.prepare');
88
+ const built = buildScoreRequest(data, args.rows, column);
89
+ const fingerprint = schemeFingerprint(built.body);
90
+ const continuation = await env.continuation.issue({
91
+ operation: 'performance.flow.score.submit.apply',
92
+ fingerprint,
93
+ });
94
+ return pfSuccess('performance.flow.score.submit.prepare', {
95
+ continuation,
96
+ fingerprint,
97
+ preview: {
98
+ flowId,
99
+ name: built.meta.name,
100
+ kpiUserName: built.meta.kpiUserName,
101
+ assessmentCycle: built.meta.assessmentCycle,
102
+ maxScore: built.meta.maxScore,
103
+ estimatedTotal: estimateTotal(data, built.body.kpiFlowStepLinkList),
104
+ rows: built.rows,
105
+ missingRemark: (Array.isArray(args.rows) ? args.rows : []).filter((row) => !row?.remark).map((row) => row?.dataRow),
106
+ impact: '提交会流转评分节点;所有节点评完将结束考核(finished),可能触发 ESB 动作流与消息提醒',
107
+ },
108
+ }, {
109
+ continuation,
110
+ fingerprint,
111
+ confirmHint: '提交为高风险写入:向用户展示 preview 并取得明确同意后,带 confirm=true 与 continuation 调用 performance.flow.score.submit.apply',
112
+ });
113
+ }
114
+ /** submit.apply:确认后写入评分(updateScore),成功自动回读核验。 */
115
+ async function submitApply(args, env) {
116
+ if (args.confirm !== true) {
117
+ throw pfConfirmationError('performance.flow.score.submit.apply', {
118
+ hint: '提交会流转考核流程节点,必须用户明确同意',
119
+ });
120
+ }
121
+ if (typeof args.continuation !== 'string' || !args.continuation) {
122
+ throw pfValidationError('continuation_missing', '缺少 continuation(先运行 performance.flow.score.submit.prepare)');
123
+ }
124
+ const verified = await env.continuation.verify(args.continuation, 'performance.flow.score.submit.apply');
125
+ const flowId = String(args.flowId ?? '');
126
+ if (!flowId)
127
+ throw pfValidationError('flow_id_missing', '缺少考核流程 id(flowId)');
128
+ const { data, column } = await loadDetail(env, flowId, 'performance.flow.score.submit.apply');
129
+ const built = buildScoreRequest(data, args.rows, column);
130
+ const fingerprint = schemeFingerprint(built.body);
131
+ if (String(verified.fingerprint) !== fingerprint) {
132
+ throw pfValidationError('fingerprint_mismatch', '提交内容与确认摘要不一致(评分或考核数据在 prepare 后发生变化),请重新 prepare 并再次确认', {
133
+ expected: verified.fingerprint,
134
+ actual: fingerprint,
135
+ });
136
+ }
137
+ const body = { ...built.body, distributeCheck: args.skipDistributeCheck === true ? false : true };
138
+ let response;
139
+ try {
140
+ response = await env.host.request({
141
+ path: SUBMIT_PATH,
142
+ body,
143
+ operation: 'performance.flow.score.submit.apply',
144
+ });
145
+ }
146
+ catch (error) {
147
+ const message = error?.message ?? String(error);
148
+ if (/数据已更新|182612/.test(message)) {
149
+ // 幂等守卫:同一操作人已提交过(OperateStatus=opKpsEnd)
150
+ throw pfFail('该考核已由你提交过(数据已更新,请刷新后重试)——不要重试,直接回读核对状态', { flowId });
151
+ }
152
+ throw error;
153
+ }
154
+ // 强制分布冲突:返回 remindType=warning|stop 且未流转
155
+ const remindType = response?.data?.remindType ?? response?.remindType ?? null;
156
+ if (remindType === 'stop') {
157
+ throw pfFail('绩效强制分布校验未通过(stop):本次未流转,请调整评分或联系管理员', { flowId, remindType });
158
+ }
159
+ if (remindType === 'warning') {
160
+ return pfSuccess('performance.flow.score.submit.apply', {
161
+ flowId,
162
+ submitted: false,
163
+ distributeConflict: 'warning',
164
+ message: '绩效分布比例冲突(warning):本次未流转。向用户说明后,可带 skipDistributeCheck=true 重新提交',
165
+ estimatedTotal: estimateTotal(data, built.body.kpiFlowStepLinkList),
166
+ });
167
+ }
168
+ unwrapWeaData(response, '提交评分');
169
+ // 回读核验
170
+ const after = unwrapWeaData(await env.host.request({
171
+ path: `${DETAIL_PATH}/${encodeURIComponent(flowId)}`,
172
+ method: 'GET',
173
+ operation: 'performance.flow.score.submit.apply',
174
+ }), '提交后回读');
175
+ const keys = { kpsKey: `kps${column.stepId}-${column.scoreUserId}` };
176
+ const verifyRows = (Array.isArray(after?.basicData) ? after.basicData : []).map((row) => ({
177
+ dataRow: row?.dataRow,
178
+ name: row?.type ?? null,
179
+ score: row?.[keys.kpsKey] ?? null,
180
+ }));
181
+ return pfSuccess('performance.flow.score.submit.apply', {
182
+ flowId,
183
+ submitted: true,
184
+ total: after?.score ?? null,
185
+ flowStatus: after?.flowStatus ?? null,
186
+ verify: { rows: verifyRows },
187
+ detailUrl: buildDetailUrl(flowId),
188
+ next: '已回读核对;如状态为已结束(finished),该考核本轮已完成',
189
+ });
190
+ }
191
+ export const flowScoreOperations = [
192
+ {
193
+ name: 'performance.flow.score.stage',
194
+ resource: 'performance.flow',
195
+ method: 'apply',
196
+ action: 'flow.score.stage',
197
+ summary: '评分暂存到考核详情页(低风险预览写:不流转、可覆盖、页面立即可见)',
198
+ capability: 'performance.flow.score',
199
+ risk: 'write',
200
+ requiresConfirmation: true,
201
+ inputSchema: schemaOf({
202
+ flowId: { type: 'string', description: '考核流程 id(字符串)' },
203
+ rows: PAYLOAD_SCHEMA,
204
+ confirm: { type: 'boolean', description: '必须 true(用户已知晓会写入详情页、不流转、可覆盖)' },
205
+ }, { required: ['flowId', 'rows', 'confirm'] }),
206
+ handler: stage,
207
+ },
208
+ {
209
+ name: 'performance.flow.score.submit.prepare',
210
+ resource: 'performance.flow',
211
+ method: 'prepare',
212
+ action: 'flow.score.submit',
213
+ summary: '提交评分前组装与校验(不落库):前置校验 kps/目标值/实际值/满分,返回确认摘要与 continuation',
214
+ capability: 'performance.flow.score',
215
+ risk: 'write',
216
+ requiresConfirmation: true,
217
+ inputSchema: schemaOf({
218
+ flowId: { type: 'string', description: '考核流程 id(字符串)' },
219
+ rows: PAYLOAD_SCHEMA,
220
+ }, { required: ['flowId', 'rows'] }),
221
+ handler: submitPrepare,
222
+ },
223
+ {
224
+ name: 'performance.flow.score.submit.apply',
225
+ resource: 'performance.flow',
226
+ method: 'apply',
227
+ action: 'flow.score.submit',
228
+ summary: '确认后提交评分(流转节点、可能结束考核并触发提醒),成功后自动回读',
229
+ capability: 'performance.flow.score',
230
+ risk: 'write',
231
+ requiresConfirmation: true,
232
+ inputSchema: schemaOf({
233
+ flowId: { type: 'string', description: '考核流程 id(字符串)' },
234
+ rows: PAYLOAD_SCHEMA,
235
+ confirm: { type: 'boolean', description: '必须 true(用户已明确同意提交)' },
236
+ continuation: { type: 'string', description: 'prepare 返回的 continuation' },
237
+ skipDistributeCheck: { type: 'boolean', description: '仅当用户确认接受分布冲突后跳过强制分布校验(warning 时用)' },
238
+ }, { required: ['flowId', 'rows', 'confirm', 'continuation'] }),
239
+ handler: submitApply,
240
+ },
241
+ ];
@@ -3,11 +3,17 @@ import { schemeDraftOperations } from './scheme-draft.js';
3
3
  import { schemePublishOperations } from './scheme-publish.js';
4
4
  import { schemeDetailOperations } from './scheme-detail.js';
5
5
  import { hrmResolveOperations } from './hrm-resolve.js';
6
+ import { flowListOperations } from './flow-list.js';
7
+ import { flowDetailOperations } from './flow-detail.js';
8
+ import { flowScoreOperations } from './flow-score.js';
6
9
  const definitions = [
7
10
  ...hrmResolveOperations,
8
11
  ...schemeDetailOperations,
9
12
  ...schemeDraftOperations,
10
13
  ...schemePublishOperations,
14
+ ...flowListOperations,
15
+ ...flowDetailOperations,
16
+ ...flowScoreOperations,
11
17
  ];
12
18
  const registry = new Map();
13
19
  for (const definition of definitions) {
@@ -0,0 +1,64 @@
1
+ import { isDeepStrictEqual } from 'node:util';
2
+ import { WORKFLOW_ENDPOINTS } from '../../endpoints.js';
3
+ import { extractTotal } from '../read.js';
4
+ import { responseData } from '../shared.js';
5
+ const CATEGORY_TABS = ['0', '7', '5', '8', '6', '1'];
6
+ function recordOf(value) {
7
+ return value !== null && typeof value === 'object' && !Array.isArray(value)
8
+ ? value : {};
9
+ }
10
+ /** 可选导航计数不能把业务失败或非法总数解释为零。 */
11
+ export function readTodoCategoryTotal(response) {
12
+ const outer = recordOf(response);
13
+ const data = recordOf(responseData(response));
14
+ const nested = recordOf(data.data);
15
+ if ([outer, data, nested].some(part => part.status === false || part.success === false || part.fail === true))
16
+ return null;
17
+ for (const candidate of [data.total, data.count, data.totalCount, nested.total, nested.totalCount]) {
18
+ if (candidate === undefined || candidate === null || candidate === '')
19
+ continue;
20
+ if (typeof candidate !== 'number' && typeof candidate !== 'string')
21
+ return null;
22
+ if (typeof candidate === 'string' && !candidate.trim())
23
+ return null;
24
+ const total = extractTotal({ total: candidate });
25
+ if (total !== null)
26
+ return Number.isSafeInteger(total) && total >= 0 ? total : null;
27
+ }
28
+ return null;
29
+ }
30
+ function withoutPagination(query) {
31
+ const body = structuredClone(query);
32
+ for (const key of ['customDisplayPage', 'current', 'pageSize'])
33
+ delete body[key];
34
+ return body;
35
+ }
36
+ /** 与分类链接使用同一最终查询范围;各分类只查总数,不重取明细。 */
37
+ export async function collectTodoCategoryCounts(env, listQuery, knownTotals = []) {
38
+ const body = withoutPagination(listQuery);
39
+ body.params = { ...recordOf(body.params) };
40
+ const params = recordOf(body.params);
41
+ delete params.flowSpareType;
42
+ const counts = {};
43
+ const currentTab = String(params.tabid ?? '');
44
+ const known = knownTotals.find(item => Number.isSafeInteger(item.total) && item.total >= 0
45
+ && isDeepStrictEqual(body, withoutPagination(item.body)));
46
+ if (known && CATEGORY_TABS.some(tab => tab === currentTab))
47
+ counts[currentTab] = known.total;
48
+ if (currentTab === '0' && counts['0'] === 0)
49
+ return Object.fromEntries(CATEGORY_TABS.map(tab => [tab, 0]));
50
+ const results = await Promise.allSettled(CATEGORY_TABS.filter(tab => counts[tab] === undefined).map(async (tab) => {
51
+ const categoryBody = structuredClone(body);
52
+ categoryBody.params = { ...params, tabid: tab };
53
+ const response = await env.host.workflowRequest({
54
+ method: 'POST', path: WORKFLOW_ENDPOINTS.TODO_TOTAL,
55
+ operation: 'workflow.todoSmartConvert.categoryCounts', body: categoryBody,
56
+ });
57
+ return { tab, total: readTodoCategoryTotal(response) };
58
+ }));
59
+ for (const result of results) {
60
+ if (result.status === 'fulfilled' && result.value.total !== null)
61
+ counts[result.value.tab] = result.value.total;
62
+ }
63
+ return counts;
64
+ }
@@ -7,6 +7,7 @@ import { saveSearchIndex } from '../../state.js';
7
7
  import { buildSearchQuery, extractTotal } from '../read.js';
8
8
  import { projectDisplayRows } from './todoListRows.js';
9
9
  import { responseData } from '../shared.js';
10
+ import { collectTodoCategoryCounts, readTodoCategoryTotal } from './todoSmartConvert.categoryCounts.js';
10
11
  import { openSummaryCache, promptTagOf, SUMMARY_CACHE_FILE_NAME } from './summaryCache.js';
11
12
  import { openDetailCache, detailMaterialTagOf } from './todoDetailCache.js';
12
13
  import { fetchDetailFacts, stampsOfRows } from './todoSmartConvert.detail.js';
@@ -98,6 +99,7 @@ export async function collectRawTodos(args, env) {
98
99
  return `${fmt(start)} ${fmt(end)}`;
99
100
  };
100
101
  // 探总数:报文与列表取数完全一致(去掉 customDisplayPage),路径换成同分类的总数接口。
102
+ const knownTotals = [];
101
103
  const probeTodoTotal = async () => {
102
104
  const { query } = await buildSearchQuery(listEnv, { ...searchArgs, current: 1, pageSize }, 'list', category === 'todo' ? { workflowNameMatch: 'all' } : {});
103
105
  const isremarks = String(searchArgs.isremarks ?? '').trim();
@@ -112,6 +114,11 @@ export async function collectRawTodos(args, env) {
112
114
  operation: 'workflow.todoSmartConvert.total',
113
115
  body: totalBody,
114
116
  });
117
+ if (args.includeCategoryCounts === true) {
118
+ const categoryTotal = readTodoCategoryTotal(response);
119
+ if (categoryTotal !== null)
120
+ knownTotals.push({ body: totalBody, total: categoryTotal });
121
+ }
115
122
  return extractTotal(response);
116
123
  }
117
124
  catch {
@@ -184,6 +191,7 @@ export async function collectRawTodos(args, env) {
184
191
  let totalAvailable = null;
185
192
  let pages = 0;
186
193
  let stoppedEarly = false;
194
+ let listQuery;
187
195
  // 翻页:按 current 递增,取到「累计达到 limit(若传)/ 空页 / 页不满」为止;
188
196
  // limit 不传(不限条数)时翻到数据取完为止(2026-11-11 用户定稿:不再有页数/条数上限)。
189
197
  for (let pageNo = 1; limit === null || (policy.strictLimit ? items.length < limit : pageNo <= (plannedPages ?? 0)); pageNo += 1) {
@@ -199,6 +207,9 @@ export async function collectRawTodos(args, env) {
199
207
  if (isremarks !== '') {
200
208
  query.params = { ...(query.params || {}), isremarks };
201
209
  }
210
+ // 保留最终范围的实际请求,供同轮分类链接复用,避免从名称或摘要 ID 重建筛选。
211
+ if (category === 'todo' && !listQuery)
212
+ listQuery = structuredClone(query);
202
213
  // 调试留痕(环境变量开启才写):把最终发往列表接口的 body 原样落盘,便于核对拼接结果。
203
214
  if (process.env.WEAVER_WORK_CLI_DUMP_LIST_BODY) {
204
215
  try {
@@ -475,10 +486,14 @@ export async function collectRawTodos(args, env) {
475
486
  + '本次按「从未生成过」走实时逻辑;请经 skill 的 tools 脚本调用');
476
487
  }
477
488
  }
489
+ const categoryCounts = args.includeCategoryCounts === true && category === 'todo' && listQuery
490
+ ? await collectTodoCategoryCounts(env, listQuery, knownTotals) : undefined;
478
491
  return {
479
492
  stage: 'collect',
480
493
  query: {
481
494
  category,
495
+ ...(listQuery ? { listQuery } : {}),
496
+ ...(categoryCounts ? { categoryCounts } : {}),
482
497
  ...(policy.outputMode ? { outputMode: policy.outputMode } : {}),
483
498
  ...(scope ? { tabid: searchArgs.tabid } : {}),
484
499
  /** 本次有效条数上限;历史未指定模式和 limit 时为 null。 */
@@ -165,6 +165,7 @@ export const COLLECT_ORDER_KEYS = ['sort'];
165
165
  export const ALLOWED_INPUT_KEYS = [
166
166
  'stage',
167
167
  'outputMode',
168
+ 'includeCategoryCounts',
168
169
  'items',
169
170
  'aiGroups',
170
171
  'aiSummaries',
@@ -461,6 +462,9 @@ export function rowFromAny(raw, extraFields) {
461
462
  return result;
462
463
  }
463
464
  export function assertKnownKeys(args) {
465
+ if (args.includeCategoryCounts !== undefined && typeof args.includeCategoryCounts !== 'boolean') {
466
+ throw workflowValidationError('input_invalid', 'includeCategoryCounts 必须是布尔值');
467
+ }
464
468
  const known = [...ALLOWED_INPUT_KEYS, ...RESUME_INPUT_KEYS];
465
469
  const unknown = Object.keys(args).filter((key) => !known.includes(key));
466
470
  if (unknown.length > 0) {
@@ -16,6 +16,10 @@ import { runGroupSummary, runGroupSummaryContext } from './todoSmartConvert.grou
16
16
  import { runSmartGroupAdd } from './todoSmartConvert.smartGroupAdd.js';
17
17
  import { schemaOf, } from '../types.js';
18
18
  const inputSchema = schemaOf({
19
+ includeCategoryCounts: {
20
+ type: 'boolean', default: false,
21
+ description: '仅待办prepareQuery/collect:按最终分类链接条件并行读取全部、待处理、待阅、被退回、超时、未读总数;复用同条件已有总数,失败项保持未知。默认不额外统计。',
22
+ },
19
23
  outputMode: {
20
24
  type: 'string',
21
25
  enum: [...OUTPUT_MODE_VALUES],
@@ -2,6 +2,7 @@ import { WorkflowCliError, workflowApiError } from '../../errors.js';
2
2
  import { buildSearchQuery, extractTotal, rethrowAuthOrNetworkError } from '../read.js';
3
3
  import { responseData } from '../shared.js';
4
4
  import { generalRules } from './aigroupRules.js';
5
+ import { collectTodoCategoryCounts } from './todoSmartConvert.categoryCounts.js';
5
6
  import { COLLECT_FILTER_KEYS, COLLECT_ORDER_KEYS, DEFAULT_TABID, LIST_ENDPOINT_BY_CATEGORY, QUERY_MAX_LIMIT, readCategory, readCollectPolicy, totalEndpointFor, } from './todoSmartConvert.core.js';
6
7
  function recordOf(value) {
7
8
  return value !== null && typeof value === 'object' && !Array.isArray(value)
@@ -137,12 +138,15 @@ export async function prepareTodoQuery(args, env) {
137
138
  }
138
139
  const complete = total !== null && seen.size === total && !unreadRows;
139
140
  const sort = typeof searchArgs.sort === 'string' ? searchArgs.sort.trim() : '';
141
+ const categoryCounts = args.includeCategoryCounts === true && category === 'todo'
142
+ ? await collectTodoCategoryCounts(env, listQuery, total === null ? [] : [{ body: totalBody, total }]) : undefined;
140
143
  return {
141
144
  stage: 'prepareQuery',
142
145
  query: {
143
146
  category, requestedLimit: policy.limit, totalAvailable: total,
144
147
  filters: Object.fromEntries(Object.entries(searchArgs).filter(([key]) => !['category', 'tabid', 'sort'].includes(key))),
145
148
  listQuery,
149
+ ...(categoryCounts ? { categoryCounts } : {}),
146
150
  ...(sort ? { sort } : {}),
147
151
  },
148
152
  totalCount: total,