weaver-work-cli 0.1.40 → 0.1.44

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 (401) hide show
  1. package/README.md +17 -0
  2. package/dist/chunks/{archive-JHTONRST.js → archive-P6TBQGKL.js} +13 -5
  3. package/dist/chunks/{archive-oa-FCHLCPHC.js → archive-oa-7TQ2NXOH.js} +12 -5
  4. package/dist/chunks/{asset-RLIHC7DB.js → asset-3ELRG37G.js} +11 -4
  5. package/dist/chunks/{asset-idle-KVOFTLCP.js → asset-idle-WIGMUFMD.js} +7 -3
  6. package/dist/chunks/{attachment-content-RZYDB3MB.js → attachment-content-E3276UOV.js} +5 -4
  7. package/dist/chunks/{blog-42OZTJNP.js → blog-C5NMZAAC.js} +11 -4
  8. package/dist/chunks/{caizhilian-KRK547K5.js → caizhilian-5XSM2DFP.js} +13 -6
  9. package/dist/chunks/{calendar-RTWAMKHD.js → calendar-FI2WNSBO.js} +71 -26
  10. package/dist/chunks/{chunk-CXRQWOZ5.js → chunk-3YBDYOC4.js} +3 -3
  11. package/dist/chunks/{chunk-OOUTBLZ4.js → chunk-56EZERK4.js} +1 -1
  12. package/dist/chunks/chunk-6N4JPNFL.js +76 -0
  13. package/dist/chunks/{chunk-ZUX3P6BQ.js → chunk-727FH2NI.js} +1 -1
  14. package/dist/chunks/chunk-7BDPM5ST.js +11 -0
  15. package/dist/chunks/{chunk-LN447PY2.js → chunk-BCVYBYYT.js} +432 -2247
  16. package/dist/chunks/{chunk-7E6MUOEK.js → chunk-CWYGFU5B.js} +2 -2
  17. package/dist/chunks/{chunk-NOODWMCL.js → chunk-D4ADSZ7H.js} +1 -1
  18. package/dist/chunks/{chunk-WFFNM65B.js → chunk-ETNJSKMM.js} +281 -29
  19. package/dist/chunks/{chunk-CAQNBBQA.js → chunk-F4E4EM35.js} +3 -3
  20. package/dist/chunks/{chunk-4CTESSKI.js → chunk-FAZTGX7S.js} +6 -6
  21. package/dist/chunks/chunk-FRZKBMSW.js +2562 -0
  22. package/dist/chunks/{chunk-BYBSCN4X.js → chunk-G7PQWD4L.js} +6 -3
  23. package/dist/chunks/{chunk-NJKREDA3.js → chunk-GAMZLAG2.js} +1 -1
  24. package/dist/chunks/{chunk-FLS4DPGP.js → chunk-GM6J7Q4B.js} +28 -15
  25. package/dist/chunks/{chunk-NETCCARD.js → chunk-GRDRG6HP.js} +3 -3
  26. package/dist/chunks/chunk-HIT4Y6OI.js +1238 -0
  27. package/dist/chunks/{chunk-EZALDOQH.js → chunk-HP7JIYMT.js} +5 -2
  28. package/dist/chunks/{chunk-IZSSVYAG.js → chunk-IAZ3UPY6.js} +3 -3
  29. package/dist/chunks/{chunk-ZEDWSH32.js → chunk-IC62NFM5.js} +1 -1
  30. package/dist/chunks/{chunk-P26ZWSKU.js → chunk-KIHNAS25.js} +5 -2
  31. package/dist/chunks/{chunk-57IECMWX.js → chunk-N4M2DDFE.js} +29 -15
  32. package/dist/chunks/{chunk-JWRZM2H2.js → chunk-OF4S23UB.js} +4 -4
  33. package/dist/chunks/{chunk-VNBU55SL.js → chunk-PC7VKEB5.js} +80 -2458
  34. package/dist/chunks/{chunk-G2JSIUWF.js → chunk-PUQS5MWL.js} +91 -2
  35. package/dist/chunks/{chunk-E7OK5WD5.js → chunk-Q4OYAQYH.js} +5 -5
  36. package/dist/chunks/{chunk-7BRU4EFH.js → chunk-QVSWRLLU.js} +35 -6
  37. package/dist/chunks/{chunk-T6EGVBKU.js → chunk-TA7FXXJD.js} +6 -3
  38. package/dist/chunks/{chunk-GPMFD4RD.js → chunk-TXUG266F.js} +1 -1
  39. package/dist/chunks/{chunk-4TEDNCON.js → chunk-UFIT2UU3.js} +354 -56
  40. package/dist/chunks/{chunk-LUSPKZKY.js → chunk-UG5G54VL.js} +1 -0
  41. package/dist/chunks/{chunk-NIAJ5ZCG.js → chunk-UL5XUQ25.js} +5 -2
  42. package/dist/chunks/{chunk-FMPJJYYI.js → chunk-WRXSAVKO.js} +1 -1
  43. package/dist/chunks/{chunk-7U577Q7U.js → chunk-WSF4NNMR.js} +3 -3
  44. package/dist/chunks/chunk-XHK4MDR5.js +2497 -0
  45. package/dist/chunks/{chunk-LFMSDBZN.js → chunk-XNIK66I4.js} +326 -161
  46. package/dist/chunks/{chunk-3SO6QL6U.js → chunk-YWX377BY.js} +5 -2
  47. package/dist/chunks/{chunk-BYATLLEF.js → chunk-Z3GDFVJR.js} +1 -1
  48. package/dist/chunks/{chunk-I566ZYNF.js → chunk-Z7VYWPZV.js} +1 -1
  49. package/dist/chunks/{conflict-VR55AOOO.js → conflict-ARLSZJ6V.js} +4 -3
  50. package/dist/chunks/{continuation-2CKSBLA6.js → continuation-3S37AUSH.js} +4 -3
  51. package/dist/chunks/{continuation-RN6PZN2M.js → continuation-3XLYYTKV.js} +4 -3
  52. package/dist/chunks/{continuation-HZIZRZBX.js → continuation-HFW2YT5S.js} +4 -3
  53. package/dist/chunks/{continuation-NLECEJPX.js → continuation-KI7DRRZN.js} +4 -3
  54. package/dist/chunks/{contract-HI4FNPYE.js → contract-DNIIW5VJ.js} +13 -5
  55. package/dist/chunks/{cowork-HJLI353D.js → cowork-GMLRGVIW.js} +31 -14
  56. package/dist/chunks/create-flow-J22BO65E.js +56 -0
  57. package/dist/chunks/{ebuilder-form-HTGI63UU.js → ebuilder-form-ANV2FHYV.js} +12 -7
  58. package/dist/chunks/{ehr-GYXIYH3A.js → ehr-GSTGAIY3.js} +695 -1255
  59. package/dist/chunks/{employee-SAK2QYXX.js → employee-22BGJ3QS.js} +3 -3
  60. package/dist/chunks/{env-DW3G4HUO.js → env-BX3VRFS7.js} +4 -3
  61. package/dist/chunks/{esb-I5INCEFE.js → esb-ATAIASX2.js} +12 -7
  62. package/dist/chunks/{factory-TKXGXS6L.js → factory-PETTFME6.js} +3 -2
  63. package/dist/chunks/{fna-K2MHTQ24.js → fna-YEKBSFSX.js} +14 -8
  64. package/dist/chunks/{group-chat-VYBNMJLG.js → group-chat-BFVXAYFX.js} +7 -4
  65. package/dist/chunks/{host-D5SERMAJ.js → host-HRBXEPDQ.js} +5 -5
  66. package/dist/chunks/{host-JM4YVHFM.js → host-LR55CTHP.js} +5 -5
  67. package/dist/chunks/{host-L3VLITMT.js → host-SUOY6VYQ.js} +5 -5
  68. package/dist/chunks/{host-ZUQTJYYK.js → host-SZGV4UNT.js} +5 -5
  69. package/dist/chunks/{host-256GVCAH.js → host-WIKN2EJ5.js} +5 -5
  70. package/dist/chunks/{hrm-VLRBKTZB.js → hrm-NRDO4W5G.js} +11 -7
  71. package/dist/chunks/{im-QK3VTLXK.js → im-IQ2HN23S.js} +11 -10
  72. package/dist/chunks/{invoice-T5JTA32H.js → invoice-MNRW76PP.js} +636 -1768
  73. package/dist/chunks/{jiuchuanhui-P2FNEQVZ.js → jiuchuanhui-DTRBAX4N.js} +14 -6
  74. package/dist/chunks/{lazy-dispatch-XRRI46M6.js → lazy-dispatch-ZVWAI25B.js} +7 -6
  75. package/dist/chunks/{mail-3Y7MJ6PS.js → mail-ZVAUXOJA.js} +16 -14
  76. package/dist/chunks/{meeting-M7LTXGJE.js → meeting-FEVPZ67S.js} +21 -13
  77. package/dist/chunks/{okr-OBC6S67L.js → okr-SDH3E5RA.js} +12 -5
  78. package/dist/chunks/{operations-5QL3AECO.js → operations-62N6EP3C.js} +4 -3
  79. package/dist/chunks/{plan-5H6I53SK.js → plan-E35JFDI7.js} +12 -5
  80. package/dist/chunks/{project-L75QZV4S.js → project-73QXBAB2.js} +49 -25
  81. package/dist/chunks/reception-UWZVACBN.js +1899 -0
  82. package/dist/chunks/recruit-stage-4MAOCKFY.js +4770 -0
  83. package/dist/chunks/registry-IM5G23LS.js +24 -0
  84. package/dist/chunks/{registry-UGRBCBHO.js → registry-JDUS4E7D.js} +7 -6
  85. package/dist/chunks/{registry-RXPN6BBT.js → registry-KNKSCJNT.js} +7 -6
  86. package/dist/chunks/{registry-NYPYMZXG.js → registry-PO7SI256.js} +4 -4
  87. package/dist/chunks/{registry-QGHFNUWS.js → registry-PVUZQDDQ.js} +3 -3
  88. package/dist/chunks/{room-recommend-A3UDC3CA.js → room-recommend-H7KLXA5R.js} +6 -5
  89. package/dist/chunks/{schedule-5GCACCK7.js → schedule-ESZIBAUO.js} +6 -5
  90. package/dist/chunks/{workflow-M5ZJ7DWF.js → workflow-CWJFJLQU.js} +15 -10
  91. package/dist/cmd/action.js +6 -0
  92. package/dist/cmd/identity/index.js +45 -0
  93. package/dist/cmd/index.js +2 -0
  94. package/dist/core/continuation-ttl.js +18 -0
  95. package/dist/core/error-codes.js +85 -0
  96. package/dist/core/logger.js +11 -0
  97. package/dist/index.js +41 -30
  98. package/dist/internal/e10/auth/commands.js +164 -8
  99. package/dist/internal/e10/auth/error-log.js +182 -0
  100. package/dist/internal/e10/auth/messages.js +6 -0
  101. package/dist/internal/e10/auth/session.js +34 -3
  102. package/dist/internal/e10/auth/xiaoe.js +286 -44
  103. package/dist/internal/e10/auth-recovery.js +72 -14
  104. package/dist/internal/e10/context.js +72 -13
  105. package/dist/internal/e10/index.js +1 -1
  106. package/dist/internal/e10/network-error.js +93 -0
  107. package/dist/internal/e10/request-runtime.js +6 -0
  108. package/dist/internal/skills/install.js +9 -1
  109. package/dist/shortcuts/archive/continuation.js +2 -1
  110. package/dist/shortcuts/archive/index.js +3 -0
  111. package/dist/shortcuts/archive/operations/confirm.js +2 -1
  112. package/dist/shortcuts/archive-oa/continuation.js +2 -1
  113. package/dist/shortcuts/archive-oa/index.js +2 -0
  114. package/dist/shortcuts/archive-oa/operations/confirm.js +2 -1
  115. package/dist/shortcuts/asset/continuation.js +2 -1
  116. package/dist/shortcuts/asset/index.js +2 -0
  117. package/dist/shortcuts/asset-idle/index.js +2 -0
  118. package/dist/shortcuts/blog/continuation.js +2 -1
  119. package/dist/shortcuts/blog/index.js +2 -0
  120. package/dist/shortcuts/caizhilian/continuation.js +2 -1
  121. package/dist/shortcuts/caizhilian/index.js +2 -0
  122. package/dist/shortcuts/caizhilian/operations/confirm.js +3 -2
  123. package/dist/shortcuts/calendar/continuation.js +2 -1
  124. package/dist/shortcuts/calendar/index.js +2 -0
  125. package/dist/shortcuts/calendar/operations/read.js +31 -22
  126. package/dist/shortcuts/calendar/operations/write.js +46 -2
  127. package/dist/shortcuts/contract/continuation.js +2 -1
  128. package/dist/shortcuts/contract/index.js +2 -0
  129. package/dist/shortcuts/contract/operations/write.js +2 -1
  130. package/dist/shortcuts/cowork/continuation.js +2 -1
  131. package/dist/shortcuts/cowork/index.js +2 -0
  132. package/dist/shortcuts/cowork/operations/discuss-write.js +5 -1
  133. package/dist/shortcuts/cowork/operations/item-write.js +1 -7
  134. package/dist/shortcuts/cowork/operations/member-write.js +3 -1
  135. package/dist/shortcuts/cowork/operations/permission-write.js +5 -1
  136. package/dist/shortcuts/cowork/operations/shared.js +7 -0
  137. package/dist/shortcuts/ebuilder-form/continuation.js +2 -1
  138. package/dist/shortcuts/ebuilder-form/index.js +2 -0
  139. package/dist/shortcuts/ebuilder-form/operations/write.js +3 -2
  140. package/dist/shortcuts/ehr/continuation.js +2 -1
  141. package/dist/shortcuts/ehr/index.js +2 -0
  142. package/dist/shortcuts/ehr/operations/attend-write.js +44 -2
  143. package/dist/shortcuts/ehr/operations/hr-contact.js +7 -4
  144. package/dist/shortcuts/ehr/operations/hr-report.js +13 -7
  145. package/dist/shortcuts/ehr/operations/recruit-candidate-import.js +317 -63
  146. package/dist/shortcuts/ehr/operations/recruit-position.js +134 -2
  147. package/dist/shortcuts/ehr/operations/recruit-write.js +263 -18
  148. package/dist/shortcuts/ehr/operations/recruit.js +10 -4
  149. package/dist/shortcuts/ehr/operations/shared.js +47 -0
  150. package/dist/shortcuts/esb/continuation.js +2 -1
  151. package/dist/shortcuts/esb/index.js +2 -0
  152. package/dist/shortcuts/esb/operations/trigger.js +2 -1
  153. package/dist/shortcuts/fna/continuation.js +2 -1
  154. package/dist/shortcuts/fna/index.js +2 -0
  155. package/dist/shortcuts/fna/operations/invoice-writeoff.js +1 -1
  156. package/dist/shortcuts/fna/operations/loan.js +1 -1
  157. package/dist/shortcuts/hrm/index.js +2 -0
  158. package/dist/shortcuts/hrm/operations/org.js +118 -0
  159. package/dist/shortcuts/im/continuation.js +2 -1
  160. package/dist/shortcuts/index.js +10 -0
  161. package/dist/shortcuts/invoice/continuation.js +2 -1
  162. package/dist/shortcuts/invoice/index.js +14 -15
  163. package/dist/shortcuts/invoice/invoice-record.js +93 -0
  164. package/dist/shortcuts/invoice/manifest.js +190 -393
  165. package/dist/shortcuts/invoice/operations/add.js +2 -1
  166. package/dist/shortcuts/invoice/operations/delete.js +2 -1
  167. package/dist/shortcuts/invoice/operations/import.js +2 -1
  168. package/dist/shortcuts/invoice/operations/issuing-contract-detail.js +86 -0
  169. package/dist/shortcuts/invoice/operations/issuing-contracts.js +210 -0
  170. package/dist/shortcuts/invoice/operations/registry.js +17 -17
  171. package/dist/shortcuts/invoice/operations/reim-auto.js +4 -569
  172. package/dist/shortcuts/invoice/operations/reim.js +52 -341
  173. package/dist/shortcuts/invoice/operations/shared.js +21 -4
  174. package/dist/shortcuts/invoice/operations/update.js +2 -1
  175. package/dist/shortcuts/invoice/projection.js +10 -62
  176. package/dist/shortcuts/jiuchuanhui/continuation.js +2 -1
  177. package/dist/shortcuts/jiuchuanhui/index.js +2 -0
  178. package/dist/shortcuts/jiuchuanhui/operations/datajson.js +2 -1
  179. package/dist/shortcuts/jiuchuanhui/operations/esb.js +2 -1
  180. package/dist/shortcuts/mail/continuation.js +2 -1
  181. package/dist/shortcuts/mail/index.js +2 -0
  182. package/dist/shortcuts/mail/operations/mail-blacklist.js +1 -1
  183. package/dist/shortcuts/mail/operations/mail-contacts.js +1 -1
  184. package/dist/shortcuts/mail/operations/mail-send.js +1 -1
  185. package/dist/shortcuts/mail/operations/mail-sign.js +1 -1
  186. package/dist/shortcuts/mail/operations/mail-template.js +1 -1
  187. package/dist/shortcuts/meeting/continuation.js +2 -1
  188. package/dist/shortcuts/meeting/index.js +2 -0
  189. package/dist/shortcuts/meeting/operations/change.js +1 -1
  190. package/dist/shortcuts/meeting/operations/create.js +1 -1
  191. package/dist/shortcuts/meeting/operations/eb/catalog.js +4 -1
  192. package/dist/shortcuts/meeting/operations/eb/create-flow.js +101 -35
  193. package/dist/shortcuts/meeting/operations/eb/decision.js +1 -1
  194. package/dist/shortcuts/meeting/operations/eb/factory.js +34 -1
  195. package/dist/shortcuts/meeting/operations/eb/group-chat.js +25 -3
  196. package/dist/shortcuts/meeting/operations/eb/person-cache.js +96 -0
  197. package/dist/shortcuts/meeting/operations/eb/room-recommend.js +33 -11
  198. package/dist/shortcuts/meeting/operations/lifecycle.js +1 -1
  199. package/dist/shortcuts/meeting/operations/receipts.js +1 -1
  200. package/dist/shortcuts/meeting/operations/signs.js +1 -1
  201. package/dist/shortcuts/okr/continuation.js +2 -1
  202. package/dist/shortcuts/okr/index.js +2 -0
  203. package/dist/shortcuts/okr/operations/write.js +1 -1
  204. package/dist/shortcuts/plan/continuation.js +2 -1
  205. package/dist/shortcuts/plan/index.js +2 -0
  206. package/dist/shortcuts/plan/operations/write.js +1 -1
  207. package/dist/shortcuts/project/continuation.js +2 -1
  208. package/dist/shortcuts/project/index.js +2 -0
  209. package/dist/shortcuts/project/operations/read.js +6 -25
  210. package/dist/shortcuts/project/operations/shared.js +22 -0
  211. package/dist/shortcuts/project/operations/write.js +28 -2
  212. package/dist/shortcuts/reception/constants.js +53 -0
  213. package/dist/shortcuts/reception/errors.js +54 -0
  214. package/dist/shortcuts/reception/host.js +125 -0
  215. package/dist/shortcuts/reception/index.js +198 -0
  216. package/dist/shortcuts/reception/manifest.js +177 -0
  217. package/dist/shortcuts/reception/operations/ask.js +71 -0
  218. package/dist/shortcuts/reception/operations/browsertool.js +58 -0
  219. package/dist/shortcuts/reception/operations/compose.js +129 -0
  220. package/dist/shortcuts/reception/operations/customparams.js +74 -0
  221. package/dist/shortcuts/reception/operations/doc.js +238 -0
  222. package/dist/shortcuts/reception/operations/docrender.js +36 -0
  223. package/dist/shortcuts/reception/operations/panels.js +179 -0
  224. package/dist/shortcuts/reception/operations/registry.js +26 -0
  225. package/dist/shortcuts/reception/operations/render-assets.js +184 -0
  226. package/dist/shortcuts/reception/operations/render.js +123 -0
  227. package/dist/shortcuts/reception/operations/runs.js +38 -0
  228. package/dist/shortcuts/reception/operations/schedule.js +127 -0
  229. package/dist/shortcuts/reception/operations/shared.js +196 -0
  230. package/dist/shortcuts/reception/operations/snapshot.js +68 -0
  231. package/dist/shortcuts/reception/operations/types.js +1 -0
  232. package/dist/shortcuts/reception/operations.js +33 -0
  233. package/dist/shortcuts/reception/upload.js +218 -0
  234. package/dist/shortcuts/recruit-stage/context.js +231 -0
  235. package/dist/shortcuts/recruit-stage/continuation.js +74 -0
  236. package/dist/shortcuts/recruit-stage/errors.js +65 -0
  237. package/dist/shortcuts/recruit-stage/host.js +109 -0
  238. package/dist/shortcuts/recruit-stage/index.js +115 -0
  239. package/dist/shortcuts/recruit-stage/manifest.js +29 -0
  240. package/dist/shortcuts/recruit-stage/operations/interview-arrange.js +722 -0
  241. package/dist/shortcuts/recruit-stage/operations/interview-feedback.js +269 -0
  242. package/dist/shortcuts/recruit-stage/operations/jd-create.js +719 -0
  243. package/dist/shortcuts/recruit-stage/operations/list.js +431 -0
  244. package/dist/shortcuts/recruit-stage/operations/registry.js +38 -0
  245. package/dist/shortcuts/recruit-stage/operations/resume-import.js +1354 -0
  246. package/dist/shortcuts/recruit-stage/operations/search.js +158 -0
  247. package/dist/shortcuts/recruit-stage/operations/types.js +25 -0
  248. package/dist/shortcuts/recruit-stage/school-tiers.json +318 -0
  249. package/dist/shortcuts/recruit-stage/shared.js +608 -0
  250. package/dist/shortcuts/workflow/continuation.js +2 -1
  251. package/dist/shortcuts/workflow/index.js +2 -0
  252. package/dist/shortcuts/workflow/operations/form.js +32 -8
  253. package/dist/shortcuts/workflow/operations/todoSmartConvert/detailFieldRules.js +4 -2
  254. package/dist/shortcuts/workflow/operations/todoSmartConvert/summaryCache.js +13 -6
  255. package/dist/shortcuts/workflow/operations/todoSmartConvert/todoDetailCache.js +17 -24
  256. package/dist/shortcuts/workflow/operations/todoSmartConvert/todoDetailFetcher.js +14 -9
  257. package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.collect.js +50 -8
  258. package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.core.js +2 -1
  259. package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.detail.js +17 -11
  260. package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.group.js +7 -39
  261. package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.groupSummary.js +3 -2
  262. package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.js +51 -15
  263. package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.pipeline.js +16 -1
  264. package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.smartGroup.js +151 -63
  265. package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.subGroup.js +56 -0
  266. package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.summary.js +39 -14
  267. package/dist/shortcuts/workflow/operations/write.js +1 -1
  268. package/docs/_catalog.md +3 -0
  269. package/docs/agent-invoice.md +1 -1
  270. package/docs/archive-oa.md +1 -1
  271. package/docs/caizhilian.md +1 -1
  272. package/docs/calendar.md +1 -1
  273. package/docs/contract.md +1 -1
  274. package/docs/e10-auth.md +23 -1
  275. package/docs/ehr.md +2 -2
  276. package/docs/esb.md +1 -1
  277. package/docs/im.md +1 -1
  278. package/docs/invoice.md +8 -12
  279. package/docs/okr.md +1 -1
  280. package/docs/operation-manual.md +8 -0
  281. package/docs/reception.md +119 -0
  282. package/package.json +1 -1
  283. package/scripts/clean.mjs +43 -2
  284. package/scripts/install-skill-to-xiaoe.mjs +105 -0
  285. package/scripts/package-skill.mjs +4 -2
  286. package/skill-template/business-info.json +42 -2
  287. package/skill-template/domains/caizhilian.md +1 -1
  288. package/skill-template/domains/reception-flow.md +18 -0
  289. package/skill-template/domains/recruit-stage.md +29 -0
  290. package/skill-template/domains/yepiaotong.md +4 -7
  291. package/skills/weaver-e10-archive-oa/references/source-manifest.json +14 -14
  292. package/skills/weaver-e10-blog/references/blog-publish.md +1 -1
  293. package/skills/weaver-e10-blog/references/source-manifest.json +7 -7
  294. package/skills/weaver-e10-caizhilian/references/source-manifest.json +21 -21
  295. package/skills/weaver-e10-caizhilian/references/write-protocol.md +2 -2
  296. package/skills/weaver-e10-calendar/SKILL.md +2 -1
  297. package/skills/weaver-e10-calendar/references/calendar-write.md +55 -1
  298. package/skills/weaver-e10-cowork/SKILL.md +1 -1
  299. package/skills/weaver-e10-cowork/references/cowork-write.md +3 -1
  300. package/skills/weaver-e10-ebuilder-form/SKILL.md +1 -1
  301. package/skills/weaver-e10-ebuilder-form/references/custom-api.md +1 -1
  302. package/skills/weaver-e10-ebuilder-form/references/openapi-write.md +1 -1
  303. package/skills/weaver-e10-esb/SKILL.md +2 -2
  304. package/skills/weaver-e10-esb/references/source-manifest.json +22 -22
  305. package/skills/weaver-e10-esb/references/trigger.md +2 -2
  306. package/skills/weaver-e10-jinchengda/references/contract-clause-library-crud.md +1 -1
  307. package/skills/weaver-e10-jinchengda/references/contract-clause-reference-save.md +1 -1
  308. package/skills/weaver-e10-jinchengda/references/contract-request-write.md +1 -1
  309. package/skills/weaver-e10-jinchengda/references/source-manifest.json +29 -29
  310. package/skills/weaver-e10-jucailin/SKILL.md +1 -1
  311. package/skills/weaver-e10-jucailin/references/attend-write.md +10 -2
  312. package/skills/weaver-e10-jucailin/references/hr-contact.md +8 -0
  313. package/skills/weaver-e10-jucailin/references/hr-report.md +8 -0
  314. package/skills/weaver-e10-jucailin/references/recruit-create.md +14 -5
  315. package/skills/weaver-e10-jucailin/references/recruit-read.md +1 -1
  316. package/skills/weaver-e10-jucailin/references/recruit-write.md +5 -4
  317. package/skills/weaver-e10-mail/SKILL.md +1 -1
  318. package/skills/weaver-e10-meeting/SKILL.md +39 -7
  319. package/skills/weaver-e10-meeting/references/meeting-change.md +1 -1
  320. package/skills/weaver-e10-meeting/references/meeting-create.md +1 -1
  321. package/skills/weaver-e10-meeting/references/meeting-lifecycle.md +1 -1
  322. package/skills/weaver-e10-meeting/references/meeting-verification.md +1 -1
  323. package/skills/weaver-e10-okr/references/okr-align.md +1 -1
  324. package/skills/weaver-e10-okr/references/okr-keyresult.md +1 -1
  325. package/skills/weaver-e10-okr/references/okr-write.md +1 -1
  326. package/skills/weaver-e10-okr/references/source-manifest.json +8 -8
  327. package/skills/weaver-e10-plan/references/plan-report-write.md +1 -1
  328. package/skills/weaver-e10-plan/references/source-manifest.json +20 -20
  329. package/skills/weaver-e10-qiyecheng/references/loan-management.md +1 -1
  330. package/skills/weaver-e10-qiyecheng/references/source-manifest.json +18 -18
  331. package/skills/weaver-e10-reception-flow/SKILL.md +173 -0
  332. package/skills/weaver-e10-reception-flow/assets//350/241/214/347/250/213/345/215/225/346/250/241/346/235/277-/346/263/233/345/276/256.docx +0 -0
  333. package/skills/weaver-e10-reception-flow/data/fields-snapshot.json +213 -0
  334. package/skills/weaver-e10-reception-flow/references/browsertool.md +68 -0
  335. package/skills/weaver-e10-reception-flow/references/env-pitfalls.md +51 -0
  336. package/skills/weaver-e10-reception-flow/references/fields-snapshot.md +227 -0
  337. package/skills/weaver-e10-reception-flow/references/guide.md +179 -0
  338. package/skills/weaver-e10-reception-flow/scripts/locate.sh +14 -0
  339. package/skills/weaver-e10-reception-flow/scripts/render.py +724 -0
  340. package/skills/weaver-e10-recruit-stage/SKILL.md +230 -0
  341. package/skills/weaver-e10-recruit-stage/agents/openai.yaml +119 -0
  342. package/skills/weaver-e10-recruit-stage/lib/recruit-xiaoe-file.mjs +188 -0
  343. package/skills/weaver-e10-recruit-stage/lib/xiaoe-session.mjs +66 -0
  344. package/skills/weaver-e10-recruit-stage/references/position-templates.md +202 -0
  345. package/skills/weaver-e10-recruit-stage/references/recruit-arrange-interview.md +322 -0
  346. package/skills/weaver-e10-recruit-stage/references/recruit-capability-check.md +127 -0
  347. package/skills/weaver-e10-recruit-stage/references/recruit-check-install.md +65 -0
  348. package/skills/weaver-e10-recruit-stage/references/recruit-detail-process.md +63 -0
  349. package/skills/weaver-e10-recruit-stage/references/recruit-edit-interview-feedback.md +142 -0
  350. package/skills/weaver-e10-recruit-stage/references/recruit-jd-create.md +95 -0
  351. package/skills/weaver-e10-recruit-stage/references/recruit-jd-template.md +56 -0
  352. package/skills/weaver-e10-recruit-stage/references/recruit-list-candidate.md +101 -0
  353. package/skills/weaver-e10-recruit-stage/references/recruit-list-interview.md +148 -0
  354. package/skills/weaver-e10-recruit-stage/references/recruit-match-candidates.md +77 -0
  355. package/skills/weaver-e10-recruit-stage/references/recruit-output-links.md +59 -0
  356. package/skills/weaver-e10-recruit-stage/references/recruit-resolve-creator.md +69 -0
  357. package/skills/weaver-e10-recruit-stage/references/recruit-resolve-metadata.md +241 -0
  358. package/skills/weaver-e10-recruit-stage/references/recruit-resume-import.md +451 -0
  359. package/skills/weaver-e10-recruit-stage/references/recruit-resume-parse.md +128 -0
  360. package/skills/weaver-e10-recruit-stage/references/recruit-search-candidate.md +146 -0
  361. package/skills/weaver-e10-recruit-stage/references/recruit-urge-feedback.md +69 -0
  362. package/skills/weaver-e10-shared/SKILL.md +1 -1
  363. package/skills/weaver-e10-shared/references/e10-auth-and-session.md +10 -2
  364. package/skills/weaver-e10-shijingran/SKILL.md +7 -6
  365. package/skills/weaver-e10-shijingran/references/operations.md +3 -1
  366. package/skills/weaver-e10-shijingran/references/source-manifest.json +30 -28
  367. package/skills/weaver-e10-shijingran/references/write-operations.md +2 -0
  368. package/skills/weaver-e10-skill-maker/references/module-cli-generation.md +2 -0
  369. package/skills/weaver-e10-wenshuding/references/source-manifest.json +3 -3
  370. package/skills/weaver-e10-workflow/SKILL.md +4 -2
  371. package/skills/weaver-e10-workflow/aigroup/default.json +11 -9
  372. package/skills/weaver-e10-workflow/references/source-manifest.json +32 -32
  373. package/skills/weaver-e10-workflow/references/todo-smart-convert.md +23 -13
  374. package/skills/weaver-e10-workflow/tools/todo-summary.cjs +62 -20
  375. package/skills/weaver-e10-yepiaotong/SKILL.md +28 -36
  376. package/skills/weaver-e10-yepiaotong/references/invoice-agent-entry.md +6 -3
  377. package/skills/weaver-e10-yepiaotong/references/invoice-detail.md +13 -10
  378. package/skills/weaver-e10-yepiaotong/references/invoice-enterprise-list.md +2 -0
  379. package/skills/weaver-e10-yepiaotong/references/invoice-issuing-workflow.md +194 -155
  380. package/skills/weaver-e10-yepiaotong/references/invoice-output-view.md +28 -32
  381. package/skills/weaver-e10-yepiaotong/references/invoice-personal-list.md +5 -1
  382. package/skills/weaver-e10-yepiaotong/references/invoice-reim.md +8 -10
  383. package/skills/weaver-e10-yepiaotong/references/reim-api-reference.md +211 -616
  384. package/skills/weaver-e10-yepiaotong/references/reim-examples.md +149 -117
  385. package/skills/weaver-e10-yepiaotong/references/reim-expense-subject-rules.md +17 -20
  386. package/skills/weaver-e10-yepiaotong/references/reim-form-fill-rules.md +20 -39
  387. package/skills/weaver-e10-yepiaotong/references/reim-matching-rules.md +55 -22
  388. package/skills/weaver-e10-yepiaotong/references/reim-phone-subsidy-rules.md +7 -17
  389. package/skills/weaver-e10-yepiaotong/references/reim-workflow.md +88 -92
  390. package/skills/weaver-e10-yepiaotong/references/source-manifest.json +144 -354
  391. package/skills/weaver-e10-yimiaoban/SKILL.md +1 -1
  392. package/skills/weaver-e10-yimiaoban/references/msg-write.md +1 -1
  393. package/skills/weaver-e10-yimiaoban/references/safety-boundaries.md +1 -1
  394. package/skills/weaver-e10-yimiaoban/references/source-manifest.json +7 -7
  395. package/dist/chunks/chunk-SPRHHSVC.js +0 -465
  396. package/dist/chunks/registry-KMHCPAAD.js +0 -22
  397. package/dist/shortcuts/invoice/markdown.js +0 -172
  398. package/dist/shortcuts/invoice/operations/issuing-qys.js +0 -424
  399. package/skills/weaver-e10-meeting.zip +0 -0
  400. package/skills/weaver-e10-yepiaotong/references/invoice-issuing-examples.md +0 -131
  401. package/skills/weaver-e10-yepiaotong/references/invoice-issuing-form-fill-rules.md +0 -179
@@ -0,0 +1,2562 @@
1
+ import { createRequire as __esbuildCreateRequire } from 'node:module';
2
+ const require = __esbuildCreateRequire(import.meta.url);
3
+ import {
4
+ dayOf,
5
+ filterUsages,
6
+ invalidateDayUsages,
7
+ loadDayUsages,
8
+ loadRooms,
9
+ recommendRooms
10
+ } from "./chunk-GM6J7Q4B.js";
11
+ import {
12
+ cacheScopeSuffix,
13
+ readCache,
14
+ writeCache
15
+ } from "./chunk-Z7VYWPZV.js";
16
+ import {
17
+ fetchEbAppSettings,
18
+ findCommonFreeSlots
19
+ } from "./chunk-OF4S23UB.js";
20
+ import {
21
+ EB_BASE,
22
+ SCHEMA_DATETIME_MINUTE,
23
+ ebBusinessSuccess,
24
+ meetingSuccess,
25
+ meetingValidationError,
26
+ schemaOf,
27
+ writeBody
28
+ } from "./chunk-QVSWRLLU.js";
29
+ import {
30
+ CONTINUATION_TTL_MS,
31
+ CONTINUATION_TTL_SECONDS
32
+ } from "./chunk-7BDPM5ST.js";
33
+
34
+ // src/shortcuts/meeting/operations/eb/create-flow.ts
35
+ import { existsSync } from "node:fs";
36
+ import { mkdir, readFile, writeFile } from "node:fs/promises";
37
+ import { homedir } from "node:os";
38
+ import { resolve } from "node:path";
39
+
40
+ // src/shortcuts/meeting/operations/eb/flow-memory.ts
41
+ var FLOW_PICK_TTL_MS = 30 * 24 * 60 * 60 * 1e3;
42
+ function flowPickKey(scope) {
43
+ return `flow-pick-${scope}`;
44
+ }
45
+ async function readFlowPick(env) {
46
+ const scope = await cacheScopeSuffix(env);
47
+ const hit = await readCache(env, flowPickKey(scope), { ttlMs: FLOW_PICK_TTL_MS });
48
+ if (!hit?.data?.workflowId) return null;
49
+ try {
50
+ const session = await env.host.getSession();
51
+ const userId = String(session?.userId ?? "");
52
+ if (hit.data.userId && userId && hit.data.userId !== userId) return null;
53
+ } catch {
54
+ }
55
+ return hit.data;
56
+ }
57
+ async function rememberFlowPick(env, workflowId, name) {
58
+ const id = String(workflowId ?? "").trim();
59
+ if (id === "") return;
60
+ let userId = "";
61
+ try {
62
+ const session = await env.host.getSession();
63
+ userId = String(session?.userId ?? "");
64
+ } catch {
65
+ }
66
+ const scope = await cacheScopeSuffix(env);
67
+ await writeCache(env, flowPickKey(scope), {
68
+ workflowId: id,
69
+ ...name ? { name: String(name) } : {},
70
+ ...userId ? { userId } : {},
71
+ savedAt: Date.now()
72
+ });
73
+ }
74
+ function pickRememberedFlow(launchable, remembered) {
75
+ if (!remembered?.workflowId) return null;
76
+ return launchable.find((probe) => probe.workflowId === remembered.workflowId) ?? null;
77
+ }
78
+
79
+ // src/shortcuts/meeting/operations/eb/person-cache.ts
80
+ var PERSON_TTL_MS = 24 * 60 * 60 * 1e3;
81
+ var BATCH_MAX = 100;
82
+ function personKey(scope) {
83
+ return `person-v1-${scope}`;
84
+ }
85
+ async function readAll(env) {
86
+ const scope = await cacheScopeSuffix(env);
87
+ const hit = await readCache(env, personKey(scope), { ttlMs: PERSON_TTL_MS * 30 });
88
+ if (!hit) return {};
89
+ const now = Date.now();
90
+ const fresh = {};
91
+ for (const [id, record] of Object.entries(hit.data ?? {})) {
92
+ if (record && now - Number(record.savedAt || 0) <= PERSON_TTL_MS) fresh[id] = record;
93
+ }
94
+ return fresh;
95
+ }
96
+ async function writeAll(env, all) {
97
+ const scope = await cacheScopeSuffix(env);
98
+ await writeCache(env, personKey(scope), all);
99
+ }
100
+ async function resolvePersonsCached(env, ids, options = {}) {
101
+ const wanted = [...new Set(ids.map((id) => String(id ?? "").trim()).filter((id) => id !== ""))];
102
+ const persons = /* @__PURE__ */ new Map();
103
+ if (wanted.length === 0) return { persons, requests: 0, fromCache: 0 };
104
+ const all = options.refresh === true ? {} : await readAll(env);
105
+ const missing = [];
106
+ let fromCache = 0;
107
+ for (const id of wanted) {
108
+ const hit = all[id];
109
+ if (hit) {
110
+ persons.set(id, hit);
111
+ fromCache += 1;
112
+ } else missing.push(id);
113
+ }
114
+ if (missing.length === 0) return { persons, requests: 0, fromCache };
115
+ let requests = 0;
116
+ for (let index = 0; index < missing.length; index += BATCH_MAX) {
117
+ const chunk = missing.slice(index, index + BATCH_MAX);
118
+ try {
119
+ const { hrmEmployeeOperations } = await import("./employee-22BGJ3QS.js");
120
+ const batch = hrmEmployeeOperations.find((operation) => operation.name === "hrm.employee.batch");
121
+ if (!batch) break;
122
+ const result = await batch.handler({ ids: chunk }, env);
123
+ requests += 1;
124
+ const rows = result?.data?.rows ?? result?.data?.userList ?? [];
125
+ for (const row of rows) {
126
+ const id = String(row?.id ?? "").trim();
127
+ if (!id) continue;
128
+ const record = {
129
+ id,
130
+ name: String(row?.name ?? "").trim(),
131
+ ...row?.department ? { department: String(row.department) } : {},
132
+ ...row?.departmentId ? { departmentId: String(row.departmentId) } : {},
133
+ ...row?.subCompany ? { subCompany: String(row.subCompany) } : {},
134
+ ...row?.position ? { position: String(row.position) } : {},
135
+ ...row?.mobile ? { mobile: String(row.mobile) } : {},
136
+ ...row?.jobNum ? { jobNum: String(row.jobNum) } : {},
137
+ ...row?.imCid ? { imCid: String(row.imCid) } : {},
138
+ savedAt: Date.now()
139
+ };
140
+ persons.set(id, record);
141
+ all[id] = record;
142
+ }
143
+ } catch {
144
+ }
145
+ }
146
+ if (requests > 0) await writeAll(env, all);
147
+ return { persons, requests, fromCache };
148
+ }
149
+ async function resolveNamesCached(env, ids) {
150
+ const { persons } = await resolvePersonsCached(env, ids);
151
+ const map = /* @__PURE__ */ new Map();
152
+ for (const [id, person] of persons) {
153
+ if (person.name) map.set(id, person.name);
154
+ }
155
+ return map;
156
+ }
157
+
158
+ // src/shortcuts/meeting/operations/eb/create-flow.ts
159
+ var FIELD_ALIASES = {
160
+ mt_name: ["\u4F1A\u8BAE\u540D\u79F0", "\u4F1A\u8BAE\u4E3B\u9898", "\u4E3B\u9898"],
161
+ begin_datetime: ["\u5F00\u59CB\u65F6\u95F4", "\u4F1A\u8BAE\u5F00\u59CB\u65F6\u95F4"],
162
+ end_datetime: ["\u7ED3\u675F\u65F6\u95F4", "\u4F1A\u8BAE\u7ED3\u675F\u65F6\u95F4"],
163
+ mt_desc: ["\u4F1A\u8BAE\u5185\u5BB9", "\u4F1A\u8BAE\u8BF4\u660E", "\u4F1A\u8BAE\u63CF\u8FF0"],
164
+ address: ["\u4F1A\u8BAE\u5730\u70B9", "\u4F1A\u8BAE\u5BA4"],
165
+ customize_address: ["\u81EA\u5B9A\u4E49\u4F1A\u8BAE\u5730\u70B9", "\u81EA\u5B9A\u4E49\u5730\u70B9"],
166
+ hrm_members: ["\u53C2\u4F1A\u4EBA\u5458", "\u53C2\u4F1A\u4EBA"],
167
+ total_member: ["\u53C2\u4F1A\u4EBA\u6570", "\u4EBA\u6570"],
168
+ /** 参会客户(CustomerComponent 客户浏览按钮):值是客户 id 列表,不是客户名称文本。 */
169
+ crm_members: ["\u53C2\u4F1A\u5BA2\u6237", "\u5BA2\u6237"],
170
+ crm_member_count: ["\u5E94\u5230\u5BA2\u6237\u6570", "\u5BA2\u6237\u6570"],
171
+ caller: ["\u53EC\u96C6\u4EBA", "\u53D1\u8D77\u4EBA"],
172
+ contacter: ["\u8054\u7CFB\u4EBA"],
173
+ mt_type: ["\u4F1A\u8BAE\u7C7B\u578B"],
174
+ other_remark: ["\u5907\u6CE8", "\u5176\u4ED6\u8BF4\u660E"]
175
+ };
176
+ var PERSON_FIELD_LABELS = { caller: "\u53EC\u96C6\u4EBA", contacter: "\u8054\u7CFB\u4EBA" };
177
+ function workflowEnv(env) {
178
+ return env;
179
+ }
180
+ async function loadCreateForm(env, workflowId) {
181
+ const { createWorkflowHost } = await import("./host-SUOY6VYQ.js");
182
+ const { createWorkflowContinuationSigner } = await import("./continuation-HFW2YT5S.js");
183
+ const { getWorkflowOperation } = await import("./registry-JDUS4E7D.js");
184
+ const wfEnv = {
185
+ ...workflowEnv(env),
186
+ host: createWorkflowHost(env.ctx),
187
+ continuation: createWorkflowContinuationSigner(env.ctx)
188
+ };
189
+ const operation = getWorkflowOperation("workflow.createForm");
190
+ const result = await operation.handler({ workflow: [workflowId] }, wfEnv);
191
+ const data = result?.data ?? {};
192
+ if (data.status !== "FORM_READY") {
193
+ throw meetingValidationError(
194
+ "flow_form_unavailable",
195
+ `\u5EFA\u4F1A\u6D41\u7A0B\u8868\u5355\u8F7D\u5165\u5931\u8D25\uFF08status=${String(data.status)}\uFF09\uFF1A${String(data.clarificationQuestion ?? data.note ?? "").slice(0, 200)}`,
196
+ { workflowId }
197
+ );
198
+ }
199
+ const wf = data.workflow ?? {};
200
+ return {
201
+ fields: data.fields ?? [],
202
+ continuation: data.continuation,
203
+ requestName: data.requestName,
204
+ contextId: data.contextId,
205
+ workflowName: String(wf.name ?? wf.workflowName ?? "").trim() || void 0
206
+ };
207
+ }
208
+ async function resolveEmployeeNames(env, ids) {
209
+ const unique = [...new Set(ids.map((id) => String(id).trim()).filter((id) => id !== ""))];
210
+ if (unique.length === 0) return /* @__PURE__ */ new Map();
211
+ return resolveNamesCached(env, unique);
212
+ }
213
+ async function resolvePersonTokens(env, tokens) {
214
+ const map = /* @__PURE__ */ new Map();
215
+ const unique = [...new Set(tokens.map((token) => String(token).trim()).filter((token) => token !== ""))];
216
+ if (unique.length === 0) return map;
217
+ const idLike = unique.filter((token) => /^\d{8,}$/.test(token));
218
+ const nameLike = unique.filter((token) => !/^\d{8,}$/.test(token));
219
+ if (idLike.length > 0) {
220
+ const names = await resolveEmployeeNames(env, idLike);
221
+ for (const id of idLike) map.set(id, { id, name: names.get(id) ?? id });
222
+ }
223
+ if (nameLike.length > 0) {
224
+ try {
225
+ const { hrmEmployeeOperations } = await import("./employee-22BGJ3QS.js");
226
+ const query = hrmEmployeeOperations.find((operation) => operation.name === "hrm.employee.query");
227
+ for (const name of nameLike) {
228
+ if (!query) break;
229
+ const found = await query.handler({ keyword: name, pageSize: 10 }, env).catch(() => null);
230
+ const rows = found?.data?.rows ?? [];
231
+ const exact = rows.find((row) => String(row.name ?? "").trim() === name);
232
+ const hit = exact ?? (rows.length === 1 ? rows[0] : void 0);
233
+ const id = String(hit?.id ?? "").trim();
234
+ if (id === "") continue;
235
+ map.set(name, { id, name: String(hit?.name ?? name) });
236
+ }
237
+ } catch {
238
+ }
239
+ }
240
+ return map;
241
+ }
242
+ async function resolveSelfPerson(env) {
243
+ let session = null;
244
+ try {
245
+ session = await env.host?.getSession?.();
246
+ } catch {
247
+ return null;
248
+ }
249
+ const id = String(session?.userId ?? "").trim();
250
+ if (id === "" || id === "unknown") return null;
251
+ const names = await resolveEmployeeNames(env, [id]);
252
+ const name = String(names.get(id) ?? "").trim();
253
+ if (name === "") return null;
254
+ return { id, name };
255
+ }
256
+ function applySelfPersonDefaults(args, self) {
257
+ const filled = [];
258
+ const missing = ["caller", "contacter"].filter((field) => String(args[field] ?? "").trim() === "");
259
+ if (missing.length === 0) return { filled, warning: "" };
260
+ if (!self) {
261
+ return {
262
+ filled,
263
+ warning: missing.length === 2 ? "\u26A0\uFE0F \u6CA1\u80FD\u786E\u8BA4\u5F53\u524D\u767B\u5F55\u7528\u6237\u5BF9\u5E94\u7684\u5458\u5DE5 \u2014\u2014\u300C\u53EC\u96C6\u4EBA\u300D\u300C\u8054\u7CFB\u4EBA\u300D\u4F1A\u7559\u7A7A\uFF0C\u8BF7\u663E\u5F0F\u4F20 caller / contacter\uFF08\u5458\u5DE5 id \u6216\u59D3\u540D\uFF09\u3002" : ""
264
+ };
265
+ }
266
+ for (const field of missing) {
267
+ args[field] = self.id;
268
+ filled.push({ field, id: self.id, name: self.name });
269
+ }
270
+ return { filled, warning: "" };
271
+ }
272
+ function parseRoomRef(input) {
273
+ const text = String(input ?? "").trim();
274
+ if (!text) return {};
275
+ const withId = /^(.*?)[((]\s*(\d{4,})\s*[))]$/.exec(text);
276
+ if (withId) {
277
+ const name = withId[1].trim();
278
+ const id = withId[2];
279
+ return name ? { id, name } : { id };
280
+ }
281
+ if (/^\d+$/.test(text)) return { id: text };
282
+ return { name: text };
283
+ }
284
+ async function resolveAddressRoom(env, input) {
285
+ const text = String(input ?? "").trim();
286
+ if (!text) return null;
287
+ const ref = parseRoomRef(text);
288
+ const { loadRooms: loadRooms2 } = await import("./room-recommend-H7KLXA5R.js");
289
+ let rooms = [];
290
+ try {
291
+ rooms = (await loadRooms2(env, {})).rooms;
292
+ } catch {
293
+ return { id: ref.id ?? "", name: ref.name ?? text, status: "unknown", lookupFailed: true };
294
+ }
295
+ const hit = (ref.id ? rooms.find((room) => room.id === ref.id) : void 0) ?? (ref.name ? rooms.find((room) => room.name === ref.name) : void 0);
296
+ if (hit) return { id: hit.id, name: hit.name, status: hit.status, statusText: hit.statusText };
297
+ if (ref.id) return { id: ref.id, name: ref.name ?? "", status: "unknown" };
298
+ return null;
299
+ }
300
+ async function resolveRoomValue(env, input) {
301
+ const text = String(input ?? "").trim();
302
+ if (!text) return null;
303
+ const resolved = await resolveAddressRoom(env, text).catch(() => null);
304
+ if (resolved?.id && !resolved.lookupFailed) {
305
+ return { id: resolved.id, name: resolved.name || resolved.id };
306
+ }
307
+ const ref = parseRoomRef(text);
308
+ if (ref.id) {
309
+ try {
310
+ const { getMeetingOperation } = await import("./registry-IM5G23LS.js");
311
+ const detail = await getMeetingOperation("meeting.eb.room.detail").handler({ id: ref.id }, env);
312
+ const main = detail?.data?.mainTable ?? detail?.data?.data?.mainTable ?? {};
313
+ const name = String(main.room_name ?? "").trim() || ref.name || "";
314
+ if (name) return { id: ref.id, name };
315
+ } catch {
316
+ }
317
+ return { id: ref.id, name: ref.name || ref.id };
318
+ }
319
+ return null;
320
+ }
321
+ async function shapeBrowserValues(env, values) {
322
+ const notes = [];
323
+ const shaped = { ...values };
324
+ const readable = {};
325
+ if (shaped.address !== void 0 && shaped.address !== "") {
326
+ const room = await resolveRoomValue(env, String(shaped.address));
327
+ if (room) {
328
+ shaped.address = room;
329
+ readable.address = room.name;
330
+ notes.push(`\u4F1A\u8BAE\u5730\u70B9\u6309\u6D4F\u89C8\u6309\u94AE\u683C\u5F0F\u63D0\u4EA4\uFF1A${room.name}(${room.id})`);
331
+ } else {
332
+ readable.address = String(shaped.address);
333
+ }
334
+ }
335
+ if (shaped.begin_datetime !== void 0 && String(shaped.begin_datetime).trim() !== "") {
336
+ readable.begin_datetime = String(shaped.begin_datetime).trim();
337
+ }
338
+ if (shaped.end_datetime !== void 0 && String(shaped.end_datetime).trim() !== "") {
339
+ readable.end_datetime = String(shaped.end_datetime).trim();
340
+ }
341
+ const personFields = ["hrm_members", "caller", "contacter"];
342
+ const idPool = [];
343
+ for (const key of personFields) {
344
+ const raw = shaped[key];
345
+ if (raw === void 0 || raw === "") continue;
346
+ const ids = String(raw).split(/[,;,;\s]+/).map((item) => item.trim()).filter((item) => item !== "");
347
+ idPool.push(...ids);
348
+ }
349
+ if (idPool.length > 0) {
350
+ const people = await resolvePersonTokens(env, idPool);
351
+ const toObject = (token) => people.get(token) ?? { id: token, name: token };
352
+ const toName = (token) => people.get(token)?.name ?? token;
353
+ if (shaped.hrm_members !== void 0 && shaped.hrm_members !== "") {
354
+ const ids = String(shaped.hrm_members).split(/[,;,;\s]+/).map((item) => item.trim()).filter((item) => item !== "");
355
+ shaped.hrm_members = ids.map(toObject);
356
+ readable.hrm_members = ids.map(toName).join("\u3001");
357
+ notes.push(`\u53C2\u4F1A\u4EBA\u5458\u6309\u6D4F\u89C8\u6309\u94AE\u683C\u5F0F\u63D0\u4EA4\uFF1A${ids.length} \u4EBA`);
358
+ }
359
+ if (shaped.caller !== void 0 && shaped.caller !== "") {
360
+ const id = String(shaped.caller).trim();
361
+ shaped.caller = toObject(id);
362
+ readable.caller = toName(id);
363
+ }
364
+ if (shaped.contacter !== void 0 && shaped.contacter !== "") {
365
+ const id = String(shaped.contacter).trim();
366
+ shaped.contacter = toObject(id);
367
+ readable.contacter = toName(id);
368
+ }
369
+ const unresolved = [...new Set(idPool)].filter((token) => !people.has(token));
370
+ if (unresolved.length > 0) {
371
+ notes.push(
372
+ `\u26A0\uFE0F \u6709 ${unresolved.length} \u4E2A\u4EBA\u5458\u6CA1\u89E3\u6790\u5230\u5458\u5DE5\uFF1A${unresolved.join("\u3001")} \u2014\u2014 \u8868\u5355\u91CC\u7684\u300C\u53C2\u4F1A\u4EBA\u5458/\u53EC\u96C6\u4EBA/\u8054\u7CFB\u4EBA\u300D\u53EF\u80FD\u663E\u793A\u4E0D\u51FA\u6765\u3002\u8BF7\u6539\u4F20\u5458\u5DE5 id\uFF0C\u6216\u786E\u8BA4\u59D3\u540D\u4E0E\u82B1\u540D\u518C\u5B8C\u5168\u4E00\u81F4\u3002`
373
+ );
374
+ }
375
+ }
376
+ if (shaped.crm_members !== void 0 && shaped.crm_members !== "") {
377
+ const rows = [];
378
+ const push = (idRaw, nameRaw) => {
379
+ const id = String(idRaw ?? "").trim();
380
+ const name = String(nameRaw ?? "").trim();
381
+ if (id === "" && name === "") return;
382
+ rows.push({ id, name });
383
+ };
384
+ const pushToken = (tokenRaw) => {
385
+ const token = String(tokenRaw ?? "").trim();
386
+ if (token === "") return;
387
+ const matched = token.match(/^(.*?)[((]\s*([0-9A-Za-z_-]+)\s*[))]$/);
388
+ if (matched) {
389
+ push(matched[2], matched[1]);
390
+ return;
391
+ }
392
+ if (/^\d{8,}$/.test(token)) {
393
+ push(token, "");
394
+ return;
395
+ }
396
+ push("", token);
397
+ };
398
+ const raw = shaped.crm_members;
399
+ if (Array.isArray(raw)) {
400
+ for (const item of raw) {
401
+ if (item && typeof item === "object") {
402
+ const obj = item;
403
+ push(obj.id ?? obj.sjID ?? obj.customerId, obj.name ?? obj.mc);
404
+ } else {
405
+ for (const token of String(item).split(/[,;,;]+/).map((one) => one.trim()).filter((one) => one !== "")) {
406
+ pushToken(token);
407
+ }
408
+ }
409
+ }
410
+ } else if (typeof raw === "object") {
411
+ const obj = raw;
412
+ push(obj.id ?? obj.sjID ?? obj.customerId, obj.name ?? obj.mc);
413
+ } else {
414
+ for (const token of String(raw).split(/[,;,;]+/).map((item) => item.trim()).filter((item) => item !== "")) {
415
+ pushToken(token);
416
+ }
417
+ }
418
+ if (rows.length > 0) {
419
+ const nameOnly = rows.filter((row) => row.id === "" && row.name !== "");
420
+ if (nameOnly.length > 0) {
421
+ try {
422
+ const { getMeetingOperation } = await import("./registry-IM5G23LS.js");
423
+ const search = getMeetingOperation("meeting.eb.crm.search");
424
+ for (const row of nameOnly) {
425
+ const found = await search.handler({ keyword: row.name, limit: 5 }, env).catch(() => null);
426
+ const items = found?.data?.items ?? [];
427
+ const hit = items.find((item) => String(item?.name ?? "").trim() === row.name) ?? items[0];
428
+ const id = String(hit?.customerId ?? "").trim();
429
+ if (id === "") continue;
430
+ row.id = id;
431
+ const fullName = String(hit?.name ?? "").trim();
432
+ if (fullName !== "") row.name = fullName;
433
+ }
434
+ } catch {
435
+ }
436
+ }
437
+ const unresolved = rows.filter((row) => row.id === "");
438
+ if (unresolved.length > 0) {
439
+ throw meetingValidationError(
440
+ "crm_not_found",
441
+ `\u53C2\u4F1A\u5BA2\u6237\u6709 ${unresolved.length} \u4E2A\u5728 CRM \u91CC\u67E5\u4E0D\u5230\uFF1A${unresolved.map((row) => row.name).join("\u3001")}\u3002\u8BF7\u786E\u8BA4\u5BA2\u6237\u540D\u79F0\uFF0C\u6216\u5148\u5230\u5BA2\u6237\u8868\u5EFA\u6863\uFF1B\u4E5F\u53EF\u4EE5\u6539\u7528\u300C\u5BA2\u6237\u540D(\u5BA2\u6237id)\u300D\u6216 \`[{id,name}]\` \u4F20 crm_members\u3002`
442
+ );
443
+ }
444
+ shaped.crm_members = rows;
445
+ readable.crm_members = rows.map((row) => row.name || row.id).join("\u3001");
446
+ notes.push(`\u53C2\u4F1A\u5BA2\u6237\u6309\u5BA2\u6237\u6D4F\u89C8\u6309\u94AE\u683C\u5F0F\u63D0\u4EA4\uFF1A${rows.length} \u4E2A\u5BA2\u6237`);
447
+ const missingNames = rows.filter((row) => row.name === "");
448
+ if (missingNames.length > 0) {
449
+ throw meetingValidationError(
450
+ "crm_name_required",
451
+ `\u53C2\u4F1A\u5BA2\u6237\u6709 ${missingNames.length} \u4E2A\u53EA\u7ED9\u4E86 id\u3001\u6CA1\u6709\u5BA2\u6237\u540D\u79F0\uFF1A${missingNames.map((row) => row.id).join("\u3001")}\u3002\u5BA2\u6237\u6D4F\u89C8\u6309\u94AE\u5FC5\u987B\u5E26\u540D\u79F0\u624D\u80FD\u5199\u5165\uFF08\u53EA\u7ED9 id \u4F1A\u88AB\u670D\u52A1\u7AEF\u9759\u9ED8\u5B58\u6210\u7A7A\u503C\uFF09\u3002\u8BF7\u5148\u7528 \`meeting.eb.crm.search\` \u6309\u5BA2\u6237\u540D\u67E5\u5230 \`{ customerId, name }\`\uFF0C\u518D\u4EE5 \`[{id,name}]\` \u6216\u300C\u5BA2\u6237\u540D(\u5BA2\u6237id)\u300D\u7684\u5F62\u5F0F\u4F20 \`crm_members\`\u3002`
452
+ );
453
+ }
454
+ } else {
455
+ delete shaped.crm_members;
456
+ }
457
+ }
458
+ for (const [key, raw] of Object.entries(values)) {
459
+ if (readable[key] !== void 0) continue;
460
+ if (raw === void 0 || raw === null || raw === "") continue;
461
+ if (typeof raw === "object") continue;
462
+ readable[key] = String(raw);
463
+ }
464
+ return { values: shaped, notes, readable };
465
+ }
466
+ function normalizeFieldName(name) {
467
+ return String(name ?? "").replace(/[((][^(())]*[))]/g, "").replace(/[\s\u3000]+/g, "").trim();
468
+ }
469
+ var CRM_DETAIL_COLUMNS = {
470
+ xm: ["\u59D3\u540D", "\u5BA2\u6237\u59D3\u540D", "\u53C2\u4F1A\u4EBA", "\u53C2\u4F1A\u4EBA\u59D3\u540D"],
471
+ xb: ["\u6027\u522B"],
472
+ zw: ["\u804C\u4F4D", "\u804C\u52A1"],
473
+ sjhm: ["\u624B\u673A\u53F7\u7801", "\u624B\u673A\u53F7", "\u624B\u673A", "\u7535\u8BDD", "\u8054\u7CFB\u7535\u8BDD"],
474
+ bz: ["\u5907\u6CE8", "\u8BF4\u660E"]
475
+ };
476
+ function resolveCrmDetailTarget(fields) {
477
+ const groups = /* @__PURE__ */ new Map();
478
+ for (const field of fields) {
479
+ const sid = String(field.subFormId ?? "").trim();
480
+ if (!sid) continue;
481
+ const list = groups.get(sid);
482
+ if (list) list.push(field);
483
+ else groups.set(sid, [field]);
484
+ }
485
+ let best = null;
486
+ for (const [subFormId, list] of groups) {
487
+ const columns = {};
488
+ const labels = {};
489
+ for (const [semantic, aliases] of Object.entries(CRM_DETAIL_COLUMNS)) {
490
+ const hit = list.find((field) => aliases.includes(normalizeFieldName(field.name)));
491
+ if (!hit) continue;
492
+ columns[semantic] = hit.id;
493
+ labels[semantic] = hit.name;
494
+ }
495
+ if (!columns.xm) continue;
496
+ const score = Object.keys(columns).length + (columns.sjhm ? 1 : 0) + (columns.zw ? 1 : 0);
497
+ if (!best || score > best.score) best = { subFormId, columns, labels, score };
498
+ }
499
+ return best ? { subFormId: best.subFormId, columns: best.columns, labels: best.labels } : null;
500
+ }
501
+ function detectCrmMentionInText(...texts) {
502
+ for (const text of texts) {
503
+ if (typeof text !== "string") continue;
504
+ const value = text.trim();
505
+ if (value === "") continue;
506
+ const hit = /(?:参会|拜访|来访)?客户\s*(?:名称)?\s*(?:是|为|[::])\s*([^\s,,。;;、))]{2,40})/.exec(value);
507
+ if (hit?.[1]) return hit[1].trim();
508
+ }
509
+ return null;
510
+ }
511
+ function normalizeCrmDetailRows(raw) {
512
+ if (raw === void 0 || raw === null || raw === "") return [];
513
+ const list = Array.isArray(raw) ? raw : [raw];
514
+ const keyAlias = {
515
+ xm: "xm",
516
+ name: "xm",
517
+ customername: "xm",
518
+ \u59D3\u540D: "xm",
519
+ \u5BA2\u6237\u59D3\u540D: "xm",
520
+ xb: "xb",
521
+ gender: "xb",
522
+ sex: "xb",
523
+ \u6027\u522B: "xb",
524
+ zw: "zw",
525
+ title: "zw",
526
+ position: "zw",
527
+ job: "zw",
528
+ \u804C\u4F4D: "zw",
529
+ \u804C\u52A1: "zw",
530
+ sjhm: "sjhm",
531
+ mobile: "sjhm",
532
+ phone: "sjhm",
533
+ tel: "sjhm",
534
+ \u624B\u673A\u53F7\u7801: "sjhm",
535
+ \u624B\u673A\u53F7: "sjhm",
536
+ \u7535\u8BDD: "sjhm",
537
+ \u8054\u7CFB\u7535\u8BDD: "sjhm",
538
+ bz: "bz",
539
+ remark: "bz",
540
+ note: "bz",
541
+ \u5907\u6CE8: "bz",
542
+ \u8BF4\u660E: "bz"
543
+ };
544
+ const rows = [];
545
+ for (const item of list) {
546
+ if (item === void 0 || item === null || typeof item !== "object") continue;
547
+ const row = {};
548
+ for (const [key, value] of Object.entries(item)) {
549
+ const semantic = keyAlias[String(key).trim().toLowerCase()] ?? keyAlias[String(key).trim()];
550
+ if (!semantic) continue;
551
+ if (value === void 0 || value === null) continue;
552
+ const text = String(value).trim();
553
+ if (text === "") continue;
554
+ row[semantic] = text;
555
+ }
556
+ if (!row.xm && !row.sjhm) continue;
557
+ rows.push(row);
558
+ }
559
+ return rows;
560
+ }
561
+ function crmMemberEntriesFromArgs(raw) {
562
+ const list = Array.isArray(raw) ? raw : raw === void 0 || raw === null || raw === "" ? [] : [raw];
563
+ const out = [];
564
+ const push = (idRaw, nameRaw, contactsRaw) => {
565
+ const id = String(idRaw ?? "").trim();
566
+ const name = String(nameRaw ?? "").trim();
567
+ if (id === "" && name === "") return;
568
+ const contacts = (Array.isArray(contactsRaw) ? contactsRaw : []).map((item) => {
569
+ const row = item ?? {};
570
+ return {
571
+ name: String(row.name ?? row.xm ?? "").trim(),
572
+ mobile: String(row.mobile ?? row.sjhm ?? row.phone ?? "").trim(),
573
+ ...String(row.dept ?? row.bm ?? "").trim() === "" ? {} : { dept: String(row.dept ?? row.bm).trim() }
574
+ };
575
+ }).filter((one) => one.name !== "" || one.mobile !== "");
576
+ out.push({ id: id === "" ? name : id, name, contacts });
577
+ };
578
+ for (const item of list) {
579
+ if (item && typeof item === "object") {
580
+ const obj = item;
581
+ push(obj.customerId ?? obj.sjID ?? obj.id, obj.name ?? obj.mc, obj.contacts ?? obj.lxr);
582
+ } else {
583
+ const token = String(item).trim();
584
+ if (token === "") continue;
585
+ const matched = token.match(/^(.*?)[((]\s*([0-9A-Za-z_-]+)\s*[))]$/);
586
+ if (matched) push(matched[2], matched[1], void 0);
587
+ else push(token, "", void 0);
588
+ }
589
+ }
590
+ return out;
591
+ }
592
+ function crmContactsToDetailRows(entries) {
593
+ const rows = [];
594
+ const seen = /* @__PURE__ */ new Set();
595
+ for (const entry of entries) {
596
+ for (const contact of entry.contacts) {
597
+ const xm = contact.name.trim();
598
+ const sjhm = contact.mobile.trim();
599
+ if (xm === "" && sjhm === "") continue;
600
+ const key = `${xm}|${sjhm}`;
601
+ if (seen.has(key)) continue;
602
+ seen.add(key);
603
+ const row = { xm: xm === "" ? sjhm : xm };
604
+ if (sjhm !== "") row.sjhm = sjhm;
605
+ if (contact.dept && contact.dept.trim() !== "") row.bz = `\u90E8\u95E8\uFF1A${contact.dept.trim()}`;
606
+ rows.push(row);
607
+ }
608
+ }
609
+ return rows;
610
+ }
611
+ async function resolveAutoCrmDetailRows(env, raw) {
612
+ const entries = crmMemberEntriesFromArgs(raw);
613
+ const missing = [];
614
+ if (entries.length > 0) {
615
+ try {
616
+ const { getMeetingOperation } = await import("./registry-IM5G23LS.js");
617
+ const search = getMeetingOperation("meeting.eb.crm.search");
618
+ for (const entry of entries) {
619
+ if (entry.contacts.length > 0) continue;
620
+ const keyword = (entry.name || entry.id).trim();
621
+ if (keyword === "") {
622
+ missing.push(entry.id);
623
+ continue;
624
+ }
625
+ const shortBase = keyword.split("--")[0].trim();
626
+ const stripped = shortBase.replace(/[((][^))]*[))]/gu, "").replace(/(股份有限公司|有限责任公司|集团有限公司|有限公司|集团|公司)$/u, "").trim();
627
+ const candidates = [...new Set([keyword, shortBase, stripped, shortBase.slice(0, 4)].filter((one) => one !== ""))];
628
+ let live = [];
629
+ for (const candidate of candidates) {
630
+ const found = await search.handler({ keyword: candidate, limit: 50 }, env).catch(() => null);
631
+ const items = found?.data?.items ?? [];
632
+ const hit = entry.id !== "" ? items.find((item) => String(item?.customerId ?? "") === entry.id) : void 0;
633
+ const contacts = hit?.contacts ?? [];
634
+ if (contacts.length > live.length) live = contacts;
635
+ }
636
+ if (live.length === 0) {
637
+ missing.push(entry.name || entry.id);
638
+ continue;
639
+ }
640
+ entry.contacts = live;
641
+ }
642
+ } catch {
643
+ }
644
+ }
645
+ return {
646
+ rows: crmContactsToDetailRows(entries),
647
+ customers: entries.map((entry) => entry.name || entry.id).filter((one) => one !== ""),
648
+ missing
649
+ };
650
+ }
651
+ function mapFields(fields, values, preferred = {}) {
652
+ const byName = new Map(fields.map((field) => [field.name.trim(), field]));
653
+ const byId = new Map(fields.map((field) => [field.id, field]));
654
+ const byNormalized = /* @__PURE__ */ new Map();
655
+ for (const field of fields) {
656
+ const key = normalizeFieldName(field.name);
657
+ if (key && !byNormalized.has(key)) byNormalized.set(key, field);
658
+ }
659
+ const main = {};
660
+ const mapped = {};
661
+ const unmapped = [];
662
+ const resolved = {};
663
+ const findField = (aliases) => {
664
+ for (const name of aliases) {
665
+ const field = byName.get(name);
666
+ if (field) return field;
667
+ }
668
+ for (const name of aliases) {
669
+ const field = byNormalized.get(normalizeFieldName(name));
670
+ if (field) return field;
671
+ }
672
+ for (const name of aliases) {
673
+ const needle = normalizeFieldName(name);
674
+ if (needle.length < 2) continue;
675
+ for (const [key, field] of byNormalized) {
676
+ if (key.includes(needle)) return field;
677
+ }
678
+ }
679
+ return void 0;
680
+ };
681
+ for (const [key, raw] of Object.entries(values)) {
682
+ if (raw === void 0 || raw === null || raw === "") continue;
683
+ const aliases = FIELD_ALIASES[key] ?? [key];
684
+ const prefId = preferred[key];
685
+ const hit = (prefId ? byId.get(prefId) : void 0) ?? findField(aliases);
686
+ if (!hit) {
687
+ unmapped.push(key);
688
+ continue;
689
+ }
690
+ main[hit.id] = raw;
691
+ mapped[key] = `${hit.name}(${hit.id})`;
692
+ resolved[key] = hit.id;
693
+ }
694
+ return { main, mapped, unmapped, resolved };
695
+ }
696
+ var PREVIEW_PERSON_FIELD_RE = /^(召集人|联系人|参会人员|会议创建人|主讲人|负责人|费用承担人)$/;
697
+ async function decoratePreviewPersonNames(env, main, fields, known = /* @__PURE__ */ new Map()) {
698
+ const targets = fields.filter((field) => PREVIEW_PERSON_FIELD_RE.test(String(field?.name ?? "").trim()));
699
+ if (targets.length === 0) return main;
700
+ const ID_ONLY_RE = /^\d{8,}$/;
701
+ const missingNameId = (value) => {
702
+ if (typeof value === "string") return ID_ONLY_RE.test(value.trim()) ? value.trim() : null;
703
+ if (value && typeof value === "object" && !Array.isArray(value)) {
704
+ const obj = value;
705
+ const id = String(obj.id ?? "").trim();
706
+ const name = String(obj.name ?? "").trim();
707
+ if (id !== "" && (name === "" || name === id)) return id;
708
+ }
709
+ return null;
710
+ };
711
+ const ids = /* @__PURE__ */ new Set();
712
+ for (const field of targets) {
713
+ const value = main[field.id];
714
+ const one = missingNameId(value);
715
+ if (one) ids.add(one);
716
+ else if (Array.isArray(value)) for (const item of value) {
717
+ const hit = missingNameId(item);
718
+ if (hit) ids.add(hit);
719
+ }
720
+ }
721
+ if (ids.size === 0) return main;
722
+ let names = new Map(known);
723
+ const unknown = [...ids].filter((id) => !names.has(id));
724
+ if (unknown.length > 0) {
725
+ try {
726
+ const resolved = await resolveEmployeeNames(env, unknown);
727
+ for (const [id, name] of resolved) names.set(id, name);
728
+ } catch {
729
+ }
730
+ }
731
+ if (names.size === 0) return main;
732
+ const rename = (value) => {
733
+ const one = missingNameId(value);
734
+ if (one) return names.get(one) ?? value;
735
+ if (value && typeof value === "object" && !Array.isArray(value)) {
736
+ const obj = value;
737
+ const id = String(obj.id ?? "").trim();
738
+ const name = names.get(id);
739
+ if (name) return { ...obj, name };
740
+ }
741
+ return value;
742
+ };
743
+ const decorated = { ...main };
744
+ for (const field of targets) {
745
+ const value = decorated[field.id];
746
+ decorated[field.id] = Array.isArray(value) ? value.map(rename) : rename(value);
747
+ }
748
+ return decorated;
749
+ }
750
+ function renderFormPreview(fields, main) {
751
+ const fmt = (value) => {
752
+ if (value === void 0 || value === null) return "\u2014";
753
+ if (Array.isArray(value)) {
754
+ const parts = value.map((one) => fmt(one)).filter((one) => one !== "\u2014");
755
+ return parts.length > 0 ? parts.join("\u3001") : "\u2014";
756
+ }
757
+ if (typeof value === "object") {
758
+ const obj = value;
759
+ const name = String(obj.name ?? obj.mc ?? "").trim();
760
+ if (name !== "") return name.replace(/\|/gu, "/");
761
+ const id = String(obj.id ?? obj.customerId ?? obj.sjID ?? "").trim();
762
+ return id === "" ? "\u2014" : id;
763
+ }
764
+ const text = String(value).trim();
765
+ return text === "" ? "\u2014" : text.replace(/\|/gu, "/").replace(/\r?\n/gu, " ");
766
+ };
767
+ const lines = ["| \u5B57\u6BB5 | \u503C |", "| --- | --- |"];
768
+ const known = /* @__PURE__ */ new Set();
769
+ for (const field of fields) {
770
+ known.add(field.id);
771
+ if (!(field.id in main)) continue;
772
+ lines.push(`| ${String(field.name).replace(/\|/gu, "/")} | ${fmt(main[field.id])} |`);
773
+ }
774
+ for (const [id, value] of Object.entries(main)) {
775
+ if (known.has(id)) continue;
776
+ lines.push(`| ${id} | ${fmt(value)} |`);
777
+ }
778
+ return lines.join("\n");
779
+ }
780
+ function flowFieldCacheDir(env) {
781
+ const configured = env?.ctx?.config?.path?.();
782
+ const root = configured ? resolve(String(configured), "..") : process.env.WEAVER_WORK_CLI_HOME || process.env.WORK_CLI_HOME || resolve(homedir(), ".weaver-work-cli");
783
+ return resolve(root, "meeting", "cache");
784
+ }
785
+ function flowFieldCacheFile(env, workflowId) {
786
+ return resolve(flowFieldCacheDir(env), `flow-fields-${workflowId}.json`);
787
+ }
788
+ async function readFlowFieldMap(env, workflowId) {
789
+ try {
790
+ const file = flowFieldCacheFile(env, workflowId);
791
+ if (!existsSync(file)) return {};
792
+ const parsed = JSON.parse(await readFile(file, "utf8"));
793
+ return parsed && typeof parsed.mapping === "object" && parsed.mapping ? parsed.mapping : {};
794
+ } catch {
795
+ return {};
796
+ }
797
+ }
798
+ async function writeFlowFieldMap(env, workflowId, workflowName, mapping) {
799
+ if (Object.keys(mapping).length === 0) return;
800
+ try {
801
+ const file = flowFieldCacheFile(env, workflowId);
802
+ await mkdir(resolve(file, ".."), { recursive: true });
803
+ const cache = {
804
+ workflowId,
805
+ ...workflowName ? { workflowName } : {},
806
+ savedAt: (/* @__PURE__ */ new Date()).toISOString(),
807
+ mapping
808
+ };
809
+ await writeFile(file, JSON.stringify(cache, null, 2), "utf8");
810
+ } catch {
811
+ }
812
+ }
813
+ function normalizeWorkflowIds(raw) {
814
+ if (raw === void 0 || raw === null) return [];
815
+ const list = Array.isArray(raw) ? raw : [raw];
816
+ const ids = [];
817
+ for (const item of list) {
818
+ for (const piece of String(item ?? "").split(/[,;,;\s]+/)) {
819
+ const term = piece.trim();
820
+ if (!term) continue;
821
+ const matched = term.match(/[((](\d{6,})[))]$/);
822
+ const id = matched ? matched[1] : term;
823
+ if (!ids.includes(id)) ids.push(id);
824
+ }
825
+ }
826
+ return ids;
827
+ }
828
+ var FIXED_FLOW_IDS = ["1326190634427154474", "1325677244111462606"];
829
+ var FIXED_FLOW_PROFILES = [
830
+ {
831
+ host: "www.e-cology.com.cn",
832
+ tenantKey: "t7akvdnf84",
833
+ label: "\u6CDB\u5FAE\u751F\u4EA7\uFF08\u6CDB\u5FAE\u7F51\u7EDC\uFF09",
834
+ ids: [...FIXED_FLOW_IDS]
835
+ }
836
+ ];
837
+ function fixedFlowFlagOn() {
838
+ const flag = String(process.env.WEAVER_MEETING_FIXED_FLOW ?? "1").trim().toLowerCase();
839
+ return !(flag === "0" || flag === "false" || flag === "off");
840
+ }
841
+ function fixedFlowOverride() {
842
+ const override = String(process.env.WEAVER_MEETING_FIXED_FLOW_IDS ?? "").trim();
843
+ if (!override) return [];
844
+ return override.split(/[,;,;\s]+/).map((item) => item.trim()).filter((item) => item !== "");
845
+ }
846
+ function fixedFlowIds() {
847
+ if (!fixedFlowFlagOn()) return [];
848
+ const override = fixedFlowOverride();
849
+ return override.length > 0 ? override : [...FIXED_FLOW_IDS];
850
+ }
851
+ async function fixedFlowIdsForEnv(env) {
852
+ if (!fixedFlowFlagOn()) return { ids: [] };
853
+ const override = fixedFlowOverride();
854
+ if (override.length > 0) return { ids: override, label: "\u73AF\u5883\u53D8\u91CF\u6307\u5B9A" };
855
+ let baseUrl = "";
856
+ let tenantKey = "";
857
+ try {
858
+ const session = await env?.host?.getSession?.();
859
+ baseUrl = String(session?.baseUrl ?? "");
860
+ tenantKey = String(session?.tenantKey ?? session?.tenantId ?? "");
861
+ } catch {
862
+ }
863
+ if (!baseUrl) return { ids: [...FIXED_FLOW_IDS], label: "\u9ED8\u8BA4\u56FA\u5316\u914D\u7F6E\uFF08\u672A\u53D6\u5230\u767B\u5F55\u73AF\u5883\uFF09" };
864
+ const host = baseUrl.replace(/^https?:\/\//i, "").replace(/\/.*$/, "").toLowerCase();
865
+ const hit = FIXED_FLOW_PROFILES.find((profile) => profile.host === host && (!profile.tenantKey || !tenantKey || profile.tenantKey === tenantKey));
866
+ return hit ? { ids: [...hit.ids], label: hit.label } : { ids: [] };
867
+ }
868
+ function shouldAutoPickFlow(args) {
869
+ if (args.flowChoice === "auto") return true;
870
+ return String(process.env.WEAVER_MEETING_FLOW_CHOICE ?? "").trim().toLowerCase() === "auto";
871
+ }
872
+ async function sendInvitationToGroup(env, groupId, filePath, warnings) {
873
+ const started = Date.now();
874
+ try {
875
+ const { buildImEnv } = await import("./group-chat-BFVXAYFX.js");
876
+ const { getImOperation } = await import("./registry-PVUZQDDQ.js");
877
+ const imEnv = await buildImEnv(env);
878
+ const prepared = await getImOperation("im.msg.send.group.prepare").handler(
879
+ { groupId, file: filePath },
880
+ imEnv
881
+ );
882
+ const continuation = String(prepared?.data?.continuation ?? "");
883
+ const applied = continuation ? await getImOperation("im.msg.send.group.apply").handler({ continuation, confirm: true }, imEnv) : null;
884
+ const ok = applied?.ok === true;
885
+ if (!ok) {
886
+ warnings.push(
887
+ `\u9080\u8BF7\u51FD\u6CA1\u80FD\u53D1\u5230\u7FA4\u91CC\uFF08${String(applied?.error?.message ?? prepared?.error?.message ?? "\u672A\u77E5\u539F\u56E0").slice(0, 150)}\uFF09\uFF1B\u6587\u4EF6\u5DF2\u751F\u6210\uFF0C\u53EF\u624B\u52A8\u8F6C\u53D1\u3002`
888
+ );
889
+ }
890
+ return { ok, ms: Date.now() - started };
891
+ } catch (error) {
892
+ warnings.push(`\u9080\u8BF7\u51FD\u53D1\u7FA4\u5F02\u5E38\uFF08\u4E0D\u5F71\u54CD\u5EFA\u4F1A\uFF09\uFF1A${String(error?.message ?? error).slice(0, 150)}`);
893
+ return { ok: false, ms: Date.now() - started };
894
+ }
895
+ }
896
+ async function resolveWorkflowId(env, args) {
897
+ const explicitList = normalizeWorkflowIds(args.workflowId);
898
+ if (explicitList.length > 0) {
899
+ return {
900
+ workflowId: explicitList.length === 1 ? explicitList[0] : "",
901
+ candidates: explicitList,
902
+ source: "argument"
903
+ };
904
+ }
905
+ const fixed = await fixedFlowIdsForEnv(env);
906
+ if (fixed.ids.length > 0) {
907
+ return {
908
+ workflowId: fixed.ids.length === 1 ? fixed.ids[0] : "",
909
+ candidates: fixed.ids,
910
+ source: "fixed",
911
+ ...fixed.label ? { label: fixed.label } : {}
912
+ };
913
+ }
914
+ const settings = await fetchEbAppSettings(env, "meeting.eb.meeting.create.flow.prepare");
915
+ const candidates = String(settings.mtNewWf ?? "").split(/[,;,;\s]+/).map((item) => item.trim()).filter((item) => item !== "");
916
+ if (candidates.length === 0) {
917
+ throw meetingValidationError(
918
+ "flow_not_configured",
919
+ "\u5E94\u7528\u8BBE\u7F6E\u91CC\u6CA1\u6709\u914D\u7F6E\u300C\u65B0\u5EFA\u4F1A\u8BAE\u5DE5\u4F5C\u6D41\u300D\uFF08mt_new_wf \u4E3A\u7A7A\uFF09\uFF0C\u4E5F\u6CA1\u6709\u542F\u7528\u56FA\u5316\u6D41\u7A0B\uFF0C\u65E0\u6CD5\u8D70\u6D41\u7A0B\u5EFA\u4F1A\uFF1B\u8BF7\u7BA1\u7406\u5458\u5728\u4F1A\u8BAE\u5E94\u7528\u8BBE\u7F6E\u91CC\u914D\u7F6E\uFF0C\u6216\u7528 WEAVER_MEETING_FIXED_FLOW_IDS \u6307\u5B9A\u9ED8\u8BA4\u6D41\u7A0B"
920
+ );
921
+ }
922
+ return { workflowId: candidates.length === 1 ? candidates[0] : "", candidates, source: "settings" };
923
+ }
924
+ function pad2(value) {
925
+ return String(value).padStart(2, "0");
926
+ }
927
+ function tomorrowIso() {
928
+ const date = new Date(Date.now() + 24 * 60 * 60 * 1e3);
929
+ return `${date.getFullYear()}-${pad2(date.getMonth() + 1)}-${pad2(date.getDate())}`;
930
+ }
931
+ function formatMinute(date) {
932
+ return `${date.getFullYear()}-${pad2(date.getMonth() + 1)}-${pad2(date.getDate())} ${pad2(date.getHours())}:${pad2(date.getMinutes())}`;
933
+ }
934
+ async function probeWorkflowCandidates(env, ids) {
935
+ const probed = await Promise.all(ids.map(async (id) => {
936
+ try {
937
+ const probeForm = await loadCreateForm(env, id);
938
+ return {
939
+ id,
940
+ probeForm,
941
+ probe: {
942
+ workflowId: id,
943
+ ...probeForm.workflowName ? { name: probeForm.workflowName } : {},
944
+ launchable: true
945
+ }
946
+ };
947
+ } catch (error) {
948
+ return {
949
+ id,
950
+ probeForm: null,
951
+ probe: {
952
+ workflowId: id,
953
+ launchable: false,
954
+ reason: String(error?.message ?? error).slice(0, 160)
955
+ }
956
+ };
957
+ }
958
+ }));
959
+ const probes = [];
960
+ const loadedForms = /* @__PURE__ */ new Map();
961
+ for (const item of probed) {
962
+ if (item.probeForm) loadedForms.set(item.id, item.probeForm);
963
+ probes.push(item.probe);
964
+ }
965
+ return { probes, loadedForms };
966
+ }
967
+ var ebMeetingCreateFlowPrepare = {
968
+ name: "meeting.eb.meeting.create.flow.prepare",
969
+ resource: "eb",
970
+ method: "meeting.eb.meeting.create.flow.prepare",
971
+ action: "meeting.eb.meeting.create.flow.prepare",
972
+ summary: '\u6D41\u7A0B\u5EFA\u4F1A\uFF08\u51C6\u5907\uFF09\uFF1A\u7528\u56FA\u5316\u6D41\u7A0B\u5019\u9009\u9010\u4E2A\u63A2\u6D4B\u53D1\u8D77\u6743\u9650 \u2014\u2014 \u4EC5 1 \u4E2A\u53EF\u53D1\u8D77\u5C31\u81EA\u52A8\u7528\u5B83\u3001\u591A\u4E2A\u90FD\u53EF\u53D1\u8D77\u5219\u8FD4\u56DE\u9009\u9879\u8BA9\u7528\u6237\u9009\u3001\u90FD\u4E0D\u53EF\u53D1\u8D77\u62A5\u300C\u6CA1\u6709\u53D1\u8D77\u6743\u9650\u300D\uFF1B\u4E0D\u4F20 begin_datetime \u65F6\u81EA\u52A8\u63A8\u8350\u300C\u4EBA+\u4F1A\u8BAE\u5BA4\u90FD\u7A7A\u95F2\u300D\u7684\u65F6\u6BB5\u3002\u53EA\u51FA\u9884\u89C8\u4E0E\u786E\u8BA4\u7968\u636E\uFF0C\u4E0D\u63D0\u4EA4\u3002\u26A0\uFE0F \u7528\u6237\u63D0\u5230\u5BA2\u6237\u540D\uFF08\u300C\u5BA2\u6237\u662F X\u300D\uFF09\u65F6**\u5FC5\u987B\u5148** meeting.eb.crm.search {"keyword":"X"} \u62FF customerId\uFF0C\u518D\u4F20 crm_members:[{id,name}]\uFF1B\u53EA\u628A\u5BA2\u6237\u540D\u5199\u8FDB\u4F1A\u8BAE\u540D\u79F0/\u5185\u5BB9\uFF0C\u8868\u5355\u300C\u53C2\u4F1A\u5BA2\u6237\u300D\u5C31\u662F\u7A7A\u7684',
973
+ capability: "eb.meeting",
974
+ risk: "read-before-write",
975
+ requiresConfirmation: true,
976
+ inputSchema: schemaOf(
977
+ {
978
+ mt_name: { type: "string", description: "\u4F1A\u8BAE\u540D\u79F0\uFF08\u5FC5\u586B\uFF09" },
979
+ begin_datetime: {
980
+ ...SCHEMA_DATETIME_MINUTE,
981
+ description: "\u5F00\u59CB\u65F6\u95F4\uFF08yyyy-MM-dd HH:mm\uFF09\u3002**\u53EF\u4EE5\u4E0D\u4F20**\uFF1A\u4E0D\u4F20\u4F1A\u6309\u53C2\u4F1A\u4EBA\u4E0E\u4F1A\u8BAE\u5BA4\u7A7A\u95F2\u60C5\u51B5\u63A8\u8350 3 \u4E2A\u65F6\u6BB5\u8BA9\u4F60\u9009\uFF1B\u53EA\u4F20\u5F00\u59CB\u65F6\u95F4\u3001\u4E0D\u4F20\u7ED3\u675F\u65F6\u95F4\u65F6\uFF0C\u6309 durationMinutes\uFF08\u9ED8\u8BA4 60 \u5206\u949F\uFF09\u81EA\u52A8\u7B97\u7ED3\u675F\u65F6\u95F4"
982
+ },
983
+ end_datetime: {
984
+ ...SCHEMA_DATETIME_MINUTE,
985
+ description: "\u7ED3\u675F\u65F6\u95F4\uFF08yyyy-MM-dd HH:mm\uFF09\uFF1B\u4E0D\u4F20\u5219\u6309 durationMinutes \u4ECE\u5F00\u59CB\u65F6\u95F4\u63A8\u7B97\uFF08\u9ED8\u8BA4 60 \u5206\u949F\uFF09"
986
+ },
987
+ mt_desc: { type: "string", description: "\u4F1A\u8BAE\u5185\u5BB9/\u8BF4\u660E" },
988
+ address: { type: "string", description: "\u4F1A\u8BAE\u5BA4\uFF08\u540D\u79F0\u6216 id\uFF0C\u6309\u6D41\u7A0B\u8868\u5355\u5B57\u6BB5\u8981\u6C42\uFF09" },
989
+ customize_address: { type: "string", description: "\u81EA\u5B9A\u4E49\u4F1A\u8BAE\u5730\u70B9" },
990
+ hrm_members: { type: "string", description: "\u53C2\u4F1A\u4EBA\u5458\uFF08\u9017\u53F7\u5206\u9694\u5458\u5DE5 id \u6216\u59D3\u540D\uFF0C\u6309\u6D41\u7A0B\u8868\u5355\u8981\u6C42\uFF09" },
991
+ total_member: { type: "number", description: "\u53C2\u4F1A\u4EBA\u6570" },
992
+ crm_members: {
993
+ oneOf: [{ type: "string" }, { type: "array", items: { oneOf: [{ type: "string" }, { type: "object" }] } }],
994
+ description: "\u53C2\u4F1A\u5BA2\u6237\uFF1A**\u5FC5\u987B\u5E26\u5BA2\u6237\u540D\u79F0**\uFF0C\u5199\u6CD5 `[{id,name}]` \u6216\u300C\u5BA2\u6237\u540D(\u5BA2\u6237id)\u300D\u6216\u9017\u53F7\u5206\u9694\u7684\u8FD9\u4E24\u79CD\u3002\u5BA2\u6237\u5148\u4ECE `meeting.eb.crm.search` \u6309\u5BA2\u6237\u540D\u67E5\u51FA\uFF08\u5165\u53C2 custom_name\uFF0C\u51FA\u53C2 items[].customerId / name\uFF09\uFF0C\u8BE5\u67E5\u8BE2**\u4E00\u6B21\u53EA\u56DE\u9996\u4E2A\u5339\u914D** \u21D2 exact=false \u65F6\u5FC5\u987B\u5148\u8BA9\u7528\u6237\u786E\u8BA4\u5BA2\u6237\u540D\u518D\u5199\u8FD9\u4E2A\u5B57\u6BB5\u3002\u26D4 \u53EA\u7ED9 id \u4E0D\u7ED9\u540D\u79F0\u4F1A\u88AB\u62D2\u7EDD\uFF08\u5BA2\u6237\u6D4F\u89C8\u6309\u94AE\u6309\u540D\u79F0\u843D\u503C\uFF0C\u53EA\u7ED9 id \u4F1A\u9759\u9ED8\u5B58\u6210\u7A7A\uFF09"
995
+ },
996
+ crm_member_count: { type: "number", description: "\u5E94\u5230\u5BA2\u6237\u6570\uFF1B\u4E0D\u4F20\u5219\u6309 crm_members \u6761\u6570\u81EA\u52A8\u7B97" },
997
+ crm_member_details: {
998
+ type: "array",
999
+ description: '\u53C2\u4F1A\u5BA2\u6237\u660E\u7EC6\uFF08\u5BBF\u4E3B\u8868\u5355\u91CC\u7684\u660E\u7EC6\u8868\uFF0C\u5217 \u59D3\u540D/\u6027\u522B/\u804C\u4F4D/\u624B\u673A\u53F7\u7801/\u5907\u6CE8\uFF09\uFF1A\u6BCF\u884C `{"xm":"\u5F20\u4E09","xb":"\u7537","zw":"\u7ECF\u7406","sjhm":"138...","bz":""}`\uFF0C\u4E5F\u63A5\u53D7\u4E2D\u6587\u952E\uFF08\u59D3\u540D/\u6027\u522B/\u804C\u4F4D/\u624B\u673A\u53F7\u7801/\u5907\u6CE8\uFF09\u3002\u5217\u5B57\u6BB5 id \u7531 CLI \u4ECE\u8868\u5355\u91CC\u6309\u5217\u540D\u53CD\u67E5\uFF0C\u4E0D\u7528\u4F20\u3002\u26A0\uFE0F \u8BE5\u660E\u7EC6\u8868\u5FC5\u987B\u5728\u53D1\u8D77\u8282\u70B9\u5E03\u5C40\u91CC\uFF08\u5426\u5219 CLI \u4F1A\u63D0\u793A"\u8868\u5355\u91CC\u6CA1\u6709\u53C2\u4F1A\u5BA2\u6237\u660E\u7EC6"\u5E76\u5FFD\u7565\u8FD9\u4E9B\u884C\uFF09\u26D4 \u9ED8\u8BA4\u4E0D\u751F\u6548\uFF1A\u5BA2\u6237\u8054\u7CFB\u4EBA\u7531 CLI \u6309 CRM \u5168\u91CF\u81EA\u52A8\u5E26\u5165\uFF0C\u8FD9\u91CC\u53EA\u5728 crm_detail_mode:"only" \u65F6\u624D\u7528\u6765"\u53EA\u5199\u8FD9\u51E0\u4F4D"',
1000
+ items: { type: "object" }
1001
+ },
1002
+ crm_detail_mode: {
1003
+ type: "string",
1004
+ description: '\u660E\u7EC6\u884C\u53E3\u5F84\uFF1A\u4E0D\u4F20\uFF08\u9ED8\u8BA4\uFF09= \u6309 CRM \u628A\u8BE5\u5BA2\u6237**\u5168\u90E8**\u8054\u7CFB\u4EBA\u81EA\u52A8\u5199\u5165\u300C\u53C2\u4F1A\u5BA2\u6237\u660E\u7EC6\u300D\uFF08\u4E00\u4EBA\u4E00\u884C\uFF0C\u4E0D\u7528\u95EE\u7528\u6237\u9009\u54EA\u4F4D\uFF09\uFF1B\u4F20 "only" = \u53EA\u5199 crm_member_details \u91CC\u70B9\u540D\u7684\u8FD9\u51E0\u4F4D'
1005
+ },
1006
+ caller: { type: "string", description: "\u53EC\u96C6\u4EBA\uFF08\u5458\u5DE5 id \u6216\u59D3\u540D\uFF09\u3002\u7F3A\u7701 = \u5F53\u524D\u767B\u5F55\u4EBA\uFF0C\u4E0D\u7528\u4F20\uFF1B\u53EA\u6709\u6307\u5B9A\u522B\u4EBA\u5F53\u53EC\u96C6\u4EBA\u624D\u4F20" },
1007
+ contacter: { type: "string", description: "\u8054\u7CFB\u4EBA\uFF08\u5458\u5DE5 id \u6216\u59D3\u540D\uFF09\u3002\u7F3A\u7701 = \u5F53\u524D\u767B\u5F55\u4EBA\uFF0C\u4E0D\u7528\u4F20\uFF1B\u53EA\u6709\u6307\u5B9A\u522B\u4EBA\u5F53\u8054\u7CFB\u4EBA\u624D\u4F20" },
1008
+ mt_type: {
1009
+ type: "string",
1010
+ description: "\u4F1A\u8BAE\u7C7B\u578B\uFF1A\u53EF\u4F20\u7C7B\u578B\u540D\u79F0\u6216 id\uFF08\u5148\u7528 `meeting.eb.type.list` \u67E5\u6709\u54EA\u4E9B\uFF09\u3002**\u5F88\u591A\u79DF\u6237\u7684\u6D41\u7A0B\u8868\u5355\u628A\u300C\u4F1A\u8BAE\u7C7B\u578B\u300D\u8BBE\u4E3A\u5FC5\u586B**\uFF0C\u4E0D\u4F20\u4F1A\u88AB `workflow.createRequest` \u6253\u56DE\u7F3A\u5B57\u6BB5"
1011
+ },
1012
+ other_remark: { type: "string", description: "\u5907\u6CE8" },
1013
+ workflowId: {
1014
+ oneOf: [{ type: "string" }, { type: "array", items: { type: "string" } }],
1015
+ description: "\u6307\u5B9A\u5EFA\u4F1A\u6D41\u7A0B id\uFF1A\u5355\u4E2A id\u3001id \u6570\u7EC4\u6216\u9017\u53F7\u5206\u9694\u90FD\u53EF\u4EE5\uFF0C\u4E5F\u63A5\u53D7\u300C\u6D41\u7A0B\u540D(123456)\u300D\u5199\u6CD5\u3002**\u4F20\u591A\u4E2A\u65F6 CLI \u540C\u6837\u4E0D\u4F1A\u66FF\u4F60\u9009**\u2014\u2014\u4F1A\u9010\u4E2A\u63A2\u6D4B\u53EF\u53D1\u8D77\u6027\uFF0C\u591A\u4E2A\u53EF\u7528\u5219\u8FD4\u56DE NEEDS_SELECTION \u8BA9\u7528\u6237\u6311\uFF1B\u4E0D\u4F20\u5219\u7528\u5E94\u7528\u8BBE\u7F6E mt_new_wf \u914D\u7F6E\u7684\u6D41\u7A0B\uFF08\u914D\u4E86\u591A\u4E2A\u65F6\u540C\u6837\u8BA9\u7528\u6237\u9009\uFF09"
1016
+ },
1017
+ autoRoom: { type: "boolean", description: "\u9ED8\u8BA4 false\uFF1A\u672A\u6307\u5B9A\u4F1A\u8BAE\u5BA4\u65F6\u8FD4\u56DE\u5019\u9009\u8BA9\u7528\u6237\u9009\uFF1B\u4F20 true \u624D\u81EA\u52A8\u91C7\u7528\u63A8\u8350" },
1018
+ allowNoRoom: { type: "boolean", description: "\u786E\u5B9E\u4E0D\u9700\u8981\u4F1A\u8BAE\u5BA4\uFF08\u7EBF\u4E0A\u4F1A\u7B49\uFF09\u65F6\u4F20 true\uFF0C\u907F\u514D\u88AB\u201C\u8BF7\u9009\u62E9\u4F1A\u8BAE\u5BA4\u201D\u62E6\u4F4F" },
1019
+ timeConfirmed: {
1020
+ type: "boolean",
1021
+ description: '\u26D4 **\u65F6\u95F4\u7684"\u7528\u6237\u5DF2\u786E\u8BA4"\u6807\u8BB0**\u3002\u53EA\u6709\u4EE5\u4E0B\u4E24\u79CD\u60C5\u51B5\u624D\u4F20 true\uFF1A\u2460 \u7528\u6237\u539F\u8BDD\u91CC\u660E\u786E\u7ED9\u51FA\u4E86\u65F6\u95F4\uFF08\u5982"\u660E\u5929 9 \u70B9\u5230 10 \u70B9"\uFF09\uFF1B\u2461 \u7528\u6237\u5728\u65F6\u6BB5\u9009\u9879\u91CC\u70B9\u9009\u540E\uFF0C\u628A `options[].value` **\u6574\u4F53**\u539F\u6837\u56DE\u4F20\uFF08value \u81EA\u5E26\u8BE5\u6807\u8BB0\uFF09\u3002\u4E0D\u4F20 = \u672A\u786E\u8BA4\uFF1A\u5373\u4F7F\u4F60\u4F20\u4E86 begin_datetime\uFF0CCLI \u4E5F**\u4E0D\u4F1A**\u5F53\u6210\u5DF2\u5B9A\uFF0C\u800C\u662F\u8FD4\u56DE\u65F6\u6BB5\u9009\u9879\u8BA9\u7528\u6237\u70B9\u9009\u3002\u26D4 \u7528\u6237\u53EA\u8BF4"\u660E\u5929/\u4E0A\u5348/\u4E0B\u5348"\u8FD9\u7C7B\u6A21\u7CCA\u8BF4\u6CD5\u65F6\uFF0C**\u5FC5\u987B\u4E0D\u4F20**\uFF0C\u8BA9 CLI \u7ED9\u5019\u9009'
1022
+ },
1023
+ roomConfirmed: {
1024
+ type: "boolean",
1025
+ description: '\u26D4 **\u4F1A\u8BAE\u5BA4\u7684"\u7528\u6237\u5DF2\u786E\u8BA4"\u6807\u8BB0**\u3002\u53EA\u6709\u4EE5\u4E0B\u4E24\u79CD\u60C5\u51B5\u624D\u4F20 true\uFF1A\u2460 \u7528\u6237\u539F\u8BDD\u660E\u786E\u6307\u5B9A\u4E86\u67D0\u95F4\u4F1A\u8BAE\u5BA4\uFF1B\u2461 \u7528\u6237\u5728\u623F\u95F4\u9009\u9879\u91CC\u70B9\u9009\u540E\u628A `options[].value` \u6574\u4F53\u539F\u6837\u56DE\u4F20\u3002\u4E0D\u4F20 = \u672A\u786E\u8BA4\uFF1A\u5373\u4F7F\u4F20\u4E86 address\uFF0CCLI \u4E5F\u4F1A\u628A"\u4F60\u6307\u5B9A\u7684\u8FD9\u95F4"\u548C\u63A8\u8350\u5019\u9009\u4E00\u8D77\u5217\u51FA\u6765\u8BA9\u7528\u6237\u70B9\u9009\u3002\u26D4 \u4E0D\u8981\u81EA\u5DF1\u4ECE room.list / room.recommend \u91CC\u6311\u4E00\u95F4\u585E\u8FDB address \u2014\u2014 \u90A3\u662F\u66FF\u7528\u6237\u62CD\u677F'
1026
+ },
1027
+ extraFields: {
1028
+ type: "object",
1029
+ description: '\u6309**\u6D41\u7A0B\u8868\u5355\u91CC\u7684\u5B57\u6BB5\u540D**\u586B\u989D\u5916\u5B57\u6BB5\uFF0C\u5F62\u5982 {"\u53C2\u4F1A\u5BA2\u6237": "xx\u516C\u53F8", "\u8054\u7CFB\u65B9\u5F0F": "138xxxx"}\uFF1A\u7528\u4E8E\u79DF\u6237\u5728\u6D41\u7A0B\u8868\u5355\u4E0A\u81EA\u5EFA\u3001CLI \u5185\u7F6E\u522B\u540D\u91CC\u6CA1\u6709\u7684\u5B57\u6BB5\u3002\u952E\u5FC5\u987B\u4E0E\u8BE5\u6D41\u7A0B\u8868\u5355\u7684\u5B57\u6BB5\u540D\u5B8C\u5168\u4E00\u81F4\uFF08prepare \u7684 warnings \u4F1A\u5217\u51FA\u8868\u5355\u73B0\u6709\u5168\u90E8\u5B57\u6BB5\u540D\uFF09\uFF1B\u5339\u914D\u4E0D\u5230\u7684\u4F1A\u8FDB unmapped \u63D0\u793A\uFF0C\u4E0D\u4F1A\u778E\u586B\u3002\u26D4 **\u4F1A\u8BAE\u5730\u70B9 / \u53C2\u4F1A\u4EBA\u5458 / \u53EC\u96C6\u4EBA / \u8054\u7CFB\u4EBA / \u4F1A\u8BAE\u7C7B\u578B \u4E0D\u8981\u585E\u8FD9\u91CC** \u2014\u2014 \u5B83\u4EEC\u6709\u4E13\u7528\u5165\u53C2\uFF08address / hrm_members / caller / contacter / mt_type\uFF09\uFF0CCLI \u4F1A\u628A\u503C\u8865\u6210\u6D4F\u89C8\u6309\u94AE\u8981\u7684 `{id,name}` \u5BF9\u8C61\uFF1B\u585E\u8FDB extraFields \u4F1A\u6309\u7EAF\u6587\u672C\u63D0\u4EA4\uFF0C\u670D\u52A1\u7AEF\u4F1A\u6253\u56DE\u300C\u8BF7\u6309\u540D\u79F0\u9009\u62E9\u300D'
1030
+ },
1031
+ dateFrom: {
1032
+ type: "string",
1033
+ description: "\u6CA1\u7ED9\u5177\u4F53\u65F6\u95F4\u65F6\u6309\u54EA\u4E00\u5929\u63A8\u8350\u65F6\u6BB5\uFF08yyyy-MM-dd\uFF1B\u4E0D\u4F20\u9ED8\u8BA4\u660E\u5929\uFF09\u3002\u26A0\uFE0F \u7528\u6237\u8BF4\u4E86\u300C\u4E0A\u5348/\u4E0B\u5348/\u665A\u4E0A\u300D\u5C31\u5FC5\u987B\u540C\u65F6\u4F20 time_slot \u2014\u2014 \u53EA\u4F20 dateFrom \u4F1A\u5F39\u65F6\u6BB5\u9009\u62E9\u5668\u8BA9\u7528\u6237\u518D\u9009\u4E00\u6B21"
1034
+ },
1035
+ time_slot: {
1036
+ type: "string",
1037
+ enum: ["\u4E0A\u5348", "\u65E9\u4E0A", "\u4E0B\u5348", "\u665A\u4E0A"],
1038
+ description: '\u7528\u6237\u53EA\u8BF4\u4E86\u300C\u4E0A\u5348/\u4E0B\u5348/\u665A\u4E0A\u300D\u65F6\u4F20\u8FD9\u4E2A\uFF08\u914D\u5408 dateFrom\uFF09\uFF1A\u4E0A\u5348/\u65E9\u4E0A=09:00\u201312:00\u3001\u4E0B\u5348=13:00\u201318:00\u3001\u665A\u4E0A=18:00\u201321:00\uFF0CCLI \u76F4\u63A5\u5B9A\u4E0B\u6765\u3001\u4E0D\u518D\u8FD4\u56DE\u65F6\u6BB5\u5019\u9009\u3002\u26D4 \u4E0D\u8981\u53EA\u4F20 dateFrom \u5C31\u671F\u5F85"\u8BA9\u7528\u6237\u9009\u65F6\u6BB5"\u2014\u2014\u7528\u6237\u5DF2\u7ECF\u8BF4\u4E86\u65F6\u6BB5\u5C31\u522B\u518D\u95EE'
1039
+ },
1040
+ durationMinutes: {
1041
+ type: "number",
1042
+ description: "\u4F1A\u8BAE\u65F6\u957F\uFF08\u5206\u949F\uFF0C\u9ED8\u8BA4 60\uFF09\uFF1A\u53EA\u7ED9\u4E86\u5F00\u59CB\u65F6\u95F4\u65F6\u7528\u6765\u7B97\u7ED3\u675F\u65F6\u95F4\uFF1B\u63A8\u8350\u65F6\u6BB5\u65F6\u4E5F\u6309\u8FD9\u4E2A\u65F6\u957F\u627E"
1043
+ },
1044
+ workStartHour: { type: "number", description: "\u63A8\u8350\u65F6\u6BB5\u7684\u6700\u65E9\u5C0F\u65F6\uFF08\u9ED8\u8BA4 9\uFF09" },
1045
+ workEndHour: { type: "number", description: "\u63A8\u8350\u65F6\u6BB5\u7684\u6700\u665A\u5C0F\u65F6\uFF08\u9ED8\u8BA4 18\uFF09" },
1046
+ fieldValues: {
1047
+ type: "object",
1048
+ additionalProperties: true,
1049
+ description: '\u6309**\u8868\u5355\u5B57\u6BB5 datakey\uFF08fieldId\uFF09**\u76F4\u63A5\u7ED9\u503C\uFF0C\u5F62\u5982 {"1325677252711735881": "\u7814\u8BA8\u4F1A"}\u3002\u4F18\u5148\u7EA7\u6700\u9AD8\uFF08\u540C\u540D\u5B57\u6BB5\u4EE5\u5B83\u4E3A\u51C6\uFF09\uFF1A\u9002\u5408\u5B57\u6BB5\u540D\u5E26\u63D0\u793A\u8BED\u3001\u6216\u79DF\u6237\u81EA\u5EFA\u5B57\u6BB5\u8FD9\u7C7B\u6309\u4E2D\u6587\u540D\u731C\u4E0D\u5230\u7684\u60C5\u51B5\u3002datakey \u4ECE prepare \u8FD4\u56DE\u7684 preview.mapped\uFF08\u5F62\u5982 "\u4F1A\u8BAE\u540D\u79F0(1325677252711735881)"\uFF09\u91CC\u53D6\uFF1B\u6BCF\u4E2A\u6D41\u7A0B\u7684 datakey \u56FA\u5B9A\u4E0D\u53D8\uFF0C\u53EF\u957F\u671F\u786C\u7F16\u7801\u3002'
1050
+ },
1051
+ flowChoice: {
1052
+ type: "string",
1053
+ enum: ["auto", "ask"],
1054
+ description: '\u591A\u4E2A\u5EFA\u4F1A\u6D41\u7A0B**\u90FD\u6709\u53D1\u8D77\u6743\u9650**\u65F6\u600E\u4E48\u529E\uFF1A\u9ED8\u8BA4\uFF08\u4E0D\u4F20 / ask\uFF09= \u8FD4\u56DE\u9009\u9879\u8BA9\u7528\u6237\u6311\uFF1Bauto = \u81EA\u52A8\u53D6\u4F18\u5148\u7EA7\u6700\u9AD8\u7684\u90A3\u4E2A\uFF08\u7701\u4E00\u8F6E\uFF0C\u4F46\u9009\u9519\u6D41\u7A0B\u4F1A\u6F0F\u5B57\u6BB5\uFF0C\u614E\u7528\uFF09\u3002\u6709**\u6D41\u7A0B\u8BB0\u5FC6**\uFF08\u8BE5\u8D26\u53F7\u4E0A\u6B21\u6210\u529F\u7528\u8FC7\u7684\u6D41\u7A0B\uFF09\u4E14\u672C\u6B21\u4ECD\u53EF\u53D1\u8D77\u65F6\uFF0C\u9ED8\u8BA4\u76F4\u63A5\u6CBF\u7528\u4E0A\u6B21\u9009\u62E9\u5E76\u7559\u75D5\uFF0C\u4E0D\u518D\u5F39\u9009\u9879\uFF1B\u8981\u5F3A\u5236\u56DE\u5230"\u6BCF\u6B21\u90FD\u95EE"\u624D\u4F20 ask\u3002\u53EA\u6709 1 \u4E2A\u6709\u6743\u9650\u65F6\u4E0D\u53D7\u6B64\u53C2\u6570\u5F71\u54CD\uFF0CCLI \u76F4\u63A5\u53D1\u8D77'
1055
+ }
1056
+ },
1057
+ { required: ["mt_name"] }
1058
+ ),
1059
+ handler: async (args, env) => {
1060
+ let workflowId = "";
1061
+ let flowPickNote = null;
1062
+ const decisions = {};
1063
+ const enrich = args.enrich !== false;
1064
+ let beginText = String(args.begin_datetime ?? "").trim();
1065
+ let endText = String(args.end_datetime ?? "").trim();
1066
+ const TIME_SLOT_RANGES = {
1067
+ \u4E0A\u5348: ["09:00", "12:00"],
1068
+ \u65E9\u4E0A: ["09:00", "12:00"],
1069
+ \u4E0B\u5348: ["13:00", "18:00"],
1070
+ \u665A\u4E0A: ["18:00", "21:00"]
1071
+ };
1072
+ let slotConfirmed = false;
1073
+ const slotArg = String(args.time_slot ?? "").trim();
1074
+ if (slotArg !== "" && !/^\d{4}-\d{2}-\d{2}[ T]\d{2}:\d{2}/.test(beginText)) {
1075
+ const range = TIME_SLOT_RANGES[slotArg];
1076
+ const day2 = String(args.dateFrom ?? "").trim().slice(0, 10) || beginText.slice(0, 10) || tomorrowIso();
1077
+ if (range && /^\d{4}-\d{2}-\d{2}$/.test(day2)) {
1078
+ beginText = `${day2} ${range[0]}`;
1079
+ endText = `${day2} ${range[1]}`;
1080
+ slotConfirmed = true;
1081
+ }
1082
+ }
1083
+ if (!slotConfirmed && !/\d{1,2}:\d{2}/.test(beginText)) {
1084
+ const workStart = Number(args.workStartHour);
1085
+ const workEnd = Number(args.workEndHour);
1086
+ if (Number.isFinite(workStart) && Number.isFinite(workEnd) && workEnd > workStart) {
1087
+ const slotName = workEnd <= 12 && workStart < 12 ? "\u4E0A\u5348" : workStart >= 13 && workEnd <= 18 ? "\u4E0B\u5348" : workStart >= 18 ? "\u665A\u4E0A" : "";
1088
+ const range = slotName ? TIME_SLOT_RANGES[slotName] : void 0;
1089
+ const day2 = String(args.dateFrom ?? "").trim().slice(0, 10) || beginText.slice(0, 10) || tomorrowIso();
1090
+ if (range && /^\d{4}-\d{2}-\d{2}$/.test(day2)) {
1091
+ beginText = `${day2} ${range[0]}`;
1092
+ endText = `${day2} ${range[1]}`;
1093
+ slotConfirmed = true;
1094
+ }
1095
+ }
1096
+ }
1097
+ const slotHit = beginText.match(/(\d{4}-\d{2}-\d{2})?\s*(上午|早上|下午|晚上)/u);
1098
+ if (slotHit) {
1099
+ const range = TIME_SLOT_RANGES[slotHit[2]];
1100
+ const day2 = slotHit[1] || beginText.slice(0, 10) || String(args.dateFrom ?? "").trim().slice(0, 10) || tomorrowIso();
1101
+ const rest = beginText.replace(slotHit[0], "");
1102
+ if (range && /^\d{4}-\d{2}-\d{2}$/.test(day2) && !/\d{1,2}:\d{2}/.test(rest)) {
1103
+ beginText = `${day2} ${range[0]}`;
1104
+ endText = `${day2} ${range[1]}`;
1105
+ slotConfirmed = true;
1106
+ }
1107
+ }
1108
+ const rawMembers = String(args.hrm_members ?? "").split(/[,;,;\s]+/).map((item) => item.trim()).filter((item) => item !== "");
1109
+ let membersDefaulted = false;
1110
+ if (rawMembers.length === 0) {
1111
+ const self = await resolveSelfPerson(env);
1112
+ if (self) {
1113
+ rawMembers.push(self.id);
1114
+ membersDefaulted = true;
1115
+ args.hrm_members = rawMembers.join(",");
1116
+ }
1117
+ }
1118
+ const nameLike = rawMembers.filter((item) => !/^\d+$/.test(item));
1119
+ const nameToId = nameLike.length > 0 ? await import("./schedule-ESZIBAUO.js").then((m) => m.resolveMemberIdsByName(env, nameLike)).catch(() => /* @__PURE__ */ new Map()) : /* @__PURE__ */ new Map();
1120
+ const memberIds = rawMembers.map((item) => nameToId.get(item) ?? item);
1121
+ const timeConfirmed = args.timeConfirmed === true || slotConfirmed;
1122
+ const callerWorkflowId = String(args.workflowId ?? "").trim();
1123
+ const earlyWorkflowNote = callerWorkflowId === "" ? "" : `\u26D4 \u4F60\u4F20\u4E86 workflowId=${callerWorkflowId}\uFF0C\u4F46**\u6D41\u7A0B\u8FD8\u6CA1\u5230\u786E\u8BA4\u6B65\u9AA4**\uFF08\u987A\u5E8F\u662F \u540D\u79F0\u2192\u65F6\u95F4\u2192\u53C2\u4F1A\u4EBA\u2192\u5730\u70B9\u2192\u6D41\u7A0B\uFF09\u3002\u672C\u6B21\u53EA\u5904\u7406\u65F6\u95F4/\u5730\u70B9\uFF1B\u26D4 \u4E0D\u8981\u5728\u56DE\u590D\u91CC\u8BF4"\u6309 X \u6D41\u7A0B\u53D1\u8D77"\u2014\u2014\u56DB\u8981\u7D20\u5B9A\u5B8C\u540E CLI \u4F1A\u8FD4\u56DE\u6D41\u7A0B\u9009\u9879\u8BA9\u7528\u6237\u70B9\u3002`;
1124
+ const beginHasTime = /^\d{4}-\d{2}-\d{2}[ T]\d{2}:\d{2}/.test(beginText);
1125
+ const endHasTime = /^\d{4}-\d{2}-\d{2}[ T]\d{2}:\d{2}/.test(endText);
1126
+ if (beginHasTime && !endHasTime) {
1127
+ const duration = Number(args.durationMinutes) > 0 ? Math.round(Number(args.durationMinutes)) : 60;
1128
+ const startMs = Date.parse(beginText.slice(0, 16).replace(" ", "T"));
1129
+ if (Number.isFinite(startMs)) endText = formatMinute(new Date(startMs + duration * 6e4));
1130
+ }
1131
+ if (!beginHasTime || !timeConfirmed) {
1132
+ const day2 = /^\d{4}-\d{2}-\d{2}/.test(beginText) ? beginText.slice(0, 10) : String(args.dateFrom ?? "").trim().slice(0, 10) || tomorrowIso();
1133
+ const duration = Number(args.durationMinutes) > 0 ? Math.round(Number(args.durationMinutes)) : 60;
1134
+ const { getMeetingOperation } = await import("./registry-IM5G23LS.js");
1135
+ const suggested = await getMeetingOperation("meeting.eb.meeting.create.suggest").handler(
1136
+ {
1137
+ dateFrom: day2,
1138
+ durationMinutes: duration,
1139
+ hrm_members: memberIds.join(","),
1140
+ maxSlots: 3,
1141
+ topN: 3,
1142
+ ...Number(args.total_member) > 0 ? { memberCount: Number(args.total_member) } : {},
1143
+ ...args.workStartHour !== void 0 ? { workStartHour: Number(args.workStartHour) } : {},
1144
+ ...args.workEndHour !== void 0 ? { workEndHour: Number(args.workEndHour) } : {}
1145
+ },
1146
+ env
1147
+ ).catch((error) => ({ data: { slots: [] }, slotError: String(error?.message ?? error).slice(0, 160) }));
1148
+ const slotOptions2 = suggested?.data?.slots ?? [];
1149
+ const slotWarnings = [
1150
+ ...suggested?.warnings ?? [],
1151
+ ...suggested?.slotError ? [`\u65F6\u6BB5\u63A8\u8350\u672A\u8DD1\u6210\u529F\uFF1A${suggested.slotError}`] : [],
1152
+ ...memberIds.length === 0 ? ['\u26A0\uFE0F \u6CA1\u6709\u53C2\u4F1A\u4EBA\u5458\uFF0C\u65E0\u6CD5\u6838\u9A8C"\u4EBA\u662F\u5426\u7A7A\u95F2" \u2014\u2014 \u4E0B\u9762\u53EA\u662F**\u4F1A\u8BAE\u5BA4\u6709\u7A7A**\u7684\u65F6\u6BB5\uFF0C\u8BF7\u5982\u5B9E\u8BF4\u660E\u3002'] : []
1153
+ ];
1154
+ return meetingSuccess("meeting.eb.meeting.create.flow.prepare", {
1155
+ status: "NEEDS_SELECTION",
1156
+ selectionType: "slot",
1157
+ ui: { component: "choice", multiple: false, recommendedKey: "T1" },
1158
+ message: slotOptions2.length > 0 ? `${beginHasTime ? `\u4F60\u4F20\u5165\u7684\u65F6\u95F4 ${beginText}~${endText} **\u672A\u7ECF\u7528\u6237\u786E\u8BA4**\uFF08\u6CA1\u5E26 timeConfirmed\uFF09` : "\u6CA1\u6709\u7ED9\u51FA\u5177\u4F53\u65F6\u95F4"}\uFF0C\u5DF2\u6309\u53C2\u4F1A\u4EBA\u4E0E\u4F1A\u8BAE\u5BA4\u7A7A\u95F2\u60C5\u51B5\u63A8\u8350 ${slotOptions2.length} \u4E2A\u65F6\u6BB5\uFF08${day2}\uFF0C\u65F6\u957F ${duration} \u5206\u949F\uFF09\u2014\u2014 \u26D4 \u5FC5\u987B\u8BA9\u7528\u6237\u5728\u9009\u9879\u91CC\u70B9\u9009\uFF0C**\u4E0D\u8981**\u628A\u4EFB\u4F55\u4E00\u4E2A\u5019\u9009\u5199\u6210"\u5DF2\u5B9A"\u6216\u653E\u8FDB\u786E\u8BA4\u6458\u8981` : `${beginHasTime ? `\u4F60\u4F20\u5165\u7684\u65F6\u95F4 ${beginText}~${endText} \u672A\u7ECF\u7528\u6237\u786E\u8BA4\uFF08\u6CA1\u5E26 timeConfirmed\uFF09` : "\u6CA1\u6709\u7ED9\u51FA\u5177\u4F53\u65F6\u95F4"}\uFF0C\u4E14 ${day2} \u6CA1\u80FD\u627E\u5230\u300C\u53C2\u4F1A\u4EBA\u7A7A\u95F2 + \u4F1A\u8BAE\u5BA4\u7A7A\u95F2\u300D\u7684\u65F6\u6BB5\uFF0C\u8BF7\u8BA9\u7528\u6237\u6362\u4E2A\u65E5\u671F\u6216\u6307\u5B9A\u65F6\u95F4`,
1159
+ options: slotOptions2.map((slot, index) => ({
1160
+ key: `T${index + 1}`,
1161
+ label: String(slot.label ?? ""),
1162
+ // ⛔ 时间不在 slot 顶层,而在 slot.value 里(suggest 的返回结构)—— 取错会让调用方
1163
+ // 拿不到 begin/end,只能再问用户一次时间(2026-10-30 冒烟实测踩到)。
1164
+ // `timeConfirmed: true` 在这里是**关键**:用户点选后 value 原样回传,下一轮才被认作"已确认";
1165
+ // agent 自己编的时间不带这个标记,就永远停在选项这一步。
1166
+ value: {
1167
+ begin_datetime: String(slot.value?.begin ?? slot.begin ?? "").trim(),
1168
+ end_datetime: String(slot.value?.end ?? slot.end ?? "").trim(),
1169
+ address: slot.value?.address ?? null,
1170
+ timeConfirmed: true
1171
+ },
1172
+ reason: String(slot.reason ?? ""),
1173
+ rooms: slot.rooms ?? []
1174
+ })),
1175
+ day: day2,
1176
+ durationMinutes: duration,
1177
+ memberIds,
1178
+ // ⛔ 这里**不能**出现 workflowId:流程确认在四要素之后(2026-10-30 顺序调整)。
1179
+ // 返回 workflowId 会让 agent 误以为"流程已定",于是在回复里先讲流程、再问时间。
1180
+ workflowPending: true,
1181
+ hint: "\u9009\u5B9A\u540E\u628A value **\u6574\u4F53**\u539F\u6837\u5E26\u56DE\u91CD\u65B0\u8C03\u7528\uFF08\u542B timeConfirmed: true\uFF09\uFF1Baddress \u5DF2\u81EA\u52A8\u5E26\u4E0A\u8BE5\u65F6\u6BB5\u53EF\u7528\u7684\u4F1A\u8BAE\u5BA4\uFF0C\u4ECD\u9700\u8BA9\u7528\u6237\u5355\u72EC\u786E\u8BA4\u6216\u7528 roomConfirmed: true"
1182
+ }, {
1183
+ warnings: [
1184
+ `${beginHasTime ? `\u672C\u6B21**\u6CA1\u6709\u63D0\u4EA4**\uFF1A\u4F60\u4F20\u5165\u7684\u65F6\u95F4 ${beginText}~${endText} \u6CA1\u6709\u7528\u6237\u786E\u8BA4\u6807\u8BB0\uFF08timeConfirmed\uFF09\uFF0C\u5DF2\u6539\u4E3A\u7ED9\u5019\u9009\u3002` : "\u672C\u6B21**\u6CA1\u6709\u63D0\u4EA4**\uFF1A\u65F6\u95F4\u672A\u786E\u5B9A\uFF08\u7F3A begin_datetime\uFF09\u3002"}\u5DF2\u6309 ${day2} \u63A8\u8350\u65F6\u6BB5\uFF0C\u8BF7\u7528\u9009\u9879\u8BA9\u7528\u6237\u6311\u4E00\u4E2A\u3002`,
1185
+ ...slotWarnings,
1186
+ ...earlyWorkflowNote ? [earlyWorkflowNote] : []
1187
+ ]
1188
+ });
1189
+ }
1190
+ let addressInput = args.address;
1191
+ const hadAddressInput = String(args.address ?? "").trim() !== "";
1192
+ const day = beginText.slice(0, 10);
1193
+ const durationMinutes = beginText && endText ? Math.max(15, Math.round((Date.parse(endText.replace(" ", "T")) - Date.parse(beginText.replace(" ", "T"))) / 6e4) || 60) : 60;
1194
+ const timings = {};
1195
+ const startedAt = Date.now();
1196
+ const enrichFailures = [];
1197
+ const noteFailure = (label) => (error) => {
1198
+ enrichFailures.push(`${label}\u672A\u5B8C\u6210\uFF1A${String(error?.message ?? error).slice(0, 120)}`);
1199
+ return null;
1200
+ };
1201
+ const needSelfPerson = String(args.caller ?? "").trim() === "" || String(args.contacter ?? "").trim() === "";
1202
+ const autoPerson = applySelfPersonDefaults(
1203
+ args,
1204
+ needSelfPerson ? await resolveSelfPerson(env) : null
1205
+ );
1206
+ const autoFilledPerson = autoPerson.filled;
1207
+ const selfPersonWarning = autoPerson.warning;
1208
+ const declaredTotal = Number(args.total_member) > 0 ? Number(args.total_member) : null;
1209
+ const callerToken = String(args.caller ?? "").trim();
1210
+ const callerInMembers = callerToken !== "" && (rawMembers.includes(callerToken) || memberIds.includes(callerToken));
1211
+ const roomMemberCount = declaredTotal ?? (memberIds.length > 0 ? memberIds.length + (callerInMembers ? 0 : 1) : void 0);
1212
+ const crmMentionedInText = detectCrmMentionInText(
1213
+ String(args.mt_name ?? ""),
1214
+ String(args.mt_desc ?? ""),
1215
+ String(args.other_remark ?? "")
1216
+ );
1217
+ const customerWords = /(接待|招待|客户|贵宾|来访)/u.test(
1218
+ `${String(args.mt_name ?? "")} ${String(args.mt_desc ?? "")} ${String(args.other_remark ?? "")}`
1219
+ );
1220
+ const hasCustomer = (Array.isArray(args.crm_members) ? args.crm_members.length > 0 : String(args.crm_members ?? "").trim() !== "") || Boolean(crmMentionedInText) || customerWords;
1221
+ const dayUsagesTask = enrich && beginText && endText ? loadDayUsages(env, day) : Promise.resolve(null);
1222
+ const roomTask = enrich && beginText && endText ? (async () => {
1223
+ const usageData = await dayUsagesTask;
1224
+ return recommendRooms(env, {
1225
+ beginDatetime: beginText,
1226
+ endDatetime: endText,
1227
+ ...roomMemberCount ? { memberCount: roomMemberCount } : {},
1228
+ // 带客户时优先接待类会议室(2026-11-02 用户口径:加了客户就推接待类)
1229
+ ...hasCustomer ? { hasCustomer: true } : {},
1230
+ // 2026-11-03 用户批准松绑:不再每次强制重拉台账(省 ~1s + 2 请求)。
1231
+ // 兜底在 recommendRooms 内部:24h 缓存凑不出候选时自动强制重拉一次再算;
1232
+ // 代价是刚导入的会议室在缓存期可能按名称查不到(按 id 指定不受影响)。
1233
+ topN: 3,
1234
+ // 占用走全天缓存(usageData 为 null 时 recommendRooms 内部自己查,行为不变)
1235
+ ...usageData ? { dayUsages: usageData.rows } : {}
1236
+ });
1237
+ })().catch(noteFailure("\u4F1A\u8BAE\u5BA4\u63A8\u8350")) : Promise.resolve(null);
1238
+ const addressId = String(addressInput ?? "").trim();
1239
+ const roomConfirmed = args.roomConfirmed === true;
1240
+ const roomConflictTask = enrich && beginText && endText && addressId !== "" ? (async () => {
1241
+ const room = await resolveAddressRoom(env, addressId);
1242
+ if (!room) return { unresolved: true, input: addressId };
1243
+ if (!room.id || room.lookupFailed || room.status !== "0") return { room };
1244
+ const usageData = await dayUsagesTask.catch(() => null);
1245
+ if (usageData) {
1246
+ const conflicts = filterUsages(usageData.rows, { roomId: room.id, begin: beginText, end: endText }).map((usage) => ({ mtId: usage.mtId, begin: usage.start, end: usage.end }));
1247
+ return {
1248
+ room,
1249
+ hasConflict: conflicts.length > 0,
1250
+ conflicts,
1251
+ verdict: conflicts.length > 0 ? "warn" : "ok",
1252
+ requests: usageData.requests,
1253
+ usageFromCache: usageData.fromCache
1254
+ };
1255
+ }
1256
+ const { getMeetingOperation } = await import("./registry-IM5G23LS.js");
1257
+ const result = await getMeetingOperation("meeting.eb.conflict.room").handler(
1258
+ { beginDatetime: beginText, endDatetime: endText, address: room.id },
1259
+ env
1260
+ );
1261
+ return { room, ...result?.data ?? {} };
1262
+ })().catch(noteFailure("\u4F1A\u8BAE\u5BA4**\u5360\u7528**\u68C0\u6D4B")) : Promise.resolve(null);
1263
+ const conflictTask = enrich && beginText && endText && memberIds.length > 0 ? (async () => {
1264
+ const { getMeetingOperation } = await import("./registry-IM5G23LS.js");
1265
+ return getMeetingOperation("meeting.eb.conflict.member").handler(
1266
+ { beginDatetime: beginText, endDatetime: endText, hrmMembers: memberIds.join(",") },
1267
+ env
1268
+ );
1269
+ })().catch(noteFailure("\u53C2\u4F1A\u4EBA**\u4F1A\u8BAE\u5360\u7528**\u68C0\u6D4B")) : Promise.resolve(null);
1270
+ const availabilityTask = enrich && beginText && endText && memberIds.length > 0 ? findCommonFreeSlots(env, {
1271
+ rangeStart: `${day} 00:00`,
1272
+ rangeEnd: `${day} 23:59`,
1273
+ durationMinutes,
1274
+ members: memberIds,
1275
+ maxSlots: 3,
1276
+ maxDays: 1,
1277
+ includeSchedule: true
1278
+ }).catch(noteFailure("\u53C2\u4F1A\u4EBA**\u65E5\u7A0B\u7A7A\u95F2**\u68C0\u6D4B")) : Promise.resolve(null);
1279
+ const [roomRec, memberConflict, free, roomConflict] = await Promise.all([
1280
+ roomTask,
1281
+ conflictTask,
1282
+ availabilityTask,
1283
+ roomConflictTask
1284
+ ]);
1285
+ timings.parallelMs = Date.now() - startedAt;
1286
+ const memberConflicts = memberConflict?.data?.conflicts ?? [];
1287
+ if (memberConflicts.length > 0) decisions.memberConflicts = memberConflicts;
1288
+ const freeSlots = free?.slots ?? [];
1289
+ if (free) {
1290
+ decisions.scheduleItems = free.scheduleItems;
1291
+ decisions.availabilityCost = free.cost;
1292
+ if (freeSlots.length > 0) {
1293
+ decisions.suggestedSlots = freeSlots;
1294
+ decisions.slotOptions = freeSlots.map((slot, index) => ({
1295
+ key: `T${index + 1}`,
1296
+ label: `${slot.begin.slice(11)}~${slot.end.slice(11)}\uFF08${day}\uFF09 \xB7 \u5168\u90E8\u53C2\u4F1A\u4EBA\u7A7A\u95F2`,
1297
+ value: { begin: slot.begin, end: slot.end },
1298
+ reason: "\u8BE5\u65F6\u6BB5\u6240\u6709\u53C2\u4F1A\u4EBA\u90FD\u6CA1\u6709\u4F1A\u8BAE\u4E0E\u65E5\u7A0B\u5360\u7528\uFF08\u5DF2\u540C\u65F6\u6838\u5BF9\u4F1A\u8BAE\u56DE\u6267\u4E0E\u65E5\u7A0B\uFF09"
1299
+ }));
1300
+ } else if (free.blockingSummary) {
1301
+ decisions.dayBlocked = { day, summary: free.blockingSummary };
1302
+ }
1303
+ }
1304
+ const conflictBrief = {
1305
+ memberConflicts,
1306
+ suggestedSlots: freeSlots,
1307
+ ...enrichFailures.length > 0 ? { enrichFailures } : {}
1308
+ };
1309
+ const failureWarnings = enrichFailures.map(
1310
+ (failure) => `\u26A0\uFE0F ${failure} \u2014\u2014 **\u8FD9\u4E0D\u4EE3\u8868\u6CA1\u6709\u51B2\u7A81**\uFF0C\u8BF7\u5982\u5B9E\u544A\u77E5\u7528\u6237\u8BE5\u9879\u672A\u6838\u9A8C\uFF0C\u4E0D\u8981\u58F0\u79F0"\u65F6\u95F4\u5DF2\u786E\u8BA4\u7A7A\u95F2"`
1311
+ );
1312
+ const roomOptions = (roomRec?.candidates ?? []).map((candidate, index) => ({
1313
+ key: `R${index + 1}`,
1314
+ label: `${candidate.name}${candidate.capacity.max > 0 ? `\uFF08\u53EF\u5BB9 ${candidate.capacity.max} \u4EBA\uFF09` : ""}${index === 0 ? " \xB7 \u63A8\u8350" : ""}`,
1315
+ // roomConfirmed: true = 用户点选该选项即代表"确认用这间",原样回传后下一轮才被认。
1316
+ value: { id: candidate.id, name: candidate.name, roomConfirmed: true },
1317
+ reason: candidate.reasons.join("\uFF1B")
1318
+ }));
1319
+ const roomConflictData = roomConflict;
1320
+ const resolvedAddress = roomConflictData?.room ?? null;
1321
+ const resolvedAddressId = resolvedAddress?.id || addressId;
1322
+ const addressDisplay = resolvedAddress?.name || addressId;
1323
+ if (roomConflictData?.unresolved === true) {
1324
+ decisions.roomNotFound = { input: addressId, candidates: roomOptions.length };
1325
+ if (roomOptions.length > 0) decisions.roomOptions = roomOptions;
1326
+ return meetingSuccess("meeting.eb.meeting.create.flow.prepare", {
1327
+ status: "NEEDS_SELECTION",
1328
+ selectionType: "room",
1329
+ ui: { component: "choice", multiple: false, recommendedKey: "R1" },
1330
+ message: `\u6CA1\u627E\u5230\u540D\u4E3A\u300C${addressId}\u300D\u7684\u4F1A\u8BAE\u5BA4\uFF08\u4F1A\u8BAE\u5BA4\u53F0\u8D26\u91CC\u6CA1\u6709\u8FD9\u4E2A\u540D\u5B57\uFF09\uFF0C\u672C\u6B21**\u6CA1\u6709\u63D0\u4EA4**\u3002` + (roomOptions.length > 0 ? `\u8BF7\u4ECE\u4E0B\u9762 ${roomOptions.length} \u4E2A\u5728\u8BE5\u65F6\u6BB5\u7A7A\u95F2\u7684\u4F1A\u8BAE\u5BA4\u91CC\u9009\u4E00\u95F4\uFF0C\u6216\u6838\u5BF9\u4E00\u4E0B\u4F1A\u8BAE\u5BA4\u540D\u79F0` : "\u8BE5\u65F6\u6BB5\u4E5F\u6CA1\u6709\u53EF\u7528\u7684\u7A7A\u95F2\u4F1A\u8BAE\u5BA4\uFF0C\u8BF7\u6539\u4F1A\u8BAE\u65F6\u95F4\u6216\u6539\u7EBF\u4E0A\u4F1A\u8BAE\uFF08allowNoRoom: true\uFF09"),
1331
+ workflowPending: true,
1332
+ options: roomOptions,
1333
+ recommended: roomOptions[0]?.value ?? null,
1334
+ roomNotFound: decisions.roomNotFound,
1335
+ hint: "\u9009\u5B9A\u540E\u628A value **\u6574\u4F53**\u539F\u6837\u5E26\u56DE\uFF08\u542B roomConfirmed: true\uFF09\uFF1B\u6838\u5BF9\u540D\u79F0\u53EF\u7528 `meeting.eb.room.list` \u770B\u5168\u91CF\u6E05\u5355"
1336
+ }, {
1337
+ warnings: [
1338
+ `\u4F1A\u8BAE\u5BA4\u300C${addressId}\u300D\u5728\u53F0\u8D26\u91CC\u4E0D\u5B58\u5728\uFF0C\u5DF2\u62E6\u4E0B\u672A\u63D0\u4EA4\u3002`,
1339
+ '\u26D4 \u4E0D\u8981\u628A\u5B83\u5F53\u6210"\u7528\u6237\u6307\u5B9A\u7684\u623F\u95F4"\u5199\u8FDB\u786E\u8BA4\u6458\u8981 \u2014\u2014 \u8FD9\u95F4\u623F\u6839\u672C\u6CA1\u6709\u88AB\u89E3\u6790\u51FA\u6765\u3002'
1340
+ ]
1341
+ });
1342
+ }
1343
+ if (resolvedAddress && resolvedAddress.status === "1") {
1344
+ decisions.roomSealed = { id: resolvedAddress.id, name: resolvedAddress.name };
1345
+ if (roomOptions.length > 0) decisions.roomOptions = roomOptions;
1346
+ return meetingSuccess("meeting.eb.meeting.create.flow.prepare", {
1347
+ status: "NEEDS_SELECTION",
1348
+ selectionType: "room",
1349
+ ui: { component: "choice", multiple: false, recommendedKey: "R1" },
1350
+ message: `\u4F1A\u8BAE\u5BA4\u300C${resolvedAddress.name}\u300D\u5F53\u524D\u662F**\u5C01\u5B58**\u72B6\u6001\uFF08\u4E0D\u53EF\u9884\u7EA6\uFF09\uFF0C\u672C\u6B21**\u6CA1\u6709\u63D0\u4EA4**\u3002` + (roomOptions.length > 0 ? "\u8BF7\u6539\u7528\u4E0B\u9762\u7A7A\u95F2\u7684\u4F1A\u8BAE\u5BA4" : "\u8BE5\u65F6\u6BB5\u6CA1\u6709\u5176\u5B83\u53EF\u7528\u4F1A\u8BAE\u5BA4\uFF0C\u8BF7\u6539\u4F1A\u8BAE\u65F6\u95F4"),
1351
+ workflowPending: true,
1352
+ options: roomOptions,
1353
+ recommended: roomOptions[0]?.value ?? null,
1354
+ roomSealed: decisions.roomSealed
1355
+ }, {
1356
+ warnings: [`\u4F1A\u8BAE\u5BA4\u300C${resolvedAddress.name}\u300D\uFF08${resolvedAddress.id}\uFF09\u5DF2\u5C01\u5B58\uFF0C\u4E0D\u53EF\u9884\u7EA6\uFF0C\u5DF2\u62E6\u4E0B\u672A\u63D0\u4EA4\u3002`]
1357
+ });
1358
+ }
1359
+ if (addressInput && roomConfirmed && roomConflictData?.hasConflict === true) {
1360
+ const busy = Array.isArray(roomConflictData.conflicts) ? roomConflictData.conflicts : [];
1361
+ decisions.roomConflict = {
1362
+ address: resolvedAddressId,
1363
+ addressName: addressDisplay,
1364
+ hasConflict: true,
1365
+ conflicts: busy,
1366
+ verdict: roomConflictData.verdict ?? "conflict"
1367
+ };
1368
+ if (roomOptions.length > 0) decisions.roomOptions = roomOptions;
1369
+ return meetingSuccess("meeting.eb.meeting.create.flow.prepare", {
1370
+ status: "NEEDS_SELECTION",
1371
+ selectionType: "room_conflict",
1372
+ ui: { component: "choice", multiple: false, recommendedKey: "R1" },
1373
+ message: `\u4F60\u6307\u5B9A\u7684\u4F1A\u8BAE\u5BA4\u300C${addressDisplay}\u300D\u5728 ${beginText}~${endText} \u5DF2\u88AB\u5360\u7528\uFF08${busy.length} \u6761\u5360\u7528\u8BB0\u5F55\uFF09\uFF0C\u672C\u6B21**\u6CA1\u6709\u63D0\u4EA4**\u3002\u8BF7\u6539\u7528\u4E0B\u9762\u7A7A\u95F2\u7684\u4F1A\u8BAE\u5BA4\uFF0C\u6216\u8C03\u6574\u4F1A\u8BAE\u65F6\u95F4`,
1374
+ workflowPending: true,
1375
+ options: roomOptions,
1376
+ recommended: roomOptions[0]?.value ?? null,
1377
+ conflicts: busy,
1378
+ roomConflict: decisions.roomConflict,
1379
+ hint: "\u9009\u5B9A\u540E\u628A value.id \u4F5C\u4E3A address \u91CD\u65B0\u8C03\u7528\uFF1B\u8981\u6539\u65F6\u95F4\u5C31\u540C\u65F6\u4F20\u65B0\u7684 begin_datetime/end_datetime"
1380
+ }, {
1381
+ warnings: [
1382
+ `\u4F1A\u8BAE\u5BA4\u300C${addressDisplay}\u300D\uFF08${resolvedAddressId}\uFF09\u5728\u8BE5\u65F6\u6BB5\u5DF2\u6709 ${busy.length} \u6761\u5360\u7528\uFF0C\u5DF2\u62E6\u4E0B\u672A\u63D0\u4EA4\u3002`,
1383
+ roomOptions.length > 0 ? `\u5DF2\u6309\u4EBA\u6570/\u5E38\u7528/\u7A7A\u95F2\u7ED9\u51FA ${roomOptions.length} \u4E2A\u66FF\u4EE3\u4F1A\u8BAE\u5BA4\uFF08R1 \u4E3A\u9996\u9009\uFF09\u3002` : "\u8BE5\u65F6\u6BB5\u6CA1\u6709\u53EF\u66FF\u4EE3\u7684\u7A7A\u95F2\u4F1A\u8BAE\u5BA4\uFF0C\u5EFA\u8BAE\u8C03\u6574\u4F1A\u8BAE\u65F6\u95F4\u6216\u6539\u7EBF\u4E0A\u4F1A\u8BAE\uFF08allowNoRoom: true\uFF09\u3002"
1384
+ ]
1385
+ });
1386
+ }
1387
+ if (roomRec) {
1388
+ decisions.roomOptions = roomOptions;
1389
+ decisions.autoRoom = {
1390
+ picked: roomRec.best ? { id: roomRec.best.id, name: roomRec.best.name, score: roomRec.best.score, reasons: roomRec.best.reasons } : null,
1391
+ candidates: roomRec.candidates,
1392
+ meta: roomRec.meta
1393
+ };
1394
+ const autoRoom = args.autoRoom === true;
1395
+ const needRoomPick = !addressInput || !roomConfirmed;
1396
+ let pickOptions = roomOptions;
1397
+ if (addressInput && !roomConfirmed) {
1398
+ const hit = roomOptions.find((item) => String(item.value?.id) === resolvedAddressId);
1399
+ const specified = hit ? { ...hit, label: `${hit.label}\uFF08\u4F60\u6307\u5B9A\u7684\uFF0C\u5F85\u786E\u8BA4\uFF09`, value: { ...hit.value, roomConfirmed: true } } : {
1400
+ key: "R0",
1401
+ label: `${addressDisplay}\uFF08\u4F60\u6307\u5B9A\u7684\uFF0C\u5F85\u786E\u8BA4\uFF09`,
1402
+ value: { ...resolvedAddressId ? { id: resolvedAddressId } : {}, name: addressDisplay, roomConfirmed: true },
1403
+ reason: "\u4F60\u4F20\u5165\u7684\u4F1A\u8BAE\u5BA4\uFF0C\u672A\u63D0\u4EA4\u3001\u672A\u786E\u8BA4"
1404
+ };
1405
+ pickOptions = [specified, ...roomOptions.filter((item) => String(item.value?.id) !== resolvedAddressId)].map((item, index) => ({ ...item, key: `R${index + 1}` }));
1406
+ }
1407
+ if (needRoomPick && !autoRoom && pickOptions.length > 0 && args.allowNoRoom !== true) {
1408
+ return meetingSuccess("meeting.eb.meeting.create.flow.prepare", {
1409
+ status: "NEEDS_SELECTION",
1410
+ selectionType: "room",
1411
+ ui: { component: "choice", multiple: false, recommendedKey: "R1" },
1412
+ message: addressInput ? `\u4F60\u4F20\u5165\u7684\u4F1A\u8BAE\u5BA4\u300C${addressDisplay}\u300D**\u672A\u7ECF\u7528\u6237\u786E\u8BA4**\uFF08\u6CA1\u5E26 roomConfirmed\uFF09\uFF0C\u5DF2\u628A\u5B83\u548C\u5176\u5B83\u5019\u9009\u4E00\u8D77\u5217\u51FA\u6765 \u2014\u2014 \u26D4 \u5FC5\u987B\u8BA9\u7528\u6237\u5728\u9009\u9879\u91CC\u70B9\u9009\uFF0C\u4E0D\u8981\u76F4\u63A5\u63D0\u4EA4` : `\u672A\u6307\u5B9A\u4F1A\u8BAE\u5BA4\uFF0C\u8BF7\u4ECE ${pickOptions.length} \u4E2A\u5019\u9009\u91CC\u9009\u62E9\uFF08\u5DF2\u6309\u4EBA\u6570/\u5E38\u7528/\u65F6\u6BB5\u5360\u7528\u6392\u5E8F\uFF09`,
1413
+ // 固化自动选的流程要带出来:调用方下一轮带 address 重调时不用再猜用的是哪条流程。
1414
+ workflowPending: true,
1415
+ options: pickOptions,
1416
+ recommended: pickOptions[0]?.value ?? null,
1417
+ hint: "\u9009\u5B9A\u540E\u628A value **\u6574\u4F53**\u539F\u6837\u5E26\u56DE\uFF08\u542B roomConfirmed: true\uFF09\uFF1B\u786E\u5B9E\u4E0D\u9700\u8981\u4F1A\u8BAE\u5BA4\u8BF7\u4F20 allowNoRoom: true",
1418
+ ...conflictBrief
1419
+ }, {
1420
+ warnings: [
1421
+ addressInput ? `\u4F1A\u8BAE\u5BA4\u300C${addressDisplay}\u300D\u672A\u7ECF\u7528\u6237\u786E\u8BA4\uFF1A\u672C\u6B21**\u6CA1\u6709**\u63D0\u4EA4\u3002` : "\u672A\u6307\u5B9A\u4F1A\u8BAE\u5BA4\uFF1A\u672C\u6B21**\u6CA1\u6709**\u63D0\u4EA4\uFF0C\u4E5F\u6CA1\u6709\u66FF\u7528\u6237\u6311\u623F\u95F4\u3002",
1422
+ "\u5982\u9700\u76F4\u63A5\u5EFA\u4F1A\u5E76\u6CBF\u7528\u63A8\u8350\uFF0C\u53EF\u4F20 autoRoom: true\uFF1B\u4E0D\u9700\u8981\u4F1A\u8BAE\u5BA4\u5219\u4F20 allowNoRoom: true\u3002",
1423
+ ...earlyWorkflowNote ? [earlyWorkflowNote] : [],
1424
+ ...memberConflicts.length > 0 ? [`\u26A0\uFE0F \u6CE8\u610F\uFF1A\u53C2\u4F1A\u4EBA\u5728\u8BE5\u65F6\u6BB5\u5DF2\u6709 ${memberConflicts.length} \u573A\u4F1A\u8BAE\u51B2\u7A81 \u2014\u2014 \u9009\u623F\u524D\u5148\u628A\u8FD9\u6761\u544A\u8BC9\u7528\u6237\uFF0C\u522B\u8BA9\u4ED6\u9009\u5B8C\u624D\u53D1\u73B0\u3002`] : [],
1425
+ ...freeSlots.length > 0 ? [`\u5F53\u5929\u5168\u90E8\u53C2\u4F1A\u4EBA\u90FD\u7A7A\u95F2\u7684\u65F6\u6BB5\uFF1A${freeSlots.map((s) => `${s.begin.slice(11)}~${s.end.slice(11)}`).join("\u3001")}`] : [],
1426
+ ...failureWarnings
1427
+ ]
1428
+ });
1429
+ }
1430
+ if (addressInput) {
1431
+ } else if (autoRoom && roomRec.best) {
1432
+ addressInput = roomRec.best.id;
1433
+ }
1434
+ }
1435
+ if (enrich && !addressInput && args.allowNoRoom !== true) {
1436
+ decisions.roomUnavailable = {
1437
+ reason: roomRec ? `\u8BE5\u65F6\u6BB5\u6CA1\u6709\u6EE1\u8DB3\u6761\u4EF6\u7684\u7A7A\u95F2\u4F1A\u8BAE\u5BA4\uFF08\u5171 ${roomRec.meta?.roomsTotal ?? 0} \u95F4\uFF0C\u53EF\u7528 ${roomRec.meta?.roomsUsable ?? 0} \u95F4\uFF0C\u88AB\u5360\u7528 ${roomRec.meta?.roomsBusy ?? 0} \u95F4\uFF09` : "\u4F1A\u8BAE\u5BA4\u63A8\u8350\u6CA1\u6709\u8FD4\u56DE\u7ED3\u679C\uFF08\u4F1A\u8BAE\u5BA4\u5217\u8868\u63A5\u53E3\u8BFB\u4E0D\u5230\uFF0C\u6216\u63A8\u8350\u8FC7\u7A0B\u51FA\u9519\uFF09",
1438
+ meta: roomRec?.meta ?? null
1439
+ };
1440
+ return meetingSuccess("meeting.eb.meeting.create.flow.prepare", {
1441
+ status: "NEEDS_SELECTION",
1442
+ selectionType: "room_unavailable",
1443
+ ui: { component: "choice", multiple: false, recommendedKey: "C2" },
1444
+ message: "\u672A\u6307\u5B9A\u4F1A\u8BAE\u5BA4\uFF0C\u4E14\u6309\u4EBA\u6570/\u65F6\u6BB5\u6CA1\u80FD\u63A8\u8350\u51FA\u53EF\u7528\u7684\u7A7A\u95F2\u4F1A\u8BAE\u5BA4\u3002\u8BF7\u8BA9\u7528\u6237\u4ECE\u4E0B\u9762\u4E09\u6761\u91CC\u9009\u4E00\u6761\uFF0C**\u4E0D\u8981**\u76F4\u63A5\u63D0\u4EA4\u4E00\u4E2A\u6CA1\u6709\u5730\u70B9\u7684\u4F1A\u8BAE",
1445
+ workflowPending: true,
1446
+ options: [
1447
+ { key: "C1", label: "\u6211\u6307\u5B9A\u5177\u4F53\u4F1A\u8BAE\u5BA4\uFF08\u8868\u5355\u91CC\u70B9\u9009\uFF0C\u6216\u544A\u8BC9\u6211\u4F1A\u8BAE\u5BA4\u540D\u79F0/id\uFF09", value: { action: "specify" } },
1448
+ { key: "C2", label: "\u6539\u7528\u7EBF\u4E0A\u4F1A\u8BAE\uFF08\u817E\u8BAF\u4F1A\u8BAE/\u89C6\u9891\uFF09", value: { action: "no_room" } },
1449
+ { key: "C3", label: '\u5148\u6309"\u5730\u70B9\u5F85\u5B9A"\u63D0\u4EA4', value: { action: "allow_no_room" } }
1450
+ ],
1451
+ roomUnavailable: decisions.roomUnavailable,
1452
+ ...conflictBrief
1453
+ }, {
1454
+ warnings: [
1455
+ `\u4F1A\u8BAE\u5BA4\u63A8\u8350\u65E0\u7ED3\u679C\uFF1A${String(decisions.roomUnavailable.reason)}\u3002\u672C\u6B21**\u6CA1\u6709\u63D0\u4EA4**\u3002`,
1456
+ "\u786E\u5B9E\u4E0D\u9700\u8981\u4F1A\u8BAE\u5BA4\uFF08\u7EBF\u4E0A\u4F1A\uFF09\u5C31\u5E26 allowNoRoom: true \u91CD\u65B0\u8C03\u7528\uFF1B\u8981\u6307\u5B9A\u623F\u95F4\u5C31\u5E26 address\u3002",
1457
+ ...memberConflicts.length > 0 ? [`\u26A0\uFE0F \u53E6\u5916\uFF1A\u53C2\u4F1A\u4EBA\u5728\u8BE5\u65F6\u6BB5\u5DF2\u6709 ${memberConflicts.length} \u573A\u4F1A\u8BAE\u51B2\u7A81 \u2014\u2014 \u6362\u65F6\u95F4\u53EF\u80FD\u6BD4\u6362\u623F\u95F4\u66F4\u5212\u7B97\u3002`] : [],
1458
+ ...freeSlots.length > 0 ? [`\u5F53\u5929\u5168\u90E8\u53C2\u4F1A\u4EBA\u90FD\u7A7A\u95F2\u7684\u65F6\u6BB5\uFF1A${freeSlots.map((s) => `${s.begin.slice(11)}~${s.end.slice(11)}`).join("\u3001")}`] : [],
1459
+ ...failureWarnings
1460
+ ]
1461
+ });
1462
+ }
1463
+ if (enrich && addressInput && !roomConfirmed && roomOptions.length === 0 && args.allowNoRoom !== true) {
1464
+ const specified = {
1465
+ key: "R1",
1466
+ label: `${addressDisplay}\uFF08\u4F60\u6307\u5B9A\u7684\uFF0C\u5F85\u786E\u8BA4\uFF09`,
1467
+ value: { ...resolvedAddressId ? { id: resolvedAddressId } : {}, name: addressDisplay, roomConfirmed: true },
1468
+ reason: "\u4F60\u4F20\u5165\u7684\u4F1A\u8BAE\u5BA4\uFF0C\u672A\u63D0\u4EA4\u3001\u672A\u786E\u8BA4"
1469
+ };
1470
+ return meetingSuccess("meeting.eb.meeting.create.flow.prepare", {
1471
+ status: "NEEDS_SELECTION",
1472
+ selectionType: "room",
1473
+ ui: { component: "choice", multiple: false, recommendedKey: "R1" },
1474
+ message: "\u4F60\u4F20\u5165\u7684\u4F1A\u8BAE\u5BA4\u672A\u7ECF\u7528\u6237\u786E\u8BA4\uFF0C\u4E14\u672C\u6B21\u6CA1\u80FD\u63A8\u8350\u51FA\u5176\u5B83\u5019\u9009 \u2014\u2014 \u8BF7\u8BA9\u7528\u6237\u786E\u8BA4\u8FD9\u4E00\u95F4\uFF0C\u6216\u6362\u4E00\u95F4 / \u6539\u65F6\u6BB5",
1475
+ workflowPending: true,
1476
+ options: [specified],
1477
+ recommended: specified.value,
1478
+ hint: "\u7528\u6237\u786E\u8BA4\u7528\u8FD9\u95F4\u5C31\u628A value \u539F\u6837\u5E26\u56DE\uFF08\u542B roomConfirmed: true\uFF09"
1479
+ }, {
1480
+ warnings: ["\u4F1A\u8BAE\u5BA4\u672A\u7ECF\u7528\u6237\u786E\u8BA4\uFF0C\u672C\u6B21**\u6CA1\u6709**\u63D0\u4EA4\u3002", ...failureWarnings]
1481
+ });
1482
+ }
1483
+ const resolved = await resolveWorkflowId(env, args);
1484
+ const confirmedAddressId = resolvedAddressId;
1485
+ const confirmedAddressLabel = addressId === "" ? "" : resolvedAddress?.name || String(roomOptions.find((item) => String(item.value?.id ?? "") === confirmedAddressId)?.value?.name ?? "") || addressId;
1486
+ const confirmedWhen = `${beginText}~${String(endText).slice(11) || endText}`;
1487
+ let candidates = resolved.candidates;
1488
+ workflowId = resolved.workflowId;
1489
+ let sourceLabel = resolved.source === "argument" ? "\u8C03\u7528\u65B9\u4F20\u5165" : resolved.source === "fixed" ? `\u56FA\u5316\u914D\u7F6E\uFF08${resolved.label ?? "\u9ED8\u8BA4"}\uFF09` : "\u5E94\u7528\u8BBE\u7F6E\u914D\u7F6E";
1490
+ let probes = [];
1491
+ let loadedForms = /* @__PURE__ */ new Map();
1492
+ const autoPick = shouldAutoPickFlow(args);
1493
+ if (!workflowId && candidates.length > 1) {
1494
+ let probed = await probeWorkflowCandidates(env, candidates);
1495
+ probes = probed.probes;
1496
+ loadedForms = probed.loadedForms;
1497
+ let launchable = probes.filter((probe) => probe.launchable);
1498
+ if (launchable.length === 0 && resolved.source === "fixed") {
1499
+ const settings = await fetchEbAppSettings(env, "meeting.eb.meeting.create.flow.prepare");
1500
+ const fallbackIds = String(settings.mtNewWf ?? "").split(/[,;,;\s]+/).map((item) => item.trim()).filter((item) => item !== "");
1501
+ if (fallbackIds.length > 0) {
1502
+ probed = await probeWorkflowCandidates(env, fallbackIds);
1503
+ probes = probed.probes;
1504
+ loadedForms = probed.loadedForms;
1505
+ candidates = fallbackIds;
1506
+ sourceLabel = "\u5E94\u7528\u8BBE\u7F6E\u914D\u7F6E";
1507
+ launchable = probes.filter((probe) => probe.launchable);
1508
+ }
1509
+ }
1510
+ if (launchable.length === 0) {
1511
+ throw meetingValidationError(
1512
+ "flow_not_launchable",
1513
+ `\u5F53\u524D\u8D26\u53F7**\u6CA1\u6709\u53D1\u8D77\u5EFA\u4F1A\u6D41\u7A0B\u7684\u6743\u9650**\uFF1A${sourceLabel}\u7684 ${candidates.length} \u4E2A\u5EFA\u4F1A\u6D41\u7A0B\u90FD\u53D1\u8D77\u4E0D\u4E86\uFF08\u65E0\u53D1\u8D77\u6743\u9650\u6216\u6D41\u7A0B\u5DF2\u505C\u7528\uFF09\u2014\u2014${probes.map((probe) => `${probe.workflowId}\uFF08${probe.reason ?? "\u4E0D\u53EF\u53D1\u8D77"}\uFF09`).join("\uFF1B")}\u3002\u8BF7\u5982\u5B9E\u544A\u77E5\u7528\u6237\uFF1A\u9700\u8981\u627E\u7BA1\u7406\u5458\u5F00\u901A\u8BE5\u6D41\u7A0B\u7684\u53D1\u8D77\u6743\u9650\uFF0C\u6216\u8BF7\u6709\u6743\u9650\u7684\u540C\u4E8B\u4EE3\u4E3A\u53D1\u8D77\uFF1B**\u4E0D\u8981**\u6539\u7528\u76F4\u8FDE\u5EFA\u4F1A\u7ED5\u8FC7\u6D41\u7A0B\u7BA1\u63A7\u3002`,
1514
+ { probes }
1515
+ );
1516
+ }
1517
+ if (launchable.length > 1 && !autoPick) {
1518
+ const remembered = args.flowChoice === "ask" ? null : await readFlowPick(env).catch(() => null);
1519
+ const rememberedHit = pickRememberedFlow(launchable, remembered);
1520
+ if (rememberedHit) {
1521
+ workflowId = rememberedHit.workflowId;
1522
+ const others = launchable.filter((probe) => probe.workflowId !== rememberedHit.workflowId).map((probe) => probe.name ? `${probe.name}\uFF08${probe.workflowId}\uFF09` : probe.workflowId);
1523
+ flowPickNote = `${sourceLabel}\uFF1A\u5F53\u524D\u8D26\u53F7\u53EF\u53D1\u8D77 ${launchable.length} \u4E2A\u5EFA\u4F1A\u6D41\u7A0B\uFF0C\u5DF2\u6CBF\u7528\u4F60\u4E0A\u6B21\u9009\u7684\u300C${rememberedHit.name ?? rememberedHit.workflowId}\u300D\uFF08${rememberedHit.workflowId}\uFF09\u53D1\u8D77 \u2014\u2014 \u8981\u6362\u7684\u8BDD\u8BF4\u4E00\u58F0${others.length > 0 ? `\uFF08\u5176\u4ED6\u53EF\u7528\uFF1A${others.join("\u3001")}\uFF09` : ""}\u3002`;
1524
+ } else {
1525
+ return meetingSuccess("meeting.eb.meeting.create.flow.prepare", {
1526
+ status: "NEEDS_SELECTION",
1527
+ // ⚠️ 以前漏了这个字段(agent 拿到 undefined 无法判断是哪类选择,2026-10-30 真机发现)。
1528
+ selectionType: "flow",
1529
+ // 明确告诉调用方"这是一道选择题,请用选项控件呈现",不要降级成文本列表
1530
+ // (2026-10-30 用户反馈:agent 把会议室候选写成文本 + "需要你指定一间",没给选项卡)。
1531
+ ui: { component: "choice", multiple: false, recommendedKey: "W1" },
1532
+ // 四要素已经确认到这一步了:摘要一起给出去,用户只需点一下流程,就能直接提交。
1533
+ confirmed: {
1534
+ mt_name: String(args.mt_name ?? ""),
1535
+ begin_datetime: beginText,
1536
+ end_datetime: endText,
1537
+ address: confirmedAddressId || null,
1538
+ addressName: confirmedAddressLabel || null,
1539
+ hrm_members: memberIds
1540
+ },
1541
+ message: `\u4F1A\u8BAE\u8981\u7D20\u5DF2\u786E\u8BA4\uFF08${String(args.mt_name ?? "")} \xB7 ${confirmedWhen}${confirmedAddressLabel ? ` \xB7 ${confirmedAddressLabel}` : " \xB7 \u65E0\u4F1A\u8BAE\u5BA4"}\uFF09\uFF1B\u5F53\u524D\u8D26\u53F7\u5BF9 ${sourceLabel}\u7684 ${candidates.length} \u4E2A\u5EFA\u4F1A\u6D41\u7A0B**\u90FD\u6709\u53D1\u8D77\u6743\u9650**\uFF0C\u8BF7\u8BA9\u7528\u6237\u6700\u540E\u9009\u4E00\u4E0B\u300C\u7528\u54EA\u6761\u6D41\u7A0B\u53D1\u8D77\u300D\u2014\u2014 **\u4E0D\u8981\u9ED8\u8BA4\u53D6\u7B2C\u4E00\u4E2A**\uFF08\u5404\u6D41\u7A0B\u8868\u5355\u5B57\u6BB5\u53EF\u80FD\u5B8C\u5168\u4E0D\u540C\uFF0C\u9009\u9519\u4F1A\u6F0F\u5B57\u6BB5\uFF1B2026-10-29 \u771F\u5B9E\u4E8B\u6545\uFF1A\u53D6\u7B2C\u4E00\u4E2A\u5BFC\u81F4\u5B57\u6BB5\u5168\u586B\u4E0D\u8FDB\u53E6\u4E00\u6761\u6D41\u7A0B\uFF0C\u7528\u6237\u4EE5\u4E3A"\u7CFB\u7EDF\u53EA\u652F\u6301\u4E00\u6761\u6D41\u7A0B"\uFF09\u3002\u26A0\uFE0F \u53EA\u6709\u5176\u4E2D 1 \u4E2A\u6709\u6743\u9650\u65F6 CLI \u4F1A\u76F4\u63A5\u53D1\u8D77\uFF0C\u4E0D\u4F1A\u8D70\u5230\u8FD9\u4E00\u6B65`,
1542
+ options: launchable.map((probe, index) => ({
1543
+ key: `W${index + 1}`,
1544
+ label: probe.name ? `${probe.name}\uFF08${probe.workflowId}\uFF09` : probe.workflowId,
1545
+ // ⛔ 把已确认的四要素一起带回去:用户点选流程后**原样回传 value** 就能直接出确认摘要,
1546
+ // 不用再走一遍时间/房间闸门(否则"先定四要素再选流程"会多出一轮无效往返)。
1547
+ value: {
1548
+ workflowId: probe.workflowId,
1549
+ begin_datetime: beginText,
1550
+ end_datetime: endText,
1551
+ timeConfirmed: true,
1552
+ ...confirmedAddressId ? { address: confirmedAddressId, roomConfirmed: true } : {}
1553
+ },
1554
+ reason: "\u5F53\u524D\u8D26\u53F7\u6709\u53D1\u8D77\u6743\u9650",
1555
+ // 把该流程的字段名如实带出来:不同流程字段差异很大(有的有设备需求/涉密项目,有的没有),
1556
+ // 用户要靠这个才能选对(2026-10-29 用户反馈:选错方式后字段全填不进去)。
1557
+ fields: (loadedForms.get(probe.workflowId)?.fields ?? []).map((f) => f.name).filter(Boolean)
1558
+ })),
1559
+ probes
1560
+ }, {
1561
+ warnings: [
1562
+ `${sourceLabel}\uFF1A\u5171 ${candidates.length} \u4E2A\u5EFA\u4F1A\u6D41\u7A0B\uFF0C\u5176\u4E2D ${launchable.length} \u4E2A\u5F53\u524D\u8D26\u53F7\u53EF\u53D1\u8D77\uFF1B**\u5FC5\u987B\u628A\u8FD9\u51E0\u4E2A\u6D41\u7A0B\u505A\u6210\u9009\u9879\u8BA9\u7528\u6237\u6311\u4E00\u4E2A\uFF0C\u7981\u6B62\u81EA\u5DF1\u66FF\u7528\u6237\u9009**\uFF1B\u9009\u5B9A\u540E\u5E26\u5355\u4E2A workflowId \u91CD\u65B0 prepare\u3002`,
1563
+ ...probes.filter((probe) => !probe.launchable).map((probe) => `\u6D41\u7A0B ${probe.workflowId} \u5F53\u524D\u8D26\u53F7\u65E0\u6CD5\u53D1\u8D77\uFF08${probe.reason ?? "\u65E0\u6743\u9650"}\uFF09\uFF0C\u5DF2\u6392\u9664`)
1564
+ ]
1565
+ });
1566
+ }
1567
+ }
1568
+ if (workflowId === "") workflowId = launchable[0].workflowId;
1569
+ if (launchable.length === 1 && candidates.length > 1 && flowPickNote === null) {
1570
+ const only = launchable[0];
1571
+ flowPickNote = `${sourceLabel}\uFF1A\u5171 ${candidates.length} \u4E2A\u5EFA\u4F1A\u6D41\u7A0B\uFF0C\u5F53\u524D\u8D26\u53F7\u53EA\u6709\u300C${only.name ?? only.workflowId}\u300D\uFF08${only.workflowId}\uFF09\u6709\u53D1\u8D77\u6743\u9650\uFF0C\u5DF2\u76F4\u63A5\u7528\u5B83\u53D1\u8D77`;
1572
+ }
1573
+ if (launchable.length > 1 && flowPickNote === null) {
1574
+ const picked2 = launchable[0];
1575
+ const others = launchable.slice(1).map((probe) => probe.name ? `${probe.name}\uFF08${probe.workflowId}\uFF09` : probe.workflowId);
1576
+ flowPickNote = `${sourceLabel}\uFF1A\u5171 ${candidates.length} \u4E2A\u5EFA\u4F1A\u6D41\u7A0B\uFF0C\u5F53\u524D\u8D26\u53F7\u53EF\u53D1\u8D77 ${launchable.length} \u4E2A\uFF0C\u5DF2\u6309\u4F18\u5148\u7EA7\u81EA\u52A8\u9009\u7528\u300C${picked2.name ?? picked2.workflowId}\u300D\uFF08${picked2.workflowId}\uFF09\uFF1B\u5176\u4ED6\u53EF\u7528\u6D41\u7A0B\uFF1A${others.join("\u3001")} \u2014\u2014 \u8981\u7528\u5B83\u4EEC\u8BF7\u663E\u5F0F\u4F20 workflowId\u3002`;
1577
+ }
1578
+ }
1579
+ let form = loadedForms.get(workflowId);
1580
+ if (!form) {
1581
+ try {
1582
+ form = await loadCreateForm(env, workflowId);
1583
+ } catch (error) {
1584
+ throw meetingValidationError(
1585
+ "flow_not_launchable",
1586
+ `\u5F53\u524D\u8D26\u53F7**\u6CA1\u6709\u53D1\u8D77\u5EFA\u4F1A\u6D41\u7A0B\u7684\u6743\u9650**\uFF08\u6216\u6D41\u7A0B\u5DF2\u505C\u7528\uFF09\uFF1A\u5EFA\u4F1A\u6D41\u7A0B ${workflowId} \u7684\u8868\u5355\u8F7D\u5165\u5931\u8D25 \u2014\u2014 ${String(error?.message ?? error).slice(0, 200)}\u3002\u8BF7\u5982\u5B9E\u544A\u77E5\u7528\u6237\uFF1A\u9700\u8981\u627E\u7BA1\u7406\u5458\u5F00\u901A\u8BE5\u6D41\u7A0B\u7684\u53D1\u8D77\u6743\u9650\uFF0C\u6216\u8BF7\u6709\u6743\u9650\u7684\u540C\u4E8B\u4EE3\u4E3A\u53D1\u8D77\uFF1B**\u4E0D\u8981**\u6539\u7528\u76F4\u8FDE\u5EFA\u4F1A\u7ED5\u8FC7\u6D41\u7A0B\u7BA1\u63A7\u3002`,
1587
+ { workflowId }
1588
+ );
1589
+ }
1590
+ }
1591
+ if (!form.continuation) {
1592
+ throw meetingValidationError("flow_context_missing", "\u5EFA\u4F1A\u6D41\u7A0B\u8868\u5355\u6CA1\u6709\u8FD4\u56DE continuation\uFF0C\u65E0\u6CD5\u7EE7\u7EED\u63D0\u4EA4");
1593
+ }
1594
+ decisions.timings = timings;
1595
+ const crmMemberCount = (() => {
1596
+ if (args.crm_member_count !== void 0 && args.crm_member_count !== "") return args.crm_member_count;
1597
+ const raw = args.crm_members;
1598
+ if (raw === void 0 || raw === null || raw === "") return void 0;
1599
+ if (Array.isArray(raw)) return raw.length > 0 ? raw.length : void 0;
1600
+ const text = String(raw).trim();
1601
+ if (!text) return void 0;
1602
+ const count = text.split(/[,;,;]+/).map((item) => item.trim()).filter((item) => item !== "").length;
1603
+ return count > 0 ? count : void 0;
1604
+ })();
1605
+ const shaped = await shapeBrowserValues(env, {
1606
+ mt_name: args.mt_name,
1607
+ // ⛔ 2026-11-05 修:用户只说「明天下午」时,时间是 CLI 按 time_slot 展开出来的(beginText/endText),
1608
+ // 原始入参 args.begin_datetime 是空的 —— 以前这里直接取 args,表单两个时间字段就空着,
1609
+ // 页面打开后默认成"当前时间"(用户实测:填 11-06 13:00–18:00,表单显示 11-05 17:25)。
1610
+ begin_datetime: beginText || args.begin_datetime,
1611
+ end_datetime: endText || args.end_datetime,
1612
+ mt_desc: args.mt_desc,
1613
+ address: addressInput,
1614
+ customize_address: args.customize_address,
1615
+ hrm_members: args.hrm_members,
1616
+ total_member: args.total_member,
1617
+ crm_members: args.crm_members,
1618
+ ...crmMemberCount === void 0 ? {} : { crm_member_count: crmMemberCount },
1619
+ caller: args.caller,
1620
+ contacter: args.contacter,
1621
+ other_remark: args.other_remark,
1622
+ mt_type: args.mt_type,
1623
+ ...args.extraFields && typeof args.extraFields === "object" && !Array.isArray(args.extraFields) ? args.extraFields : {}
1624
+ });
1625
+ const preferredFields = await readFlowFieldMap(env, workflowId);
1626
+ const { main, mapped, unmapped, resolved: resolvedFields } = mapFields(form.fields, shaped.values, preferredFields);
1627
+ await writeFlowFieldMap(env, workflowId, form.workflowName, resolvedFields);
1628
+ const warnings = [];
1629
+ if (autoFilledPerson.length > 0) {
1630
+ const labels = autoFilledPerson.map((one) => `\u300C${PERSON_FIELD_LABELS[one.field]}\u300D`).join("");
1631
+ warnings.push(
1632
+ `${labels}\u6CA1\u6709\u4F20\u503C\uFF0C\u5DF2\u6309**\u5F53\u524D\u767B\u5F55\u4EBA**\u8865\u9F50\uFF1A${autoFilledPerson[0].name}\uFF08${autoFilledPerson[0].id}\uFF09\u3002\u8981\u6362\u6210\u522B\u4EBA\uFF08\u4F8B\u5982\u66FF\u4ED6\u4EBA\u5EFA\u4F1A\u3001\u6307\u5B9A\u522B\u7684\u8054\u7CFB\u4EBA\uFF09\u8BF7\u663E\u5F0F\u4F20 caller / contacter\u3002`
1633
+ );
1634
+ } else if (selfPersonWarning) {
1635
+ warnings.push(selfPersonWarning);
1636
+ }
1637
+ if (flowPickNote) warnings.push(flowPickNote);
1638
+ for (const note of shaped.notes) warnings.push(note);
1639
+ const crmMentioned = detectCrmMentionInText(args.mt_name, args.mt_desc, args.other_remark);
1640
+ if (crmMentioned && !args.crm_members) {
1641
+ const hasCrmField = form.fields.some((field) => /参会客户/.test(String(field?.label ?? field?.name ?? field?.fieldName ?? "")));
1642
+ warnings.push(
1643
+ `\u4F1A\u8BAE\u540D\u79F0/\u5185\u5BB9\u91CC\u63D0\u5230\u5BA2\u6237\u300C${crmMentioned}\u300D\uFF0C\u4F46\u672C\u6B21\u6CA1\u4F20 crm_members` + (hasCrmField ? `\uFF0C\u8BE5\u6D41\u7A0B\u8868\u5355**\u6709\u300C\u53C2\u4F1A\u5BA2\u6237\u300D\u5B57\u6BB5\uFF0C\u73B0\u5728\u4F1A\u662F\u7A7A\u7684**\u3002\u8BF7\u5148 meeting.eb.crm.search {"keyword":"${crmMentioned}"} \u62FF items[].customerId\uFF0C\u518D\u7528 crm_members:[{id,name}] \u91CD\u65B0\u63D0\u4EA4\uFF08\u5FC5\u987B\u5E26\u5BA2\u6237\u540D\u79F0\uFF09\u3002` : "\uFF08\u8BE5\u6D41\u7A0B\u8868\u5355\u91CC\u6CA1\u6709\u300C\u53C2\u4F1A\u5BA2\u6237\u300D\u5B57\u6BB5\uFF0C\u672C\u6761\u53EF\u5FFD\u7565\uFF09\u3002")
1644
+ );
1645
+ }
1646
+ const crmMembersGiven = Array.isArray(args.crm_members) ? args.crm_members.length > 0 : String(args.crm_members ?? "").trim() !== "";
1647
+ if (crmMembersGiven) {
1648
+ const crmFieldId = String(resolvedFields.crm_members ?? "").trim();
1649
+ const crmField = form.fields.find((field) => String(field?.id ?? "") === crmFieldId);
1650
+ const componentKey = String(crmField?.componentKey ?? "").toLowerCase();
1651
+ if (crmField && componentKey !== "" && componentKey !== "customer" && componentKey !== "customercomponent") {
1652
+ warnings.push(
1653
+ `\u300C\u53C2\u4F1A\u5BA2\u6237\u300D\u5B57\u6BB5\uFF08${crmFieldId}\uFF09\u662F ${crmField.componentKey} \u7EC4\u4EF6\uFF1A\u5BA2\u6237 id \u4E0E\u540D\u79F0\u7167\u5E38\u5199\u8FDB\u6D41\u7A0B\u5355\u636E\uFF0C\u518D\u7531 ESB \u7684\u5B57\u6BB5\u6620\u5C04\u540C\u6B65\u5230\u4F1A\u8BAE\u8868 \u2014\u2014 \u6B63\u5E38\u914D\u7F6E\uFF0C\u4E0D\u9700\u8981\u6539\u8868\u5355\u3002`
1654
+ );
1655
+ }
1656
+ }
1657
+ const providedCrmDetailRows = normalizeCrmDetailRows(args.crm_member_details);
1658
+ const onlyDetailMode = String(args.crm_detail_mode ?? "").trim().toLowerCase() === "only";
1659
+ let crmDetailRows = onlyDetailMode ? providedCrmDetailRows : [];
1660
+ if (crmMembersGiven && !onlyDetailMode) {
1661
+ const detailTarget = resolveCrmDetailTarget(form.fields);
1662
+ if (detailTarget) {
1663
+ const auto = await resolveAutoCrmDetailRows(env, shaped.values.crm_members ?? args.crm_members);
1664
+ if (auto.rows.length > 0) {
1665
+ crmDetailRows = auto.rows;
1666
+ if (providedCrmDetailRows.length > 0) {
1667
+ const byName = new Map(providedCrmDetailRows.map((row) => [String(row.xm ?? "").trim(), row]));
1668
+ crmDetailRows = crmDetailRows.map((row) => {
1669
+ const given = byName.get(String(row.xm ?? "").trim());
1670
+ if (!given) return row;
1671
+ const merged = { ...row };
1672
+ for (const [key, value] of Object.entries(given)) {
1673
+ if (String(value ?? "").trim() !== "") merged[key] = String(value);
1674
+ }
1675
+ return merged;
1676
+ });
1677
+ }
1678
+ warnings.push(
1679
+ `\u5DF2\u81EA\u52A8\u628A\u300C${auto.customers.join("\u3001")}\u300D\u7684 ${auto.rows.length} \u4F4D\u8054\u7CFB\u4EBA\u5199\u8FDB\u300C\u53C2\u4F1A\u5BA2\u6237\u660E\u7EC6\u300D\uFF1A${auto.rows.map((row) => `${row.xm}${row.sjhm ? ` ${row.sjhm}` : ""}`).join("\u3001")}\uFF08\u660E\u7EC6\u8868\u672C\u6765\u5C31\u4E00\u4EBA\u4E00\u884C\uFF0C\u4E0D\u9700\u8981\u8BA9\u7528\u6237\u6311\uFF09\u3002\u786E\u5B9E\u53EA\u60F3\u8981\u5176\u4E2D\u51E0\u4F4D\u65F6\uFF0C\u4F20 crm_detail_mode:"only" \u518D\u914D crm_member_details \u624D\u8986\u76D6\u672C\u6B21\u81EA\u52A8\u5E26\u5165\u3002`
1680
+ );
1681
+ } else if (auto.missing.length > 0) {
1682
+ warnings.push(
1683
+ `\u5DF2\u5199\u300C\u53C2\u4F1A\u5BA2\u6237\u300D\uFF0C\u4F46\u6CA1\u80FD\u81EA\u52A8\u5E26\u51FA\u300C${auto.missing.join("\u3001")}\u300D\u7684\u8054\u7CFB\u4EBA\uFF08CRM \u91CC\u6CA1\u5EFA\u6863\u8054\u7CFB\u4EBA\uFF09\u3002`
1684
+ // ⛔ 2026-11-05 用户明确:**没有联系人不用问**。建会和邀请函都不依赖客户联系人,
1685
+ // 以前这句提示在引导模型回头问「补充联系人姓名手机号」,属于多余的一轮。
1686
+ // 用户真给了联系人时才会传 crm_member_details,这里不要主动要。
1687
+ );
1688
+ }
1689
+ }
1690
+ }
1691
+ let detailPayload;
1692
+ if (crmDetailRows.length > 0) {
1693
+ const target = resolveCrmDetailTarget(form.fields);
1694
+ if (!target) {
1695
+ warnings.push(
1696
+ `\u4F20\u4E86 crm_member_details\uFF08${crmDetailRows.length} \u884C\uFF09\uFF0C\u4F46\u8BE5\u5EFA\u4F1A\u6D41\u7A0B\u7684**\u53D1\u8D77\u8282\u70B9\u8868\u5355\u91CC\u6CA1\u6709\u300C\u53C2\u4F1A\u5BA2\u6237\u660E\u7EC6\u300D\u660E\u7EC6\u8868**\uFF08\u6216\u5B83\u88AB\u6446\u5728\u9690\u85CF\u884C\u4E0A\uFF09\uFF0C\u660E\u7EC6\u65E0\u6CD5\u5199\u5165\uFF0C\u5DF2\u5FFD\u7565\u8FD9\u4E9B\u884C\uFF1B\u4E3B\u8868\u7684\u300C\u53C2\u4F1A\u5BA2\u6237\u300D\u7167\u5E38\u5199\u5165\u3002`
1697
+ );
1698
+ } else {
1699
+ detailPayload = {
1700
+ [target.subFormId]: crmDetailRows.map((row) => {
1701
+ const line = {};
1702
+ for (const [semantic, fieldId] of Object.entries(target.columns)) {
1703
+ const value = row[semantic];
1704
+ if (value !== void 0 && value !== "") line[fieldId] = value;
1705
+ }
1706
+ return line;
1707
+ })
1708
+ };
1709
+ warnings.push(
1710
+ `\u53C2\u4F1A\u5BA2\u6237\u660E\u7EC6\uFF1A${crmDetailRows.length} \u884C\u5199\u5165\u660E\u7EC6\u8868 ${target.subFormId}\uFF08\u5217\uFF1A${Object.values(target.labels).join("/")}\uFF09`
1711
+ );
1712
+ }
1713
+ }
1714
+ if (args.fieldValues && typeof args.fieldValues === "object" && !Array.isArray(args.fieldValues)) {
1715
+ const knownIds = new Set(form.fields.map((field) => field.id));
1716
+ for (const [fieldId, raw] of Object.entries(args.fieldValues)) {
1717
+ if (raw === void 0 || raw === null || raw === "") continue;
1718
+ if (!knownIds.has(fieldId)) {
1719
+ warnings.push(`fieldValues \u91CC\u7684 datakey\u300C${fieldId}\u300D\u4E0D\u5728\u8BE5\u6D41\u7A0B\u8868\u5355\u91CC\uFF0C\u5DF2\u5FFD\u7565\uFF08\u5148\u7528 prepare \u4E0D\u5E26 fieldValues \u8DD1\u4E00\u6B21\uFF0C\u770B unmapped/\u8868\u5355\u5B57\u6BB5\u6E05\u5355\uFF09`);
1720
+ continue;
1721
+ }
1722
+ main[fieldId] = raw;
1723
+ mapped[`datakey:${fieldId}`] = fieldId;
1724
+ }
1725
+ }
1726
+ if (enrichFailures.length > 0) {
1727
+ decisions.enrichFailures = enrichFailures;
1728
+ for (const failure of enrichFailures) {
1729
+ warnings.push(`\u26A0\uFE0F ${failure} \u2014\u2014 **\u8FD9\u4E0D\u4EE3\u8868\u6CA1\u6709\u51B2\u7A81**\uFF0C\u8BF7\u5982\u5B9E\u544A\u77E5\u7528\u6237\u8BE5\u9879\u672A\u6838\u9A8C\uFF0C\u4E0D\u8981\u58F0\u79F0"\u65F6\u95F4\u5DF2\u786E\u8BA4\u7A7A\u95F2"`);
1730
+ }
1731
+ }
1732
+ const picked = decisions.autoRoom?.picked;
1733
+ if (picked && !hadAddressInput) {
1734
+ warnings.push(
1735
+ `\u672A\u6307\u5B9A\u4F1A\u8BAE\u5BA4 \u2192 \u5DF2\u81EA\u52A8\u9009\u62E9\u300C${picked.name}\u300D\uFF08${(picked.reasons ?? []).join("\uFF1B")}\uFF09\uFF1B\u53E6\u6709\u5019\u9009 ${(decisions.roomOptions ?? []).slice(1).map((item) => item.label).join(" / ") || "\u65E0"}`
1736
+ );
1737
+ }
1738
+ const slotOptions = decisions.slotOptions ?? [];
1739
+ const memberConflictCount = decisions.memberConflicts?.length ?? 0;
1740
+ if (memberConflictCount > 0 && slotOptions.length > 0) {
1741
+ warnings.push(
1742
+ `\u53C2\u4F1A\u4EBA\u65F6\u95F4\u6709\u51B2\u7A81\uFF08${memberConflictCount} \u6761\u5360\u7528\uFF09\uFF1B\u5F53\u5929\u6240\u6709\u4EBA\u90FD\u7A7A\u7684\u65F6\u6BB5\uFF1A` + slotOptions.map((item) => `[${item.key}] ${item.label}`).join("\uFF1B") + "\u2014\u2014\u8BF7\u7528\u9009\u9879\u65B9\u5F0F\u8BA9\u7528\u6237\u6311\uFF08\u9009\u5B9A\u540E\u91CD\u65B0 prepare \u5E76\u6539\u65F6\u95F4\uFF09\u3002"
1743
+ );
1744
+ } else if (memberConflictCount === 0 && slotOptions.length > 0) {
1745
+ warnings.push(
1746
+ `\u8BE5\u65F6\u6BB5\u53C2\u4F1A\u4EBA\u6CA1\u6709\u4F1A\u8BAE/\u65E5\u7A0B\u5360\u7528\uFF08\u5DF2\u6838\u5BF9\u4F1A\u8BAE\u56DE\u6267\u4E0E\u65E5\u7A0B\uFF09\u3002\u5F53\u5929\u5176\u4ED6\u5171\u540C\u7A7A\u95F2\u65F6\u6BB5\uFF1A${slotOptions.map((item) => `[${item.key}] ${item.label}`).join("\uFF1B")}`
1747
+ );
1748
+ } else if (decisions.dayBlocked?.summary) {
1749
+ warnings.push(String(decisions.dayBlocked.summary));
1750
+ }
1751
+ const unmappedReal = unmapped.filter((name) => name !== "mt_name" && name !== "crm_member_count");
1752
+ if (unmappedReal.length > 0) {
1753
+ warnings.push(
1754
+ `\u4EE5\u4E0B\u5B57\u6BB5\u6CA1\u6709\u5728\u5EFA\u4F1A\u6D41\u7A0B\u8868\u5355\u91CC\u627E\u5230\u540C\u540D\u5B57\u6BB5\uFF0C\u672A\u81EA\u52A8\u586B\u5199\uFF1A${unmappedReal.join("\u3001")}\uFF08\u8868\u5355\u73B0\u6709\u5B57\u6BB5\uFF1A${form.fields.map((field) => field.name).join("\u3001")}\uFF09`
1755
+ );
1756
+ }
1757
+ if (!main[form.fields.find((field) => field.name === "\u4F1A\u8BAE\u540D\u79F0")?.id ?? ""] && !mapped.mt_name) {
1758
+ warnings.push(
1759
+ "\u8BE5\u5EFA\u4F1A\u6D41\u7A0B\u7684\u8868\u5355\u6CA1\u6709\u300C\u4F1A\u8BAE\u540D\u79F0\u300D\u5B57\u6BB5\uFF08\u90E8\u5206\u6D41\u7A0B\u7528\u6D41\u7A0B\u6807\u9898\u4EE3\u66FF\u4F1A\u8BAE\u540D\u79F0\uFF0C\u5C5E\u6B63\u5E38\u914D\u7F6E\uFF0C\u4E0D\u662F\u6D41\u7A0B\u914D\u9519\uFF09\u3002\u5982\u9700\u4F1A\u8BAE\u540D\u79F0\u72EC\u7ACB\u6210\u5B57\u6BB5\uFF0C\u8BF7\u6539\u9009\u5E26\u8BE5\u5B57\u6BB5\u7684\u6D41\u7A0B\uFF08\u5982\u300C\u4F1A\u8BAE\u7533\u8BF7\u6D41\u7A0B\uFF08NEW\uFF09\u300D\uFF09\u3002"
1760
+ );
1761
+ }
1762
+ const crmPatchIds = (Array.isArray(shaped.values.crm_members) ? shaped.values.crm_members : []).map((row) => String(row?.id ?? "").trim()).filter((id) => id !== "");
1763
+ const groupMemberIds = (Array.isArray(shaped.values.hrm_members) ? shaped.values.hrm_members : []).map((one) => String(one?.id ?? one ?? "").trim()).filter((id) => id !== "");
1764
+ const session = await env.host.getSession();
1765
+ const continuation = await env.continuation.issue(
1766
+ {
1767
+ operation: "meeting.eb.meeting.create.flow.apply",
1768
+ baseUrl: session.baseUrl,
1769
+ profile: session.profile,
1770
+ userId: session.userId,
1771
+ payload: {
1772
+ workflowId,
1773
+ requestName: String(args.mt_name ?? args.mt_subject ?? ""),
1774
+ mtName: String(args.mt_name ?? args.mt_subject ?? ""),
1775
+ workflowName: String(form.workflowName ?? ""),
1776
+ data: { main, ...detailPayload ? { details: detailPayload } : {} },
1777
+ surfaceContinuation: form.continuation,
1778
+ // 供 apply 在「会议还没生成」时按申请单信息预生成邀请函(预置函)
1779
+ invitationFields: shaped.readable,
1780
+ // 提交后回显要用「字段名 → 值」,字段清单先存下来(apply 阶段拿不到 createForm 结果)
1781
+ fieldLabels: form.fields.map((field) => ({ id: String(field.id), name: String(field.name) })),
1782
+ // 已确认的「人员 id → 姓名」,供 apply 回显时把裸 id 换成姓名
1783
+ ...autoFilledPerson.length > 0 ? { personLabels: Object.fromEntries(autoFilledPerson.map((one) => [one.id, one.name])) } : {},
1784
+ // 会议记录的客户要靠 apply 补写(表单「参会客户」是 Ebuilder,单据↔会议表不同步)
1785
+ ...crmPatchIds.length > 0 ? { crmPatch: { ids: crmPatchIds, count: crmMemberCount === void 0 ? crmPatchIds.length : crmMemberCount } } : {},
1786
+ // 建群要素:apply 拿到会议 id 后先建群、再把群 id 回写 imchat_groupid
1787
+ groupChat: {
1788
+ memberIds: groupMemberIds,
1789
+ // ⛔ 2026-11-04 修:用户只说"明天上午"(time_slot)时,begin_datetime 是 CLI 展开出来的,
1790
+ // `shaped.values` 里**没有**这个键 —— 直接取会得到空串,群消息里"开始时间/结束时间"就空着。
1791
+ // 这里统一用展开后的 beginText/endText。
1792
+ beginDatetime: beginText,
1793
+ endDatetime: endText,
1794
+ // ⛔ 2026-11-04 修:shaped.address 在这之前已被解析成 `{id,name}` 对象,
1795
+ // 直接 String() 会变成 "[object Object]" 打进群消息(用户实测看到的就是这个)。
1796
+ // 群消息要的是人话名称,这里优先取 name。
1797
+ address: (() => {
1798
+ const value = shaped.values.address;
1799
+ if (value && typeof value === "object") return String(value.name ?? value.id ?? "");
1800
+ return String(value ?? "");
1801
+ })()
1802
+ }
1803
+ },
1804
+ fingerprint: JSON.stringify({ workflowId, main, ...detailPayload ? { details: detailPayload } : {} })
1805
+ },
1806
+ CONTINUATION_TTL_MS
1807
+ );
1808
+ return meetingSuccess(
1809
+ "meeting.eb.meeting.create.flow.prepare",
1810
+ {
1811
+ status: "AWAITING_CONFIRMATION",
1812
+ preview: {
1813
+ workflowId,
1814
+ workflowCandidates: candidates,
1815
+ ...probes.length > 0 ? { workflowProbes: probes } : {},
1816
+ ...flowPickNote ? { workflowAutoPicked: { workflowId, source: resolved.source, note: flowPickNote } } : {},
1817
+ requestName: String(args.mt_name ?? args.mt_subject ?? ""),
1818
+ fieldMapping: mapped,
1819
+ formData: { main },
1820
+ // 人话版「即将提交的内容」—— 提交前必须先贴给用户核对(见 SKILL 建会章节)。
1821
+ formPreview: renderFormPreview(
1822
+ form.fields,
1823
+ await decoratePreviewPersonNames(
1824
+ env,
1825
+ main,
1826
+ form.fields,
1827
+ new Map(autoFilledPerson.map((one) => [one.id, one.name]))
1828
+ )
1829
+ ),
1830
+ // 召集人/联系人是不是"替用户默认填的"要说清楚,用户才知道能不能改。
1831
+ ...autoFilledPerson.length > 0 ? {
1832
+ autoFilled: Object.fromEntries(
1833
+ autoFilledPerson.map((one) => [PERSON_FIELD_LABELS[one.field], `${one.name}(${one.id})`])
1834
+ )
1835
+ } : {},
1836
+ ...detailPayload ? { detailRows: { subFormId: Object.keys(detailPayload)[0], count: crmDetailRows.length, rows: crmDetailRows } } : {},
1837
+ formFieldCount: form.fields.length,
1838
+ ...Object.keys(decisions).length > 0 ? { decisions } : {}
1839
+ },
1840
+ continuation,
1841
+ expiresInSeconds: CONTINUATION_TTL_SECONDS
1842
+ },
1843
+ warnings.length > 0 ? { warnings } : {}
1844
+ );
1845
+ }
1846
+ };
1847
+ var CRM_PATCH_SETTLE_MS = [4e3, 6e3];
1848
+ async function patchMeetingCrmMembers(env, meetingId, ids, count, settleMsList = CRM_PATCH_SETTLE_MS) {
1849
+ const list = ids.map((id) => String(id ?? "").trim()).filter((id) => id !== "");
1850
+ if (String(meetingId).trim() === "" || list.length === 0) {
1851
+ return { ok: false, error: "\u6CA1\u6709\u4F1A\u8BAE id \u6216\u5BA2\u6237 id" };
1852
+ }
1853
+ const mainTable = {
1854
+ id: String(meetingId).trim(),
1855
+ operate_type: "UPDATE",
1856
+ crm_members: list.join(",")
1857
+ };
1858
+ const total = Number(count);
1859
+ if (Number.isFinite(total) && total > 0) mainTable.crm_total_member = String(total);
1860
+ const write = async () => {
1861
+ const session = await env.host.getSession();
1862
+ await env.host.request({
1863
+ method: "POST",
1864
+ path: `${EB_BASE}/updateFormData/change_meeting`,
1865
+ query: { id: String(meetingId).trim() },
1866
+ operation: "meeting.eb.meeting.create.flow.apply",
1867
+ body: writeBody(String(session.userId), { mainTable, details: {}, operateType: {} }),
1868
+ acceptBusiness: ebBusinessSuccess
1869
+ });
1870
+ };
1871
+ const readBack = async () => {
1872
+ const { getMeetingOperation } = await import("./registry-IM5G23LS.js");
1873
+ const detail = getMeetingOperation("meeting.eb.meeting.detail");
1874
+ const read = await detail.handler({ id: String(meetingId).trim() }, env);
1875
+ return String(read?.data?.data?.crm_members ?? "").trim();
1876
+ };
1877
+ let lastError = "";
1878
+ for (const settleMs of settleMsList) {
1879
+ try {
1880
+ await write();
1881
+ } catch (error) {
1882
+ return { ok: false, error: String(error?.message ?? error).slice(0, 160) };
1883
+ }
1884
+ await new Promise((resolve2) => setTimeout(resolve2, settleMs));
1885
+ try {
1886
+ const value = await readBack();
1887
+ if (value !== "") return { ok: true, value };
1888
+ lastError = "\u8865\u5199\u540E\u56DE\u8BFB crm_members \u4ECD\u4E3A\u7A7A\uFF08\u591A\u534A\u88AB\u4F1A\u8BAE\u521D\u59CB\u5316\u7684\u540E\u7EED\u5199\u5165\u8986\u76D6\u4E86\uFF09";
1889
+ } catch (error) {
1890
+ lastError = `\u8865\u5199\u6210\u529F\u4F46\u56DE\u8BFB\u5931\u8D25\uFF1A${String(error?.message ?? error).slice(0, 120)}`;
1891
+ }
1892
+ }
1893
+ return { ok: false, error: lastError };
1894
+ }
1895
+ async function renderPreInvitation(payload, env) {
1896
+ const fields = payload?.invitationFields ?? {};
1897
+ const started = Date.now();
1898
+ try {
1899
+ const { getMeetingOperation } = await import("./registry-IM5G23LS.js");
1900
+ const render = getMeetingOperation("meeting.invitation.render");
1901
+ const rendered = await render.handler(
1902
+ {
1903
+ mt_name: String(fields.mt_name ?? payload?.mtName ?? "").trim(),
1904
+ begin_datetime: String(fields.begin_datetime ?? "").trim(),
1905
+ end_datetime: String(fields.end_datetime ?? "").trim(),
1906
+ address: String(fields.address ?? fields.customize_address ?? "").trim(),
1907
+ hrm_members: String(fields.hrm_members ?? "").trim(),
1908
+ mt_desc: String(fields.mt_desc ?? "").trim(),
1909
+ org_members: String(fields.org_members ?? "").trim(),
1910
+ caller: String(fields.caller ?? "").trim(),
1911
+ contacter: String(fields.contacter ?? "").trim(),
1912
+ total_member: String(fields.total_member ?? "").trim(),
1913
+ // 客户单位(邀请函开头「尊敬的 XXX」):建会时填了参会客户就直接带过去,
1914
+ // 否则整句永远是【待补充】—— 用户看到的就是"客户明明填了,邀请函里却没有"。
1915
+ extra: { guest_org: String(fields.crm_members ?? "").trim() }
1916
+ },
1917
+ env
1918
+ );
1919
+ return {
1920
+ invitation: { pending: true, preRendered: true, ...rendered?.data ?? {} },
1921
+ ms: Date.now() - started
1922
+ };
1923
+ } catch (error) {
1924
+ return {
1925
+ invitation: {
1926
+ pending: true,
1927
+ preRendered: false,
1928
+ ok: false,
1929
+ error: String(error?.message ?? error).slice(0, 200)
1930
+ },
1931
+ ms: Date.now() - started
1932
+ };
1933
+ }
1934
+ }
1935
+ var ebMeetingCreateFlowApply = {
1936
+ name: "meeting.eb.meeting.create.flow.apply",
1937
+ resource: "eb",
1938
+ method: "meeting.eb.meeting.create.flow.apply",
1939
+ action: "meeting.eb.meeting.create.flow.apply",
1940
+ summary: "\u6D41\u7A0B\u5EFA\u4F1A\uFF08\u63D0\u4EA4\uFF09\uFF1A\u7528\u786E\u8BA4\u7968\u636E\u63D0\u4EA4\u5EFA\u4F1A\u6D41\u7A0B\uFF1B\u63D0\u4EA4\u540E\u8F6E\u8BE2\u4F1A\u8BAE\u5217\u8868\u786E\u8BA4\u4F1A\u8BAE\u662F\u5426\u5DF2\u751F\u6210\uFF0C\u751F\u6210\u5219\u81EA\u52A8\u51FA\u9080\u8BF7\u51FD",
1941
+ capability: "eb.meeting",
1942
+ risk: "high-risk-write",
1943
+ requiresConfirmation: true,
1944
+ inputSchema: schemaOf(
1945
+ {
1946
+ continuation: { type: "string", description: "prepare \u8FD4\u56DE\u7684\u786E\u8BA4\u7968\u636E\uFF08\u5FC5\u586B\uFF09" },
1947
+ confirm: { type: "boolean", description: "\u5FC5\u987B\u663E\u5F0F\u4F20 true" },
1948
+ submit_mode: {
1949
+ type: "string",
1950
+ enum: ["direct", "browser"],
1951
+ description: '\u63D0\u4EA4\u65B9\u5F0F\uFF0C\u9ED8\u8BA4 browser\uFF1A\u5728\u5C0Fe \u91CC**\u5F39\u51FA\u6D41\u7A0B\u8868\u5355**\uFF0C\u5B57\u6BB5\u5DF2\u9884\u586B\uFF0C\u7528\u6237\u6838\u5BF9/\u4FEE\u6539\u540E\u81EA\u5DF1\u70B9\u63D0\u4EA4\u3002direct = \u76F4\u63A5\u5199\u670D\u52A1\u7AEF\uFF08\u4F1A\u8BAE\u5F53\u573A\u751F\u6210\u3001\u9080\u8BF7\u51FD\u7528\u771F\u5B9E\u6570\u636E\uFF0C\u4F46\u6CA1\u6709\u4EBA\u5DE5\u6838\u5BF9\u8868\u5355\u8FD9\u4E00\u6B65\uFF09\uFF1B\u53EA\u6709\u7528\u6237\u660E\u786E\u8BF4"\u4E0D\u7528\u6211\u786E\u8BA4\uFF0C\u76F4\u63A5\u5EFA"\u65F6\u624D\u4F20 direct'
1952
+ },
1953
+ waitSeconds: { type: "number", description: "\u63D0\u4EA4\u540E\u7B49\u5F85\u4F1A\u8BAE\u751F\u6210\u7684\u6700\u957F\u79D2\u6570\uFF08\u9ED8\u8BA4 60\uFF0C0 = \u4E0D\u7B49\u5F85\uFF09" }
1954
+ },
1955
+ { required: ["continuation", "confirm"] }
1956
+ ),
1957
+ handler: async (args, env) => {
1958
+ if (args.confirm !== true) {
1959
+ throw meetingValidationError("confirmation_required", "\u6D41\u7A0B\u5EFA\u4F1A\u5C5E\u4E8E\u9AD8\u5F71\u54CD\u5199\u64CD\u4F5C\uFF0C\u5FC5\u987B\u663E\u5F0F\u4F20 confirm=true");
1960
+ }
1961
+ const lease = await env.continuation.verify(
1962
+ String(args.continuation ?? ""),
1963
+ "meeting.eb.meeting.create.flow.apply"
1964
+ );
1965
+ const session = await env.host.getSession();
1966
+ if (lease.baseUrl !== session.baseUrl || lease.userId !== session.userId) {
1967
+ throw meetingValidationError("context_mismatch", "\u786E\u8BA4\u4E0A\u4E0B\u6587\u5DF2\u53D8\u5316\uFF08\u79DF\u6237\u6216\u767B\u5F55\u8D26\u53F7\u4E0D\u540C\uFF09\uFF0C\u8BF7\u91CD\u65B0\u6267\u884C prepare");
1968
+ }
1969
+ const payload = lease?.payload ?? {};
1970
+ const { createWorkflowHost } = await import("./host-SUOY6VYQ.js");
1971
+ const { createWorkflowContinuationSigner } = await import("./continuation-HFW2YT5S.js");
1972
+ const { getWorkflowOperation } = await import("./registry-JDUS4E7D.js");
1973
+ const wfEnv = {
1974
+ ...workflowEnv(env),
1975
+ host: createWorkflowHost(env.ctx),
1976
+ continuation: createWorkflowContinuationSigner(env.ctx)
1977
+ };
1978
+ const submitStartedAt = Date.now();
1979
+ const submit = getWorkflowOperation("workflow.createRequest");
1980
+ const submitMode = String(args.submit_mode ?? "browser").trim();
1981
+ const submitted = await submit.handler(
1982
+ {
1983
+ // 工作流的入参名是 context(createForm 返回的 continuation 就是它的 context 句柄)
1984
+ context: payload.surfaceContinuation,
1985
+ data: payload.data,
1986
+ action: "submit",
1987
+ requestName: payload.requestName,
1988
+ confirm: true,
1989
+ ...submitMode === "browser" ? {} : { forceServerSubmit: true }
1990
+ },
1991
+ wfEnv
1992
+ );
1993
+ const submittedData = submitted?.data ?? {};
1994
+ const requestId = String(submittedData.requestId ?? submittedData.id ?? "").trim();
1995
+ if (!requestId && String(submittedData.status ?? "") === "NEEDS_CONFIRMATION") {
1996
+ return meetingSuccess(
1997
+ "meeting.eb.meeting.create.flow.apply",
1998
+ {
1999
+ status: "NEEDS_CONFIRMATION",
2000
+ workflowId: payload.workflowId,
2001
+ requestName: payload.requestName,
2002
+ message: String(submittedData.message ?? ""),
2003
+ resolvedValues: submittedData.resolvedValues ?? [],
2004
+ unresolved: submittedData.unresolved ?? submittedData.candidates ?? [],
2005
+ submit: submittedData
2006
+ },
2007
+ {
2008
+ warnings: [
2009
+ "\u5EFA\u4F1A\u6D41\u7A0B\u672A\u63D0\u4EA4\uFF1A\u670D\u52A1\u7AEF\u6709\u5B57\u6BB5\u65E0\u6CD5\u552F\u4E00\u89E3\u6790\uFF08\u591A\u4E3A\u4F1A\u8BAE\u5730\u70B9/\u53C2\u4F1A\u4EBA\u5458/\u53EC\u96C6\u4EBA\u7B49\u6D4F\u89C8\u6309\u94AE\u5B57\u6BB5\uFF09\uFF0C\u8BF7\u6309 message / unresolved \u4E0E\u7528\u6237\u786E\u8BA4\u53D6\u503C\u540E\u91CD\u65B0 prepare\uFF08\u628A\u8FD9\u4E9B\u5B57\u6BB5\u6539\u6210\u670D\u52A1\u7AEF\u8BA4\u5F97\u7684\u683C\u5F0F\uFF0C\u5982\u300C\u540D\u79F0(ID)\u300D\uFF09\u3002"
2010
+ ]
2011
+ }
2012
+ );
2013
+ }
2014
+ if (!requestId) {
2015
+ const submitStatus = String(submittedData.status ?? submitted?.status ?? "");
2016
+ if (submitStatus === "BROWSER_FILL") {
2017
+ const pre = await renderPreInvitation(payload, env);
2018
+ let groupChat2;
2019
+ const groupPayload2 = payload?.groupChat;
2020
+ if (groupPayload2) {
2021
+ try {
2022
+ const { ensureMeetingGroupChat } = await import("./group-chat-BFVXAYFX.js");
2023
+ groupChat2 = {
2024
+ ...await ensureMeetingGroupChat(env, {
2025
+ meetingName: String(payload.mtName ?? ""),
2026
+ beginDatetime: String(groupPayload2.beginDatetime ?? ""),
2027
+ endDatetime: String(groupPayload2.endDatetime ?? ""),
2028
+ memberIds: Array.isArray(groupPayload2.memberIds) ? groupPayload2.memberIds : [],
2029
+ ...groupPayload2.address ? { address: String(groupPayload2.address) } : {}
2030
+ })
2031
+ };
2032
+ } catch (error) {
2033
+ groupChat2 = { ok: false, error: String(error?.message ?? error).slice(0, 200) };
2034
+ }
2035
+ }
2036
+ if (groupChat2 && groupChat2.ok) {
2037
+ try {
2038
+ const { savePendingForm } = await import("./group-chat-BFVXAYFX.js");
2039
+ await savePendingForm(env, {
2040
+ workflowId: String(payload.workflowId ?? ""),
2041
+ workflowName: String(payload.workflowName ?? ""),
2042
+ mtName: String(payload.mtName ?? ""),
2043
+ groupId: String(groupChat2.groupId ?? ""),
2044
+ groupName: String(groupChat2.groupName ?? "")
2045
+ });
2046
+ } catch {
2047
+ }
2048
+ }
2049
+ const browserWarnings = [];
2050
+ let browserInvitation = pre.invitation;
2051
+ const browserGroupId = String(groupChat2?.groupId ?? "").trim();
2052
+ const browserInvitePath = String(pre.invitation?.filePath ?? "").trim();
2053
+ if (browserGroupId && browserInvitePath) {
2054
+ const sent = await sendInvitationToGroup(env, browserGroupId, browserInvitePath, browserWarnings);
2055
+ browserInvitation = { ...pre.invitation, sentToGroup: { groupId: browserGroupId, ok: sent.ok } };
2056
+ }
2057
+ return meetingSuccess(
2058
+ "meeting.eb.meeting.create.flow.apply",
2059
+ {
2060
+ status: "BROWSER_FILL",
2061
+ workflowId: payload.workflowId,
2062
+ requestName: payload.requestName,
2063
+ requestId: null,
2064
+ meetingId: null,
2065
+ contextId: submittedData.contextId ?? null,
2066
+ // 宿主要靠这段 <browsertool> 才能把表单拉到浏览器里填,必须原样透出
2067
+ finalMarkdown: submittedData.finalMarkdown ?? null,
2068
+ // 与 finalMarkdown 相邻的硬提示:模型「以为 CLI 已经打开了表单」是这次翻车的直接原因
2069
+ finalMarkdownHint: '\u628A finalMarkdown \u539F\u6837\u8D34\u5728\u56DE\u590D\u6700\u540E\uFF08\u4ECE <browsertool> \u5230 </browsertool>\uFF0C\u4E0D\u5305\u4EE3\u7801\u5757\uFF09\uFF1B\u4E0D\u8D34\u8FD9\u6BB5\uFF1D\u7528\u6237\u770B\u4E0D\u5230\u8868\u5355\uFF0C\u4E5F\u4E0D\u80FD\u8BF4"\u8868\u5355\u5DF2\u6253\u5F00"\u3002',
2070
+ message: String(submittedData.message ?? ""),
2071
+ invitation: browserInvitation,
2072
+ ...groupChat2 ? { groupChat: groupChat2 } : {},
2073
+ timings: { submitMs: Date.now() - submitStartedAt, invitationMs: pre.ms }
2074
+ },
2075
+ {
2076
+ warnings: [
2077
+ '\u5F53\u524D\u662F\u5C0Fe \u73AF\u5883\uFF1A\u672C\u6B21**\u6CA1\u6709\u5411\u670D\u52A1\u7AEF\u5199\u5165**\uFF0C\u5EFA\u4F1A\u6D41\u7A0B\u6539\u7531\u6D4F\u89C8\u5668\u9875\u9762\u5B8C\u6210\u586B\u5355\uFF08\u89C1 finalMarkdown\uFF09\u3002\u56E0\u6B64\u8FD8\u6CA1\u6709 requestId / \u4F1A\u8BAE id\uFF0C\u4E5F**\u4E0D\u80FD\u8BF4"\u6D41\u7A0B\u5DF2\u63D0\u4EA4"**\u3002',
2078
+ ...groupChat2 && groupChat2.ok ? [`\u7FA4\u804A\u5DF2\u540C\u6B65\u5EFA\u597D\uFF08\u7FA4 id ${String(groupChat2.groupId)}\uFF0C\u7FA4\u540D ${String(groupChat2.groupName)}\uFF09\uFF1A\u6D41\u7A0B\u8FD8\u6CA1\u63D0\u4EA4\u3001\u6CA1\u6709\u4F1A\u8BAE id\uFF0C\u6240\u4EE5 imchat_groupid \u6682\u65F6\u6CA1\u56DE\u5199\uFF1B\u4F1A\u8BAE\u751F\u6210\u540E\u518D\u8DD1\u4E00\u6B21 meeting.eb.meeting.group.ensure\uFF08\u4F20 meetingId + groupId\uFF09\u7ED1\u5B9A\u3002`] : groupChat2 ? [`\u7FA4\u804A\u6CA1\u5EFA\u6210\u529F\uFF08${String(groupChat2.error ?? "\u672A\u77E5\u539F\u56E0")}\uFF09\uFF1A\u4F1A\u8BAE\u7167\u5E38\u53EF\u4EE5\u5728\u9875\u9762\u91CC\u63D0\u4EA4\uFF0C\u7FA4\u9700\u8981\u624B\u5DE5\u5EFA\u6216\u7A0D\u540E\u91CD\u8BD5\u3002`] : [],
2079
+ `\u9080\u8BF7\u51FD\u5DF2\u6309\u7533\u8BF7\u5355\u4FE1\u606F**\u9884\u751F\u6210**\uFF08\u9884\u7F6E\u51FD\uFF0C${String(pre.invitation.filePath ?? "\u89C1 filePath")}\uFF09\uFF1A` + (browserInvitation.sentToGroup?.ok ? "\u5DF2\u628A docx \u53D1\u5230\u4F1A\u8BAE\u7FA4\uFF1B\u5B57\u6BB5\u53EF\u80FD\u542B\u3010\u5F85\u8865\u5145\u3011\uFF0C\u5BA1\u6279\u901A\u8FC7\u3001\u4F1A\u8BAE\u751F\u6210\u540E\u53EF\u7528 mtId \u518D\u8DD1\u4E00\u6B21 meeting.invitation.render \u62FF\u5B8C\u6574\u7248\u672C\u3002" : "\u8BF7\u4E0B\u8F7D\u540E\u4EBA\u5DE5\u6838\u5BF9\u3001\u81EA\u884C\u53D1\u9001\uFF1B\u6D41\u7A0B\u5BA1\u6279\u901A\u8FC7\u3001\u4F1A\u8BAE\u751F\u6210\u540E\u53EF\u7528 mtId \u518D\u8DD1\u4E00\u6B21 meeting.invitation.render \u62FF\u5B8C\u6574\u5B57\u6BB5\u7248\u672C\u3002"),
2080
+ '\u26D4 \u4E0D\u8981\u56E0\u4E3A"\u6CA1\u6709 requestId / \u6CA1\u6709\u4F1A\u8BAE id"\u91CD\u590D apply \u2014\u2014 \u586B\u5355\u8981\u5728\u90A3\u4E2A\u6D4F\u89C8\u5668\u9875\u9762\u91CC\u70B9\u63D0\u4EA4\u3002',
2081
+ ...browserWarnings
2082
+ ]
2083
+ }
2084
+ );
2085
+ }
2086
+ const missing = submittedData.missingFields ?? submittedData.requiredMissing ?? submittedData.missing ?? [];
2087
+ throw meetingValidationError(
2088
+ "flow_submit_incomplete",
2089
+ `\u5EFA\u4F1A\u6D41\u7A0B\u672A\u63D0\u4EA4\u6210\u529F\uFF08status=${String(submittedData.status ?? submitted?.status ?? "\u672A\u77E5")}\uFF09\uFF1A` + (Array.isArray(missing) && missing.length > 0 ? `\u7F3A\u5C11\u5FC5\u586B\u9879 ${missing.map((item) => item?.name ?? item).join("\u3001")}` : "\u670D\u52A1\u7AEF\u672A\u8FD4\u56DE requestId\uFF0C\u8BF7\u67E5\u770B result \u6392\u67E5"),
2090
+ { submit: submittedData, missing }
2091
+ );
2092
+ }
2093
+ const warnings = [];
2094
+ const submitDay = dayOf(String(payload?.groupChat?.beginDatetime ?? ""));
2095
+ if (submitDay !== "") void invalidateDayUsages(env, submitDay).catch(() => void 0);
2096
+ void rememberFlowPick(
2097
+ env,
2098
+ String(payload?.workflowId ?? ""),
2099
+ typeof payload?.workflowName === "string" ? payload.workflowName : void 0
2100
+ ).catch(() => void 0);
2101
+ const waitSeconds = args.waitSeconds === void 0 ? 20 : Math.max(0, Math.min(180, Number(args.waitSeconds)));
2102
+ let meetingId = "";
2103
+ const timings = { submitMs: Date.now() - submitStartedAt };
2104
+ if (waitSeconds > 0) {
2105
+ const { getMeetingOperation } = await import("./registry-IM5G23LS.js");
2106
+ const list = getMeetingOperation("meeting.eb.meeting.list");
2107
+ const deadline = Date.now() + Math.min(waitSeconds, 30) * 1e3;
2108
+ const pollStart = Date.now();
2109
+ let waited = 0;
2110
+ let stepIndex = 0;
2111
+ const pollSteps = [500, 1e3, 2e3, 4e3];
2112
+ while (Date.now() <= deadline) {
2113
+ try {
2114
+ const page = await list.handler({ mt_name: payload.mtName, pageSize: 5 }, env);
2115
+ const rows = page?.data?.rows ?? [];
2116
+ const hit = rows.map((row) => row?.mainTable ?? row ?? {}).find((main) => String(main.mt_name ?? "").trim() === String(payload.mtName).trim());
2117
+ if (hit) {
2118
+ meetingId = String(hit.id ?? "").trim();
2119
+ if (meetingId) break;
2120
+ }
2121
+ } catch {
2122
+ }
2123
+ if (waited >= 7500) break;
2124
+ const step = pollSteps[Math.min(stepIndex, pollSteps.length - 1)];
2125
+ stepIndex += 1;
2126
+ await new Promise((resolve2) => setTimeout(resolve2, step));
2127
+ waited += step;
2128
+ }
2129
+ timings.pollMs = Date.now() - pollStart;
2130
+ }
2131
+ let crmLinked;
2132
+ const crmPatch = payload?.crmPatch;
2133
+ const crmPatchEnabled = process.env.WEAVER_MEETING_CRM_PATCH === "1";
2134
+ if (meetingId && crmPatchEnabled && Array.isArray(crmPatch?.ids) && crmPatch.ids.length > 0) {
2135
+ const patched = await patchMeetingCrmMembers(env, meetingId, crmPatch.ids, crmPatch.count);
2136
+ crmLinked = {
2137
+ ok: patched.ok,
2138
+ requested: crmPatch.ids.length,
2139
+ ...patched.value ? { readBack: patched.value } : {},
2140
+ ...patched.error ? { error: patched.error } : {}
2141
+ };
2142
+ if (patched.ok) {
2143
+ warnings.push(`\u300C\u53C2\u4F1A\u5BA2\u6237\u300D\u5DF2\u8865\u5199\u5230\u4F1A\u8BAE\u8BB0\u5F55\uFF08crm_members=${patched.value}\uFF09\u3002`);
2144
+ } else {
2145
+ warnings.push(
2146
+ `\u300C\u53C2\u4F1A\u5BA2\u6237\u300D\u6CA1\u6709\u56DE\u8BFB\u5230\uFF08${patched.error ?? "\u672A\u77E5\u539F\u56E0"}\uFF09\uFF1A\u5F53\u524D\u8D70\u7684\u662F CLI \u624B\u5DE5\u8865\u5199\uFF08WEAVER_MEETING_CRM_PATCH=1\uFF09\uFF0C\u4E0D\u4F9D\u8D56 ESB \u5B57\u6BB5\u6620\u5C04\u65F6\u624D\u9700\u8981\u5B83\u3002`
2147
+ );
2148
+ }
2149
+ }
2150
+ let groupChat;
2151
+ const groupPayload = payload?.groupChat;
2152
+ if (groupPayload) {
2153
+ const groupStart = Date.now();
2154
+ try {
2155
+ const { ensureMeetingGroupChat } = await import("./group-chat-BFVXAYFX.js");
2156
+ const group = await ensureMeetingGroupChat(env, {
2157
+ meetingName: String(payload.mtName ?? ""),
2158
+ beginDatetime: String(groupPayload.beginDatetime ?? ""),
2159
+ endDatetime: String(groupPayload.endDatetime ?? ""),
2160
+ memberIds: Array.isArray(groupPayload.memberIds) ? groupPayload.memberIds : [],
2161
+ ...groupPayload.address ? { address: String(groupPayload.address) } : {},
2162
+ ...meetingId ? { meetingId } : {}
2163
+ });
2164
+ groupChat = { ...group };
2165
+ if (group.ok && group.bound) {
2166
+ warnings.push(
2167
+ `\u5DF2\u6309\u4F1A\u8BAE\u540C\u6B65\u5EFA\u7FA4\u300C${group.groupName ?? payload.mtName}\u300D\uFF08\u7FA4 id ${group.groupId}\uFF09\uFF0C\u5E76\u56DE\u5199\u5230\u4F1A\u8BAE\u8BB0\u5F55 imchat_groupid${group.readBack ? `\uFF08\u56DE\u8BFB ${group.readBack}\uFF09` : ""}\u3002`
2168
+ );
2169
+ } else if (group.ok) {
2170
+ warnings.push(
2171
+ `\u7FA4\u5DF2\u5EFA\u597D\uFF08\u7FA4 id ${group.groupId}\uFF09\uFF0C\u4F46\u4F1A\u8BAE\u8FD8\u6CA1\u751F\u6210\uFF0C\u6682\u65F6\u6CA1\u6CD5\u56DE\u5199 imchat_groupid\uFF1B\u4F1A\u8BAE\u751F\u6210\u540E\u4F20 meetingId+groupId \u8DD1\u4E00\u6B21 meeting.eb.meeting.group.ensure \u7ED1\u5B9A\u5373\u53EF\u3002`
2172
+ );
2173
+ } else {
2174
+ warnings.push(
2175
+ `\u7FA4\u804A\u6CA1\u5EFA\u6210\u529F/\u6CA1\u7ED1\u4E0A\uFF08${group.error ?? "\u672A\u77E5\u539F\u56E0"}\uFF09\uFF1A\u4F1A\u8BAE\u672C\u8EAB\u5DF2\u5EFA\u597D\uFF0C\u7FA4\u53EF\u5728 IM \u91CC\u624B\u5DE5\u5EFA\uFF0C\u518D\u628A\u7FA4 id \u4F20\u5230 meeting.eb.meeting.group.ensure \u7684 groupId \u7ED1\u5B9A\u3002`
2176
+ );
2177
+ }
2178
+ } catch (error) {
2179
+ warnings.push(`\u5EFA\u7FA4\u5F02\u5E38\uFF08\u4E0D\u5F71\u54CD\u5EFA\u4F1A\uFF09\uFF1A${String(error?.message ?? error).slice(0, 200)}`);
2180
+ }
2181
+ timings.groupMs = Date.now() - groupStart;
2182
+ }
2183
+ let invitation = { pending: true };
2184
+ if (meetingId) {
2185
+ const invitationStart = Date.now();
2186
+ try {
2187
+ const { getMeetingOperation } = await import("./registry-IM5G23LS.js");
2188
+ const render = getMeetingOperation("meeting.invitation.render");
2189
+ const rendered = await render.handler(
2190
+ {
2191
+ mtId: meetingId,
2192
+ // 同理:会议主表不存客户名,用建会时填的参会客户补「客户单位」
2193
+ extra: { guest_org: String(payload?.invitationFields?.crm_members ?? "").trim() }
2194
+ },
2195
+ env
2196
+ );
2197
+ invitation = { pending: false, ...rendered?.data ?? {} };
2198
+ timings.invitationMs = Date.now() - invitationStart;
2199
+ } catch (error) {
2200
+ invitation = {
2201
+ pending: false,
2202
+ ok: false,
2203
+ error: String(error?.message ?? error).slice(0, 200)
2204
+ };
2205
+ }
2206
+ } else {
2207
+ const pre = await renderPreInvitation(payload, env);
2208
+ invitation = pre.invitation;
2209
+ timings.invitationMs = pre.ms;
2210
+ warnings.push(
2211
+ `\u6D41\u7A0B\u5DF2\u63D0\u4EA4\uFF08requestId=${requestId || "\u672A\u8FD4\u56DE"}\uFF09\uFF0C\u4F46 ${waitSeconds}s \u5185\u6CA1\u5728\u4F1A\u8BAE\u8868\u91CC\u67E5\u5230\u300C${payload.mtName}\u300D\u2014\u2014\u591A\u6570\u60C5\u51B5\u662F\u8FD8\u5728\u5BA1\u6279\u4E2D\u3002\u5DF2\u6309\u7533\u8BF7\u5355\u4FE1\u606F**\u9884\u751F\u6210**\u9080\u8BF7\u51FD\uFF08\u5C5E\u9884\u7F6E\u51FD\uFF0C\u8BF7\u4EBA\u5DE5\u6838\u5BF9\u540E\u81EA\u884C\u53D1\u9001\uFF09\uFF1B\u5BA1\u6279\u901A\u8FC7\u3001\u4F1A\u8BAE\u751F\u6210\u540E\u53EF\u7528 mtId \u518D\u8DD1\u4E00\u6B21 meeting.invitation.render \u62FF\u5230\u5B8C\u6574\u5B57\u6BB5\u7248\u672C\u3002\u26D4 \u672C operation \u4E0D\u91CD\u590D\u63D0\u4EA4\u6D41\u7A0B \u2014\u2014 \u4E0D\u8981\u56E0\u4E3A"\u6CA1\u6709\u4F1A\u8BAE id"\u5C31\u91CD\u590D apply\u3002`
2212
+ );
2213
+ }
2214
+ const inviteGroupId = String(groupChat?.groupId ?? "").trim();
2215
+ const inviteFilePath = String(invitation?.filePath ?? "").trim();
2216
+ if (inviteGroupId && inviteFilePath) {
2217
+ const sent = await sendInvitationToGroup(env, inviteGroupId, inviteFilePath, warnings);
2218
+ invitation.sentToGroup = { groupId: inviteGroupId, ok: sent.ok };
2219
+ timings.invitationSendMs = sent.ms;
2220
+ }
2221
+ return meetingSuccess(
2222
+ "meeting.eb.meeting.create.flow.apply",
2223
+ {
2224
+ status: "COMPLETE",
2225
+ timings,
2226
+ workflowId: payload.workflowId,
2227
+ requestId,
2228
+ requestName: payload.requestName,
2229
+ meetingId: meetingId || null,
2230
+ // 参会客户有没有真的写进会议记录(表单侧是 Ebuilder,需 apply 补写;回读确认才算 ok)
2231
+ ...crmLinked ? { crmLinked } : {},
2232
+ // 同步建的群(群 id / 群名 / 有没有回写 imchat_groupid)
2233
+ ...groupChat ? { groupChat } : {},
2234
+ // 提交后回显「实际提交了什么」:字段名 → 值(人员/客户显示姓名,不显示 id)。
2235
+ // 用户要的就是"能看见内容",替代走不通的浏览器填单核对。
2236
+ submittedPreview: renderFormPreview(
2237
+ payload?.fieldLabels ?? [],
2238
+ await decoratePreviewPersonNames(
2239
+ env,
2240
+ payload?.data?.main ?? {},
2241
+ payload?.fieldLabels ?? [],
2242
+ new Map(Object.entries(payload?.personLabels ?? {}))
2243
+ )
2244
+ ),
2245
+ invitation,
2246
+ result: submitted?.data ?? null
2247
+ },
2248
+ warnings.length > 0 ? { warnings } : {}
2249
+ );
2250
+ }
2251
+ };
2252
+ var ebMeetingCreateFlowQuick = {
2253
+ name: "meeting.eb.meeting.create.flow.quick",
2254
+ resource: "eb",
2255
+ method: "meeting.eb.meeting.create.flow.quick",
2256
+ action: "meeting.eb.meeting.create.flow.quick",
2257
+ summary: '\u4E00\u6B65\u6D41\u7A0B\u5EFA\u4F1A\uFF08prepare+apply \u5408\u5E76\uFF09\uFF1A\u5185\u90E8\u5E76\u884C\u505A\u4F1A\u8BAE\u5BA4\u63A8\u8350/\u51B2\u7A81\u68C0\u6D4B/\u7A7A\u95F2\u65F6\u6BB5\uFF0C\u9ED8\u8BA4**\u5F39\u6D4F\u89C8\u5668\u8868\u5355**\u7ED9\u7528\u6237\u6838\u5BF9\u63D0\u4EA4\uFF08submit_mode=browser\uFF0C\u5C0Fe \u91CC\u9884\u586B\u4EBA\u5458/\u5BA2\u6237\u540E\u7531\u7528\u6237\u70B9\u63D0\u4EA4\uFF1B\u975E\u5C0Fe \u73AF\u5883\u4F1A\u81EA\u52A8\u5199\u670D\u52A1\u7AEF\uFF09\uFF1B\u4F20 submit_mode=direct \u624D\u662F\u670D\u52A1\u7AEF\u76F4\u63D0\uFF08\u62FF requestId + meetingId\uFF0C\u4F1A\u8BAE\u5F53\u573A\u751F\u6210\u3001\u9080\u8BF7\u51FD\u7528\u771F\u5B9E\u6570\u636E\uFF09\u3002\u591A\u6D41\u7A0B\u6216\u9700\u9009\u62E9\u65F6\u4E0D\u63D0\u4EA4\uFF0C\u8FD4\u56DE\u9009\u9879\u3002\u26A0\uFE0F \u7528\u6237\u63D0\u5230\u5BA2\u6237\u540D\u65F6**\u5FC5\u987B\u5148** meeting.eb.crm.search {"keyword":"X"} \u62FF customerId \u518D\u4F20 crm_members:[{id,name}]\uFF1B\u53EA\u628A\u5BA2\u6237\u540D\u5199\u8FDB\u4F1A\u8BAE\u540D\u79F0/\u5185\u5BB9\u800C\u4E0D\u4F20 crm_members \u4F1A\u88AB\u76F4\u63A5\u62D2\u7EDD\uFF08crm_member_required\uFF09\u3002\u26D4 \u4E0D\u8981\u7528 submit_mode=browser \u2014\u2014 \u5C0Fe \u586B\u5355\u9875\u4E0D\u7ED9\u6D4F\u89C8\u6309\u94AE\u8D4B\u503C\uFF0C\u53C2\u4F1A\u4EBA\u5458/\u53C2\u4F1A\u5BA2\u6237\u4F1A\u6574\u6BB5\u4E22\u5931',
2258
+ capability: "eb.meeting",
2259
+ risk: "high-risk-write",
2260
+ requiresConfirmation: true,
2261
+ inputSchema: schemaOf(
2262
+ {
2263
+ mt_name: { type: "string", description: "\u4F1A\u8BAE\u540D\u79F0\uFF08\u5FC5\u586B\uFF09" },
2264
+ begin_datetime: {
2265
+ ...SCHEMA_DATETIME_MINUTE,
2266
+ description: "\u5F00\u59CB\u65F6\u95F4\uFF08yyyy-MM-dd HH:mm\uFF09\u3002**\u53EF\u4EE5\u4E0D\u4F20**\uFF1A\u4E0D\u4F20\u4F1A\u6309\u53C2\u4F1A\u4EBA\u4E0E\u4F1A\u8BAE\u5BA4\u7A7A\u95F2\u60C5\u51B5\u63A8\u8350 3 \u4E2A\u65F6\u6BB5\u8BA9\u4F60\u9009\uFF1B\u53EA\u4F20\u5F00\u59CB\u65F6\u95F4\u3001\u4E0D\u4F20\u7ED3\u675F\u65F6\u95F4\u65F6\uFF0C\u6309 durationMinutes\uFF08\u9ED8\u8BA4 60 \u5206\u949F\uFF09\u81EA\u52A8\u7B97\u7ED3\u675F\u65F6\u95F4"
2267
+ },
2268
+ end_datetime: {
2269
+ ...SCHEMA_DATETIME_MINUTE,
2270
+ description: "\u7ED3\u675F\u65F6\u95F4\uFF08yyyy-MM-dd HH:mm\uFF09\uFF1B\u4E0D\u4F20\u5219\u6309 durationMinutes \u4ECE\u5F00\u59CB\u65F6\u95F4\u63A8\u7B97\uFF08\u9ED8\u8BA4 60 \u5206\u949F\uFF09"
2271
+ },
2272
+ mt_desc: { type: "string", description: "\u4F1A\u8BAE\u5185\u5BB9/\u8BF4\u660E" },
2273
+ address: { type: "string", description: "\u4F1A\u8BAE\u5BA4\uFF08id \u6216\u540D\u79F0\uFF1B\u4E0D\u4F20\u5219\u8FD4\u56DE\u5019\u9009\u8BA9\u7528\u6237\u9009\uFF0C\u4E0D\u4F1A\u81EA\u52A8\u51B3\u5B9A\uFF09" },
2274
+ customize_address: { type: "string", description: "\u81EA\u5B9A\u4E49\u4F1A\u8BAE\u5730\u70B9" },
2275
+ hrm_members: { type: "string", description: "\u53C2\u4F1A\u4EBA\u5458 id\uFF0C\u9017\u53F7\u5206\u9694" },
2276
+ total_member: { type: "number", description: "\u53C2\u4F1A\u4EBA\u6570" },
2277
+ caller: { type: "string", description: "\u53EC\u96C6\u4EBA\uFF08\u5458\u5DE5 id \u6216\u59D3\u540D\uFF09\u3002\u7F3A\u7701 = \u5F53\u524D\u767B\u5F55\u4EBA\uFF0C\u4E0D\u7528\u4F20\uFF1B\u53EA\u6709\u6307\u5B9A\u522B\u4EBA\u5F53\u53EC\u96C6\u4EBA\u624D\u4F20" },
2278
+ contacter: { type: "string", description: "\u8054\u7CFB\u4EBA\uFF08\u5458\u5DE5 id \u6216\u59D3\u540D\uFF09\u3002\u7F3A\u7701 = \u5F53\u524D\u767B\u5F55\u4EBA\uFF0C\u4E0D\u7528\u4F20\uFF1B\u53EA\u6709\u6307\u5B9A\u522B\u4EBA\u5F53\u8054\u7CFB\u4EBA\u624D\u4F20" },
2279
+ mt_type: {
2280
+ type: "string",
2281
+ description: "\u4F1A\u8BAE\u7C7B\u578B\uFF1A\u53EF\u4F20\u7C7B\u578B\u540D\u79F0\u6216 id\uFF08\u5148\u7528 `meeting.eb.type.list` \u67E5\u6709\u54EA\u4E9B\uFF09\u3002**\u5F88\u591A\u79DF\u6237\u7684\u6D41\u7A0B\u8868\u5355\u628A\u300C\u4F1A\u8BAE\u7C7B\u578B\u300D\u8BBE\u4E3A\u5FC5\u586B**\uFF0C\u4E0D\u4F20\u4F1A\u88AB `workflow.createRequest` \u6253\u56DE\u7F3A\u5B57\u6BB5"
2282
+ },
2283
+ other_remark: { type: "string", description: "\u5907\u6CE8" },
2284
+ workflowId: {
2285
+ oneOf: [{ type: "string" }, { type: "array", items: { type: "string" } }],
2286
+ description: "\u6307\u5B9A\u5EFA\u4F1A\u6D41\u7A0B id\uFF08\u5355\u4E2A / \u6570\u7EC4 / \u9017\u53F7\u5206\u9694\uFF09\u3002\u4F20\u591A\u4E2A\u65F6\u4E0D\u4F1A\u66FF\u4F60\u9009\uFF1A\u4F1A\u8FD4\u56DE NEEDS_SELECTION \u8BA9\u7528\u6237\u6311"
2287
+ },
2288
+ autoRoom: { type: "boolean", description: "\u9ED8\u8BA4 false\uFF1A\u4E0D\u6307\u5B9A\u4F1A\u8BAE\u5BA4\u65F6\u8FD4\u56DE\u5019\u9009\u8BA9\u7528\u6237\u9009\uFF1B\u4F20 true \u624D\u81EA\u52A8\u91C7\u7528\u63A8\u8350\u4F1A\u8BAE\u5BA4" },
2289
+ allowNoRoom: { type: "boolean", description: "\u786E\u5B9E\u4E0D\u9700\u8981\u4F1A\u8BAE\u5BA4\uFF08\u7EBF\u4E0A\u4F1A\u7B49\uFF09\u65F6\u4F20 true" },
2290
+ timeConfirmed: {
2291
+ type: "boolean",
2292
+ description: '\u65F6\u95F4\u7684"\u7528\u6237\u5DF2\u786E\u8BA4"\u6807\u8BB0\uFF1A\u7528\u6237\u539F\u8BDD\u660E\u786E\u7ED9\u4E86\u65F6\u95F4\u3001\u6216\u5728\u65F6\u6BB5\u9009\u9879\u91CC\u70B9\u9009\u540E\u539F\u6837\u56DE\u4F20 value\uFF08\u81EA\u5E26\u6807\u8BB0\uFF09\u65F6\u624D\u4F20 true\uFF1B\u4E0D\u4F20 = \u672A\u786E\u8BA4\uFF0CCLI \u4F1A\u8FD4\u56DE\u65F6\u6BB5\u9009\u9879\u8BA9\u7528\u6237\u70B9\u9009'
2293
+ },
2294
+ roomConfirmed: {
2295
+ type: "boolean",
2296
+ description: '\u4F1A\u8BAE\u5BA4\u7684"\u7528\u6237\u5DF2\u786E\u8BA4"\u6807\u8BB0\uFF1A\u7528\u6237\u539F\u8BDD\u660E\u786E\u6307\u5B9A\u3001\u6216\u5728\u623F\u95F4\u9009\u9879\u91CC\u70B9\u9009\u540E\u539F\u6837\u56DE\u4F20 value\uFF08\u81EA\u5E26\u6807\u8BB0\uFF09\u65F6\u624D\u4F20 true\uFF1B\u4E0D\u4F20 = \u672A\u786E\u8BA4\uFF0CCLI \u4F1A\u628A\u6307\u5B9A\u623F\u95F4\u548C\u5019\u9009\u4E00\u8D77\u5217\u51FA\u6765\u8BA9\u7528\u6237\u70B9\u9009'
2297
+ },
2298
+ confirm: { type: "boolean", description: "\u5FC5\u987B\u663E\u5F0F true \u624D\u4F1A\u771F\u6B63\u63D0\u4EA4" },
2299
+ waitSeconds: { type: "number", description: "\u63D0\u4EA4\u540E\u7B49\u5F85\u4F1A\u8BAE\u751F\u6210\u7684\u79D2\u6570\uFF08\u9ED8\u8BA4 20\uFF1B\u7B97\u6CD5\u662F\u7ACB\u5373\u67E5\u4E00\u6B21 + 5s \u518D\u67E5\u4E00\u6B21\uFF0C\u4ECD\u672A\u751F\u6210\u5C31\u8FD4\u56DE pending\uFF09" },
2300
+ enrich: { type: "boolean", description: "\u662F\u5426\u987A\u5E26\u505A\u4F1A\u8BAE\u5BA4\u63A8\u8350/\u51B2\u7A81\u68C0\u6D4B/\u7A7A\u95F2\u65F6\u6BB5\uFF08\u9ED8\u8BA4 true\uFF1B\u4EBA\u3001\u65F6\u95F4\u3001\u623F\u95F4\u90FD\u5DF2\u786E\u5B9A\u65F6\u4F20 false \u53EF\u663E\u8457\u52A0\u5FEB\uFF09" },
2301
+ extraFields: {
2302
+ type: "object",
2303
+ description: '\u6309\u6D41\u7A0B\u8868\u5355\u5B57\u6BB5\u540D\u586B\u989D\u5916\u5B57\u6BB5\uFF08\u79DF\u6237\u81EA\u5EFA\u5B57\u6BB5\u7528\u8FD9\u4E2A\u53E3\u5B50\u5E26\u8FDB\u53BB\uFF09\uFF0C\u5F62\u5982 {"\u53C2\u4F1A\u5BA2\u6237": "xx\u516C\u53F8"}'
2304
+ },
2305
+ dateFrom: {
2306
+ type: "string",
2307
+ description: "\u6CA1\u7ED9\u5177\u4F53\u65F6\u95F4\u65F6\u6309\u54EA\u4E00\u5929\u63A8\u8350\u65F6\u6BB5\uFF08yyyy-MM-dd\uFF1B\u4E0D\u4F20\u9ED8\u8BA4\u660E\u5929\uFF09\u3002\u26A0\uFE0F \u7528\u6237\u8BF4\u4E86\u300C\u4E0A\u5348/\u4E0B\u5348/\u665A\u4E0A\u300D\u5C31\u5FC5\u987B\u540C\u65F6\u4F20 time_slot \u2014\u2014 \u53EA\u4F20 dateFrom \u4F1A\u5F39\u65F6\u6BB5\u9009\u62E9\u5668\u8BA9\u7528\u6237\u518D\u9009\u4E00\u6B21"
2308
+ },
2309
+ time_slot: {
2310
+ type: "string",
2311
+ enum: ["\u4E0A\u5348", "\u65E9\u4E0A", "\u4E0B\u5348", "\u665A\u4E0A"],
2312
+ description: '\u7528\u6237\u53EA\u8BF4\u4E86\u300C\u4E0A\u5348/\u4E0B\u5348/\u665A\u4E0A\u300D\u65F6\u4F20\u8FD9\u4E2A\uFF08\u914D\u5408 dateFrom\uFF09\uFF1A\u4E0A\u5348/\u65E9\u4E0A=09:00\u201312:00\u3001\u4E0B\u5348=13:00\u201318:00\u3001\u665A\u4E0A=18:00\u201321:00\uFF0CCLI \u76F4\u63A5\u5B9A\u4E0B\u6765\u3001\u4E0D\u518D\u8FD4\u56DE\u65F6\u6BB5\u5019\u9009\u3002\u26D4 \u4E0D\u8981\u53EA\u4F20 dateFrom \u5C31\u671F\u5F85"\u8BA9\u7528\u6237\u9009\u65F6\u6BB5"\u2014\u2014\u7528\u6237\u5DF2\u7ECF\u8BF4\u4E86\u65F6\u6BB5\u5C31\u522B\u518D\u95EE'
2313
+ },
2314
+ durationMinutes: {
2315
+ type: "number",
2316
+ description: "\u4F1A\u8BAE\u65F6\u957F\uFF08\u5206\u949F\uFF0C\u9ED8\u8BA4 60\uFF09\uFF1A\u53EA\u7ED9\u4E86\u5F00\u59CB\u65F6\u95F4\u65F6\u7528\u6765\u7B97\u7ED3\u675F\u65F6\u95F4\uFF1B\u63A8\u8350\u65F6\u6BB5\u65F6\u4E5F\u6309\u8FD9\u4E2A\u65F6\u957F\u627E"
2317
+ },
2318
+ workStartHour: { type: "number", description: "\u63A8\u8350\u65F6\u6BB5\u7684\u6700\u65E9\u5C0F\u65F6\uFF08\u9ED8\u8BA4 9\uFF09" },
2319
+ workEndHour: { type: "number", description: "\u63A8\u8350\u65F6\u6BB5\u7684\u6700\u665A\u5C0F\u65F6\uFF08\u9ED8\u8BA4 18\uFF09" },
2320
+ fieldValues: {
2321
+ type: "object",
2322
+ additionalProperties: true,
2323
+ description: '\u6309**\u8868\u5355\u5B57\u6BB5 datakey\uFF08fieldId\uFF09**\u76F4\u63A5\u7ED9\u503C\uFF0C\u5F62\u5982 {"1325677252711735881": "\u7814\u8BA8\u4F1A"}\uFF1B\u4F18\u5148\u7EA7\u6700\u9AD8\uFF0C\u9002\u5408\u5B57\u6BB5\u540D\u5E26\u63D0\u793A\u8BED\u6216\u79DF\u6237\u81EA\u5EFA\u5B57\u6BB5\u3002datakey \u89C1 prepare \u7684 preview.mapped'
2324
+ },
2325
+ flowChoice: {
2326
+ type: "string",
2327
+ enum: ["auto", "ask"],
2328
+ description: "\u591A\u4E2A\u5EFA\u4F1A\u6D41\u7A0B**\u90FD\u6709\u53D1\u8D77\u6743\u9650**\u65F6\uFF1A\u9ED8\u8BA4\uFF08\u4E0D\u4F20 / ask\uFF09= \u8FD4\u56DE\u9009\u9879\u8BA9\u7528\u6237\u6311\uFF1Bauto = \u81EA\u52A8\u53D6\u4F18\u5148\u7EA7\u6700\u9AD8\u7684\u3002\u6709\u6D41\u7A0B\u8BB0\u5FC6\uFF08\u4E0A\u6B21\u6210\u529F\u7528\u8FC7\u7684\u6D41\u7A0B\uFF09\u4E14\u4ECD\u53EF\u53D1\u8D77\u65F6\u9ED8\u8BA4\u6CBF\u7528\u4E0A\u6B21\u9009\u62E9\uFF0C\u4F20 ask \u5F3A\u5236\u6BCF\u6B21\u90FD\u95EE\u3002\u53EA\u6709 1 \u4E2A\u6709\u6743\u9650\u65F6\u76F4\u63A5\u53D1\u8D77"
2329
+ },
2330
+ crm_skip: {
2331
+ type: "boolean",
2332
+ description: "\u663E\u5F0F\u58F0\u660E\u300C\u8FD9\u6B21\u4E0D\u586B\u53C2\u4F1A\u5BA2\u6237\u300D\u3002\u4F1A\u8BAE\u540D\u79F0/\u5185\u5BB9\u91CC\u51FA\u73B0 `\u5BA2\u6237\uFF1AX`\u3001`\u5BA2\u6237\u662FX` \u8FD9\u7C7B\u5B57\u6837\u5374**\u6CA1\u4F20 `crm_members`**\u65F6\uFF0C\u4E00\u6B65\u5EFA\u4F1A\u4F1A\u76F4\u63A5\u62D2\u7EDD\uFF08crm_member_required\uFF09\u2014\u2014\u786E\u8BA4\u8FD9\u4E9B\u5B57\u6837\u4E0D\u662F\u8981\u4E0A\u4F1A\u8868\u7684\u5BA2\u6237\uFF0C\u624D\u4F20 true"
2333
+ },
2334
+ submit_mode: {
2335
+ type: "string",
2336
+ enum: ["direct", "browser"],
2337
+ description: '\u63D0\u4EA4\u65B9\u5F0F\uFF0C\u9ED8\u8BA4 browser\uFF1A\u5728\u5C0Fe \u91CC**\u5F39\u51FA\u6D41\u7A0B\u8868\u5355**\uFF08\u5B57\u6BB5\u5DF2\u9884\u586B\u542B\u4EBA\u5458/\u5BA2\u6237\uFF09\uFF0C\u7528\u6237\u6838\u5BF9\u4FEE\u6539\u540E\u81EA\u5DF1\u70B9\u63D0\u4EA4\u3002direct = \u76F4\u63A5\u5199\u670D\u52A1\u7AEF\uFF08\u4F1A\u8BAE\u5F53\u573A\u751F\u6210\u3001\u9080\u8BF7\u51FD\u7528\u771F\u5B9E\u6570\u636E\uFF0C\u4F46\u6CA1\u6709\u4EBA\u5DE5\u6838\u5BF9\u8868\u5355\u8FD9\u4E00\u6B65\uFF09\uFF1B\u53EA\u6709\u7528\u6237\u660E\u786E\u8BF4"\u4E0D\u7528\u6211\u786E\u8BA4\uFF0C\u76F4\u63A5\u5EFA"\u65F6\u624D\u4F20 direct'
2338
+ }
2339
+ },
2340
+ { required: ["mt_name", "confirm"] }
2341
+ ),
2342
+ handler: async (args, env) => {
2343
+ if (args.confirm !== true) {
2344
+ throw meetingValidationError(
2345
+ "confirmation_required",
2346
+ "\u4E00\u6B65\u5EFA\u4F1A\u4F1A\u76F4\u63A5\u63D0\u4EA4\u6D41\u7A0B\uFF0C\u5FC5\u987B\u663E\u5F0F\u4F20 confirm=true\uFF1B\u5982\u53EA\u60F3\u770B\u65B9\u6848\uFF0C\u8BF7\u7528 meeting.eb.meeting.create.flow.prepare"
2347
+ );
2348
+ }
2349
+ const crmMentioned = detectCrmMentionInText(args.mt_name, args.mt_desc, args.other_remark);
2350
+ const crmSkipped = args.crm_skip === true;
2351
+ if (crmMentioned && !args.crm_members && !crmSkipped) {
2352
+ throw meetingValidationError(
2353
+ "crm_member_required",
2354
+ `\u4F1A\u8BAE\u540D\u79F0/\u5185\u5BB9\u91CC\u63D0\u5230\u5BA2\u6237\u300C${crmMentioned}\u300D\uFF0C\u4F46\u6CA1\u4F20 crm_members \u2014\u2014 \u63D0\u4EA4\u540E\u300C\u53C2\u4F1A\u5BA2\u6237\u300D\u4F1A\u662F\u7A7A\u7684\u3002\u5148 meeting.eb.crm.search {"keyword":"${crmMentioned}"} \u62FF items[].customerId\uFF0C\u518D\u628A crm_members:[{"id":"<customerId>","name":"<\u5B8C\u6574\u5BA2\u6237\u540D>"}] \u4E00\u8D77\u4F20\uFF08\u5FC5\u987B\u5E26\u540D\u79F0\uFF0C\u53EA\u7ED9 id \u4F1A\u88AB\u9759\u9ED8\u5B58\u7A7A\uFF09\uFF1B\u786E\u5B9E\u4E0D\u9700\u8981\u586B\u53C2\u4F1A\u5BA2\u6237\u5C31\u4F20 crm_skip:true\u3002`
2355
+ );
2356
+ }
2357
+ const { getMeetingOperation } = await import("./registry-IM5G23LS.js");
2358
+ const prepareStartedAt = Date.now();
2359
+ const { submit_mode: _submitMode, confirm: _confirm, ...prepareArgs } = args;
2360
+ const prepared = await getMeetingOperation("meeting.eb.meeting.create.flow.prepare").handler(
2361
+ // submit_mode 只属于提交阶段,prepare 的 schema 不接受它(additionalProperties:false)
2362
+ prepareArgs,
2363
+ env
2364
+ );
2365
+ if (prepared?.data?.status === "NEEDS_SELECTION") {
2366
+ return prepared;
2367
+ }
2368
+ const continuation = String(prepared?.data?.continuation ?? "");
2369
+ if (!continuation) {
2370
+ throw meetingValidationError("flow_prepare_failed", "\u5EFA\u4F1A\u6D41\u7A0B\u51C6\u5907\u9636\u6BB5\u6CA1\u6709\u8FD4\u56DE\u786E\u8BA4\u7968\u636E\uFF0C\u672A\u63D0\u4EA4");
2371
+ }
2372
+ const prepareMs = Date.now() - prepareStartedAt;
2373
+ const applyStartedAt = Date.now();
2374
+ const applied = await getMeetingOperation("meeting.eb.meeting.create.flow.apply").handler(
2375
+ {
2376
+ continuation,
2377
+ confirm: true,
2378
+ ...args.submit_mode ? { submit_mode: args.submit_mode } : {},
2379
+ ...args.waitSeconds !== void 0 ? { waitSeconds: args.waitSeconds } : {}
2380
+ },
2381
+ env
2382
+ );
2383
+ const warnings = [
2384
+ ...prepared?.warnings ?? [],
2385
+ ...applied?.warnings ?? []
2386
+ ];
2387
+ return meetingSuccess(
2388
+ "meeting.eb.meeting.create.flow.quick",
2389
+ {
2390
+ status: applied?.data?.status ?? "COMPLETE",
2391
+ workflowId: applied?.data?.workflowId,
2392
+ requestId: applied?.data?.requestId,
2393
+ meetingId: applied?.data?.meetingId ?? null,
2394
+ invitation: applied?.data?.invitation ?? null,
2395
+ // 同步建的群(群 id / 群名 / 有没有回写 imchat_groupid)
2396
+ ...applied?.data?.groupChat ? { groupChat: (applied?.data).groupChat } : {},
2397
+ // 已提交内容回显(字段名 → 值),提交后可直接贴给用户看"到底填进去了什么"
2398
+ submittedPreview: applied?.data?.submittedPreview ?? null,
2399
+ // 小e 环境(BROWSER_FILL)不写服务端,表单靠这段 <browsertool> 在浏览器里填 —— 必须一起透出,
2400
+ // 否则宿主拿不到表单,用户看到的就是"提交了但没反应"。
2401
+ ...applied?.data?.contextId ? { contextId: (applied?.data).contextId } : {},
2402
+ ...applied?.data?.finalMarkdown ? { finalMarkdown: (applied?.data).finalMarkdown } : {},
2403
+ ...applied?.data?.finalMarkdownHint ? { finalMarkdownHint: (applied?.data).finalMarkdownHint } : {},
2404
+ decisions: prepared?.data?.preview?.decisions ?? null,
2405
+ timings: {
2406
+ ...prepared?.data?.preview?.decisions?.timings ?? {},
2407
+ // apply 侧的分段耗时(提交/轮询/邀请函)也要带出来,否则"到底慢在哪"还是看不清
2408
+ ...applied?.data?.timings ?? {},
2409
+ prepareMs,
2410
+ applyMs: Date.now() - applyStartedAt,
2411
+ totalMs: Date.now() - prepareStartedAt
2412
+ }
2413
+ },
2414
+ warnings.length > 0 ? { warnings } : {}
2415
+ );
2416
+ }
2417
+ };
2418
+ var ebMeetingCreateSuggest = {
2419
+ name: "meeting.eb.meeting.create.suggest",
2420
+ resource: "eb",
2421
+ method: "meeting.eb.meeting.create.suggest",
2422
+ action: "meeting.eb.meeting.create.suggest",
2423
+ summary: "\u5EFA\u4F1A\u5EFA\u8BAE\uFF1A\u7ED9\u5B9A\u65E5\u671F\u8303\u56F4\u4E0E\u53C2\u4F1A\u4EBA\uFF0C\u63A8\u8350\u300C\u6240\u6709\u4EBA\u90FD\u7A7A\u95F2 + \u8BE5\u65F6\u6BB5\u6709\u53EF\u7528\u4F1A\u8BAE\u5BA4\u300D\u7684\u65F6\u95F4\u5019\u9009\uFF08\u53EA\u8BFB\uFF0C\u4E0D\u5EFA\u4F1A\uFF09",
2424
+ capability: "eb.meeting",
2425
+ risk: "read",
2426
+ inputSchema: schemaOf(
2427
+ {
2428
+ dateFrom: { type: "string", description: "\u8D77\u59CB\u65E5\u671F\uFF08\u5FC5\u586B\uFF0Cyyyy-MM-dd\uFF09" },
2429
+ dateTo: { type: "string", description: "\u7ED3\u675F\u65E5\u671F\uFF08\u53EF\u9009\uFF0C\u9ED8\u8BA4\u540C dateFrom\uFF1B\u6700\u591A\u8DE8 14 \u5929\uFF09" },
2430
+ durationMinutes: { type: "number", description: "\u4F1A\u8BAE\u65F6\u957F\uFF08\u5206\u949F\uFF0C\u9ED8\u8BA4 60\uFF09" },
2431
+ hrm_members: { type: "string", description: "\u53C2\u4F1A\u4EBA\u5458\uFF08\u5FC5\u586B\uFF0C\u5458\u5DE5 id \u6216\u59D3\u540D\uFF0C\u9017\u53F7\u5206\u9694\uFF1B\u59D3\u540D\u4F1A\u81EA\u52A8\u53CD\u67E5 id\uFF09" },
2432
+ memberCount: { type: "number", description: "\u53C2\u4F1A\u4EBA\u6570\uFF08\u53EF\u9009\uFF0C\u7528\u4E8E\u4F1A\u8BAE\u5BA4\u5BB9\u91CF\u7B5B\u9009\uFF1B\u4E0D\u4F20\u5219\u6309 hrm_members \u4E2A\u6570\uFF09" },
2433
+ workStartHour: { type: "number", description: "\u53EA\u5728\u51E0\u70B9\u4EE5\u540E\u627E\uFF08\u9ED8\u8BA4 9\uFF09" },
2434
+ workEndHour: { type: "number", description: "\u53EA\u5728\u51E0\u70B9\u4EE5\u524D\u627E\uFF08\u9ED8\u8BA4 18\uFF09" },
2435
+ maxSlots: { type: "number", description: "\u6700\u591A\u7ED9\u51E0\u4E2A\u65F6\u95F4\u5019\u9009\uFF08\u9ED8\u8BA4 3\uFF0C\u6700\u5927 8\uFF09" },
2436
+ topN: { type: "number", description: "\u6BCF\u4E2A\u65F6\u95F4\u5019\u9009\u6700\u591A\u5E26\u51E0\u95F4\u4F1A\u8BAE\u5BA4\uFF08\u9ED8\u8BA4 3\uFF09" },
2437
+ includeSchedule: { type: "boolean", description: "\u662F\u5426\u628A\u65E5\u7A0B\uFF08ESB\uFF09\u4E5F\u7B97\u8FDB\u5360\u7528\uFF08\u9ED8\u8BA4 true\uFF09" }
2438
+ },
2439
+ { required: ["dateFrom", "hrm_members"] }
2440
+ ),
2441
+ handler: async (args, env) => {
2442
+ const dateFrom = String(args.dateFrom ?? "").trim().slice(0, 10);
2443
+ if (!/^\d{4}-\d{2}-\d{2}$/.test(dateFrom)) {
2444
+ throw meetingValidationError("datetime_invalid", `dateFrom \u5FC5\u987B\u662F yyyy-MM-dd\uFF0C\u6536\u5230\u300C${String(args.dateFrom ?? "")}\u300D`);
2445
+ }
2446
+ const dateTo = String(args.dateTo ?? "").trim().slice(0, 10) || dateFrom;
2447
+ if (!/^\d{4}-\d{2}-\d{2}$/.test(dateTo)) {
2448
+ throw meetingValidationError("datetime_invalid", `dateTo \u5FC5\u987B\u662F yyyy-MM-dd\uFF0C\u6536\u5230\u300C${String(args.dateTo ?? "")}\u300D`);
2449
+ }
2450
+ const durationMinutes = Number(args.durationMinutes) > 0 ? Number(args.durationMinutes) : 60;
2451
+ const maxSlots = Math.max(1, Math.min(8, Number(args.maxSlots) || 3));
2452
+ const topN = Math.max(1, Math.min(5, Number(args.topN) || 3));
2453
+ const rawMembers = String(args.hrm_members ?? "").split(/[,;,;\s]+/).map((item) => item.trim()).filter((item) => item !== "");
2454
+ const nameLike = rawMembers.filter((item) => !/^\d+$/.test(item));
2455
+ const nameToId = nameLike.length > 0 ? await import("./schedule-ESZIBAUO.js").then((m) => m.resolveMemberIdsByName(env, nameLike)).catch(() => /* @__PURE__ */ new Map()) : /* @__PURE__ */ new Map();
2456
+ const memberIds = rawMembers.map((item) => nameToId.get(item) ?? item);
2457
+ const unresolved = rawMembers.filter((item) => nameToId.get(item) === void 0 && !/^\d+$/.test(item));
2458
+ const selfId = await env.host.getSession().then((s) => String(s?.userId ?? "")).catch(() => "");
2459
+ const selfIncluded = selfId !== "" && memberIds.includes(selfId);
2460
+ const memberCount = Number(args.memberCount) > 0 ? Number(args.memberCount) : memberIds.length > 0 ? memberIds.length + (selfIncluded ? 0 : 1) : void 0;
2461
+ const warnings = [];
2462
+ if (unresolved.length > 0) {
2463
+ warnings.push(`\u26A0\uFE0F \u8FD9\u4E9B\u53C2\u4F1A\u4EBA\u6CA1\u67E5\u5230\u5458\u5DE5 id\uFF1A${unresolved.join("\u3001")} \u2014\u2014 \u5DF2\u8DF3\u8FC7\uFF0C\u5176\u7A7A\u95F2\u60C5\u51B5**\u672A\u6838\u9A8C**`);
2464
+ }
2465
+ const free = await findCommonFreeSlots(env, {
2466
+ rangeStart: `${dateFrom} 00:00`,
2467
+ rangeEnd: `${dateTo} 23:59`,
2468
+ durationMinutes,
2469
+ members: memberIds,
2470
+ maxSlots,
2471
+ maxDays: 14,
2472
+ includeSchedule: args.includeSchedule !== false,
2473
+ ...args.workStartHour !== void 0 ? { workStartHour: Number(args.workStartHour) } : {},
2474
+ ...args.workEndHour !== void 0 ? { workEndHour: Number(args.workEndHour) } : {}
2475
+ });
2476
+ await loadRooms(env, { refresh: true }).catch(() => null);
2477
+ const withRooms = await Promise.all((free.slots ?? []).map(async (slot) => {
2478
+ try {
2479
+ const rec = await recommendRooms(env, {
2480
+ beginDatetime: slot.begin,
2481
+ endDatetime: slot.end,
2482
+ ...memberCount ? { memberCount } : {},
2483
+ topN
2484
+ });
2485
+ return {
2486
+ begin: slot.begin,
2487
+ end: slot.end,
2488
+ rooms: rec.candidates.map((candidate) => ({
2489
+ id: candidate.id,
2490
+ name: candidate.name,
2491
+ capacityMax: candidate.capacity.max,
2492
+ reasons: candidate.reasons
2493
+ }))
2494
+ };
2495
+ } catch {
2496
+ return { begin: slot.begin, end: slot.end, rooms: [] };
2497
+ }
2498
+ }));
2499
+ const usable = withRooms.filter((slot) => slot.rooms.length > 0);
2500
+ if (usable.length === 0) {
2501
+ const why = (free.slots ?? []).length === 0 ? "\u8BE5\u8303\u56F4\u5185\u6240\u6709\u53C2\u4F1A\u4EBA\u6CA1\u6709\u5171\u540C\u7684\u7A7A\u95F2\u65F6\u6BB5" : `${(free.slots ?? []).length} \u4E2A\u300C\u4EBA\u7A7A\u95F2\u300D\u7684\u65F6\u6BB5\u91CC\uFF0C\u6CA1\u6709\u4E00\u4E2A\u8FD8\u80FD\u8BA2\u5230\u4F1A\u8BAE\u5BA4`;
2502
+ warnings.push(
2503
+ `\u6CA1\u627E\u5230\u540C\u65F6\u6EE1\u8DB3\u300C\u4EBA\u5458\u7A7A\u95F2 + \u4F1A\u8BAE\u5BA4\u7A7A\u95F2\u300D\u7684\u65F6\u95F4\u5019\u9009\uFF1A${why}\u3002\u8BF7\u5982\u5B9E\u544A\u77E5\u7528\u6237\uFF0C\u5E76\u5EFA\u8BAE\u6362\u4E2A\u65E5\u671F\u8303\u56F4\u3001\u7F29\u77ED\u65F6\u957F\uFF0C\u6216\u6539\u4E3A\u7EBF\u4E0A\u4F1A\u8BAE\uFF08allowNoRoom: true\uFF09\u3002`
2504
+ );
2505
+ if (free.blockingSummary) warnings.push(`\u5F53\u5929\u5360\u7528\u6982\u51B5\uFF1A${free.blockingSummary}`);
2506
+ }
2507
+ return meetingSuccess(
2508
+ "meeting.eb.meeting.create.suggest",
2509
+ {
2510
+ dateFrom,
2511
+ dateTo,
2512
+ durationMinutes,
2513
+ // 同样是"让用户点一下":时段候选用选项控件呈现,别写成文本列表
2514
+ ui: { component: "choice", multiple: false, recommendedKey: "T1" },
2515
+ slots: usable.map((slot, index) => ({
2516
+ key: `T${index + 1}`,
2517
+ label: `${slot.begin.slice(5, 10)} ${slot.begin.slice(11)}~${slot.end.slice(11)}`,
2518
+ value: { begin: slot.begin, end: slot.end, address: slot.rooms[0]?.id ?? null },
2519
+ reason: `${memberCount ? `${memberCount} \u4EBA\u5168\u90E8\u7A7A\u95F2\uFF08\u4F1A\u8BAE\u56DE\u6267 + \u65E5\u7A0B\u5DF2\u6838\uFF09\uFF1B` : ""}${slot.rooms.length} \u95F4\u4F1A\u8BAE\u5BA4\u53EF\u7528\uFF1A${slot.rooms.map((room) => room.name).join("\u3001")}`,
2520
+ rooms: slot.rooms
2521
+ })),
2522
+ // 把"人空闲但没房间"的时段也带出来,方便调用方解释为什么被剔除
2523
+ skippedSlots: withRooms.filter((slot) => slot.rooms.length === 0),
2524
+ memberIds,
2525
+ scheduleItems: free.scheduleItems,
2526
+ idle: free.idle,
2527
+ cost: free.cost
2528
+ },
2529
+ warnings.length > 0 ? { warnings } : {}
2530
+ );
2531
+ }
2532
+ };
2533
+ var meetingEbCreateFlowOperations = [
2534
+ ebMeetingCreateSuggest,
2535
+ ebMeetingCreateFlowPrepare,
2536
+ ebMeetingCreateFlowApply,
2537
+ ebMeetingCreateFlowQuick
2538
+ ];
2539
+
2540
+ export {
2541
+ resolveSelfPerson,
2542
+ applySelfPersonDefaults,
2543
+ parseRoomRef,
2544
+ resolveAddressRoom,
2545
+ shapeBrowserValues,
2546
+ resolveCrmDetailTarget,
2547
+ detectCrmMentionInText,
2548
+ normalizeCrmDetailRows,
2549
+ crmMemberEntriesFromArgs,
2550
+ crmContactsToDetailRows,
2551
+ mapFields,
2552
+ renderFormPreview,
2553
+ readFlowFieldMap,
2554
+ normalizeWorkflowIds,
2555
+ fixedFlowIds,
2556
+ fixedFlowIdsForEnv,
2557
+ shouldAutoPickFlow,
2558
+ resolveWorkflowId,
2559
+ patchMeetingCrmMembers,
2560
+ renderPreInvitation,
2561
+ meetingEbCreateFlowOperations
2562
+ };