weaver-work-cli 0.1.47 → 0.1.49

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 (229) hide show
  1. package/dist/chunks/{archive-oa-BBDP7AKJ.js → archive-oa-57R2FYHV.js} +565 -17
  2. package/dist/chunks/{attachment-content-MCXQBD6N.js → attachment-content-MU2LPI5P.js} +3 -3
  3. package/dist/chunks/{chunk-J2VEB5K3.js → chunk-2BQESR2U.js} +2 -2
  4. package/dist/chunks/{chunk-727FH2NI.js → chunk-2IGZUMNG.js} +15 -2
  5. package/dist/chunks/{chunk-IP4CWQCF.js → chunk-3NV2ETZR.js} +8 -8
  6. package/dist/chunks/{chunk-OXHHJWNC.js → chunk-3X7VOSBA.js} +1 -1
  7. package/dist/chunks/chunk-5QYE52LG.js +223 -0
  8. package/dist/chunks/{chunk-IRMIEDXN.js → chunk-6GWU63YF.js} +1 -1
  9. package/dist/chunks/{chunk-3YV7PKRL.js → chunk-6QYNE6HE.js} +12 -212
  10. package/dist/chunks/{chunk-Q4OYAQYH.js → chunk-72MI3MBX.js} +4 -0
  11. package/dist/chunks/{chunk-AD46OMQK.js → chunk-BRRW7CWA.js} +121 -46
  12. package/dist/chunks/{chunk-76H3IKH6.js → chunk-D2QRZUW4.js} +221 -37
  13. package/dist/chunks/{chunk-GSZTA43P.js → chunk-EJVA5ZVB.js} +2 -2
  14. package/dist/chunks/{chunk-4RWS2YYL.js → chunk-GEOMANP7.js} +3 -3
  15. package/dist/chunks/{chunk-LIEQJIGM.js → chunk-GR76ZDDX.js} +0 -3
  16. package/dist/chunks/{chunk-O6CMPO65.js → chunk-IW7A2IQY.js} +16 -146
  17. package/dist/chunks/chunk-JEQHNNSS.js +158 -0
  18. package/dist/chunks/{chunk-6V5ZPKHV.js → chunk-K3BT54CU.js} +4 -4
  19. package/dist/chunks/{chunk-6AXKWFKG.js → chunk-KV5SOWMS.js} +4 -4
  20. package/dist/chunks/{chunk-JB34OE7R.js → chunk-NBEWUR7L.js} +1 -1
  21. package/dist/chunks/{chunk-PSOMGA3U.js → chunk-ZKEUGS2U.js} +36 -7
  22. package/dist/chunks/{conflict-H7EHQXYY.js → conflict-6347A7YK.js} +2 -2
  23. package/dist/chunks/{contract-3QLAGYQL.js → contract-N6P2HIIE.js} +425 -187
  24. package/dist/chunks/{create-flow-VRVJEOBX.js → create-flow-7WG7LVX5.js} +6 -6
  25. package/dist/chunks/data-QO7QWOIV.js +2525 -0
  26. package/dist/chunks/{ehr-SH2LM3NK.js → ehr-XI4BIVR2.js} +16 -5
  27. package/dist/chunks/{employee-NOHNXC46.js → employee-DR5Y64TI.js} +2 -1
  28. package/dist/chunks/{env-66FPSJDV.js → env-LHRKSLG6.js} +2 -2
  29. package/dist/chunks/{factory-UH2TZBVA.js → factory-2H7Z4RWJ.js} +1 -1
  30. package/dist/chunks/{group-chat-CAKMMV7K.js → group-chat-EW6PNDDT.js} +3 -3
  31. package/dist/chunks/{hrm-UNKCCCGP.js → hrm-YGIR3HGF.js} +4 -2
  32. package/dist/chunks/{im-NJB7ZYMH.js → im-3RCNL5GT.js} +107 -1
  33. package/dist/chunks/{invoice-UEAHSYAE.js → invoice-FXWH5GPO.js} +2 -71
  34. package/dist/chunks/{lazy-dispatch-25XGTXLM.js → lazy-dispatch-XSAHDK6Z.js} +3 -3
  35. package/dist/chunks/{meeting-VTBFW4HI.js → meeting-N2FQBHXI.js} +10 -10
  36. package/dist/chunks/org-NFE7X7FK.js +12 -0
  37. package/dist/chunks/{reception-5WITA44R.js → reception-MYOKJULO.js} +905 -116
  38. package/dist/chunks/{recruit-stage-CAKZTUA7.js → recruit-stage-FKWS5UQF.js} +118 -29
  39. package/dist/chunks/{registry-VWXWPVAG.js → registry-3UGIWH53.js} +4 -2
  40. package/dist/chunks/{registry-AQVGHUM6.js → registry-7VZ6YJUF.js} +2 -2
  41. package/dist/chunks/{registry-PVUZQDDQ.js → registry-BUTEDK3C.js} +1 -1
  42. package/dist/chunks/{registry-JVQBLFQ5.js → registry-CKUVBS53.js} +10 -10
  43. package/dist/chunks/{room-recommend-5U55FMXZ.js → room-recommend-MBCYENQ2.js} +4 -4
  44. package/dist/chunks/{schedule-IDETODCA.js → schedule-5IFMCXME.js} +4 -4
  45. package/dist/chunks/{workflow-BSYT5TGL.js → workflow-2TRU2ZSP.js} +5 -5
  46. package/dist/core/refs.js +19 -2
  47. package/dist/index.js +20 -15
  48. package/dist/shortcuts/archive-oa/constants.js +42 -0
  49. package/dist/shortcuts/archive-oa/host.js +2 -2
  50. package/dist/shortcuts/archive-oa/index.js +38 -0
  51. package/dist/shortcuts/archive-oa/operations/borrow-car.js +117 -3
  52. package/dist/shortcuts/archive-oa/operations/contract-modules.js +57 -0
  53. package/dist/shortcuts/archive-oa/operations/contract.js +23 -8
  54. package/dist/shortcuts/archive-oa/operations/my-borrow-contract.js +271 -0
  55. package/dist/shortcuts/archive-oa/operations/registry.js +9 -4
  56. package/dist/shortcuts/archive-oa/operations/shared.js +41 -5
  57. package/dist/shortcuts/contract/index.js +9 -1
  58. package/dist/shortcuts/contract/manifest.js +14 -2
  59. package/dist/shortcuts/contract/operations/card.js +231 -0
  60. package/dist/shortcuts/contract/operations/registry.js +2 -0
  61. package/dist/shortcuts/contract/operations/review.js +16 -5
  62. package/dist/shortcuts/contract/operations/summary.js +25 -17
  63. package/dist/shortcuts/data/errors.js +64 -0
  64. package/dist/shortcuts/data/host.js +140 -0
  65. package/dist/shortcuts/data/index.js +429 -0
  66. package/dist/shortcuts/data/manifest.js +133 -0
  67. package/dist/shortcuts/data/operations/attend.js +62 -0
  68. package/dist/shortcuts/data/operations/conf.js +384 -0
  69. package/dist/shortcuts/data/operations/ds.js +686 -0
  70. package/dist/shortcuts/data/operations/field.js +68 -0
  71. package/dist/shortcuts/data/operations/index.js +65 -0
  72. package/dist/shortcuts/data/operations/module.js +383 -0
  73. package/dist/shortcuts/data/operations/noun.js +102 -0
  74. package/dist/shortcuts/data/operations/query.js +85 -0
  75. package/dist/shortcuts/data/operations/scene.js +235 -0
  76. package/dist/shortcuts/data/operations/shared.js +279 -0
  77. package/dist/shortcuts/ehr/operations/recruit-write.js +22 -5
  78. package/dist/shortcuts/ehr/recruit-stage/operations/interview-arrange.js +28 -12
  79. package/dist/shortcuts/ehr/recruit-stage/operations/resume-import.js +21 -13
  80. package/dist/shortcuts/ehr/recruit-stage/shared.js +90 -8
  81. package/dist/shortcuts/im/index.js +128 -0
  82. package/dist/shortcuts/im/operations/session.js +6 -0
  83. package/dist/shortcuts/index.js +5 -0
  84. package/dist/shortcuts/invoice/host.js +0 -3
  85. package/dist/shortcuts/invoice/manifest.js +0 -1
  86. package/dist/shortcuts/invoice/operations/reim-subsidy.js +1 -71
  87. package/dist/shortcuts/meeting/operations/eb/conflict.js +26 -3
  88. package/dist/shortcuts/meeting/operations/eb/continuation-alias.js +63 -0
  89. package/dist/shortcuts/meeting/operations/eb/create-flow.js +71 -12
  90. package/dist/shortcuts/meeting/operations/eb/factory.js +5 -3
  91. package/dist/shortcuts/meeting/operations/eb/member-expand.js +200 -0
  92. package/dist/shortcuts/meeting/operations/registry.js +2 -0
  93. package/dist/shortcuts/reception/constants.js +11 -0
  94. package/dist/shortcuts/reception/host.js +33 -1
  95. package/dist/shortcuts/reception/index.js +22 -1
  96. package/dist/shortcuts/reception/manifest.js +55 -2
  97. package/dist/shortcuts/reception/operations/ask.js +37 -1
  98. package/dist/shortcuts/reception/operations/compose.js +124 -3
  99. package/dist/shortcuts/reception/operations/doc.js +59 -0
  100. package/dist/shortcuts/reception/operations/docrender.js +25 -1
  101. package/dist/shortcuts/reception/operations/leads.js +245 -0
  102. package/dist/shortcuts/reception/operations/markdown.js +22 -0
  103. package/dist/shortcuts/reception/operations/panels.js +84 -21
  104. package/dist/shortcuts/reception/operations/registry.js +2 -0
  105. package/dist/shortcuts/reception/operations/render.js +76 -3
  106. package/dist/shortcuts/reception/operations/restaurant-rooms.js +118 -0
  107. package/dist/shortcuts/reception/operations/restaurant.js +264 -0
  108. package/dist/shortcuts/reception/operations/restaurantrooms.js +42 -0
  109. package/dist/shortcuts/reception/operations/schedule.js +7 -1
  110. package/dist/shortcuts/reception/upload.js +22 -6
  111. package/dist/shortcuts/recruit-stage/operations/interview-arrange.js +28 -12
  112. package/dist/shortcuts/recruit-stage/operations/resume-import.js +21 -13
  113. package/dist/shortcuts/recruit-stage/shared.js +99 -14
  114. package/docs/SKILL.md +1 -0
  115. package/docs/_catalog.md +3 -0
  116. package/docs/archive-oa.md +4 -2
  117. package/docs/data.md +149 -0
  118. package/docs/reception.md +59 -5
  119. package/package.json +1 -1
  120. package/scripts/check-skill-sync.mjs +188 -0
  121. package/scripts/package-skill.mjs +17 -3
  122. package/skill-template/business-info.json +23 -0
  123. package/skill-template/domains/archive-oa.md +2 -1
  124. package/skill-template/domains/data.md +15 -0
  125. package/skill-template/master-skill-template.md +1 -0
  126. package/skill-template/skill-template.md +1 -0
  127. package/skills/weaver-e10-archive-oa/SKILL.md +35 -7
  128. package/skills/weaver-e10-archive-oa/references/borrow-car.md +32 -7
  129. package/skills/weaver-e10-archive-oa/references/contract-search.md +105 -4
  130. package/skills/weaver-e10-archive-oa/references/disabled-capabilities.md +2 -2
  131. package/skills/weaver-e10-archive-oa/references/my-borrow-contract.md +97 -0
  132. package/skills/weaver-e10-archive-oa/references/my-borrow.md +6 -1
  133. package/skills/weaver-e10-archive-oa/references/qys-contract-search.md +48 -2
  134. package/skills/weaver-e10-calendar/SKILL.md +1 -1
  135. package/skills/weaver-e10-calendar/references/calendar-query.md +1 -1
  136. package/skills/weaver-e10-calendar/references/calendar-write.md +9 -9
  137. package/skills/weaver-e10-cowork/SKILL.md +9 -6
  138. package/skills/weaver-e10-data/SKILL.md +118 -0
  139. package/skills/weaver-e10-data/references/config-center.md +90 -0
  140. package/skills/weaver-e10-data/references/datasource.md +136 -0
  141. package/skills/weaver-e10-data/references/scene-and-misc.md +82 -0
  142. package/skills/weaver-e10-jinchengda/SKILL.md +10 -7
  143. package/skills/weaver-e10-jinchengda/references/contract-action-card-template.html +17 -0
  144. package/skills/weaver-e10-jinchengda/references/contract-action-card.md +263 -35
  145. package/skills/weaver-e10-jinchengda/references/contract-action-engine.md +8 -5
  146. package/skills/weaver-e10-jinchengda/references/contract-ai-assistant.md +1 -1
  147. package/skills/weaver-e10-jinchengda/references/contract-ai-review.md +175 -22
  148. package/skills/weaver-e10-jinchengda/references/contract-command-index.md +2 -2
  149. package/skills/weaver-e10-jinchengda/references/contract-credit-page.md +1 -1
  150. package/skills/weaver-e10-jinchengda/references/contract-doc-compare.md +1 -1
  151. package/skills/weaver-e10-jinchengda/references/contract-doc-triage.md +124 -19
  152. package/skills/weaver-e10-jinchengda/references/contract-element-extract.md +2 -2
  153. package/skills/weaver-e10-jinchengda/references/contract-execution-rules.md +4 -4
  154. package/skills/weaver-e10-jinchengda/references/contract-field-extract-other-flows.md +6 -0
  155. package/skills/weaver-e10-jinchengda/references/contract-flow-launch.md +1 -1
  156. package/skills/weaver-e10-jinchengda/references/contract-performance-query.md +1 -1
  157. package/skills/weaver-e10-jinchengda/references/contract-quote-to-contract.md +1 -1
  158. package/skills/weaver-e10-jinchengda/references/contract-risk-report-template.html +178 -0
  159. package/skills/weaver-e10-jinchengda/references/contract-template-recommend.md +1 -1
  160. package/skills/weaver-e10-jinchengda/references/orchestration.md +7 -7
  161. package/skills/weaver-e10-jinchengda/scripts/plan_actions.py +279 -0
  162. package/skills/weaver-e10-jinchengda/scripts/render_action_card.py +450 -0
  163. package/skills/weaver-e10-jinchengda/scripts/render_risk_report.py +358 -0
  164. package/skills/weaver-e10-jinchengda/scripts/validate_action_card.py +505 -0
  165. package/skills/weaver-e10-jucailin/SKILL.md +7 -4
  166. package/skills/weaver-e10-jucailin/references/recruit-create.md +3 -2
  167. package/skills/weaver-e10-jucailin/references/recruit-read.md +2 -1
  168. package/skills/weaver-e10-jucailin/references/recruit-stage-ops.md +3 -3
  169. package/skills/weaver-e10-jucailin/references/safety-boundaries.md +30 -2
  170. package/skills/weaver-e10-mail/SKILL.md +17 -4
  171. package/skills/weaver-e10-meeting/SKILL.md +129 -412
  172. package/skills/weaver-e10-meeting/references/create-flow.md +188 -0
  173. package/skills/weaver-e10-meeting/references/create-guardrails.md +234 -0
  174. package/skills/weaver-e10-meeting/references/pitfalls.md +40 -0
  175. package/skills/weaver-e10-reception-flow/SKILL.md +77 -19
  176. package/skills/weaver-e10-reception-flow/data/fields-snapshot.json +628 -26
  177. package/skills/weaver-e10-reception-flow/references/fields-snapshot.md +96 -26
  178. package/skills/weaver-e10-reception-flow/references/guide.md +4 -3
  179. package/skills/weaver-e10-reception-flow/scripts/render.py +84 -3
  180. package/skills/weaver-e10-recruit-stage/SKILL.md +45 -12
  181. package/skills/weaver-e10-recruit-stage/agents/openai.yaml +78 -8
  182. package/skills/weaver-e10-recruit-stage/references/position-templates.md +5 -0
  183. package/skills/weaver-e10-recruit-stage/references/recruit-arrange-interview.md +1 -1
  184. package/skills/weaver-e10-recruit-stage/references/recruit-edit-interview-feedback.md +1 -1
  185. package/skills/weaver-e10-recruit-stage/references/recruit-jd-create.md +40 -11
  186. package/skills/weaver-e10-recruit-stage/references/recruit-list-candidate.md +1 -1
  187. package/skills/weaver-e10-recruit-stage/references/recruit-list-interview.md +1 -1
  188. package/skills/weaver-e10-recruit-stage/references/recruit-match-candidates.md +1 -1
  189. package/skills/weaver-e10-recruit-stage/references/recruit-resume-import.md +16 -0
  190. package/skills/weaver-e10-recruit-stage/references/recruit-resume-parse.md +1 -1
  191. package/skills/weaver-e10-recruit-stage/references/recruit-search-candidate.md +1 -1
  192. package/skills/weaver-e10-recruit-stage/references/recruit-urge-feedback.md +1 -1
  193. package/skills/weaver-e10-recruit-stage/references/recruit-utterance-glossary.md +169 -0
  194. package/skills/weaver-e10-shijingran/SKILL.md +6 -2
  195. package/skills/weaver-e10-shijingran/references/source-manifest.json +5 -4
  196. package/skills/weaver-e10-workflow/SKILL.md +1 -1
  197. package/skills/weaver-e10-yepiaotong/SKILL.md +8 -4
  198. package/skills/weaver-e10-yepiaotong/references/invoice-issuing-workflow.md +1 -1
  199. package/skills/weaver-e10-yepiaotong/references/invoice-reim.md +1 -1
  200. package/skills/weaver-e10-yepiaotong/references/reim-api-reference.md +2 -2
  201. package/skills/weaver-e10-yepiaotong/references/reim-form-fill-rules.md +1 -1
  202. package/skills/weaver-e10-yepiaotong/references/reim-phone-subsidy-rules.md +1 -1
  203. package/skills/weaver-e10-yepiaotong/references/reim-workflow.md +1 -0
  204. package/skills/weaver-e10-yimiaoban/SKILL.md +2 -1
  205. package/skills/weaver-e10-yimiaoban/references/msg-write.md +32 -0
  206. package/skills/weaver-e10-yimiaoban/references/session-sysmsg.md +3 -0
  207. package/skills/weaver-e10-yimiaoban/references/source-manifest.json +11 -11
  208. package/dist/chunks/{ebuilder-form-GWDTKEI2.js → ebuilder-form-CBYI6CQ6.js} +3 -3
  209. /package/{skills → docs/legacy}/weaver-e10-jucailin/archive/LEGACY-README.md +0 -0
  210. /package/{skills → docs/legacy}/weaver-e10-jucailin/archive/LEGACY-SKILL.md +0 -0
  211. /package/{skills → docs/legacy}/weaver-e10-jucailin/archive/LEGACY-openai.yaml +0 -0
  212. /package/{skills → docs/legacy}/weaver-e10-jucailin/archive/LEGACY-position-templates.md +0 -0
  213. /package/{skills → docs/legacy}/weaver-e10-jucailin/archive/LEGACY-recruit-arrange-interview.md +0 -0
  214. /package/{skills → docs/legacy}/weaver-e10-jucailin/archive/LEGACY-recruit-capability-check.md +0 -0
  215. /package/{skills → docs/legacy}/weaver-e10-jucailin/archive/LEGACY-recruit-check-install.md +0 -0
  216. /package/{skills → docs/legacy}/weaver-e10-jucailin/archive/LEGACY-recruit-detail-process.md +0 -0
  217. /package/{skills → docs/legacy}/weaver-e10-jucailin/archive/LEGACY-recruit-edit-interview-feedback.md +0 -0
  218. /package/{skills → docs/legacy}/weaver-e10-jucailin/archive/LEGACY-recruit-jd-create.md +0 -0
  219. /package/{skills → docs/legacy}/weaver-e10-jucailin/archive/LEGACY-recruit-jd-template.md +0 -0
  220. /package/{skills → docs/legacy}/weaver-e10-jucailin/archive/LEGACY-recruit-list-candidate.md +0 -0
  221. /package/{skills → docs/legacy}/weaver-e10-jucailin/archive/LEGACY-recruit-list-interview.md +0 -0
  222. /package/{skills → docs/legacy}/weaver-e10-jucailin/archive/LEGACY-recruit-match-candidates.md +0 -0
  223. /package/{skills → docs/legacy}/weaver-e10-jucailin/archive/LEGACY-recruit-output-links.md +0 -0
  224. /package/{skills → docs/legacy}/weaver-e10-jucailin/archive/LEGACY-recruit-resolve-creator.md +0 -0
  225. /package/{skills → docs/legacy}/weaver-e10-jucailin/archive/LEGACY-recruit-resolve-metadata.md +0 -0
  226. /package/{skills → docs/legacy}/weaver-e10-jucailin/archive/LEGACY-recruit-resume-import.md +0 -0
  227. /package/{skills → docs/legacy}/weaver-e10-jucailin/archive/LEGACY-recruit-resume-parse.md +0 -0
  228. /package/{skills → docs/legacy}/weaver-e10-jucailin/archive/LEGACY-recruit-search-candidate.md +0 -0
  229. /package/{skills → docs/legacy}/weaver-e10-jucailin/archive/LEGACY-recruit-urge-feedback.md +0 -0
@@ -443,6 +443,18 @@ const quoteContracts = [
443
443
  out: { type: 'string', minLength: 1, maxLength: 4096, description: '输出 HTML 绝对路径' },
444
444
  }, ['data', 'out']),
445
445
  },
446
+ {
447
+ name: 'contract.card.render',
448
+ risk: 'local-file-write',
449
+ fixed: { local: true, kind: 'card-render' },
450
+ inputSchema: readSchema({
451
+ data: { type: 'string', minLength: 1, maxLength: 4096, description: '卡片数据 JSON 文件路径(cards 数组 + title/width/hint)' },
452
+ out: { type: 'string', minLength: 1, maxLength: 4096, description: '输出卡片 HTML 绝对路径(即 customParams.html 内容)' },
453
+ summary: { type: 'string', minLength: 1, maxLength: 4096, description: '可选:摘要数据 JSON 路径,渲染后内嵌为 artifact 动作的内容' },
454
+ browsertool: { type: 'string', minLength: 1, maxLength: 4096, description: '可选:同时输出完整 browsertool JSON 的路径' },
455
+ baseUrl: { type: 'string', minLength: 1, maxLength: 2048, description: '可选:当前 E10 环境地址,缺省取登录会话' },
456
+ }, ['data', 'out']),
457
+ },
446
458
  {
447
459
  name: 'contract.file.download',
448
460
  risk: 'local-file-write',
@@ -1124,11 +1136,11 @@ export const contractOperations = [
1124
1136
  method: 'POST',
1125
1137
  path: '/api/ebd/contract/ai/getAiReviewRecord',
1126
1138
  aiId: '1326842382967570463',
1127
- defaults: { sclx: '1,2,3' },
1139
+ defaults: { sclx: '8' },
1128
1140
  },
1129
1141
  inputSchema: readSchema({
1130
1142
  fileId: { type: 'string', minLength: 1, maxLength: 64 },
1131
- sclx: { type: 'string', pattern: '^[1-3](,[1-3]){0,2}$' },
1143
+ sclx: { type: 'string', pattern: '^8$' },
1132
1144
  }, ['fileId']),
1133
1145
  },
1134
1146
  {
@@ -0,0 +1,231 @@
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
+ import { renderSummaryHtml } from './summary.js';
6
+ /**
7
+ * 行为卡片 HTML 渲染(本地,零依赖)。
8
+ *
9
+ * 定位:模型只产出「卡片清单 + 摘要数据」的紧凑 JSON(约 2~3 KB),
10
+ * 卡片骨架、事件绑定、ES5 脚本、browsertool 外壳全部由本 operation 生成。
11
+ *
12
+ * 为什么值得做(2026-11-09):
13
+ * 1. 手写卡片 HTML 是"点不动"的高发区(双引号截断、括号错位、漏 initialArtifactKeys)。
14
+ * 生成器固定输出,这三类错误从结构上不可能发生——这是主要收益。
15
+ * 2. 卡片从「逐张重复 HTML」改为「紧凑数组 + 循环生成」,
16
+ * 常驻体积从约 6 KB 降到约 2 KB(脚本只写一次)。
17
+ *
18
+ * 注意:browsertool 必须内联完整 HTML,所以模型回复的体积下限仍由成品 HTML 决定。
19
+ * 本 operation 靠"结构复用"降低成品体积,不承诺数量级的 token 下降。
20
+ */
21
+ const CARD_SCRIPT = `(function(){
22
+ var root=document.getElementById('__UID__');
23
+ if(!root){return;}
24
+ var st=root.querySelector('[data-status]');
25
+ function say(m){if(st){st.textContent=m;}}
26
+ function plug(){
27
+ if(window.xiaoePlugin){return window.xiaoePlugin;}
28
+ if(window.rawWindow&&window.rawWindow.xiaoePlugin){return window.rawWindow.xiaoePlugin;}
29
+ return null;
30
+ }
31
+ var wrap=document.createElement('div');
32
+ root.insertBefore(wrap,st);
33
+ var cards=[];
34
+ var cb=root.querySelector('[data-cards]');
35
+ try{cards=JSON.parse(cb?cb.value:'[]');}catch(e){cards=[];}
36
+ var ICON={send:'📧',shield:'🛡',search:'🔍',doc:'📋',compare:'🔄',calc:'📊',link:'🔗'};
37
+ function run(c){
38
+ var a=c.action||{};
39
+ if(a.type==='sendQuestion'){
40
+ var ps=plug();
41
+ if(!ps||!ps.session||typeof ps.session.sendQuestion!=='function'){say('当前环境不支持发送会话消息');return;}
42
+ try{ps.session.sendQuestion({question:a.question||c.title||'',files:[]});say('已发送,正在处理');}
43
+ catch(e){say('发送失败,请重试');}
44
+ return;
45
+ }
46
+ var p=plug();
47
+ if(!p||!p.rightPanel||typeof p.rightPanel.open!=='function'){say('当前环境没有小e右侧面板');return;}
48
+ var cfg={};
49
+ if(a.type==='e10Sdk'){
50
+ var prm={app:a.app,compName:a.comp};
51
+ if(a.companyName){prm.companyName=a.companyName;}
52
+ if(a.customParams){prm.customParams=a.customParams;}
53
+ cfg.type='e10Sdk';
54
+ cfg.width=a.width||1300;
55
+ cfg.contentProps={src:a.src,sdkOptions:{compName:'ui.CorsComponent',routerType:'MemoryRouter',routerProps:{initialEntries:a.entries},params:prm}};
56
+ }else if(a.type==='artifact'){
57
+ var sb=root.querySelector('[data-summary]');
58
+ var h=sb?sb.value:'';
59
+ if(!h){say('摘要内容为空');return;}
60
+ cfg.type='artifact';
61
+ cfg.width=a.width||760;
62
+ cfg.contentProps={initialArtifactKeys:['summary-1'],artifacts:[{id:'summary-1',name:'合同摘要.html',fileType:'html',raw:{html:h}}]};
63
+ }else{say('不支持的动作类型');return;}
64
+ try{p.rightPanel.open(cfg);say('已打开');}catch(e){say('面板打开失败,请检查右侧面板');}
65
+ }
66
+ for(var i=0;i<cards.length;i++){
67
+ (function(c){
68
+ var b=document.createElement('button');
69
+ b.type='button';
70
+ b.setAttribute('data-act',c.id||('act'+i));
71
+ b.style.cssText='width:100%;box-sizing:border-box;text-align:left;font-family:inherit;display:flex;align-items:center;gap:12px;background:#fff;border:1px solid #e3e6eb;border-radius:10px;padding:16px;margin-bottom:12px;cursor:pointer';
72
+ var ic=document.createElement('span');
73
+ ic.style.cssText='flex:0 0 auto;width:44px;height:44px;border-radius:10px;background:#eef4ff;display:flex;align-items:center;justify-content:center;font-size:20px';
74
+ ic.innerHTML=ICON[c.icon]||ICON.doc;
75
+ var tx=document.createElement('span');
76
+ tx.style.cssText='min-width:0';
77
+ var t1=document.createElement('span');
78
+ t1.style.cssText='display:block;margin-bottom:6px;font-size:15px;font-weight:700;color:#1f2329';
79
+ t1.textContent=c.title||'';
80
+ if(c.recommended){
81
+ var bd=document.createElement('span');
82
+ bd.style.cssText='font-size:11px;color:#fff;background:#1a56b8;border-radius:999px;padding:2px 10px;margin-left:8px';
83
+ bd.textContent='推荐';
84
+ t1.appendChild(bd);
85
+ }
86
+ var t2=document.createElement('span');
87
+ t2.style.cssText='display:block;font-size:13px;color:#5c6570;line-height:1.5';
88
+ t2.textContent=c.desc||'';
89
+ tx.appendChild(t1);tx.appendChild(t2);
90
+ b.appendChild(ic);b.appendChild(tx);
91
+ b.addEventListener('click',function(){run(c);});
92
+ b.addEventListener('mouseenter',function(){b.style.borderColor='#1a56b8';});
93
+ b.addEventListener('mouseleave',function(){b.style.borderColor='#e3e6eb';});
94
+ wrap.appendChild(b);
95
+ })(cards[i]);
96
+ }
97
+ say('共 '+cards.length+' 个可执行操作');
98
+ })();`;
99
+ function escAttr(value) {
100
+ return String(value ?? '')
101
+ .replace(/&/gu, '&amp;')
102
+ .replace(/</gu, '&lt;')
103
+ .replace(/>/gu, '&gt;')
104
+ .replace(/'/gu, '&#39;');
105
+ }
106
+ /** textarea 是 raw text:先把 & 转义,再把双引号转成实体,读 .value 时浏览器会还原。 */
107
+ function textareaRaw(value) {
108
+ return value
109
+ .replace(/&/gu, '&amp;')
110
+ .replace(/"/gu, '&quot;')
111
+ .replace(/<\/textarea/giu, '&lt;/textarea');
112
+ }
113
+ function makeUid() {
114
+ const now = new Date();
115
+ const pad = (value) => String(value).padStart(2, '0');
116
+ const stamp = `${now.getFullYear()}${pad(now.getMonth() + 1)}${pad(now.getDate())}`
117
+ + `${pad(now.getHours())}${pad(now.getMinutes())}`;
118
+ const rand = Math.random().toString(36).slice(2, 6);
119
+ return `card-${stamp}-${rand}`;
120
+ }
121
+ function readJsonObject(path, label) {
122
+ let raw;
123
+ try {
124
+ raw = readFileSync(path, 'utf8').replace(/^\uFEFF/u, '');
125
+ }
126
+ catch (error) {
127
+ const message = error instanceof Error ? error.message : String(error);
128
+ throw contractValidationError('data_unreadable', `无法读取${label} JSON:${message}`);
129
+ }
130
+ let parsed;
131
+ try {
132
+ parsed = JSON.parse(raw);
133
+ }
134
+ catch (error) {
135
+ const message = error instanceof Error ? error.message : String(error);
136
+ throw contractValidationError('data_unreadable', `无法解析${label} JSON:${message}`);
137
+ }
138
+ if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) {
139
+ throw contractValidationError('data_unreadable', `${label}必须是 JSON 对象`);
140
+ }
141
+ return parsed;
142
+ }
143
+ export const contractCardOperations = [
144
+ {
145
+ name: 'contract.card.render',
146
+ async execute(input, context) {
147
+ const dataPath = resolve(requireNonEmptyString(input.data, 'data', 4096).trim());
148
+ const outPath = resolve(requireNonEmptyString(input.out, 'out', 4096).trim());
149
+ const data = readJsonObject(dataPath, '卡片数据');
150
+ const cards = Array.isArray(data.cards) ? data.cards : [];
151
+ if (cards.length === 0) {
152
+ throw contractValidationError('cards_required', '卡片数据必须包含非空的 cards 数组');
153
+ }
154
+ let summaryHtml = '';
155
+ if (input.summary) {
156
+ const summaryPath = resolve(requireNonEmptyString(input.summary, 'summary', 4096).trim());
157
+ summaryHtml = renderSummaryHtml(readJsonObject(summaryPath, '摘要数据'));
158
+ }
159
+ let baseUrl = input.baseUrl ? requireNonEmptyString(input.baseUrl, 'baseUrl', 2048).trim() : '';
160
+ if (!baseUrl) {
161
+ const session = await context.host.getSession();
162
+ baseUrl = String(session?.baseUrl ?? '').trim();
163
+ }
164
+ baseUrl = baseUrl.replace(/\/+$/u, '');
165
+ if (!baseUrl) {
166
+ throw contractValidationError('base_url_missing', '无法确定当前 E10 环境地址,请显式传入 baseUrl');
167
+ }
168
+ const uid = typeof data.id === 'string' && data.id.trim() ? data.id.trim() : makeUid();
169
+ const hint = typeof data.hint === 'string' ? data.hint.trim() : '';
170
+ const title = typeof data.title === 'string' && data.title.trim() ? data.title.trim() : '可执行操作';
171
+ const width = typeof data.width === 'number' && data.width > 0 ? data.width : 1300;
172
+ const cardsJson = JSON.stringify(cards);
173
+ const script = CARD_SCRIPT.replace(/__UID__/gu, uid);
174
+ const parts = [];
175
+ parts.push(`<section id='${escAttr(uid)}' style='padding:4px 2px;font-family:Microsoft YaHei,PingFang SC,sans-serif'>`);
176
+ if (hint) {
177
+ parts.push(`<div style='background:#eef4ff;border:1px solid #d6e4ff;border-radius:8px;padding:10px 12px;margin-bottom:12px;font-size:12.5px;color:#1d39c4;line-height:1.6'>${escAttr(hint)}</div>`);
178
+ }
179
+ parts.push(`<p data-status aria-live='polite' style='margin:8px 0 0;color:#b45309;font-size:12px;line-height:1.6'></p>`);
180
+ parts.push(`<textarea data-cards style='display:none'>${textareaRaw(cardsJson)}</textarea>`);
181
+ if (summaryHtml) {
182
+ parts.push(`<textarea data-summary style='display:none'>${textareaRaw(summaryHtml)}</textarea>`);
183
+ }
184
+ parts.push(`</section><script>${script}</script>`);
185
+ const html = parts.join('');
186
+ writeFileSync(outPath, html, 'utf8');
187
+ const bytes = Buffer.byteLength(html, 'utf8');
188
+ let browsertoolPath = '';
189
+ if (input.browsertool) {
190
+ browsertoolPath = resolve(requireNonEmptyString(input.browsertool, 'browsertool', 4096).trim());
191
+ const browsertool = {
192
+ version: 1,
193
+ callId: typeof data.callId === 'string' && data.callId.trim() ? data.callId.trim() : `${uid}-01`,
194
+ toolId: 'fill_form',
195
+ arguments: {
196
+ type: 'e10',
197
+ title,
198
+ src: `${baseUrl}/sp/contract/xiaoe-custom-page`,
199
+ width,
200
+ sdkRenderType: 'inline',
201
+ sdkOptions: {
202
+ compName: 'ui.CorsComponent',
203
+ routerType: 'MemoryRouter',
204
+ routerProps_pc: { initialEntries: ['/sp/contract/xiaoe-custom-page'] },
205
+ params_pc: {
206
+ app: '@weapp/contract',
207
+ compName: 'xiaoeCustomPage',
208
+ customParams: { html },
209
+ },
210
+ },
211
+ },
212
+ };
213
+ writeFileSync(browsertoolPath, JSON.stringify(browsertool), 'utf8');
214
+ }
215
+ return {
216
+ status: 'COMPLETE',
217
+ data: {
218
+ output: outPath,
219
+ fileName: basename(outPath),
220
+ fileSize: bytes,
221
+ uid,
222
+ cardCount: cards.length,
223
+ cardIds: cards.map((card) => String(card?.id ?? '')),
224
+ summaryEmbedded: Boolean(summaryHtml),
225
+ browsertool: browsertoolPath || undefined,
226
+ note: 'HTML 与 browsertool JSON 均由 CLI 生成;模型不要再手写卡片 HTML',
227
+ },
228
+ };
229
+ },
230
+ },
231
+ ];
@@ -4,6 +4,7 @@ import { contractAssistantOperations } from './assistant.js';
4
4
  import { contractClauseInsertOperations } from './clause-insert.js';
5
5
  import { contractClauseLibraryOperations } from './clause-library.js';
6
6
  import { contractClauseReferenceOperations } from './clause-reference.js';
7
+ import { contractCardOperations } from './card.js';
7
8
  import { contractCompareOperations } from './compare.js';
8
9
  import { contractCreditPageOperations } from './credit-page.js';
9
10
  import { contractCustomerOperations } from './customer.js';
@@ -38,6 +39,7 @@ function buildRegistry() {
38
39
  ...contractAssistantOperations,
39
40
  ...contractPerformanceOperations,
40
41
  ...contractSummaryOperations,
42
+ ...contractCardOperations,
41
43
  ...contractQuoteOperations,
42
44
  ];
43
45
  for (const handler of handlers) {
@@ -15,7 +15,13 @@ const PREWARM_PATH = '/api/ebd/contract/ai/saveInternalRecord';
15
15
  const PREWARM_TIMEOUT_MS = 30_000;
16
16
  const PREWARM_ERROR = 'prewarm_error';
17
17
  const MAX_FILES = 10;
18
- const SCLX_PATTERN = /^[1-3](?:,[1-3]){0,2}$/u;
18
+ /** 合同预审固定只走风险审查,sclx 取值为 8(2026-11-09 用户确认)。 */
19
+ export const CONTRACT_REVIEW_SCLX = '8';
20
+ /**
21
+ * 旧分类取值:`1`=内控、`2`=法审、`3`=纠错。
22
+ * 代码保留备查,但对应触发入口已全部屏蔽,不再作为 sclx 的合法取值。
23
+ */
24
+ export const LEGACY_SCLX_PATTERN = /^[1-3](?:,[1-3]){0,2}$/u;
19
25
  /**
20
26
  * 触发预审预热。
21
27
  *
@@ -51,9 +57,9 @@ async function prewarmAll(host, fileIds) {
51
57
  }
52
58
  function normalizeSclx(value) {
53
59
  if (value === undefined || value === null || value === '')
54
- return '1,2,3';
55
- if (typeof value !== 'string' || !SCLX_PATTERN.test(value)) {
56
- throw contractValidationError('sclx_invalid', 'sclx 只能是 "1"、"2"、"3" 或它们的逗号组合(如 "1,2,3")');
60
+ return CONTRACT_REVIEW_SCLX;
61
+ if (typeof value !== 'string' || value !== CONTRACT_REVIEW_SCLX) {
62
+ throw contractValidationError('sclx_invalid', `合同预审只走风险审查,sclx 固定为 "${CONTRACT_REVIEW_SCLX}";内控/法审/纠错(1/2/3)入口已屏蔽`);
57
63
  }
58
64
  return value;
59
65
  }
@@ -175,10 +181,15 @@ export const contractReviewOperations = [
175
181
  async execute(input, { host }) {
176
182
  const fileId = requireNonEmptyString(input.fileId, 'fileId', 64);
177
183
  const sclx = normalizeSclx(input.sclx);
184
+ // 请求体与前端实际调用保持一致:flowId + sclx + fileId。
185
+ // 注意:不要带 ai_id —— 带上会导致服务端返回空记录(2026-11-09 实测)。
186
+ const flowId = (input.flowId === undefined || input.flowId === null || input.flowId === '')
187
+ ? AI_REVIEW_PREWARM_FLOW_ID
188
+ : requireNonEmptyString(input.flowId, 'flowId', 64);
178
189
  const value = await host.contractRequest({
179
190
  method: 'POST',
180
191
  path: '/api/ebd/contract/ai/getAiReviewRecord',
181
- body: { sclx, fileId, ai_id: AI_REVIEW_ASSISTANT_ID },
192
+ body: { flowId, sclx, fileId },
182
193
  timeoutMs: 120_000,
183
194
  });
184
195
  const records = collectRecords(value);
@@ -122,6 +122,30 @@ function sectionHtml(section) {
122
122
  return parts.join('');
123
123
  }
124
124
  const SECTION_TYPES = ['alert', 'reasons', 'grid', 'table', 'checks', 'list', 'next'];
125
+ /**
126
+ * 按固定模板把摘要数据渲染成完整 HTML。
127
+ * 抽成导出函数,供 contract.summary.render 与 contract.card.render(内嵌摘要)共用。
128
+ */
129
+ export function renderSummaryHtml(data) {
130
+ const sections = asArray(data.sections);
131
+ if (sections.length === 0) {
132
+ throw contractValidationError('sections_required', '摘要数据必须包含非空的 sections 数组');
133
+ }
134
+ const unknownTypes = sections
135
+ .map((section) => String(section?.type ?? ''))
136
+ .filter((type) => !SECTION_TYPES.includes(type));
137
+ if (unknownTypes.length) {
138
+ throw contractValidationError('section_type_unknown', `未知的 section 类型:${[...new Set(unknownTypes)].join(', ')};支持 ${SECTION_TYPES.join(' / ')}`);
139
+ }
140
+ const badge = esc(data.badge ?? '合同');
141
+ const title = esc(data.title ?? '合同摘要');
142
+ const meta = esc(data.meta ?? '');
143
+ const body = sections.map((section) => sectionHtml(section)).join('');
144
+ return `<!DOCTYPE html><html lang="zh-CN"><head><meta charset="UTF-8">`
145
+ + `<title>合同摘要 - ${title}</title><style>${CSS}</style></head><body><div class="w">`
146
+ + `<div class="hd"><span class="bd">${badge}</span><h1>${title}</h1><div class="mt">${meta}</div></div>`
147
+ + `${body}</div></body></html>`;
148
+ }
125
149
  export const contractSummaryOperations = [
126
150
  {
127
151
  name: 'contract.summary.render',
@@ -142,23 +166,7 @@ export const contractSummaryOperations = [
142
166
  throw contractValidationError('data_unreadable', `无法读取摘要数据 JSON:${message}`);
143
167
  }
144
168
  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>`;
169
+ const html = renderSummaryHtml(data);
162
170
  writeFileSync(outPath, html, 'utf8');
163
171
  const bytes = Buffer.byteLength(html, 'utf8');
164
172
  return {
@@ -0,0 +1,64 @@
1
+ import { CliError, ExitCode } from '../../core/errors.js';
2
+ /**
3
+ * data 模块的错误类型。
4
+ *
5
+ * 退出码沿用 e10-data 的既有语义(技能侧按退出码分流,不能改):
6
+ * 0 正常(**空结果也算正常**)|2 未登录·凭据失效|3 非 JSON·confAttrs 异常
7
+ * 4 权限受限(hasSearchRight=false,终端态)|6 命中 HRM 路径黑名单|7 请求失败|8 用法错误
8
+ * 映射到框架的 ExitCode:2→UsageError、3→AuthError、4→PolicyError、6→PolicyError、
9
+ * 7→NetworkError、8→UsageError。**退出码数值本身必须与旧版一致**,因此这里直接使用数值。
10
+ */
11
+ export const DataExit = {
12
+ OK: 0,
13
+ AUTH: 2,
14
+ JSON: 3,
15
+ PERM: 4,
16
+ HRM: 6,
17
+ HTTP: 7,
18
+ USAGE: 8,
19
+ };
20
+ export class DataCliError extends CliError {
21
+ type;
22
+ subtype;
23
+ code;
24
+ retryable;
25
+ stage;
26
+ details;
27
+ constructor(type, subtype, message, options = {}) {
28
+ super(message, options.exitCode ?? ExitCode.GeneralError);
29
+ this.name = 'DataCliError';
30
+ this.type = type;
31
+ this.subtype = subtype;
32
+ this.code = options.code;
33
+ this.retryable = options.retryable ?? false;
34
+ this.stage = options.stage;
35
+ this.details = options.details;
36
+ }
37
+ }
38
+ export function dataValidationError(subtype, message, exitCode = DataExit.USAGE) {
39
+ return new DataCliError('validation', subtype, message, { exitCode });
40
+ }
41
+ export function dataAuthError(subtype, message, details) {
42
+ return new DataCliError('authentication', subtype, message, { exitCode: DataExit.AUTH, details });
43
+ }
44
+ export function dataNetworkError(subtype, message, details) {
45
+ return new DataCliError('network', subtype, message, { exitCode: DataExit.HTTP, retryable: true, details });
46
+ }
47
+ export function dataApiError(subtype, message, options = {}) {
48
+ return new DataCliError('api', subtype, message, {
49
+ code: options.code,
50
+ details: options.details,
51
+ exitCode: options.exitCode ?? DataExit.JSON,
52
+ });
53
+ }
54
+ export function dataPolicyError(subtype, message, details) {
55
+ return new DataCliError('policy', subtype, message, { exitCode: DataExit.PERM, details });
56
+ }
57
+ /** 权限受限是「终端态」:结果照常给,但退出码必须非 0(对齐 call_module.py)。 */
58
+ export function dataPermissionBlocked(message) {
59
+ return new DataCliError('policy', 'permission_restricted', message, { exitCode: DataExit.PERM });
60
+ }
61
+ /** HRM 路径黑名单:人员/部门/岗位一律走 `weaver-work-cli hrm`,禁止在 data 通道直调。 */
62
+ export function dataHrmBlocked(apiPath) {
63
+ return new DataCliError('policy', 'hrm_path_blocked', `该接口命中 HRM 路径黑名单(${apiPath})→ 人员/部门/岗位一律走 weaver-work-cli 的 hrm 子命令,禁止直调`, { exitCode: DataExit.HRM, details: { apiPath } });
64
+ }
@@ -0,0 +1,140 @@
1
+ import { E10_SESSION_EXPIRED_MESSAGE } from '../../internal/e10/auth/messages.js';
2
+ import { requireE10Session } from '../../internal/e10/context.js';
3
+ import { E10ApiError, createE10RequestRuntime } from '../../internal/e10/request-runtime.js';
4
+ import { isE10SessionExpiredResponse } from '../../internal/e10/auth-recovery.js';
5
+ import { dataApiError, dataAuthError, dataNetworkError, dataValidationError, } from './errors.js';
6
+ /** 业务请求默认超时(与 e10-data 的 module call 默认一致:60s)。 */
7
+ export const DATA_TIMEOUT_MS = 60_000;
8
+ /** EB 业务 ID。e10-data 对 conf / module 通道恒定下发该头,运行时不会自动注入。 */
9
+ export const DATA_EB_BUSINESS_ID = '10000000000000000';
10
+ function queryStringOf(query) {
11
+ if (!query)
12
+ return undefined;
13
+ const out = {};
14
+ for (const [key, value] of Object.entries(query)) {
15
+ if (value === undefined || value === null)
16
+ continue;
17
+ out[key] = value;
18
+ }
19
+ return out;
20
+ }
21
+ function formStringOf(form) {
22
+ if (typeof form === 'string')
23
+ return form;
24
+ const params = new URLSearchParams();
25
+ for (const [key, value] of Object.entries(form)) {
26
+ if (value === undefined || value === null)
27
+ continue;
28
+ // 数组按多值展开、对象 JSON 化 —— 与 e10-data 的 moduleQueryString 口径一致
29
+ if (Array.isArray(value)) {
30
+ for (const item of value) {
31
+ params.append(key, item !== null && typeof item === 'object' ? JSON.stringify(item) : String(item));
32
+ }
33
+ }
34
+ else {
35
+ params.append(key, typeof value === 'object' ? JSON.stringify(value) : String(value));
36
+ }
37
+ }
38
+ return params.toString();
39
+ }
40
+ function multipartOf(fields) {
41
+ const form = new FormData();
42
+ for (const [key, value] of Object.entries(fields)) {
43
+ if (value === undefined || value === null)
44
+ continue;
45
+ form.append(key, typeof value === 'object' ? JSON.stringify(value) : String(value));
46
+ }
47
+ return form;
48
+ }
49
+ export function createDataHost(ctx, dependencies = {}) {
50
+ let authSession = null;
51
+ let snapshot = null;
52
+ const requireSession = dependencies.requireSession ?? requireE10Session;
53
+ async function ensureSession() {
54
+ if (!authSession) {
55
+ authSession = await requireSession(ctx);
56
+ snapshot = {
57
+ baseUrl: authSession.getBaseUrl(),
58
+ userId: authSession.userId,
59
+ tenantKey: authSession.tenantKey,
60
+ eteamsId: authSession.eteamsId,
61
+ userAgent: authSession.uaHeader(),
62
+ };
63
+ }
64
+ return authSession;
65
+ }
66
+ async function requestText(request) {
67
+ const session = await ensureSession();
68
+ const runtime = createE10RequestRuntime(ctx, session);
69
+ const method = request.method ?? (request.body === undefined && request.form === undefined && request.multipart === undefined
70
+ ? 'GET'
71
+ : 'POST');
72
+ let response;
73
+ try {
74
+ response = await runtime.requestJson({
75
+ module: 'data',
76
+ operation: request.operation ?? request.path,
77
+ method,
78
+ path: request.path,
79
+ query: queryStringOf(request.query),
80
+ // multipart 与 body/form 互斥:FormData 自带 boundary,不能与 Content-Type 混用
81
+ body: request.multipart === undefined ? request.body : undefined,
82
+ form: request.multipart === undefined && request.form !== undefined ? formStringOf(request.form) : undefined,
83
+ formData: request.multipart === undefined ? undefined : multipartOf(request.multipart),
84
+ headers: {
85
+ // e10-data 对 conf / module 通道恒定下发 ebbusinessid,运行时不会自动注入
86
+ ebbusinessid: DATA_EB_BUSINESS_ID,
87
+ ...(request.headers ?? {}),
88
+ },
89
+ trustedHeaders: request.trustedHeaders,
90
+ timeoutMs: request.timeoutMs ?? DATA_TIMEOUT_MS,
91
+ });
92
+ }
93
+ catch (error) {
94
+ if (error instanceof E10ApiError) {
95
+ if (error.type === 'authentication')
96
+ throw dataAuthError('session_expired', error.message);
97
+ if (error.type === 'network')
98
+ throw dataNetworkError(error.subtype, error.message, error.details);
99
+ }
100
+ throw error;
101
+ }
102
+ if (isE10SessionExpiredResponse(response)) {
103
+ throw dataAuthError('session_expired', E10_SESSION_EXPIRED_MESSAGE, { httpStatus: response.status });
104
+ }
105
+ if (response.parseError) {
106
+ if (response.status >= 200 && response.status < 300) {
107
+ // 2xx 但非 JSON:把原文交回调用方(module call 需要原样输出前 2000 字符)
108
+ return { status: response.status, text: response.text, value: null };
109
+ }
110
+ throw dataNetworkError('non_json', `HTTP ${response.status} 非 JSON 响应: ${response.text.slice(0, 300)}`, {
111
+ status: response.status,
112
+ });
113
+ }
114
+ return { status: response.status, text: response.text, value: response.value };
115
+ }
116
+ async function request(request) {
117
+ const { status, value, text } = await requestText(request);
118
+ if (status < 200 || status >= 300) {
119
+ throw dataApiError('http_error', `接口 HTTP ${status}`, {
120
+ code: status,
121
+ details: { status, body: String(text ?? '').slice(0, 500) },
122
+ exitCode: 7,
123
+ });
124
+ }
125
+ return value;
126
+ }
127
+ async function session() {
128
+ await ensureSession();
129
+ return snapshot;
130
+ }
131
+ return { session, request, requestText };
132
+ }
133
+ /** 参数校验小工具:必填项缺失统一走用法错误(退出码 8)。 */
134
+ export function needArg(input, key, flag) {
135
+ const raw = input[key];
136
+ if (raw === undefined || raw === null || raw === '' || raw === true) {
137
+ throw dataValidationError('missing_argument', `缺少必填参数 --${flag ?? key.replace(/_/g, '-')}`);
138
+ }
139
+ return String(raw);
140
+ }