weaver-work-cli 0.1.62 → 0.1.63
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/{archive-S2VKZWQ3.js → archive-BLDYBZDX.js} +5 -4
- package/dist/chunks/{archive-oa-HEDSIUUY.js → archive-oa-3GJ3TWXR.js} +5 -4
- package/dist/chunks/{asset-HYH4W357.js → asset-AFXJN4CK.js} +5 -4
- package/dist/chunks/{asset-idle-N7REBNGL.js → asset-idle-VUJXWGWJ.js} +5 -4
- package/dist/chunks/{attachment-content-VYYA75FR.js → attachment-content-VMJA7NSQ.js} +3 -3
- package/dist/chunks/{blog-SLMZZICV.js → blog-EREB35VU.js} +5 -4
- package/dist/chunks/{caizhilian-RV43KKBT.js → caizhilian-ATM2JO5S.js} +5 -5
- package/dist/chunks/{calendar-DMVZ4OLY.js → calendar-E26ZIH7S.js} +5 -4
- package/dist/chunks/{chunk-6XSSAUNW.js → chunk-4OB22YKE.js} +48 -12
- package/dist/chunks/{chunk-UBGWIXU3.js → chunk-5CY37VLS.js} +131 -38
- package/dist/chunks/{chunk-EGANE35F.js → chunk-6G2JARDK.js} +1 -1
- package/dist/chunks/{chunk-WIWDVETN.js → chunk-6VCQLZXE.js} +75 -76
- package/dist/chunks/{chunk-E5YD5JWR.js → chunk-BY3WDJO5.js} +1 -1
- package/dist/chunks/{chunk-IW7A2IQY.js → chunk-C4YQJFZV.js} +43 -15
- package/dist/chunks/{chunk-BQYX2UX5.js → chunk-C5PIGPGX.js} +5 -3
- package/dist/chunks/{chunk-UBRWONP4.js → chunk-EOZHSNND.js} +2 -2
- package/dist/chunks/{chunk-UQFPF4EX.js → chunk-G3ZM57PD.js} +2 -2
- package/dist/chunks/{chunk-XT77MP54.js → chunk-GOBNIGWS.js} +410 -24
- package/dist/chunks/{chunk-KY3R42RS.js → chunk-GQK6WLOS.js} +5 -3
- package/dist/chunks/{chunk-BIA2NKUG.js → chunk-HEJPVXD3.js} +5 -5
- package/dist/chunks/{chunk-ILALC2N6.js → chunk-I4C2KR2G.js} +1 -1
- package/dist/chunks/{chunk-YI2YMW5N.js → chunk-IGICM3WJ.js} +2 -2
- package/dist/chunks/chunk-IN6NXQ26.js +680 -0
- package/dist/chunks/{chunk-VBFBMM7G.js → chunk-LOVAIGM2.js} +387 -70
- package/dist/chunks/{chunk-H6YOMI3U.js → chunk-OMAGCLUE.js} +5 -3
- package/dist/chunks/{chunk-VNYOUAWV.js → chunk-QAMIIFP6.js} +11 -11
- package/dist/chunks/{chunk-QBDXJS2W.js → chunk-QZYKZ7MQ.js} +16 -8
- package/dist/chunks/{chunk-V2LASYKO.js → chunk-RR45ELVE.js} +30 -24
- package/dist/chunks/{chunk-NRYDJN4J.js → chunk-RV2JAA5I.js} +89 -8
- package/dist/chunks/{chunk-TEZHIB6T.js → chunk-SDPC7BG2.js} +5 -3
- package/dist/chunks/{chunk-T2KVJFWJ.js → chunk-SHBDXEUE.js} +4 -7
- package/dist/chunks/{chunk-P6TXQK75.js → chunk-THMBDCRA.js} +5 -3
- package/dist/chunks/chunk-TJN4PIYO.js +47 -0
- package/dist/chunks/{chunk-DTCQFTHW.js → chunk-TNFIUZ4H.js} +3 -3
- package/dist/chunks/{chunk-JFAWZX53.js → chunk-UPVAQJKS.js} +282 -131
- package/dist/chunks/{chunk-KXJA42EA.js → chunk-WPBZQVLS.js} +1 -1
- package/dist/chunks/{conflict-GFJRS6I7.js → conflict-AMNTM3FV.js} +2 -2
- package/dist/chunks/{contract-U3ZGNRWB.js → contract-PLO2V2NO.js} +2333 -4426
- package/dist/chunks/{cowork-EX7PKIDK.js → cowork-FZAXE6FO.js} +5 -4
- package/dist/chunks/{create-flow-EJZD434E.js → create-flow-2DAUN7HU.js} +16 -6
- package/dist/chunks/{data-FOODGAMF.js → data-7NXMWET4.js} +3 -3
- package/dist/chunks/{ebuilder-form-I2EOKODG.js → ebuilder-form-DEYHX6M7.js} +4 -4
- package/dist/chunks/{ehr-TE4RFNID.js → ehr-QQH2DYYA.js} +244 -151
- package/dist/chunks/{employee-DR5Y64TI.js → employee-PGMY6NI6.js} +1 -1
- package/dist/chunks/{entry-mode-ZOLSXEGX.js → entry-mode-2JTVEKMP.js} +3 -3
- package/dist/chunks/{env-TID5NFR6.js → env-2JZMXC6I.js} +2 -2
- package/dist/chunks/{esb-7L6MHYLB.js → esb-I5ZFHJUK.js} +8 -8
- package/dist/chunks/{factory-OG7BPMH5.js → factory-XIATYHU6.js} +1 -1
- package/dist/chunks/{fna-6V2ENR3Y.js → fna-3V2TL6B2.js} +5 -4
- package/dist/chunks/{group-chat-5DKPWIHL.js → group-chat-CVYUZCOQ.js} +3 -3
- package/dist/chunks/{host-TJ5VVHM7.js → host-4DP7C7YQ.js} +4 -4
- package/dist/chunks/{host-3DLYA54R.js → host-4KQCAEWA.js} +4 -4
- package/dist/chunks/{host-ONZC6AE7.js → host-4X2F3JPQ.js} +4 -4
- package/dist/chunks/{host-OGBHL75G.js → host-BD7NAM33.js} +4 -4
- package/dist/chunks/{host-VTPAWDZV.js → host-CBONEAZS.js} +4 -4
- package/dist/chunks/{host-GOJHHTPY.js → host-L37QVNIV.js} +4 -4
- package/dist/chunks/{hrm-2N7NFQDZ.js → hrm-OL3IKN7C.js} +6 -6
- package/dist/chunks/{im-XCH47ZBN.js → im-YXQWUF3R.js} +4 -4
- package/dist/chunks/{invoice-5KJ7T774.js → invoice-4WY32PR2.js} +4 -4
- package/dist/chunks/{jiuchuanhui-PL6DRPBM.js → jiuchuanhui-L6SHLONH.js} +5 -4
- package/dist/chunks/{lazy-dispatch-UATEN7H7.js → lazy-dispatch-OYE6QV24.js} +5 -5
- package/dist/chunks/{mail-Q7Z4CQ4D.js → mail-PZV2KNRU.js} +5 -4
- package/dist/chunks/{meeting-5E3BNARL.js → meeting-6SOBCC6N.js} +16 -15
- package/dist/chunks/{minute-doc-NXRE5C77.js → minute-doc-KSJSJNOH.js} +4 -4
- package/dist/chunks/{okr-3O3XNYOK.js → okr-B76FW5M2.js} +5 -4
- package/dist/chunks/{operations-EZWG72FH.js → operations-YOMEGFLV.js} +5 -5
- package/dist/chunks/{performance-Y7CPNSOR.js → performance-4VBKUPFO.js} +5 -4
- package/dist/chunks/{plan-BLGPZF5M.js → plan-HBNZRQTI.js} +5 -4
- package/dist/chunks/{project-6MZMLJMP.js → project-IV6FWK74.js} +5 -4
- package/dist/chunks/{reception-F2VT2X52.js → reception-BR5YURT6.js} +3 -3
- package/dist/chunks/{recruit-stage-4ETIBMIW.js → recruit-stage-4HQ6OGXT.js} +654 -336
- package/dist/chunks/{registry-I4DVPDMU.js → registry-7LICMV5J.js} +12 -12
- package/dist/chunks/{registry-3FYSWV3U.js → registry-JFQEFC7E.js} +3 -3
- package/dist/chunks/{registry-3UGIWH53.js → registry-JMNOXRST.js} +2 -2
- package/dist/chunks/{registry-7RS74TCK.js → registry-MZJQX65Q.js} +5 -5
- package/dist/chunks/{room-recommend-GWCVKCXW.js → room-recommend-43GLLE7Y.js} +4 -4
- package/dist/chunks/{schedule-6AN63MJQ.js → schedule-ZQ42BEW6.js} +4 -4
- package/dist/chunks/{smart-extract-SR4SJJKN.js → smart-extract-QKAEAZGM.js} +3 -3
- package/dist/chunks/{workflow-KF7FA2UQ.js → workflow-6HV7H5PC.js} +10 -7
- package/dist/index.js +34 -34
- package/dist/internal/e10/auth/commands.js +21 -1
- package/dist/internal/e10/auth/xiaoe.js +6 -2
- package/dist/internal/e10/auth-recovery.js +28 -2
- package/dist/internal/e10/request-runtime.js +15 -3
- package/dist/internal/e10/request-trace.js +65 -0
- package/dist/shortcuts/contract/data/metric-catalog.js +149 -0
- package/dist/shortcuts/contract/index.js +14 -39
- package/dist/shortcuts/contract/manifest.js +115 -270
- package/dist/shortcuts/contract/operations/compare-report.js +437 -0
- package/dist/shortcuts/contract/operations/compare.js +2 -0
- package/dist/shortcuts/contract/operations/first-screen.js +96 -207
- package/dist/shortcuts/contract/operations/flow.js +19 -1
- package/dist/shortcuts/contract/operations/{card-ebdf-list.js → ledger-card.js} +98 -25
- package/dist/shortcuts/contract/operations/ledger.js +315 -1
- package/dist/shortcuts/contract/operations/metrics.js +93 -0
- package/dist/shortcuts/contract/operations/modeltext.js +3 -3
- package/dist/shortcuts/contract/operations/page.js +8 -4
- package/dist/shortcuts/contract/operations/performance.js +53 -0
- package/dist/shortcuts/contract/operations/quote-recognize.js +289 -0
- package/dist/shortcuts/contract/operations/quote-submit.js +264 -0
- package/dist/shortcuts/contract/operations/recommend.js +42 -1
- package/dist/shortcuts/contract/operations/registry.js +16 -23
- package/dist/shortcuts/contract/operations/{card-risk-report.js → review-report.js} +24 -114
- package/dist/shortcuts/contract/operations/review.js +33 -167
- package/dist/shortcuts/contract/operations/save-recognize.js +173 -43
- package/dist/shortcuts/contract/operations/triage.js +13 -6
- package/dist/shortcuts/contract/operations/{template.js → type-clause-read.js} +10 -25
- package/dist/shortcuts/contract/operations/upload.js +17 -11
- package/dist/shortcuts/contract/prewarm-cache.js +6 -2
- package/dist/shortcuts/contract/prewarm.js +33 -23
- package/dist/shortcuts/contract/recommend-cache.js +191 -0
- package/dist/shortcuts/ehr/operations/recruit-interview-overview.js +85 -62
- package/dist/shortcuts/ehr/operations/recruit-position.js +21 -13
- package/dist/shortcuts/ehr/operations/recruit-short-cache.js +59 -0
- package/dist/shortcuts/ehr/operations/recruit-tag.js +17 -11
- package/dist/shortcuts/ehr/operations/recruit-write.js +118 -70
- package/dist/shortcuts/ehr/operations/recruit.js +338 -121
- package/dist/shortcuts/hrm/operations/employee.js +64 -17
- package/dist/shortcuts/hrm/operations/resolve.js +419 -369
- package/dist/shortcuts/im/host.js +38 -22
- package/dist/shortcuts/meeting/operations/eb/conflict.js +60 -2
- package/dist/shortcuts/meeting/operations/eb/create-flow.js +116 -7
- package/dist/shortcuts/meeting/operations/eb/create-form-link.js +380 -0
- package/dist/shortcuts/meeting/operations/eb/index.js +2 -0
- package/dist/shortcuts/meeting/operations/eb/room-recommend.js +1 -3
- package/dist/shortcuts/recruit-stage/batch-store.js +44 -0
- package/dist/shortcuts/recruit-stage/context.js +75 -9
- package/dist/shortcuts/recruit-stage/manifest.js +1 -1
- package/dist/shortcuts/recruit-stage/operations/jd-create.js +33 -22
- package/dist/shortcuts/recruit-stage/operations/list.js +187 -37
- package/dist/shortcuts/recruit-stage/operations/registry.js +2 -0
- package/dist/shortcuts/recruit-stage/operations/resume-import.js +231 -313
- package/dist/shortcuts/recruit-stage/operations/search.js +5 -5
- package/dist/shortcuts/recruit-stage/operations/tag.js +286 -0
- package/dist/shortcuts/workflow/endpoints.js +2 -0
- package/dist/shortcuts/workflow/operations/form.js +12 -15
- package/dist/shortcuts/workflow/operations/read.js +8 -8
- package/dist/shortcuts/workflow/operations/todoSmartConvert/todoListRows.js +3 -2
- package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.collect.js +7 -6
- package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.core.js +4 -3
- package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.group.js +1 -0
- package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.js +33 -6
- package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.prepareQuery.js +153 -0
- package/dist/shortcuts/workflow/operations/todoSmartConvert/workflowClarification.js +232 -0
- package/dist/shortcuts/workflow/operations.js +5 -0
- package/docs/contract.md +2 -2
- package/docs/e10-auth.md +28 -0
- package/docs/ehr.md +1 -1
- package/package.json +1 -1
- package/skills/weaver-e10-hrm/SKILL.md +3 -3
- package/skills/weaver-e10-hrm/references/employee.md +13 -2
- package/skills/weaver-e10-jinchengda/SKILL.md +237 -347
- package/skills/weaver-e10-jinchengda/references/contract-agent-entry.md +7 -14
- package/skills/weaver-e10-jinchengda/references/contract-ai-assistant.md +21 -12
- package/skills/weaver-e10-jinchengda/references/contract-ai-review.md +109 -185
- package/skills/weaver-e10-jinchengda/references/contract-clause-insert.md +12 -4
- package/skills/weaver-e10-jinchengda/references/contract-clause-library-crud.md +28 -20
- package/skills/weaver-e10-jinchengda/references/contract-clause-recommender.md +12 -17
- package/skills/weaver-e10-jinchengda/references/contract-clause-reference-save.md +7 -13
- package/skills/weaver-e10-jinchengda/references/contract-command-index.md +21 -12
- package/skills/weaver-e10-jinchengda/references/contract-compare-report-template.html +10 -18
- package/skills/weaver-e10-jinchengda/references/contract-compare-report.md +18 -17
- package/skills/weaver-e10-jinchengda/references/contract-credit-page.md +114 -61
- package/skills/weaver-e10-jinchengda/references/contract-disabled-capabilities.md +8 -2
- package/skills/weaver-e10-jinchengda/references/contract-doc-compare.md +73 -104
- package/skills/weaver-e10-jinchengda/references/contract-doc-triage.md +32 -37
- package/skills/weaver-e10-jinchengda/references/contract-element-extract.md +12 -10
- package/skills/weaver-e10-jinchengda/references/contract-element-save-record.md +70 -82
- package/skills/weaver-e10-jinchengda/references/contract-execution-rules.md +37 -33
- package/skills/weaver-e10-jinchengda/references/contract-field-extract-new-customer.md +94 -27
- package/skills/weaver-e10-jinchengda/references/contract-field-extract-other-flows.md +5 -5
- package/skills/weaver-e10-jinchengda/references/contract-flow-launch.md +9 -15
- package/skills/weaver-e10-jinchengda/references/contract-ledger-catalog.md +9 -4
- package/skills/weaver-e10-jinchengda/references/contract-ledger-query-playbook.md +59 -32
- package/skills/weaver-e10-jinchengda/references/contract-ledger-rules.md +7 -5
- package/skills/weaver-e10-jinchengda/references/contract-modeltext-library.md +21 -13
- package/skills/weaver-e10-jinchengda/references/contract-multi-file.md +13 -13
- package/skills/weaver-e10-jinchengda/references/contract-object-detect.md +6 -5
- package/skills/weaver-e10-jinchengda/references/contract-open-web-pages.md +250 -0
- package/skills/weaver-e10-jinchengda/references/contract-performance-query.md +11 -20
- package/skills/weaver-e10-jinchengda/references/contract-quote-to-contract.md +203 -54
- package/skills/weaver-e10-jinchengda/references/contract-request-status.md +4 -11
- package/skills/weaver-e10-jinchengda/references/contract-request-write.md +11 -17
- package/skills/weaver-e10-jinchengda/references/contract-signing-subjects.md +11 -17
- package/skills/weaver-e10-jinchengda/references/contract-subject-create.md +5 -11
- package/skills/weaver-e10-jinchengda/references/contract-template-recommend.md +56 -7
- package/skills/weaver-e10-jinchengda/references/contract-workflow-discovery.md +10 -16
- package/skills/weaver-e10-jinchengda/references/orchestration.md +31 -33
- package/skills/weaver-e10-jucailin/SKILL.md +6 -7
- package/skills/weaver-e10-jucailin/agents/openai.yaml +52 -0
- package/skills/weaver-e10-jucailin/references/recruit-interview-overview.md +8 -6
- package/skills/weaver-e10-jucailin/references/recruit-read.md +4 -0
- package/skills/weaver-e10-jucailin/references/recruit-screening-to-interview-sop.md +2 -2
- package/skills/weaver-e10-jucailin/references/recruit-write.md +4 -4
- package/skills/weaver-e10-meeting/SKILL.md +83 -531
- package/skills/weaver-e10-meeting/references/commands-table.md +61 -0
- package/skills/weaver-e10-meeting/references/create-commands.md +136 -0
- package/skills/weaver-e10-meeting/references/create-flow.md +3 -1
- package/skills/weaver-e10-meeting/references/create-guardrails.md +14 -8
- package/skills/weaver-e10-meeting/references/custom-fields.md +40 -0
- package/skills/weaver-e10-meeting/references/eb-contracts.md +60 -0
- package/skills/weaver-e10-meeting/references/invitation.md +69 -0
- package/skills/weaver-e10-meeting/references/minutes-pipeline.md +119 -0
- package/skills/weaver-e10-meeting/references/pitfalls.md +1 -1
- package/skills/weaver-e10-meeting/references/room-recommend.md +88 -0
- package/skills/weaver-e10-recruit-stage/SKILL.md +317 -266
- package/skills/weaver-e10-recruit-stage/agents/openai.yaml +22 -27
- package/skills/weaver-e10-recruit-stage/references/env-ziyong.md +1 -1
- package/skills/weaver-e10-recruit-stage/references/recruit-arrange-interview.md +30 -27
- package/skills/weaver-e10-recruit-stage/references/recruit-capability-check.md +2 -6
- package/skills/weaver-e10-recruit-stage/references/recruit-edit-interview-feedback.md +12 -10
- package/skills/weaver-e10-recruit-stage/references/recruit-interview-not-attended.md +2 -0
- package/skills/weaver-e10-recruit-stage/references/recruit-jd-create.md +23 -19
- package/skills/weaver-e10-recruit-stage/references/recruit-jd-template.md +3 -1
- package/skills/weaver-e10-recruit-stage/references/recruit-list-candidate.md +18 -16
- package/skills/weaver-e10-recruit-stage/references/recruit-list-interview.md +25 -23
- package/skills/weaver-e10-recruit-stage/references/recruit-match-candidates.md +10 -10
- package/skills/weaver-e10-recruit-stage/references/recruit-resolve-metadata.md +2 -2
- package/skills/weaver-e10-recruit-stage/references/recruit-resume-import-batch.md +11 -11
- package/skills/weaver-e10-recruit-stage/references/recruit-resume-import.md +150 -85
- package/skills/weaver-e10-recruit-stage/references/recruit-resume-parse.md +14 -18
- package/skills/weaver-e10-recruit-stage/references/recruit-search-by-tag.md +1 -1
- package/skills/weaver-e10-recruit-stage/references/recruit-tag-recommend.md +173 -0
- package/skills/weaver-e10-recruit-stage/references/recruit-tag-taxonomy.json +76 -0
- package/skills/weaver-e10-recruit-stage/references/recruit-urge-feedback.md +3 -1
- package/skills/weaver-e10-recruit-stage/references/recruit-utterance-glossary.md +2 -2
- package/skills/weaver-e10-workflow/SKILL.md +49 -32
- package/skills/weaver-e10-workflow/references/todo-dialogue.md +67 -34
- package/skills/weaver-e10-workflow/references/todo-smart-convert.md +65 -51
- package/skills/weaver-e10-workflow/references/workflow-agent-entry.md +18 -11
- package/skills/weaver-e10-workflow/references/workflow-create.md +2 -2
- package/skills/weaver-e10-workflow/references/workflow-memory.md +19 -37
- package/skills/weaver-e10-workflow/references/workflow-query.md +25 -22
- package/skills/weaver-e10-workflow/references/workflow-view.md +1 -1
- package/skills/weaver-e10-workflow/tools/todo-summary.cjs +318 -110
- package/skills/weaver-e10-yimiaoban/SKILL.md +10 -10
- package/skills/weaver-e10-yimiaoban/references/person.md +1 -1
- package/skills/weaver-e10-yimiaoban/references/safety-boundaries.md +1 -1
- package/skills/weaver-e10-yimiaoban/references/source-manifest.json +9 -9
- package/dist/chunks/chunk-6QYNE6HE.js +0 -658
- package/dist/chunks/chunk-SHYQUBY3.js +0 -48
- package/dist/shortcuts/contract/operations/card-action.js +0 -1266
- package/dist/shortcuts/contract/operations/card-plan.js +0 -393
- package/dist/shortcuts/contract/operations/card.js +0 -232
- package/dist/shortcuts/contract/operations/compare-screen.js +0 -378
- package/dist/shortcuts/contract/operations/quote-to-contract.js +0 -495
- package/dist/shortcuts/contract/operations/quotescreen.js +0 -529
- package/dist/shortcuts/contract/operations/summary-validate.js +0 -293
- package/dist/shortcuts/contract/operations/summary.js +0 -187
- package/dist/shortcuts/ehr/recruit-stage/batch-store.js +0 -78
- package/dist/shortcuts/ehr/recruit-stage/context.js +0 -231
- package/dist/shortcuts/ehr/recruit-stage/continuation.js +0 -74
- package/dist/shortcuts/ehr/recruit-stage/errors.js +0 -65
- package/dist/shortcuts/ehr/recruit-stage/fs-scan.js +0 -165
- package/dist/shortcuts/ehr/recruit-stage/host.js +0 -109
- package/dist/shortcuts/ehr/recruit-stage/operations/interview-arrange.js +0 -1065
- package/dist/shortcuts/ehr/recruit-stage/operations/interview-feedback.js +0 -295
- package/dist/shortcuts/ehr/recruit-stage/operations/jd-create.js +0 -961
- package/dist/shortcuts/ehr/recruit-stage/operations/list.js +0 -431
- package/dist/shortcuts/ehr/recruit-stage/operations/registry.js +0 -50
- package/dist/shortcuts/ehr/recruit-stage/operations/resume-import.js +0 -1655
- package/dist/shortcuts/ehr/recruit-stage/operations/search.js +0 -158
- package/dist/shortcuts/ehr/recruit-stage/operations/types.js +0 -34
- package/dist/shortcuts/ehr/recruit-stage/runtime.js +0 -31
- package/dist/shortcuts/ehr/recruit-stage/school-tiers.json +0 -318
- package/dist/shortcuts/ehr/recruit-stage/shared.js +0 -887
- package/skills/weaver-e10-jinchengda/references/contract-action-card-template.html +0 -22
- package/skills/weaver-e10-jinchengda/references/contract-action-card.md +0 -554
- package/skills/weaver-e10-jinchengda/references/contract-action-engine.md +0 -279
- package/skills/weaver-e10-jinchengda/references/contract-card-render-internals.md +0 -483
- package/skills/weaver-e10-jinchengda/references/contract-template-selector.md +0 -46
- package/skills/weaver-e10-recruit-stage/lib/recruit-resume-photo.py +0 -194
|
@@ -1,495 +0,0 @@
|
|
|
1
|
-
import { existsSync, mkdirSync, statSync } from 'node:fs';
|
|
2
|
-
import { basename, join } from 'node:path';
|
|
3
|
-
import { contractValidationError } from '../errors.js';
|
|
4
|
-
import { resolveOperation } from './op-resolver.js';
|
|
5
|
-
/**
|
|
6
|
-
* 报价单 → 合同 一键盘:`contract.quotescreen.tocontract`。
|
|
7
|
-
*
|
|
8
|
-
* 为什么需要它(2026-11-16 用户实测反馈):
|
|
9
|
-
* 一次「按报价单生成合同」在模型侧跑了 17 轮往返,其中真正必要的只有 2 轮,其余全部消耗在:
|
|
10
|
-
* ① 反复在 quote.parse / recommend.doc / file.download / slots.scan / slots.fill / card.action
|
|
11
|
-
* 之间倒手,每倒一次就是一次工具往返(5~10 s);
|
|
12
|
-
* ② 填充方案靠模型手工拼(本次连拼 3 版:把两个明细段合成一段导致汇总格串行、
|
|
13
|
-
* 又把遮蔽后的 `[[MONEY_xxx]]` 误判成示例值残留而重复补写);
|
|
14
|
-
* ③ 因为不信内置校验,另写了 3 个 Python 脚本回读成品,每个脚本又占 2 轮。
|
|
15
|
-
*
|
|
16
|
-
* 这三件事里,①③ 完全可以由代码确定性地做完——`quotescreen.ts` 早已证明进程内串接的范式
|
|
17
|
-
* (`resolveOperation(name).execute(...)`,不起子进程、不落参数文件)。
|
|
18
|
-
* ② 里属于「语义映射」的部分仍需模型判断,因此本 operation 只做**结构性**字段的确定性装配:
|
|
19
|
-
* 甲方/乙方/签订时间/总额/产品与费用小计/付款分期/标题,并把装配结果原文回传供模型复核;
|
|
20
|
-
* 分类拿不准的一律进 `unsupported` / `warnings`,绝不静默丢弃。
|
|
21
|
-
*
|
|
22
|
-
* 语义边界(不变):
|
|
23
|
-
* - 不判合同类型、不指定 flowKey、不上传流程附件、不存识别记录、不做表单预填
|
|
24
|
-
* —— 报价单转合同一律走这条豁免口径,类型判定交给用户点「发起合同流程」之后。
|
|
25
|
-
* - 卡片由 `contract.card.action` 渲染,本 operation 不拼 HTML。
|
|
26
|
-
* - 模板选择仍可由模型用 `templateFileId` / `templatePath` 覆盖,自动推荐只是默认路径。
|
|
27
|
-
*/
|
|
28
|
-
const DEFAULT_OUR_COMPANY = '泛微网络科技股份有限公司';
|
|
29
|
-
const DEFAULT_SIGN_PLACE = '上海市';
|
|
30
|
-
const DEFAULT_SUBJECT = '协同办公系统(e-cology)';
|
|
31
|
-
const DEFAULT_MIN_SCORE = 85;
|
|
32
|
-
const DEFAULT_TEMPLATE_MODULE = 'ebuilderform';
|
|
33
|
-
const DEFAULT_PAYMENT_RATIOS = [0.3, 0.3, 0.3, 0.1];
|
|
34
|
-
/** 服务类费用的名称关键词:命中即归入「服务费用」明细段,其余归入「产品费用」段。 */
|
|
35
|
-
const SERVICE_HINTS = ['实施', '服务', '培训', '运维', '咨询', '开发', '部署', '迁移', '上线', '验收', '维护', 'support'];
|
|
36
|
-
/** 汇总类金额格的标签关键词:这些格由 details.subtotal 或总额统一写入,不逐格硬编码。 */
|
|
37
|
-
const TOTAL_LABEL_HINTS = ['总额', '合计', '总价', '总计'];
|
|
38
|
-
const PRODUCT_LABEL_HINTS = ['产品费用', '软件产品费', '产品费'];
|
|
39
|
-
const SERVICE_LABEL_HINTS = ['服务费用', '服务费'];
|
|
40
|
-
function isRecord(value) {
|
|
41
|
-
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
42
|
-
}
|
|
43
|
-
function str(value) {
|
|
44
|
-
if (typeof value === 'string')
|
|
45
|
-
return value.trim();
|
|
46
|
-
if (typeof value === 'number' && Number.isFinite(value))
|
|
47
|
-
return String(value);
|
|
48
|
-
return '';
|
|
49
|
-
}
|
|
50
|
-
function numOf(value) {
|
|
51
|
-
if (typeof value === 'number' && Number.isFinite(value))
|
|
52
|
-
return value;
|
|
53
|
-
if (typeof value === 'string') {
|
|
54
|
-
const cleaned = value.replace(/[,\s¥¥]/gu, '');
|
|
55
|
-
if (!cleaned)
|
|
56
|
-
return null;
|
|
57
|
-
const parsed = Number(cleaned);
|
|
58
|
-
return Number.isFinite(parsed) ? parsed : null;
|
|
59
|
-
}
|
|
60
|
-
return null;
|
|
61
|
-
}
|
|
62
|
-
function moneyText(value) {
|
|
63
|
-
return Math.round(value).toLocaleString('en-US');
|
|
64
|
-
}
|
|
65
|
-
function formatDate(date) {
|
|
66
|
-
return `${date.getFullYear()} 年 ${date.getMonth() + 1} 月 ${date.getDate()} 日`;
|
|
67
|
-
}
|
|
68
|
-
async function callOperation(name, input, context) {
|
|
69
|
-
const operation = resolveOperation(name);
|
|
70
|
-
const result = await operation.execute(input, context);
|
|
71
|
-
return (result?.data ?? {});
|
|
72
|
-
}
|
|
73
|
-
/** 报价单分节 → 合同费用行。汇总表(is_summary)与 0 元项一律排除,防重复计价。 */
|
|
74
|
-
function collectSections(parsed) {
|
|
75
|
-
const raw = Array.isArray(parsed.sections) ? parsed.sections : [];
|
|
76
|
-
const out = [];
|
|
77
|
-
for (const section of raw) {
|
|
78
|
-
if (!isRecord(section))
|
|
79
|
-
continue;
|
|
80
|
-
if (section.is_summary === true)
|
|
81
|
-
continue;
|
|
82
|
-
const name = str(section.name) || str(section.title);
|
|
83
|
-
const amount = numOf(section.total ?? section.amount ?? section.sum);
|
|
84
|
-
if (amount === null || amount === 0)
|
|
85
|
-
continue;
|
|
86
|
-
out.push({ name: name || '费用项', amount });
|
|
87
|
-
}
|
|
88
|
-
return out;
|
|
89
|
-
}
|
|
90
|
-
function sumAmount(sections) {
|
|
91
|
-
return sections.reduce((acc, section) => acc + section.amount, 0);
|
|
92
|
-
}
|
|
93
|
-
/** 按名称关键词把费用分节拆成产品组 / 服务组。 */
|
|
94
|
-
function splitSections(sections) {
|
|
95
|
-
const product = [];
|
|
96
|
-
const service = [];
|
|
97
|
-
for (const section of sections) {
|
|
98
|
-
if (SERVICE_HINTS.some((hint) => section.name.includes(hint)))
|
|
99
|
-
service.push(section);
|
|
100
|
-
else
|
|
101
|
-
product.push(section);
|
|
102
|
-
}
|
|
103
|
-
return { product, service };
|
|
104
|
-
}
|
|
105
|
-
function buildContractTitle(customer, subject, withService) {
|
|
106
|
-
const owner = customer || '客户';
|
|
107
|
-
return withService ? `${owner}${subject}软件产品及实施服务购买合同` : `${owner}${subject}软件产品购买合同`;
|
|
108
|
-
}
|
|
109
|
-
/** 分期金额:比例模式按总额换算,末期用差额兜底,保证累计严格等于总额。 */
|
|
110
|
-
function buildPayments(total, ratios) {
|
|
111
|
-
const safe = ratios.filter((ratio) => Number.isFinite(ratio) && ratio > 0);
|
|
112
|
-
if (!safe.length)
|
|
113
|
-
return [total];
|
|
114
|
-
const out = [];
|
|
115
|
-
let acc = 0;
|
|
116
|
-
for (let i = 0; i < safe.length; i += 1) {
|
|
117
|
-
if (i === safe.length - 1) {
|
|
118
|
-
out.push(Math.round(total - acc));
|
|
119
|
-
}
|
|
120
|
-
else {
|
|
121
|
-
const value = Math.round(total * safe[i]);
|
|
122
|
-
out.push(value);
|
|
123
|
-
acc += value;
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
return out;
|
|
127
|
-
}
|
|
128
|
-
function normalizePayments(input, total) {
|
|
129
|
-
if (!Array.isArray(input) || input.length === 0)
|
|
130
|
-
return buildPayments(total, DEFAULT_PAYMENT_RATIOS);
|
|
131
|
-
const nums = input.map((item) => numOf(item)).filter((item) => item !== null && item > 0);
|
|
132
|
-
if (!nums.length)
|
|
133
|
-
return buildPayments(total, DEFAULT_PAYMENT_RATIOS);
|
|
134
|
-
const isRatio = nums.every((num) => num <= 1);
|
|
135
|
-
return isRatio ? buildPayments(total, nums) : nums;
|
|
136
|
-
}
|
|
137
|
-
function toItems(sections) {
|
|
138
|
-
return sections.map((section, index) => ({
|
|
139
|
-
编号: String(index + 1),
|
|
140
|
-
名称: section.name,
|
|
141
|
-
单价: String(section.amount),
|
|
142
|
-
数量: '1',
|
|
143
|
-
折扣: '100%',
|
|
144
|
-
金额: String(section.amount),
|
|
145
|
-
}));
|
|
146
|
-
}
|
|
147
|
-
/**
|
|
148
|
-
* 按 scan 位点确定性装配填充方案。
|
|
149
|
-
*
|
|
150
|
-
* 关键约束(来自 2026-11-16 实测踩坑):
|
|
151
|
-
* - 明细**一段一方案**:模板同一张表里「产品费」「服务费用」是两段,合成一个 details
|
|
152
|
-
* 会让行数调整跨段生效、行号重映射撞车,直接冲掉段末汇总格。
|
|
153
|
-
* - 汇总格(段末合并行的金额格)**不显式写**:`slots.fill` 阶段 3 已按 `details.subtotal`
|
|
154
|
-
* 自动写段末合并行末格,再硬写一次就会出现「同一格被写入不同值」。
|
|
155
|
-
* - 段落位点是**整段替换**,必须给完整段落文本(`fullText`),只给客户名会把整段标题覆盖掉。
|
|
156
|
-
*/
|
|
157
|
-
function buildPlan(args) {
|
|
158
|
-
const slots = [];
|
|
159
|
-
const details = [];
|
|
160
|
-
const unsupported = [];
|
|
161
|
-
const warnings = [];
|
|
162
|
-
const detailAreas = args.scanSlots
|
|
163
|
-
.filter((slot) => str(slot?.type) === 'detail-area')
|
|
164
|
-
.slice()
|
|
165
|
-
.sort((a, b) => Number(a.table) - Number(b.table) || Number(a.startRow) - Number(b.startRow));
|
|
166
|
-
const summarySlotIds = new Set();
|
|
167
|
-
const summaryBindings = [];
|
|
168
|
-
for (const area of detailAreas) {
|
|
169
|
-
const bound = str(area.summarySlotId);
|
|
170
|
-
if (!bound)
|
|
171
|
-
continue;
|
|
172
|
-
summarySlotIds.add(bound);
|
|
173
|
-
summaryBindings.push({ detailSlotId: str(area.slotId), summarySlotId: bound });
|
|
174
|
-
}
|
|
175
|
-
// ── 段落位点:整段替换
|
|
176
|
-
for (const slot of args.scanSlots) {
|
|
177
|
-
if (str(slot?.type) !== 'paragraph')
|
|
178
|
-
continue;
|
|
179
|
-
const slotId = str(slot.slotId);
|
|
180
|
-
const full = str(slot.fullText) || str(slot.current);
|
|
181
|
-
if (!slotId || !full)
|
|
182
|
-
continue;
|
|
183
|
-
if (/xxx公司|×××公司|【客户】|【甲方】/u.test(full)) {
|
|
184
|
-
slots.push({ slotId, value: args.contractTitle, required: true });
|
|
185
|
-
}
|
|
186
|
-
else if (/\*+有限公司/u.test(full)) {
|
|
187
|
-
slots.push({ slotId, value: full.replace(/\*+有限公司/gu, args.customer), required: true });
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
// ── 付款格按行序取分期金额
|
|
191
|
-
const paymentSlots = args.scanSlots
|
|
192
|
-
.filter((slot) => str(slot?.type) === 'cell' && /付款金额/u.test(str(slot.label)))
|
|
193
|
-
.slice()
|
|
194
|
-
.sort((a, b) => Number(a.row) - Number(b.row));
|
|
195
|
-
const paymentSlotIds = new Set(paymentSlots.map((slot) => str(slot.slotId)).filter(Boolean));
|
|
196
|
-
for (const slot of args.scanSlots) {
|
|
197
|
-
if (str(slot?.type) !== 'cell')
|
|
198
|
-
continue;
|
|
199
|
-
const slotId = str(slot.slotId);
|
|
200
|
-
if (!slotId)
|
|
201
|
-
continue;
|
|
202
|
-
// 汇总格由 details.subtotal 负责;付款格单独按行序处理
|
|
203
|
-
if (summarySlotIds.has(slotId) || paymentSlotIds.has(slotId))
|
|
204
|
-
continue;
|
|
205
|
-
const label = str(slot.label);
|
|
206
|
-
const constraint = str(slot.constraint);
|
|
207
|
-
if (/签订时间|签订日期|生效日期|签署日期/u.test(label)) {
|
|
208
|
-
slots.push({ slotId, value: args.signDate, required: true });
|
|
209
|
-
continue;
|
|
210
|
-
}
|
|
211
|
-
if (/签订地点|签约地点/u.test(label)) {
|
|
212
|
-
slots.push({ slotId, value: args.signPlace });
|
|
213
|
-
continue;
|
|
214
|
-
}
|
|
215
|
-
if (/甲方|买方|需方/u.test(label)) {
|
|
216
|
-
slots.push({ slotId, value: args.customer, required: true });
|
|
217
|
-
continue;
|
|
218
|
-
}
|
|
219
|
-
if (/乙方|卖方|供方/u.test(label)) {
|
|
220
|
-
slots.push({ slotId, value: args.ourCompany, required: true });
|
|
221
|
-
continue;
|
|
222
|
-
}
|
|
223
|
-
if (constraint !== 'money')
|
|
224
|
-
continue;
|
|
225
|
-
// 明细表内的金额格只由 details.subtotal 写(段末合并行)。
|
|
226
|
-
// 明细表里其他合并行的空白金额格是「节标题行」(如「2服务费用」)的位子,
|
|
227
|
-
// 按标签猜着填会把节标题行写出金额——2026-11-16 回归实测:label 含「服务费用」
|
|
228
|
-
// 的节标题格被误填 167,500,导致「2服务费用」这一行右侧凭空出现一个金额。
|
|
229
|
-
if (detailAreas.some((area) => Number(area.table) === Number(slot.table)))
|
|
230
|
-
continue;
|
|
231
|
-
if (TOTAL_LABEL_HINTS.some((hint) => label.includes(hint))) {
|
|
232
|
-
slots.push({ slotId, value: moneyText(args.totalAmount), required: true });
|
|
233
|
-
continue;
|
|
234
|
-
}
|
|
235
|
-
if (PRODUCT_LABEL_HINTS.some((hint) => label.includes(hint))) {
|
|
236
|
-
slots.push({ slotId, value: moneyText(args.productAmount) });
|
|
237
|
-
continue;
|
|
238
|
-
}
|
|
239
|
-
if (SERVICE_LABEL_HINTS.some((hint) => label.includes(hint))) {
|
|
240
|
-
slots.push({ slotId, value: moneyText(args.serviceAmount) });
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
paymentSlots.forEach((slot, index) => {
|
|
244
|
-
const slotId = str(slot.slotId);
|
|
245
|
-
const amount = args.paymentAmounts[index];
|
|
246
|
-
if (!slotId || amount === undefined) {
|
|
247
|
-
if (slotId)
|
|
248
|
-
warnings.push(`付款分期只给了 ${args.paymentAmounts.length} 期,模板第 ${index + 1} 期(${slotId})留空`);
|
|
249
|
-
return;
|
|
250
|
-
}
|
|
251
|
-
slots.push({ slotId, value: moneyText(amount), required: true });
|
|
252
|
-
});
|
|
253
|
-
// ── 明细:一段一方案
|
|
254
|
-
if (detailAreas.length === 0) {
|
|
255
|
-
unsupported.push({ field: '费用明细', reason: '模板未识别到明细表,费用明细未写入,建议另附报价清单作为合同附件' });
|
|
256
|
-
return { slots, details, unsupported, warnings, summaryBindings };
|
|
257
|
-
}
|
|
258
|
-
if (detailAreas.length === 1) {
|
|
259
|
-
const all = [...args.productSections, ...args.serviceSections];
|
|
260
|
-
details.push({
|
|
261
|
-
slotId: str(detailAreas[0].slotId),
|
|
262
|
-
subtotal: args.totalAmount,
|
|
263
|
-
items: toItems(all),
|
|
264
|
-
});
|
|
265
|
-
return { slots, details, unsupported, warnings, summaryBindings };
|
|
266
|
-
}
|
|
267
|
-
const first = detailAreas[0];
|
|
268
|
-
const second = detailAreas[1];
|
|
269
|
-
if (args.productSections.length) {
|
|
270
|
-
details.push({ slotId: str(first.slotId), subtotal: args.productAmount, items: toItems(args.productSections) });
|
|
271
|
-
}
|
|
272
|
-
else {
|
|
273
|
-
warnings.push('模板第 1 个明细区无对应产品费用数据,该区保留模板原样,请人工核对');
|
|
274
|
-
unsupported.push({ field: '产品费明细', reason: '报价单无产品类费用分节,模板第 1 明细区未写入' });
|
|
275
|
-
}
|
|
276
|
-
if (args.serviceSections.length) {
|
|
277
|
-
details.push({ slotId: str(second.slotId), subtotal: args.serviceAmount, items: toItems(args.serviceSections) });
|
|
278
|
-
}
|
|
279
|
-
else {
|
|
280
|
-
warnings.push('模板第 2 个明细区无对应服务费用数据,该区保留模板原样,请人工核对或改用单明细段模板');
|
|
281
|
-
unsupported.push({ field: '服务费明细', reason: '报价单无服务类费用分节,模板第 2 明细区未写入' });
|
|
282
|
-
}
|
|
283
|
-
for (let index = 2; index < detailAreas.length; index += 1) {
|
|
284
|
-
unsupported.push({
|
|
285
|
-
field: `明细区${index + 1}`,
|
|
286
|
-
reason: '模板明细段多于报价单的费用分节维度,未自动填充',
|
|
287
|
-
});
|
|
288
|
-
}
|
|
289
|
-
return { slots, details, unsupported, warnings, summaryBindings };
|
|
290
|
-
}
|
|
291
|
-
function buildRecommendContent(args) {
|
|
292
|
-
const detail = args.sections.map((section) => `${section.name} ${moneyText(section.amount)} 元`).join('、');
|
|
293
|
-
return [
|
|
294
|
-
`销售一套 ${args.subject} 软件产品及实施服务。`,
|
|
295
|
-
args.customer ? `客户为 ${args.customer}。` : '',
|
|
296
|
-
`合同总金额 ${moneyText(args.totalAmount)} 元。`,
|
|
297
|
-
detail ? `费用构成:${detail}。` : '',
|
|
298
|
-
'需要一份标准的新客户软件产品及实施服务购买合同范文。',
|
|
299
|
-
].filter(Boolean).join('');
|
|
300
|
-
}
|
|
301
|
-
export const contractQuoteToContractOperations = [
|
|
302
|
-
{
|
|
303
|
-
name: 'contract.quotescreen.tocontract',
|
|
304
|
-
async execute(input, context) {
|
|
305
|
-
const quoteFile = str(input.quoteFile);
|
|
306
|
-
if (!quoteFile)
|
|
307
|
-
throw contractValidationError('quote_file_required', 'quoteFile 必须是报价单 .xlsx 绝对路径');
|
|
308
|
-
if (!existsSync(quoteFile))
|
|
309
|
-
throw contractValidationError('quote_file_not_found', `报价单不存在:${quoteFile}`);
|
|
310
|
-
const outDir = str(input.outDir);
|
|
311
|
-
if (!outDir)
|
|
312
|
-
throw contractValidationError('out_dir_required', 'outDir 为必填');
|
|
313
|
-
mkdirSync(outDir, { recursive: true });
|
|
314
|
-
const warnings = [];
|
|
315
|
-
const steps = [];
|
|
316
|
-
// ── 1. 解析报价单:一次拿到 meta / totals / sections / checks
|
|
317
|
-
const parsed = await callOperation('contract.quote.parse', {
|
|
318
|
-
path: quoteFile,
|
|
319
|
-
...(str(input.sheet) ? { sheet: str(input.sheet) } : {}),
|
|
320
|
-
}, context);
|
|
321
|
-
steps.push('quote.parse');
|
|
322
|
-
const meta = isRecord(parsed.meta) ? parsed.meta : {};
|
|
323
|
-
const totals = isRecord(parsed.totals) ? parsed.totals : {};
|
|
324
|
-
const customer = str(input.customerName) || str(meta.customer);
|
|
325
|
-
if (!customer) {
|
|
326
|
-
warnings.push('未能从报价单识别客户全称:合同名称与甲方会退化,建议用 customerName 传入后重跑');
|
|
327
|
-
}
|
|
328
|
-
const sections = collectSections(parsed);
|
|
329
|
-
const { product, service } = splitSections(sections);
|
|
330
|
-
const productAmount = sumAmount(product);
|
|
331
|
-
const serviceAmount = sumAmount(service);
|
|
332
|
-
const sectionTotal = productAmount + serviceAmount;
|
|
333
|
-
const totalAmount = numOf(totals.finalTotal ?? totals.final_total ?? totals.standardTotal ?? totals.standard_total) ?? sectionTotal;
|
|
334
|
-
if (Math.abs(sectionTotal - totalAmount) > 0.01) {
|
|
335
|
-
warnings.push(`费用分项合计 ${moneyText(sectionTotal)} 元与报价总额 ${moneyText(totalAmount)} 元不一致,差额 ${moneyText(Math.abs(sectionTotal - totalAmount))} 元;合同按报价总额填写,请核准后再发客户`);
|
|
336
|
-
}
|
|
337
|
-
const quoteChecks = Array.isArray(parsed.checks) ? parsed.checks : [];
|
|
338
|
-
// ── 2. 模板:本地路径 > 指定 fileId > 智能推荐
|
|
339
|
-
const subject = str(input.subjectTitle) || DEFAULT_SUBJECT;
|
|
340
|
-
const contractTitle = str(input.contractTitle)
|
|
341
|
-
|| buildContractTitle(customer, subject, serviceAmount > 0);
|
|
342
|
-
const ourCompany = str(input.ourCompany) || DEFAULT_OUR_COMPANY;
|
|
343
|
-
let templatePath = str(input.templatePath);
|
|
344
|
-
const templateInfo = {
|
|
345
|
-
mode: templatePath ? 'local-path' : 'recommend',
|
|
346
|
-
fileName: templatePath ? basename(templatePath) : '',
|
|
347
|
-
fileId: '',
|
|
348
|
-
matchScore: null,
|
|
349
|
-
};
|
|
350
|
-
if (!templatePath) {
|
|
351
|
-
let fileId = str(input.templateFileId);
|
|
352
|
-
if (!fileId) {
|
|
353
|
-
const content = str(input.recommendContent) || buildRecommendContent({ customer, subject, totalAmount, sections });
|
|
354
|
-
const recommend = await callOperation('contract.recommend.doc', { content }, context);
|
|
355
|
-
steps.push('recommend.doc');
|
|
356
|
-
const list = Array.isArray(recommend.recommendations) ? recommend.recommendations : [];
|
|
357
|
-
const top = list[0];
|
|
358
|
-
if (!isRecord(top)) {
|
|
359
|
-
throw contractValidationError('recommend_empty', '范文库未匹配到可用模板,请用 templateFileId 或 templatePath 指定');
|
|
360
|
-
}
|
|
361
|
-
const score = Number(top.matchScore ?? 0);
|
|
362
|
-
const minScore = input.minMatchScore === undefined ? DEFAULT_MIN_SCORE : Number(input.minMatchScore);
|
|
363
|
-
if (!Number.isFinite(score) || score < minScore) {
|
|
364
|
-
throw contractValidationError('recommend_low_score', `范文最佳匹配分 ${score} 低于阈值 ${minScore}(${str(top.fileName)});请确认模板后重跑,或用 templateFileId 指定`);
|
|
365
|
-
}
|
|
366
|
-
const files = Array.isArray(top.files) ? top.files : [];
|
|
367
|
-
fileId = str(files[0]?.id) || str(top.fileId);
|
|
368
|
-
templateInfo.fileName = str(top.fileName);
|
|
369
|
-
templateInfo.matchScore = score;
|
|
370
|
-
templateInfo.mode = 'recommend';
|
|
371
|
-
if (!fileId)
|
|
372
|
-
throw contractValidationError('template_file_id_missing', `范文 ${str(top.fileName)} 未返回可用 fileId`);
|
|
373
|
-
}
|
|
374
|
-
else {
|
|
375
|
-
templateInfo.mode = 'file-id';
|
|
376
|
-
}
|
|
377
|
-
templateInfo.fileId = fileId;
|
|
378
|
-
templatePath = join(outDir, 'template.docx');
|
|
379
|
-
await callOperation('contract.file.download', {
|
|
380
|
-
fileId,
|
|
381
|
-
module: str(input.templateModule) || DEFAULT_TEMPLATE_MODULE,
|
|
382
|
-
savePath: templatePath,
|
|
383
|
-
}, context);
|
|
384
|
-
steps.push('file.download');
|
|
385
|
-
templateInfo.fileName = templateInfo.fileName || basename(templatePath);
|
|
386
|
-
}
|
|
387
|
-
// ── 3. 扫描位点
|
|
388
|
-
const scan = await callOperation('contract.docx.slots.scan', {
|
|
389
|
-
template: templatePath,
|
|
390
|
-
out: join(outDir, 'slots.json'),
|
|
391
|
-
}, context);
|
|
392
|
-
steps.push('docx.slots.scan');
|
|
393
|
-
const scanSlots = Array.isArray(scan.slots) ? scan.slots : [];
|
|
394
|
-
// ── 4. 装配填充方案
|
|
395
|
-
const signDate = str(input.signDate) || formatDate(new Date());
|
|
396
|
-
const paymentAmounts = normalizePayments(input.payments, totalAmount);
|
|
397
|
-
const planBuild = buildPlan({
|
|
398
|
-
scanSlots,
|
|
399
|
-
customer: customer || '客户',
|
|
400
|
-
ourCompany,
|
|
401
|
-
signDate,
|
|
402
|
-
signPlace: str(input.signPlace) || DEFAULT_SIGN_PLACE,
|
|
403
|
-
contractTitle,
|
|
404
|
-
totalAmount,
|
|
405
|
-
productAmount,
|
|
406
|
-
serviceAmount,
|
|
407
|
-
productSections: product,
|
|
408
|
-
serviceSections: service,
|
|
409
|
-
paymentAmounts,
|
|
410
|
-
});
|
|
411
|
-
steps.push('plan.build');
|
|
412
|
-
// ── 5. 回填
|
|
413
|
-
const outPath = str(input.out) || join(outDir, `${contractTitle}.docx`);
|
|
414
|
-
const fill = await callOperation('contract.docx.slots.fill', {
|
|
415
|
-
template: templatePath,
|
|
416
|
-
out: outPath,
|
|
417
|
-
plan: {
|
|
418
|
-
slots: planBuild.slots,
|
|
419
|
-
details: planBuild.details,
|
|
420
|
-
unsupported: planBuild.unsupported,
|
|
421
|
-
totals: { grandTotal: totalAmount, installments: paymentAmounts },
|
|
422
|
-
},
|
|
423
|
-
...(input.strict === undefined ? {} : { strict: input.strict }),
|
|
424
|
-
}, context);
|
|
425
|
-
steps.push('docx.slots.fill');
|
|
426
|
-
const validate = isRecord(fill.validate)
|
|
427
|
-
? fill.validate
|
|
428
|
-
: { ok: false, checks: [], fails: ['slots.fill 未返回校验结果'] };
|
|
429
|
-
const validateOk = validate.ok === true;
|
|
430
|
-
const fillWarnings = Array.isArray(fill.warnings) ? fill.warnings.map((item) => String(item)) : [];
|
|
431
|
-
// ── 6. 动作卡片(失败不影响合同交付)
|
|
432
|
-
let card = null;
|
|
433
|
-
if (input.card !== false && validateOk) {
|
|
434
|
-
try {
|
|
435
|
-
const cardData = await callOperation('contract.card.action', {
|
|
436
|
-
fileName: basename(outPath),
|
|
437
|
-
...(customer ? { companyName: customer } : {}),
|
|
438
|
-
out: join(outDir, 'card_contract.json'),
|
|
439
|
-
context: { generatedDocx: true, flowTypeUndetermined: true, docType: 'contract', scene: 'doc' },
|
|
440
|
-
}, context);
|
|
441
|
-
steps.push('card.action');
|
|
442
|
-
card = {
|
|
443
|
-
browsertool: cardData.browsertool,
|
|
444
|
-
selfCheckPassed: cardData.selfCheckPassed,
|
|
445
|
-
selfCheck: cardData.selfCheck,
|
|
446
|
-
title: cardData.title,
|
|
447
|
-
};
|
|
448
|
-
}
|
|
449
|
-
catch (error) {
|
|
450
|
-
warnings.push(`动作卡片生成失败(合同文件不受影响):${error instanceof Error ? error.message : String(error)}`);
|
|
451
|
-
}
|
|
452
|
-
}
|
|
453
|
-
const bytes = existsSync(outPath) ? statSync(outPath).size : 0;
|
|
454
|
-
return {
|
|
455
|
-
status: 'COMPLETE',
|
|
456
|
-
data: {
|
|
457
|
-
ok: validateOk,
|
|
458
|
-
quote: {
|
|
459
|
-
customer,
|
|
460
|
-
quoteDate: str(meta.quoteDate) || str(meta.quote_date),
|
|
461
|
-
sales: str(meta.sales) || str(meta.manager),
|
|
462
|
-
totalAmount,
|
|
463
|
-
productAmount,
|
|
464
|
-
serviceAmount,
|
|
465
|
-
sections,
|
|
466
|
-
checks: quoteChecks,
|
|
467
|
-
},
|
|
468
|
-
template: templateInfo,
|
|
469
|
-
contract: {
|
|
470
|
-
path: outPath,
|
|
471
|
-
fileName: basename(outPath),
|
|
472
|
-
title: contractTitle,
|
|
473
|
-
bytes,
|
|
474
|
-
signDate,
|
|
475
|
-
payments: paymentAmounts,
|
|
476
|
-
},
|
|
477
|
-
plan: {
|
|
478
|
-
slots: planBuild.slots,
|
|
479
|
-
details: planBuild.details,
|
|
480
|
-
unsupported: planBuild.unsupported,
|
|
481
|
-
summaryBindings: planBuild.summaryBindings,
|
|
482
|
-
totals: { grandTotal: totalAmount, installments: paymentAmounts },
|
|
483
|
-
},
|
|
484
|
-
validate,
|
|
485
|
-
card,
|
|
486
|
-
steps,
|
|
487
|
-
warnings: [...warnings, ...planBuild.warnings, ...fillWarnings],
|
|
488
|
-
note: validateOk
|
|
489
|
-
? '一次命令完成报价单解析、范文推荐、模板下载、位点扫描、方案装配、回填校验与出卡;产物可直接交付'
|
|
490
|
-
: '合同未通过校验,禁止交付;按 validate.fails 定位缺口后重跑',
|
|
491
|
-
},
|
|
492
|
-
};
|
|
493
|
-
},
|
|
494
|
-
},
|
|
495
|
-
];
|