weaver-work-cli 0.1.50 → 0.1.53
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/README.md +1 -1
- package/dist/chunks/{attachment-content-EJYIOJPH.js → attachment-content-W3TSJC3Y.js} +3 -3
- package/dist/chunks/{chunk-BFKLQLBK.js → chunk-2J3XY4ED.js} +7 -7
- package/dist/chunks/{chunk-K67FODVC.js → chunk-6GCXWKG6.js} +1 -1
- package/dist/chunks/{chunk-WNJUGI2F.js → chunk-76PRVYH4.js} +1 -1
- package/dist/chunks/{chunk-RYFRGTUV.js → chunk-DEHJ7PMA.js} +4 -4
- package/dist/chunks/{chunk-3NCFFHB2.js → chunk-IF33CG4V.js} +1 -1
- package/dist/chunks/{chunk-YB3AJYPY.js → chunk-PE334WL3.js} +4 -4
- package/dist/chunks/{chunk-MCZG6HPM.js → chunk-QQXMHM3J.js} +2 -2
- package/dist/chunks/{chunk-7ECB22G3.js → chunk-U7ROML5E.js} +23 -23
- package/dist/chunks/{chunk-7AYQJSFY.js → chunk-WTLQGS6D.js} +2 -2
- package/dist/chunks/{chunk-6T53BSWZ.js → chunk-XPQN4E5O.js} +50 -19
- package/dist/chunks/{chunk-HARQF5IP.js → chunk-Z4G7LLDD.js} +25 -25
- package/dist/chunks/{conflict-C4UDHCWV.js → conflict-57WDJWL7.js} +2 -2
- package/dist/chunks/{contract-VUC6JOPG.js → contract-LJRAXVZU.js} +8587 -1421
- package/dist/chunks/{create-flow-6OG2LYBD.js → create-flow-3FMMZBCA.js} +6 -6
- package/dist/chunks/{data-QO7QWOIV.js → data-WK5CQXNF.js} +17 -32
- package/dist/chunks/{env-WP57TF2S.js → env-JYZE3BZB.js} +2 -2
- package/dist/chunks/{factory-VUXI7N5C.js → factory-66SCIKW3.js} +1 -1
- package/dist/chunks/{group-chat-UQRGXILK.js → group-chat-MNRYMLNG.js} +3 -3
- package/dist/chunks/{invoice-E7GOITEU.js → invoice-V7ZTITUO.js} +725 -205
- package/dist/chunks/{meeting-4BBLVAWM.js → meeting-IIY4UAJL.js} +10 -10
- package/dist/chunks/{recruit-stage-FKWS5UQF.js → recruit-stage-XCMVEQA2.js} +718 -131
- package/dist/chunks/{registry-V4CHRQDI.js → registry-CJOVECZD.js} +1 -1
- package/dist/chunks/{registry-5CRCN2TV.js → registry-METZ2LWE.js} +10 -10
- package/dist/chunks/{room-recommend-AYR3UG7R.js → room-recommend-YFY7HTOF.js} +4 -4
- package/dist/chunks/{schedule-JZEFIXUS.js → schedule-6I63TERA.js} +4 -4
- package/dist/chunks/smart-extract-FOUYNIG3.js +2882 -0
- package/dist/chunks/{workflow-3ZAF2J5E.js → workflow-YHXFIU63.js} +1 -1
- package/dist/index.js +11 -6
- package/dist/shortcuts/contract/manifest.js +251 -0
- package/dist/shortcuts/contract/ooxml/docx-table.js +233 -0
- package/dist/shortcuts/contract/operations/card-action.js +1165 -0
- package/dist/shortcuts/contract/operations/card-ebdf-list.js +571 -0
- package/dist/shortcuts/contract/operations/card-plan.js +327 -0
- package/dist/shortcuts/contract/operations/card-risk-report.js +565 -0
- package/dist/shortcuts/contract/operations/card.js +6 -5
- package/dist/shortcuts/contract/operations/docx-fillfromquote.js +532 -0
- package/dist/shortcuts/contract/operations/docx-verify.js +258 -0
- package/dist/shortcuts/contract/operations/elements-build.js +761 -0
- package/dist/shortcuts/contract/operations/elements-spec.js +216 -0
- package/dist/shortcuts/contract/operations/first-screen.js +588 -0
- package/dist/shortcuts/contract/operations/flow.js +81 -25
- package/dist/shortcuts/contract/operations/ledger.js +438 -0
- package/dist/shortcuts/contract/operations/modeltext.js +132 -0
- package/dist/shortcuts/contract/operations/op-resolver.js +22 -0
- package/dist/shortcuts/contract/operations/performance.js +104 -3
- package/dist/shortcuts/contract/operations/quote.js +131 -25
- package/dist/shortcuts/contract/operations/quotescreen.js +529 -0
- package/dist/shortcuts/contract/operations/registry.js +30 -0
- package/dist/shortcuts/contract/operations/review.js +73 -58
- package/dist/shortcuts/contract/operations/summary-validate.js +293 -0
- package/dist/shortcuts/contract/operations/summary.js +4 -2
- package/dist/shortcuts/contract/operations/triage.js +1100 -0
- package/dist/shortcuts/contract/operations/upload.js +48 -7
- package/dist/shortcuts/contract/prewarm-cache.js +90 -0
- package/dist/shortcuts/contract/prewarm.js +88 -0
- package/dist/shortcuts/contract/upload-cache.js +49 -4
- package/dist/shortcuts/data/index.js +1 -6
- package/dist/shortcuts/data/manifest.js +2 -2
- package/dist/shortcuts/data/operations/index.js +1 -1
- package/dist/shortcuts/data/operations/query.js +23 -46
- package/dist/shortcuts/index.js +5 -0
- package/dist/shortcuts/invoice/index.js +0 -12
- package/dist/shortcuts/invoice/manifest.js +200 -49
- package/dist/shortcuts/invoice/operations/registry.js +4 -2
- package/dist/shortcuts/invoice/operations/reim-relation.js +438 -0
- package/dist/shortcuts/invoice/operations/shared.js +3 -19
- package/dist/shortcuts/invoice/operations/upload-and-validate.js +109 -73
- package/dist/shortcuts/recruit-stage/operations/interview-arrange.js +4 -2
- package/dist/shortcuts/recruit-stage/operations/jd-create.js +6 -2
- package/dist/shortcuts/recruit-stage/operations/list.js +217 -1
- package/dist/shortcuts/recruit-stage/operations/resume-import.js +144 -158
- package/dist/shortcuts/recruit-stage/operations/search.js +348 -0
- package/dist/shortcuts/recruit-stage/shared.js +5 -0
- package/dist/shortcuts/recruit-stage/tag-lookup.js +136 -0
- package/dist/shortcuts/smart-extract/constants.js +79 -0
- package/dist/shortcuts/smart-extract/continuation.js +71 -0
- package/dist/shortcuts/smart-extract/errors.js +68 -0
- package/dist/shortcuts/smart-extract/host.js +191 -0
- package/dist/shortcuts/smart-extract/index.js +105 -0
- package/dist/shortcuts/smart-extract/ledger.js +70 -0
- package/dist/shortcuts/smart-extract/manifest.js +35 -0
- package/dist/shortcuts/smart-extract/operations/attachment.js +212 -0
- package/dist/shortcuts/smart-extract/operations/batch.js +67 -0
- package/dist/shortcuts/smart-extract/operations/config.js +118 -0
- package/dist/shortcuts/smart-extract/operations/fill.js +492 -0
- package/dist/shortcuts/smart-extract/operations/preview.js +174 -0
- package/dist/shortcuts/smart-extract/operations/registry.js +34 -0
- package/dist/shortcuts/smart-extract/operations/save.js +355 -0
- package/dist/shortcuts/smart-extract/operations/shared.js +191 -0
- package/dist/shortcuts/smart-extract/operations/structure.js +401 -0
- package/dist/shortcuts/smart-extract/operations/target.js +167 -0
- package/dist/shortcuts/smart-extract/operations/types.js +22 -0
- package/dist/shortcuts/smart-extract/operations/validate.js +454 -0
- package/dist/shortcuts/workflow/operations/form.js +68 -33
- package/dist/shortcuts/workflow/operations/read.js +19 -1
- package/docs/SKILL.md +1 -1
- package/docs/_catalog.md +3 -0
- package/docs/agent-invoice.md +5 -7
- package/docs/data.md +5 -1
- package/docs/fna.md +14 -1
- package/docs/invoice.md +7 -5
- package/docs/smart-extract.md +156 -0
- package/package.json +1 -1
- package/skill-template/business-info.json +16 -1
- package/skill-template/domains/qiyecheng.md +2 -0
- package/skill-template/domains/smart-extract.md +16 -0
- package/skill-template/domains/yepiaotong.md +2 -2
- package/skills/weaver-e10-data/references/scene-and-misc.md +4 -3
- package/skills/weaver-e10-jinchengda/SKILL.md +223 -35
- package/skills/weaver-e10-jinchengda/references/contract-action-card.md +47 -481
- package/skills/weaver-e10-jinchengda/references/contract-action-engine.md +11 -11
- package/skills/weaver-e10-jinchengda/references/contract-agent-entry.md +3 -3
- package/skills/weaver-e10-jinchengda/references/contract-ai-assistant.md +1 -1
- package/skills/weaver-e10-jinchengda/references/contract-ai-review.md +32 -16
- package/skills/weaver-e10-jinchengda/references/contract-card-render-internals.md +478 -0
- package/skills/weaver-e10-jinchengda/references/contract-command-index.md +4 -4
- package/skills/weaver-e10-jinchengda/references/contract-disabled-capabilities.md +2 -2
- package/skills/weaver-e10-jinchengda/references/contract-doc-triage.md +39 -61
- package/skills/weaver-e10-jinchengda/references/contract-element-save-record.md +18 -13
- package/skills/weaver-e10-jinchengda/references/contract-execution-rules.md +2 -2
- package/skills/weaver-e10-jinchengda/references/contract-field-extract-new-customer.md +21 -6
- package/skills/weaver-e10-jinchengda/references/contract-field-extract-other-flows.md +6 -4
- package/skills/weaver-e10-jinchengda/references/contract-flow-launch.md +3 -3
- package/skills/weaver-e10-jinchengda/references/contract-ledger-catalog.md +263 -0
- package/skills/weaver-e10-jinchengda/references/contract-ledger-query-playbook.md +525 -0
- package/skills/weaver-e10-jinchengda/references/contract-ledger-rules.md +36 -0
- package/skills/weaver-e10-jinchengda/references/contract-modeltext-library.md +128 -0
- package/skills/weaver-e10-jinchengda/references/contract-multi-file.md +87 -0
- package/skills/weaver-e10-jinchengda/references/contract-performance-query.md +80 -54
- package/skills/weaver-e10-jinchengda/references/contract-quote-to-contract.md +110 -14
- package/skills/weaver-e10-jinchengda/references/contract-template-selector.md +19 -21
- package/skills/weaver-e10-jinchengda/references/orchestration.md +12 -12
- package/skills/weaver-e10-jinchengda/references/source-manifest.json +1 -6
- package/skills/weaver-e10-jinchengda/scripts/fill_plan.py +2 -1
- package/skills/weaver-e10-qiyecheng/SKILL.md +37 -0
- package/skills/weaver-e10-qiyecheng/references/ai-check-audit.md +14 -0
- package/skills/weaver-e10-qiyecheng/references/budget.md +14 -0
- package/skills/weaver-e10-qiyecheng/references/catalog.md +25 -0
- package/skills/weaver-e10-qiyecheng/references/expense-center.md +8 -0
- package/skills/weaver-e10-qiyecheng/references/expense-chart.md +9 -0
- package/skills/weaver-e10-qiyecheng/references/invoice-writeoff.md +13 -0
- package/skills/weaver-e10-qiyecheng/references/loan-management.md +14 -0
- package/skills/weaver-e10-qiyecheng/references/self-hosted-mode.md +239 -0
- package/skills/weaver-e10-qiyecheng/references/source-manifest.json +34 -27
- package/skills/weaver-e10-recruit-stage/SKILL.md +62 -4
- package/skills/weaver-e10-recruit-stage/agents/openai.yaml +42 -8
- package/skills/weaver-e10-recruit-stage/references/env-ziyong.md +79 -0
- package/skills/weaver-e10-recruit-stage/references/recruit-arrange-interview.md +11 -3
- package/skills/weaver-e10-recruit-stage/references/recruit-edit-interview-feedback.md +3 -2
- package/skills/weaver-e10-recruit-stage/references/recruit-interview-not-attended.md +153 -0
- package/skills/weaver-e10-recruit-stage/references/recruit-jd-create.md +7 -4
- package/skills/weaver-e10-recruit-stage/references/recruit-match-candidates.md +1 -1
- package/skills/weaver-e10-recruit-stage/references/recruit-my-positions.md +66 -0
- package/skills/weaver-e10-recruit-stage/references/recruit-output-links.md +156 -42
- package/skills/weaver-e10-recruit-stage/references/recruit-resume-import-batch.md +122 -0
- package/skills/weaver-e10-recruit-stage/references/recruit-resume-import.md +36 -8
- package/skills/weaver-e10-recruit-stage/references/recruit-search-by-tag.md +157 -0
- package/skills/weaver-e10-recruit-stage/references/recruit-utterance-glossary.md +35 -0
- package/skills/weaver-e10-smart-extract/SKILL.md +180 -0
- package/skills/weaver-e10-smart-extract/references/api-contract.md +71 -0
- package/skills/weaver-e10-smart-extract/references/result-format.md +102 -0
- package/skills/weaver-e10-smart-extract/references/troubleshooting.md +106 -0
- package/skills/weaver-e10-workflow/references/workflow-create.md +6 -5
- package/skills/weaver-e10-workflow/references/workflow-edit.md +1 -1
- package/skills/weaver-e10-workflow/references/workflow-query.md +1 -1
- package/skills/weaver-e10-workflow/references/workflow-view.md +1 -1
- package/skills/weaver-e10-yepiaotong/SKILL.md +46 -33
- package/skills/weaver-e10-yepiaotong/references/invoice-add.md +2 -0
- package/skills/weaver-e10-yepiaotong/references/invoice-file-upload.md +1 -1
- package/skills/weaver-e10-yepiaotong/references/invoice-import.md +19 -2
- package/skills/weaver-e10-yepiaotong/references/invoice-ocr-preview.md +8 -2
- package/skills/weaver-e10-yepiaotong/references/invoice-reim-relation.md +407 -0
- package/skills/weaver-e10-yepiaotong/references/invoice-reim.md +12 -8
- package/skills/weaver-e10-yepiaotong/references/invoice-upload-and-validate.md +97 -39
- package/skills/weaver-e10-yepiaotong/references/reim-api-reference.md +91 -2
- package/skills/weaver-e10-yepiaotong/references/reim-examples.md +1 -1
- package/skills/weaver-e10-yepiaotong/references/reim-form-fill-rules.md +12 -12
- package/skills/weaver-e10-yepiaotong/references/reim-matching-rules.md +8 -4
- package/skills/weaver-e10-yepiaotong/references/reim-phone-subsidy-rules.md +136 -91
- package/skills/weaver-e10-yepiaotong/references/reim-workflow.md +109 -23
- package/skills/weaver-e10-yepiaotong/references/source-manifest.json +110 -43
- package/dist/shortcuts/invoice/operations/validate-preview.js +0 -40
- package/skills/weaver-e10-jinchengda/scripts/plan_actions.py +0 -279
- package/skills/weaver-e10-jinchengda/scripts/render_action_card.py +0 -450
- package/skills/weaver-e10-jinchengda/scripts/render_ebdf_list_card.py +0 -265
- package/skills/weaver-e10-jinchengda/scripts/render_risk_report.py +0 -358
- package/skills/weaver-e10-jinchengda/scripts/validate_action_card.py +0 -588
- package/skills/weaver-e10-jinchengda/scripts/verify_docx_placeholders.py +0 -118
- package/skills/weaver-e10-yepiaotong/references/invoice-validation-preview.md +0 -40
|
@@ -3,6 +3,7 @@ import { flowPageUrl } from './page.js';
|
|
|
3
3
|
import { loadFormContext, inspectUploadField, resolveUploadFieldId } from './form-info.js';
|
|
4
4
|
import { requireNonEmptyString } from './shared.js';
|
|
5
5
|
import { assertContractDocument, uploadFile } from './upload.js';
|
|
6
|
+
import { lookupFileModule } from '../upload-cache.js';
|
|
6
7
|
/**
|
|
7
8
|
* 四个合同流程的固定 workflowId / fieldId。
|
|
8
9
|
* 这些是业务常量(不是环境 ID),但流程页面里的其他 ID 仍需运行时解析。
|
|
@@ -40,6 +41,12 @@ function requestIdOf(value) {
|
|
|
40
41
|
const text = String(candidate).trim();
|
|
41
42
|
return text ? text : undefined;
|
|
42
43
|
}
|
|
44
|
+
function optionalText(value) {
|
|
45
|
+
if (value === undefined || value === null)
|
|
46
|
+
return undefined;
|
|
47
|
+
const text = String(value).trim();
|
|
48
|
+
return text ? text : undefined;
|
|
49
|
+
}
|
|
43
50
|
export const contractFlowOperations = [
|
|
44
51
|
{
|
|
45
52
|
name: 'contract.flow.page',
|
|
@@ -92,34 +99,80 @@ export const contractFlowOperations = [
|
|
|
92
99
|
name: 'contract.flow.launch',
|
|
93
100
|
async execute(input, { host }) {
|
|
94
101
|
const flow = resolveFlow(input.flow);
|
|
95
|
-
|
|
96
|
-
|
|
102
|
+
// 入参二选一(2026-11-12 用户定稿):
|
|
103
|
+
// - path:本地上传(最常用)
|
|
104
|
+
// - fileId:复用会话里已有的文件;若它当初不是 workflow 上传的,表单附件挂不住,需要 path 重新上传
|
|
105
|
+
const rawPath = optionalText(input.path);
|
|
106
|
+
const presetFileId = optionalText(input.fileId);
|
|
107
|
+
if (!rawPath && !presetFileId) {
|
|
108
|
+
throw contractValidationError('file_required', '必须提供 path(本地上传)或 fileId(复用会话已有文件)之一');
|
|
109
|
+
}
|
|
110
|
+
if (rawPath)
|
|
111
|
+
assertContractDocument(rawPath);
|
|
97
112
|
// 先解析上传字段(O-3c):宁可多三次只读请求,也不把合同挂到一个可能失效的 fieldId 上。
|
|
98
113
|
const formContext = await loadFormContext(host, flow.workflowId);
|
|
99
114
|
const uploadField = resolveUploadFieldId(formContext.layout, flow.fieldId, flow.label);
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
path: '/api/workflow/core/flowPage/loadBaseParam',
|
|
103
|
-
query: { isCreate: 1, workflowId: flow.workflowId },
|
|
104
|
-
body: { workflowId: flow.workflowId, isCreate: 1, isMobile: 0 },
|
|
105
|
-
});
|
|
106
|
-
const requestId = requestIdOf(baseParam);
|
|
107
|
-
if (!requestId) {
|
|
108
|
-
throw contractValidationError('request_id_missing', 'loadBaseParam 未返回 requestInfo.requestId,已停止上传,避免文件挂到错误流程', { workflowId: flow.workflowId });
|
|
109
|
-
}
|
|
110
|
-
const uploaded = await uploadFile(host, {
|
|
111
|
-
path,
|
|
112
|
-
module: 'workflow',
|
|
113
|
-
extraFields: {
|
|
114
|
-
authModule: 'workflow',
|
|
115
|
-
source: 'form',
|
|
116
|
-
fieldId: uploadField.fieldId,
|
|
117
|
-
sourceRefId: requestId,
|
|
118
|
-
refId: requestId,
|
|
119
|
-
folderId: '300',
|
|
120
|
-
},
|
|
121
|
-
});
|
|
115
|
+
// 判断已有 fileId 能否直接复用:只有确认它本就是 workflow 上传的才行。
|
|
116
|
+
// 未知(缓存过期 / 换环境 / 别处传的)一律按"不是 workflow"处理,重新上传。
|
|
122
117
|
const session = await host.getSession();
|
|
118
|
+
let presetModule = null;
|
|
119
|
+
if (presetFileId) {
|
|
120
|
+
presetModule = await lookupFileModule({
|
|
121
|
+
fileId: presetFileId,
|
|
122
|
+
baseUrl: session.baseUrl,
|
|
123
|
+
userId: session.userId ?? '',
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
const canReuse = presetFileId !== undefined && presetModule === 'workflow';
|
|
127
|
+
let uploaded;
|
|
128
|
+
let fileSource;
|
|
129
|
+
let reuploadReason;
|
|
130
|
+
if (canReuse) {
|
|
131
|
+
uploaded = {
|
|
132
|
+
fileId: presetFileId,
|
|
133
|
+
name: '',
|
|
134
|
+
size: 0,
|
|
135
|
+
md5: '',
|
|
136
|
+
module: 'workflow',
|
|
137
|
+
reused: true,
|
|
138
|
+
prewarmed: true,
|
|
139
|
+
};
|
|
140
|
+
fileSource = 'reused';
|
|
141
|
+
}
|
|
142
|
+
else if (rawPath) {
|
|
143
|
+
// 需要真正上传:先拿 requestId,再把文件挂到流程表单字段上。
|
|
144
|
+
const baseParam = await host.contractRequest({
|
|
145
|
+
method: 'POST',
|
|
146
|
+
path: '/api/workflow/core/flowPage/loadBaseParam',
|
|
147
|
+
query: { isCreate: 1, workflowId: flow.workflowId },
|
|
148
|
+
body: { workflowId: flow.workflowId, isCreate: 1, isMobile: 0 },
|
|
149
|
+
});
|
|
150
|
+
const requestId = requestIdOf(baseParam);
|
|
151
|
+
if (!requestId) {
|
|
152
|
+
throw contractValidationError('request_id_missing', 'loadBaseParam 未返回 requestInfo.requestId,已停止上传,避免文件挂到错误流程', { workflowId: flow.workflowId });
|
|
153
|
+
}
|
|
154
|
+
uploaded = await uploadFile(host, {
|
|
155
|
+
path: rawPath,
|
|
156
|
+
module: 'workflow',
|
|
157
|
+
extraFields: {
|
|
158
|
+
authModule: 'workflow',
|
|
159
|
+
source: 'form',
|
|
160
|
+
fieldId: uploadField.fieldId,
|
|
161
|
+
sourceRefId: requestId,
|
|
162
|
+
refId: requestId,
|
|
163
|
+
folderId: '300',
|
|
164
|
+
},
|
|
165
|
+
});
|
|
166
|
+
fileSource = presetFileId ? 'reuploaded' : 'uploaded';
|
|
167
|
+
if (presetFileId) {
|
|
168
|
+
reuploadReason = presetModule
|
|
169
|
+
? `已有文件的 module 是 ${presetModule},表单附件必须用 workflow 上传的文件,已重新上传`
|
|
170
|
+
: '已有文件的 module 未知,无法确认能挂到表单附件字段,已重新上传';
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
else {
|
|
174
|
+
throw contractValidationError('reupload_required', `fileId ${presetFileId} 不是 workflow 上传的文件(或无法确认),表单附件挂不住;请同时提供 path 以便重新上传`, { fileId: presetFileId, module: presetModule });
|
|
175
|
+
}
|
|
123
176
|
return {
|
|
124
177
|
status: 'COMPLETE',
|
|
125
178
|
data: {
|
|
@@ -129,8 +182,11 @@ export const contractFlowOperations = [
|
|
|
129
182
|
fieldId: uploadField.fieldId,
|
|
130
183
|
fieldIdPreset: flow.fieldId,
|
|
131
184
|
fieldIdSource: uploadField.state,
|
|
132
|
-
requestId,
|
|
133
185
|
file: uploaded,
|
|
186
|
+
fileSource,
|
|
187
|
+
presetFileId,
|
|
188
|
+
presetFileModule: presetModule,
|
|
189
|
+
reuploadReason,
|
|
134
190
|
url: flowPageUrl(session.baseUrl, flow.workflowId, uploaded.fileId),
|
|
135
191
|
page: { width: 1000 },
|
|
136
192
|
},
|
|
@@ -0,0 +1,438 @@
|
|
|
1
|
+
import { existsSync, readFileSync, readdirSync } from 'node:fs';
|
|
2
|
+
import { homedir } from 'node:os';
|
|
3
|
+
import { basename, join } from 'node:path';
|
|
4
|
+
import { contractValidationError } from '../errors.js';
|
|
5
|
+
/**
|
|
6
|
+
* 台账数据处理的本地 operation(2026-11-13 从 scripts/ledger_aggregate.py 与
|
|
7
|
+
* scripts/ledger_guard.py 迁移,遵守「能力下沉 CLI」规范)。
|
|
8
|
+
*
|
|
9
|
+
* 为什么必须做成 operation 而不是技能包里的 Python 脚本:
|
|
10
|
+
* 1) 技能包只应保留「必须依赖 python-docx / PyPDF2 等 Node 无等价库」的脚本,
|
|
11
|
+
* 纯 JSON 读取、分组求和、阈值判定这类逻辑 Node 原生即可完成;
|
|
12
|
+
* 2) 脚本散落在 skills/scripts 下会出现两套入口、两套参数、两份文档,
|
|
13
|
+
* 文档与实现容易漂移(本次事故即为脚本先上线、SKILL.md 白名单未登记);
|
|
14
|
+
* 3) operation 自带 manifest 契约(参数校验、风险标注、schema 可查),
|
|
15
|
+
* 跨平台行为一致,且不需要用户额外准备 Python 运行时。
|
|
16
|
+
*
|
|
17
|
+
* 两者都是纯本地能力:不访问任何业务接口、不读取凭证。
|
|
18
|
+
*/
|
|
19
|
+
// ---------------------------------------------------------------- 公共工具
|
|
20
|
+
/** Python 的 `json.loads` 前会去掉 BOM,这里同样处理。 */
|
|
21
|
+
function readJsonFile(path) {
|
|
22
|
+
const raw = readFileSync(path, 'utf8').replace(/^\uFEFF/u, '');
|
|
23
|
+
return JSON.parse(raw);
|
|
24
|
+
}
|
|
25
|
+
function isRecord(value) {
|
|
26
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
27
|
+
}
|
|
28
|
+
/** 人员字段是 JSON 字符串/数组时解析成「姓名(id)」,其余按文本处理。 */
|
|
29
|
+
function cellText(value) {
|
|
30
|
+
if (value === null || value === undefined)
|
|
31
|
+
return '';
|
|
32
|
+
let raw;
|
|
33
|
+
if (typeof value === 'object') {
|
|
34
|
+
raw = JSON.stringify(value);
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
raw = String(value);
|
|
38
|
+
}
|
|
39
|
+
const trimmed = raw.trim();
|
|
40
|
+
if (trimmed.startsWith('[') || trimmed.startsWith('{')) {
|
|
41
|
+
const names = [...trimmed.matchAll(/"name"\s*:\s*"([^"]+)"/gu)].map((m) => m[1]);
|
|
42
|
+
const ids = [...trimmed.matchAll(/"id"\s*:\s*"?(\d+)"?/gu)].map((m) => m[1]);
|
|
43
|
+
if (names.length > 0) {
|
|
44
|
+
if (ids.length === names.length) {
|
|
45
|
+
return names.map((name, index) => `${name}(${ids[index]})`).join('、');
|
|
46
|
+
}
|
|
47
|
+
return names.join('、');
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return raw;
|
|
51
|
+
}
|
|
52
|
+
/** 金额是「1,234.00」这类展示串,汇总前必须去千分位。 */
|
|
53
|
+
function toNumber(value) {
|
|
54
|
+
const text = cellText(value).replace(/,/gu, '').replace(/\s/gu, '');
|
|
55
|
+
if (!text || text === '-' || text === '—')
|
|
56
|
+
return 0;
|
|
57
|
+
const num = Number(text);
|
|
58
|
+
return Number.isFinite(num) ? num : 0;
|
|
59
|
+
}
|
|
60
|
+
function matchFilters(row, conditions) {
|
|
61
|
+
for (const cond of conditions) {
|
|
62
|
+
const at = cond.indexOf('=');
|
|
63
|
+
if (at <= 0)
|
|
64
|
+
continue;
|
|
65
|
+
const key = cond.slice(0, at).trim();
|
|
66
|
+
const want = cond.slice(at + 1);
|
|
67
|
+
if (!cellText(row[key]).includes(want))
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
70
|
+
return true;
|
|
71
|
+
}
|
|
72
|
+
function refsDirDefault() {
|
|
73
|
+
return join(homedir(), '.weaver-work-cli', 'state', 'refs');
|
|
74
|
+
}
|
|
75
|
+
/** refId 可能带后缀,先精确命中,再递归按前缀找。 */
|
|
76
|
+
function findRefFile(refsDir, refId) {
|
|
77
|
+
const direct = join(refsDir, `${refId}.json`);
|
|
78
|
+
if (existsSync(direct))
|
|
79
|
+
return direct;
|
|
80
|
+
const stack = [refsDir];
|
|
81
|
+
while (stack.length > 0) {
|
|
82
|
+
const dir = stack.pop();
|
|
83
|
+
let entries;
|
|
84
|
+
try {
|
|
85
|
+
entries = readdirSync(dir, { withFileTypes: true });
|
|
86
|
+
}
|
|
87
|
+
catch {
|
|
88
|
+
continue;
|
|
89
|
+
}
|
|
90
|
+
for (const entry of entries) {
|
|
91
|
+
const path = join(dir, entry.name);
|
|
92
|
+
if (entry.isDirectory()) {
|
|
93
|
+
stack.push(path);
|
|
94
|
+
}
|
|
95
|
+
else if (entry.name.startsWith(refId) && entry.name.endsWith('.json')) {
|
|
96
|
+
return path;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
return null;
|
|
101
|
+
}
|
|
102
|
+
/** refs 落盘结构是 { envelope: { data: { rows, pagination } } };顺序向下钻取。 */
|
|
103
|
+
function loadRows(path) {
|
|
104
|
+
const doc = readJsonFile(path);
|
|
105
|
+
let node = doc;
|
|
106
|
+
if (isRecord(node) && isRecord(node.envelope))
|
|
107
|
+
node = node.envelope;
|
|
108
|
+
if (isRecord(node) && isRecord(node.data))
|
|
109
|
+
node = node.data;
|
|
110
|
+
if (isRecord(node) && isRecord(node.result))
|
|
111
|
+
node = node.result;
|
|
112
|
+
const rawRows = isRecord(node)
|
|
113
|
+
? (Array.isArray(node.rows) ? node.rows : Array.isArray(node.displayData) ? node.displayData : [])
|
|
114
|
+
: [];
|
|
115
|
+
const rows = rawRows.filter(isRecord);
|
|
116
|
+
const pagination = isRecord(node) && isRecord(node.pagination) ? node.pagination : {};
|
|
117
|
+
return { rows, pagination };
|
|
118
|
+
}
|
|
119
|
+
function groupThousands(value) {
|
|
120
|
+
return value.toLocaleString('en-US', { maximumFractionDigits: 2, minimumFractionDigits: 2 });
|
|
121
|
+
}
|
|
122
|
+
// ---------------------------------------------------------------- 量级守卫常量
|
|
123
|
+
/** 单次取数硬上限:pageSize 最大 200 × maxPages 默认 10。 */
|
|
124
|
+
const PAGE_SIZE_MAX = 200;
|
|
125
|
+
const MAX_PAGES_DEFAULT = 10;
|
|
126
|
+
const SINGLE_CALL_CAP = PAGE_SIZE_MAX * MAX_PAGES_DEFAULT;
|
|
127
|
+
const WINDOW_LIMIT = 20_000;
|
|
128
|
+
const HARD_LIMIT = 100_000;
|
|
129
|
+
const CONTEXT_SAFE_KB = 50;
|
|
130
|
+
/** 台账 → 卡片信息(拒绝后兜底打开系统组件用,2026-11-13 实测口径)。 */
|
|
131
|
+
const MENU_CARDS = {
|
|
132
|
+
直销合同: { viewKey: 'ecology', variant: 'ledger', pageId: '846297265322576591' },
|
|
133
|
+
直销业绩: { viewKey: 'directPerf', variant: 'ledger', pageId: '846297265322576586' },
|
|
134
|
+
合同收款: { viewKey: null, variant: 'ebdf-list', pageId: '846297265322576589' },
|
|
135
|
+
项目验收: { viewKey: null, variant: 'ebdf-list', pageId: '846297265322576590' },
|
|
136
|
+
渠道订单: { viewKey: 'etOrder', variant: 'ledger', pageId: '881211097502359554' },
|
|
137
|
+
'渠道订单-商务': { viewKey: 'agree', variant: 'ledger', pageId: '1000604870446374992' },
|
|
138
|
+
};
|
|
139
|
+
const CONDITION_TYPES = ['none', 'time', 'person', 'customer', 'contract'];
|
|
140
|
+
function buildFallbackCard(menu, comParams, origin) {
|
|
141
|
+
const info = MENU_CARDS[menu];
|
|
142
|
+
if (!info) {
|
|
143
|
+
return {
|
|
144
|
+
available: false,
|
|
145
|
+
reason: `未知台账「${menu}」,请从六台账中选择:${Object.keys(MENU_CARDS).join('、')}`,
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
const args = { menu, title: `${menu} 台账` };
|
|
149
|
+
if (origin)
|
|
150
|
+
args.origin = origin;
|
|
151
|
+
let note = '打开后请在页面自行选择筛选条件查看数据。';
|
|
152
|
+
if (comParams) {
|
|
153
|
+
if (info.variant === 'ledger') {
|
|
154
|
+
args.comParamsJson = JSON.stringify(comParams);
|
|
155
|
+
note = '已预置筛选条件,打开即可看到对应范围;也可在页面继续调整。';
|
|
156
|
+
}
|
|
157
|
+
else {
|
|
158
|
+
note =
|
|
159
|
+
'该台账为 ebdf 列表卡,预置条件必须用 field_<字段id>(传语义键会报 com_param_key_invalid),' +
|
|
160
|
+
'兜底场景不预置条件,请在页面自行筛选。';
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
return {
|
|
164
|
+
available: true,
|
|
165
|
+
variant: info.variant,
|
|
166
|
+
viewKey: info.viewKey,
|
|
167
|
+
pageId: info.pageId,
|
|
168
|
+
command: 'weaver-work-cli --json contract run contract.card.ebdf-list --input <args.json>',
|
|
169
|
+
args,
|
|
170
|
+
note,
|
|
171
|
+
usage: '把 args 写入 UTF-8 JSON 文件后执行上面 command,输出即 <browsertool> 卡片',
|
|
172
|
+
...(origin ? {} : { warning: '未取到当前环境域名,请补 origin 后再渲染卡片' }),
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
// ---------------------------------------------------------------- operations
|
|
176
|
+
export const contractLedgerOperations = [
|
|
177
|
+
{
|
|
178
|
+
name: 'contract.ledger.aggregate',
|
|
179
|
+
async execute(input) {
|
|
180
|
+
const single = typeof input.ref === 'string' && input.ref ? input.ref : null;
|
|
181
|
+
const many = Array.isArray(input.refs)
|
|
182
|
+
? input.refs.map((item, index) => {
|
|
183
|
+
if (typeof item !== 'string' || !item) {
|
|
184
|
+
throw contractValidationError('refs_invalid', `refs[${index}] 必须是非空字符串`);
|
|
185
|
+
}
|
|
186
|
+
return item;
|
|
187
|
+
})
|
|
188
|
+
: [];
|
|
189
|
+
const file = typeof input.file === 'string' && input.file ? input.file : null;
|
|
190
|
+
const refsDir = typeof input.refsDir === 'string' && input.refsDir ? input.refsDir : refsDirDefault();
|
|
191
|
+
const by = Array.isArray(input.by) ? input.by.map(String) : [];
|
|
192
|
+
const sum = Array.isArray(input.sum) ? input.sum.map(String) : [];
|
|
193
|
+
const where = Array.isArray(input.where) ? input.where.map(String) : [];
|
|
194
|
+
const dedupe = input.dedupe === true;
|
|
195
|
+
const detail = input.detail === true;
|
|
196
|
+
const limitRaw = input.limit;
|
|
197
|
+
const limit = typeof limitRaw === 'number' && Number.isFinite(limitRaw) && limitRaw > 0 ? Math.floor(limitRaw) : 20;
|
|
198
|
+
const sources = [];
|
|
199
|
+
if (file) {
|
|
200
|
+
if (!existsSync(file)) {
|
|
201
|
+
throw contractValidationError('file_not_found', `找不到结果文件:${file}`);
|
|
202
|
+
}
|
|
203
|
+
sources.push(file);
|
|
204
|
+
}
|
|
205
|
+
for (const refId of [...(single ? [single] : []), ...many]) {
|
|
206
|
+
const found = findRefFile(refsDir, refId);
|
|
207
|
+
if (!found) {
|
|
208
|
+
throw contractValidationError('ref_not_found', `找不到 refId 对应的结果文件:${refId}`);
|
|
209
|
+
}
|
|
210
|
+
sources.push(found);
|
|
211
|
+
}
|
|
212
|
+
if (sources.length === 0) {
|
|
213
|
+
throw contractValidationError('source_required', '请用 ref、refs 或 file 指定结果来源');
|
|
214
|
+
}
|
|
215
|
+
const allRows = [];
|
|
216
|
+
const seen = new Set();
|
|
217
|
+
const sourceInfo = [];
|
|
218
|
+
let totalSum = 0;
|
|
219
|
+
let totalUnknown = false;
|
|
220
|
+
let truncatedAny = false;
|
|
221
|
+
for (const path of sources) {
|
|
222
|
+
const { rows, pagination } = loadRows(path);
|
|
223
|
+
sourceInfo.push({
|
|
224
|
+
file: basename(path),
|
|
225
|
+
rows: rows.length,
|
|
226
|
+
total: pagination.total ?? null,
|
|
227
|
+
truncated: pagination.truncated === true,
|
|
228
|
+
});
|
|
229
|
+
if (pagination.total === null || pagination.total === undefined) {
|
|
230
|
+
totalUnknown = true;
|
|
231
|
+
}
|
|
232
|
+
else {
|
|
233
|
+
totalSum += Number(pagination.total) || 0;
|
|
234
|
+
}
|
|
235
|
+
if (pagination.truncated === true)
|
|
236
|
+
truncatedAny = true;
|
|
237
|
+
for (const row of rows) {
|
|
238
|
+
if (dedupe) {
|
|
239
|
+
let key = null;
|
|
240
|
+
for (const field of ['id', 'form_data_id', 'rowKey', 'ebrecord_rowkey']) {
|
|
241
|
+
const text = cellText(row[field]);
|
|
242
|
+
if (text) {
|
|
243
|
+
key = `${field}|${text}`;
|
|
244
|
+
break;
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
if (key) {
|
|
248
|
+
if (seen.has(key))
|
|
249
|
+
continue;
|
|
250
|
+
seen.add(key);
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
allRows.push(row);
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
const rows = allRows.filter((row) => matchFilters(row, where));
|
|
257
|
+
const warnings = [];
|
|
258
|
+
if (truncatedAny) {
|
|
259
|
+
warnings.push('存在 truncated=true 的来源,当前不是全量;请缩小范围重查,或补齐分页后合并。');
|
|
260
|
+
}
|
|
261
|
+
if (!totalUnknown && !dedupe && totalSum !== allRows.length) {
|
|
262
|
+
warnings.push(`台账 total 合计 ${totalSum} 与载入行数 ${allRows.length} 不一致,结果可能不完整。`);
|
|
263
|
+
}
|
|
264
|
+
const data = {
|
|
265
|
+
sources: sourceInfo,
|
|
266
|
+
sourceCount: sources.length,
|
|
267
|
+
dedupe,
|
|
268
|
+
mergedRows: allRows.length,
|
|
269
|
+
totalSum: totalUnknown ? null : totalSum,
|
|
270
|
+
totalUnknown,
|
|
271
|
+
truncated: truncatedAny,
|
|
272
|
+
filteredRows: rows.length,
|
|
273
|
+
warnings,
|
|
274
|
+
};
|
|
275
|
+
if (rows.length > 0) {
|
|
276
|
+
if (by.length > 0) {
|
|
277
|
+
const groups = new Map();
|
|
278
|
+
for (const row of rows) {
|
|
279
|
+
const key = by.map((field) => cellText(row[field]) || '(空)').join(' / ');
|
|
280
|
+
const bucket = groups.get(key);
|
|
281
|
+
if (bucket)
|
|
282
|
+
bucket.push(row);
|
|
283
|
+
else
|
|
284
|
+
groups.set(key, [row]);
|
|
285
|
+
}
|
|
286
|
+
const groupList = [...groups.entries()]
|
|
287
|
+
.sort((a, b) => b[1].length - a[1].length)
|
|
288
|
+
.map(([key, items]) => {
|
|
289
|
+
const sums = {};
|
|
290
|
+
for (const field of sum) {
|
|
291
|
+
sums[field] = Number(items.reduce((acc, item) => acc + toNumber(item[field]), 0).toFixed(2));
|
|
292
|
+
}
|
|
293
|
+
return { key, rows: items.length, sums };
|
|
294
|
+
});
|
|
295
|
+
data.groups = groupList;
|
|
296
|
+
data.groupCount = groupList.length;
|
|
297
|
+
}
|
|
298
|
+
else {
|
|
299
|
+
const sums = {};
|
|
300
|
+
for (const field of sum) {
|
|
301
|
+
sums[field] = Number(rows.reduce((acc, row) => acc + toNumber(row[field]), 0).toFixed(2));
|
|
302
|
+
}
|
|
303
|
+
data.totals = { rows: rows.length, sums };
|
|
304
|
+
}
|
|
305
|
+
if (detail) {
|
|
306
|
+
data.detail = rows.slice(0, limit).map((row) => ({
|
|
307
|
+
qdrq: cellText(row.qdrq),
|
|
308
|
+
hth: cellText(row.hth),
|
|
309
|
+
khmc: cellText(row.khmc),
|
|
310
|
+
xsjl: cellText(row.xsjl),
|
|
311
|
+
htzje: cellText(row.htzje),
|
|
312
|
+
}));
|
|
313
|
+
data.detailLimit = limit;
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
return { status: 'COMPLETE', data };
|
|
317
|
+
},
|
|
318
|
+
},
|
|
319
|
+
{
|
|
320
|
+
name: 'contract.ledger.guard',
|
|
321
|
+
async execute(input, { host }) {
|
|
322
|
+
const menu = typeof input.menu === 'string' ? input.menu.trim() : '';
|
|
323
|
+
if (!menu) {
|
|
324
|
+
throw contractValidationError('menu_required', 'menu 必须是台账名称');
|
|
325
|
+
}
|
|
326
|
+
const totalRaw = input.total;
|
|
327
|
+
if (typeof totalRaw !== 'number' || !Number.isFinite(totalRaw) || totalRaw < 0) {
|
|
328
|
+
throw contractValidationError('total_invalid', 'total 必须是探量得到的非负整数');
|
|
329
|
+
}
|
|
330
|
+
const total = Math.floor(totalRaw);
|
|
331
|
+
const condition = typeof input.condition === 'string' ? input.condition : 'none';
|
|
332
|
+
if (!CONDITION_TYPES.includes(condition)) {
|
|
333
|
+
throw contractValidationError('condition_invalid', `condition 只能是 ${CONDITION_TYPES.join(' / ')}`);
|
|
334
|
+
}
|
|
335
|
+
const rowsKbRaw = input.rowsPerRecord;
|
|
336
|
+
const rowsKb = typeof rowsKbRaw === 'number' && Number.isFinite(rowsKbRaw) && rowsKbRaw > 0 ? rowsKbRaw : 3.3;
|
|
337
|
+
let comParams = null;
|
|
338
|
+
let rawParams = typeof input.comParams === 'string' ? input.comParams.trim() : '';
|
|
339
|
+
if (typeof input.comParams === 'object' && input.comParams !== null) {
|
|
340
|
+
comParams = input.comParams;
|
|
341
|
+
}
|
|
342
|
+
if (!rawParams && typeof input.comParamsFile === 'string' && input.comParamsFile) {
|
|
343
|
+
try {
|
|
344
|
+
rawParams = readFileSync(input.comParamsFile, 'utf8').replace(/^\uFEFF/u, '').trim();
|
|
345
|
+
}
|
|
346
|
+
catch {
|
|
347
|
+
// 与脚本一致:读不到只忽略,不阻断判定
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
if (!comParams && rawParams) {
|
|
351
|
+
try {
|
|
352
|
+
const parsed = JSON.parse(rawParams);
|
|
353
|
+
if (isRecord(parsed))
|
|
354
|
+
comParams = parsed;
|
|
355
|
+
}
|
|
356
|
+
catch {
|
|
357
|
+
// 非合法 JSON 时忽略,避免拿错条件生成兜底卡
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
let origin = typeof input.origin === 'string' && input.origin ? input.origin : null;
|
|
361
|
+
if (!origin) {
|
|
362
|
+
try {
|
|
363
|
+
const session = await host.getSession();
|
|
364
|
+
origin = session.baseUrl ?? null;
|
|
365
|
+
}
|
|
366
|
+
catch {
|
|
367
|
+
origin = null;
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
const estMb = Number(((total * rowsKb) / 1024).toFixed(2));
|
|
371
|
+
const capText = groupThousands(SINGLE_CALL_CAP);
|
|
372
|
+
let decision;
|
|
373
|
+
let reason;
|
|
374
|
+
let suggestion;
|
|
375
|
+
let batches = 1;
|
|
376
|
+
if (condition === 'none') {
|
|
377
|
+
decision = 'REFUSE';
|
|
378
|
+
reason =
|
|
379
|
+
`本次查询没有带任何约束条件。${menu} 台账无条件总量达 ${total.toLocaleString('en-US')} 条,` +
|
|
380
|
+
`预计输出约 ${estMb.toFixed(2)} MB,单次调用最多只能取回 ${SINGLE_CALL_CAP.toLocaleString('en-US')} 条,` +
|
|
381
|
+
'必然截断且耗时不可控。';
|
|
382
|
+
suggestion =
|
|
383
|
+
'请至少加一个约束后再查:①时间(如 2026-11);②人员(传人员 ID 做 inC);' +
|
|
384
|
+
'③客户名称;④具体合同号。建议先按月收窄,再把结果给我汇总。';
|
|
385
|
+
batches = null;
|
|
386
|
+
}
|
|
387
|
+
else if (total > HARD_LIMIT) {
|
|
388
|
+
decision = 'REFUSE';
|
|
389
|
+
reason =
|
|
390
|
+
`${menu} 命中 ${total.toLocaleString('en-US')} 条,超过可安全处理上限 ${HARD_LIMIT.toLocaleString('en-US')} 条` +
|
|
391
|
+
`(预计 ${estMb.toFixed(2)} MB)。即使拆窗口也会产生 ${Math.floor(total / SINGLE_CALL_CAP) + 1} 次以上的分页请求` +
|
|
392
|
+
'与超大中间结果,失败风险高、结果不可信。';
|
|
393
|
+
suggestion =
|
|
394
|
+
`请继续收窄到 ${HARD_LIMIT.toLocaleString('en-US')} 条以内:①把时间窗口缩到单月或单周;` +
|
|
395
|
+
'②叠加人员/客户条件;③若确实需要全量,请改为按批分次查询(每次一类条件),由您确认批次范围后再逐批执行。';
|
|
396
|
+
batches = null;
|
|
397
|
+
}
|
|
398
|
+
else if (total > SINGLE_CALL_CAP) {
|
|
399
|
+
decision = 'PROCEED_WITH_WINDOW';
|
|
400
|
+
batches = Math.ceil(total / SINGLE_CALL_CAP);
|
|
401
|
+
reason =
|
|
402
|
+
`${menu} 命中 ${total.toLocaleString('en-US')} 条,超过单次上限 ${capText} 条,` +
|
|
403
|
+
`需要拆成 ${batches} 个窗口分批取数(预计共 ${estMb.toFixed(2)} MB)。`;
|
|
404
|
+
suggestion =
|
|
405
|
+
`建议优先继续收窄(按月/周/人员/客户),把每批压到 ${capText} 条以内再执行;` +
|
|
406
|
+
'若坚持分批,我会逐批取数并用 refs + dedupe 合并后给结论。';
|
|
407
|
+
}
|
|
408
|
+
else {
|
|
409
|
+
decision = 'PROCEED';
|
|
410
|
+
reason = `${menu} 命中 ${total.toLocaleString('en-US')} 条,在单次上限 ${capText} 条以内(预计 ${estMb.toFixed(2)} MB)。`;
|
|
411
|
+
suggestion = '可直接一次取全;返回前会校验 fetched == total 再报总数。';
|
|
412
|
+
}
|
|
413
|
+
const fallbackCard = decision === 'REFUSE' ? buildFallbackCard(menu, comParams, origin) : null;
|
|
414
|
+
return {
|
|
415
|
+
status: 'COMPLETE',
|
|
416
|
+
data: {
|
|
417
|
+
menu,
|
|
418
|
+
total,
|
|
419
|
+
condition,
|
|
420
|
+
decision,
|
|
421
|
+
reason,
|
|
422
|
+
suggestion,
|
|
423
|
+
batches,
|
|
424
|
+
estimatedMB: estMb,
|
|
425
|
+
thresholds: {
|
|
426
|
+
singleCallCap: SINGLE_CALL_CAP,
|
|
427
|
+
windowLimit: WINDOW_LIMIT,
|
|
428
|
+
hardLimit: HARD_LIMIT,
|
|
429
|
+
contextSafeKB: CONTEXT_SAFE_KB,
|
|
430
|
+
},
|
|
431
|
+
mustReportToUser: decision !== 'PROCEED',
|
|
432
|
+
fallbackCard,
|
|
433
|
+
note: '拒绝以 data.decision=REFUSE 表达,不再使用退出码 3(与「登录失效」冲突);本 operation 不访问业务接口。',
|
|
434
|
+
},
|
|
435
|
+
};
|
|
436
|
+
},
|
|
437
|
+
},
|
|
438
|
+
];
|