weaver-work-cli 0.1.62 → 0.1.64

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (299) hide show
  1. package/dist/chunks/{archive-S2VKZWQ3.js → archive-WUZKAEZ6.js} +5 -4
  2. package/dist/chunks/{archive-oa-HEDSIUUY.js → archive-oa-PN46RTI2.js} +5 -4
  3. package/dist/chunks/{asset-HYH4W357.js → asset-ZPC5VWZM.js} +5 -4
  4. package/dist/chunks/{asset-idle-N7REBNGL.js → asset-idle-DHGP3NYY.js} +5 -4
  5. package/dist/chunks/{attachment-content-VYYA75FR.js → attachment-content-JQDW3BIB.js} +3 -3
  6. package/dist/chunks/{blog-SLMZZICV.js → blog-JC47AIXK.js} +5 -4
  7. package/dist/chunks/{caizhilian-RV43KKBT.js → caizhilian-IKIHM77A.js} +5 -5
  8. package/dist/chunks/{calendar-DMVZ4OLY.js → calendar-GZTSJ57Y.js} +5 -4
  9. package/dist/chunks/{chunk-H6YOMI3U.js → chunk-26FCCU5O.js} +5 -3
  10. package/dist/chunks/{chunk-E5YD5JWR.js → chunk-3PCXBG4H.js} +1 -1
  11. package/dist/chunks/{chunk-UBRWONP4.js → chunk-3W5NMGDS.js} +2 -2
  12. package/dist/chunks/{chunk-DTCQFTHW.js → chunk-4AFWOGOV.js} +3 -3
  13. package/dist/chunks/{chunk-VNYOUAWV.js → chunk-5QQKLR6H.js} +11 -11
  14. package/dist/chunks/{chunk-BQYX2UX5.js → chunk-6T5X6YWX.js} +5 -3
  15. package/dist/chunks/{chunk-KXJA42EA.js → chunk-AFZTMYGC.js} +1 -1
  16. package/dist/chunks/{chunk-YI2YMW5N.js → chunk-AGSO3PIK.js} +2 -2
  17. package/dist/chunks/{chunk-IW7A2IQY.js → chunk-C4YQJFZV.js} +43 -15
  18. package/dist/chunks/{chunk-WIWDVETN.js → chunk-FDBAFANU.js} +76 -76
  19. package/dist/chunks/{chunk-NRYDJN4J.js → chunk-FJUOUSV3.js} +89 -8
  20. package/dist/chunks/{chunk-EGANE35F.js → chunk-HLT6B26P.js} +1 -1
  21. package/dist/chunks/{chunk-P6TXQK75.js → chunk-HWA2A25Y.js} +5 -3
  22. package/dist/chunks/{chunk-T2KVJFWJ.js → chunk-I3MOFD6Q.js} +4 -7
  23. package/dist/chunks/chunk-IN6NXQ26.js +680 -0
  24. package/dist/chunks/{chunk-UBGWIXU3.js → chunk-INVYKG4I.js} +140 -45
  25. package/dist/chunks/{chunk-QBDXJS2W.js → chunk-K7QKQRSL.js} +168 -62
  26. package/dist/chunks/{chunk-BIA2NKUG.js → chunk-KDFEHDIB.js} +5 -5
  27. package/dist/chunks/{chunk-ILALC2N6.js → chunk-KYDXWYFB.js} +1 -1
  28. package/dist/chunks/{chunk-V2LASYKO.js → chunk-Q6D6PSMH.js} +30 -24
  29. package/dist/chunks/{chunk-UQFPF4EX.js → chunk-RMOH2GMF.js} +2 -2
  30. package/dist/chunks/{chunk-VBFBMM7G.js → chunk-SCMHG23G.js} +387 -70
  31. package/dist/chunks/chunk-TJN4PIYO.js +47 -0
  32. package/dist/chunks/{chunk-JFAWZX53.js → chunk-UPVAQJKS.js} +282 -131
  33. package/dist/chunks/{chunk-KY3R42RS.js → chunk-VLY5RTVO.js} +5 -3
  34. package/dist/chunks/{chunk-TEZHIB6T.js → chunk-WSHIOSGM.js} +5 -3
  35. package/dist/chunks/{chunk-6XSSAUNW.js → chunk-XHSEK2VM.js} +48 -12
  36. package/dist/chunks/{chunk-XT77MP54.js → chunk-YTFNMQO4.js} +410 -24
  37. package/dist/chunks/{conflict-GFJRS6I7.js → conflict-UUC7AFUI.js} +2 -2
  38. package/dist/chunks/{contract-U3ZGNRWB.js → contract-INMS7SYQ.js} +3051 -4497
  39. package/dist/chunks/{cowork-EX7PKIDK.js → cowork-34CBYVQP.js} +5 -4
  40. package/dist/chunks/{create-flow-EJZD434E.js → create-flow-YOR4QTAJ.js} +18 -6
  41. package/dist/chunks/{data-FOODGAMF.js → data-QKWI5325.js} +14 -3
  42. package/dist/chunks/{ebuilder-form-I2EOKODG.js → ebuilder-form-ZONRROK4.js} +4 -4
  43. package/dist/chunks/{ehr-TE4RFNID.js → ehr-2CONM7R6.js} +244 -151
  44. package/dist/chunks/{employee-DR5Y64TI.js → employee-PGMY6NI6.js} +1 -1
  45. package/dist/chunks/{entry-mode-ZOLSXEGX.js → entry-mode-S2ENJ6GZ.js} +3 -3
  46. package/dist/chunks/{env-TID5NFR6.js → env-ZSAXU5PJ.js} +2 -2
  47. package/dist/chunks/{esb-7L6MHYLB.js → esb-FQASCY2H.js} +8 -8
  48. package/dist/chunks/{factory-OG7BPMH5.js → factory-N76QQA53.js} +1 -1
  49. package/dist/chunks/{fna-6V2ENR3Y.js → fna-FCLVIWAS.js} +5 -4
  50. package/dist/chunks/{group-chat-5DKPWIHL.js → group-chat-UM665WDZ.js} +3 -3
  51. package/dist/chunks/{host-VTPAWDZV.js → host-2ED2KC4X.js} +4 -4
  52. package/dist/chunks/{host-TJ5VVHM7.js → host-2UYZEY2V.js} +4 -4
  53. package/dist/chunks/{host-3DLYA54R.js → host-46NYKDQP.js} +4 -4
  54. package/dist/chunks/{host-OGBHL75G.js → host-7IPZKIM4.js} +4 -4
  55. package/dist/chunks/{host-GOJHHTPY.js → host-P7G22WNM.js} +4 -4
  56. package/dist/chunks/{host-ONZC6AE7.js → host-XLCBLNJD.js} +4 -4
  57. package/dist/chunks/{hrm-2N7NFQDZ.js → hrm-XKL27NX2.js} +6 -6
  58. package/dist/chunks/{im-XCH47ZBN.js → im-NDYIMASG.js} +4 -4
  59. package/dist/chunks/{invoice-5KJ7T774.js → invoice-MOGNB6HN.js} +4 -4
  60. package/dist/chunks/{jiuchuanhui-PL6DRPBM.js → jiuchuanhui-3T5X7SB7.js} +5 -4
  61. package/dist/chunks/{lazy-dispatch-UATEN7H7.js → lazy-dispatch-4WOIL3ZQ.js} +5 -5
  62. package/dist/chunks/{mail-Q7Z4CQ4D.js → mail-P7VMUKQW.js} +5 -4
  63. package/dist/chunks/{meeting-5E3BNARL.js → meeting-MMTYDHXA.js} +16 -15
  64. package/dist/chunks/{minute-doc-NXRE5C77.js → minute-doc-LCSBWGJ3.js} +4 -4
  65. package/dist/chunks/{okr-3O3XNYOK.js → okr-VZXRQGS4.js} +5 -4
  66. package/dist/chunks/{operations-EZWG72FH.js → operations-MI2BSKZX.js} +5 -5
  67. package/dist/chunks/{performance-Y7CPNSOR.js → performance-OPEQNW7Y.js} +873 -17
  68. package/dist/chunks/{plan-BLGPZF5M.js → plan-TJAS4N5X.js} +5 -4
  69. package/dist/chunks/{project-6MZMLJMP.js → project-CYBGU6K6.js} +5 -4
  70. package/dist/chunks/{reception-F2VT2X52.js → reception-3FT2F66K.js} +3 -3
  71. package/dist/chunks/{recruit-stage-4ETIBMIW.js → recruit-stage-WPGB5BDJ.js} +654 -336
  72. package/dist/chunks/{registry-3FYSWV3U.js → registry-BAWCWV4D.js} +3 -3
  73. package/dist/chunks/{registry-I4DVPDMU.js → registry-FNI5E76J.js} +12 -12
  74. package/dist/chunks/{registry-3UGIWH53.js → registry-JMNOXRST.js} +2 -2
  75. package/dist/chunks/{registry-7RS74TCK.js → registry-QRMXRSCT.js} +5 -5
  76. package/dist/chunks/{room-recommend-GWCVKCXW.js → room-recommend-I7QQRHEL.js} +4 -4
  77. package/dist/chunks/{schedule-6AN63MJQ.js → schedule-3P7EWGNZ.js} +4 -4
  78. package/dist/chunks/{smart-extract-SR4SJJKN.js → smart-extract-FOBSVNYW.js} +3 -3
  79. package/dist/chunks/{workflow-KF7FA2UQ.js → workflow-U2KKTVQY.js} +10 -7
  80. package/dist/index.js +34 -34
  81. package/dist/internal/e10/auth/commands.js +203 -44
  82. package/dist/internal/e10/auth/xiaoe.js +6 -2
  83. package/dist/internal/e10/auth-recovery.js +28 -2
  84. package/dist/internal/e10/request-runtime.js +15 -3
  85. package/dist/internal/e10/request-trace.js +65 -0
  86. package/dist/shortcuts/contract/data/metric-catalog.js +149 -0
  87. package/dist/shortcuts/contract/error-actions.js +112 -0
  88. package/dist/shortcuts/contract/errors.js +9 -1
  89. package/dist/shortcuts/contract/index.js +14 -39
  90. package/dist/shortcuts/contract/manifest.js +130 -274
  91. package/dist/shortcuts/contract/operations/compare-report.js +437 -0
  92. package/dist/shortcuts/contract/operations/compare.js +2 -0
  93. package/dist/shortcuts/contract/operations/docx-slots.js +112 -5
  94. package/dist/shortcuts/contract/operations/docx-verify.js +2 -70
  95. package/dist/shortcuts/contract/operations/elements-build.js +82 -56
  96. package/dist/shortcuts/contract/operations/elements-spec.js +140 -3
  97. package/dist/shortcuts/contract/operations/first-screen.js +96 -207
  98. package/dist/shortcuts/contract/operations/flow.js +19 -1
  99. package/dist/shortcuts/contract/operations/{card-ebdf-list.js → ledger-card.js} +123 -27
  100. package/dist/shortcuts/contract/operations/ledger.js +343 -1
  101. package/dist/shortcuts/contract/operations/metrics.js +93 -0
  102. package/dist/shortcuts/contract/operations/modeltext.js +3 -3
  103. package/dist/shortcuts/contract/operations/money.js +90 -0
  104. package/dist/shortcuts/contract/operations/page.js +8 -4
  105. package/dist/shortcuts/contract/operations/performance.js +53 -0
  106. package/dist/shortcuts/contract/operations/placeholder-scan.js +104 -0
  107. package/dist/shortcuts/contract/operations/quote-recognize.js +326 -0
  108. package/dist/shortcuts/contract/operations/quote-ref.js +179 -0
  109. package/dist/shortcuts/contract/operations/quote-submit.js +281 -0
  110. package/dist/shortcuts/contract/operations/quote.js +66 -12
  111. package/dist/shortcuts/contract/operations/recommend.js +42 -1
  112. package/dist/shortcuts/contract/operations/registry.js +16 -23
  113. package/dist/shortcuts/contract/operations/{card-risk-report.js → review-report.js} +24 -114
  114. package/dist/shortcuts/contract/operations/review.js +33 -167
  115. package/dist/shortcuts/contract/operations/save-recognize.js +173 -43
  116. package/dist/shortcuts/contract/operations/solutions-spec.js +79 -0
  117. package/dist/shortcuts/contract/operations/triage.js +68 -15
  118. package/dist/shortcuts/contract/operations/{template.js → type-clause-read.js} +10 -25
  119. package/dist/shortcuts/contract/operations/upload.js +17 -11
  120. package/dist/shortcuts/contract/prewarm-cache.js +6 -2
  121. package/dist/shortcuts/contract/prewarm.js +33 -23
  122. package/dist/shortcuts/contract/recommend-cache.js +191 -0
  123. package/dist/shortcuts/data/operations/shared.js +14 -1
  124. package/dist/shortcuts/ehr/operations/recruit-interview-overview.js +85 -62
  125. package/dist/shortcuts/ehr/operations/recruit-position.js +21 -13
  126. package/dist/shortcuts/ehr/operations/recruit-short-cache.js +59 -0
  127. package/dist/shortcuts/ehr/operations/recruit-tag.js +17 -11
  128. package/dist/shortcuts/ehr/operations/recruit-write.js +118 -70
  129. package/dist/shortcuts/ehr/operations/recruit.js +338 -121
  130. package/dist/shortcuts/hrm/operations/employee.js +64 -17
  131. package/dist/shortcuts/hrm/operations/resolve.js +419 -369
  132. package/dist/shortcuts/im/host.js +38 -22
  133. package/dist/shortcuts/meeting/operations/eb/conflict.js +60 -2
  134. package/dist/shortcuts/meeting/operations/eb/create-flow.js +138 -15
  135. package/dist/shortcuts/meeting/operations/eb/create-form-link.js +380 -0
  136. package/dist/shortcuts/meeting/operations/eb/index.js +2 -0
  137. package/dist/shortcuts/meeting/operations/eb/room-recommend.js +1 -3
  138. package/dist/shortcuts/performance/flow-utils.js +363 -0
  139. package/dist/shortcuts/performance/manifest.js +2 -2
  140. package/dist/shortcuts/performance/operations/flow-detail.js +85 -0
  141. package/dist/shortcuts/performance/operations/flow-list.js +213 -0
  142. package/dist/shortcuts/performance/operations/flow-score.js +241 -0
  143. package/dist/shortcuts/performance/operations/registry.js +6 -0
  144. package/dist/shortcuts/recruit-stage/batch-store.js +44 -0
  145. package/dist/shortcuts/recruit-stage/context.js +75 -9
  146. package/dist/shortcuts/recruit-stage/manifest.js +1 -1
  147. package/dist/shortcuts/recruit-stage/operations/jd-create.js +33 -22
  148. package/dist/shortcuts/recruit-stage/operations/list.js +187 -37
  149. package/dist/shortcuts/recruit-stage/operations/registry.js +2 -0
  150. package/dist/shortcuts/recruit-stage/operations/resume-import.js +231 -313
  151. package/dist/shortcuts/recruit-stage/operations/search.js +5 -5
  152. package/dist/shortcuts/recruit-stage/operations/tag.js +286 -0
  153. package/dist/shortcuts/workflow/endpoints.js +2 -0
  154. package/dist/shortcuts/workflow/operations/form.js +12 -15
  155. package/dist/shortcuts/workflow/operations/read.js +8 -8
  156. package/dist/shortcuts/workflow/operations/todoSmartConvert/todoListRows.js +3 -2
  157. package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.collect.js +7 -6
  158. package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.core.js +4 -3
  159. package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.group.js +1 -0
  160. package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.js +33 -6
  161. package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.prepareQuery.js +153 -0
  162. package/dist/shortcuts/workflow/operations/todoSmartConvert/workflowClarification.js +232 -0
  163. package/dist/shortcuts/workflow/operations.js +5 -0
  164. package/docs/contract.md +2 -2
  165. package/docs/e10-auth.md +55 -2
  166. package/docs/ehr.md +1 -1
  167. package/package.json +1 -1
  168. package/skills/weaver-e10-hrm/SKILL.md +3 -3
  169. package/skills/weaver-e10-hrm/references/employee.md +13 -2
  170. package/skills/weaver-e10-jinchengda/SKILL.md +283 -345
  171. package/skills/weaver-e10-jinchengda/references/contract-agent-entry.md +7 -14
  172. package/skills/weaver-e10-jinchengda/references/contract-ai-assistant.md +21 -12
  173. package/skills/weaver-e10-jinchengda/references/contract-ai-review.md +126 -202
  174. package/skills/weaver-e10-jinchengda/references/contract-clause-insert.md +13 -5
  175. package/skills/weaver-e10-jinchengda/references/contract-clause-library-crud.md +28 -20
  176. package/skills/weaver-e10-jinchengda/references/contract-clause-recommender.md +12 -17
  177. package/skills/weaver-e10-jinchengda/references/contract-clause-reference-save.md +7 -13
  178. package/skills/weaver-e10-jinchengda/references/contract-command-index.md +47 -16
  179. package/skills/weaver-e10-jinchengda/references/contract-compare-report-template.html +10 -18
  180. package/skills/weaver-e10-jinchengda/references/contract-compare-report.md +19 -18
  181. package/skills/weaver-e10-jinchengda/references/contract-credit-page.md +114 -61
  182. package/skills/weaver-e10-jinchengda/references/contract-disabled-capabilities.md +8 -2
  183. package/skills/weaver-e10-jinchengda/references/contract-doc-compare.md +78 -112
  184. package/skills/weaver-e10-jinchengda/references/contract-doc-triage.md +67 -333
  185. package/skills/weaver-e10-jinchengda/references/contract-element-extract.md +18 -15
  186. package/skills/weaver-e10-jinchengda/references/contract-element-save-record.md +80 -84
  187. package/skills/weaver-e10-jinchengda/references/contract-execution-rules.md +38 -34
  188. package/skills/weaver-e10-jinchengda/references/contract-field-extract-new-customer.md +132 -47
  189. package/skills/weaver-e10-jinchengda/references/contract-field-extract-other-flows.md +108 -217
  190. package/skills/weaver-e10-jinchengda/references/contract-flow-launch.md +14 -20
  191. package/skills/weaver-e10-jinchengda/references/contract-ledger-catalog.md +13 -7
  192. package/skills/weaver-e10-jinchengda/references/contract-ledger-query-playbook.md +86 -46
  193. package/skills/weaver-e10-jinchengda/references/contract-ledger-rules.md +12 -10
  194. package/skills/weaver-e10-jinchengda/references/contract-modeltext-library.md +22 -14
  195. package/skills/weaver-e10-jinchengda/references/contract-multi-file.md +18 -18
  196. package/skills/weaver-e10-jinchengda/references/contract-object-detect.md +27 -26
  197. package/skills/weaver-e10-jinchengda/references/contract-open-web-pages.md +252 -0
  198. package/skills/weaver-e10-jinchengda/references/contract-performance-query.md +15 -23
  199. package/skills/weaver-e10-jinchengda/references/contract-quote-to-contract.md +290 -104
  200. package/skills/weaver-e10-jinchengda/references/contract-request-status.md +5 -12
  201. package/skills/weaver-e10-jinchengda/references/contract-request-write.md +12 -18
  202. package/skills/weaver-e10-jinchengda/references/contract-signing-subjects.md +11 -17
  203. package/skills/weaver-e10-jinchengda/references/contract-subject-create.md +5 -11
  204. package/skills/weaver-e10-jinchengda/references/contract-template-recommend.md +56 -7
  205. package/skills/weaver-e10-jinchengda/references/contract-type-fingerprints.md +12 -12
  206. package/skills/weaver-e10-jinchengda/references/contract-workflow-discovery.md +10 -16
  207. package/skills/weaver-e10-jinchengda/references/orchestration.md +33 -35
  208. package/skills/weaver-e10-jucailin/SKILL.md +6 -7
  209. package/skills/weaver-e10-jucailin/agents/openai.yaml +52 -0
  210. package/skills/weaver-e10-jucailin/references/recruit-interview-overview.md +8 -6
  211. package/skills/weaver-e10-jucailin/references/recruit-read.md +4 -0
  212. package/skills/weaver-e10-jucailin/references/recruit-screening-to-interview-sop.md +2 -2
  213. package/skills/weaver-e10-jucailin/references/recruit-write.md +4 -4
  214. package/skills/weaver-e10-meeting/SKILL.md +87 -534
  215. package/skills/weaver-e10-meeting/references/commands-table.md +61 -0
  216. package/skills/weaver-e10-meeting/references/create-commands.md +136 -0
  217. package/skills/weaver-e10-meeting/references/create-flow.md +9 -7
  218. package/skills/weaver-e10-meeting/references/create-guardrails.md +23 -17
  219. package/skills/weaver-e10-meeting/references/custom-fields.md +40 -0
  220. package/skills/weaver-e10-meeting/references/eb-contracts.md +60 -0
  221. package/skills/weaver-e10-meeting/references/invitation.md +69 -0
  222. package/skills/weaver-e10-meeting/references/meeting-eb.md +26 -26
  223. package/skills/weaver-e10-meeting/references/meeting-invitation.md +2 -2
  224. package/skills/weaver-e10-meeting/references/meeting-minute-file.md +2 -2
  225. package/skills/weaver-e10-meeting/references/meeting-verification.md +1 -1
  226. package/skills/weaver-e10-meeting/references/minutes-pipeline.md +119 -0
  227. package/skills/weaver-e10-meeting/references/pitfalls.md +1 -1
  228. package/skills/weaver-e10-meeting/references/room-recommend.md +88 -0
  229. package/skills/weaver-e10-performance/SKILL.md +45 -5
  230. package/skills/weaver-e10-performance/agents/openai.yaml +26 -2
  231. package/skills/weaver-e10-performance/references/flow-api.md +128 -0
  232. package/skills/weaver-e10-performance/references/flow-assess.md +149 -0
  233. package/skills/weaver-e10-recruit-stage/SKILL.md +317 -266
  234. package/skills/weaver-e10-recruit-stage/agents/openai.yaml +22 -27
  235. package/skills/weaver-e10-recruit-stage/references/env-ziyong.md +1 -1
  236. package/skills/weaver-e10-recruit-stage/references/recruit-arrange-interview.md +30 -27
  237. package/skills/weaver-e10-recruit-stage/references/recruit-capability-check.md +2 -6
  238. package/skills/weaver-e10-recruit-stage/references/recruit-edit-interview-feedback.md +12 -10
  239. package/skills/weaver-e10-recruit-stage/references/recruit-interview-not-attended.md +2 -0
  240. package/skills/weaver-e10-recruit-stage/references/recruit-jd-create.md +23 -19
  241. package/skills/weaver-e10-recruit-stage/references/recruit-jd-template.md +3 -1
  242. package/skills/weaver-e10-recruit-stage/references/recruit-list-candidate.md +18 -16
  243. package/skills/weaver-e10-recruit-stage/references/recruit-list-interview.md +25 -23
  244. package/skills/weaver-e10-recruit-stage/references/recruit-match-candidates.md +10 -10
  245. package/skills/weaver-e10-recruit-stage/references/recruit-resolve-metadata.md +2 -2
  246. package/skills/weaver-e10-recruit-stage/references/recruit-resume-import-batch.md +11 -11
  247. package/skills/weaver-e10-recruit-stage/references/recruit-resume-import.md +150 -85
  248. package/skills/weaver-e10-recruit-stage/references/recruit-resume-parse.md +14 -18
  249. package/skills/weaver-e10-recruit-stage/references/recruit-search-by-tag.md +1 -1
  250. package/skills/weaver-e10-recruit-stage/references/recruit-tag-recommend.md +173 -0
  251. package/skills/weaver-e10-recruit-stage/references/recruit-tag-taxonomy.json +76 -0
  252. package/skills/weaver-e10-recruit-stage/references/recruit-urge-feedback.md +3 -1
  253. package/skills/weaver-e10-recruit-stage/references/recruit-utterance-glossary.md +2 -2
  254. package/skills/weaver-e10-workflow/SKILL.md +49 -32
  255. package/skills/weaver-e10-workflow/references/todo-dialogue.md +67 -34
  256. package/skills/weaver-e10-workflow/references/todo-smart-convert.md +65 -51
  257. package/skills/weaver-e10-workflow/references/workflow-agent-entry.md +18 -11
  258. package/skills/weaver-e10-workflow/references/workflow-create.md +2 -2
  259. package/skills/weaver-e10-workflow/references/workflow-memory.md +19 -37
  260. package/skills/weaver-e10-workflow/references/workflow-query.md +25 -22
  261. package/skills/weaver-e10-workflow/references/workflow-view.md +1 -1
  262. package/skills/weaver-e10-workflow/tools/todo-summary.cjs +318 -110
  263. package/skills/weaver-e10-yimiaoban/SKILL.md +17 -14
  264. package/skills/weaver-e10-yimiaoban/references/person.md +1 -1
  265. package/skills/weaver-e10-yimiaoban/references/safety-boundaries.md +1 -1
  266. package/skills/weaver-e10-yimiaoban/references/source-manifest.json +9 -9
  267. package/dist/chunks/chunk-6QYNE6HE.js +0 -658
  268. package/dist/chunks/chunk-SHYQUBY3.js +0 -48
  269. package/dist/shortcuts/contract/operations/card-action.js +0 -1266
  270. package/dist/shortcuts/contract/operations/card-plan.js +0 -393
  271. package/dist/shortcuts/contract/operations/card.js +0 -232
  272. package/dist/shortcuts/contract/operations/compare-screen.js +0 -378
  273. package/dist/shortcuts/contract/operations/quote-to-contract.js +0 -495
  274. package/dist/shortcuts/contract/operations/quotescreen.js +0 -529
  275. package/dist/shortcuts/contract/operations/summary-validate.js +0 -293
  276. package/dist/shortcuts/contract/operations/summary.js +0 -187
  277. package/dist/shortcuts/ehr/recruit-stage/batch-store.js +0 -78
  278. package/dist/shortcuts/ehr/recruit-stage/context.js +0 -231
  279. package/dist/shortcuts/ehr/recruit-stage/continuation.js +0 -74
  280. package/dist/shortcuts/ehr/recruit-stage/errors.js +0 -65
  281. package/dist/shortcuts/ehr/recruit-stage/fs-scan.js +0 -165
  282. package/dist/shortcuts/ehr/recruit-stage/host.js +0 -109
  283. package/dist/shortcuts/ehr/recruit-stage/operations/interview-arrange.js +0 -1065
  284. package/dist/shortcuts/ehr/recruit-stage/operations/interview-feedback.js +0 -295
  285. package/dist/shortcuts/ehr/recruit-stage/operations/jd-create.js +0 -961
  286. package/dist/shortcuts/ehr/recruit-stage/operations/list.js +0 -431
  287. package/dist/shortcuts/ehr/recruit-stage/operations/registry.js +0 -50
  288. package/dist/shortcuts/ehr/recruit-stage/operations/resume-import.js +0 -1655
  289. package/dist/shortcuts/ehr/recruit-stage/operations/search.js +0 -158
  290. package/dist/shortcuts/ehr/recruit-stage/operations/types.js +0 -34
  291. package/dist/shortcuts/ehr/recruit-stage/runtime.js +0 -31
  292. package/dist/shortcuts/ehr/recruit-stage/school-tiers.json +0 -318
  293. package/dist/shortcuts/ehr/recruit-stage/shared.js +0 -887
  294. package/skills/weaver-e10-jinchengda/references/contract-action-card-template.html +0 -22
  295. package/skills/weaver-e10-jinchengda/references/contract-action-card.md +0 -554
  296. package/skills/weaver-e10-jinchengda/references/contract-action-engine.md +0 -279
  297. package/skills/weaver-e10-jinchengda/references/contract-card-render-internals.md +0 -483
  298. package/skills/weaver-e10-jinchengda/references/contract-template-selector.md +0 -46
  299. package/skills/weaver-e10-recruit-stage/lib/recruit-resume-photo.py +0 -194
@@ -1,1266 +0,0 @@
1
- import { existsSync, mkdirSync, readFileSync, statSync, writeFileSync } from 'node:fs';
2
- import { dirname, join, resolve } from 'node:path';
3
- import { Script } from 'node:vm';
4
- import { contractValidationError } from '../errors.js';
5
- import { planActions } from './card-plan.js';
6
- /**
7
- * 行为卡片渲染器(本地,零依赖)。
8
- *
9
- * 迁移自 `scripts/render_action_card.py`(2026-11-12 第三批)。
10
- *
11
- * 历史背景(保留,避免重复踩坑):此前模板只是「可照抄的样例」,卡片与 handler
12
- * 全部写死,于是反复出现同一类偏差——sendQuestion 写成 plugin.sendQuestion、
13
- * e10Sdk 漏 params.compName、只绑 click 无 hover、width 沿用旧值、
14
- * 摘要内嵌时引号/换行/`</script>` 未转义导致整段脚本失效。
15
- * 本 operation 把「算卡片 → 生成 HTML → 绑交互 → 组装外层 JSON → 自检」全部固化。
16
- *
17
- * 三处历史修复必须在迁移后保持:
18
- * 1. `__W__` 必须在**拼完所有 handler 之后**统一替换,否则 handler 里的
19
- * `width:__W__` 残留,点击抛 ReferenceError 被 try/catch 吞成「面板打开失败」;
20
- * 2. 模板正文起点按「section 开标签含 id 属性」定位,不能用 `indexOf('<section')`,
21
- * 注释里出现该字样会误命中,多出一个未闭合开标签;
22
- * 3. `js_str` 的转义顺序不可调整(先处理 `</script>`,再归零双引号,最后转义反斜杠与单引号)。
23
- */
24
- const DEFAULT_BASE = 'https://www.e-cology.com.cn';
25
- const DEFAULT_AIID = '1326842382967570463';
26
- export const CARD_PANEL_WIDTH = 1300;
27
- const WIDTH = CARD_PANEL_WIDTH;
28
- /** flowKey → workflowId(与 contract-flow-launch.md 保持一致)。 */
29
- const FLOW_IDS = new Map([
30
- ['契约锁', '100003460000002066'],
31
- ['新客户', '1269716062340284522'],
32
- ['老客户增值', '1283761429944369334'],
33
- ['常规二次销售', '1283761687634100307'],
34
- ]);
35
- const SVG = {
36
- launch: "<svg width='22' height='22' viewBox='0 0 24 24' fill='none' stroke='#7b8cf0' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'><path d='M22 2 11 13'/><path d='M22 2 15 22l-4-9-9-4z'/></svg>",
37
- doc: "<svg width='22' height='22' viewBox='0 0 24 24' fill='none' stroke='#7b8cf0' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'><path d='M14 3H7a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8z'/><path d='M14 3v5h5'/><path d='M9 13h6'/><path d='M9 17h4'/></svg>",
38
- eye: "<svg width='22' height='22' viewBox='0 0 24 24' fill='none' stroke='#7b8cf0' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'><path d='M2 12s3.5-7 10-7 10 7 10 7-3.5 7-10 7-10-7-10-7z'/><circle cx='12' cy='12' r='3'/></svg>",
39
- search: "<svg width='22' height='22' viewBox='0 0 24 24' fill='none' stroke='#7b8cf0' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'><circle cx='11' cy='11' r='7'/><path d='M16.5 16.5 21 21'/></svg>",
40
- list: "<svg width='22' height='22' viewBox='0 0 24 24' fill='none' stroke='#7b8cf0' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'><rect x='4' y='3' width='16' height='18' rx='2'/><path d='M8 8h8'/><path d='M8 12h8'/><path d='M8 16h5'/></svg>",
41
- swap: "<svg width='22' height='22' viewBox='0 0 24 24' fill='none' stroke='#7b8cf0' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'><path d='M7 4v16'/><path d='M4 17l3 3 3-3'/><path d='M17 20V4'/><path d='M14 7l3-3 3 3'/></svg>",
42
- edit: "<svg width='22' height='22' viewBox='0 0 24 24' fill='none' stroke='#7b8cf0' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'><path d='M12 20h9'/><path d='M16.5 3.5a2.1 2.1 0 0 1 3 3L7 19l-4 1 1-4z'/></svg>",
43
- };
44
- /** action id → [dom 后缀, 图标, 走法] */
45
- const ACTION_META = new Map([
46
- ['launch-flow', ['launch', 'launch', 'e10Sdk']],
47
- ['generate-contract', ['gen', 'doc', 'sendQuestion']],
48
- ['review', ['review', 'doc', 'sendQuestion']],
49
- ['export-review', ['report', 'list', 'artifact']],
50
- ['view-review', ['detail', 'eye', 'e10Sdk']],
51
- ['credit', ['credit', 'search', 'e10Sdk']],
52
- ['view-compare', ['cmpview', 'eye', 'e10Sdk']],
53
- ['export-compare-report', ['cmpreport', 'list', 'artifact']],
54
- ['compare', ['cmp', 'swap', 'sendQuestion']],
55
- ['clause-rewrite', ['rewrite', 'edit', 'sendQuestion']],
56
- ['request-status', ['status', 'search', 'sendQuestion']],
57
- ['summary', ['summary', 'list', 'artifact']],
58
- ['element-extract', ['extract', 'doc', 'sendQuestion']],
59
- ['supervise', ['supervise', 'launch', 'sendQuestion']],
60
- ['template-recommend', ['tpl', 'doc', 'sendQuestion']],
61
- ['performance', ['perf', 'list', 'sendQuestion']],
62
- ['retry-upload', ['retry', 'doc', 'sendQuestion']],
63
- ]);
64
- /** 兜底 sendQuestion 指令。 */
65
- const SEND_TEXT = new Map([
66
- ['generate-contract', '按这份报价单生成合同'],
67
- ['review', '对这份合同做合同预审,输出风险条款与修改建议'],
68
- ['clause-rewrite', '按预审建议修改合同条款'],
69
- ['request-status', '查一下这份合同的审批进度'],
70
- ['compare', '比对这两份合同的差异'],
71
- ['element-extract', '从这份合同里抽取要素'],
72
- ['supervise', '催办一下当前合同的审批'],
73
- ['template-recommend', '推荐几个适合的合同模板'],
74
- ['performance', '查一下这份合同的业绩核算'],
75
- ['retry-upload', '换一份文件重新解析'],
76
- ]);
77
- // 2026-11-13 用户指定:卡片容器改用原生 <button>,键盘 Enter/Space 由浏览器原生处理,
78
- // 模板里不再出现任何 keydown 判断(此前 e.key==='Enter' 的 === 在模型手写时易被写成 =,导致 JS 异常)。
79
- const CARD_TPL = "<button type='button' id='{dom_id}' style='display:flex;align-items:center;gap:12px;"
80
- + "width:100%;box-sizing:border-box;text-align:left;font-family:inherit;"
81
- + "background:#fff;border:1px solid #e8ebf2;border-radius:12px;padding:16px;{mb}cursor:pointer'>"
82
- + "<span style='flex:0 0 auto;width:44px;height:44px;border-radius:10px;background:#eef1fb;"
83
- + "display:flex;align-items:center;justify-content:center'>{icon}</span>"
84
- + "<span style='min-width:0'>"
85
- + "<span style='display:block;font-size:15px;font-weight:700;color:#1f2430;margin-bottom:6px'>{title}{badge}</span>"
86
- + "<span style='display:block;font-size:13px;color:#7a8497;line-height:1.5'>{desc}</span>"
87
- + '</span></button>';
88
- const BADGE = "<span style='font-size:11px;color:#3b6fe0;background:#eaf0fe;border-radius:10px;"
89
- + "padding:2px 8px;line-height:1.4;margin-left:8px'>推荐</span>";
90
- /** 交互脚本基础件(ES5、零双引号)。 */
91
- const JS_BASE = "var P=window.xiaoePlugin||(window.rawWindow&&window.rawWindow.xiaoePlugin);"
92
- + "var tip=document.getElementById('tip');"
93
- + 'function say(m){if(tip){tip.textContent=m;}}'
94
- + "function hasP(){if(!P||!P.rightPanel||typeof P.rightPanel.open!=='function'){"
95
- + "say('当前环境没有小e右侧面板');return false;}return true;}"
96
- + "function op(cfg){if(!hasP()){return;}try{P.rightPanel.open(cfg);say('已打开');}"
97
- + "catch(e){say('面板打开失败,请确认右侧面板已挂载');}}"
98
- + "function send(q){if(!P||!P.session||typeof P.session.sendQuestion!=='function'){"
99
- + "say('当前环境不支持发送会话消息');return;}"
100
- + "try{P.session.sendQuestion({question:q,files:[]});say('已发送,正在处理…');}"
101
- + "catch(e){say('发送失败,请重试');}}"
102
- + "function art(html,title,key){if(!hasP()){return;}if(!html){say('内容为空');return;}"
103
- + "try{P.rightPanel.open({type:'artifact',width:__W__,title:title,contentProps:{"
104
- + "artifacts:[{id:key,name:title,fileType:'html',raw:{html:html}}],"
105
- + "initialArtifactKeys:[key]}});}catch(e){say('面板打开失败,请确认右侧面板已挂载');}}"
106
- + 'function bind(id,fn){var el=document.getElementById(id);if(!el){return;}el.onclick=fn;'
107
- + "el.onmouseenter=function(){el.style.borderColor='#1d6fd8';"
108
- + "el.style.boxShadow='0 2px 8px rgba(29,111,216,.12)';};"
109
- + "el.onmouseleave=function(){el.style.borderColor='#e8ebf2';el.style.boxShadow='none';};}";
110
- // 2026-11-13 用户指定:不再绑定 onkeydown。卡片是原生 <button>,Enter/Space 由浏览器原生触发 click,
111
- // 模板中因此不含任何 === 比较,避免模型手写时把 === 写成 = 造成 JS 语法异常。
112
- /** 内嵌模板(与 references/contract-action-card-template.html 互为镜像,两者必须一致)。 */
113
- export const CARD_TEMPLATE = `<!--
114
- 行为卡片内层模板(contract-action-card-template.html)
115
-
116
- 定位:本模板由本文件下方的 renderActionCard() 在进程内替换占位符后产出完整 browsertool payload。
117
- 模型**不写 HTML、不替换占位符、不做引号转义、不跑 node --check**。
118
-
119
- 历史(不要照旧文档操作):
120
- 2026-11-09 重写:由「可照抄的样例」改为「供渲染器填充的真模板」;
121
- —— 旧版问题:卡片与 handler 全部写死、button 布局不符合标准卡、只绑 click 无 hover、
122
- review 缺 params.compName、残留调试文案,照抄必错。
123
- 2026-11-12:原负责替换占位符的 scripts/render_action_card.py 已删除,能力下沉为本 operation。
124
-
125
- 占位符(全部由 renderActionCard() 替换):
126
- {{CARD_ID}} {{CARDS}} {{SUMMARY_JS}} {{COMPARE_JS}} {{REPORT_JS}} {{BODY}}
127
-
128
- 注意:本注释块在渲染时会被丢弃,渲染器按「section 开标签含 id 属性」定位正文起点。
129
- -->
130
- <section id='{{CARD_ID}}' style='padding:4px 2px;font-family:Microsoft YaHei,PingFang SC,sans-serif'>
131
- {{CARDS}}
132
- <p id='tip' style='margin:8px 0 0;color:#b45309;font-size:12px'></p>
133
- </section>
134
- <script>(function(){var S={{SUMMARY_JS}};var C={{COMPARE_JS}};var R={{REPORT_JS}};{{BODY}}})();</script>
135
- `;
136
- function truthyText(value) {
137
- if (value === null || value === undefined || value === false || value === '' || value === 0)
138
- return '';
139
- return String(value);
140
- }
141
- function pad2(value) {
142
- return String(value).padStart(2, '0');
143
- }
144
- function stampNow() {
145
- const now = new Date();
146
- return `${now.getFullYear()}${pad2(now.getMonth() + 1)}${pad2(now.getDate())}`
147
- + `${pad2(now.getHours())}${pad2(now.getMinutes())}`;
148
- }
149
- /** 把文本变成 JS 字符串字面量(单引号包裹),保证零双引号、无裸换行。 */
150
- function jsStr(text) {
151
- let s = truthyText(text);
152
- s = s.split('\r\n').join(' ').split('\n').join(' ').split('\r').join(' ');
153
- s = s.replace(/ {2,}/gu, ' ');
154
- s = s.split('</script>').join('<\\/script>'); // 防止外层 script 提前闭合
155
- s = s.split('"').join("'"); // 双引号归零
156
- s = s.split('\\').join('\\\\'); // 先转义已有反斜杠
157
- s = s.split('<\\\\/script>').join('<\\/script>'); // 恢复 script 转义
158
- s = s.split("'").join("\\'"); // 单引号转义
159
- return `'${s}'`;
160
- }
161
- /** Python `str(x or '').replace("'", '').replace(chr(92), '')`:去掉单引号与反斜杠。 */
162
- function safeInline(value) {
163
- return truthyText(value).split("'").join('').split('\\').join('');
164
- }
165
- /**
166
- * 从多种入参形态里取出一侧比对文件。
167
- *
168
- * 兼容三类来源:`{fileId,fileName}` 对象、`comparePair` 里的平铺字段、顶层平铺字段。
169
- * 任一来源给出非空 fileId 即采用(对象优先),全空返回 undefined。
170
- */
171
- function pickCompareFileRef(objects, ids, names) {
172
- for (const candidate of objects) {
173
- if (!candidate || typeof candidate !== 'object')
174
- continue;
175
- const row = candidate;
176
- const fileId = truthyText(row.fileId) || truthyText(row.file_id);
177
- if (!fileId)
178
- continue;
179
- return { fileId, fileName: truthyText(row.fileName) || truthyText(row.file_name) };
180
- }
181
- const fileId = ids.map((item) => truthyText(item)).find((item) => item.length > 0);
182
- if (!fileId)
183
- return undefined;
184
- const fileName = names.map((item) => truthyText(item)).find((item) => item.length > 0) || '';
185
- return { fileId, fileName };
186
- }
187
- /** 按 action id 生成 handler 函数体;返回 null 表示缺关键参数、该卡不进。 */
188
- function buildHandler(action, cfg) {
189
- const aid = String(action.id ?? '');
190
- const meta = ACTION_META.get(aid) ?? [aid, 'doc', 'sendQuestion'];
191
- const dom = `c-${meta[0]}`;
192
- if (aid === 'launch-flow') {
193
- const wid = FLOW_IDS.get(cfg.flow_key || '');
194
- // flowKey 未定(报价单刚转出合同、未判类型)→ 提示语卡:发消息由对话侧判类型后办理。
195
- // 2026-11-16 修复:旧实现此处直接 return null,把「发起合同流程」整张卡吞掉,
196
- // 表现为「只有查资信一张卡」,且引擎侧 planned 里仍有它,排查时极易误判为引擎问题。
197
- if (!wid)
198
- return { dom, body: "function(){send('按这份合同发起合同流程');}" };
199
- let src = `${cfg.base}/sp/workflow/flowpage/create/${wid}?workflowId=${wid}&isCreate=1`;
200
- if (cfg.file_id)
201
- src += `&fileId=${cfg.file_id}`;
202
- // 要素预填走 params.customParams(aiExtraId + openSource + 合同文件字段),
203
- // 与 SKILL.md 红线14 一致;缺 aiExtraId 时退回「只带附件预览」的旧行为。
204
- let rawKeys = cfg.field_assign_keys || '';
205
- if (Array.isArray(rawKeys))
206
- rawKeys = rawKeys.map((item) => String(item)).join(',');
207
- let keyStr = String(rawKeys ?? '')
208
- .split(',')
209
- .map((item) => item.trim())
210
- .filter((item) => item.length > 0)
211
- .join(',');
212
- if (!keyStr && cfg.attachment_field_id)
213
- keyStr = safeInline(cfg.attachment_field_id);
214
- const cp = [];
215
- const extraQ = [];
216
- if (cfg.ai_extra_id) {
217
- cp.push(`aiExtraId:'${safeInline(cfg.ai_extra_id)}'`);
218
- cp.push("openSource:'xiaoE'");
219
- extraQ.push(`aiExtraId=${safeInline(cfg.ai_extra_id)}`);
220
- extraQ.push('openSource=xiaoE');
221
- if (cfg.attachment_field_id && cfg.file_id) {
222
- cp.push(`'${safeInline(cfg.attachment_field_id)}':'${safeInline(cfg.file_id)}'`);
223
- extraQ.push(`${safeInline(cfg.attachment_field_id)}=${safeInline(cfg.file_id)}`);
224
- }
225
- // fieldAssignKeys / initialCovertName:customParams 与 src 两处同值
226
- if (keyStr) {
227
- cp.push(`fieldAssignKeys:'${keyStr}'`);
228
- extraQ.push(`fieldAssignKeys=${keyStr}`);
229
- }
230
- // initialCovertName 固定传 1,与 fieldAssignKeys 是否为空无关
231
- cp.push('initialCovertName:1');
232
- extraQ.push('initialCovertName=1');
233
- }
234
- // 逐值拼接,不做整体编码(值均为数字/固定串)
235
- if (extraQ.length)
236
- src += `&${extraQ.join('&')}`;
237
- // customParams 放在 sdkOptions.params 下,params_pc / params_mobile 只放 app 与 compName
238
- let params = "params_pc:{app:'@weapp/workflow',compName:'Comp.WffpRoute'},"
239
- + "params_mobile:{app:'@weapp/workflow',compName:'Comp.MWffpRoute',noMDialog:true}";
240
- if (cp.length)
241
- params += `,params:{customParams:{${cp.join(',')}}}`;
242
- const body = `function(){op({type:'e10Sdk',width:__W__,contentProps:{src:'${src}',`
243
- + "sdkOptions:{compName:'ui.CorsComponent',routerType:'MemoryRouter',"
244
- + `routerProps_pc:{initialEntries:['/flowpage/create/${wid}']},`
245
- + `routerProps_mobile:{initialEntries:['/flowpage/create/${wid}']},`
246
- + `${params}}}});}`;
247
- return { dom, body };
248
- }
249
- if (aid === 'view-review') {
250
- const fileName = (cfg.file_name || '').split("'").join('');
251
- const body = "function(){op({type:'e10Sdk',width:__W__,contentProps:{"
252
- + `src:'${cfg.base}/sp/contract/business/ai-contract',`
253
- + "sdkOptions:{compName:'ui.CorsComponent',routerType:'MemoryRouter',"
254
- + "routerProps:{initialEntries:['/sp/contract/business/ai-contract']},"
255
- + "params:{app:'@weapp/contract',compName:'AIContractV2',"
256
- + `aiProps:{aiid:'${cfg.aiid}',fileId:'${cfg.file_id || ''}',fileName:'${fileName}'}}}}});}`;
257
- return { dom, body };
258
- }
259
- if (aid === 'credit') {
260
- const company = cfg.company_name;
261
- if (!company)
262
- return { dom, body: null };
263
- const body = "function(){op({type:'e10Sdk',width:__W__,contentProps:{"
264
- + `src:'${cfg.base}/sp/contract/business/credit',`
265
- + "sdkOptions:{compName:'ui.CorsComponent',routerType:'MemoryRouter',"
266
- + "routerProps:{initialEntries:['/sp/contract/business/credit']},"
267
- + "params:{app:'@weapp/contract',compName:'ContractCreditDetail',"
268
- + `companyName:['${company.split("'").join('')}']}}}});}`;
269
- return { dom, body };
270
- }
271
- if (aid === 'view-compare') {
272
- const baseFile = cfg.base_file;
273
- const compareFile = cfg.compare_file;
274
- // 比对页必须带两份文件;缺任一侧时该卡不出(空壳卡能打开但左右栏全空,且全程无报错)
275
- if (!baseFile?.fileId || !compareFile?.fileId)
276
- return { dom, body: null };
277
- const body = "function(){op({type:'e10Sdk',width:__W__,contentProps:{"
278
- + `src:'${cfg.base}/sp/contract/business/doc-compare',`
279
- + "sdkOptions:{compName:'ui.CorsComponent',routerType:'MemoryRouter',"
280
- + "routerProps:{initialEntries:['/sp/contract/business/doc-compare']},"
281
- + "params:{app:'@weapp/contract',compName:'AIDocCompare',"
282
- + `baseFile:{fileId:'${safeInline(baseFile.fileId)}',fileName:'${safeInline(baseFile.fileName)}'},`
283
- + `compareFile:{fileId:'${safeInline(compareFile.fileId)}',fileName:'${safeInline(compareFile.fileName)}'}}}}});}`;
284
- return { dom, body };
285
- }
286
- if (aid === 'export-review') {
287
- return { dom, body: "function(){art(R,'合同风险审查报告.html','report-1');}" };
288
- }
289
- if (aid === 'summary') {
290
- return { dom, body: "function(){art(S,'合同摘要.html','summary-1');}" };
291
- }
292
- if (aid === 'export-compare-report') {
293
- return { dom, body: "function(){art(C,'合同比对报告.html','compare-1');}" };
294
- }
295
- // 其余走 sendQuestion
296
- const text = SEND_TEXT.get(aid) || String(action.title ?? '');
297
- return { dom, body: `function(){send('${text.split("'").join('')}');}` };
298
- }
299
- export function renderActionCard(ctx, cfg, template) {
300
- const plan = planActions(ctx);
301
- let cards = plan.cards;
302
- // 支持只输出指定动作(only),用于单独出「发起流程」卡;仍由本渲染器生成,禁止手写卡片。
303
- if (cfg.only.length) {
304
- cards = cards.filter((card) => cfg.only.includes(String(card.id)));
305
- }
306
- const parts = [];
307
- const handlers = [];
308
- cards.forEach((card, index) => {
309
- const meta = ACTION_META.get(String(card.id)) ?? [String(card.id), 'doc', 'sendQuestion'];
310
- const { dom, body } = buildHandler(card, cfg);
311
- // 缺关键参数(如 flowKey 未映射、无企业全称)→ 该卡不进
312
- if (body === null)
313
- return;
314
- parts.push(CARD_TPL
315
- .split('{dom_id}').join(dom)
316
- .split('{mb}').join(index === cards.length - 1 ? '' : 'margin-bottom:12px;')
317
- .split('{icon}').join(SVG[meta[1]] ?? SVG.doc)
318
- .split('{title}').join(String(card.title ?? ''))
319
- .split('{badge}').join(index === 0 ? BADGE : '')
320
- .split('{desc}').join(String(card.desc ?? '')));
321
- handlers.push({ dom, body });
322
- });
323
- if (!parts.length) {
324
- return { payload: null, planned: cards.map((card) => String(card.id)), cardCount: 0, hint: plan.hint };
325
- }
326
- let bodyJs = JS_BASE;
327
- // hb 本身已是 function(){...},这里只做赋值,不要再包一层 function hN(){}
328
- handlers.forEach((handler, index) => {
329
- bodyJs += `var h${index}=${handler.body};`;
330
- });
331
- handlers.forEach((handler, index) => {
332
- bodyJs += `bind('${handler.dom}',h${index});`;
333
- });
334
- bodyJs += `say('就绪,共 ${handlers.length} 个动作');`;
335
- // 必须拼完全部脚本后统一替换,覆盖 JS_BASE 与所有 handler(否则 handler 里的
336
- // width:__W__ 残留,点击抛 ReferenceError 被 try/catch 吞成「面板打开失败」)
337
- bodyJs = bodyJs.split('__W__').join(String(WIDTH));
338
- const summaryJs = jsStr(cfg.summary_html || '');
339
- const reportJs = jsStr(cfg.report_html || '');
340
- const compareJs = jsStr(cfg.compare_html || '');
341
- // 只取正文起点:模板头部是说明注释,不能进 customParams.html。
342
- // 必须按「section 开标签且带 id 属性」定位,不能 indexOf('<section')——
343
- // 注释里只要出现该字样就会误命中,导致多出一个未闭合的开标签。
344
- const match = /<section\s+id=/u.exec(template);
345
- if (!match) {
346
- throw contractValidationError('template_invalid', '模板缺少带 id 的 section,无法渲染');
347
- }
348
- const body = template.slice(match.index);
349
- const html = body
350
- .split('{{CARD_ID}}').join(cfg.card_id)
351
- .split('{{CARDS}}').join(parts.join('\n'))
352
- .split('{{SUMMARY_JS}}').join(summaryJs)
353
- .split('{{COMPARE_JS}}').join(compareJs)
354
- .split('{{REPORT_JS}}').join(reportJs)
355
- .split('{{BODY}}').join(bodyJs);
356
- const count = handlers.length;
357
- let title = cfg.title ? cfg.title : `可做的 ${count} 件事`;
358
- title = title.replace(/[\\/:*?"<>|]/gu, ' ');
359
- const payload = {
360
- version: 1,
361
- callId: cfg.call_id,
362
- toolId: 'fill_form',
363
- arguments: {
364
- type: 'e10',
365
- title,
366
- src: `${cfg.base}/sp/contract/xiaoe-custom-page`,
367
- width: WIDTH,
368
- sdkRenderType: 'inline',
369
- sdkOptions: {
370
- compName: 'ui.CorsComponent',
371
- routerType: 'MemoryRouter',
372
- routerProps_pc: { initialEntries: ['/sp/contract/xiaoe-custom-page'] },
373
- params_pc: {
374
- app: '@weapp/contract',
375
- compName: 'xiaoeCustomPage',
376
- customParams: { html },
377
- },
378
- },
379
- },
380
- };
381
- return { payload, planned: cards.map((card) => String(card.id)), cardCount: count };
382
- }
383
- /** 交付参数白名单:多出来的键会被宿主静默忽略,是高风险拼写错误。 */
384
- const KNOWN_TOP_KEYS = new Set(['version', 'callId', 'toolId', 'arguments']);
385
- const KNOWN_ARG_KEYS = new Set(['type', 'title', 'src', 'width', 'sdkRenderType', 'sdkOptions']);
386
- /** src → 目标页组件名(与 validate_action_card.py 的 E10_COMP_EXPECT 一致)。 */
387
- const E10_COMP_EXPECT = [
388
- ['/sp/contract/business/credit', 'ContractCreditDetail'],
389
- ['/sp/contract/business/ai-contract', 'AIContractV2'],
390
- ['/sp/ebdfpage/list/', 'TableViewList'],
391
- ['/sp/workflow/flowpage/create/', 'Comp.WffpRoute'],
392
- ['/sp/contract/xiaoe-list', 'XiaoeList'],
393
- ];
394
- function eachMatch(re, textValue) {
395
- const out = [];
396
- const flags = re.flags.includes('g') ? re.flags : `${re.flags}g`;
397
- const scan = new RegExp(re.source, flags);
398
- let hit = scan.exec(textValue);
399
- while (hit) {
400
- out.push(hit);
401
- if (hit[0].length === 0)
402
- scan.lastIndex += 1;
403
- hit = scan.exec(textValue);
404
- }
405
- return out;
406
- }
407
- function countOf(hay, needle) {
408
- if (!needle)
409
- return 0;
410
- let count = 0;
411
- let at = hay.indexOf(needle);
412
- while (at !== -1) {
413
- count += 1;
414
- at = hay.indexOf(needle, at + needle.length);
415
- }
416
- return count;
417
- }
418
- /**
419
- * 深度自检:2026-11-13 从 `scripts/validate_action_card.py` 并入的检查项。
420
- *
421
- * 原脚本 511 行、15 项终检,与 `selfCheckActionCard` 已有的引号/反斜杠/ES5/
422
- * hover/语法存在大量重叠。此处只补「原来没查、但一定会导致交付事故」的项:
423
- * 外层 JSON 骨架、元素 id 与绑定目标、状态反馈节点、var S 常量、artifact 键、
424
- * sendQuestion 命名空间、e10Sdk 组件名。重复项由调用方去重,保证一份判据。
425
- *
426
- * 与脚本的两处有意差异(均为避免误报):
427
- * 1) 卡片容器同时认 `<button id=...>` 与 `<div role='button' id=...>`——
428
- * CLI 生成的卡片是 button,脚本只认 div,照搬会把正常卡片判失败;
429
- * 2) 双引号允许 0 个,或恰好是 `var S="..."` 的包裹对,其余一律失败。
430
- */
431
- export function deepCheckActionCard(payload) {
432
- const problems = [];
433
- const warnings = [];
434
- const checks = [];
435
- const pass = (item, detail = '') => {
436
- checks.push({ level: 'PASS', item, detail });
437
- };
438
- const fail = (item, detail) => {
439
- checks.push({ level: 'FAIL', item, detail });
440
- problems.push(`${item}:${detail}`);
441
- };
442
- const warn = (item, detail) => {
443
- checks.push({ level: 'WARN', item, detail });
444
- warnings.push(`${item}:${detail}`);
445
- };
446
- const eqCheck = (actual, expect, item) => {
447
- if (actual === expect)
448
- pass(item);
449
- else
450
- fail(item, `期望 ${String(expect)},实际 ${String(actual)}`);
451
- };
452
- const args = (payload.arguments ?? {});
453
- const sdk = (args.sdkOptions ?? {});
454
- const paramsPc = (sdk.params_pc ?? {});
455
- const routerPc = (sdk.routerProps_pc ?? {});
456
- const html = String((paramsPc.customParams ?? {}).html ?? '');
457
- // ── 外层 JSON 骨架(缺 src / compName / type 时整块不进渲染链路)
458
- eqCheck(payload.version, 1, 'outer.version == 1');
459
- if (String(payload.callId ?? '').trim())
460
- pass('outer.callId 非空');
461
- else
462
- fail('outer.callId 非空', '缺失或为空');
463
- eqCheck(payload.toolId, 'fill_form', "outer.toolId == 'fill_form'");
464
- eqCheck(args.type, 'e10', "arguments.type == 'e10'");
465
- const src = String(args.src ?? '');
466
- if (src.endsWith('/sp/contract/xiaoe-custom-page'))
467
- pass('arguments.src 指向 xiaoe-custom-page');
468
- else
469
- fail('arguments.src 指向 xiaoe-custom-page', `实际 ${src || '<空>'}`);
470
- eqCheck(args.width, CARD_PANEL_WIDTH, `arguments.width == ${CARD_PANEL_WIDTH}`);
471
- eqCheck(args.sdkRenderType, 'inline', "arguments.sdkRenderType == 'inline'");
472
- eqCheck(sdk.compName, 'ui.CorsComponent', "sdkOptions.compName == 'ui.CorsComponent'");
473
- eqCheck(sdk.routerType, 'MemoryRouter', "sdkOptions.routerType == 'MemoryRouter'");
474
- if (Array.isArray(routerPc.initialEntries) && routerPc.initialEntries.length > 0) {
475
- pass('routerProps_pc.initialEntries 非空');
476
- }
477
- else {
478
- fail('routerProps_pc.initialEntries 非空', '缺失或空数组');
479
- }
480
- eqCheck(paramsPc.app, '@weapp/contract', "params_pc.app == '@weapp/contract'");
481
- eqCheck(paramsPc.compName, 'xiaoeCustomPage', "params_pc.compName == 'xiaoeCustomPage'");
482
- if (html)
483
- pass('params_pc.customParams.html 存在', `${html.length} 字符`);
484
- else {
485
- fail('params_pc.customParams.html 存在', '缺失(摘要点开会是空白页)');
486
- return { problems, warnings, checks };
487
- }
488
- const inner = html.replace(/<!--[\s\S]*?-->/gu, '');
489
- // ── 摘要承载方式:禁用 textarea(内容会以纯文本泄漏)
490
- if (inner.toLowerCase().includes('<textarea')) {
491
- fail('不使用 textarea 承载摘要', 'textarea 会把摘要当纯文本渲染');
492
- }
493
- else {
494
- pass('不使用 textarea 承载摘要');
495
- }
496
- // ── 标签配对(内嵌报告的 </script> 可能写成 <\/script>,先归一)
497
- const normalized = inner.split('<\\/script>').join('</script>');
498
- for (const tag of ['section', 'script']) {
499
- const open = countOf(normalized, `<${tag}`);
500
- const close = countOf(normalized, `</${tag}>`);
501
- if (open === close && open > 0)
502
- pass(`<${tag}> 配对`, `${open}`);
503
- else if (open === 0 && close === 0)
504
- warn(`<${tag}> 未出现`, '跳过');
505
- else
506
- fail(`<${tag}> 配对`, `开 ${open} / 闭 ${close}`);
507
- }
508
- // ── 元素 id 唯一 + 事件绑定目标必须存在
509
- // (历史缺陷:绑定到不存在的 id 会被静默跳过,表现为「点了没反应」)
510
- const allIds = [];
511
- for (const hit of eachMatch(/<[a-zA-Z][a-zA-Z0-9]*[^>]*id='([^']+)'/gu, inner)) {
512
- allIds.push(String(hit[1]));
513
- }
514
- const cardIds = [];
515
- for (const hit of eachMatch(/<(button|div)[^>]*id='([^']+)'[^>]*>/gu, inner)) {
516
- const tag = String(hit[1]);
517
- const chunk = String(hit[0]);
518
- if (tag === 'button' || chunk.includes("role='button'"))
519
- cardIds.push(String(hit[2]));
520
- }
521
- if (cardIds.length === 0) {
522
- fail('动作卡带 id', '未找到带 id 的 button 或 div[role=button]');
523
- }
524
- else if (new Set(cardIds).size !== cardIds.length) {
525
- fail('卡片 id 唯一', `重复:${cardIds.join(',')}`);
526
- }
527
- else {
528
- pass('卡片 id 唯一', `${cardIds.length} 张`);
529
- }
530
- const targets = [];
531
- for (const hit of eachMatch(/getElementById\('([^']+)'\)/gu, inner))
532
- targets.push(String(hit[1]));
533
- for (const hit of eachMatch(/bind\('([^']+)'/gu, inner))
534
- targets.push(String(hit[1]));
535
- if (targets.length === 0) {
536
- fail('事件绑定目标存在', '未找到 getElementById / bind 调用');
537
- }
538
- else {
539
- const missing = [...new Set(targets)].filter((id) => !allIds.includes(id));
540
- if (missing.length > 0)
541
- fail('事件绑定目标存在', `缺少 id:${missing.join(',')}`);
542
- else
543
- pass('事件绑定目标存在', `${new Set(targets).size} 个`);
544
- }
545
- // ── 状态反馈节点(点击失败必须有可见提示,否则静默失效)
546
- if (inner.includes('data-status') || /id='tip'/u.test(inner)) {
547
- pass('有可见状态反馈节点');
548
- }
549
- else {
550
- fail('有可见状态反馈节点', '无 data-status / id=tip,失败会静默');
551
- }
552
- // ── var S 摘要常量(反斜杠安全转义已由调用方统一检查,这里只查闭合与裸双引号)
553
- const sAt = inner.indexOf('var S=');
554
- if (sAt === -1) {
555
- warn('var S 摘要常量存在', '未找到,跳过常量检查');
556
- }
557
- else {
558
- const closed = /^var S=(['"])([\s\S]*?)\1;/u.exec(inner.slice(sAt));
559
- if (!closed) {
560
- fail('var S 常量正确闭合', '找不到闭合引号');
561
- }
562
- else {
563
- const value = String(closed[2]);
564
- const innerQuotes = countOf(value, '"');
565
- if (innerQuotes === 0)
566
- pass('var S 内无裸双引号');
567
- else
568
- fail('var S 内无裸双引号', `${innerQuotes} 个,字符串会提前闭合`);
569
- }
570
- }
571
- // ── artifact 必须带 initialArtifactKeys,且与 artifacts[].id 匹配
572
- if (inner.includes('artifact')) {
573
- if (!inner.includes('initialArtifactKeys')) {
574
- fail('artifact 带 initialArtifactKeys', '缺失会导致面板空白或打开错文档');
575
- }
576
- else {
577
- pass('artifact 带 initialArtifactKeys');
578
- const artIds = [];
579
- for (const hit of eachMatch(/artifacts:\s*\[\s*\{\s*id:\s*'([^']+)'/gu, inner)) {
580
- artIds.push(String(hit[1]));
581
- }
582
- const keyBlock = /initialArtifactKeys:\s*\[([^\]]*)\]/u.exec(inner);
583
- if (artIds.length > 0 && keyBlock) {
584
- const keys = String(keyBlock[1])
585
- .split(',')
586
- .map((item) => item.trim().replace(/^['"]|['"]$/gu, ''))
587
- .filter((item) => item.length > 0);
588
- if (keys.some((key) => artIds.includes(key)))
589
- pass('initialArtifactKeys 与 artifacts.id 匹配');
590
- else
591
- fail('initialArtifactKeys 与 artifacts.id 匹配', `keys=${keys.join(',')} ids=${artIds.join(',')}`);
592
- }
593
- }
594
- }
595
- // ── 摘要必须由常量承载(raw.html:S 却无 var S 时点开是空白)
596
- if (/raw:\s*\{\s*html:\s*S\s*\}/u.test(inner)) {
597
- if (inner.includes('var S'))
598
- pass('摘要由 var S 常量承载');
599
- else
600
- fail('摘要由 var S 常量承载', 'raw.html:S 但未定义 var S');
601
- }
602
- // ── sendQuestion 必须走 session 命名空间且传对象(写成 plugin.sendQuestion 会静默不发)
603
- const sqCalls = eachMatch(/([A-Za-z0-9_$.]+)\s*\.\s*sendQuestion\s*\(/gu, inner);
604
- if (sqCalls.length === 0) {
605
- if (/[^A-Za-z0-9_$.]sendQuestion\s*\(/u.test(inner)) {
606
- fail('sendQuestion 走 session 命名空间', '存在裸 sendQuestion(...) 调用');
607
- }
608
- else {
609
- pass('sendQuestion 未调用(跳过)');
610
- }
611
- }
612
- else {
613
- const badNs = sqCalls.filter((hit) => String(hit[1]).split('.').pop() !== 'session');
614
- if (badNs.length > 0) {
615
- fail('sendQuestion 走 session 命名空间', `实际 ${badNs.map((hit) => hit[0]).join(', ')}`);
616
- }
617
- else {
618
- pass('sendQuestion 走 session 命名空间', `${sqCalls.length} 处`);
619
- }
620
- let badArg = 0;
621
- for (const hit of sqCalls) {
622
- const from = (hit.index ?? 0) + hit[0].length;
623
- const tail = inner.slice(from, from + 200);
624
- if (!/^\s*\{/u.test(tail) || !/question\s*:/u.test(tail))
625
- badArg += 1;
626
- }
627
- if (badArg > 0)
628
- fail('sendQuestion 传 {question, files}', `${badArg} 处不是对象字面量`);
629
- else
630
- pass('sendQuestion 传 {question, files}');
631
- }
632
- // ── e10Sdk 必须带 params.compName 且与 src 对应(漏写时白屏但无 JS 错误)
633
- const sdkStarts = eachMatch(/type\s*:\s*'e10Sdk'/gu, inner).map((hit) => hit.index ?? 0);
634
- if (sdkStarts.length === 0) {
635
- pass('e10Sdk compName(无调用,跳过)');
636
- }
637
- else {
638
- const fails = [];
639
- sdkStarts.forEach((start, index) => {
640
- const end = index + 1 < sdkStarts.length ? sdkStarts[index + 1] : Math.min(inner.length, start + 3000);
641
- const seg = inner.slice(start, end);
642
- const srcHit = /src\s*:\s*'([^']+)'/u.exec(seg);
643
- const pageSrc = srcHit ? String(srcHit[1]) : '';
644
- const inParams = /params\s*:\s*\{[^{}]*?compName\s*:\s*'([^']+)'/u.exec(seg);
645
- const inParamsPc = /params_pc\s*:\s*\{[^{}]*?compName\s*:\s*'([^']+)'/u.exec(seg);
646
- const compName = inParams ? String(inParams[1]) : inParamsPc ? String(inParamsPc[1]) : '';
647
- const expected = E10_COMP_EXPECT.find(([path]) => pageSrc.includes(path))?.[1];
648
- if (!compName)
649
- fails.push(`${pageSrc || '<无 src>'} 缺 compName(期望 ${expected || '?'})`);
650
- else if (expected && compName !== expected)
651
- fails.push(`${pageSrc} compName=${compName},期望 ${expected}`);
652
- });
653
- if (fails.length > 0)
654
- fail('e10Sdk compName 与 src 对应', fails.join(';'));
655
- else
656
- pass('e10Sdk compName 与 src 对应', `${sdkStarts.length} 处`);
657
- }
658
- return { problems, warnings, checks };
659
- }
660
- /**
661
- * 内容级自检:2026-11-13 从 `scripts/verify_card_delivery.py` 下沉(脚本已下线)。
662
- *
663
- * 原脚本 7 项里,html 非空 / hover 绑定 / 非安全转义已由
664
- * `deepCheckActionCard`(html 非空、绑定目标与状态反馈)和
665
- * `selfCheckActionCard`(hover 视觉反馈、反斜杠转义)覆盖,此处不重复实现。
666
- * 只补原先查不到、又一定导致交付事故的内容项:
667
- * 1. 流程卡 src 的 fileId 存在且与 cfg.file_id 同源;
668
- * 2. customParams 合同文件字段值与 cfg.file_id 同源;
669
- * 3. 审查详情卡 aiProps 的 aiid / fileId / fileName 非空且与 cfg 一致;
670
- * 4. 被 art() 引用的 var S / R / C 常量非空(≥20 字符)且上游确有内容;
671
- * 5. payload 顶层与 arguments 的未知参数。
672
- *
673
- * 判据不另起炉灶:结果合并进 selfCheck 的同一份 problems / warnings / checks。
674
- */
675
- export function contentCheckActionCard(payload, expected) {
676
- const problems = [];
677
- const warnings = [];
678
- const checks = [];
679
- const pass = (item, detail = '') => {
680
- checks.push({ level: 'PASS', item, detail });
681
- };
682
- const fail = (item, detail) => {
683
- checks.push({ level: 'FAIL', item, detail });
684
- problems.push(`${item}:${detail}`);
685
- };
686
- const warn = (item, detail) => {
687
- checks.push({ level: 'WARN', item, detail });
688
- warnings.push(`${item}:${detail}`);
689
- };
690
- const html = String(payload.arguments?.sdkOptions?.params_pc?.customParams?.html ?? '');
691
- const wantFileId = String(expected.fileId ?? '').trim();
692
- // ── 1) 流程卡 src.fileId:缺 fileId 或与 cfg 不同源,流程附件会挂错文件
693
- const flowSegments = eachMatch(/flowpage\/create\/[^']*/gu, html).map((hit) => String(hit[0]));
694
- const flowIds = [];
695
- for (const seg of flowSegments) {
696
- for (const hit of eachMatch(/fileId=(\d+)/gu, seg))
697
- flowIds.push(String(hit[1]));
698
- }
699
- const hasFlowSrc = flowSegments.some((seg) => seg.includes('workflowId='));
700
- if (!hasFlowSrc) {
701
- pass('流程卡 fileId 归属', '无流程卡,跳过');
702
- }
703
- else if (flowIds.length === 0) {
704
- fail('流程卡 fileId 归属', '流程卡 src 缺 fileId=(cfg.file_id 为空,附件会挂不到文件)');
705
- }
706
- else if (!wantFileId) {
707
- fail('流程卡 fileId 归属', 'cfg.file_id 为空,但流程卡带了 fileId(渲染器与 cfg 不一致)');
708
- }
709
- else {
710
- const uniq = [...new Set(flowIds)];
711
- const bad = uniq.filter((id) => id !== wantFileId);
712
- if (bad.length)
713
- fail('流程卡 fileId 归属', `卡片=${uniq.join(',')},应为=${wantFileId}(流程附件会挂错文件)`);
714
- else
715
- pass('流程卡 fileId 归属', uniq.join(','));
716
- }
717
- // ── 2) customParams 合同附件字段值也必须等于 cfg.file_id
718
- const fieldPairs = eachMatch(/'(\d{10,})'\s*:\s*'(\d{10,})'/gu, html);
719
- if (fieldPairs.length === 0) {
720
- pass('customParams 附件字段归属', '无预填附件字段,跳过');
721
- }
722
- else if (!wantFileId) {
723
- fail('customParams 附件字段归属', '存在附件字段但 cfg.file_id 为空');
724
- }
725
- else {
726
- const bad = fieldPairs.map((hit) => String(hit[2])).filter((value) => value !== wantFileId);
727
- if (bad.length)
728
- fail('customParams 附件字段归属', `字段值=${bad.join(',')},应为=${wantFileId}`);
729
- else
730
- pass('customParams 附件字段归属', `${fieldPairs.length} 处`);
731
- }
732
- // ── 3) 审查详情卡 aiProps:三个值缺一个,审查页就打不开文件
733
- const reviewHit = /aiProps:\{aiid:'([^']*)',fileId:'([^']*)',fileName:'([^']*)'\}/u.exec(html);
734
- if (!reviewHit) {
735
- pass('审查详情卡 aiProps', '无审查详情入口,跳过');
736
- }
737
- else {
738
- const aiid = String(reviewHit[1]);
739
- const fid = String(reviewHit[2]);
740
- const fname = String(reviewHit[3]).trim();
741
- const wantAiid = String(expected.aiid ?? '').trim();
742
- const wantName = String(expected.fileName ?? '').split("'").join('').trim();
743
- if (!aiid)
744
- fail('审查详情卡 aiid', '为空(审查页打不开)');
745
- else if (wantAiid && aiid !== wantAiid)
746
- fail('审查详情卡 aiid', `卡片=${aiid},应为=${wantAiid}`);
747
- else
748
- pass('审查详情卡 aiid', aiid);
749
- if (!fid)
750
- fail('审查详情卡 fileId 归属', '为空(审查页打不开文件)');
751
- else if (!wantFileId)
752
- fail('审查详情卡 fileId 归属', `卡片=${fid},但 cfg.file_id 为空`);
753
- else if (fid !== wantFileId)
754
- fail('审查详情卡 fileId 归属', `卡片=${fid},应为=${wantFileId}`);
755
- else
756
- pass('审查详情卡 fileId 归属', fid);
757
- if (!fname)
758
- fail('审查详情卡 fileName', '为空(审查页打不开文件)');
759
- else if (wantName && fname !== wantName)
760
- warn('审查详情卡 fileName', `卡片=${fname},cfg.file_name=${wantName}`);
761
- else
762
- pass('审查详情卡 fileName', fname);
763
- }
764
- // ── 3.5) 比对详情卡 params:缺 baseFile / compareFile 时页面能打开,但左右栏全空且不报错
765
- const compareHit = /compName:'AIDocCompare',baseFile:\{fileId:'([^']*)',fileName:'([^']*)'\},compareFile:\{fileId:'([^']*)',fileName:'([^']*)'\}/u.exec(html);
766
- const hasCompareSrc = /\/sp\/contract\/business\/doc-compare/u.test(html);
767
- if (!hasCompareSrc) {
768
- pass('比对详情卡 baseFile/compareFile', '无比对详情入口,跳过');
769
- }
770
- else if (!compareHit) {
771
- fail('比对详情卡 baseFile/compareFile', 'params 缺 baseFile/compareFile(左右栏全空,且不报错)');
772
- }
773
- else {
774
- const cardBaseId = String(compareHit[1]).trim();
775
- const cardCompareId = String(compareHit[3]).trim();
776
- const wantBaseId = String(expected.baseFileId ?? '').trim();
777
- const wantCompareId = String(expected.compareFileId ?? '').trim();
778
- if (!cardBaseId)
779
- fail('比对详情卡 baseFile', 'fileId 为空(左栏空白)');
780
- else if (!wantBaseId)
781
- fail('比对详情卡 baseFile', `卡片=${cardBaseId},但 cfg.base_file 为空`);
782
- else if (cardBaseId !== wantBaseId)
783
- fail('比对详情卡 baseFile', `卡片=${cardBaseId},应为=${wantBaseId}`);
784
- else
785
- pass('比对详情卡 baseFile', cardBaseId);
786
- if (!cardCompareId)
787
- fail('比对详情卡 compareFile', 'fileId 为空(右栏空白)');
788
- else if (!wantCompareId)
789
- fail('比对详情卡 compareFile', `卡片=${cardCompareId},但 cfg.compare_file 为空`);
790
- else if (cardCompareId !== wantCompareId)
791
- fail('比对详情卡 compareFile', `卡片=${cardCompareId},应为=${wantCompareId}`);
792
- else
793
- pass('比对详情卡 compareFile', cardCompareId);
794
- }
795
- // ── 4) 被 art() 引用的内容常量:空常量点开就是空白页,且不会报 JS 错误
796
- const consts = new Map();
797
- for (const hit of eachMatch(/var ([SRC])='((?:[^'\\]|\\.)*)'/gu, html)) {
798
- consts.set(String(hit[1]), String(hit[2]));
799
- }
800
- const used = [...new Set(eachMatch(/art\(\s*([SRC])\s*,/gu, html).map((hit) => String(hit[1])))].sort();
801
- const upstream = {
802
- S: String(expected.summaryHtml ?? ''),
803
- R: String(expected.reportHtml ?? ''),
804
- C: String(expected.compareHtml ?? ''),
805
- };
806
- if (used.length === 0) {
807
- pass('内容常量 var S/R/C', '无 artifact 引用,跳过');
808
- }
809
- else {
810
- for (const name of used) {
811
- const item = `内容常量 var ${name}`;
812
- const body = consts.get(name);
813
- const source = upstream[name] || '';
814
- if (body === undefined)
815
- fail(item, 'art() 引用了未声明的常量');
816
- else if (body.trim().length < 20) {
817
- fail(item, `为空或过短(${body.trim().length} 字符,上游 ${source.length} 字符),点开是空白页`);
818
- }
819
- else if (!source.trim()) {
820
- fail(item, `上游内容为空,但卡片出现 ${body.trim().length} 字符(渲染器与 cfg 不一致)`);
821
- }
822
- else
823
- pass(item, `${body.trim().length} 字符`);
824
- }
825
- }
826
- // ── 5) payload 未知参数:宿主会静默忽略,拼错参数名时排查成本极高
827
- const args = (payload.arguments ?? {});
828
- const extraTop = Object.keys(payload).filter((key) => !KNOWN_TOP_KEYS.has(key));
829
- const extraArgs = Object.keys(args).filter((key) => !KNOWN_ARG_KEYS.has(key));
830
- if (extraTop.length || extraArgs.length) {
831
- fail('payload 参数识别', `未识别参数:${[...extraTop, ...extraArgs].sort().join(',')}(会被静默忽略)`);
832
- }
833
- else {
834
- pass('payload 参数识别', `arguments ${Object.keys(args).length} 个键`);
835
- }
836
- return { problems, warnings, checks };
837
- }
838
- /** 交付前自检:引号、反斜杠、`__W__` 残留、ES5、hover 绑定、脚本语法、内容级项。 */
839
- export function selfCheckActionCard(payload, expected) {
840
- const problems = [];
841
- const html = String(payload.arguments?.sdkOptions?.params_pc?.customParams?.html ?? '');
842
- const doubleQuotes = (html.match(/"/gu) ?? []).length;
843
- // 只允许 0 个,或恰好是 var S="..." 的那一对(与 validate_action_card.py 口径一致)
844
- const sWrapped = /var S="/u.test(html);
845
- if (doubleQuotes !== 0 && !(doubleQuotes === 2 && sWrapped)) {
846
- problems.push(`html 内双引号 ${doubleQuotes} 个(只允许 0,或 var S="..." 的包裹对)`);
847
- }
848
- // 允许三类安全转义:`\\`(合法双反斜杠,jsStr 会把内嵌内容里的原始 \ 翻倍)、
849
- // `<\/script>`(闭标签转义)、`\'`(单引号转义)。
850
- // 内嵌报告若自带 `\'`(如 charset=\'utf-8\'),jsStr 会逐级转成 `\\\'`,
851
- // 只认后两种会让合法内容被误判成非安全转义(2026-11-16 实测误报 4 处)。
852
- const unsafe = (html.match(/\\(?!\\|\/script>|')/gu) ?? []).length;
853
- if (unsafe)
854
- problems.push(`非安全转义反斜杠 ${unsafe} 处`);
855
- const scriptMatch = /<script>([\s\S]*)<\/script>/u.exec(html);
856
- // ES5 只扫脚本正文:html 里可能有说明文字/属性,不能当语法看
857
- const jsCode = scriptMatch ? scriptMatch[1] : html;
858
- // 宽度占位符必须已全部替换。残留时点击抛 ReferenceError,又被 handler 的
859
- // try/catch 吞掉,只显示「面板打开失败」,属静默故障。
860
- const placeholders = (jsCode.split('__W__').length - 1);
861
- if (placeholders)
862
- problems.push(`残留未替换的宽度占位符 __W__ ${placeholders} 处(点击会 ReferenceError)`);
863
- const esPatterns = [
864
- [/=>/u, 'arrow'],
865
- [/\bconst\b/u, 'const'],
866
- [/\blet\b/u, 'let'],
867
- [/\?\?/u, '??'],
868
- [/\?\./u, '?.'],
869
- [/`/u, 'template literal'],
870
- ];
871
- for (const [pattern, name] of esPatterns) {
872
- if (pattern.test(jsCode))
873
- problems.push(`ES5 违规:${name}`);
874
- }
875
- // 可点卡片必须同时具备 click、hover 绑定与视觉变化:
876
- // 只绑 click 用户不知道能点;只绑 hover 无样式变化等于没有反馈。
877
- const hasClick = jsCode.includes('onclick') || jsCode.includes("addEventListener('click'");
878
- const hasHover = jsCode.includes('mouseenter') || jsCode.includes('mouseover');
879
- const hasHoverStyle = jsCode.includes('borderColor') || jsCode.includes('boxShadow');
880
- if (hasClick && !hasHover) {
881
- problems.push('缺少 hover 绑定:有 click 但无 mouseenter/mouseover');
882
- }
883
- else if (hasClick && hasHover && !hasHoverStyle) {
884
- problems.push('缺少 hover 视觉反馈:无 borderColor/boxShadow 变化');
885
- }
886
- if (!scriptMatch) {
887
- problems.push('未找到 script');
888
- }
889
- else {
890
- try {
891
- // 等价 `node --check`:按 script 语义解析,不执行
892
- // eslint-disable-next-line no-new
893
- new Script(jsCode);
894
- }
895
- catch (error) {
896
- const message = error instanceof Error ? error.message : String(error);
897
- problems.push(`node --check 失败:${message.split('\n').slice(0, 3).join(' / ')}`);
898
- }
899
- }
900
- const cardCount = (html.match(/<button type='button'/gu) ?? []).length;
901
- // 2026-11-13:并入原 scripts/validate_action_card.py 的终检项(该脚本已下线)。
902
- // 两处 problems 去重后返回,保证交付判据只有一份。
903
- const deep = deepCheckActionCard(payload);
904
- for (const item of deep.problems) {
905
- if (!problems.includes(item))
906
- problems.push(item);
907
- }
908
- const warnings = [...deep.warnings];
909
- const checks = [...deep.checks];
910
- // 2026-11-13 第九批下沉:原 scripts/verify_card_delivery.py 的内容级项(脚本已下线)。
911
- // expected 由 operation 用内部 cfg 构造;不传时仍兼容纯结构自检的旧调用方。
912
- // 不新增 contract.card.verify:判据只认 selfCheck / selfCheckChecks / selfCheckPassed。
913
- if (expected) {
914
- const content = contentCheckActionCard(payload, expected);
915
- for (const item of content.problems) {
916
- if (!problems.includes(item))
917
- problems.push(item);
918
- }
919
- for (const item of content.warnings) {
920
- if (!warnings.includes(item))
921
- warnings.push(item);
922
- }
923
- checks.push(...content.checks);
924
- }
925
- return {
926
- problems,
927
- warnings,
928
- checks,
929
- cardCount,
930
- htmlLength: html.length,
931
- };
932
- }
933
- /**
934
- * 成品 `<browsertool>` 文本校验:外层 JSON 可解析 + 内层脚本语法可解析。
935
- *
936
- * 与 `selfCheckActionCard` 的分工:那个查「构造出来的对象」是否合规,
937
- * 这个查「最终要发出去的那段字符串」是否还能被宿主解析。手改少一层反斜杠
938
- * (如 JSON 里写成 `\'`)时对象层完全正常,只有本函数能在交付前拦住。
939
- */
940
- export function verifyBrowsertoolText(text) {
941
- const raw = String(text ?? '');
942
- const bytes = Buffer.byteLength(raw, 'utf8');
943
- const trimmed = raw.trim();
944
- if (!trimmed)
945
- return { passed: false, problems: ['内容为空'], bytes };
946
- const problems = [];
947
- if (trimmed.startsWith('```')) {
948
- problems.push('被代码围栏包裹(宿主会当普通文本,卡片不渲染)');
949
- }
950
- const openCount = (trimmed.match(/<browsertool>/gu) ?? []).length;
951
- const closeCount = (trimmed.match(/<\/browsertool>/gu) ?? []).length;
952
- if (openCount !== 1 || closeCount !== 1) {
953
- problems.push(`标签不成对:<browsertool> ${openCount} 个、</browsertool> ${closeCount} 个`);
954
- }
955
- const openIndex = trimmed.indexOf('<browsertool>');
956
- const closeIndex = trimmed.lastIndexOf('</browsertool>');
957
- const closeTail = closeIndex + '</browsertool>'.length;
958
- if (openIndex !== 0 || closeIndex < 0 || closeTail !== trimmed.length) {
959
- problems.push('标签外还有内容(闭合标签后不得续写正文,也不得前置说明)');
960
- }
961
- if (openIndex !== 0 || closeIndex <= openIndex) {
962
- return { passed: false, problems, bytes };
963
- }
964
- const payloadText = trimmed.slice('<browsertool>'.length, closeIndex).trim();
965
- let payload;
966
- try {
967
- payload = JSON.parse(payloadText);
968
- }
969
- catch (error) {
970
- const message = error instanceof Error ? error.message : String(error);
971
- const hit = /position (\d+)/u.exec(message);
972
- const at = hit ? Number(hit[1]) : -1;
973
- const from = at >= 0 ? Math.max(0, at - 40) : 0;
974
- const snippet = payloadText.slice(from, from + 80).replace(/\s+/gu, ' ');
975
- problems.push(`外层 JSON 解析失败:${message}(附近:${snippet || '<空>'})`);
976
- return { passed: false, problems, bytes };
977
- }
978
- const args = (payload.arguments ?? {});
979
- if (payload.toolId !== 'fill_form') {
980
- problems.push(`toolId 应为 fill_form,实际 ${String(payload.toolId ?? '<空>')}`);
981
- }
982
- if (args.type !== 'e10') {
983
- problems.push(`arguments.type 应为 e10,实际 ${String(args.type ?? '<空>')}`);
984
- }
985
- if (!String(args.src ?? '').trim())
986
- problems.push('缺少 arguments.src');
987
- if (!(typeof args.width === 'number' && args.width > 0))
988
- problems.push('缺少有效的 arguments.width');
989
- const sdk = (args.sdkOptions ?? {});
990
- const paramsPc = (sdk.params_pc ?? {});
991
- const html = String((paramsPc.customParams ?? {}).html ?? '');
992
- if (!String(paramsPc.compName ?? '').trim()) {
993
- problems.push('缺少 params_pc.compName(组件不会挂载,卡片不显示)');
994
- }
995
- if (!(sdk.routerProps_pc ?? {}).initialEntries) {
996
- problems.push('缺少 sdkOptions.routerProps_pc.initialEntries');
997
- }
998
- if (!html) {
999
- problems.push('缺少 params_pc.customParams.html');
1000
- return { passed: false, problems, bytes };
1001
- }
1002
- // 必须用 indexOf 取**最外层** script 起点:内嵌报告(如风险审查报告)自带 <script>,
1003
- // 而 jsStr 只转义了闭标签 </script> → <\/script>,开标签仍是字面 <script>。
1004
- // 用 lastIndexOf 会命中字符串内部那个开标签,截出的片段从字符串中间开始,
1005
- // 表现为「脚本语法错误:Invalid or unexpected token」(2026-11-16 实测)。
1006
- const scriptOpen = html.indexOf('<script>');
1007
- const scriptClose = html.lastIndexOf('</script>');
1008
- if (scriptOpen < 0 || scriptClose <= scriptOpen) {
1009
- problems.push('html 内缺少完整 <script> 块');
1010
- }
1011
- else {
1012
- const jsCode = html.slice(scriptOpen + '<script>'.length, scriptClose);
1013
- if (jsCode.includes('__W__'))
1014
- problems.push('脚本残留宽度占位符 __W__(点击会 ReferenceError)');
1015
- try {
1016
- // 只编译不执行,等价 node --check
1017
- // eslint-disable-next-line no-new
1018
- new Script(jsCode);
1019
- }
1020
- catch (error) {
1021
- const message = error instanceof Error ? error.message : String(error);
1022
- problems.push(`脚本语法错误:${message.split('\n').slice(0, 3).join(' / ')}`);
1023
- }
1024
- }
1025
- return { passed: problems.length === 0, problems, bytes };
1026
- }
1027
- function isFile(path) {
1028
- try {
1029
- return existsSync(path) && statSync(path).isFile();
1030
- }
1031
- catch {
1032
- return false;
1033
- }
1034
- }
1035
- function readTextOrThrow(path, label) {
1036
- if (!path)
1037
- return '';
1038
- if (!isFile(path)) {
1039
- throw contractValidationError('file_not_found', `${label} 文件不存在:${path}`);
1040
- }
1041
- return readFileSync(path, 'utf8');
1042
- }
1043
- function loadContext(input) {
1044
- const direct = input.context;
1045
- if (direct && typeof direct === 'object' && !Array.isArray(direct)) {
1046
- return { ctx: direct, source: 'context' };
1047
- }
1048
- // contextJson 既接受 JSON 字符串,也接受直接传对象。
1049
- // 历史缺陷(2026-11-16 实测):旧实现只认字符串,传对象时被静默忽略 → 落到目录兜底,
1050
- // 从 out 目录里的 first_screen_result.json 读出旧 flowKey,显式传 null 也压不住,
1051
- // 最终多出一张「发起流程」卡,且流程附件会挂到错误的 fileId 上。
1052
- if (input.contextJson && typeof input.contextJson === 'object' && !Array.isArray(input.contextJson)) {
1053
- return { ctx: input.contextJson, source: 'contextJson' };
1054
- }
1055
- const inline = typeof input.contextJson === 'string' && input.contextJson.trim() ? input.contextJson.trim() : '';
1056
- const fileRaw = typeof input.contextFile === 'string' ? input.contextFile.trim() : '';
1057
- const file = fileRaw ? resolve(fileRaw) : '';
1058
- const explicit = Boolean(inline || fileRaw);
1059
- if (file) {
1060
- if (!isFile(file))
1061
- throw contractValidationError('context_unreadable', `上下文文件不存在:${file}`);
1062
- try {
1063
- const parsed = JSON.parse(readFileSync(file, 'utf8').replace(/^\uFEFF/u, ''));
1064
- if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) {
1065
- throw new Error('上下文必须是 JSON 对象');
1066
- }
1067
- return { ctx: parsed, source: file };
1068
- }
1069
- catch (error) {
1070
- const message = error instanceof Error ? error.message : String(error);
1071
- throw contractValidationError('context_invalid', `上下文不是合法 JSON 对象:${message}`);
1072
- }
1073
- }
1074
- if (inline) {
1075
- try {
1076
- const parsed = JSON.parse(inline);
1077
- if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) {
1078
- throw new Error('上下文必须是 JSON 对象');
1079
- }
1080
- return { ctx: parsed, source: 'contextJson' };
1081
- }
1082
- catch (error) {
1083
- const message = error instanceof Error ? error.message : String(error);
1084
- throw contractValidationError('context_invalid', `上下文不是合法 JSON 对象:${message}`);
1085
- }
1086
- }
1087
- // 显式给了上下文却没用上(如上一步未返回)→ 直接报错,不回落到目录扫描。
1088
- // 回落的后果是静默使用上一轮的旧状态,卡片看起来正常但状态是错的,排查成本极高。
1089
- if (explicit) {
1090
- throw contractValidationError('context_empty', '已传 context 相关参数但未得到有效上下文,请检查取值,不要依赖目录兜底');
1091
- }
1092
- // 兜底:按产物所在目录找 card_context.json / first_screen_result.json
1093
- const dirs = [];
1094
- for (const key of ['out', 'summaryHtml', 'reportHtml', 'compareHtml']) {
1095
- const value = input[key];
1096
- if (typeof value === 'string' && value.trim())
1097
- dirs.push(dirname(resolve(value.trim())));
1098
- }
1099
- dirs.push(process.cwd());
1100
- const seen = new Set();
1101
- for (const dir of dirs) {
1102
- if (!dir || seen.has(dir) || !existsSync(dir))
1103
- continue;
1104
- seen.add(dir);
1105
- for (const name of ['card_context.json', 'first_screen_result.json']) {
1106
- const path = join(dir, name);
1107
- if (!isFile(path))
1108
- continue;
1109
- try {
1110
- let parsed = JSON.parse(readFileSync(path, 'utf8').replace(/^\uFEFF/u, ''));
1111
- if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed))
1112
- continue;
1113
- if (name === 'first_screen_result.json') {
1114
- const ctx = { scene: 'doc', docType: 'contract' };
1115
- if (parsed.workflowFileId || parsed.reviewFileId)
1116
- ctx.hasFileId = true;
1117
- if (parsed.flow)
1118
- ctx.flowKey = parsed.flow;
1119
- if (parsed.summaryHtml)
1120
- ctx.summaryReady = true;
1121
- if (parsed.reportHtml)
1122
- ctx.reviewed = true;
1123
- parsed = ctx;
1124
- }
1125
- return { ctx: parsed, source: path };
1126
- }
1127
- catch {
1128
- continue;
1129
- }
1130
- }
1131
- }
1132
- return { ctx: {}, source: 'minimal' };
1133
- }
1134
- /**
1135
- * 渲染行为卡片(browsertool payload)。
1136
- *
1137
- * 产出可直接裸输出的 `<browsertool>...</browsertool>`(`out` 指定时写入文件)。
1138
- * `selfCheck` 非空表示结构不达标,禁止交付。
1139
- */
1140
- export const contractCardActionOperation = {
1141
- name: 'contract.card.action',
1142
- async execute(input) {
1143
- const { ctx, source } = loadContext(input);
1144
- // 命令行已给出的产物视为对应状态已达成,避免动作被误过滤
1145
- const fileId = truthyText(input.fileId);
1146
- const flowKey = truthyText(input.flowKey);
1147
- const companyName = truthyText(input.companyName);
1148
- const summaryPath = truthyText(input.summaryHtml);
1149
- const reportPath = truthyText(input.reportHtml);
1150
- const comparePath = truthyText(input.compareHtml);
1151
- const setDefault = (key, value) => {
1152
- if (!(key in ctx) || ctx[key] === undefined || ctx[key] === null)
1153
- ctx[key] = value;
1154
- };
1155
- if (fileId) {
1156
- setDefault('hasFileId', true);
1157
- setDefault('fileId', fileId);
1158
- }
1159
- if (flowKey)
1160
- setDefault('flowKey', flowKey);
1161
- if (companyName)
1162
- setDefault('hasCounterparty', true);
1163
- if (summaryPath)
1164
- setDefault('summaryReady', true);
1165
- if (reportPath)
1166
- setDefault('reviewed', true);
1167
- if (comparePath)
1168
- setDefault('compared', true);
1169
- setDefault('scene', 'doc');
1170
- // 比对页要左右两份文件:对象形态优先,其次 comparePair 平铺字段,最后顶层入参
1171
- const rawInput = input;
1172
- const pair = (ctx.comparePair && typeof ctx.comparePair === 'object')
1173
- ? ctx.comparePair
1174
- : {};
1175
- const baseFileRef = pickCompareFileRef([ctx.baseFile, rawInput.baseFile], [pair.baseFileId, ctx.baseFileId, rawInput.baseFileId], [pair.baseFileName, ctx.baseFileName, rawInput.baseFileName]);
1176
- const compareFileRef = pickCompareFileRef([ctx.compareFile, rawInput.compareFile], [pair.compareFileId, ctx.compareFileId, rawInput.compareFileId], [pair.compareFileName, ctx.compareFileName, rawInput.compareFileName]);
1177
- const stamp = stampNow();
1178
- const cfg = {
1179
- file_id: fileId || undefined,
1180
- file_name: truthyText(input.fileName) || undefined,
1181
- flow_key: flowKey || truthyText(ctx.flowKey) || undefined,
1182
- company_name: companyName || undefined,
1183
- summary_html: readTextOrThrow(summaryPath, 'summaryHtml'),
1184
- report_html: readTextOrThrow(reportPath, 'reportHtml'),
1185
- compare_html: readTextOrThrow(comparePath, 'compareHtml'),
1186
- base_file: baseFileRef,
1187
- compare_file: compareFileRef,
1188
- base: (truthyText(input.baseUrl) || DEFAULT_BASE).replace(/\/+$/u, ''),
1189
- aiid: truthyText(input.aiid) || DEFAULT_AIID,
1190
- ai_extra_id: truthyText(input.aiExtraId) || truthyText(ctx.aiExtraId) || '',
1191
- attachment_field_id: truthyText(input.attachmentFieldId) || truthyText(ctx.attachmentFieldId) || '',
1192
- field_assign_keys: truthyText(input.fieldAssignKeys) || ctx.fieldAssignKeys || '',
1193
- card_id: truthyText(input.cardId) || `card-${stamp}`,
1194
- call_id: truthyText(input.callId) || `contract-card-${stamp}-01`,
1195
- title: truthyText(input.title) || undefined,
1196
- only: truthyText(input.only)
1197
- .split(',')
1198
- .map((item) => item.trim())
1199
- .filter((item) => item.length > 0),
1200
- };
1201
- const templatePath = truthyText(input.template);
1202
- const template = templatePath ? readTextOrThrow(resolve(templatePath), 'template') : CARD_TEMPLATE;
1203
- const { payload, planned, cardCount, hint } = renderActionCard(ctx, cfg, template);
1204
- if (!payload) {
1205
- // NO_CARD 属正常收口:按 contract-action-engine.md §7 处理,不写文件
1206
- return {
1207
- status: 'COMPLETE',
1208
- data: {
1209
- noCard: true,
1210
- planned,
1211
- cardCount: 0,
1212
- contextSource: source,
1213
- hint: hint || '过滤后无可用动作(按 contract-action-engine.md §7 处理)',
1214
- },
1215
- };
1216
- }
1217
- // 内容级自检的期望值一律取内部 cfg,不接受调用方另传,避免「自己验自己」。
1218
- const check = selfCheckActionCard(payload, {
1219
- fileId: cfg.file_id || '',
1220
- fileName: cfg.file_name || '',
1221
- aiid: cfg.aiid,
1222
- summaryHtml: cfg.summary_html || '',
1223
- reportHtml: cfg.report_html || '',
1224
- compareHtml: cfg.compare_html || '',
1225
- baseFileId: cfg.base_file?.fileId || '',
1226
- compareFileId: cfg.compare_file?.fileId || '',
1227
- });
1228
- const text = `<browsertool>\n${JSON.stringify(payload, null, 1)}\n</browsertool>`;
1229
- // 成品文本自检:查的是「最终要发出去的那段字符串」。
1230
- // 外层 JSON 非法转义、script 被截断、被代码围栏包裹,只有这一步能拦住。
1231
- for (const item of verifyBrowsertoolText(text).problems) {
1232
- const message = `browsertool 文本校验:${item}`;
1233
- if (!check.problems.includes(message))
1234
- check.problems.push(message);
1235
- }
1236
- let output;
1237
- const outPath = truthyText(input.out);
1238
- if (outPath) {
1239
- output = resolve(outPath);
1240
- mkdirSync(dirname(output), { recursive: true });
1241
- writeFileSync(output, text, 'utf8');
1242
- }
1243
- return {
1244
- status: 'COMPLETE',
1245
- data: {
1246
- noCard: false,
1247
- planned,
1248
- cardCount,
1249
- contextSource: source,
1250
- title: payload.arguments.title,
1251
- callId: payload.callId,
1252
- htmlLength: check.htmlLength,
1253
- selfCheck: check.problems,
1254
- selfCheckWarnings: check.warnings,
1255
- selfCheckChecks: check.checks,
1256
- selfCheckPassed: check.problems.length === 0,
1257
- bytes: Buffer.byteLength(text, 'utf8'),
1258
- ...(output ? { output, browsertool: text } : { browsertool: text }),
1259
- note: check.problems.length
1260
- ? '自检未通过,禁止交付;请按 selfCheck 修正后重跑'
1261
- : 'browsertool 可直接裸输出;禁止再手写卡片 HTML',
1262
- },
1263
- };
1264
- },
1265
- };
1266
- export const contractCardActionOperations = [contractCardActionOperation];