weaver-work-cli 0.1.44 → 0.1.46
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 +9 -5
- package/dist/chunks/{archive-P6TBQGKL.js → archive-ZQ4A4TV6.js} +388 -44
- package/dist/chunks/{archive-oa-7TQ2NXOH.js → archive-oa-BBDP7AKJ.js} +2 -2
- package/dist/chunks/{asset-3ELRG37G.js → asset-ZOJVBWZH.js} +2 -2
- package/dist/chunks/{asset-idle-WIGMUFMD.js → asset-idle-XGB5IPGT.js} +2 -2
- package/dist/chunks/{attachment-content-E3276UOV.js → attachment-content-MCXQBD6N.js} +3 -3
- package/dist/chunks/{blog-C5NMZAAC.js → blog-QSHLZSFW.js} +2 -2
- package/dist/chunks/caizhilian-KCQYFH72.js +204 -0
- package/dist/chunks/{calendar-FI2WNSBO.js → calendar-DLGMRJQA.js} +2 -2
- package/dist/chunks/{chunk-PUQS5MWL.js → chunk-3YV7PKRL.js} +1 -1
- package/dist/chunks/{chunk-FAZTGX7S.js → chunk-4RWS2YYL.js} +5 -5
- package/dist/chunks/{chunk-GM6J7Q4B.js → chunk-6AXKWFKG.js} +32 -12
- package/dist/chunks/{chunk-ETNJSKMM.js → chunk-6NXT4ICB.js} +148 -21
- package/dist/chunks/{chunk-QVSWRLLU.js → chunk-6V5ZPKHV.js} +56 -12
- package/dist/chunks/chunk-762M5XJS.js +215 -0
- package/dist/chunks/{chunk-PC7VKEB5.js → chunk-76H3IKH6.js} +178 -37
- package/dist/chunks/{chunk-FRZKBMSW.js → chunk-AD46OMQK.js} +239 -41
- package/dist/chunks/{chunk-WSF4NNMR.js → chunk-CZNZKOHR.js} +2 -2
- package/dist/chunks/{chunk-TA7FXXJD.js → chunk-DLY5GUXX.js} +1 -1
- package/dist/chunks/{chunk-BCVYBYYT.js → chunk-GR76ZDDX.js} +2 -2
- package/dist/chunks/{chunk-CWYGFU5B.js → chunk-GSZTA43P.js} +2 -2
- package/dist/chunks/{chunk-GRDRG6HP.js → chunk-HFXK54M4.js} +2 -2
- package/dist/chunks/{chunk-N4M2DDFE.js → chunk-IP4CWQCF.js} +11 -11
- package/dist/chunks/{chunk-GAMZLAG2.js → chunk-IRMIEDXN.js} +1 -1
- package/dist/chunks/{chunk-XNIK66I4.js → chunk-JB34OE7R.js} +790 -77
- package/dist/chunks/{chunk-HIT4Y6OI.js → chunk-JFAWZX53.js} +134 -13
- package/dist/chunks/{chunk-D4ADSZ7H.js → chunk-O6CMPO65.js} +24 -1
- package/dist/chunks/{chunk-Z7VYWPZV.js → chunk-OXHHJWNC.js} +1 -1
- package/dist/chunks/chunk-P5GQRWDC.js +60 -0
- package/dist/chunks/{caizhilian-5XSM2DFP.js → chunk-PGO4ILMQ.js} +41 -521
- package/dist/chunks/{chunk-OF4S23UB.js → chunk-PSOMGA3U.js} +4 -4
- package/dist/chunks/{chunk-F4E4EM35.js → chunk-TGAGQV4I.js} +2 -2
- package/dist/chunks/{chunk-UFIT2UU3.js → chunk-U6R6FZHD.js} +168 -14
- package/dist/chunks/{chunk-XHK4MDR5.js → chunk-UFIFZ4YC.js} +48 -14
- package/dist/chunks/chunk-VRPH24IC.js +76 -0
- package/dist/chunks/{chunk-3YBDYOC4.js → chunk-YIKSL36S.js} +2 -2
- package/dist/chunks/{chunk-IAZ3UPY6.js → chunk-Z6UUBY37.js} +2 -2
- package/dist/chunks/{conflict-ARLSZJ6V.js → conflict-H7EHQXYY.js} +2 -2
- package/dist/chunks/continuation-GW6PRWK3.js +12 -0
- package/dist/chunks/{contract-DNIIW5VJ.js → contract-3QLAGYQL.js} +5793 -4591
- package/dist/chunks/{cowork-GMLRGVIW.js → cowork-3ACICHDQ.js} +2 -2
- package/dist/chunks/{create-flow-J22BO65E.js → create-flow-VRVJEOBX.js} +6 -6
- package/dist/chunks/{ebuilder-form-ANV2FHYV.js → ebuilder-form-GWDTKEI2.js} +5 -5
- package/dist/chunks/{ehr-GSTGAIY3.js → ehr-SH2LM3NK.js} +648 -88
- package/dist/chunks/{employee-22BGJ3QS.js → employee-NOHNXC46.js} +1 -1
- package/dist/chunks/{env-BX3VRFS7.js → env-66FPSJDV.js} +2 -2
- package/dist/chunks/{esb-ATAIASX2.js → esb-4BQHNP5C.js} +4 -4
- package/dist/chunks/{factory-PETTFME6.js → factory-UH2TZBVA.js} +1 -1
- package/dist/chunks/{fna-YEKBSFSX.js → fna-ZVB2IILI.js} +2 -2
- package/dist/chunks/{group-chat-BFVXAYFX.js → group-chat-CAKMMV7K.js} +3 -3
- package/dist/chunks/{host-WIKN2EJ5.js → host-3TNBMDTR.js} +3 -3
- package/dist/chunks/host-7NTIBSPK.js +25 -0
- package/dist/chunks/{host-SZGV4UNT.js → host-7OWWPLM4.js} +3 -3
- package/dist/chunks/{host-HRBXEPDQ.js → host-G3VU7SDW.js} +3 -3
- package/dist/chunks/{host-LR55CTHP.js → host-M4XP5URR.js} +3 -3
- package/dist/chunks/{host-SUOY6VYQ.js → host-TUOIOEMC.js} +3 -3
- package/dist/chunks/{hrm-NRDO4W5G.js → hrm-UNKCCCGP.js} +5 -5
- package/dist/chunks/{im-IQ2HN23S.js → im-NJB7ZYMH.js} +3 -3
- package/dist/chunks/{invoice-MNRW76PP.js → invoice-OQP3TMKQ.js} +3 -3
- package/dist/chunks/{jiuchuanhui-DTRBAX4N.js → jiuchuanhui-ASFZBMPU.js} +2 -2
- package/dist/chunks/{lazy-dispatch-ZVWAI25B.js → lazy-dispatch-DD6ULZ3I.js} +4 -4
- package/dist/chunks/{mail-ZVAUXOJA.js → mail-M3HJF5ER.js} +2 -2
- package/dist/chunks/{meeting-FEVPZ67S.js → meeting-VTBFW4HI.js} +12 -12
- package/dist/chunks/{okr-SDH3E5RA.js → okr-EVX7FB5G.js} +2 -2
- package/dist/chunks/operations-J7PUIVWZ.js +15 -0
- package/dist/chunks/{plan-E35JFDI7.js → plan-2QJQEPBO.js} +2 -2
- package/dist/chunks/{project-73QXBAB2.js → project-XELELW2T.js} +2 -2
- package/dist/chunks/{reception-UWZVACBN.js → reception-5WITA44R.js} +2 -2
- package/dist/chunks/{recruit-stage-4MAOCKFY.js → recruit-stage-CAKZTUA7.js} +1343 -178
- package/dist/chunks/{registry-JDUS4E7D.js → registry-AQVGHUM6.js} +2 -2
- package/dist/chunks/{registry-IM5G23LS.js → registry-JVQBLFQ5.js} +10 -10
- package/dist/chunks/{registry-KNKSCJNT.js → registry-QJCZ2GVG.js} +4 -4
- package/dist/chunks/{registry-PO7SI256.js → registry-VWXWPVAG.js} +2 -2
- package/dist/chunks/{room-recommend-H7KLXA5R.js → room-recommend-5U55FMXZ.js} +6 -4
- package/dist/chunks/{schedule-ESZIBAUO.js → schedule-IDETODCA.js} +4 -4
- package/dist/chunks/{workflow-CWJFJLQU.js → workflow-BSYT5TGL.js} +6 -4
- package/dist/cmd/action.js +14 -10
- package/dist/index.js +30 -30
- package/dist/internal/e10/auth/commands.js +32 -0
- package/dist/internal/e10/auth/error-log.js +156 -26
- package/dist/internal/e10/auth/xiaoe.js +176 -13
- package/dist/internal/e10/context.js +12 -1
- package/dist/shortcuts/archive/operations/borrow-list.js +105 -14
- package/dist/shortcuts/archive/operations/flow-url.js +182 -22
- package/dist/shortcuts/archive/operations/getPageUrl.js +75 -0
- package/dist/shortcuts/archive/operations/prelib.js +33 -4
- package/dist/shortcuts/archive/operations/shared.js +52 -0
- package/dist/shortcuts/contract/host.js +111 -4
- package/dist/shortcuts/contract/index.js +19 -0
- package/dist/shortcuts/contract/manifest.js +125 -0
- package/dist/shortcuts/contract/ooxml/clause-insert.js +249 -0
- package/dist/shortcuts/contract/operations/clause-insert.js +56 -0
- package/dist/shortcuts/contract/operations/customer.js +192 -0
- package/dist/shortcuts/contract/operations/file-download.js +75 -0
- package/dist/shortcuts/contract/operations/flow.js +44 -2
- package/dist/shortcuts/contract/operations/form-info.js +162 -62
- package/dist/shortcuts/contract/operations/registry.js +8 -0
- package/dist/shortcuts/contract/operations/review.js +116 -1
- package/dist/shortcuts/contract/operations/summary.js +177 -0
- package/dist/shortcuts/contract/operations/upload.js +64 -4
- package/dist/shortcuts/contract/upload-cache.js +104 -0
- package/dist/shortcuts/ehr/host.js +2 -2
- package/dist/shortcuts/ehr/index.js +14 -3
- package/dist/shortcuts/ehr/manifest.js +5 -1
- package/dist/shortcuts/ehr/operations/recruit-candidate-import.js +44 -12
- package/dist/shortcuts/ehr/operations/recruit-interview-overview.js +258 -0
- package/dist/shortcuts/ehr/operations/recruit-position.js +146 -43
- package/dist/shortcuts/ehr/operations/recruit-stats.js +14 -1
- package/dist/shortcuts/ehr/operations/recruit-tag.js +173 -0
- package/dist/shortcuts/ehr/operations/recruit-write.js +154 -36
- package/dist/shortcuts/ehr/operations/recruit.js +196 -12
- package/dist/shortcuts/ehr/operations/registry.js +4 -0
- package/dist/shortcuts/ehr/operations.js +24 -0
- package/dist/shortcuts/ehr/recruit-stage/batch-store.js +78 -0
- package/dist/shortcuts/ehr/recruit-stage/context.js +231 -0
- package/dist/shortcuts/ehr/recruit-stage/continuation.js +74 -0
- package/dist/shortcuts/ehr/recruit-stage/errors.js +65 -0
- package/dist/shortcuts/ehr/recruit-stage/fs-scan.js +165 -0
- package/dist/shortcuts/ehr/recruit-stage/host.js +109 -0
- package/dist/shortcuts/ehr/recruit-stage/operations/interview-arrange.js +1049 -0
- package/dist/shortcuts/ehr/recruit-stage/operations/interview-feedback.js +295 -0
- package/dist/shortcuts/ehr/recruit-stage/operations/jd-create.js +961 -0
- package/dist/shortcuts/ehr/recruit-stage/operations/list.js +431 -0
- package/dist/shortcuts/ehr/recruit-stage/operations/registry.js +50 -0
- package/dist/shortcuts/ehr/recruit-stage/operations/resume-import.js +1647 -0
- package/dist/shortcuts/ehr/recruit-stage/operations/search.js +158 -0
- package/dist/shortcuts/ehr/recruit-stage/operations/types.js +34 -0
- package/dist/shortcuts/ehr/recruit-stage/runtime.js +31 -0
- package/dist/shortcuts/ehr/recruit-stage/school-tiers.json +318 -0
- package/dist/shortcuts/ehr/recruit-stage/shared.js +805 -0
- package/dist/shortcuts/hrm/operations/employee.js +29 -1
- package/dist/shortcuts/meeting/operations/eb/create-flow.js +274 -75
- package/dist/shortcuts/meeting/operations/eb/draft-memory.js +56 -0
- package/dist/shortcuts/meeting/operations/eb/factory.js +63 -11
- package/dist/shortcuts/meeting/operations/eb/person-cache.js +2 -2
- package/dist/shortcuts/meeting/operations/eb/room-recommend.js +38 -7
- package/dist/shortcuts/meeting/operations/invitation-publish.js +132 -0
- package/dist/shortcuts/meeting/operations/invitation.js +27 -4
- package/dist/shortcuts/meeting/operations/registry.js +2 -0
- package/dist/shortcuts/recruit-stage/batch-store.js +78 -0
- package/dist/shortcuts/recruit-stage/fs-scan.js +165 -0
- package/dist/shortcuts/recruit-stage/operations/interview-arrange.js +356 -29
- package/dist/shortcuts/recruit-stage/operations/interview-feedback.js +36 -10
- package/dist/shortcuts/recruit-stage/operations/jd-create.js +309 -67
- package/dist/shortcuts/recruit-stage/operations/registry.js +12 -0
- package/dist/shortcuts/recruit-stage/operations/resume-import.js +310 -17
- package/dist/shortcuts/recruit-stage/operations/types.js +9 -0
- package/dist/shortcuts/recruit-stage/shared.js +221 -24
- package/dist/shortcuts/workflow/index.js +2 -0
- package/dist/shortcuts/workflow/operations/read.js +8 -3
- package/dist/shortcuts/workflow/operations/todoSmartConvert/aigroupRules.js +92 -5
- package/dist/shortcuts/workflow/operations/todoSmartConvert/priorityExpr.js +509 -0
- package/dist/shortcuts/workflow/operations/todoSmartConvert/todoListRows.js +22 -1
- package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.collect.js +32 -6
- package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.core.js +57 -11
- package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.group.js +165 -52
- package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.js +57 -14
- package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.smartGroup.js +44 -18
- package/docs/contract.md +1 -0
- package/docs/e10-auth.md +4 -2
- package/docs/todo-smart-convert/data-contract.md +7 -0
- package/package.json +1 -1
- package/skill-template/domains/jinchengda.md +2 -0
- package/skills/weaver-e10-jinchengda/SKILL.md +198 -205
- package/skills/weaver-e10-jinchengda/references/contract-action-card.md +759 -0
- package/skills/weaver-e10-jinchengda/references/contract-action-engine.md +250 -0
- package/skills/weaver-e10-jinchengda/references/contract-ai-review.md +146 -7
- package/skills/weaver-e10-jinchengda/references/contract-clause-insert.md +178 -0
- package/skills/weaver-e10-jinchengda/references/contract-command-index.md +75 -0
- package/skills/weaver-e10-jinchengda/references/contract-compare-report-template.html +137 -0
- package/skills/weaver-e10-jinchengda/references/contract-compare-report.md +163 -0
- package/skills/weaver-e10-jinchengda/references/contract-credit-page.md +52 -3
- package/skills/weaver-e10-jinchengda/references/contract-doc-compare.md +92 -5
- package/skills/weaver-e10-jinchengda/references/contract-doc-triage.md +602 -0
- package/skills/weaver-e10-jinchengda/references/contract-element-extract.md +209 -0
- package/skills/weaver-e10-jinchengda/references/contract-execution-rules.md +126 -0
- package/skills/weaver-e10-jinchengda/references/contract-field-extract-new-customer.md +312 -0
- package/skills/weaver-e10-jinchengda/references/contract-field-extract-other-flows.md +555 -0
- package/skills/weaver-e10-jinchengda/references/contract-flow-launch.md +47 -12
- package/skills/weaver-e10-jinchengda/references/contract-object-detect.md +469 -0
- package/skills/weaver-e10-jinchengda/references/contract-quote-to-contract.md +154 -1
- package/skills/weaver-e10-jinchengda/references/contract-type-fingerprints.md +224 -0
- package/skills/weaver-e10-jinchengda/references/orchestration.md +355 -0
- package/skills/weaver-e10-jucailin/SKILL.md +12 -3
- package/skills/weaver-e10-jucailin/archive/LEGACY-README.md +18 -0
- package/skills/weaver-e10-jucailin/archive/LEGACY-SKILL.md +239 -0
- package/skills/weaver-e10-jucailin/archive/LEGACY-openai.yaml +131 -0
- package/skills/weaver-e10-jucailin/archive/LEGACY-position-templates.md +221 -0
- package/skills/weaver-e10-jucailin/archive/LEGACY-recruit-arrange-interview.md +334 -0
- package/skills/weaver-e10-jucailin/archive/LEGACY-recruit-capability-check.md +127 -0
- package/skills/weaver-e10-jucailin/archive/LEGACY-recruit-check-install.md +65 -0
- package/skills/weaver-e10-jucailin/archive/LEGACY-recruit-detail-process.md +63 -0
- package/skills/weaver-e10-jucailin/archive/LEGACY-recruit-edit-interview-feedback.md +142 -0
- package/skills/weaver-e10-jucailin/archive/LEGACY-recruit-jd-create.md +114 -0
- package/skills/weaver-e10-jucailin/archive/LEGACY-recruit-jd-template.md +56 -0
- package/skills/weaver-e10-jucailin/archive/LEGACY-recruit-list-candidate.md +101 -0
- package/skills/weaver-e10-jucailin/archive/LEGACY-recruit-list-interview.md +148 -0
- package/skills/weaver-e10-jucailin/archive/LEGACY-recruit-match-candidates.md +77 -0
- package/skills/weaver-e10-jucailin/archive/LEGACY-recruit-output-links.md +72 -0
- package/skills/weaver-e10-jucailin/archive/LEGACY-recruit-resolve-creator.md +69 -0
- package/skills/weaver-e10-jucailin/archive/LEGACY-recruit-resolve-metadata.md +241 -0
- package/skills/weaver-e10-jucailin/archive/LEGACY-recruit-resume-import.md +457 -0
- package/skills/weaver-e10-jucailin/archive/LEGACY-recruit-resume-parse.md +128 -0
- package/skills/weaver-e10-jucailin/archive/LEGACY-recruit-search-candidate.md +146 -0
- package/skills/weaver-e10-jucailin/archive/LEGACY-recruit-urge-feedback.md +69 -0
- package/skills/weaver-e10-jucailin/lib/recruit-xiaoe-file.mjs +192 -0
- package/skills/weaver-e10-jucailin/lib/xiaoe-session.mjs +66 -0
- package/skills/weaver-e10-jucailin/references/recruit-create.md +19 -91
- package/skills/weaver-e10-jucailin/references/recruit-interview-overview.md +64 -0
- package/skills/weaver-e10-jucailin/references/recruit-read.md +63 -1
- package/skills/weaver-e10-jucailin/references/recruit-screening-to-interview-sop.md +95 -0
- package/skills/weaver-e10-jucailin/references/recruit-stage-ops.md +89 -0
- package/skills/weaver-e10-jucailin/references/recruit-tag.md +81 -0
- package/skills/weaver-e10-jucailin/references/recruit-write.md +55 -11
- package/skills/weaver-e10-meeting/SKILL.md +103 -11
- package/skills/weaver-e10-meeting/references/meeting-eb.md +1 -1
- package/skills/weaver-e10-recruit-stage/SKILL.md +19 -11
- package/skills/weaver-e10-recruit-stage/agents/openai.yaml +26 -8
- package/skills/weaver-e10-recruit-stage/lib/recruit-xiaoe-file.mjs +5 -1
- package/skills/weaver-e10-recruit-stage/references/position-templates.md +23 -2
- package/skills/weaver-e10-recruit-stage/references/recruit-arrange-interview.md +13 -1
- package/skills/weaver-e10-recruit-stage/references/recruit-jd-create.md +40 -18
- package/skills/weaver-e10-recruit-stage/references/recruit-output-links.md +27 -14
- package/skills/weaver-e10-recruit-stage/references/recruit-resume-import.md +11 -1
- package/skills/weaver-e10-shared/references/e10-auth-and-session.md +4 -2
- package/skills/weaver-e10-wenshuding/SKILL.md +17 -7
- package/skills/weaver-e10-wenshuding/references/archive-borrow-list.md +28 -0
- package/skills/weaver-e10-wenshuding/references/archive-flow.md +24 -8
- package/skills/weaver-e10-wenshuding/references/archive-prelib-list.md +3 -0
- package/skills/weaver-e10-wenshuding/references/archive-prelib-open.md +4 -0
- package/skills/weaver-e10-wenshuding/references/archive-search.md +3 -1
- package/skills/weaver-e10-workflow/SKILL.md +19 -17
- package/skills/weaver-e10-workflow/aigroup/default.json +10 -6
- package/skills/weaver-e10-workflow/references/todo-smart-convert.md +36 -3
- package/skills/weaver-e10-workflow/references/workflow-memory.md +1 -1
- package/skills/weaver-e10-workflow/references/workflow-query.md +9 -6
- package/skills/weaver-e10-workflow/tools/todo-summary.cjs +152 -1
- package/skills/weaver-e10-yimiaoban/SKILL.md +17 -5
- package/skills/weaver-e10-yimiaoban/references/msg-write.md +30 -0
- package/skills/weaver-e10-yimiaoban/references/session-sysmsg.md +72 -0
- package/skills/weaver-e10-yimiaoban/references/source-manifest.json +7 -7
|
@@ -108,6 +108,38 @@ function parseFrame(data, nodeId) {
|
|
|
108
108
|
enable_node_permission: config.enableNodePermission !== false,
|
|
109
109
|
};
|
|
110
110
|
}
|
|
111
|
+
/**
|
|
112
|
+
* 表单类接口的 `customParam`——权限与授权的全部上下文都在这一个对象里。
|
|
113
|
+
*
|
|
114
|
+
* 这份字面量来自本仓库**已被线上验证可用**的 `getFormLayout` 请求(同一租户、同一表单、同一会话),
|
|
115
|
+
* `contract.customer.browser` 等"点浏览按钮"的接口必须原样复用,不要自己裁剪子集:
|
|
116
|
+
* 少一个键不会报错,只会静默改变数据权限过滤范围,表现为"查得到但条目偏少"。
|
|
117
|
+
*/
|
|
118
|
+
export function formCustomParam(workflowId, runtime, frame) {
|
|
119
|
+
return {
|
|
120
|
+
permissionType: frame.permission_type,
|
|
121
|
+
requestId: runtime.request_id,
|
|
122
|
+
workflowId,
|
|
123
|
+
nodeId: runtime.node_id,
|
|
124
|
+
authSignatureStr: runtime.auth_signature,
|
|
125
|
+
authStr: runtime.auth_str,
|
|
126
|
+
readOnly: false,
|
|
127
|
+
identityId: runtime.identity_id,
|
|
128
|
+
identityType: runtime.identity_type,
|
|
129
|
+
isTest: false,
|
|
130
|
+
create: true,
|
|
131
|
+
mobile: false,
|
|
132
|
+
formId: frame.form_id,
|
|
133
|
+
source: 'view',
|
|
134
|
+
isAgent: false,
|
|
135
|
+
beAgentId: '0',
|
|
136
|
+
hideSysFieldArea: true,
|
|
137
|
+
viewFormNodeId: frame.view_form_node_id,
|
|
138
|
+
timestamp: frame.timestamp,
|
|
139
|
+
turnTodoUser: [],
|
|
140
|
+
sysFieldNewMode: frame.sys_field_new_mode,
|
|
141
|
+
};
|
|
142
|
+
}
|
|
111
143
|
/** getFormLayout 请求体(对应 workflow 模块的 buildLayoutRequest)。 */
|
|
112
144
|
function buildLayoutRequest(workflowId, runtime, frame) {
|
|
113
145
|
const permissionId = String(frame.permission_id ?? '').trim();
|
|
@@ -117,29 +149,7 @@ function buildLayoutRequest(workflowId, runtime, frame) {
|
|
|
117
149
|
formId: frame.form_id,
|
|
118
150
|
...(nodePermissionEnabled && permissionId ? { permissionId } : {}),
|
|
119
151
|
module: 'workflow',
|
|
120
|
-
customParam:
|
|
121
|
-
permissionType: frame.permission_type,
|
|
122
|
-
requestId: runtime.request_id,
|
|
123
|
-
workflowId,
|
|
124
|
-
nodeId: runtime.node_id,
|
|
125
|
-
authSignatureStr: runtime.auth_signature,
|
|
126
|
-
authStr: runtime.auth_str,
|
|
127
|
-
readOnly: false,
|
|
128
|
-
identityId: runtime.identity_id,
|
|
129
|
-
identityType: runtime.identity_type,
|
|
130
|
-
isTest: false,
|
|
131
|
-
create: true,
|
|
132
|
-
mobile: false,
|
|
133
|
-
formId: frame.form_id,
|
|
134
|
-
source: 'view',
|
|
135
|
-
isAgent: false,
|
|
136
|
-
beAgentId: '0',
|
|
137
|
-
hideSysFieldArea: true,
|
|
138
|
-
viewFormNodeId: frame.view_form_node_id,
|
|
139
|
-
timestamp: frame.timestamp,
|
|
140
|
-
turnTodoUser: [],
|
|
141
|
-
sysFieldNewMode: frame.sys_field_new_mode,
|
|
142
|
-
},
|
|
152
|
+
customParam: formCustomParam(workflowId, runtime, frame),
|
|
143
153
|
cacheUid: randomUUID(),
|
|
144
154
|
newLayout: frame.new_layout,
|
|
145
155
|
layoutMultiId: frame.layout_multi_id,
|
|
@@ -174,18 +184,22 @@ function viewRelateMaps(layoutData) {
|
|
|
174
184
|
/**
|
|
175
185
|
* 读布局页签结构,与 workflow 模块的 parseLayoutMeta 同源:
|
|
176
186
|
* - `hidePositions`:Excel 布局里 `attrs.hide` 的格子坐标,落在这些位置的字段视为不可见
|
|
177
|
-
* - `compsFieldIds
|
|
187
|
+
* - `compsFieldIds`:**所有页签** `comps[].config.fieldId`,主表字段必须在此白名单内
|
|
178
188
|
* 明细表字段不受此约束(它们挂在 detailtable 组件下,不出现在页面 comps 里)
|
|
189
|
+
*
|
|
190
|
+
* 2026-11-03 修正:原先只读 `pageLayouts[0]`,导致**第二页及以后的主表字段被整条过滤掉**,
|
|
191
|
+
* 表现为「表单里明明有、form.info 里查不到」——O-3c 的字段对不上就是被这个假象带偏的。
|
|
179
192
|
*/
|
|
180
193
|
function parseLayoutMeta(layoutData) {
|
|
181
194
|
const hiddenCellIds = new Set();
|
|
182
195
|
const compsFieldIds = new Set();
|
|
183
|
-
let page0 = null;
|
|
184
196
|
const pageLayouts = layoutData && layoutData.formLayout ? layoutData.formLayout.pageLayouts : undefined;
|
|
185
|
-
if (Array.isArray(pageLayouts)
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
197
|
+
if (!Array.isArray(pageLayouts))
|
|
198
|
+
return { hiddenCellIds, compsFieldIds };
|
|
199
|
+
for (const page of pageLayouts) {
|
|
200
|
+
if (!page || typeof page !== 'object')
|
|
201
|
+
continue;
|
|
202
|
+
const workbook = (page.config && page.config.workbook) ? page.config.workbook : {};
|
|
189
203
|
const cells = workbook.Sheet1 ? workbook.Sheet1.cells : null;
|
|
190
204
|
const hidePositions = new Set();
|
|
191
205
|
if (Array.isArray(cells)) {
|
|
@@ -197,7 +211,7 @@ function parseLayoutMeta(layoutData) {
|
|
|
197
211
|
hidePositions.add(`${cell.col}:${cell.row}`);
|
|
198
212
|
}
|
|
199
213
|
}
|
|
200
|
-
for (const comp of
|
|
214
|
+
for (const comp of page.comps || []) {
|
|
201
215
|
if (!comp || typeof comp !== 'object')
|
|
202
216
|
continue;
|
|
203
217
|
const cfg = comp.config || {};
|
|
@@ -295,6 +309,123 @@ function extractFields(layoutData) {
|
|
|
295
309
|
});
|
|
296
310
|
return result;
|
|
297
311
|
}
|
|
312
|
+
/**
|
|
313
|
+
* 附件类组件(发起时把合同文件挂到这类字段上)。
|
|
314
|
+
* 与 workflow 模块一致:E10 的上传控件 `componentKey` 是 `FileComponent`。
|
|
315
|
+
*/
|
|
316
|
+
const UPLOAD_COMPONENTS = new Set(['filecomponent', 'file', 'files', 'attachment', 'attachments', 'uploadfile']);
|
|
317
|
+
/**
|
|
318
|
+
* 从布局树里收集**主表**附件字段(O-3c 的判定依据)。
|
|
319
|
+
*
|
|
320
|
+
* 两处刻意与 `extractFields` 不同:
|
|
321
|
+
* - **不走 comps 白名单**:附件字段可能被藏在非首页签或隐藏格子里,但它仍是合法上传目标;
|
|
322
|
+
* - **排除明细表字段**:明细里的附件挂不住"整份合同"这个文件,挂上去等于丢附件。
|
|
323
|
+
*/
|
|
324
|
+
export function listUploadFields(layoutData) {
|
|
325
|
+
const picked = new Map();
|
|
326
|
+
const walk = (value) => {
|
|
327
|
+
if (Array.isArray(value)) {
|
|
328
|
+
for (const child of value)
|
|
329
|
+
walk(child);
|
|
330
|
+
return;
|
|
331
|
+
}
|
|
332
|
+
if (!value || typeof value !== 'object')
|
|
333
|
+
return;
|
|
334
|
+
const fieldId = String(value.fieldId ?? '').trim();
|
|
335
|
+
const component = String(value.componentKey ?? value.type ?? '').trim().toLowerCase();
|
|
336
|
+
if (fieldId && UPLOAD_COMPONENTS.has(component)) {
|
|
337
|
+
const previous = picked.get(fieldId);
|
|
338
|
+
if (previous === undefined || Object.keys(value).length > Object.keys(previous).length) {
|
|
339
|
+
picked.set(fieldId, value);
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
for (const child of Object.values(value))
|
|
343
|
+
walk(child);
|
|
344
|
+
};
|
|
345
|
+
walk((layoutData ?? {}).formLayout);
|
|
346
|
+
const result = [];
|
|
347
|
+
for (const [fieldId, raw] of picked) {
|
|
348
|
+
if (String(raw.subFormId ?? '').trim())
|
|
349
|
+
continue;
|
|
350
|
+
result.push({ fieldId, title: String(raw.title ?? raw.name ?? fieldId) });
|
|
351
|
+
}
|
|
352
|
+
return result;
|
|
353
|
+
}
|
|
354
|
+
/**
|
|
355
|
+
* 只做判定、不抛错——给诊断型只读 operation 用(`contract.flow.upload-field`)。
|
|
356
|
+
* 真正发起时要走 `resolveUploadFieldId`,它会在判不出来时阻断。
|
|
357
|
+
*/
|
|
358
|
+
export function inspectUploadField(layoutData, presetFieldId) {
|
|
359
|
+
const preset = String(presetFieldId ?? '').trim();
|
|
360
|
+
const candidates = listUploadFields(layoutData);
|
|
361
|
+
const ids = candidates.map((candidate) => candidate.fieldId);
|
|
362
|
+
if (preset && ids.includes(preset)) {
|
|
363
|
+
return { state: 'preset', fieldId: preset, presetFieldId: preset, candidates };
|
|
364
|
+
}
|
|
365
|
+
if (candidates.length === 1) {
|
|
366
|
+
return { state: 'layout', fieldId: candidates[0].fieldId, presetFieldId: preset, candidates };
|
|
367
|
+
}
|
|
368
|
+
if (candidates.length === 0) {
|
|
369
|
+
return { state: 'missing', fieldId: null, presetFieldId: preset, candidates };
|
|
370
|
+
}
|
|
371
|
+
return { state: 'ambiguous', fieldId: null, presetFieldId: preset, candidates };
|
|
372
|
+
}
|
|
373
|
+
/**
|
|
374
|
+
* 发起流程前解析上传字段:预设 → 布局唯一 → 阻断。
|
|
375
|
+
*
|
|
376
|
+
* **不兜底**:判不出来就报错,绝不把文件往一个"大概是附件"的字段上塞——
|
|
377
|
+
* 挂错字段不会报错,只会让合同发起后正文里看不到文件(静默丢附件)。
|
|
378
|
+
*/
|
|
379
|
+
export function resolveUploadFieldId(layoutData, presetFieldId, label) {
|
|
380
|
+
const inspection = inspectUploadField(layoutData, presetFieldId);
|
|
381
|
+
if (inspection.state === 'preset' || inspection.state === 'layout')
|
|
382
|
+
return inspection;
|
|
383
|
+
const listed = inspection.candidates.map((candidate) => `${candidate.fieldId}(${candidate.title})`).join(' / ');
|
|
384
|
+
if (inspection.state === 'missing') {
|
|
385
|
+
throw contractValidationError('upload_field_missing', `${label} 的表单布局里找不到主表附件字段(FileComponent),已停止上传:挂到不存在的字段会静默丢附件`, { presetFieldId: inspection.presetFieldId });
|
|
386
|
+
}
|
|
387
|
+
throw contractValidationError('upload_field_ambiguous', `${label} 的表单里有多个主表附件字段:${listed};请指定要挂哪一个,不能替用户选择`, { presetFieldId: inspection.presetFieldId, candidates: inspection.candidates });
|
|
388
|
+
}
|
|
389
|
+
/**
|
|
390
|
+
* `loadBaseParam → loadFrameParam → getFormLayout` 三段式,串成一次可复用的表单上下文读取。
|
|
391
|
+
*
|
|
392
|
+
* 从 `contract.workflow.form.info` 内部抽出,供 form.info 与 `contract.customer.browser` 共用,
|
|
393
|
+
* 避免同一串请求在多处各写一遍(写两遍必然漂移)。
|
|
394
|
+
*/
|
|
395
|
+
export async function loadFormContext(host, workflowId) {
|
|
396
|
+
const query = { workflowId, isCreate: 1, ...AJAX_QUERY };
|
|
397
|
+
const base = { workflowId, isCreate: 1, isMobile: 0 };
|
|
398
|
+
const baseValue = await host.contractRequest({
|
|
399
|
+
method: 'POST',
|
|
400
|
+
path: FORM_INFO_ENDPOINTS.loadBase,
|
|
401
|
+
query,
|
|
402
|
+
body: base,
|
|
403
|
+
});
|
|
404
|
+
const frameValue = await host.contractRequest({
|
|
405
|
+
method: 'POST',
|
|
406
|
+
path: FORM_INFO_ENDPOINTS.loadFrame,
|
|
407
|
+
query,
|
|
408
|
+
body: base,
|
|
409
|
+
});
|
|
410
|
+
const runtime = parseRuntime(unwrapPayload(baseValue), workflowId);
|
|
411
|
+
const frame = parseFrame(unwrapPayload(frameValue), runtime.node_id);
|
|
412
|
+
const layoutPath = formApiUrl(FORM_INFO_ENDPOINTS.formLayout, frame.relate_type);
|
|
413
|
+
const layoutValue = await host.contractRequest({
|
|
414
|
+
method: 'POST',
|
|
415
|
+
path: layoutPath,
|
|
416
|
+
query: { formId: frame.form_id, ...AJAX_QUERY },
|
|
417
|
+
body: buildLayoutRequest(workflowId, runtime, frame),
|
|
418
|
+
});
|
|
419
|
+
const layout = unwrapPayload(layoutValue);
|
|
420
|
+
if (!layout || typeof layout !== 'object') {
|
|
421
|
+
throw contractValidationError('format_error', 'getFormLayout 未返回有效 data');
|
|
422
|
+
}
|
|
423
|
+
const returnedFormId = String((layout.form ?? {}).id ?? '');
|
|
424
|
+
if (returnedFormId && returnedFormId !== frame.form_id) {
|
|
425
|
+
throw contractValidationError('format_error', 'getFormLayout 返回了不同的 formId');
|
|
426
|
+
}
|
|
427
|
+
return { workflowId, layoutPath, runtime, frame, layout, fields: extractFields(layout) };
|
|
428
|
+
}
|
|
298
429
|
/**
|
|
299
430
|
* `contract.workflow.form.info`:读流程发起表单的字段定义。
|
|
300
431
|
* 输入只需 `workflowId`;三段式内部的中间值(formId / requestId / nodeId)由实现自行串联。
|
|
@@ -304,38 +435,7 @@ export const contractWorkflowFormInfoOperation = {
|
|
|
304
435
|
async execute(input, context) {
|
|
305
436
|
const { host } = context;
|
|
306
437
|
const workflowId = requireId(input.workflowId, 'workflowId');
|
|
307
|
-
const
|
|
308
|
-
const base = { workflowId, isCreate: 1, isMobile: 0 };
|
|
309
|
-
const baseValue = await host.contractRequest({
|
|
310
|
-
method: 'POST',
|
|
311
|
-
path: FORM_INFO_ENDPOINTS.loadBase,
|
|
312
|
-
query,
|
|
313
|
-
body: base,
|
|
314
|
-
});
|
|
315
|
-
const frameValue = await host.contractRequest({
|
|
316
|
-
method: 'POST',
|
|
317
|
-
path: FORM_INFO_ENDPOINTS.loadFrame,
|
|
318
|
-
query,
|
|
319
|
-
body: base,
|
|
320
|
-
});
|
|
321
|
-
const runtime = parseRuntime(unwrapPayload(baseValue), workflowId);
|
|
322
|
-
const frame = parseFrame(unwrapPayload(frameValue), runtime.node_id);
|
|
323
|
-
const layoutPath = formApiUrl(FORM_INFO_ENDPOINTS.formLayout, frame.relate_type);
|
|
324
|
-
const layoutValue = await host.contractRequest({
|
|
325
|
-
method: 'POST',
|
|
326
|
-
path: layoutPath,
|
|
327
|
-
query: { formId: frame.form_id, ...AJAX_QUERY },
|
|
328
|
-
body: buildLayoutRequest(workflowId, runtime, frame),
|
|
329
|
-
});
|
|
330
|
-
const layout = unwrapPayload(layoutValue);
|
|
331
|
-
if (!layout || typeof layout !== 'object') {
|
|
332
|
-
throw contractValidationError('format_error', 'getFormLayout 未返回有效 data');
|
|
333
|
-
}
|
|
334
|
-
const returnedFormId = String((layout.form ?? {}).id ?? '');
|
|
335
|
-
if (returnedFormId && returnedFormId !== frame.form_id) {
|
|
336
|
-
throw contractValidationError('format_error', 'getFormLayout 返回了不同的 formId');
|
|
337
|
-
}
|
|
338
|
-
const fields = extractFields(layout);
|
|
438
|
+
const { layoutPath, runtime, frame, layout, fields, } = await loadFormContext(host, workflowId);
|
|
339
439
|
const requiredFields = fields.filter((field) => field.required).map((field) => field.id);
|
|
340
440
|
const subFormRequired = {};
|
|
341
441
|
for (const field of fields) {
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { contractValidationError } from '../errors.js';
|
|
2
2
|
import { contractOperations } from '../manifest.js';
|
|
3
3
|
import { contractAssistantOperations } from './assistant.js';
|
|
4
|
+
import { contractClauseInsertOperations } from './clause-insert.js';
|
|
4
5
|
import { contractClauseLibraryOperations } from './clause-library.js';
|
|
5
6
|
import { contractClauseReferenceOperations } from './clause-reference.js';
|
|
6
7
|
import { contractCompareOperations } from './compare.js';
|
|
7
8
|
import { contractCreditPageOperations } from './credit-page.js';
|
|
9
|
+
import { contractCustomerOperations } from './customer.js';
|
|
10
|
+
import { contractFileDownloadOperations } from './file-download.js';
|
|
8
11
|
import { contractFlowOperations } from './flow.js';
|
|
9
12
|
import { contractPerformanceOperations } from './performance.js';
|
|
10
13
|
import { contractQuoteOperations } from './quote.js';
|
|
@@ -12,6 +15,7 @@ import { contractRecommendOperations } from './recommend.js';
|
|
|
12
15
|
import { contractRequestOperations } from './request.js';
|
|
13
16
|
import { contractReviewOperations } from './review.js';
|
|
14
17
|
import { contractSubjectOperations } from './subject.js';
|
|
18
|
+
import { contractSummaryOperations } from './summary.js';
|
|
15
19
|
import { contractTemplateOperations } from './template.js';
|
|
16
20
|
import { contractWorkflowOperations } from './workflow.js';
|
|
17
21
|
function buildRegistry() {
|
|
@@ -19,17 +23,21 @@ function buildRegistry() {
|
|
|
19
23
|
const handlers = [
|
|
20
24
|
...contractTemplateOperations,
|
|
21
25
|
...contractClauseLibraryOperations,
|
|
26
|
+
...contractClauseInsertOperations,
|
|
22
27
|
...contractClauseReferenceOperations,
|
|
23
28
|
...contractSubjectOperations,
|
|
29
|
+
...contractCustomerOperations,
|
|
24
30
|
...contractWorkflowOperations,
|
|
25
31
|
...contractRequestOperations,
|
|
26
32
|
...contractReviewOperations,
|
|
33
|
+
...contractFileDownloadOperations,
|
|
27
34
|
...contractFlowOperations,
|
|
28
35
|
...contractRecommendOperations,
|
|
29
36
|
...contractCompareOperations,
|
|
30
37
|
...contractCreditPageOperations,
|
|
31
38
|
...contractAssistantOperations,
|
|
32
39
|
...contractPerformanceOperations,
|
|
40
|
+
...contractSummaryOperations,
|
|
33
41
|
...contractQuoteOperations,
|
|
34
42
|
];
|
|
35
43
|
for (const handler of handlers) {
|
|
@@ -4,8 +4,51 @@ import { requireNonEmptyString } from './shared.js';
|
|
|
4
4
|
import { assertContractDocument, uploadFile } from './upload.js';
|
|
5
5
|
/** 固定 AI 审查助手 ID,只用于导出审查记录接口,不要拼到审查页地址上。 */
|
|
6
6
|
export const AI_REVIEW_ASSISTANT_ID = '1326842382967570463';
|
|
7
|
+
/**
|
|
8
|
+
* 预审预热流程 ID(固定业务常量,禁止替换)。
|
|
9
|
+
*
|
|
10
|
+
* `saveInternalRecord` 是合同预审的预处理接口:调用后服务端即开始跑预审,
|
|
11
|
+
* 用户真正打开审查页时结果已就绪。因为预审耗时较长,故在上传成功那一刻就触发。
|
|
12
|
+
*/
|
|
13
|
+
export const AI_REVIEW_PREWARM_FLOW_ID = '1269716062340284522';
|
|
14
|
+
const PREWARM_PATH = '/api/ebd/contract/ai/saveInternalRecord';
|
|
15
|
+
const PREWARM_TIMEOUT_MS = 30_000;
|
|
16
|
+
const PREWARM_ERROR = 'prewarm_error';
|
|
7
17
|
const MAX_FILES = 10;
|
|
8
18
|
const SCLX_PATTERN = /^[1-3](?:,[1-3]){0,2}$/u;
|
|
19
|
+
/**
|
|
20
|
+
* 触发预审预热。
|
|
21
|
+
*
|
|
22
|
+
* 刻意**不抛出异常**:预热只是加速手段,失败不影响上传与后续审查,
|
|
23
|
+
* 因此把失败收敛成 `{ ok: false, error }` 交给调用方汇总成 warnings。
|
|
24
|
+
*/
|
|
25
|
+
async function prewarmOne(host, fileId) {
|
|
26
|
+
try {
|
|
27
|
+
await host.contractRequest({
|
|
28
|
+
method: 'POST',
|
|
29
|
+
path: PREWARM_PATH,
|
|
30
|
+
body: { flowId: AI_REVIEW_PREWARM_FLOW_ID, fileId },
|
|
31
|
+
timeoutMs: PREWARM_TIMEOUT_MS,
|
|
32
|
+
// 触发型接口:成功时响应体为空,代表"预审已在执行"。
|
|
33
|
+
// 不能走业务码判定,否则空体会被判成业务失败。
|
|
34
|
+
okOnHttpSuccess: true,
|
|
35
|
+
});
|
|
36
|
+
return { fileId, ok: true };
|
|
37
|
+
}
|
|
38
|
+
catch (error) {
|
|
39
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
40
|
+
const structured = error;
|
|
41
|
+
const code = structured?.code === undefined ? '' : ` code=${String(structured.code)}`;
|
|
42
|
+
const raw = typeof structured?.details?.raw === 'string'
|
|
43
|
+
? ` raw=${String(structured.details.raw).slice(0, 300)}`
|
|
44
|
+
: '';
|
|
45
|
+
return { fileId, ok: false, error: `${message}${code}${raw}` };
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
/** 多文件并行预热,避免串行累加等待。 */
|
|
49
|
+
async function prewarmAll(host, fileIds) {
|
|
50
|
+
return Promise.all(fileIds.map((fileId) => prewarmOne(host, fileId)));
|
|
51
|
+
}
|
|
9
52
|
function normalizeSclx(value) {
|
|
10
53
|
if (value === undefined || value === null || value === '')
|
|
11
54
|
return '1,2,3';
|
|
@@ -43,14 +86,86 @@ export const contractReviewOperations = [
|
|
|
43
86
|
assertContractDocument(path);
|
|
44
87
|
files.push(await uploadFile(host, { path, module: 'ebContract' }));
|
|
45
88
|
}
|
|
89
|
+
// ---- 默认行为:上传成功即触发预审预热 ----
|
|
90
|
+
// 预审本身较慢,等到用户点"预审"才开始跑会白等;因此在这里就把预审排上队。
|
|
91
|
+
// 预热失败不影响上传结果,只记 warning(用户仍可正常打开审查页,只是要等)。
|
|
92
|
+
const prewarmEnabled = input.prewarm !== false;
|
|
93
|
+
const prewarm = prewarmEnabled
|
|
94
|
+
? await prewarmAll(host, files.map((file) => file.fileId))
|
|
95
|
+
: null;
|
|
96
|
+
const warnings = (prewarm ?? [])
|
|
97
|
+
.filter((item) => !item.ok)
|
|
98
|
+
.map((item) => `预审预热失败(fileId ${item.fileId}):${item.error}`);
|
|
99
|
+
if (!prewarmEnabled) {
|
|
100
|
+
warnings.push('已按 prewarm=false 跳过预审预热,打开审查页时才会开始跑预审');
|
|
101
|
+
}
|
|
46
102
|
const session = await host.getSession();
|
|
47
103
|
return {
|
|
48
104
|
status: 'COMPLETE',
|
|
49
105
|
data: {
|
|
50
106
|
files,
|
|
107
|
+
prewarm: prewarm
|
|
108
|
+
? {
|
|
109
|
+
flowId: AI_REVIEW_PREWARM_FLOW_ID,
|
|
110
|
+
enabled: true,
|
|
111
|
+
okCount: prewarm.filter((item) => item.ok).length,
|
|
112
|
+
failCount: prewarm.filter((item) => !item.ok).length,
|
|
113
|
+
results: prewarm,
|
|
114
|
+
}
|
|
115
|
+
: { flowId: AI_REVIEW_PREWARM_FLOW_ID, enabled: false },
|
|
116
|
+
warnings,
|
|
51
117
|
url: reviewPageUrl(session.baseUrl, files),
|
|
52
118
|
page: { width: 1000 },
|
|
53
|
-
note: '
|
|
119
|
+
note: '上传完成并已触发预审预热;把 url 原样放进 browsertool 的 arguments.url,并带 width: 1000;不要做整体编码',
|
|
120
|
+
},
|
|
121
|
+
};
|
|
122
|
+
},
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
name: 'contract.review.prewarm',
|
|
126
|
+
async execute(input, { host }) {
|
|
127
|
+
const fileId = requireNonEmptyString(input.fileId, 'fileId', 64).trim();
|
|
128
|
+
if (input.fileIds !== undefined) {
|
|
129
|
+
throw contractValidationError('input_conflict', 'fileId 与 fileIds 只能二选一');
|
|
130
|
+
}
|
|
131
|
+
const result = await prewarmOne(host, fileId);
|
|
132
|
+
if (!result.ok) {
|
|
133
|
+
// 独立调用时用户是显式要预热,失败要如实报错而不是静默吞掉。
|
|
134
|
+
throw new Error(`预审预热失败:${result.error}`);
|
|
135
|
+
}
|
|
136
|
+
return {
|
|
137
|
+
status: 'COMPLETE',
|
|
138
|
+
data: {
|
|
139
|
+
fileId,
|
|
140
|
+
flowId: AI_REVIEW_PREWARM_FLOW_ID,
|
|
141
|
+
prewarmed: true,
|
|
142
|
+
note: '已触发预审预处理,服务端开始跑预审;稍后打开审查页即可看到结果',
|
|
143
|
+
},
|
|
144
|
+
};
|
|
145
|
+
},
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
name: 'contract.review.prewarm.batch',
|
|
149
|
+
async execute(input, { host }) {
|
|
150
|
+
const raw = input.fileIds;
|
|
151
|
+
if (!Array.isArray(raw) || raw.length === 0) {
|
|
152
|
+
throw contractValidationError('file_ids_required', 'fileIds 必须是非空的 fileId 数组');
|
|
153
|
+
}
|
|
154
|
+
if (raw.length > MAX_FILES) {
|
|
155
|
+
throw contractValidationError('file_ids_too_many', `一次最多预热 ${MAX_FILES} 份文件`);
|
|
156
|
+
}
|
|
157
|
+
const fileIds = raw.map((item, index) => requireNonEmptyString(item, `fileIds[${index}]`, 64).trim());
|
|
158
|
+
const results = await prewarmAll(host, fileIds);
|
|
159
|
+
return {
|
|
160
|
+
status: results.every((item) => item.ok) ? 'COMPLETE' : 'PARTIAL',
|
|
161
|
+
data: {
|
|
162
|
+
flowId: AI_REVIEW_PREWARM_FLOW_ID,
|
|
163
|
+
okCount: results.filter((item) => item.ok).length,
|
|
164
|
+
failCount: results.filter((item) => !item.ok).length,
|
|
165
|
+
results,
|
|
166
|
+
warnings: results
|
|
167
|
+
.filter((item) => !item.ok)
|
|
168
|
+
.map((item) => `预审预热失败(fileId ${item.fileId}):${item.error}`),
|
|
54
169
|
},
|
|
55
170
|
};
|
|
56
171
|
},
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import { readFileSync, writeFileSync } from 'node:fs';
|
|
2
|
+
import { basename, resolve } from 'node:path';
|
|
3
|
+
import { contractValidationError } from '../errors.js';
|
|
4
|
+
import { requireNonEmptyString } from './shared.js';
|
|
5
|
+
/**
|
|
6
|
+
* 合同摘要 HTML 渲染(本地,零依赖)。
|
|
7
|
+
*
|
|
8
|
+
* 定位:模型只产出紧凑的数据 JSON(约 1~2 KB),HTML/CSS 由本 operation 生成。
|
|
9
|
+
* 手写 7 KB HTML 是首屏最大耗时来源,渲染下沉到 CLI 后模型输出量减少约 3/4。
|
|
10
|
+
*/
|
|
11
|
+
const CSS = [
|
|
12
|
+
'body{margin:0;padding:24px 20px;background:#f5f7fa;color:#1f2430;',
|
|
13
|
+
'font-family:"Microsoft YaHei","PingFang SC",sans-serif;font-size:14px;line-height:1.65}',
|
|
14
|
+
'.w{max-width:1040px;margin:0 auto}',
|
|
15
|
+
'.hd,.s{background:#fff;border:1px solid #e2e8f0;border-radius:8px;padding:18px 20px;margin-bottom:14px}',
|
|
16
|
+
'.bd{display:inline-block;padding:3px 14px;border-radius:16px;background:#1d6fd8;color:#fff;',
|
|
17
|
+
'font-size:13px;font-weight:700}',
|
|
18
|
+
'h1{font-size:19px;margin:10px 0 6px;line-height:1.4}',
|
|
19
|
+
'.mt{color:#5b6577;font-size:12px}',
|
|
20
|
+
'h2{font-size:15px;margin:0 0 12px;padding-left:9px;border-left:4px solid #1d6fd8}',
|
|
21
|
+
'g{display:grid;grid-template-columns:150px 1fr;border-top:1px solid #e6ebf2}',
|
|
22
|
+
'g>div{padding:8px 10px;border-bottom:1px solid #e6ebf2}',
|
|
23
|
+
'g>.k{background:#f8fafc;color:#46506a;font-weight:600}',
|
|
24
|
+
'ul{margin:0;padding-left:20px}li{margin-bottom:4px}',
|
|
25
|
+
'table{border-collapse:collapse;width:100%;font-size:13px}',
|
|
26
|
+
'th,td{border:1px solid #dde3ec;padding:7px 9px}',
|
|
27
|
+
'th{background:#eef3fb;text-align:left;white-space:nowrap}',
|
|
28
|
+
'td.n{text-align:right}',
|
|
29
|
+
'tr.t td{background:#f7f9fc;font-weight:700}',
|
|
30
|
+
'.na{color:#98a2b3}',
|
|
31
|
+
'.wn{background:#fff8e6;border:1px solid #f2d48a;border-radius:6px;padding:10px 12px;margin-bottom:10px}',
|
|
32
|
+
'.er{background:#fdeceb;border:1px solid #f0b4ae;border-radius:6px;padding:10px 12px;margin-bottom:10px}',
|
|
33
|
+
'.ok{background:#f1f9f2;border:1px solid #b7dfc0;border-radius:6px;padding:10px 12px;margin-bottom:10px}',
|
|
34
|
+
'.nt{color:#7a8497;font-size:12px;margin:6px 0 0}',
|
|
35
|
+
].join('');
|
|
36
|
+
function esc(value) {
|
|
37
|
+
return String(value ?? '')
|
|
38
|
+
.replace(/&/gu, '&')
|
|
39
|
+
.replace(/</gu, '<')
|
|
40
|
+
.replace(/>/gu, '>');
|
|
41
|
+
}
|
|
42
|
+
function asArray(value) {
|
|
43
|
+
return Array.isArray(value) ? value : [];
|
|
44
|
+
}
|
|
45
|
+
function sectionHtml(section) {
|
|
46
|
+
const type = String(section.type ?? '');
|
|
47
|
+
const title = section.title ? `<h2>${esc(section.title)}</h2>` : '';
|
|
48
|
+
if (type === 'alert') {
|
|
49
|
+
const level = section.level === 'error' ? 'er' : 'wn';
|
|
50
|
+
return `<div class="s">${title}<div class="${level}">${esc(section.text)}</div></div>`;
|
|
51
|
+
}
|
|
52
|
+
const parts = [`<div class="s">${title}`];
|
|
53
|
+
if (type === 'reasons') {
|
|
54
|
+
if (section.lead)
|
|
55
|
+
parts.push(`<p style="margin:0 0 8px">${esc(section.lead)}</p>`);
|
|
56
|
+
const items = asArray(section.items);
|
|
57
|
+
if (items.length) {
|
|
58
|
+
parts.push(`<ul>${items.map((item) => `<li>${esc(item)}</li>`).join('')}</ul>`);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
else if (type === 'grid') {
|
|
62
|
+
const rows = asArray(section.rows);
|
|
63
|
+
parts.push('<g>');
|
|
64
|
+
for (const row of rows) {
|
|
65
|
+
const cells = asArray(row);
|
|
66
|
+
parts.push(`<div class="k">${esc(cells[0])}</div><div>${esc(cells[1])}</div>`);
|
|
67
|
+
}
|
|
68
|
+
parts.push('</g>');
|
|
69
|
+
}
|
|
70
|
+
else if (type === 'table') {
|
|
71
|
+
const headers = asArray(section.headers);
|
|
72
|
+
const rightAlign = section.align === 'right';
|
|
73
|
+
parts.push('<table><thead><tr>');
|
|
74
|
+
parts.push(headers.map((header) => `<th>${esc(header)}</th>`).join(''));
|
|
75
|
+
parts.push('</tr></thead><tbody>');
|
|
76
|
+
for (const row of asArray(section.rows)) {
|
|
77
|
+
const cells = asArray(row);
|
|
78
|
+
parts.push('<tr>');
|
|
79
|
+
cells.forEach((cell, index) => {
|
|
80
|
+
const cls = rightAlign && index > 0 ? ' class="n"' : '';
|
|
81
|
+
parts.push(`<td${cls}>${esc(cell)}</td>`);
|
|
82
|
+
});
|
|
83
|
+
parts.push('</tr>');
|
|
84
|
+
}
|
|
85
|
+
const total = asArray(section.total);
|
|
86
|
+
if (total.length) {
|
|
87
|
+
const span = Math.max(0, headers.length - 1);
|
|
88
|
+
parts.push('<tr class="t">');
|
|
89
|
+
if (span > 0)
|
|
90
|
+
parts.push(`<td colspan="${span}">${esc(total[0])}</td>`);
|
|
91
|
+
parts.push(`<td class="n">${esc(total[total.length - 1])}</td>`);
|
|
92
|
+
parts.push('</tr>');
|
|
93
|
+
}
|
|
94
|
+
parts.push('</tbody></table>');
|
|
95
|
+
if (section.note)
|
|
96
|
+
parts.push(`<p class="nt">${esc(section.note)}</p>`);
|
|
97
|
+
}
|
|
98
|
+
else if (type === 'checks') {
|
|
99
|
+
const ok = asArray(section.ok);
|
|
100
|
+
const warn = asArray(section.warn);
|
|
101
|
+
if (ok.length)
|
|
102
|
+
parts.push(`<div class="ok">✅ ${esc(ok.join(';'))}</div>`);
|
|
103
|
+
if (warn.length)
|
|
104
|
+
parts.push(`<div class="wn">⚠ ${esc(warn.join(';'))}</div>`);
|
|
105
|
+
}
|
|
106
|
+
else if (type === 'list') {
|
|
107
|
+
const items = asArray(section.items);
|
|
108
|
+
if (items.length) {
|
|
109
|
+
parts.push(`<ul>${items.map((item) => `<li>${esc(item)}</li>`).join('')}</ul>`);
|
|
110
|
+
}
|
|
111
|
+
if (section.note)
|
|
112
|
+
parts.push(`<p class="nt">${esc(section.note)}</p>`);
|
|
113
|
+
}
|
|
114
|
+
else if (type === 'next') {
|
|
115
|
+
parts.push(`<p style="margin:0">${esc(section.text)}</p>`);
|
|
116
|
+
parts.push('<p class="nt">本摘要基于合同正文解析生成,不构成法律审查意见。</p>');
|
|
117
|
+
}
|
|
118
|
+
else if (section.text) {
|
|
119
|
+
parts.push(`<p>${esc(section.text)}</p>`);
|
|
120
|
+
}
|
|
121
|
+
parts.push('</div>');
|
|
122
|
+
return parts.join('');
|
|
123
|
+
}
|
|
124
|
+
const SECTION_TYPES = ['alert', 'reasons', 'grid', 'table', 'checks', 'list', 'next'];
|
|
125
|
+
export const contractSummaryOperations = [
|
|
126
|
+
{
|
|
127
|
+
name: 'contract.summary.render',
|
|
128
|
+
async execute(input) {
|
|
129
|
+
const dataPath = resolve(requireNonEmptyString(input.data, 'data', 4096).trim());
|
|
130
|
+
const outPath = resolve(requireNonEmptyString(input.out, 'out', 4096).trim());
|
|
131
|
+
let data;
|
|
132
|
+
try {
|
|
133
|
+
const raw = readFileSync(dataPath, 'utf8').replace(/^\uFEFF/u, '');
|
|
134
|
+
const parsed = JSON.parse(raw);
|
|
135
|
+
if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) {
|
|
136
|
+
throw new Error('summary data must be an object');
|
|
137
|
+
}
|
|
138
|
+
data = parsed;
|
|
139
|
+
}
|
|
140
|
+
catch (error) {
|
|
141
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
142
|
+
throw contractValidationError('data_unreadable', `无法读取摘要数据 JSON:${message}`);
|
|
143
|
+
}
|
|
144
|
+
const sections = asArray(data.sections);
|
|
145
|
+
if (sections.length === 0) {
|
|
146
|
+
throw contractValidationError('sections_required', '摘要数据必须包含非空的 sections 数组');
|
|
147
|
+
}
|
|
148
|
+
const unknownTypes = sections
|
|
149
|
+
.map((section) => String(section?.type ?? ''))
|
|
150
|
+
.filter((type) => !SECTION_TYPES.includes(type));
|
|
151
|
+
if (unknownTypes.length) {
|
|
152
|
+
throw contractValidationError('section_type_unknown', `未知的 section 类型:${[...new Set(unknownTypes)].join(', ')};支持 ${SECTION_TYPES.join(' / ')}`);
|
|
153
|
+
}
|
|
154
|
+
const badge = esc(data.badge ?? '合同');
|
|
155
|
+
const title = esc(data.title ?? '合同摘要');
|
|
156
|
+
const meta = esc(data.meta ?? '');
|
|
157
|
+
const body = sections.map((section) => sectionHtml(section)).join('');
|
|
158
|
+
const html = `<!DOCTYPE html><html lang="zh-CN"><head><meta charset="UTF-8">`
|
|
159
|
+
+ `<title>合同摘要 - ${title}</title><style>${CSS}</style></head><body><div class="w">`
|
|
160
|
+
+ `<div class="hd"><span class="bd">${badge}</span><h1>${title}</h1><div class="mt">${meta}</div></div>`
|
|
161
|
+
+ `${body}</div></body></html>`;
|
|
162
|
+
writeFileSync(outPath, html, 'utf8');
|
|
163
|
+
const bytes = Buffer.byteLength(html, 'utf8');
|
|
164
|
+
return {
|
|
165
|
+
status: 'COMPLETE',
|
|
166
|
+
data: {
|
|
167
|
+
output: outPath,
|
|
168
|
+
fileName: basename(outPath),
|
|
169
|
+
fileSize: bytes,
|
|
170
|
+
sectionCount: sections.length,
|
|
171
|
+
sectionTypes: sections.map((section) => String(section.type)),
|
|
172
|
+
note: 'HTML 由 CLI 按固定模板渲染;模型只需提供紧凑数据 JSON',
|
|
173
|
+
},
|
|
174
|
+
};
|
|
175
|
+
},
|
|
176
|
+
},
|
|
177
|
+
];
|