weaver-work-cli 0.1.64 → 0.1.66
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunks/{attachment-content-JQDW3BIB.js → attachment-content-NRBGS5XG.js} +3 -3
- package/dist/chunks/{chunk-RMOH2GMF.js → chunk-2BAZJCG7.js} +2 -2
- package/dist/chunks/{chunk-SHX7XBYR.js → chunk-4WCVRDC5.js} +83 -33
- package/dist/chunks/{chunk-KDFEHDIB.js → chunk-5FQT7GSN.js} +2 -2
- package/dist/chunks/{chunk-3PCXBG4H.js → chunk-AAOYOPHW.js} +1 -1
- package/dist/chunks/{chunk-5QQKLR6H.js → chunk-BZ6HAY2U.js} +7 -7
- package/dist/chunks/{chunk-I3MOFD6Q.js → chunk-EYEJW5SG.js} +4 -4
- package/dist/chunks/{chunk-SCMHG23G.js → chunk-GOZ75GHU.js} +38 -38
- package/dist/chunks/{chunk-4AFWOGOV.js → chunk-M7IEDTRI.js} +1 -1
- package/dist/chunks/{chunk-XHSEK2VM.js → chunk-NNXZMBIB.js} +6 -6
- package/dist/chunks/{chunk-K7QKQRSL.js → chunk-NP3ZZFGI.js} +24 -24
- package/dist/chunks/{chunk-INVYKG4I.js → chunk-SAADVUK6.js} +32 -32
- package/dist/chunks/{chunk-YTFNMQO4.js → chunk-VWQGF3KW.js} +103 -19
- package/dist/chunks/{chunk-AGSO3PIK.js → chunk-YFX5JKOY.js} +2 -2
- package/dist/chunks/{chunk-KYDXWYFB.js → chunk-YT73QQMS.js} +1 -1
- package/dist/chunks/{conflict-UUC7AFUI.js → conflict-LJYKIUJM.js} +2 -2
- package/dist/chunks/{contract-INMS7SYQ.js → contract-N5WNHKHI.js} +94 -30
- package/dist/chunks/{create-flow-YOR4QTAJ.js → create-flow-75MCKXGI.js} +6 -6
- package/dist/chunks/{entry-mode-S2ENJ6GZ.js → entry-mode-3PI6A7JD.js} +3 -3
- package/dist/chunks/{env-ZSAXU5PJ.js → env-FI62FOKK.js} +2 -2
- package/dist/chunks/{factory-N76QQA53.js → factory-HLS4SDQM.js} +1 -1
- package/dist/chunks/{group-chat-UM665WDZ.js → group-chat-MFBVOLKY.js} +3 -3
- package/dist/chunks/{lazy-dispatch-4WOIL3ZQ.js → lazy-dispatch-K25LTKQY.js} +2 -2
- package/dist/chunks/{meeting-MMTYDHXA.js → meeting-ROWDB3DO.js} +11 -11
- package/dist/chunks/{minute-doc-LCSBWGJ3.js → minute-doc-ABMO2UDX.js} +2 -2
- package/dist/chunks/{registry-BAWCWV4D.js → registry-NLAO2W6T.js} +2 -2
- package/dist/chunks/{registry-FNI5E76J.js → registry-QV6IPRVM.js} +11 -11
- package/dist/chunks/{room-recommend-I7QQRHEL.js → room-recommend-P54PQTCN.js} +4 -4
- package/dist/chunks/{schedule-3P7EWGNZ.js → schedule-BEBFGMT6.js} +4 -4
- package/dist/chunks/{smart-extract-FOBSVNYW.js → smart-extract-DEBLJPCQ.js} +11 -11
- package/dist/chunks/{workflow-U2KKTVQY.js → workflow-LBFFZZN2.js} +2 -2
- package/dist/cmd/refs/index.js +24 -23
- package/dist/core/output.js +134 -41
- package/dist/index.js +7 -7
- package/dist/shortcuts/contract/manifest.js +11 -4
- package/dist/shortcuts/contract/operations/first-screen.js +41 -19
- package/dist/shortcuts/contract/operations/flow.js +2 -0
- package/dist/shortcuts/contract/operations/ledger.js +58 -8
- package/dist/shortcuts/contract/operations/quote-recognize.js +31 -9
- package/dist/shortcuts/contract/operations/quote-submit.js +4 -1
- package/dist/shortcuts/contract/operations/upload.js +21 -1
- package/dist/shortcuts/contract/upload-cache.js +2 -2
- package/dist/shortcuts/smart-extract/operations/fill.js +14 -14
- package/dist/shortcuts/workflow/index.js +2 -2
- package/dist/shortcuts/workflow/operations/form.js +28 -4
- package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.categoryCounts.js +64 -0
- package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.collect.js +15 -0
- package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.core.js +4 -0
- package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.js +4 -0
- package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.prepareQuery.js +4 -0
- package/docs/agent-io-channel-design.md +21 -10
- package/docs/smart-extract.md +1 -1
- package/docs/todo-smart-convert/data-contract.md +1 -1
- package/package.json +1 -1
- package/skills/weaver-e10-jinchengda/SKILL.md +67 -31
- package/skills/weaver-e10-jinchengda/references/contract-ai-review.md +18 -18
- package/skills/weaver-e10-jinchengda/references/contract-clause-insert.md +4 -4
- package/skills/weaver-e10-jinchengda/references/contract-clause-library-crud.md +1 -1
- package/skills/weaver-e10-jinchengda/references/contract-command-index.md +2 -2
- package/skills/weaver-e10-jinchengda/references/contract-compare-report.md +6 -6
- package/skills/weaver-e10-jinchengda/references/contract-credit-page.md +3 -3
- package/skills/weaver-e10-jinchengda/references/contract-disabled-capabilities.md +1 -1
- package/skills/weaver-e10-jinchengda/references/contract-doc-compare.md +6 -6
- package/skills/weaver-e10-jinchengda/references/contract-doc-triage.md +7 -7
- package/skills/weaver-e10-jinchengda/references/contract-element-save-record.md +9 -9
- package/skills/weaver-e10-jinchengda/references/contract-execution-rules.md +3 -3
- package/skills/weaver-e10-jinchengda/references/contract-field-extract-new-customer.md +11 -11
- package/skills/weaver-e10-jinchengda/references/contract-field-extract-other-flows.md +18 -18
- package/skills/weaver-e10-jinchengda/references/contract-flow-launch.md +4 -4
- package/skills/weaver-e10-jinchengda/references/contract-ledger-catalog.md +18 -15
- package/skills/weaver-e10-jinchengda/references/contract-ledger-query-playbook.md +51 -28
- package/skills/weaver-e10-jinchengda/references/contract-ledger-rules.md +6 -6
- package/skills/weaver-e10-jinchengda/references/contract-modeltext-library.md +1 -1
- package/skills/weaver-e10-jinchengda/references/contract-multi-file.md +20 -9
- package/skills/weaver-e10-jinchengda/references/contract-object-detect.md +18 -18
- package/skills/weaver-e10-jinchengda/references/contract-open-web-pages.md +9 -9
- package/skills/weaver-e10-jinchengda/references/contract-performance-query.md +4 -4
- package/skills/weaver-e10-jinchengda/references/contract-quote-to-contract.md +42 -30
- package/skills/weaver-e10-jinchengda/references/contract-template-recommend.md +1 -1
- package/skills/weaver-e10-jinchengda/references/contract-type-fingerprints.md +8 -8
- package/skills/weaver-e10-jinchengda/references/contract-workflow-discovery.md +1 -1
- package/skills/weaver-e10-jinchengda/references/orchestration.md +2 -2
- package/skills/weaver-e10-jucailin/references/recruit-interview-overview.md +1 -1
- package/skills/weaver-e10-shared/references/json-output-contract.md +4 -3
- package/skills/weaver-e10-smart-extract/SKILL.md +1 -1
- package/skills/weaver-e10-workflow/SKILL.md +40 -16
- package/skills/weaver-e10-workflow/aigroup/default.json +1 -1
- package/skills/weaver-e10-workflow/references/todo-dialogue.md +30 -27
- package/skills/weaver-e10-workflow/references/todo-smart-convert.md +90 -22
- package/skills/weaver-e10-workflow/references/workflow-view.md +18 -2
- package/skills/weaver-e10-workflow/tools/todo-summary.cjs +240 -43
|
@@ -545,6 +545,45 @@ function normalizeRoutePerson(raw) {
|
|
|
545
545
|
}
|
|
546
546
|
return out.length ? out : null;
|
|
547
547
|
}
|
|
548
|
+
/**
|
|
549
|
+
* 人员/团队条件「只给了姓名、或 id 不合法」时,给出**先解析人员 ID** 的可执行动作。
|
|
550
|
+
*
|
|
551
|
+
* 事故(2026-11-23 用户反馈):用户说「查一下吴洋洋的业绩」,模型**直接开卡且没带人员筛选**,
|
|
552
|
+
* 理由是「台账卡片只接受人员 ID,我这边没有可靠的人员 ID 来源,所以把条件留给页面」。
|
|
553
|
+
* 真实原因是 **skill 从没提过 CLI 早就有 `im.person.resolve`**(实测 `{name:"吴洋洋"}` →
|
|
554
|
+
* `uid = 732851919151005700`,正是台账要的那个 ID)——模型只知道「必须传 ID、不能猜」,
|
|
555
|
+
* 于是把用户明确给的条件**静默降级**成「交给页面」,用户拿到的是一张全量卡。
|
|
556
|
+
*
|
|
557
|
+
* 因此这里不静默:把「缺 ID」变成一条带 `requiredAction` / `command` / `forbiddenClaims` 的显式结论,
|
|
558
|
+
* 并在调用方**扣住卡片**——逼出「先解析 ID 再出卡」。
|
|
559
|
+
*/
|
|
560
|
+
function buildPersonLookup(conditions, unsupported) {
|
|
561
|
+
const field = ['person', 'team'].find((name) => unsupported.includes(name));
|
|
562
|
+
if (!field)
|
|
563
|
+
return null;
|
|
564
|
+
const raw = conditions[field];
|
|
565
|
+
const keyword = isRecord(raw)
|
|
566
|
+
? String(raw.name ?? '').trim()
|
|
567
|
+
: String(raw ?? '').trim();
|
|
568
|
+
return {
|
|
569
|
+
field,
|
|
570
|
+
keyword,
|
|
571
|
+
reason: '台账人员字段与卡片人员筛选键**都要求人员 ID**:传姓名不会报错,但会被静默忽略、'
|
|
572
|
+
+ '返回全量(实测 直销业绩 like 姓名 → 451,275 条 = 全量),用户会误以为看到的就是这个人的数据,'
|
|
573
|
+
+ '比"查不到"更危险。而 CLI **本来就能按姓名解析**,不存在"没有 ID 来源"。',
|
|
574
|
+
requiredAction: `先解析「${keyword}」的人员 ID,再用 conditions.${field}={"id":"<uid>","name":"${keyword}"} 重跑本命令`
|
|
575
|
+
+ '(拿到 ID 后本命令会直接把卡片一起返回)。',
|
|
576
|
+
command: `weaver-work-cli --json im run im.person.resolve --input <含 {"name":"${keyword}"} 的 json>`,
|
|
577
|
+
altCommand: `weaver-work-cli --json hrm run hrm.employee.query --input <含 {"username":"${keyword}","full":true} 的 json>`,
|
|
578
|
+
idSource: '人员 ID 取 im.person.resolve 的 `uid`(= hrm.employee.query 的 `id`);'
|
|
579
|
+
+ '**不是** `userid`、也**不是** `cid`(这两个是别的值,填错等于没筛选)。',
|
|
580
|
+
forbiddenClaims: [
|
|
581
|
+
'不要说「我这边没有可靠的人员 ID 来源」——先跑上面的命令',
|
|
582
|
+
'不要把人员条件丢给页面筛选后直接开卡——那会出来一张全量数据的卡',
|
|
583
|
+
'不要凭姓名猜一个 ID 填进去',
|
|
584
|
+
],
|
|
585
|
+
};
|
|
586
|
+
}
|
|
548
587
|
/**
|
|
549
588
|
* 台账入口路由判定(本地,零接口)。
|
|
550
589
|
*
|
|
@@ -723,6 +762,11 @@ export const contractLedgerRouteOperation = {
|
|
|
723
762
|
route = 'card';
|
|
724
763
|
reasons.push('未命中统计信号,按看台账处理;落不了的条件留给页面筛选');
|
|
725
764
|
}
|
|
765
|
+
// ── 人员/团队条件用不了时**不静默降级**(2026-11-23 事故,见 buildPersonLookup 注释)
|
|
766
|
+
const personLookup = buildPersonLookup(conditions, unsupported);
|
|
767
|
+
if (personLookup) {
|
|
768
|
+
reasons.push(`人员条件缺人员 ID(只拿到「${personLookup.keyword}」):必须先用 im.person.resolve 解析,不得开无筛选的卡`);
|
|
769
|
+
}
|
|
726
770
|
const prefillKeys = Object.keys(prefill);
|
|
727
771
|
// comParamsJson 是**字符串**入参:提示里必须给双层序列化后的字符串字面量。
|
|
728
772
|
// 事故(2026-11-20):这里原本只 JSON.stringify 一次,渲染出 `comParamsJson={"xsjl":[…]}`,
|
|
@@ -733,10 +777,11 @@ export const contractLedgerRouteOperation = {
|
|
|
733
777
|
// ── route=card 时**顺带把卡片也生成好**(2026-11-20,省 1 轮)
|
|
734
778
|
// 卡片构造是纯本地计算(`contract.ledger.card` 不访问业务接口),进程内调用即可。
|
|
735
779
|
// 失败**绝不影响路由结论**:路由是判定,卡片是产物;产物失败降级回 nextCommand 提示。
|
|
780
|
+
// ⛔ 但**人员条件缺 ID 时故意不建卡**:否则模型会照旧把这张"没有筛选"的卡发出去。
|
|
736
781
|
let card = null;
|
|
737
782
|
let cardSelfCheck = null;
|
|
738
783
|
let cardError = null;
|
|
739
|
-
if (route === 'card') {
|
|
784
|
+
if (route === 'card' && !personLookup) {
|
|
740
785
|
try {
|
|
741
786
|
const built = await contractLedgerCardOperation.execute({ menu, comParamsJson: JSON.stringify(prefill) }, context);
|
|
742
787
|
card = built?.data?.card ?? null;
|
|
@@ -746,12 +791,14 @@ export const contractLedgerRouteOperation = {
|
|
|
746
791
|
cardError = error instanceof Error ? error.message : String(error);
|
|
747
792
|
}
|
|
748
793
|
}
|
|
749
|
-
const nextCommand =
|
|
750
|
-
?
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
794
|
+
const nextCommand = personLookup
|
|
795
|
+
? `${personLookup.command}(拿到 uid 后重跑本命令:conditions.${personLookup.field}={"id":"<uid>","name":"${personLookup.keyword}"})`
|
|
796
|
+
: route === 'card'
|
|
797
|
+
? (card
|
|
798
|
+
? '(卡片已随本响应返回:顶层 data.card 直接作为 <browsertool> 输出,无需再调 contract.ledger.card)'
|
|
799
|
+
: 'weaver-work-cli --json contract run contract.ledger.card --input <args.json>'
|
|
800
|
+
+ `(menu=${menu}${prefillHint})`)
|
|
801
|
+
: 'contract.ledger.metrics 取口径 → contract.performance.list.query 取数 → contract.ledger.aggregate 汇总';
|
|
755
802
|
return {
|
|
756
803
|
status: 'COMPLETE',
|
|
757
804
|
data: {
|
|
@@ -769,10 +816,13 @@ export const contractLedgerRouteOperation = {
|
|
|
769
816
|
card,
|
|
770
817
|
cardSelfCheck,
|
|
771
818
|
...(cardError ? { cardError } : {}),
|
|
819
|
+
...(personLookup ? { personLookup } : {}),
|
|
772
820
|
conditions,
|
|
773
821
|
note: 'route=card 时禁止先进取数链路;只有统计信号或显式 intent 才走 ledger-query。'
|
|
774
822
|
+ '「业绩」二字、年月、「某个人的 / 某个团队的」都不是统计信号。本 operation 不访问业务接口。'
|
|
775
|
-
+ 'route=card 时顶层已带构建好的 data.card(本地零接口),直接用;data.card 为 null 时才按 nextCommand 自建。'
|
|
823
|
+
+ 'route=card 时顶层已带构建好的 data.card(本地零接口),直接用;data.card 为 null 时才按 nextCommand 自建。'
|
|
824
|
+
+ '⚠️ 出现 personLookup 时:**先按它的 command 解析人员 ID 再重跑本命令**,'
|
|
825
|
+
+ '此时 card 故意为 null——不要绕开它去自建一张没有人员筛选的卡。',
|
|
776
826
|
},
|
|
777
827
|
};
|
|
778
828
|
},
|
|
@@ -91,11 +91,22 @@ function normalizeSections(input) {
|
|
|
91
91
|
}
|
|
92
92
|
return out;
|
|
93
93
|
}
|
|
94
|
-
/**
|
|
95
|
-
|
|
94
|
+
/**
|
|
95
|
+
* 合同背景说明:客户 + 标的 + 费用构成概览,全部取自报价单。
|
|
96
|
+
*
|
|
97
|
+
* ⛔ 不得写死产品名(2026-11-23 修正):此处原本固定写「采购**合同管理系统**软件产品及实施服务」,
|
|
98
|
+
* 而报价单的真实标的是「协同办公系统(e-cology)」这类——**背景说明写错产品**会进正式合同字段。
|
|
99
|
+
* 现在优先用真实合同标题/标的,拿不到时才用中性表述。
|
|
100
|
+
*/
|
|
101
|
+
function buildBackground(customer, sections, totalAmount, contractTitle = '') {
|
|
96
102
|
const parts = sections.slice(0, 8).map((section) => `${section.name} ${moneyText(section.amount)} 元`);
|
|
97
103
|
const detail = parts.length ? `费用构成:${parts.join('、')}。` : '';
|
|
98
|
-
|
|
104
|
+
// 从合同标题里取「标的」:去掉客户全称前缀与结尾的「(购买)合同」,
|
|
105
|
+
// 否则会写出「采购西安泽达…有限公司协同办公系统…购买合同」这种把合同名当产品的句子。
|
|
106
|
+
const raw = contractTitle.replace(/\.docx$/iu, '').trim();
|
|
107
|
+
const withoutCustomer = raw.includes(customer) ? raw.split(customer).join('').trim() : raw;
|
|
108
|
+
const subject = withoutCustomer.replace(/(?:购买)?合同$/u, '').trim() || '软件产品及实施服务';
|
|
109
|
+
return `${customer}采购${subject},${detail}合同总金额 ${moneyText(totalAmount)} 元。`;
|
|
99
110
|
}
|
|
100
111
|
/**
|
|
101
112
|
* 报价单 → 表单要素(按流程字段表分派)。
|
|
@@ -154,11 +165,25 @@ export function buildQuoteFieldResults(args) {
|
|
|
154
165
|
}
|
|
155
166
|
/** 通用文件名黑名单:这些名字不是「合同名称」,落到系统里无法辨识。 */
|
|
156
167
|
const GENERIC_FILE_STEMS = new Set(['合同', '合同文件', '未命名', 'document', 'new', '模板', 'temp', 'output']);
|
|
168
|
+
/**
|
|
169
|
+
* §5.2 合同名称命名规则(用户明确指定)的**代码兜底**:
|
|
170
|
+
* `{客户全称}协同办公系统(e-cology)软件产品及实施服务购买合同`。
|
|
171
|
+
*
|
|
172
|
+
* 只在**拿不到真实标题**时使用(正常链路模型会把 plan 里的 title 槽填成真实标题,
|
|
173
|
+
* 并通过 `contractTitle` 传进来)。⛔ 2026-11-23 修正:此前这里写死的是
|
|
174
|
+
* `…合同管理系统软件产品及实施服务购买合同`,与实际标的(协同办公系统(e-cology))
|
|
175
|
+
* 不符,导致返回的 `expectedFileName` 教人把名字改错。
|
|
176
|
+
*/
|
|
177
|
+
export function defaultContractTitle(customer) {
|
|
178
|
+
return `${customer || '客户'}协同办公系统(e-cology)软件产品及实施服务购买合同`;
|
|
179
|
+
}
|
|
157
180
|
/**
|
|
158
181
|
* 合同文件名归一:`{合同名称}.docx`。
|
|
159
182
|
*
|
|
160
183
|
* 2026-11-19 实测事故:编排层把回填产物写成 `合同.docx`,`flow.launch` 直接沿用本地文件名,
|
|
161
184
|
* 系统附件列表里只剩一个「合同.docx」,无法辨识客户与类型。
|
|
185
|
+
* ⚠️ 2026-11-23 补充:本函数算出的名字必须**一路传到上传**(`flow.launch.fileName` /
|
|
186
|
+
* `quotescreen.submit.fileName`);只写进字段值是不够的——附件名取自 multipart filename。
|
|
162
187
|
*/
|
|
163
188
|
export function normalizeContractFileName(contractTitle, fallbackCustomer = '') {
|
|
164
189
|
const raw = String(contractTitle ?? '').replace(/\.docx$/iu, '');
|
|
@@ -167,9 +192,7 @@ export function normalizeContractFileName(contractTitle, fallbackCustomer = '')
|
|
|
167
192
|
.replace(/\s+/gu, ' ')
|
|
168
193
|
.trim();
|
|
169
194
|
const isGeneric = !cleaned || GENERIC_FILE_STEMS.has(cleaned.toLowerCase());
|
|
170
|
-
const stem = isGeneric
|
|
171
|
-
? `${fallbackCustomer || '客户'}合同管理系统软件产品及实施服务购买合同`
|
|
172
|
-
: cleaned;
|
|
195
|
+
const stem = isGeneric ? defaultContractTitle(fallbackCustomer) : cleaned;
|
|
173
196
|
return `${stem}.docx`;
|
|
174
197
|
}
|
|
175
198
|
export const contractQuoteRecognizeOperations = [
|
|
@@ -250,12 +273,11 @@ export const contractQuoteRecognizeOperations = [
|
|
|
250
273
|
if (totalAmount <= 0) {
|
|
251
274
|
throw contractValidationError('total_amount_required', `totalAmount 必须是大于 0 的纯数值(报价单最终优惠报价),收到「${amountCheck.raw}」`, { raw: amountCheck.raw });
|
|
252
275
|
}
|
|
253
|
-
const contractTitle = str(input.contractTitle)
|
|
254
|
-
|| `${customer}合同管理系统软件产品及实施服务购买合同`;
|
|
276
|
+
const contractTitle = str(input.contractTitle) || defaultContractTitle(customer);
|
|
255
277
|
const fileName = normalizeContractFileName(str(input.contractFileName) || contractTitle, customer);
|
|
256
278
|
// ── 费用分节与背景
|
|
257
279
|
const sections = normalizeSections(input.sections);
|
|
258
|
-
const background = str(input.background) || buildBackground(customer, sections, totalAmount);
|
|
280
|
+
const background = str(input.background) || buildBackground(customer, sections, totalAmount, contractTitle);
|
|
259
281
|
const ourCompanyName = str(input.ourCompany) || DEFAULT_OUR_COMPANY;
|
|
260
282
|
// verified 默认 true:上游必须在 slots.fill 的 validate.ok === true 之后才调用本 operation。
|
|
261
283
|
// 传 false 时全部 origin 置空,宁可「合同原文」列空,也不给出失真出处。
|
|
@@ -174,7 +174,10 @@ export const contractQuoteSubmitOperations = [
|
|
|
174
174
|
verified: input.verified === undefined ? true : input.verified === true,
|
|
175
175
|
};
|
|
176
176
|
const [launched, assembled] = await Promise.all([
|
|
177
|
-
|
|
177
|
+
// ⛔ 必须把规范文件名一起传下去(2026-11-23 修复):E10 附件名恒等于上传时的 multipart 文件名,
|
|
178
|
+
// 而它原先取自本地 basename——模型把产物写成 `合同.docx`,系统附件列表里就是「合同.docx」,
|
|
179
|
+
// 与表单里的合同名称字段、以及返回的 expectedFileName 都对不上。
|
|
180
|
+
callOperation('contract.flow.launch', { flow, path: contractPath, fileName }, context),
|
|
178
181
|
callOperation('contract.quotescreen.recognize', recognizeInput, context),
|
|
179
182
|
]);
|
|
180
183
|
steps.push('flow.launch+quotescreen.recognize(parallel)');
|
|
@@ -7,6 +7,24 @@ import { ensurePrewarmed } from '../prewarm.js';
|
|
|
7
7
|
const MAX_FILE_BYTES = 200 * 1024 * 1024;
|
|
8
8
|
const DEFAULT_UPLOAD_TIMEOUT_MS = 120_000;
|
|
9
9
|
const DOC_EXTENSIONS = new Set(['.doc', '.docx']);
|
|
10
|
+
const MAX_UPLOAD_NAME_CHARS = 200;
|
|
11
|
+
/**
|
|
12
|
+
* 解析本次上传真正使用的文件名:优先用调用方给的规范名,否则回落本地 basename。
|
|
13
|
+
*
|
|
14
|
+
* 传入值一律按**纯文件名**处理(剥掉路径分隔符与各平台非法字符);清洗后为空则回落本地名,
|
|
15
|
+
* 保证永远不会上传一个空名字或带路径的名字。
|
|
16
|
+
*/
|
|
17
|
+
export function resolveUploadName(absolutePath, override) {
|
|
18
|
+
const local = basename(absolutePath);
|
|
19
|
+
const raw = typeof override === 'string' ? override.trim() : '';
|
|
20
|
+
if (!raw)
|
|
21
|
+
return local;
|
|
22
|
+
const tail = basename(raw.replace(/\\/gu, '/'));
|
|
23
|
+
const cleaned = tail.replace(/[\\/:*?"<>|\r\n\t]/gu, '').trim();
|
|
24
|
+
if (!cleaned)
|
|
25
|
+
return local;
|
|
26
|
+
return cleaned.length > MAX_UPLOAD_NAME_CHARS ? cleaned.slice(0, MAX_UPLOAD_NAME_CHARS) : cleaned;
|
|
27
|
+
}
|
|
10
28
|
function text(value) {
|
|
11
29
|
if (typeof value === 'string' && value.trim())
|
|
12
30
|
return value;
|
|
@@ -39,7 +57,7 @@ export async function uploadFile(host, options) {
|
|
|
39
57
|
if (info.size > MAX_FILE_BYTES) {
|
|
40
58
|
throw contractValidationError('file_too_large', `文件超过 ${MAX_FILE_BYTES / 1024 / 1024}MB 上限:${options.path}`);
|
|
41
59
|
}
|
|
42
|
-
const name =
|
|
60
|
+
const name = resolveUploadName(absolutePath, options.fileName);
|
|
43
61
|
const buffer = await readFile(absolutePath);
|
|
44
62
|
const md5 = createHash('md5').update(buffer).digest('hex');
|
|
45
63
|
const modified = String(Math.trunc(info.mtimeMs));
|
|
@@ -55,6 +73,8 @@ export async function uploadFile(host, options) {
|
|
|
55
73
|
module: options.module,
|
|
56
74
|
baseUrl: session.baseUrl,
|
|
57
75
|
userId: session.userId ?? '',
|
|
76
|
+
// 文件名进指纹:同一份内容以不同名字上传不能复用(附件名在上传那一刻就固定了)
|
|
77
|
+
name,
|
|
58
78
|
});
|
|
59
79
|
const hit = await lookupUpload(reuseKey);
|
|
60
80
|
if (hit) {
|
|
@@ -26,10 +26,10 @@ function ttlMs() {
|
|
|
26
26
|
export function isCacheEnabled() {
|
|
27
27
|
return ttlMs() > 0;
|
|
28
28
|
}
|
|
29
|
-
/** 指纹键:内容哈希 + module + 环境 +
|
|
29
|
+
/** 指纹键:内容哈希 + module + 环境 + 用户 + **目标文件名**,任一不同都不复用。 */
|
|
30
30
|
export function fingerprintKey(input) {
|
|
31
31
|
return createHash('sha256')
|
|
32
|
-
.update(`${input.sha256}|${input.module}|${input.baseUrl}|${input.userId}`)
|
|
32
|
+
.update(`${input.sha256}|${input.module}|${input.baseUrl}|${input.userId}|${input.name ?? ''}`)
|
|
33
33
|
.digest('hex');
|
|
34
34
|
}
|
|
35
35
|
export function sha256Of(buffer) {
|
|
@@ -2,7 +2,7 @@ import { randomBytes } from 'node:crypto';
|
|
|
2
2
|
import { mkdir, readFile, writeFile } from 'node:fs/promises';
|
|
3
3
|
import { dirname, extname } from 'node:path';
|
|
4
4
|
import { inflateRawSync } from 'node:zlib';
|
|
5
|
-
import {
|
|
5
|
+
import { defaultResultThresholdChars } from '../../../core/output.js';
|
|
6
6
|
import { DATA_SOURCE, MAX_ATTACHMENTS, MAX_ATTACHMENT_BYTES, MAX_REQUEST_ID_LENGTH, PATHS, TEXT_PREVIEW_CHARS, sessionPath, } from '../constants.js';
|
|
7
7
|
import { smartExtractBusinessError, smartExtractPartialError, smartExtractValidationError, SmartExtractCliError, } from '../errors.js';
|
|
8
8
|
import { record } from '../host.js';
|
|
@@ -21,10 +21,10 @@ function shortId(prefix) {
|
|
|
21
21
|
}
|
|
22
22
|
/** stdout 预算里留给附件正文的比例,其余归结构、规则、envelope 与 warnings。 */
|
|
23
23
|
const INLINE_BUDGET_RATIO = 0.95;
|
|
24
|
-
/** envelope 与 warnings
|
|
25
|
-
const
|
|
26
|
-
/**
|
|
27
|
-
const
|
|
24
|
+
/** envelope 与 warnings 的固定余量(字符)。 */
|
|
25
|
+
const ENVELOPE_RESERVE_CHARS = 400;
|
|
26
|
+
/** 单个附件至少能内联这么多字符才内联,否则整份落文件——把正文切一半没有意义。 */
|
|
27
|
+
const MIN_INLINE_CHARS_PER_ATTACHMENT = 800;
|
|
28
28
|
/** fill 的回执提示:只写「拿到这份结果后怎么抽、怎么存」。 */
|
|
29
29
|
function fillNextHint(sessionFile) {
|
|
30
30
|
return '按 fields 抽取,origin 用「附件ID#原文片段」,只填有值的字段。'
|
|
@@ -279,25 +279,25 @@ const fill = {
|
|
|
279
279
|
resultContract: RESULT_CONTRACT,
|
|
280
280
|
next: fillNextHint(sessionFile),
|
|
281
281
|
};
|
|
282
|
-
// 正文内联额度 = stdout
|
|
282
|
+
// 正文内联额度 = stdout 预算(字符)− 结构/规则/固定说明的实际字符。
|
|
283
283
|
// 简单表单额度富余,整份合同一次进上下文;只有真装不下才落文件让模型读一次。
|
|
284
|
-
const
|
|
285
|
-
-
|
|
286
|
-
-
|
|
287
|
-
const
|
|
288
|
-
const inlineAllowed =
|
|
284
|
+
const inlineBudgetChars = Math.floor(defaultResultThresholdChars() * INLINE_BUDGET_RATIO)
|
|
285
|
+
- JSON.stringify({ ...basePayload, attachments: [] }).length
|
|
286
|
+
- ENVELOPE_RESERVE_CHARS;
|
|
287
|
+
const perAttachmentChars = Math.floor(inlineBudgetChars / Math.max(1, downloaded.items.length));
|
|
288
|
+
const inlineAllowed = perAttachmentChars > MIN_INLINE_CHARS_PER_ATTACHMENT;
|
|
289
289
|
const extractedItems = await Promise.all(downloaded.items.map(async (item) => ({
|
|
290
290
|
item,
|
|
291
291
|
...(await extractText(item)),
|
|
292
292
|
})));
|
|
293
|
-
const
|
|
293
|
+
const totalTextChars = extractedItems.reduce((sum, entry) => sum + (entry.text ?? '').length, 0);
|
|
294
294
|
// 全部正文一次装得下就全内联;装不下才按附件均分额度,装不进的那份落文件。
|
|
295
|
-
const allInline =
|
|
295
|
+
const allInline = totalTextChars <= inlineBudgetChars;
|
|
296
296
|
const attachments = await Promise.all(extractedItems.map(async ({ item, text: extractedText, chars }) => {
|
|
297
297
|
const text = extractedText ?? '';
|
|
298
298
|
const oversized = allInline
|
|
299
299
|
? false
|
|
300
|
-
: !inlineAllowed ||
|
|
300
|
+
: !inlineAllowed || text.length > perAttachmentChars;
|
|
301
301
|
let textFile;
|
|
302
302
|
if (oversized && item.path) {
|
|
303
303
|
textFile = `${item.path}.txt`;
|
|
@@ -122,8 +122,8 @@ async function executeAndPrint(ctx, operation, input) {
|
|
|
122
122
|
/**
|
|
123
123
|
* 目录里的 `fields` 只取 `inputSchema.properties` 的键名,供 agent 判断「这个字段存不存在」。
|
|
124
124
|
*
|
|
125
|
-
* ★ 2026-10-28:整份 manifest 实测 65,748 B,超过 stdout 预算(`
|
|
126
|
-
* =
|
|
125
|
+
* ★ 2026-10-28:整份 manifest 实测 65,748 B,超过 stdout 预算(`defaultResultThresholdChars()`
|
|
126
|
+
* = 28,000 字符)后,公共输出层按 `COMPACT_TIERS` 第一档把 `operations` 截到 10 条 —— 26 个 operation 里
|
|
127
127
|
* 排在后面的(`createRequest` 之后,含 `workflow.todoSmartConvert`)在 stdout 上完全不可见,
|
|
128
128
|
* 且没有任何「还有 16 条」的提示。此处改为默认编目形态(约 15 KB,26 条全可见),
|
|
129
129
|
* 完整 inputSchema 用 `--operation` 单取,整份完整 manifest 用 `--full`。
|
|
@@ -5162,7 +5162,6 @@ async function runCreateRequest(args, env, options = {}) {
|
|
|
5162
5162
|
});
|
|
5163
5163
|
}
|
|
5164
5164
|
const [details, valueAmbiguities, preview] = await resolveEntryValues(env, entries, context.layout.form_id);
|
|
5165
|
-
const merged = mergeDetails(context.defaults || [], details);
|
|
5166
5165
|
/**
|
|
5167
5166
|
* 小e 环境(2026-10-16 用户裁定):**字段联动与显示属性联动都不跑**。
|
|
5168
5167
|
*
|
|
@@ -5176,12 +5175,37 @@ async function runCreateRequest(args, env, options = {}) {
|
|
|
5176
5175
|
* 本档既不做必填判定、也不发写请求。非小e 环境行为不变。
|
|
5177
5176
|
*/
|
|
5178
5177
|
const isXiaoE = hasXiaoEEnv(env.ctx.env, env.ctx.getGlobalOptions?.());
|
|
5179
|
-
|
|
5178
|
+
/**
|
|
5179
|
+
* 发起态的 `changeField` 联动分**两轮**跑(2026-11-23 用户裁定),顺序即页面的填写时序:
|
|
5180
|
+
*
|
|
5181
|
+
* ① **默认值轮**:把「表单默认值」当成一次用户填写,触发它们各自的 `changeField` 规则。
|
|
5182
|
+
* 没有这一轮,默认值永远进不了 `changedIds`(`_changedFieldIds` 只遍历入参),
|
|
5183
|
+
* 「姓名有默认值 ⇒ 带出人员编号」这类联动在 CLI 上就永远算不出来。
|
|
5184
|
+
* 条件字段(`conditionFieldList`)由 `runFieldLinkage` 内部从 `allDetails` 补齐,这里默认值
|
|
5185
|
+
* 本身就是触发源,不必再传。
|
|
5186
|
+
* ② **入参轮**:触发源是用户入参,**基线是①之后的加载态**(不是原始默认值)——
|
|
5187
|
+
* 这样"用户传的值恰好等于联动带出的值"会被判成"没变",不会重复发一次请求。
|
|
5188
|
+
*
|
|
5189
|
+
* ⚠️ 合并顺序是这套口径的关键,不能提前把入参并进默认值:
|
|
5190
|
+
* `loadedState`(默认值 + ①结果)→ `withInput`(**入参覆盖加载态**)→ ② → 最终再让②结果覆盖。
|
|
5191
|
+
* 反过来的话,①里"把某字段清空"的联动会盖掉用户显式传的值 —— 真机坑是 `合同号=20260999`
|
|
5192
|
+
* 的规则会重算 7 个字段、把 `相关客户` 置空,而用户这次明明传了 `相关客户=泛微上海`。
|
|
5193
|
+
*/
|
|
5194
|
+
const loadLinkageDetails = isXiaoE
|
|
5195
|
+
? []
|
|
5196
|
+
: await runFieldLinkage(env, linkageContextFromPayload(context), _entriesFromDefaults(context.defaults || []), null, null, false, null);
|
|
5197
|
+
// 加载态 = 表单默认值 + 默认值轮的联动结果(联动结果覆盖默认值)
|
|
5198
|
+
const loadedState = mergeLinkageDetails(context.defaults || [], loadLinkageDetails);
|
|
5199
|
+
// 用户入参叠在加载态之上(用户显式填的值优先于默认值轮的联动结果)
|
|
5200
|
+
const withInput = mergeDetails(loadedState, details);
|
|
5201
|
+
const changeLinkageDetails = isXiaoE
|
|
5180
5202
|
? []
|
|
5181
|
-
: await runFieldLinkage(env, linkageContextFromPayload(context), entries, null,
|
|
5203
|
+
: await runFieldLinkage(env, linkageContextFromPayload(context), entries, null, withInput, false, loadedState);
|
|
5204
|
+
// 两轮结果都要进「联动带出 / 清空」的回显与显示属性求值,少一份就会出现"字段被隐藏但值还在"。
|
|
5205
|
+
const linkageDetails = [...loadLinkageDetails, ...changeLinkageDetails];
|
|
5182
5206
|
// 明细默认值无行号,而判缺失/写载荷都按行号索引 ⇒ 按用户已建行补齐缺口(V12.1.35,
|
|
5183
5207
|
// 详见 fillDetailDefaultsByRow 注释)。放在联动之后合并,联动带出的值仍然优先。
|
|
5184
|
-
const merged2 = fillDetailDefaultsByRow(mergeLinkageDetails(
|
|
5208
|
+
const merged2 = fillDetailDefaultsByRow(mergeLinkageDetails(withInput, changeLinkageDetails), context.defaults || [], userDetailRows(entries));
|
|
5185
5209
|
const attachmentFolderIds = _attachmentFolderIds(context.rawUploadFields || {}, context.attachConfigs || {}, fields, _mainValueMap(merged2));
|
|
5186
5210
|
const folderPayload = Object.keys(attachmentFolderIds).length ? { attachmentFolderIds } : {};
|
|
5187
5211
|
const [hiddenSubforms, rowHidden, rowExtraRequired, rowDisabled] = isXiaoE
|
package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.categoryCounts.js
ADDED
|
@@ -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],
|
package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.prepareQuery.js
CHANGED
|
@@ -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,
|