weaver-work-cli 0.1.44 → 0.1.46

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (241) hide show
  1. package/README.md +9 -5
  2. package/dist/chunks/{archive-P6TBQGKL.js → archive-ZQ4A4TV6.js} +388 -44
  3. package/dist/chunks/{archive-oa-7TQ2NXOH.js → archive-oa-BBDP7AKJ.js} +2 -2
  4. package/dist/chunks/{asset-3ELRG37G.js → asset-ZOJVBWZH.js} +2 -2
  5. package/dist/chunks/{asset-idle-WIGMUFMD.js → asset-idle-XGB5IPGT.js} +2 -2
  6. package/dist/chunks/{attachment-content-E3276UOV.js → attachment-content-MCXQBD6N.js} +3 -3
  7. package/dist/chunks/{blog-C5NMZAAC.js → blog-QSHLZSFW.js} +2 -2
  8. package/dist/chunks/caizhilian-KCQYFH72.js +204 -0
  9. package/dist/chunks/{calendar-FI2WNSBO.js → calendar-DLGMRJQA.js} +2 -2
  10. package/dist/chunks/{chunk-PUQS5MWL.js → chunk-3YV7PKRL.js} +1 -1
  11. package/dist/chunks/{chunk-FAZTGX7S.js → chunk-4RWS2YYL.js} +5 -5
  12. package/dist/chunks/{chunk-GM6J7Q4B.js → chunk-6AXKWFKG.js} +32 -12
  13. package/dist/chunks/{chunk-ETNJSKMM.js → chunk-6NXT4ICB.js} +148 -21
  14. package/dist/chunks/{chunk-QVSWRLLU.js → chunk-6V5ZPKHV.js} +56 -12
  15. package/dist/chunks/chunk-762M5XJS.js +215 -0
  16. package/dist/chunks/{chunk-PC7VKEB5.js → chunk-76H3IKH6.js} +178 -37
  17. package/dist/chunks/{chunk-FRZKBMSW.js → chunk-AD46OMQK.js} +239 -41
  18. package/dist/chunks/{chunk-WSF4NNMR.js → chunk-CZNZKOHR.js} +2 -2
  19. package/dist/chunks/{chunk-TA7FXXJD.js → chunk-DLY5GUXX.js} +1 -1
  20. package/dist/chunks/{chunk-BCVYBYYT.js → chunk-GR76ZDDX.js} +2 -2
  21. package/dist/chunks/{chunk-CWYGFU5B.js → chunk-GSZTA43P.js} +2 -2
  22. package/dist/chunks/{chunk-GRDRG6HP.js → chunk-HFXK54M4.js} +2 -2
  23. package/dist/chunks/{chunk-N4M2DDFE.js → chunk-IP4CWQCF.js} +11 -11
  24. package/dist/chunks/{chunk-GAMZLAG2.js → chunk-IRMIEDXN.js} +1 -1
  25. package/dist/chunks/{chunk-XNIK66I4.js → chunk-JB34OE7R.js} +790 -77
  26. package/dist/chunks/{chunk-HIT4Y6OI.js → chunk-JFAWZX53.js} +134 -13
  27. package/dist/chunks/{chunk-D4ADSZ7H.js → chunk-O6CMPO65.js} +24 -1
  28. package/dist/chunks/{chunk-Z7VYWPZV.js → chunk-OXHHJWNC.js} +1 -1
  29. package/dist/chunks/chunk-P5GQRWDC.js +60 -0
  30. package/dist/chunks/{caizhilian-5XSM2DFP.js → chunk-PGO4ILMQ.js} +41 -521
  31. package/dist/chunks/{chunk-OF4S23UB.js → chunk-PSOMGA3U.js} +4 -4
  32. package/dist/chunks/{chunk-F4E4EM35.js → chunk-TGAGQV4I.js} +2 -2
  33. package/dist/chunks/{chunk-UFIT2UU3.js → chunk-U6R6FZHD.js} +168 -14
  34. package/dist/chunks/{chunk-XHK4MDR5.js → chunk-UFIFZ4YC.js} +48 -14
  35. package/dist/chunks/chunk-VRPH24IC.js +76 -0
  36. package/dist/chunks/{chunk-3YBDYOC4.js → chunk-YIKSL36S.js} +2 -2
  37. package/dist/chunks/{chunk-IAZ3UPY6.js → chunk-Z6UUBY37.js} +2 -2
  38. package/dist/chunks/{conflict-ARLSZJ6V.js → conflict-H7EHQXYY.js} +2 -2
  39. package/dist/chunks/continuation-GW6PRWK3.js +12 -0
  40. package/dist/chunks/{contract-DNIIW5VJ.js → contract-3QLAGYQL.js} +5793 -4591
  41. package/dist/chunks/{cowork-GMLRGVIW.js → cowork-3ACICHDQ.js} +2 -2
  42. package/dist/chunks/{create-flow-J22BO65E.js → create-flow-VRVJEOBX.js} +6 -6
  43. package/dist/chunks/{ebuilder-form-ANV2FHYV.js → ebuilder-form-GWDTKEI2.js} +5 -5
  44. package/dist/chunks/{ehr-GSTGAIY3.js → ehr-SH2LM3NK.js} +648 -88
  45. package/dist/chunks/{employee-22BGJ3QS.js → employee-NOHNXC46.js} +1 -1
  46. package/dist/chunks/{env-BX3VRFS7.js → env-66FPSJDV.js} +2 -2
  47. package/dist/chunks/{esb-ATAIASX2.js → esb-4BQHNP5C.js} +4 -4
  48. package/dist/chunks/{factory-PETTFME6.js → factory-UH2TZBVA.js} +1 -1
  49. package/dist/chunks/{fna-YEKBSFSX.js → fna-ZVB2IILI.js} +2 -2
  50. package/dist/chunks/{group-chat-BFVXAYFX.js → group-chat-CAKMMV7K.js} +3 -3
  51. package/dist/chunks/{host-WIKN2EJ5.js → host-3TNBMDTR.js} +3 -3
  52. package/dist/chunks/host-7NTIBSPK.js +25 -0
  53. package/dist/chunks/{host-SZGV4UNT.js → host-7OWWPLM4.js} +3 -3
  54. package/dist/chunks/{host-HRBXEPDQ.js → host-G3VU7SDW.js} +3 -3
  55. package/dist/chunks/{host-LR55CTHP.js → host-M4XP5URR.js} +3 -3
  56. package/dist/chunks/{host-SUOY6VYQ.js → host-TUOIOEMC.js} +3 -3
  57. package/dist/chunks/{hrm-NRDO4W5G.js → hrm-UNKCCCGP.js} +5 -5
  58. package/dist/chunks/{im-IQ2HN23S.js → im-NJB7ZYMH.js} +3 -3
  59. package/dist/chunks/{invoice-MNRW76PP.js → invoice-OQP3TMKQ.js} +3 -3
  60. package/dist/chunks/{jiuchuanhui-DTRBAX4N.js → jiuchuanhui-ASFZBMPU.js} +2 -2
  61. package/dist/chunks/{lazy-dispatch-ZVWAI25B.js → lazy-dispatch-DD6ULZ3I.js} +4 -4
  62. package/dist/chunks/{mail-ZVAUXOJA.js → mail-M3HJF5ER.js} +2 -2
  63. package/dist/chunks/{meeting-FEVPZ67S.js → meeting-VTBFW4HI.js} +12 -12
  64. package/dist/chunks/{okr-SDH3E5RA.js → okr-EVX7FB5G.js} +2 -2
  65. package/dist/chunks/operations-J7PUIVWZ.js +15 -0
  66. package/dist/chunks/{plan-E35JFDI7.js → plan-2QJQEPBO.js} +2 -2
  67. package/dist/chunks/{project-73QXBAB2.js → project-XELELW2T.js} +2 -2
  68. package/dist/chunks/{reception-UWZVACBN.js → reception-5WITA44R.js} +2 -2
  69. package/dist/chunks/{recruit-stage-4MAOCKFY.js → recruit-stage-CAKZTUA7.js} +1343 -178
  70. package/dist/chunks/{registry-JDUS4E7D.js → registry-AQVGHUM6.js} +2 -2
  71. package/dist/chunks/{registry-IM5G23LS.js → registry-JVQBLFQ5.js} +10 -10
  72. package/dist/chunks/{registry-KNKSCJNT.js → registry-QJCZ2GVG.js} +4 -4
  73. package/dist/chunks/{registry-PO7SI256.js → registry-VWXWPVAG.js} +2 -2
  74. package/dist/chunks/{room-recommend-H7KLXA5R.js → room-recommend-5U55FMXZ.js} +6 -4
  75. package/dist/chunks/{schedule-ESZIBAUO.js → schedule-IDETODCA.js} +4 -4
  76. package/dist/chunks/{workflow-CWJFJLQU.js → workflow-BSYT5TGL.js} +6 -4
  77. package/dist/cmd/action.js +14 -10
  78. package/dist/index.js +30 -30
  79. package/dist/internal/e10/auth/commands.js +32 -0
  80. package/dist/internal/e10/auth/error-log.js +156 -26
  81. package/dist/internal/e10/auth/xiaoe.js +176 -13
  82. package/dist/internal/e10/context.js +12 -1
  83. package/dist/shortcuts/archive/operations/borrow-list.js +105 -14
  84. package/dist/shortcuts/archive/operations/flow-url.js +182 -22
  85. package/dist/shortcuts/archive/operations/getPageUrl.js +75 -0
  86. package/dist/shortcuts/archive/operations/prelib.js +33 -4
  87. package/dist/shortcuts/archive/operations/shared.js +52 -0
  88. package/dist/shortcuts/contract/host.js +111 -4
  89. package/dist/shortcuts/contract/index.js +19 -0
  90. package/dist/shortcuts/contract/manifest.js +125 -0
  91. package/dist/shortcuts/contract/ooxml/clause-insert.js +249 -0
  92. package/dist/shortcuts/contract/operations/clause-insert.js +56 -0
  93. package/dist/shortcuts/contract/operations/customer.js +192 -0
  94. package/dist/shortcuts/contract/operations/file-download.js +75 -0
  95. package/dist/shortcuts/contract/operations/flow.js +44 -2
  96. package/dist/shortcuts/contract/operations/form-info.js +162 -62
  97. package/dist/shortcuts/contract/operations/registry.js +8 -0
  98. package/dist/shortcuts/contract/operations/review.js +116 -1
  99. package/dist/shortcuts/contract/operations/summary.js +177 -0
  100. package/dist/shortcuts/contract/operations/upload.js +64 -4
  101. package/dist/shortcuts/contract/upload-cache.js +104 -0
  102. package/dist/shortcuts/ehr/host.js +2 -2
  103. package/dist/shortcuts/ehr/index.js +14 -3
  104. package/dist/shortcuts/ehr/manifest.js +5 -1
  105. package/dist/shortcuts/ehr/operations/recruit-candidate-import.js +44 -12
  106. package/dist/shortcuts/ehr/operations/recruit-interview-overview.js +258 -0
  107. package/dist/shortcuts/ehr/operations/recruit-position.js +146 -43
  108. package/dist/shortcuts/ehr/operations/recruit-stats.js +14 -1
  109. package/dist/shortcuts/ehr/operations/recruit-tag.js +173 -0
  110. package/dist/shortcuts/ehr/operations/recruit-write.js +154 -36
  111. package/dist/shortcuts/ehr/operations/recruit.js +196 -12
  112. package/dist/shortcuts/ehr/operations/registry.js +4 -0
  113. package/dist/shortcuts/ehr/operations.js +24 -0
  114. package/dist/shortcuts/ehr/recruit-stage/batch-store.js +78 -0
  115. package/dist/shortcuts/ehr/recruit-stage/context.js +231 -0
  116. package/dist/shortcuts/ehr/recruit-stage/continuation.js +74 -0
  117. package/dist/shortcuts/ehr/recruit-stage/errors.js +65 -0
  118. package/dist/shortcuts/ehr/recruit-stage/fs-scan.js +165 -0
  119. package/dist/shortcuts/ehr/recruit-stage/host.js +109 -0
  120. package/dist/shortcuts/ehr/recruit-stage/operations/interview-arrange.js +1049 -0
  121. package/dist/shortcuts/ehr/recruit-stage/operations/interview-feedback.js +295 -0
  122. package/dist/shortcuts/ehr/recruit-stage/operations/jd-create.js +961 -0
  123. package/dist/shortcuts/ehr/recruit-stage/operations/list.js +431 -0
  124. package/dist/shortcuts/ehr/recruit-stage/operations/registry.js +50 -0
  125. package/dist/shortcuts/ehr/recruit-stage/operations/resume-import.js +1647 -0
  126. package/dist/shortcuts/ehr/recruit-stage/operations/search.js +158 -0
  127. package/dist/shortcuts/ehr/recruit-stage/operations/types.js +34 -0
  128. package/dist/shortcuts/ehr/recruit-stage/runtime.js +31 -0
  129. package/dist/shortcuts/ehr/recruit-stage/school-tiers.json +318 -0
  130. package/dist/shortcuts/ehr/recruit-stage/shared.js +805 -0
  131. package/dist/shortcuts/hrm/operations/employee.js +29 -1
  132. package/dist/shortcuts/meeting/operations/eb/create-flow.js +274 -75
  133. package/dist/shortcuts/meeting/operations/eb/draft-memory.js +56 -0
  134. package/dist/shortcuts/meeting/operations/eb/factory.js +63 -11
  135. package/dist/shortcuts/meeting/operations/eb/person-cache.js +2 -2
  136. package/dist/shortcuts/meeting/operations/eb/room-recommend.js +38 -7
  137. package/dist/shortcuts/meeting/operations/invitation-publish.js +132 -0
  138. package/dist/shortcuts/meeting/operations/invitation.js +27 -4
  139. package/dist/shortcuts/meeting/operations/registry.js +2 -0
  140. package/dist/shortcuts/recruit-stage/batch-store.js +78 -0
  141. package/dist/shortcuts/recruit-stage/fs-scan.js +165 -0
  142. package/dist/shortcuts/recruit-stage/operations/interview-arrange.js +356 -29
  143. package/dist/shortcuts/recruit-stage/operations/interview-feedback.js +36 -10
  144. package/dist/shortcuts/recruit-stage/operations/jd-create.js +309 -67
  145. package/dist/shortcuts/recruit-stage/operations/registry.js +12 -0
  146. package/dist/shortcuts/recruit-stage/operations/resume-import.js +310 -17
  147. package/dist/shortcuts/recruit-stage/operations/types.js +9 -0
  148. package/dist/shortcuts/recruit-stage/shared.js +221 -24
  149. package/dist/shortcuts/workflow/index.js +2 -0
  150. package/dist/shortcuts/workflow/operations/read.js +8 -3
  151. package/dist/shortcuts/workflow/operations/todoSmartConvert/aigroupRules.js +92 -5
  152. package/dist/shortcuts/workflow/operations/todoSmartConvert/priorityExpr.js +509 -0
  153. package/dist/shortcuts/workflow/operations/todoSmartConvert/todoListRows.js +22 -1
  154. package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.collect.js +32 -6
  155. package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.core.js +57 -11
  156. package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.group.js +165 -52
  157. package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.js +57 -14
  158. package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.smartGroup.js +44 -18
  159. package/docs/contract.md +1 -0
  160. package/docs/e10-auth.md +4 -2
  161. package/docs/todo-smart-convert/data-contract.md +7 -0
  162. package/package.json +1 -1
  163. package/skill-template/domains/jinchengda.md +2 -0
  164. package/skills/weaver-e10-jinchengda/SKILL.md +198 -205
  165. package/skills/weaver-e10-jinchengda/references/contract-action-card.md +759 -0
  166. package/skills/weaver-e10-jinchengda/references/contract-action-engine.md +250 -0
  167. package/skills/weaver-e10-jinchengda/references/contract-ai-review.md +146 -7
  168. package/skills/weaver-e10-jinchengda/references/contract-clause-insert.md +178 -0
  169. package/skills/weaver-e10-jinchengda/references/contract-command-index.md +75 -0
  170. package/skills/weaver-e10-jinchengda/references/contract-compare-report-template.html +137 -0
  171. package/skills/weaver-e10-jinchengda/references/contract-compare-report.md +163 -0
  172. package/skills/weaver-e10-jinchengda/references/contract-credit-page.md +52 -3
  173. package/skills/weaver-e10-jinchengda/references/contract-doc-compare.md +92 -5
  174. package/skills/weaver-e10-jinchengda/references/contract-doc-triage.md +602 -0
  175. package/skills/weaver-e10-jinchengda/references/contract-element-extract.md +209 -0
  176. package/skills/weaver-e10-jinchengda/references/contract-execution-rules.md +126 -0
  177. package/skills/weaver-e10-jinchengda/references/contract-field-extract-new-customer.md +312 -0
  178. package/skills/weaver-e10-jinchengda/references/contract-field-extract-other-flows.md +555 -0
  179. package/skills/weaver-e10-jinchengda/references/contract-flow-launch.md +47 -12
  180. package/skills/weaver-e10-jinchengda/references/contract-object-detect.md +469 -0
  181. package/skills/weaver-e10-jinchengda/references/contract-quote-to-contract.md +154 -1
  182. package/skills/weaver-e10-jinchengda/references/contract-type-fingerprints.md +224 -0
  183. package/skills/weaver-e10-jinchengda/references/orchestration.md +355 -0
  184. package/skills/weaver-e10-jucailin/SKILL.md +12 -3
  185. package/skills/weaver-e10-jucailin/archive/LEGACY-README.md +18 -0
  186. package/skills/weaver-e10-jucailin/archive/LEGACY-SKILL.md +239 -0
  187. package/skills/weaver-e10-jucailin/archive/LEGACY-openai.yaml +131 -0
  188. package/skills/weaver-e10-jucailin/archive/LEGACY-position-templates.md +221 -0
  189. package/skills/weaver-e10-jucailin/archive/LEGACY-recruit-arrange-interview.md +334 -0
  190. package/skills/weaver-e10-jucailin/archive/LEGACY-recruit-capability-check.md +127 -0
  191. package/skills/weaver-e10-jucailin/archive/LEGACY-recruit-check-install.md +65 -0
  192. package/skills/weaver-e10-jucailin/archive/LEGACY-recruit-detail-process.md +63 -0
  193. package/skills/weaver-e10-jucailin/archive/LEGACY-recruit-edit-interview-feedback.md +142 -0
  194. package/skills/weaver-e10-jucailin/archive/LEGACY-recruit-jd-create.md +114 -0
  195. package/skills/weaver-e10-jucailin/archive/LEGACY-recruit-jd-template.md +56 -0
  196. package/skills/weaver-e10-jucailin/archive/LEGACY-recruit-list-candidate.md +101 -0
  197. package/skills/weaver-e10-jucailin/archive/LEGACY-recruit-list-interview.md +148 -0
  198. package/skills/weaver-e10-jucailin/archive/LEGACY-recruit-match-candidates.md +77 -0
  199. package/skills/weaver-e10-jucailin/archive/LEGACY-recruit-output-links.md +72 -0
  200. package/skills/weaver-e10-jucailin/archive/LEGACY-recruit-resolve-creator.md +69 -0
  201. package/skills/weaver-e10-jucailin/archive/LEGACY-recruit-resolve-metadata.md +241 -0
  202. package/skills/weaver-e10-jucailin/archive/LEGACY-recruit-resume-import.md +457 -0
  203. package/skills/weaver-e10-jucailin/archive/LEGACY-recruit-resume-parse.md +128 -0
  204. package/skills/weaver-e10-jucailin/archive/LEGACY-recruit-search-candidate.md +146 -0
  205. package/skills/weaver-e10-jucailin/archive/LEGACY-recruit-urge-feedback.md +69 -0
  206. package/skills/weaver-e10-jucailin/lib/recruit-xiaoe-file.mjs +192 -0
  207. package/skills/weaver-e10-jucailin/lib/xiaoe-session.mjs +66 -0
  208. package/skills/weaver-e10-jucailin/references/recruit-create.md +19 -91
  209. package/skills/weaver-e10-jucailin/references/recruit-interview-overview.md +64 -0
  210. package/skills/weaver-e10-jucailin/references/recruit-read.md +63 -1
  211. package/skills/weaver-e10-jucailin/references/recruit-screening-to-interview-sop.md +95 -0
  212. package/skills/weaver-e10-jucailin/references/recruit-stage-ops.md +89 -0
  213. package/skills/weaver-e10-jucailin/references/recruit-tag.md +81 -0
  214. package/skills/weaver-e10-jucailin/references/recruit-write.md +55 -11
  215. package/skills/weaver-e10-meeting/SKILL.md +103 -11
  216. package/skills/weaver-e10-meeting/references/meeting-eb.md +1 -1
  217. package/skills/weaver-e10-recruit-stage/SKILL.md +19 -11
  218. package/skills/weaver-e10-recruit-stage/agents/openai.yaml +26 -8
  219. package/skills/weaver-e10-recruit-stage/lib/recruit-xiaoe-file.mjs +5 -1
  220. package/skills/weaver-e10-recruit-stage/references/position-templates.md +23 -2
  221. package/skills/weaver-e10-recruit-stage/references/recruit-arrange-interview.md +13 -1
  222. package/skills/weaver-e10-recruit-stage/references/recruit-jd-create.md +40 -18
  223. package/skills/weaver-e10-recruit-stage/references/recruit-output-links.md +27 -14
  224. package/skills/weaver-e10-recruit-stage/references/recruit-resume-import.md +11 -1
  225. package/skills/weaver-e10-shared/references/e10-auth-and-session.md +4 -2
  226. package/skills/weaver-e10-wenshuding/SKILL.md +17 -7
  227. package/skills/weaver-e10-wenshuding/references/archive-borrow-list.md +28 -0
  228. package/skills/weaver-e10-wenshuding/references/archive-flow.md +24 -8
  229. package/skills/weaver-e10-wenshuding/references/archive-prelib-list.md +3 -0
  230. package/skills/weaver-e10-wenshuding/references/archive-prelib-open.md +4 -0
  231. package/skills/weaver-e10-wenshuding/references/archive-search.md +3 -1
  232. package/skills/weaver-e10-workflow/SKILL.md +19 -17
  233. package/skills/weaver-e10-workflow/aigroup/default.json +10 -6
  234. package/skills/weaver-e10-workflow/references/todo-smart-convert.md +36 -3
  235. package/skills/weaver-e10-workflow/references/workflow-memory.md +1 -1
  236. package/skills/weaver-e10-workflow/references/workflow-query.md +9 -6
  237. package/skills/weaver-e10-workflow/tools/todo-summary.cjs +152 -1
  238. package/skills/weaver-e10-yimiaoban/SKILL.md +17 -5
  239. package/skills/weaver-e10-yimiaoban/references/msg-write.md +30 -0
  240. package/skills/weaver-e10-yimiaoban/references/session-sysmsg.md +72 -0
  241. package/skills/weaver-e10-yimiaoban/references/source-manifest.json +7 -7
@@ -18,7 +18,9 @@
18
18
  *
19
19
  * 默认值策略(跨环境运行时解析、不写死 id):状态=招聘中;流程=环境默认启用流程;
20
20
  * 人数=1、薪酬月数=12;薪酬类型=月薪、招聘方式=社会招聘;
21
- * 招聘负责人/用人经理=当前登录用户;其余关联表单型取环境内已有职位记录的值("默认值=系统现成值")。
21
+ * 招聘负责人/用人经理=当前登录用户;工作地点=「办公地点」列表里启用状态的默认详细地址;
22
+ * 其余关联表单型取环境内已有职位记录的值("默认值=系统现成值")。
23
+ * ⚠️ 工作地点**不参与继承**:历史职位曾带出 detail_location 为「1」的脏地点。
22
24
  */
23
25
  import { createHash, randomBytes } from 'node:crypto';
24
26
  import { readFileSync } from 'node:fs';
@@ -26,7 +28,7 @@ import { resolve as resolvePath, dirname } from 'node:path';
26
28
  import { fileURLToPath } from 'node:url';
27
29
  import { rsSuccess, schemaOf } from './types.js';
28
30
  import { rsFail, rsValidationError, rsConfirmationError } from '../errors.js';
29
- import { objIdOf, formIdOf, saveFormData, getDsOptions, cachedDsMap, getFormDataRecord, resolvePersonId, findMenuNode, resolveCurrentUser, buildCardUrl, buildListLocateUrl, randHex32, } from '../shared.js';
31
+ import { objIdOf, formIdOf, saveFormData, getDsOptions, getFormDataRecord, resolvePersonId, findMenuNode, resolveCurrentUser, buildCardUrl, buildListUrl, randHex32, dsOptionsSnapshot, restoreDsOptions, invalidateEnvCache, verifySubmitted, expectedFields, probeCreatePermission, } from '../shared.js';
30
32
  const SCHEMA_ID_STR = { type: 'string', description: '18 位记录 id(字符串)' };
31
33
  // 职位管理表单字段 dataKey(缓存 fields 里取;不写死 fieldId)
32
34
  const DATAKEYS_TEXT = ['position_name'];
@@ -35,12 +37,26 @@ const DATAKEYS_MTEXT = ['position_duty', 'work_request'];
35
37
  const DEF_TEXT = { recruit_count: '1', number_of_pay_months: '12' };
36
38
  const DEF_OPTION = { salary_type: '月薪', recruit_type: '社会招聘' };
37
39
  const DEF_CURRENT_USER = ['recr_principal', 'employ_manager'];
38
- // 🔴 薪资不继承:历史职位薪资可能是脏数据(实测抓到 300 元月薪),
39
- // 改为按 references/position-templates.md §1.1 的推荐表由 Agent 填入 sets,未指定就留空。
40
+ // 🔴 薪资(salary_min / salary_max)必须继承,不能留空:这两个字段是**职位表单必填项**,
41
+ // 不传会导致后端必填校验失败、建职位直接报错(2026-11-06 实测:移除继承后 willSubmit 无薪资字段)。
42
+ // 但历史薪资确实可能是脏数据(实测抓到 300 元月薪),因此不静默使用:
43
+ // 通过 summary.inheritedFromRef 暴露继承值,并对明显偏低的值追加 inheritedSalaryWarnings 提示。
44
+ // 🔴 2026-11-07 实测修正:以下字段**不再从参考职位继承**——
45
+ // · job_category(职位序列):每个职位各不相同,继承会把上一个职位的「销售」带到新职位,
46
+ // 该错误已由职位卡片页坐实(「核验1107-JD-B」JD 写的是后端接口开发,落库职位序列却是「销售」);
47
+ // · salary_min / salary_max(薪酬区间):继承会把历史脏值「0.00」写成新职位的正式薪酬,
48
+ // 同样已在卡片页坐实(最低/最高薪酬均为 0.00)。
49
+ // 自用 EB 包 ebdf_field 实测这三个字段 required 均未开启,留空不会阻断保存;
50
+ // 用户需要就显式传 jobCategory / salaryMin / salaryMax,不再用脏值填坑。
40
51
  const DEF_FROM_REF = [
41
- 'position_nature', 'job_category', 'education', 'work_years', 'work_location',
52
+ 'position_nature', 'education', 'work_years',
42
53
  ];
43
54
  const DEF_STATUS = '招聘中';
55
+ // 默认办公地点用「详细地址名称」声明,不写死记录 id:运行时到「办公地点」列表
56
+ // 按「启用」状态 + 详细地址精确匹配取 id。历史职位继承会把内容写成「1」的脏地点带进新职位
57
+ // (2026-11-06 实测:某在册地点 detail_location 就是 "1" 且状态为启用),故 work_location 已从
58
+ // DEF_FROM_REF 移除,改由本默认地点解析;匹配不到则不写该字段并点名,不臆造 id。
59
+ const DEFAULT_WORK_LOCATION = '浦江镇三鲁公路3419号泛微软件园';
44
60
  // sets 覆盖解析:字段取值类别
45
61
  const NUM_KEYS = new Set(['recruit_count', 'number_of_pay_months', 'salary_min', 'salary_max', 'internship_duration', 'working_days']);
46
62
  const PERSON_KEYS = new Set(['recr_principal', 'recr_helper', 'employ_manager', 'interviewer']);
@@ -152,45 +168,120 @@ async function findWorkPlaceMenu(ctx) {
152
168
  catch { /* 接口不可用则放弃 */ }
153
169
  return null;
154
170
  }
155
- // 工作地点:按名称/详细地址/城市解析「办公地点」记录 id
156
- async function resolveWorkLocation(ctx, value) {
157
- const { host, appId, cache } = ctx;
158
- const v = String(value).trim();
159
- if (!v)
160
- return null;
161
- // objId:优先按 tag 取;取不到时用菜单节点自带的(部分环境 tag 未注册)
162
- let pObj = '';
171
+ // 仅进程内 memo(不落盘):同一 CLI 进程内 prepare/apply 及多个 set 复用一次列表请求。
172
+ // 记录 id / 启用状态 optionId 一律运行时从列表解析,跨环境不缓存、不写死。
173
+ const workPlaceMemo = new Map();
174
+ function stripHtml(s) {
175
+ return String(s ?? '').replace(/<[^>]*>/g, '').trim();
176
+ }
177
+ function parseSpans(raw) {
163
178
  try {
164
- const t = await host.request({ path: `/api/ebuilder/form/obj/getObjsByTag?appId=${appId}&tag=uf_rcrt_work_place`, method: 'GET' });
165
- const d = t?.data;
166
- if (Array.isArray(d) && d[0])
167
- pObj = String(d[0].id || '');
179
+ const v = Array.isArray(raw) ? raw : JSON.parse(String(raw || '[]'));
180
+ return Array.isArray(v) ? v : [];
181
+ }
182
+ catch {
183
+ return [];
168
184
  }
169
- catch { /* tag 未注册:继续用菜单兜底 */ }
185
+ }
186
+ /** 「启用」判定:只读服务端翻译后的文本,不写死 optionId(跨环境 optionId 会变)。 */
187
+ function isEnabledText(s) {
188
+ const t = stripHtml(s);
189
+ return t.includes('启用') && !t.includes('禁用');
190
+ }
191
+ /** 拉取「办公地点」列表,按 place_status=启用 过滤;状态信息缺失时返回原始行并标记未过滤。 */
192
+ async function loadWorkPlaces(ctx) {
193
+ const { host, appId } = ctx;
170
194
  const menu = await findWorkPlaceMenu(ctx);
171
195
  if (!menu)
172
- return null;
173
- if (!pObj)
174
- pObj = String(menu.objId || '');
196
+ return { rows: [], statusFiltered: false };
197
+ const key = appId + '|' + menu.listId;
198
+ const cached = workPlaceMemo.get(key);
199
+ if (cached)
200
+ return cached;
201
+ const [tagObjId] = await Promise.all([
202
+ host
203
+ .request({ path: `/api/ebuilder/form/obj/getObjsByTag?appId=${appId}&tag=uf_rcrt_work_place`, method: 'GET' })
204
+ .then((t) => (Array.isArray(t?.data) && t.data[0] ? String(t.data[0].id || '') : ''))
205
+ .catch(() => ''),
206
+ ]);
207
+ const pObj = tagObjId || String(menu.objId || '');
175
208
  if (!pObj)
209
+ return { rows: [], statusFiltered: false };
210
+ const pageSize = 200;
211
+ const rawRows = [];
212
+ const dispRows = [];
213
+ for (let page = 1; page <= 5; page++) {
214
+ const body = {
215
+ current: page, pageSize, tableuid: randHex32(),
216
+ listId: menu.listId, searchParamData: { searchType: '3', type: 'and' },
217
+ terminal: 'PC', browser: 'Chrome', requiredMatch: 1, mapResult: 1,
218
+ recheckQuery: 1, isFollow: 0, isShareToMe: 0, filterCondition: {},
219
+ cusMenuId: menu.cusMenuId, urlPageTitle: menu.menuName, menuName: menu.menuName,
220
+ };
221
+ const r = await host.request({
222
+ path: `/api/ebuilder/form/list/getListDatas?passid=${pObj}&cid=${pObj}`,
223
+ body, headers: { ebBusinessId: menu.listId },
224
+ });
225
+ const batch = (r?.data?.data || r?.data?.displayData || []);
226
+ rawRows.push(...batch);
227
+ dispRows.push(...(r?.data?.displayData || []));
228
+ if (batch.length < pageSize)
229
+ break; // 服务端 total/hasMore 不可信,唯一可靠判据是分页本身
230
+ }
231
+ // 从 displayData 学「启用」对应的 optionId 集合与行 id 集合(两种形态都兼容)
232
+ const enabledStatusIds = new Set();
233
+ const enabledRowIds = new Set();
234
+ for (const d of dispRows) {
235
+ const rid = String(d?.form_data_id || d?.id || '');
236
+ if (isEnabledText(d?.place_status) && rid)
237
+ enabledRowIds.add(rid);
238
+ for (const s of parseSpans(d?.place_statusSpan)) {
239
+ if (isEnabledText(s?.name) && s?.id)
240
+ enabledStatusIds.add(String(s.id));
241
+ }
242
+ }
243
+ const statusFiltered = enabledRowIds.size > 0 || enabledStatusIds.size > 0;
244
+ const rows = rawRows
245
+ .filter((x) => !statusFiltered
246
+ || enabledRowIds.has(String(x?.form_data_id || x?.id || ''))
247
+ || enabledStatusIds.has(String(x?.place_status || '')))
248
+ .map((x) => ({
249
+ id: String(x?.form_data_id || x?.id || ''),
250
+ name: String(x?.name || ''),
251
+ detail: String(x?.detail_location || ''),
252
+ area: String(x?.area_text || ''),
253
+ city: String(x?.city || ''),
254
+ }))
255
+ .filter((x) => !!x.id);
256
+ const out = { rows, statusFiltered };
257
+ workPlaceMemo.set(key, out);
258
+ return out;
259
+ }
260
+ /** 精确匹配优先;包含匹配要求地址文本足够长且非纯数字,避免把内容写成「1」的脏地点选中。 */
261
+ function matchWorkPlace(rows, value) {
262
+ const v = String(value).trim();
263
+ if (!v || !rows.length)
176
264
  return null;
177
- const body = {
178
- current: 1, pageSize: 200, tableuid: randHex32(),
179
- listId: menu.listId, searchParamData: { searchType: '3', type: 'and' },
180
- terminal: 'PC', browser: 'Chrome', requiredMatch: 1, mapResult: 1,
181
- recheckQuery: 1, isFollow: 0, isShareToMe: 0, filterCondition: {},
182
- cusMenuId: menu.cusMenuId, urlPageTitle: menu.menuName, menuName: menu.menuName,
183
- };
184
- const r = await host.request({ path: `/api/ebuilder/form/list/getListDatas?passid=${pObj}&cid=${pObj}`, body, headers: { ebBusinessId: menu.listId } });
185
- // displayData 是服务端翻译后的可读文本;data 为原始行 —— 两者都兜
186
- const rows = r?.data?.data || r?.data?.displayData || [];
187
- const hit = rows.find((x) => {
188
- const name = String(x.name || x.detail_location || '');
189
- const detail = String(x.detail_location || '');
190
- const area = String(x.area_text || '');
191
- return name.includes(v) || detail.includes(v) || area.includes(v) || (detail && v.includes(detail));
192
- });
193
- return hit ? { id: String(hit.form_data_id || hit.id), name: String(hit.detail_location || hit.name || v) } : null;
265
+ const exact = rows.find((r) => r.detail === v) || rows.find((r) => r.name === v);
266
+ if (exact)
267
+ return exact;
268
+ const valid = (s) => s.length >= 4 && !/^\d+$/.test(s);
269
+ return rows.find((r) => (r.detail.includes(v) && valid(r.detail))
270
+ || (r.name.includes(v) && valid(r.name))
271
+ || (r.area.includes(v) && valid(r.area))
272
+ || (v.includes(r.detail) && valid(r.detail))) || null;
273
+ }
274
+ // 工作地点:按名称/详细地址/城市解析「办公地点」记录 id(只在启用记录中匹配)
275
+ async function resolveWorkLocation(ctx, value) {
276
+ if (!String(value).trim())
277
+ return null;
278
+ const { rows } = await loadWorkPlaces(ctx);
279
+ const hit = matchWorkPlace(rows, value);
280
+ return hit ? { id: hit.id, name: hit.detail || hit.name || String(value) } : null;
281
+ }
282
+ /** 默认办公地点:按声明的详细地址在启用列表中精确解析 id,解析不到返回 null(不写、不继承)。 */
283
+ async function resolveDefaultWorkLocation(ctx) {
284
+ return resolveWorkLocation(ctx, DEFAULT_WORK_LOCATION);
194
285
  }
195
286
  // 解析 sets key=value → 提交 detail(按字段取值类别;解析不到返回 null)
196
287
  async function resolveSetValue(ctx, key, value, refByFid) {
@@ -199,8 +290,18 @@ async function resolveSetValue(ctx, key, value, refByFid) {
199
290
  const id = (cache.fields[objId] || {})[key];
200
291
  if (!id)
201
292
  return null;
202
- if (NUM_KEYS.has(key))
293
+ if (NUM_KEYS.has(key)) {
294
+ // 薪资字段单位是「千元」(页面 15.00 = 15K,与字段 ID 交叉验证);用户/Agent 传的是「元」。
295
+ // 只对**显式输入**换算;从已有职位继承的值本来就是千元,绝不能再除一次。
296
+ if (key === 'salary_min' || key === 'salary_max') {
297
+ const n = Number(String(value).replace(/,/g, ''));
298
+ if (Number.isFinite(n) && n > 0) {
299
+ const k = n / 1000;
300
+ return { formField: { id }, content: String(Number.isInteger(k) ? k : Number(k.toFixed(3))) };
301
+ }
302
+ }
203
303
  return { formField: { id }, content: String(value) };
304
+ }
204
305
  if (MTEXT_KEYS.has(key))
205
306
  return { formField: { id }, dataText: { content: String(value) } };
206
307
  if (key === 'position_name')
@@ -210,7 +311,7 @@ async function resolveSetValue(ctx, key, value, refByFid) {
210
311
  return uid ? { formField: { id }, dataOptions: [{ optionId: String(uid), content: value }] } : null;
211
312
  }
212
313
  if (OPTION_KEYS.has(key)) {
213
- const m = cachedDsMap(cache, objId, key) || await getDsOptions(host, objId, id, appId);
314
+ const m = await getDsOptions(host, objId, id);
214
315
  const oid = m[value];
215
316
  return oid ? { formField: { id }, dataOptions: [{ optionId: String(oid), content: value }] } : null;
216
317
  }
@@ -368,6 +469,10 @@ async function buildJd(opts) {
368
469
  for (const k of DATAKEYS_MTEXT)
369
470
  if (!fid(k))
370
471
  throw rsFail('职位管理缺少字段 ' + k + '(ds/fields 解析不到)');
472
+ // 并行预取:refByFid(sets 解析依赖它)与 currentUser(仅第⑤步用,与 sets 无依赖)
473
+ // 同时发出,避免过去「先等 refByFid → 再逐 set 串行 → 最后才取 currentUser」的多余 RTT。
474
+ const currentUserPromise = resolveCurrentUser(host)
475
+ .catch(() => null);
371
476
  const refByFid = await fetchRefByFid(ctx);
372
477
  const map = new Map();
373
478
  const put = (d) => { if (d && d.formField && d.formField.id)
@@ -385,10 +490,13 @@ async function buildJd(opts) {
385
490
  put({ formField: { id: fid('demand') }, dataOptions: [{ optionId: String(demandId), content: demandName || String(demandId) }] });
386
491
  }
387
492
  // ② sets 覆盖(AI 依 JD 指定;优先于自动默认值)
493
+ // 各项之间互不依赖(都只读 refByFid 与字典缓存),因此并行解析:
494
+ // 原实现逐个 await,6 个 set 就要串 6 次 RTT(含 work_location 内部 2~3 次请求),是 prepare 的主要串行瓶颈。
495
+ // 仍按原顺序 put,保证同一 key 多次出现时「后者覆盖前者」的语义不变。
388
496
  const appliedSets = [];
389
497
  const skippedSets = [];
390
- for (const [k, v] of sets) {
391
- const d = await resolveSetValue(ctx, k, v, refByFid);
498
+ const resolvedSets = await Promise.all(sets.map(async ([k, v]) => ({ k, v, d: await resolveSetValue(ctx, k, v, refByFid).catch(() => null) })));
499
+ for (const { k, v, d } of resolvedSets) {
392
500
  if (d) {
393
501
  put(d);
394
502
  appliedSets.push(k + '=' + v);
@@ -401,7 +509,7 @@ async function buildJd(opts) {
401
509
  if (!hasKey('status')) {
402
510
  if (!fid('status'))
403
511
  throw rsFail('职位管理缺少字段 status(ds/fields 解析不到)');
404
- const statusMap = cachedDsMap(cache, objId, 'status') || await getDsOptions(host, objId, fid('status'), appId);
512
+ const statusMap = await getDsOptions(host, objId, fid('status'));
405
513
  const statusId = statusMap[DEF_STATUS];
406
514
  if (!statusId)
407
515
  throw rsFail('职位管理「招聘状态」未解析到「' + DEF_STATUS + '」选项(ds/options 返回为空)');
@@ -416,7 +524,7 @@ async function buildJd(opts) {
416
524
  const filled = [];
417
525
  let currentUser = null;
418
526
  if (DEF_CURRENT_USER.some((k) => fid(k) && !hasKey(k))) {
419
- currentUser = await resolveCurrentUser(host);
527
+ currentUser = await currentUserPromise;
420
528
  if (currentUser && currentUser.id) {
421
529
  for (const k of DEF_CURRENT_USER) {
422
530
  if (fid(k) && !hasKey(k)) {
@@ -435,7 +543,7 @@ async function buildJd(opts) {
435
543
  }
436
544
  for (const [k, name] of Object.entries(DEF_OPTION)) {
437
545
  if (fid(k) && !hasKey(k)) {
438
- const m = cachedDsMap(cache, objId, k) || await getDsOptions(host, objId, fid(k), appId);
546
+ const m = await getDsOptions(host, objId, fid(k));
439
547
  const oid = m[name];
440
548
  if (oid) {
441
549
  put({ formField: { id: fid(k) }, dataOptions: [{ optionId: String(oid), content: name }] });
@@ -458,6 +566,34 @@ async function buildJd(opts) {
458
566
  }
459
567
  }
460
568
  }
569
+ // 继承来的薪资若明显偏低(历史脏数据,实测出现过 300 元月薪),额外点名提示。
570
+ // 不阻断提交(薪资是必填项,阻断等于无法建档),但要求 Agent 在确认摘要里明确提示用户核对。
571
+ const inheritedSalaryWarnings = [];
572
+ for (const key of ['salary_min', 'salary_max']) {
573
+ const hit = inheritedFromRef.find((x) => x.field === key);
574
+ if (!hit)
575
+ continue;
576
+ const num = Number(String(hit.value).replace(/[^\d.]/g, ''));
577
+ // 继承值单位也是千元:18 = 18K 正常;低于 1(<1000元)或高于 100(>10万/月)才算异常
578
+ if (hit.value && Number.isFinite(num) && (num < 1 || num > 100)) {
579
+ inheritedSalaryWarnings.push(key + ' 继承值「' + hit.value + '」(千元)明显异常,请人工核对后再提交');
580
+ }
581
+ }
582
+ // ⑦ 工作地点默认值:不再从历史职位继承(实测会把 detail_location 为「1」的脏地点带进新职位),
583
+ // 改为在「办公地点」列表按「启用」状态 + 详细地址精确解析;解析不到则不写并点名。
584
+ let workLocationDefault = null;
585
+ let workLocationWarning = null;
586
+ if (!hasKey('work_location') && fid('work_location')) {
587
+ const loc = await resolveDefaultWorkLocation(ctx).catch(() => null);
588
+ if (loc) {
589
+ put({ formField: { id: fid('work_location') }, dataOptions: [{ optionId: loc.id, content: loc.name }] });
590
+ filled.push('work_location');
591
+ workLocationDefault = loc.name;
592
+ }
593
+ else {
594
+ workLocationWarning = `未在「办公地点」列表找到启用状态的默认地点「${DEFAULT_WORK_LOCATION}」,本次不写 work_location;请用 sets 指定`;
595
+ }
596
+ }
461
597
  const inv = {};
462
598
  for (const [k, v] of Object.entries(fields))
463
599
  inv[String(v)] = k;
@@ -477,11 +613,14 @@ async function buildJd(opts) {
477
613
  setApplied: appliedSets,
478
614
  setSkipped: skippedSets,
479
615
  // 明示哪些字段值继承自「环境内最近一条职位记录」——这些不是用户指定的,可能来自脏数据,
480
- // 必须在确认摘要里人工核对(尤其 work_location)
616
+ // 必须在确认摘要里人工核对(工作地点不参与继承,见 workLocationDefault)
481
617
  inheritedFromRef: inheritedFromRef.length ? inheritedFromRef : undefined,
618
+ inheritedSalaryWarnings: inheritedSalaryWarnings.length ? inheritedSalaryWarnings : undefined,
482
619
  inheritedNote: inheritedFromRef.length
483
- ? '以上字段未指定,值继承自环境内最近一条职位记录,可能含历史脏数据(如重复地点),请核对后再提交'
620
+ ? '以上字段未指定,值继承自环境内最近一条职位记录,可能含历史脏数据,请核对后再提交(工作地点不参与继承)'
484
621
  : undefined,
622
+ workLocationDefault: workLocationDefault || undefined,
623
+ workLocationWarning: workLocationWarning || undefined,
485
624
  requiredDefaultsFilled,
486
625
  },
487
626
  };
@@ -509,6 +648,9 @@ async function prepare(args, env) {
509
648
  const session = await host.getSession();
510
649
  const ctx = { host, baseUrl: session.baseUrl.replace(/\/+$/, ''), appId: '', cache: await env.recruitContext() };
511
650
  ctx.appId = ctx.cache.appId;
651
+ const perm = await probeCreatePermission(ctx.host, objIdOf(ctx.cache, 'position_manage'));
652
+ if (perm === 'denied')
653
+ throw rsFail('当前账号没有「职位管理」表单的创建权限,已阻断(未写入任何数据)');
512
654
  const positionName = String(args.positionName || '').trim();
513
655
  if (!positionName)
514
656
  throw rsValidationError('position_name_required', 'positionName 必填');
@@ -522,30 +664,103 @@ async function prepare(args, env) {
522
664
  });
523
665
  // 参考检索默认关闭:环境职位数据重复严重(实测 836 条中「舟山民宿管家」30 条)且列表层
524
666
  // 无薪资/学历字段,参考价值低于请求成本。需要时显式传 referenceKeyword 才执行;
525
- // 岗位范式改由 references/position-templates.md 提供(零请求)。
667
+ // 岗位范式改由 references/recruit-stage/position-templates.md 提供(零请求)。
526
668
  const refs = args.referenceKeyword
527
669
  ? await fetchRecentReferences(ctx, jd, String(args.referenceKeyword))
528
670
  .catch((e) => ({ available: false, reason: e.message, items: [] }))
529
671
  : {
530
672
  available: false,
531
673
  skipped: true,
532
- reason: '未显式指定 referenceKeyword,已跳过同类职位参考检索(改用 references/position-templates.md 的岗位模板)',
674
+ reason: '未显式指定 referenceKeyword,已跳过同类职位参考检索;请改用 references/recruit-stage/position-templates.md 的岗位范式补齐 positionDuty / workRequest(该文件未覆盖的职位族须由用户提供)',
533
675
  items: [],
534
676
  };
535
677
  // fingerprint 必须基于完整 dataDetails(apply 阶段比对同一口径),回执里才做瘦身。
536
678
  const willSubmit = { formId: jd.formId, objId: jd.objId, dataDetails: jd.dataDetails };
537
679
  const fp = fingerprint(willSubmit);
538
- const continuation = await env.continuation.issue({ operation: 'recruit-stage.jd.create.apply', fingerprint: fp });
539
- // 回执瘦身:willSubmit 只输出字段名清单(不含内部 fieldId),continuation 提到首部——
540
- // 避免大输出被截断导致 Agent 取不到 continuation 而重复调用 prepare(实测多花 10.7s)。
680
+ const continuation = await env.continuation.issue({ operation: 'recruit-stage.jd.create.apply', fingerprint: fp,
681
+ enumMaps: await dsOptionsSnapshot(),
682
+ // 🔴 2026-11-07 修复:协议文档写「apply 带 confirm + continuation」,但 apply 原来只从 args 取
683
+ // positionName/positionDuty/...,Agent 少传 positionName 就直接报 position_name_required。
684
+ // 现把 prepare 用过的业务参数一并签进 continuation;apply 显式传的仍优先。
685
+ argsSnapshot: {
686
+ positionName: String(args.positionName || ''),
687
+ positionDuty: args.positionDuty ? String(args.positionDuty) : undefined,
688
+ workRequest: args.workRequest ? String(args.workRequest) : undefined,
689
+ demandId: args.demandId ? String(args.demandId) : undefined,
690
+ demandName: args.demandName ? String(args.demandName) : undefined,
691
+ } });
692
+ // 回执体积控制:continuation 与 fingerprint 放在返回体最前,避免大输出被截断时 Agent 取不到它们
693
+ // 而重复调用 prepare(实测多花 10.7s)。
694
+ // 🔴 2026-11-07 修正(D1):此前 willSubmit 只列字段名、不给 fieldId 与取值,Agent 无法自检
695
+ // 「准备写进表单的到底是什么值」,只能盲确认。现在改为逐字段 {key, fieldId, value},
696
+ // 并把单值截到 60 字符控制体积;指纹仍基于完整 dataDetails,不受裁剪影响。
541
697
  const invFieldKeys = {};
542
698
  for (const [k, v] of Object.entries(ctx.cache.fields[jd.objId] || {}))
543
699
  invFieldKeys[String(v)] = k;
700
+ // dataDetails 三种取值载体必须在摘要里都覆盖到,否则会显示成 null 误导 Agent:
701
+ // 单行文本 / 数字 → content;多行文本(职位职责 / 任职要求)→ dataText.content;
702
+ // 选项 / 关联字段 → dataOptions[0]。
703
+ const briefValue = (d) => {
704
+ let raw;
705
+ if (d?.dataText && d.dataText.content !== undefined && d.dataText.content !== null)
706
+ raw = d.dataText.content;
707
+ else if (d?.content !== undefined && d?.content !== null)
708
+ raw = d.content;
709
+ else if (Array.isArray(d?.dataOptions) && d.dataOptions.length)
710
+ raw = d.dataOptions[0]?.content ?? d.dataOptions[0]?.id;
711
+ if (typeof raw === 'string')
712
+ return raw.length > 60 ? raw.slice(0, 60) + '…' : raw;
713
+ return raw === undefined ? null : raw;
714
+ };
715
+ // 🔴 2026-11-07 修复(缺陷 B):prepare 的 preview 此前恒为空对象 {}。
716
+ // 协议约定 preview 是「给用户看的确认摘要」,为空等于确认链形同虚设(用户看不到要提交什么)。
717
+ // 现在用 summary + 正文摘要拼出 preview;bodyPreview 不截成 60 字(那是 willSubmit 的体积控制口径),
718
+ // 摘要给 100 字以便用户判断 JD 是否可用。
719
+ const fieldTextOf = (name) => {
720
+ const fid = String((ctx.cache.fields[jd.objId] || {})[name] || '');
721
+ if (!fid)
722
+ return '';
723
+ const d = willSubmit.dataDetails.find((x) => String(x?.formField?.id) === fid);
724
+ const raw = d?.dataText?.content ?? d?.content;
725
+ return typeof raw === 'string' ? raw : '';
726
+ };
727
+ const clip = (s, n) => (s.length > n ? s.slice(0, n) + '…' : s);
728
+ const dutyText = fieldTextOf('position_duty');
729
+ const requestText = fieldTextOf('work_request');
730
+ // 🔴 2026-11-07 修复(缺陷 A 配套):正文为空时不再静默成功。
731
+ // 实测「技术研发」这类泛称会产出 dutyLen=0 / requestLen=0 的空 JD,但 ok=true,
732
+ // 上层看起来像"没反应"。这里显式给 warning,把责任明确回给调用方(补正文或查模板)。
733
+ const missingBody = jd.summary.dutyLen === 0 || jd.summary.requestLen === 0;
734
+ const jdWarning = missingBody
735
+ ? `JD 正文不完整(职责 ${jd.summary.dutyLen} 字 / 任职要求 ${jd.summary.requestLen} 字)。请补 positionDuty / workRequest 后重新 prepare,或按 references/recruit-stage/position-templates.md 对应职位族补齐;以当前内容 apply 会创建一条没有职责与要求的职位记录。`
736
+ : undefined;
737
+ const preview = {
738
+ action: jd.summary.action,
739
+ positionName: jd.summary.positionName,
740
+ positionDuty: dutyText ? clip(dutyText, 100) : '(空,见 warning)',
741
+ workRequest: requestText ? clip(requestText, 100) : '(空,见 warning)',
742
+ demand: jd.summary.demand,
743
+ status: jd.summary.status,
744
+ recruitFlow: jd.summary.recruitFlow,
745
+ currentUser: jd.summary.currentUser,
746
+ setApplied: jd.summary.setApplied,
747
+ setSkipped: jd.summary.setSkipped,
748
+ inheritedFromRef: jd.summary.inheritedFromRef,
749
+ inheritedSalaryWarnings: jd.summary.inheritedSalaryWarnings,
750
+ inheritedNote: jd.summary.inheritedNote,
751
+ workLocationDefault: jd.summary.workLocationDefault,
752
+ workLocationWarning: jd.summary.workLocationWarning,
753
+ requiredDefaultsFilled: jd.summary.requiredDefaultsFilled,
754
+ fieldCount: willSubmit.dataDetails.length,
755
+ warning: jdWarning,
756
+ };
544
757
  return rsSuccess('recruit-stage.jd.create.prepare', {
545
758
  mode: 'prepare',
546
759
  continuation,
547
760
  fingerprint: fp,
548
761
  ...jd.summary,
762
+ preview,
763
+ jdWarning,
549
764
  recentReferences: refs.items,
550
765
  recentReferencesNote: refs.skipped
551
766
  ? refs.reason
@@ -556,7 +771,10 @@ async function prepare(args, env) {
556
771
  formId: willSubmit.formId,
557
772
  objId: willSubmit.objId,
558
773
  fieldCount: willSubmit.dataDetails.length,
559
- fields: willSubmit.dataDetails.map((d) => invFieldKeys[String(d.formField && d.formField.id)] || String(d.formField && d.formField.id)),
774
+ fields: willSubmit.dataDetails.map((d) => {
775
+ const fid = String(d?.formField?.id || '');
776
+ return { key: invFieldKeys[fid] || fid, fieldId: fid, value: briefValue(d) };
777
+ }),
560
778
  },
561
779
  }, {
562
780
  continuation,
@@ -570,20 +788,24 @@ async function apply(args, env) {
570
788
  if (!args.continuation)
571
789
  throw rsValidationError('continuation_required', '缺少 continuation(来自 prepare 的 meta)');
572
790
  const payload = await env.continuation.verify(String(args.continuation), 'recruit-stage.jd.create.apply');
791
+ restoreDsOptions(payload.enumMaps);
792
+ // 🔴 2026-11-07 修复:把 prepare 快照里的业务参数补回 args(显式传的优先),
793
+ // 使 apply 只带 confirm + continuation 也能执行,与协议文档一致。
794
+ const merged = { ...(payload.argsSnapshot || {}), ...args };
573
795
  const host = env.host;
574
796
  const session = await host.getSession();
575
797
  const ctx = { host, baseUrl: session.baseUrl.replace(/\/+$/, ''), appId: '', cache: await env.recruitContext() };
576
798
  ctx.appId = ctx.cache.appId;
577
- const positionName = String(args.positionName || '').trim();
799
+ const positionName = String(merged.positionName || '').trim();
578
800
  if (!positionName)
579
801
  throw rsValidationError('position_name_required', 'positionName 必填');
580
802
  const jd = await buildJd({
581
803
  ctx, positionName,
582
- duty: args.positionDuty ? String(args.positionDuty) : undefined,
583
- requestText: args.workRequest ? String(args.workRequest) : undefined,
584
- demandId: args.demandId ? String(args.demandId) : undefined,
585
- demandName: args.demandName ? String(args.demandName) : undefined,
586
- sets: setsOf(args),
804
+ duty: merged.positionDuty ? String(merged.positionDuty) : undefined,
805
+ requestText: merged.workRequest ? String(merged.workRequest) : undefined,
806
+ demandId: merged.demandId ? String(merged.demandId) : undefined,
807
+ demandName: merged.demandName ? String(merged.demandName) : undefined,
808
+ sets: setsOf(merged),
587
809
  });
588
810
  const willSubmit = { formId: jd.formId, objId: jd.objId, dataDetails: jd.dataDetails };
589
811
  if (payload.fingerprint !== fingerprint(willSubmit)) {
@@ -599,24 +821,44 @@ async function apply(args, env) {
599
821
  const positionPostId = data.positionPostId;
600
822
  const checkRpa = data.checkRpa;
601
823
  const rpaValidMsg = data.rpaValidMsg || null;
602
- const created = r2?.status !== false && !!positionPostId;
603
- const listUrl = await resolvePositionNewUrl(ctx).catch(() => null);
824
+ // 页面真实响应:外层 status=true、data.status=false(业务子状态,不是失败)、fail=false、
825
+ // successMsg=操作成功,且可能没有 positionPostId。旧逻辑强依赖 positionPostId 会把成功误判为 failed。
826
+ // 🔴 2026-11-07 实测修正:`fail:false` 的真实语义是「没有失败」,旧写法 `r2?.fail !== false`
827
+ // 把「明确返回 fail:false」判成失败,于是职位已建成却返回 result=failed(ok:true)。
828
+ // 只有 `fail === true` 才算失败。
829
+ const okByResponse = r2?.status !== false && r2?.fail !== true && data.fail !== true;
830
+ // 第三层门禁:写完回查记录与关键字段,作为最终判定(接口语义不一致时以落库为准)
831
+ // 🔴 2026-11-07 扩展:此前只回查 position_name/status/salary/work_location(实测 checked 恒为 3),
832
+ // 正文两个最容易被静默丢弃的字段(position_duty / work_request)不在核对范围——写没写进去摘要看不出来。
833
+ // 现把这两个多行文本也纳入严格比对(二者载体是 dataText,与单行文本不同,漏掉就会一直"假绿")。
834
+ const verification = await verifySubmitted({
835
+ host, formId: jd.formId, objId: jd.objId, dataId: formDataId,
836
+ expected: expectedFields(jd.dataDetails, ctx.cache.fields[jd.objId] || {}, ['position_name', 'position_duty', 'work_request', 'status', 'salary_min', 'salary_max', 'work_location'], ['position_name', 'status'], ['salary_min', 'salary_max', 'work_location']),
837
+ });
838
+ if (verification.mismatches.length)
839
+ invalidateEnvCache(ctx.baseUrl, ctx.appId);
840
+ const recordOk = verification.unavailable ? okByResponse : verification.mismatches.length === 0;
841
+ const created = okByResponse && recordOk;
842
+ const result = !created ? 'failed' : (verification.mismatches.length ? 'partial' : 'success');
843
+ // 列表链接只打开列表;详情单页由 viewLink 单独给出,两者不再合并成一个「列表+滑出详情」地址。
844
+ const listUrl = buildListUrl(ctx.baseUrl, (ctx.cache.lists?.position?.listId) || '');
604
845
  const cardUrl = buildCardUrl(ctx.baseUrl, jd.objId, formDataId);
605
- const locateUrl = buildListLocateUrl(ctx.baseUrl, ctx.appId, (ctx.cache.lists?.position?.listId) || '', jd.objId, formDataId);
606
846
  return rsSuccess('recruit-stage.jd.create.apply', {
607
847
  mode: 'apply',
608
- result: created ? 'success' : 'failed',
848
+ result,
609
849
  formDataId,
610
850
  positionPostId: positionPostId || null,
611
851
  rpaChecked: checkRpa === undefined ? null : !!checkRpa,
612
852
  rpaValidMsg,
613
- positionListUrl: listUrl || null,
853
+ verification: { checked: verification.checked, mismatches: verification.mismatches, unavailable: verification.unavailable || null },
854
+ verifyWarnings: verification.mismatches.map((m) => '落库回查不一致:' + m.label + ' 期望 ' + m.expected + ',实际 ' + m.actual),
855
+ positionListUrl: listUrl,
614
856
  positionCardUrl: cardUrl,
615
- positionListLocateUrl: locateUrl,
857
+ positionListLocateUrl: listUrl,
616
858
  // 产物链接(Agent 原样搬运成 Markdown 链接,按顺序:详情在前、列表在后)
617
859
  viewLink: cardUrl ? `[查看 ${jd.summary.positionName || '新建职位'} 职位详情](${cardUrl})` : null,
618
- listLocateLink: (locateUrl || listUrl) ? `[打开招聘岗位列表(已定位新建职位)](${locateUrl || listUrl})` : null,
619
- agentNote: '查看入口 = 两个 Markdown 链接(平台实证可点击):按顺序原样搬运 viewLink 与 listLocateLink;不要包 browsertool 标签。链接只是查看入口,重复点击不会重复创建。',
860
+ listLocateLink: listUrl ? `[打开职位列表](${listUrl})` : null,
861
+ agentNote: '查看入口 = 两个 Markdown 链接:① viewLink 职位详情单页 ② listLocateLink 职位列表(只打开列表,不打开详情)。按顺序原样搬运,不要包 browsertool 标签;缺哪个只给另一个。链接只是查看入口,重复点击不会重复创建。',
620
862
  ...jd.summary,
621
863
  });
622
864
  }
@@ -34,5 +34,17 @@ export function getRecruitStageOperation(operation) {
34
34
  }
35
35
  export async function executeRecruitStageOperation(operation, input, env) {
36
36
  const definition = getRecruitStageOperation(operation);
37
+ // 拒绝未声明参数(2026-11-07):与 ehr 标准入口一致,防「参数名写错被静默忽略」。
38
+ // 例:candidate.interview.arrange.* 的时间参数是 startTime/endTime,stage.interview.arrange.* 是 start/end,
39
+ // 传错时摘要里的 time 会变成 null 而不报错。
40
+ const schema = definition.inputSchema;
41
+ if (schema && schema.additionalProperties === false) {
42
+ const known = Object.keys((schema.properties || {}));
43
+ const unknown = Object.keys(input || {}).filter((key) => !known.includes(key));
44
+ if (unknown.length > 0) {
45
+ throw new RecruitStageCliError('validation', 'unknown_argument', `未知参数:${unknown.join('、')}。本操作支持的参数:${known.length ? known.join('、') : '(无)'}。`
46
+ + '参数名写错会被静默忽略并返回看似正常的结果,请按上面的参数名重传。', { exitCode: 1 });
47
+ }
48
+ }
37
49
  return definition.handler(input, env);
38
50
  }