weaver-work-cli 0.1.70 → 0.1.73

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 (263) hide show
  1. package/dist/chunks/{archive-VUTREF3P.js → archive-THZV4ND4.js} +22 -5
  2. package/dist/chunks/{archive-oa-VXXO4RTB.js → archive-oa-PQ23OLEV.js} +17 -5
  3. package/dist/chunks/{asset-45U6TY7I.js → asset-RGPROZYH.js} +22 -5
  4. package/dist/chunks/{asset-idle-YCRBMTIT.js → asset-idle-Z2PDX7NA.js} +15 -5
  5. package/dist/chunks/{attachment-content-DMU7KNZ7.js → attachment-content-R3RPVOYE.js} +3 -3
  6. package/dist/chunks/{blog-5AML4WMG.js → blog-7U3QZPIF.js} +25 -5
  7. package/dist/chunks/{caizhilian-3P7BUNHT.js → caizhilian-3AB42GCV.js} +22 -8
  8. package/dist/chunks/{calendar-2HUXM3CZ.js → calendar-KINM64E4.js} +15 -5
  9. package/dist/chunks/{chunk-EHH363SP.js → chunk-2CHGUYMG.js} +4 -4
  10. package/dist/chunks/{chunk-GWM5TLIK.js → chunk-2XED2FKY.js} +34 -34
  11. package/dist/chunks/{chunk-DVFA3ODS.js → chunk-35A56FJ7.js} +12 -0
  12. package/dist/chunks/{chunk-QYDSTYGG.js → chunk-4BXR6CNB.js} +3 -3
  13. package/dist/chunks/{chunk-KDOJW5LH.js → chunk-4I26YMBY.js} +1 -1
  14. package/dist/chunks/{chunk-X6PMJQGO.js → chunk-4YXAK6OA.js} +19 -8
  15. package/dist/chunks/{chunk-HG6INLH6.js → chunk-54ST55IJ.js} +28 -7
  16. package/dist/chunks/{chunk-DSBV4GRK.js → chunk-6HT73VOI.js} +3 -3
  17. package/dist/chunks/{chunk-4W6BSNIL.js → chunk-7QFVXP2X.js} +6 -6
  18. package/dist/chunks/{chunk-I5XB4MZT.js → chunk-AMAPQVBT.js} +95 -65
  19. package/dist/chunks/{chunk-L2A3COWV.js → chunk-BWYVS62Z.js} +4 -4
  20. package/dist/chunks/{chunk-UPVAQJKS.js → chunk-DRUND2PJ.js} +130 -79
  21. package/dist/chunks/{chunk-LJE7RZNC.js → chunk-F4HM25K4.js} +1 -1
  22. package/dist/chunks/{chunk-T24EBWAZ.js → chunk-GAMGDNTF.js} +48 -21
  23. package/dist/chunks/{chunk-H2NRTGZR.js → chunk-GWJLAF6B.js} +3 -3
  24. package/dist/chunks/{chunk-XIBMZEDB.js → chunk-IBSJJGXL.js} +2 -2
  25. package/dist/chunks/{chunk-VZUH3LKI.js → chunk-ICP53R52.js} +167 -157
  26. package/dist/chunks/{chunk-LRKKKO5A.js → chunk-IU6UB2TD.js} +3 -4
  27. package/dist/chunks/{chunk-GTAFCAVP.js → chunk-IZCQU5D5.js} +1 -1
  28. package/dist/chunks/{chunk-727VKJQK.js → chunk-JMJBPP4B.js} +2 -2
  29. package/dist/chunks/{chunk-UVWW5ABZ.js → chunk-L7TYG5SN.js} +3 -3
  30. package/dist/chunks/{chunk-HAORST2G.js → chunk-LLCMOZ5L.js} +11 -11
  31. package/dist/chunks/{chunk-U3OO3IZF.js → chunk-NUP4RYZK.js} +20 -7
  32. package/dist/chunks/{chunk-IVCOZCAW.js → chunk-PAFOLIYQ.js} +1 -1
  33. package/dist/chunks/{chunk-LSVA7QA6.js → chunk-R3MK2RBN.js} +3 -1
  34. package/dist/chunks/{chunk-GFOFUH6O.js → chunk-TV46Q4NY.js} +52 -51
  35. package/dist/chunks/chunk-WM33BSIL.js +136 -0
  36. package/dist/chunks/{chunk-7CINV2BU.js → chunk-XZBYRYWX.js} +2 -2
  37. package/dist/chunks/{chunk-E7VWE2XI.js → chunk-ZWLWXHJC.js} +3 -3
  38. package/dist/chunks/{conflict-YW5BULJ3.js → conflict-VPAR7E6F.js} +2 -2
  39. package/dist/chunks/{contract-3PMHUASH.js → contract-DDXAO2DZ.js} +48 -5
  40. package/dist/chunks/{cowork-FZBTTBYX.js → cowork-34QCHMDD.js} +37 -8
  41. package/dist/chunks/{create-flow-5OBS3B3V.js → create-flow-52PU2OBI.js} +6 -6
  42. package/dist/chunks/{data-2YZ6A6TL.js → data-CLQ62QGD.js} +99 -184
  43. package/dist/chunks/{ebuilder-form-AWPTMZBZ.js → ebuilder-form-W5R7Q22S.js} +17 -7
  44. package/dist/chunks/{ehr-MNPR4TE5.js → ehr-LCNAVMK5.js} +67 -17
  45. package/dist/chunks/{entry-mode-L65OWPFM.js → entry-mode-6Z3ZV3DE.js} +3 -3
  46. package/dist/chunks/{env-XW7LYIME.js → env-RDKWAARB.js} +2 -2
  47. package/dist/chunks/{esb-GSB5QCEX.js → esb-ANKPUU65.js} +17 -7
  48. package/dist/chunks/{factory-MHFZZAGH.js → factory-434B7RAT.js} +1 -1
  49. package/dist/chunks/{fna-XBSNUS2V.js → fna-AKBSG5HI.js} +15 -5
  50. package/dist/chunks/{group-chat-EEOLO5NM.js → group-chat-PROTW22R.js} +3 -3
  51. package/dist/chunks/{host-NVDG3NC6.js → host-5R2SNFWD.js} +4 -4
  52. package/dist/chunks/{host-2UMNXX5H.js → host-7FJW4E7R.js} +4 -4
  53. package/dist/chunks/{host-XVWBOSEN.js → host-CGXUFQO4.js} +4 -4
  54. package/dist/chunks/{host-R7BP3CTI.js → host-PDJAKCT7.js} +6 -4
  55. package/dist/chunks/{host-SYPCA63D.js → host-WO4L5G5I.js} +4 -4
  56. package/dist/chunks/{host-BD44ASOD.js → host-XIYG4F4B.js} +4 -4
  57. package/dist/chunks/{hrm-FZUDJAND.js → hrm-WGODDTEH.js} +15 -6
  58. package/dist/chunks/{im-F5NENPD7.js → im-YKTKAJU3.js} +16 -6
  59. package/dist/chunks/{invoice-DS6FLU55.js → invoice-PVYCCCVM.js} +27 -6
  60. package/dist/chunks/{jiuchuanhui-JCBUR563.js → jiuchuanhui-RKOQW7BY.js} +19 -6
  61. package/dist/chunks/{lazy-dispatch-F6O2EPGR.js → lazy-dispatch-DW45AFQ5.js} +6 -6
  62. package/dist/chunks/{mail-ZEOSANEJ.js → mail-BNB5S4NW.js} +116 -97
  63. package/dist/chunks/{meeting-PCD5EPBF.js → meeting-O2KDJH66.js} +29 -16
  64. package/dist/chunks/{minute-doc-WTZJVCHG.js → minute-doc-JUCG56GY.js} +4 -4
  65. package/dist/chunks/{okr-OZUMTMCL.js → okr-LWFGWOE7.js} +15 -5
  66. package/dist/chunks/{operations-LQY3FTPH.js → operations-2WHIF5WV.js} +1 -1
  67. package/dist/chunks/{operations-UTUWFJTX.js → operations-532PN5OB.js} +5 -5
  68. package/dist/chunks/{performance-SMVTPK6T.js → performance-7W5COCFU.js} +92 -7
  69. package/dist/chunks/{plan-C2NENH42.js → plan-ZVY3IYTL.js} +15 -5
  70. package/dist/chunks/{project-FAJ2P3UR.js → project-SA62B7MH.js} +18 -5
  71. package/dist/chunks/{reception-NH6MJFPR.js → reception-NGIONPQ3.js} +128 -49
  72. package/dist/chunks/{recruit-stage-DPEFHLSE.js → recruit-stage-WOSN6MGP.js} +1264 -197
  73. package/dist/chunks/{registry-FTPUUHWC.js → registry-N7P3W2RD.js} +5 -5
  74. package/dist/chunks/{registry-3B3OAJYX.js → registry-R72GWXOG.js} +4 -4
  75. package/dist/chunks/{registry-ZQ7OONCB.js → registry-RIQ67ZT7.js} +12 -12
  76. package/dist/chunks/{room-recommend-73NBN3RU.js → room-recommend-KCGIVUFR.js} +4 -4
  77. package/dist/chunks/{schedule-SDBOBBUQ.js → schedule-6UP27HQ4.js} +4 -4
  78. package/dist/chunks/{smart-extract-GTYKF5TJ.js → smart-extract-DDOQSPRB.js} +19 -6
  79. package/dist/chunks/{workflow-OWHWLAOX.js → workflow-V5ALD6QZ.js} +22 -8
  80. package/dist/cmd/auth/index.js +23 -0
  81. package/dist/cmd/e10/index.js +2 -1
  82. package/dist/cmd/index.js +2 -0
  83. package/dist/core/manifest-view.js +207 -0
  84. package/dist/core/output.js +42 -8
  85. package/dist/index.js +35 -35
  86. package/dist/internal/e10/auth/crypto.js +18 -8
  87. package/dist/internal/e10/auth/error-log.js +1 -2
  88. package/dist/internal/e10/auth/messages.js +2 -3
  89. package/dist/internal/e10/auth/xiaoe.js +1 -1
  90. package/dist/internal/e10/tls-policy.js +61 -13
  91. package/dist/shortcuts/archive/index.js +11 -2
  92. package/dist/shortcuts/archive/operations/download.js +1 -0
  93. package/dist/shortcuts/archive/operations/flow-url.js +3 -0
  94. package/dist/shortcuts/archive/operations/prelib.js +2 -0
  95. package/dist/shortcuts/archive/operations/upload.js +1 -0
  96. package/dist/shortcuts/archive-oa/index.js +11 -2
  97. package/dist/shortcuts/archive-oa/operations/borrow-car.js +2 -0
  98. package/dist/shortcuts/asset/index.js +11 -2
  99. package/dist/shortcuts/asset/manifest.js +7 -0
  100. package/dist/shortcuts/asset-idle/index.js +11 -2
  101. package/dist/shortcuts/blog/index.js +11 -2
  102. package/dist/shortcuts/blog/manifest.js +10 -0
  103. package/dist/shortcuts/caizhilian/host.js +20 -4
  104. package/dist/shortcuts/caizhilian/index.js +12 -2
  105. package/dist/shortcuts/caizhilian/manifest.js +4 -25
  106. package/dist/shortcuts/caizhilian/operations/handlers/search.js +34 -0
  107. package/dist/shortcuts/caizhilian/operations/registry.js +25 -1
  108. package/dist/shortcuts/calendar/index.js +11 -2
  109. package/dist/shortcuts/contract/index.js +11 -2
  110. package/dist/shortcuts/contract/manifest.js +32 -0
  111. package/dist/shortcuts/contract/operations/write.js +3 -0
  112. package/dist/shortcuts/cowork/index.js +21 -5
  113. package/dist/shortcuts/cowork/manifest.js +3 -0
  114. package/dist/shortcuts/cowork/operations/discuss-write.js +2 -0
  115. package/dist/shortcuts/cowork/operations/item-write.js +3 -0
  116. package/dist/shortcuts/cowork/operations/member-write.js +2 -0
  117. package/dist/shortcuts/cowork/operations/permission-write.js +2 -0
  118. package/dist/shortcuts/cowork/operations/review-write.js +1 -0
  119. package/dist/shortcuts/data/errors.js +16 -29
  120. package/dist/shortcuts/data/host.js +16 -7
  121. package/dist/shortcuts/data/index.js +12 -41
  122. package/dist/shortcuts/data/manifest.js +5 -44
  123. package/dist/shortcuts/data/operations/attend.js +2 -2
  124. package/dist/shortcuts/data/operations/conf.js +0 -88
  125. package/dist/shortcuts/data/operations/ds.js +4 -4
  126. package/dist/shortcuts/data/operations/index.js +1 -5
  127. package/dist/shortcuts/data/operations/module.js +40 -14
  128. package/dist/shortcuts/data/operations/query.js +2 -2
  129. package/dist/shortcuts/ebuilder-form/index.js +11 -2
  130. package/dist/shortcuts/ebuilder-form/manifest.js +12 -0
  131. package/dist/shortcuts/ehr/index.js +11 -2
  132. package/dist/shortcuts/ehr/operations/attend-write.js +51 -8
  133. package/dist/shortcuts/ehr/operations/recruit-position.js +4 -3
  134. package/dist/shortcuts/ehr/operations/recruit-short-cache.js +6 -2
  135. package/dist/shortcuts/ehr/operations/recruit-write.js +3 -3
  136. package/dist/shortcuts/ehr/operations/recruit.js +206 -82
  137. package/dist/shortcuts/ehr/operations/shared.js +31 -0
  138. package/dist/shortcuts/esb/index.js +11 -2
  139. package/dist/shortcuts/esb/manifest.js +2 -0
  140. package/dist/shortcuts/fna/index.js +11 -2
  141. package/dist/shortcuts/hrm/index.js +11 -1
  142. package/dist/shortcuts/im/index.js +11 -2
  143. package/dist/shortcuts/invoice/index.js +11 -2
  144. package/dist/shortcuts/invoice/manifest.js +8 -0
  145. package/dist/shortcuts/jiuchuanhui/index.js +15 -1
  146. package/dist/shortcuts/jiuchuanhui/manifest.js +2 -0
  147. package/dist/shortcuts/mail/errors.js +14 -0
  148. package/dist/shortcuts/mail/index.js +23 -6
  149. package/dist/shortcuts/mail/manifest.js +11 -4
  150. package/dist/shortcuts/mail/operations/mail-blacklist.js +6 -6
  151. package/dist/shortcuts/mail/operations/mail-contacts.js +10 -10
  152. package/dist/shortcuts/mail/operations/mail-manage.js +15 -14
  153. package/dist/shortcuts/mail/operations/mail-read.js +7 -25
  154. package/dist/shortcuts/mail/operations/mail-send.js +12 -12
  155. package/dist/shortcuts/mail/operations/mail-sign.js +10 -10
  156. package/dist/shortcuts/mail/operations/mail-template.js +10 -10
  157. package/dist/shortcuts/meeting/index.js +11 -2
  158. package/dist/shortcuts/meeting/operations/invitation-publish.js +1 -0
  159. package/dist/shortcuts/okr/index.js +11 -2
  160. package/dist/shortcuts/performance/index.js +62 -3
  161. package/dist/shortcuts/performance/scheme-validate.js +7 -0
  162. package/dist/shortcuts/performance/shared.js +40 -2
  163. package/dist/shortcuts/plan/index.js +11 -2
  164. package/dist/shortcuts/project/index.js +11 -2
  165. package/dist/shortcuts/project/operations/write.js +3 -0
  166. package/dist/shortcuts/reception/constants.js +22 -0
  167. package/dist/shortcuts/reception/index.js +15 -2
  168. package/dist/shortcuts/reception/manifest.js +17 -3
  169. package/dist/shortcuts/reception/operations/ask.js +3 -0
  170. package/dist/shortcuts/reception/operations/doc.js +24 -11
  171. package/dist/shortcuts/reception/operations/docrender.js +18 -1
  172. package/dist/shortcuts/reception/operations/render-assets.js +93 -22
  173. package/dist/shortcuts/recruit-stage/context.js +12 -6
  174. package/dist/shortcuts/recruit-stage/index.js +22 -3
  175. package/dist/shortcuts/recruit-stage/manifest.js +2 -0
  176. package/dist/shortcuts/recruit-stage/operations/interview-arrange.js +19 -10
  177. package/dist/shortcuts/recruit-stage/operations/jd-create.js +487 -38
  178. package/dist/shortcuts/recruit-stage/operations/list.js +72 -1
  179. package/dist/shortcuts/recruit-stage/operations/profile.js +194 -0
  180. package/dist/shortcuts/recruit-stage/operations/registry.js +20 -2
  181. package/dist/shortcuts/recruit-stage/operations/resume-import.js +258 -63
  182. package/dist/shortcuts/recruit-stage/operations/search.js +226 -27
  183. package/dist/shortcuts/recruit-stage/operations/shortlist.js +122 -0
  184. package/dist/shortcuts/recruit-stage/operations/tag.js +17 -3
  185. package/dist/shortcuts/recruit-stage/shared.js +158 -4
  186. package/dist/shortcuts/smart-extract/index.js +11 -2
  187. package/dist/shortcuts/smart-extract/manifest.js +1 -0
  188. package/dist/shortcuts/smart-extract/operations/save.js +2 -0
  189. package/dist/shortcuts/workflow/index.js +21 -1
  190. package/dist/shortcuts/workflow/operations/form.js +36 -2
  191. package/dist/shortcuts/workflow/operations/read.js +2 -2
  192. package/dist/shortcuts/workflow/operations/write.js +1 -1
  193. package/docs/caizhilian.md +1 -1
  194. package/docs/contract.md +1 -0
  195. package/docs/data.md +22 -22
  196. package/docs/e10-auth.md +41 -33
  197. package/docs/ehr.md +2 -0
  198. package/docs/reception.md +4 -3
  199. package/package.json +1 -1
  200. package/scripts/pysite/__pycache__/sitecustomize.cpython-312.pyc +0 -0
  201. package/scripts/pysite/__pycache__/sitecustomize.cpython-313.pyc +0 -0
  202. package/scripts/pysite/sitecustomize.py +41 -0
  203. package/skill-template/domains/data.md +4 -4
  204. package/skills/weaver-e10-caizhilian/SKILL.md +1 -1
  205. package/skills/weaver-e10-caizhilian/references/org-browser.md +1 -0
  206. package/skills/weaver-e10-cowork/SKILL.md +3 -1
  207. package/skills/weaver-e10-data/SKILL.md +12 -16
  208. package/skills/weaver-e10-data/references/config-center.md +6 -7
  209. package/skills/weaver-e10-data/references/datasource.md +1 -1
  210. package/skills/weaver-e10-data/references/scene-and-misc.md +2 -2
  211. package/skills/weaver-e10-jiuchuanhui/SKILL.md +6 -4
  212. package/skills/weaver-e10-jiuchuanhui/references/clue.md +2 -2
  213. package/skills/weaver-e10-jiuchuanhui/references/customer.md +18 -8
  214. package/skills/weaver-e10-jiuchuanhui/references/sale.md +2 -2
  215. package/skills/weaver-e10-jucailin/SKILL.md +7 -3
  216. package/skills/weaver-e10-jucailin/references/attend-write.md +1 -1
  217. package/skills/weaver-e10-jucailin/references/recruit-output-links.md +33 -0
  218. package/skills/weaver-e10-jucailin/references/recruit-write.md +2 -0
  219. package/skills/weaver-e10-mail/SKILL.md +4 -1
  220. package/skills/weaver-e10-mail/references/mail-read.md +4 -2
  221. package/skills/weaver-e10-mail/references/safety-boundaries.md +1 -0
  222. package/skills/weaver-e10-okr/references/source-manifest.json +3 -3
  223. package/skills/weaver-e10-performance/SKILL.md +8 -6
  224. package/skills/weaver-e10-reception-flow/SKILL.md +97 -41
  225. package/skills/weaver-e10-reception-flow/references/guide.md +3 -1
  226. package/skills/weaver-e10-recruit-stage/SKILL.md +557 -75
  227. package/skills/weaver-e10-recruit-stage/agents/openai.yaml +67 -44
  228. package/skills/weaver-e10-recruit-stage/lib/interview-conflict.mjs +279 -0
  229. package/skills/weaver-e10-recruit-stage/lib/interview-summary.mjs +198 -0
  230. package/skills/weaver-e10-recruit-stage/lib/recruit-shortlist.mjs +697 -0
  231. package/skills/weaver-e10-recruit-stage/lib/recruit-write-helper.mjs +507 -0
  232. package/skills/weaver-e10-recruit-stage/references/env-fixed-values.md +87 -0
  233. package/skills/weaver-e10-recruit-stage/references/position-templates.md +19 -18
  234. package/skills/weaver-e10-recruit-stage/references/recruit-arrange-interview.md +19 -18
  235. package/skills/weaver-e10-recruit-stage/references/recruit-capability-check.md +1 -1
  236. package/skills/weaver-e10-recruit-stage/references/recruit-detail-process.md +1 -1
  237. package/skills/weaver-e10-recruit-stage/references/recruit-edit-interview-feedback.md +15 -2
  238. package/skills/weaver-e10-recruit-stage/references/recruit-failure-fallback.md +37 -0
  239. package/skills/weaver-e10-recruit-stage/references/recruit-interview-not-attended.md +4 -4
  240. package/skills/weaver-e10-recruit-stage/references/recruit-jd-create.md +64 -28
  241. package/skills/weaver-e10-recruit-stage/references/recruit-list-interview.md +43 -2
  242. package/skills/weaver-e10-recruit-stage/references/recruit-maint.md +41 -0
  243. package/skills/weaver-e10-recruit-stage/references/recruit-match-candidates.md +4 -4
  244. package/skills/weaver-e10-recruit-stage/references/recruit-my-positions.md +2 -2
  245. package/skills/weaver-e10-recruit-stage/references/recruit-output-links.md +25 -7
  246. package/skills/weaver-e10-recruit-stage/references/recruit-platform-compat.md +51 -0
  247. package/skills/weaver-e10-recruit-stage/references/recruit-report-templates.md +63 -0
  248. package/skills/weaver-e10-recruit-stage/references/recruit-resolve-metadata.md +4 -4
  249. package/skills/weaver-e10-recruit-stage/references/recruit-resume-import-batch.md +2 -2
  250. package/skills/weaver-e10-recruit-stage/references/recruit-resume-import.md +58 -33
  251. package/skills/weaver-e10-recruit-stage/references/recruit-resume-parse.md +4 -4
  252. package/skills/weaver-e10-recruit-stage/references/recruit-search-by-tag.md +5 -5
  253. package/skills/weaver-e10-recruit-stage/references/recruit-search-candidate.md +2 -2
  254. package/skills/weaver-e10-recruit-stage/references/recruit-tag-recommend.md +11 -10
  255. package/skills/weaver-e10-recruit-stage/references/recruit-urge-feedback.md +2 -2
  256. package/skills/weaver-e10-recruit-stage/references/recruit-utterance-glossary.md +2 -2
  257. package/skills/weaver-e10-recruit-stage/templates/candidate-evidence.html +106 -0
  258. package/skills/weaver-e10-recruit-stage/templates/interview-summary.html +325 -0
  259. package/skills/weaver-e10-recruit-stage/templates/match-report.html +265 -0
  260. package/skills/weaver-e10-shared/SKILL.md +22 -1
  261. package/skills/weaver-e10-shared/references/e10-auth-and-session.md +2 -2
  262. package/skills/weaver-e10-yimiaoban/references/source-manifest.json +3 -3
  263. package/skills/weaver-e10-jucailin/references/source-manifest.json +0 -152
@@ -23,20 +23,25 @@
23
23
  * ⚠️ 工作地点**不参与继承**:历史职位曾带出 detail_location 为「1」的脏地点。
24
24
  */
25
25
  import { createHash, randomBytes } from 'node:crypto';
26
- import { readFileSync } from 'node:fs';
26
+ import { readFileSync, writeFileSync, mkdirSync, existsSync, rmSync } from 'node:fs';
27
27
  import { resolve as resolvePath, dirname } from 'node:path';
28
28
  import { fileURLToPath } from 'node:url';
29
29
  import { rsSuccess, schemaOf } from './types.js';
30
30
  import { rsFail, rsValidationError, rsConfirmationError } from '../errors.js';
31
- import { objIdOf, formIdOf, saveFormData, getDsOptions, getFormDataRecord, resolvePersonId, findMenuNode, resolveCurrentUser, buildCardUrl, buildListUrl, randHex32, dsOptionsSnapshot, restoreDsOptions, invalidateEnvCache, verifySubmitted, expectedFields, probeCreatePermission, } from '../shared.js';
31
+ import { objIdOf, formIdOf, saveFormData, getDsOptions, getFormDataRecord, resolvePersonId, findMenuNode, resolveCurrentUser, resolveCurrentUserOrg, buildCardUrl, buildListUrl, randHex32, dsOptionsSnapshot, restoreDsOptions, invalidateEnvCache, verifySubmitted, expectedFields, probeCreatePermission, } from '../shared.js';
32
+ import { toMenuList } from '../../ehr/operations/shared.js';
32
33
  const SCHEMA_ID_STR = { type: 'string', description: '18 位记录 id(字符串)' };
33
34
  // 职位管理表单字段 dataKey(缓存 fields 里取;不写死 fieldId)
34
35
  const DATAKEYS_TEXT = ['position_name'];
35
36
  const DATAKEYS_MTEXT = ['position_duty', 'work_request'];
36
37
  // 必填字段默认值策略
37
- const DEF_TEXT = { recruit_count: '1', number_of_pay_months: '12' };
38
+ // 🔴 2026-11-28 用户口径:招聘人数默认 3(原 1)。
39
+ const DEF_TEXT = { recruit_count: '3', number_of_pay_months: '12' };
38
40
  const DEF_OPTION = { salary_type: '月薪', recruit_type: '社会招聘' };
39
- const DEF_CURRENT_USER = ['recr_principal', 'employ_manager'];
41
+ // 人员型默认 = 当前登录人(招聘负责人 + 用人经理 + 面试官)
42
+ // 🔴 2026-11-28 用户口径补充:面试官(interviewer)同样默认当前人。此前只列了前两个,
43
+ // 导致该字段一直留空。用户显式用 sets 指定时以用户为准(下面按 hasKey 判重)。
44
+ const DEF_CURRENT_USER = ['recr_principal', 'employ_manager', 'interviewer'];
40
45
  // 🔴 薪资(salary_min / salary_max)必须继承,不能留空:这两个字段是**职位表单必填项**,
41
46
  // 不传会导致后端必填校验失败、建职位直接报错(2026-11-06 实测:移除继承后 willSubmit 无薪资字段)。
42
47
  // 但历史薪资确实可能是脏数据(实测抓到 300 元月薪),因此不静默使用:
@@ -57,6 +62,54 @@ const DEF_STATUS = '招聘中';
57
62
  // (2026-11-06 实测:某在册地点 detail_location 就是 "1" 且状态为启用),故 work_location 已从
58
63
  // DEF_FROM_REF 移除,改由本默认地点解析;匹配不到则不写该字段并点名,不臆造 id。
59
64
  const DEFAULT_WORK_LOCATION = '浦江镇三鲁公路3419号泛微软件园';
65
+ // 🔴 固定字典默认值(2026-11-28 用户口径):继承不到时按环境实际字典值固定,不再留空。
66
+ // 取值必须与目标环境字典一致,否则 dictIdByName 解析不到就不会写入(宁可不写,也不臆造 id)。
67
+ // 本环境自用字典实测:职位属性=[全职/兼职/实习]、学历=[不限/大专/本科/硕士/博士]、
68
+ // 工作年限=[不限](只有这一个值,不要写「3-5年」)、职位序列=[不限/技术/销售/职能]。
69
+ const DEF_DICT = {
70
+ position_nature: '全职',
71
+ education: '本科',
72
+ work_years: '不限',
73
+ // 🔴 2026-11-28 用户口径:招聘优先级默认「中」(该字段走数据字典 低/中/高)
74
+ recruit_priority: '中',
75
+ };
76
+ /**
77
+ * 枚举(field_options)类默认值:可多值。
78
+ *
79
+ * 🔴 2026-11-28 用户口径:默认没提就按这里填,用户显式传了(sets)就以用户为准。
80
+ * 取值必须与目标环境 field_options 完全一致,否则解析不到就不写(宁可不写,也不臆造 optionId)。
81
+ *
82
+ * ⚠️ 与 DEF_OPTION 的区别:DEF_OPTION 走 getDsOptions(额外 HTTP);
83
+ * 这里的字段在环境缓存 field_options 里已有完整 optionId→名称映射,
84
+ * 直接读缓存即可,**零额外请求**(见 putCacheOptionDefault)。
85
+ *
86
+ * 本环境实测选项:
87
+ * · internal_channels(内部招聘渠道)=[内部推荐, 内部遴选]
88
+ * · third_party_platform(第三方平台)=[BOSS直聘, 猎聘, 拉勾, 前程无忧, 智联招聘]
89
+ */
90
+ const DEF_CACHE_OPTION = {
91
+ // 用户表述为「内部招聘」,该字段实际只有这两个选项,即内部招聘的全部渠道
92
+ internal_channels: ['内部推荐', '内部遴选'],
93
+ third_party_platform: ['BOSS直聘', '前程无忧'],
94
+ };
95
+ // 职位序列按岗位族推断(字典通常只有 技术/销售/职能 三档),推断不到用技术
96
+ const DEFAULT_JOB_CATEGORY = '技术';
97
+ // 招聘截止日期默认:今天 + 60 天(覆盖一个完整招聘周期)
98
+ const DEFAULT_DAYS_TO_DEADLINE = 60;
99
+ // 🔴 薪酬区间必填兜底(2026-11-28 用户口径):最低 18 / 最高 30,**单位是「千」**,
100
+ // 与表单页面一致(页面 18.00 = 18K)。这两个字段是职位表单必填项,留空会导致保存校验失败。
101
+ // ⚠️ 不要传「元」:resolveSetValue 只对**用户显式 sets 输入**做 ÷1000 换算,
102
+ // 这里的默认值是直接写入的面板值,传 18000 会被当成 18000K。
103
+ const DEF_SALARY = { salary_min: '18', salary_max: '30' };
104
+ /** 按岗位名推断职位序列族别:销售 → 销售;职能类 → 职能;其余(研发/实施/产品/项目)→ 技术 */
105
+ function inferJobCategory(positionName) {
106
+ const n = String(positionName || '');
107
+ if (/销售|客户经理|商务|大客户|渠道|BD|城市负责|区域负责|拓展/i.test(n))
108
+ return '销售';
109
+ if (/人力|行政|财务|法务|会计|招聘|HR|人事|薪酬|绩效|审计|合规|秘书/i.test(n))
110
+ return '职能';
111
+ return DEFAULT_JOB_CATEGORY;
112
+ }
60
113
  // sets 覆盖解析:字段取值类别
61
114
  const NUM_KEYS = new Set(['recruit_count', 'number_of_pay_months', 'salary_min', 'salary_max', 'internship_duration', 'working_days']);
62
115
  const PERSON_KEYS = new Set(['recr_principal', 'recr_helper', 'employ_manager', 'interviewer']);
@@ -157,11 +210,11 @@ async function fetchAllMenusFlat(ctx) {
157
210
  method: 'GET',
158
211
  });
159
212
  const flat = [];
160
- (function walk(ns) { for (const n of (ns || []))
213
+ (function walk(ns) { for (const n of toMenuList(ns))
161
214
  if (n && typeof n === 'object') {
162
215
  flat.push(n);
163
- walk(n.children || n.childs);
164
- } })(r?.data?.cusAppMenus || r?.data);
216
+ walk(n.children ?? n.childs);
217
+ } })(r?.data);
165
218
  allMenusMemo.set(key, flat);
166
219
  return flat;
167
220
  }
@@ -191,6 +244,100 @@ async function findWorkPlaceMenu(ctx) {
191
244
  catch { /* 接口不可用则放弃 */ }
192
245
  return null;
193
246
  }
247
+ // ── 招聘流程「数据兜底」:缓存取不到时直接从列表数据解析 ──────────────────────────
248
+ // 🔴 2026-11-28 向下兼容:默认招聘流程原本只读 cache.defaultRecruitFlow,
249
+ // 而该值由 context 层解析、受「探测失败标记」影响可能长期为空(一次失败记住 6 小时),
250
+ // 结果新建职位时 recruit_flow 一直留空。这里补一条**纯数据路径**:
251
+ // 菜单用 cache.lists.all_search 定位(本地已有的结构元数据),再用 listInit 反查表单 objId、
252
+ // getListDatas 取流程行,挑选默认启用行——与 context 层 ① 通道同源,但不依赖其缓存结果与失败标记。
253
+ const FLOW_MENU_NAMES = ['招聘流程'];
254
+ const flowDataMemo = new Map();
255
+ /** 「默认启用」判定:兼容多种字段命名与中英文取值(与 context 层口径一致) */
256
+ function isDefaultFlowRow(x) {
257
+ if (!x || typeof x !== 'object')
258
+ return false;
259
+ const cands = [x.is_default, x.isDefault, x.default_flow, x.defaultFlow, x.is_enable, x.enabled, x.status];
260
+ for (const v of cands) {
261
+ if (v === true || v === 1 || v === '1')
262
+ return true;
263
+ const s = String(v ?? '');
264
+ if (s === '是' || s === '启用' || s === '默认')
265
+ return true;
266
+ }
267
+ return false;
268
+ }
269
+ async function resolveFlowByData(ctx) {
270
+ const { host, appId, cache } = ctx;
271
+ // 菜单定位三级来源(与 findWorkPlaceMenu 完全同构):结构缓存缺失时仍能靠接口拿到入口
272
+ let menu = null;
273
+ const allSearch = ((cache.lists || {}).all_search || []);
274
+ menu = allSearch.find((m) => m && m.listId && FLOW_MENU_NAMES.some((n) => String(m.menuName || '').includes(n))) || null;
275
+ if (!menu) {
276
+ const hit2 = findMenuNode(cache.menus || [], FLOW_MENU_NAMES, (m) => m && m.listId);
277
+ if (hit2)
278
+ menu = hit2;
279
+ }
280
+ if (!menu) {
281
+ const flat = await fetchAllMenusFlat(ctx);
282
+ const hit3 = findMenuNode(flat, FLOW_MENU_NAMES, (m) => m && m.listId);
283
+ if (hit3)
284
+ menu = hit3;
285
+ }
286
+ if (!menu || !menu.listId)
287
+ return null;
288
+ const key = appId + '|' + String(menu.listId);
289
+ if (flowDataMemo.has(key))
290
+ return flowDataMemo.get(key) ?? null;
291
+ try {
292
+ // passid/cid 必须是表单 objId,不是 listId:先用 listInit 反查
293
+ let flowObjId = '';
294
+ try {
295
+ const liBody = {
296
+ cusMenuId: menu.cusMenuId || '',
297
+ listId: String(menu.listId),
298
+ urlPageTitle: String(menu.menuName || '招聘流程'),
299
+ };
300
+ liBody['appId_' + String(menu.listId)] = appId;
301
+ const li = await host.request({ path: '/api/ebuilder/form/list/listInit', body: liBody });
302
+ flowObjId = String(li?.data?.objid || '');
303
+ }
304
+ catch { /* listInit 不可用 → 走 tag 兜底 */ }
305
+ if (!flowObjId) {
306
+ const t = await host
307
+ .request({ path: `/api/ebuilder/form/obj/getObjsByTag?appId=${appId}&tag=uf_rcrt_recruit_flow`, method: 'GET' })
308
+ .catch(() => null);
309
+ flowObjId = Array.isArray(t?.data) && t.data[0] ? String(t.data[0].id || '') : '';
310
+ }
311
+ if (!flowObjId) {
312
+ flowDataMemo.set(key, null);
313
+ return null;
314
+ }
315
+ const body = {
316
+ current: 1, pageSize: 50, tableuid: randHex32(),
317
+ listId: String(menu.listId), searchParamData: { searchType: '3', type: 'and' },
318
+ terminal: 'PC', browser: 'Chrome', requiredMatch: 1, mapResult: 1,
319
+ recheckQuery: 1, isFollow: 0, isShareToMe: 0, filterCondition: {},
320
+ cusMenuId: String(menu.cusMenuId || ''), urlPageTitle: String(menu.menuName || '招聘流程'),
321
+ menuName: String(menu.menuName || '招聘流程'),
322
+ };
323
+ const r = await host.request({
324
+ path: `/api/ebuilder/form/list/getListDatas?passid=${flowObjId}&cid=${flowObjId}`,
325
+ body,
326
+ headers: { ebBusinessId: String(menu.listId) },
327
+ });
328
+ const rows = ((r?.data?.data || r?.data?.displayData || []) || []).filter(Boolean);
329
+ const pick = rows.find(isDefaultFlowRow) || (rows.length === 1 ? rows[0] : null);
330
+ const id = pick ? String(pick.form_data_id || pick.id || '') : '';
331
+ const name = pick ? stripHtml(pick.name || pick.flow_name || pick.content || '') : '';
332
+ const out = id && name ? { id, name } : null;
333
+ flowDataMemo.set(key, out);
334
+ return out;
335
+ }
336
+ catch {
337
+ flowDataMemo.set(key, null);
338
+ return null;
339
+ }
340
+ }
194
341
  // 仅进程内 memo(不落盘):同一 CLI 进程内 prepare/apply 及多个 set 复用一次列表请求。
195
342
  // 记录 id / 启用状态 optionId 一律运行时从列表解析,跨环境不缓存、不写死。
196
343
  const workPlaceMemo = new Map();
@@ -481,10 +628,13 @@ async function buildJd(opts) {
481
628
  if (!fid(k))
482
629
  throw rsFail('职位管理缺少字段 ' + k + '(ds/fields 解析不到)');
483
630
  // 并行预取:refByFid(sets 解析依赖它)与 currentUser(仅第⑤步用,与 sets 无依赖)
484
- // 同时发出,避免过去「先等 refByFid → 再逐 set 串行 → 最后才取 currentUser」的多余 RTT。
631
+ // 🔴 2026-11-27 优化:当 sets 已覆盖全部 DEF_FROM_REF 字段时跳过 fetchRefByFid(省 2 HTTP)。
632
+ // dict 解析回退到无 group 搜索(dictIdByName(cache, value, '')),自用环境字典无歧义,结果一致。
633
+ const setsKeys = new Set(sets.map(([k]) => k));
634
+ const needsRefByFid = !DEF_FROM_REF.every(k => setsKeys.has(k));
485
635
  const currentUserPromise = resolveCurrentUser(host)
486
636
  .catch(() => null);
487
- const refByFid = await fetchRefByFid(ctx);
637
+ const refByFid = needsRefByFid ? await fetchRefByFid(ctx) : {};
488
638
  const map = new Map();
489
639
  const put = (d) => { if (d && d.formField && d.formField.id)
490
640
  map.set(String(d.formField.id), d); };
@@ -516,18 +666,54 @@ async function buildJd(opts) {
516
666
  skippedSets.push(k + '=' + v);
517
667
  }
518
668
  }
669
+ /**
670
+ * 枚举字段取 optionId:**缓存优先**,缓存没有才回退 ds/options。
671
+ *
672
+ * 背景(2026-11-28 性能优化):招聘状态 / 薪酬类型 / 招聘方式 三个字段此前每次建职位
673
+ * 都各发一次 ds/options,共 3 个 RTT;而环境缓存 field_options 里早就有完整的
674
+ * optionId → 名称映射,属于纯粹可省的往返。缓存命中时整条链路零额外请求。
675
+ *
676
+ * 保留回退的原因:field_options 可能因解析降级/旧版本缓存而缺失该字段,此时仍需能建职位。
677
+ */
678
+ const cacheOptionId = (key, name) => {
679
+ const id = fid(key);
680
+ if (!id)
681
+ return '';
682
+ const optMap = (cache.field_options?.[objId] || {})[String(id)] || {};
683
+ for (const oid of Object.keys(optMap)) {
684
+ if (String(optMap[oid]) === name)
685
+ return String(oid);
686
+ }
687
+ return '';
688
+ };
689
+ const optionIdOf = async (key, name) => {
690
+ const hit = cacheOptionId(key, name);
691
+ if (hit)
692
+ return hit;
693
+ const id = fid(key);
694
+ if (!id)
695
+ return '';
696
+ const m = await getDsOptions(host, objId, id).catch(() => ({}));
697
+ return String(m[name] || '');
698
+ };
519
699
  // ③ 默认值:招聘状态 = 招聘中
520
700
  if (!hasKey('status')) {
521
701
  if (!fid('status'))
522
702
  throw rsFail('职位管理缺少字段 status(ds/fields 解析不到)');
523
- const statusMap = await getDsOptions(host, objId, fid('status'));
524
- const statusId = statusMap[DEF_STATUS];
703
+ const statusId = await optionIdOf('status', DEF_STATUS);
525
704
  if (!statusId)
526
- throw rsFail('职位管理「招聘状态」未解析到「' + DEF_STATUS + '」选项(ds/options 返回为空)');
527
- put({ formField: { id: fid('status') }, dataOptions: [{ optionId: String(statusId), content: DEF_STATUS }] });
705
+ throw rsFail('职位管理「招聘状态」未解析到「' + DEF_STATUS + '」选项(缓存 field_options 与 ds/options 均未命中)');
706
+ put({ formField: { id: fid('status') }, dataOptions: [{ optionId: statusId, content: DEF_STATUS }] });
528
707
  }
529
708
  // ④ 默认值:招聘流程 = 环境默认启用的流程
530
- const defFlow = cache.defaultRecruitFlow;
709
+ // 🔴 向下兼容(2026-11-28):缓存里没有 defaultRecruitFlow,或该值因「探测失败标记」被置空时,
710
+ // 直接走数据兜底 resolveFlowByData 从「招聘流程」列表解析一次,避免该字段长期留空。
711
+ let defFlow = cache.defaultRecruitFlow;
712
+ let flowFromData = false;
713
+ if (!hasKey('recruit_flow') && fid('recruit_flow') && (!defFlow || !defFlow.id)) {
714
+ defFlow = await resolveFlowByData(ctx).catch(() => null);
715
+ flowFromData = !!(defFlow && defFlow.id);
716
+ }
531
717
  if (!hasKey('recruit_flow') && fid('recruit_flow') && defFlow && defFlow.id) {
532
718
  put({ formField: { id: fid('recruit_flow') }, dataOptions: [{ optionId: String(defFlow.id), content: defFlow.name }] });
533
719
  }
@@ -554,10 +740,9 @@ async function buildJd(opts) {
554
740
  }
555
741
  for (const [k, name] of Object.entries(DEF_OPTION)) {
556
742
  if (fid(k) && !hasKey(k)) {
557
- const m = await getDsOptions(host, objId, fid(k));
558
- const oid = m[name];
743
+ const oid = await optionIdOf(k, name);
559
744
  if (oid) {
560
- put({ formField: { id: fid(k) }, dataOptions: [{ optionId: String(oid), content: name }] });
745
+ put({ formField: { id: fid(k) }, dataOptions: [{ optionId: oid, content: name }] });
561
746
  filled.push(k);
562
747
  }
563
748
  }
@@ -577,6 +762,132 @@ async function buildJd(opts) {
577
762
  }
578
763
  }
579
764
  }
765
+ // ⑥-2 固定默认值兜底(不再留空):只有在「用户未指定 + 继承也没拿到」时才套用。
766
+ // 优先级保持 用户 sets > 环境继承 > 固定默认值,避免用写死值覆盖环境真实数据。
767
+ const defaultedFields = [];
768
+ // 🔴 A 告警(2026-11-28):环境缺少某个字典项/枚举项时,默认值会「静默不写」。
769
+ // 这里显式记录「想填但填不上」的项,在摘要里点名——避免用户以为默认值已生效、
770
+ // 实际字段却留空(后端对无效 optionId 是静默丢弃)。
771
+ const defaultSkipped = [];
772
+ const putDictDefault = (key, name) => {
773
+ const id = fid(key);
774
+ if (!id || map.has(String(id)))
775
+ return false;
776
+ const group = dictGroupOf(cache, detailValueId(refByFid[String(id)]));
777
+ const did = dictIdByName(cache, name, group) || dictIdByName(cache, name, '');
778
+ if (!did)
779
+ return false; // 环境字典里没有这个值:不写、不臆造
780
+ put({ formField: { id }, dataOptions: [{ optionId: String(did), content: name }] });
781
+ filled.push(key);
782
+ defaultedFields.push({ field: key, value: name });
783
+ return true;
784
+ };
785
+ /**
786
+ * 枚举(field_options)默认值,支持多选。
787
+ * 直接读环境缓存 field_options[objId][fid](optionId → 名称),**不发请求**。
788
+ * 一个都匹配不到就不写,避免把无效 optionId 提交上去(后端会静默丢弃)。
789
+ */
790
+ const putCacheOptionDefault = (key, names) => {
791
+ const id = fid(key);
792
+ if (!id || map.has(String(id)))
793
+ return false;
794
+ const picked = [];
795
+ const missed = [];
796
+ for (const name of names) {
797
+ const oid = cacheOptionId(key, name);
798
+ if (oid)
799
+ picked.push({ optionId: oid, content: name });
800
+ else
801
+ missed.push(name);
802
+ }
803
+ if (!picked.length) {
804
+ // A 告警:一个都没匹配到 → 不写(避免提交无效 optionId),但必须留痕
805
+ defaultSkipped.push({
806
+ field: key,
807
+ wanted: names.join('、'),
808
+ reason: '环境 field_options 中不存在该选项,本次未填(该字段可能留空)',
809
+ });
810
+ return false;
811
+ }
812
+ put({ formField: { id }, dataOptions: picked });
813
+ filled.push(key);
814
+ defaultedFields.push({ field: key, value: picked.map((p) => p.content).join('、') });
815
+ if (missed.length) {
816
+ // 部分命中:已填部分,未命中的同样点名,避免「以为两个都填了」
817
+ defaultSkipped.push({
818
+ field: key,
819
+ wanted: missed.join('、'),
820
+ reason: '部分选项在环境中不存在,仅填入已命中的值',
821
+ });
822
+ }
823
+ return true;
824
+ };
825
+ for (const [k, name] of Object.entries(DEF_DICT))
826
+ putDictDefault(k, name);
827
+ // 职位序列:按岗位名推断族别(技术/销售/职能),环境无该值则跳过
828
+ putDictDefault('job_category', inferJobCategory(positionName));
829
+ // 内部招聘渠道 / 第三方平台:走缓存枚举,零额外请求
830
+ for (const [k, names] of Object.entries(DEF_CACHE_OPTION))
831
+ putCacheOptionDefault(k, names);
832
+ // 招聘截止日期:默认今天 + 60 天(纯日期字段,格式 YYYY-MM-DD)
833
+ const deadlineFid = fid('recruitment_deadline');
834
+ if (deadlineFid && !map.has(String(deadlineFid))) {
835
+ const d = new Date();
836
+ d.setDate(d.getDate() + DEFAULT_DAYS_TO_DEADLINE);
837
+ const pad = (x) => String(x).padStart(2, '0');
838
+ const deadline = d.getFullYear() + '-' + pad(d.getMonth() + 1) + '-' + pad(d.getDate());
839
+ put({ formField: { id: deadlineFid }, content: deadline });
840
+ filled.push('recruitment_deadline');
841
+ defaultedFields.push({ field: 'recruitment_deadline', value: deadline });
842
+ }
843
+ // ⑥-3 薪酬区间必填兜底:最低 18 / 最高 30(单位「千」,与页面一致)
844
+ // 走这里而不是 DEF_TEXT:DEF_TEXT 在继承之前执行,会让固定默认值盖过环境继承;
845
+ // 放在继承之后才符合「用户 sets > 环境继承 > 固定默认值」的既定优先级。
846
+ for (const [k, v] of Object.entries(DEF_SALARY)) {
847
+ const id = fid(k);
848
+ if (!id || map.has(String(id)))
849
+ continue;
850
+ put({ formField: { id }, content: v });
851
+ filled.push(k);
852
+ defaultedFields.push({ field: k, value: v });
853
+ }
854
+ // ⑥-4 组织默认:职位所属分部 / 职位所属部门 = 当前登录人所在分部与部门
855
+ // 🔴 这两个是浏览按钮字段,提交只认**记录 id**;只传名称会被后端静默丢弃(页面留空但不报错),
856
+ // 所以必须从 teamsCheck 的 currentUser 里连同 id 一起取。
857
+ // 取不到 id 就保持留空并在摘要里点名,绝不拿名称当 id 硬写。
858
+ const needOrg = ['sub_company', 'department'].some((k) => { const id = fid(k); return !!id && !map.has(String(id)); });
859
+ // 🔴 C 告警(2026-11-28):组织字段取不到记录 id 时保持留空,但必须留痕。
860
+ // 此前该分支完全静默,用户只会看到「部门/分部空着」,不知道是环境问题还是自己没填。
861
+ // 口径对齐 workLocationWarning:不阻断创建,但摘要里点名原因 + 给出补救方式(sets)。
862
+ let orgDefaultWarning = null;
863
+ if (needOrg) {
864
+ const org = await resolveCurrentUserOrg(host).catch(() => null);
865
+ if (!org) {
866
+ orgDefaultWarning = '未能解析当前登录人的所属组织(teamsCheck 不可用),本次不写「职位所属分部 / 职位所属部门」;请用 sets 指定';
867
+ }
868
+ else {
869
+ if (fid('sub_company') && !hasKey('sub_company')) {
870
+ if (org.subCompanyId) {
871
+ put({ formField: { id: fid('sub_company') }, dataOptions: [{ optionId: org.subCompanyId, content: org.subCompanyName }] });
872
+ filled.push('sub_company');
873
+ defaultedFields.push({ field: 'sub_company', value: org.subCompanyName });
874
+ }
875
+ else {
876
+ defaultSkipped.push({ field: 'sub_company', wanted: '当前人所在分部', reason: 'teamsCheck 未返回分部记录 id(subCompanyId),本次未填' });
877
+ }
878
+ }
879
+ if (fid('department') && !hasKey('department')) {
880
+ if (org.departmentId) {
881
+ put({ formField: { id: fid('department') }, dataOptions: [{ optionId: org.departmentId, content: org.departmentName }] });
882
+ filled.push('department');
883
+ defaultedFields.push({ field: 'department', value: org.departmentName });
884
+ }
885
+ else {
886
+ defaultSkipped.push({ field: 'department', wanted: '当前人所在部门', reason: 'teamsCheck 未返回部门记录 id,本次未填' });
887
+ }
888
+ }
889
+ }
890
+ }
580
891
  // 继承来的薪资若明显偏低(历史脏数据,实测出现过 300 元月薪),额外点名提示。
581
892
  // 不阻断提交(薪资是必填项,阻断等于无法建档),但要求 Agent 在确认摘要里明确提示用户核对。
582
893
  const inheritedSalaryWarnings = [];
@@ -620,6 +931,8 @@ async function buildJd(opts) {
620
931
  status: DEF_STATUS,
621
932
  // 解析不到环境默认流程时不写该字段,表单自身默认值生效;文案按实际行为表述,避免误导。
622
933
  recruitFlow: (defFlow && defFlow.id) ? defFlow.name : '(沿用表单默认值)',
934
+ // 流程来源:cache=上下文缓存命中;data=缓存缺失时从「招聘流程」列表数据兜底解析
935
+ recruitFlowSource: (defFlow && defFlow.id) ? (flowFromData ? 'data' : 'cache') : undefined,
623
936
  currentUser: currentUser ? currentUser.name : null,
624
937
  setApplied: appliedSets,
625
938
  setSkipped: skippedSets,
@@ -632,6 +945,18 @@ async function buildJd(opts) {
632
945
  : undefined,
633
946
  workLocationDefault: workLocationDefault || undefined,
634
947
  workLocationWarning: workLocationWarning || undefined,
948
+ // A/C 告警:想填但填不上的默认值(环境缺选项 / 取不到记录 id)。不阻断创建,但必须让用户看见,
949
+ // 否则会出现「摘要说已默认填写、实际字段留空」这种最难排查的情况。
950
+ defaultSkipped: defaultSkipped.length ? defaultSkipped : undefined,
951
+ defaultSkippedNote: defaultSkipped.length
952
+ ? '以上默认值未能填入(环境缺少对应选项,或取不到记录 id),对应字段可能留空;请核对后用 sets 显式指定'
953
+ : undefined,
954
+ orgDefaultWarning: orgDefaultWarning || undefined,
955
+ // 本次自动补上的固定默认值(用户未指定、继承也没拿到):摘要里明示,便于创建前核对
956
+ defaultedFields: defaultedFields.length ? defaultedFields : undefined,
957
+ defaultedNote: defaultedFields.length
958
+ ? '以上字段未指定,已按招聘助手固定默认值自动填入(可随时用 sets 覆盖)'
959
+ : undefined,
635
960
  requiredDefaultsFilled,
636
961
  },
637
962
  };
@@ -690,15 +1015,19 @@ async function prepare(args, env) {
690
1015
  const fp = fingerprint(willSubmit);
691
1016
  const continuation = await env.continuation.issue({ operation: 'recruit-stage.jd.create.apply', fingerprint: fp,
692
1017
  enumMaps: await dsOptionsSnapshot(),
693
- // 🔴 2026-11-07 修复:协议文档写「apply 带 confirm + continuation」,但 apply 原来只从 args 取
694
- // positionName/positionDuty/...,Agent 少传 positionName 就直接报 position_name_required。
695
- // 现把 prepare 用过的业务参数一并签进 continuation;apply 显式传的仍优先。
1018
+ // 🔴 2026-11-27 优化:签入 willSubmit(已解析的完整提交数据)和 summary,
1019
+ // apply 有 willSubmit 时直接用,跳过 buildJd(省 ~10 个 HTTP 请求,5-8 秒)。
1020
+ willSubmit,
1021
+ summary: jd.summary,
1022
+ // 🔴 2026-11-27 修复:argsSnapshot 漏签了 sets,apply 不传 sets 时 buildJd 产出空 sets
1023
+ // → 指纹不一致 → fingerprint_mismatch。现在补上。
696
1024
  argsSnapshot: {
697
1025
  positionName: String(args.positionName || ''),
698
1026
  positionDuty: args.positionDuty ? String(args.positionDuty) : undefined,
699
1027
  workRequest: args.workRequest ? String(args.workRequest) : undefined,
700
1028
  demandId: args.demandId ? String(args.demandId) : undefined,
701
1029
  demandName: args.demandName ? String(args.demandName) : undefined,
1030
+ sets: args.sets,
702
1031
  } });
703
1032
  // 回执体积控制:continuation 与 fingerprint 放在返回体最前,避免大输出被截断时 Agent 取不到它们
704
1033
  // 而重复调用 prepare(实测多花 10.7s)。
@@ -793,6 +1122,77 @@ async function prepare(args, env) {
793
1122
  confirmHint: '用户明确确认后,携带 confirm:true 与本 continuation 调用 recruit-stage.jd.create.apply',
794
1123
  });
795
1124
  }
1125
+ // ── 职位新建幂等:中断续跑标记(防「保存成功、提交失败 → 重跑又建一条」)──────────
1126
+ // 落盘位置与 refs 同级(state 目录),10 分钟窗口内同名可复用;提交成功即删。
1127
+ export const JD_PENDING_TTL_MS = 10 * 60 * 1000;
1128
+ export function jdPendingFile(positionName) {
1129
+ const home = process.env.USERPROFILE || process.env.HOME || '.';
1130
+ const key = createHash('sha1').update(positionName).digest('hex').slice(0, 16);
1131
+ return resolvePath(home, '.weaver-work-cli', 'state', 'jd-pending', key + '.json');
1132
+ }
1133
+ export function readJdPending(positionName) {
1134
+ try {
1135
+ const p = jdPendingFile(positionName);
1136
+ if (!existsSync(p))
1137
+ return null;
1138
+ const j = JSON.parse(readFileSync(p, 'utf8'));
1139
+ if (String(j.positionName || '') !== positionName)
1140
+ return null;
1141
+ if (!j.formDataId)
1142
+ return null;
1143
+ if (Date.now() - Number(j.savedAt || 0) > JD_PENDING_TTL_MS)
1144
+ return null;
1145
+ return { formDataId: String(j.formDataId), savedAt: Number(j.savedAt) };
1146
+ }
1147
+ catch {
1148
+ return null;
1149
+ }
1150
+ }
1151
+ export function writeJdPending(positionName, formDataId) {
1152
+ try {
1153
+ const p = jdPendingFile(positionName);
1154
+ mkdirSync(dirname(p), { recursive: true });
1155
+ writeFileSync(p, JSON.stringify({ positionName, formDataId, savedAt: Date.now() }), 'utf8');
1156
+ }
1157
+ catch { /* 标记落盘失败不阻断写入 */ }
1158
+ }
1159
+ export function clearJdPending(positionName) {
1160
+ try {
1161
+ const p = jdPendingFile(positionName);
1162
+ if (existsSync(p))
1163
+ rmSync(p);
1164
+ }
1165
+ catch { /* ignore */ }
1166
+ }
1167
+ // 记录当前 status 选项名(待发布 / 招聘中 / 招聘结束),用于判断「职位是否已真正生成」
1168
+ // 🔴 2026-11-28 用户口径:职位创建后默认就是「招聘中」,不需要先「待发布」;
1169
+ // 所以只要读到的状态不是「待发布」,就说明 ② addPosition 已经成功,可安全跳过重复提交。
1170
+ async function jdStatusName(ctx, formId, objId, dataId) {
1171
+ try {
1172
+ const rec = await getFormDataRecord(ctx.host, formId, dataId, objId);
1173
+ const dets = rec?.dataDetails || [];
1174
+ const statusFid = String((ctx.cache.fields[objId] || {})['status'] || '');
1175
+ const cell = dets.find((d) => String(d.fieldId) === statusFid && !d.subFormId);
1176
+ if (!cell)
1177
+ return '';
1178
+ const direct = String(cell.dataOptions?.[0]?.content || cell.content || '');
1179
+ if (direct)
1180
+ return direct;
1181
+ // 有些环境选项字段只回 optionId 不回 content;此时用 ds/options 反查名称,
1182
+ // 否则判不出「招聘中 vs 待发布」→ 续跑会重复提交 addPosition(幂等保护失效)。
1183
+ const oid = String(cell.dataOptions?.[0]?.optionId || '');
1184
+ if (oid) {
1185
+ const map = await getDsOptions(ctx.host, objId, statusFid).catch(() => ({}));
1186
+ const hit = Object.keys(map).find((k) => String(map[k]) === oid);
1187
+ if (hit)
1188
+ return hit;
1189
+ }
1190
+ return '';
1191
+ }
1192
+ catch {
1193
+ return '';
1194
+ }
1195
+ }
796
1196
  async function apply(args, env) {
797
1197
  if (args.confirm !== true)
798
1198
  throw rsConfirmationError('recruit-stage.jd.create.apply', { hint: '写操作必须显式 confirm:true' });
@@ -810,24 +1210,66 @@ async function apply(args, env) {
810
1210
  const positionName = String(merged.positionName || '').trim();
811
1211
  if (!positionName)
812
1212
  throw rsValidationError('position_name_required', 'positionName 必填');
813
- const jd = await buildJd({
814
- ctx, positionName,
815
- duty: merged.positionDuty ? String(merged.positionDuty) : undefined,
816
- requestText: merged.workRequest ? String(merged.workRequest) : undefined,
817
- demandId: merged.demandId ? String(merged.demandId) : undefined,
818
- demandName: merged.demandName ? String(merged.demandName) : undefined,
819
- sets: setsOf(merged),
820
- });
821
- const willSubmit = { formId: jd.formId, objId: jd.objId, dataDetails: jd.dataDetails };
822
- if (payload.fingerprint !== fingerprint(willSubmit)) {
823
- throw rsValidationError('fingerprint_mismatch', '待提交内容与 prepare 确认摘要不一致(字段值已变化),请重新 prepare 确认后再 apply');
1213
+ // 🔴 2026-11-27 优化:prepare 签入了 willSubmit(已解析的完整 dataDetails),
1214
+ // apply 直接用,跳过 buildJd(省 ~10 个 HTTP 请求,5-8 秒)。
1215
+ // 旧 continuation(无 willSubmit)走原逻辑:buildJd + 指纹比对(argsSnapshot 已补 sets,不会再 mismatch)。
1216
+ let jd;
1217
+ if (payload.willSubmit) {
1218
+ const ws = payload.willSubmit;
1219
+ jd = { objId: ws.objId, formId: ws.formId, appId: ctx.appId, dataDetails: ws.dataDetails, summary: payload.summary || {} };
1220
+ }
1221
+ else {
1222
+ jd = await buildJd({
1223
+ ctx, positionName,
1224
+ duty: merged.positionDuty ? String(merged.positionDuty) : undefined,
1225
+ requestText: merged.workRequest ? String(merged.workRequest) : undefined,
1226
+ demandId: merged.demandId ? String(merged.demandId) : undefined,
1227
+ demandName: merged.demandName ? String(merged.demandName) : undefined,
1228
+ sets: setsOf(merged),
1229
+ });
1230
+ const willSubmit = { formId: jd.formId, objId: jd.objId, dataDetails: jd.dataDetails };
1231
+ if (payload.fingerprint !== fingerprint(willSubmit)) {
1232
+ throw rsValidationError('fingerprint_mismatch', '待提交内容与 prepare 确认摘要不一致(字段值已变化),请重新 prepare 确认后再 apply');
1233
+ }
824
1234
  }
825
1235
  // ① 保存职位管理表单 → ② addPosition 提交生成职位
826
- const formDataId = await saveFormData(host, {
827
- appId: jd.appId, formId: jd.formId, objId: jd.objId,
828
- name: '职位管理-' + positionName, dataDetails: jd.dataDetails,
829
- });
830
- const r2 = await host.request({ path: '/api/recruit/position/v2/addPosition?formDataId=' + formDataId, method: 'POST' });
1236
+ // 🔴 2026-11-28 幂等:中断续跑。上次「保存成功、提交失败」会留一条待发布记录,
1237
+ // 10 分钟内同名重跑直接复用该记录续跑 ②,不再新建第二条(历史重试会留下重复职位,人工得删)。
1238
+ let formDataId = '';
1239
+ let resumedFromPending = false;
1240
+ let alreadyCreated = false;
1241
+ const pending = readJdPending(positionName);
1242
+ if (pending) {
1243
+ const st = await jdStatusName(ctx, jd.formId, jd.objId, pending.formDataId);
1244
+ formDataId = pending.formDataId;
1245
+ resumedFromPending = true;
1246
+ // 状态已是招聘中/招聘结束 → 说明上次 ② 实际成功(响应异常导致的假失败),本次直接按成功返回
1247
+ if (st && st !== '待发布')
1248
+ alreadyCreated = true;
1249
+ }
1250
+ if (!formDataId) {
1251
+ try {
1252
+ formDataId = await saveFormData(host, {
1253
+ appId: jd.appId, formId: jd.formId, objId: jd.objId,
1254
+ name: '职位管理-' + positionName, dataDetails: jd.dataDetails,
1255
+ });
1256
+ }
1257
+ catch (e) {
1258
+ // 失败步骤 + 服务端原文一起抛出:不同环境的必填配置不一致,必须能一眼看出缺什么
1259
+ throw rsFail('① 保存职位管理表单失败:' + String(e?.message || e));
1260
+ }
1261
+ writeJdPending(positionName, formDataId);
1262
+ }
1263
+ let r2 = null;
1264
+ if (!alreadyCreated) {
1265
+ try {
1266
+ r2 = await host.request({ path: '/api/recruit/position/v2/addPosition?formDataId=' + formDataId, method: 'POST' });
1267
+ }
1268
+ catch (e) {
1269
+ // 保留续跑标记:下次同名重跑从 ② 继续,不再新建记录
1270
+ throw rsFail('② addPosition 生成职位失败(已保存的职位记录 id=' + formDataId + ' 已保留,10 分钟内重跑可续):' + String(e?.message || e));
1271
+ }
1272
+ }
831
1273
  const data = r2?.data || {};
832
1274
  const positionPostId = data.positionPostId;
833
1275
  const checkRpa = data.checkRpa;
@@ -837,7 +1279,7 @@ async function apply(args, env) {
837
1279
  // 🔴 2026-11-07 实测修正:`fail:false` 的真实语义是「没有失败」,旧写法 `r2?.fail !== false`
838
1280
  // 把「明确返回 fail:false」判成失败,于是职位已建成却返回 result=failed(ok:true)。
839
1281
  // 只有 `fail === true` 才算失败。
840
- const okByResponse = r2?.status !== false && r2?.fail !== true && data.fail !== true;
1282
+ const okByResponse = r2 ? (r2?.status !== false && r2?.fail !== true && data.fail !== true) : true;
841
1283
  // 第三层门禁:写完回查记录与关键字段,作为最终判定(接口语义不一致时以落库为准)
842
1284
  // 🔴 2026-11-07 扩展:此前只回查 position_name/status/salary/work_location(实测 checked 恒为 3),
843
1285
  // 正文两个最容易被静默丢弃的字段(position_duty / work_request)不在核对范围——写没写进去摘要看不出来。
@@ -850,6 +1292,11 @@ async function apply(args, env) {
850
1292
  invalidateEnvCache(ctx.baseUrl, ctx.appId);
851
1293
  const recordOk = verification.unavailable ? okByResponse : verification.mismatches.length === 0;
852
1294
  const created = okByResponse && recordOk;
1295
+ // 🔴 2026-11-28 修复(188 真机实测):成功后不再清标记。原逻辑 created → clearJdPending,
1296
+ // 于是「同参数再跑一次」读不到 pending,必新建第二条职位(实测两个 formDataId)。
1297
+ // 现改为保留最近一次成功记录(10 分钟窗口):重跑时 jdStatusName 判「非待发布」→ 直接按已创建返回。
1298
+ if (created)
1299
+ writeJdPending(positionName, formDataId);
853
1300
  const result = !created ? 'failed' : (verification.mismatches.length ? 'partial' : 'success');
854
1301
  // 列表链接只打开列表;详情单页由 viewLink 单独给出,两者不再合并成一个「列表+滑出详情」地址。
855
1302
  // 🔴 listId 走环境缓存运行时解析,**不在 CLI 内写死任何租户专属页面 id**(CLI 跨租户共享)。
@@ -860,6 +1307,9 @@ async function apply(args, env) {
860
1307
  mode: 'apply',
861
1308
  result,
862
1309
  formDataId,
1310
+ // 幂等语义(供 Agent 与用户判断"是否真的又建了一条")
1311
+ resumedFromPending,
1312
+ alreadyCreatedBeforeThisRun: alreadyCreated,
863
1313
  positionPostId: positionPostId || null,
864
1314
  rpaChecked: checkRpa === undefined ? null : !!checkRpa,
865
1315
  rpaValidMsg,
@@ -873,7 +1323,6 @@ async function apply(args, env) {
873
1323
  // 由 Agent 按 recruit-output-links.md「链接覆盖规则」替换 path 段后再输出。
874
1324
  viewLink: cardUrl ? `[查看 ${jd.summary.positionName || '新建职位'} 职位详情](${cardUrl})` : null,
875
1325
  listLocateLink: listUrl ? `[打开职位列表](${listUrl})` : null,
876
- agentNote: '查看入口 = 两个 Markdown 链接:① viewLink 职位详情单页(原样搬运,不改)② listLocateLink 职位列表——若技能「固定参数表」配置了本租户的固定页面路由,按 recruit-output-links.md 覆盖规则用固定路由替换 path 段(origin 取自 viewLink),否则原样搬运。不要包 browsertool / <artifact> 标签;缺哪个只给另一个,不输出半截。链接只是查看入口,重复点击不会重复创建。',
877
1326
  ...jd.summary,
878
1327
  });
879
1328
  }