weaver-work-cli 0.1.45 → 0.1.47

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 (129) hide show
  1. package/dist/chunks/{attachment-content-CE3GMWTS.js → attachment-content-MCXQBD6N.js} +3 -3
  2. package/dist/chunks/{chunk-VIMCY4DI.js → chunk-4RWS2YYL.js} +2 -2
  3. package/dist/chunks/{chunk-4EXOIQDI.js → chunk-6AXKWFKG.js} +4 -14
  4. package/dist/chunks/{chunk-JWWTI63L.js → chunk-6V5ZPKHV.js} +2 -8
  5. package/dist/chunks/{chunk-3ZMAQQ3W.js → chunk-76H3IKH6.js} +39 -26
  6. package/dist/chunks/{chunk-LGKWL4OH.js → chunk-AD46OMQK.js} +86 -25
  7. package/dist/chunks/{chunk-3WBIQLMB.js → chunk-GSZTA43P.js} +2 -2
  8. package/dist/chunks/{chunk-OAE3AZBQ.js → chunk-IP4CWQCF.js} +6 -6
  9. package/dist/chunks/{chunk-77YP6I52.js → chunk-IRMIEDXN.js} +1 -1
  10. package/dist/chunks/{chunk-LRCPNDZA.js → chunk-J2VEB5K3.js} +11 -9
  11. package/dist/chunks/{chunk-T4MWQAQB.js → chunk-JFAWZX53.js} +128 -9
  12. package/dist/chunks/{chunk-GR76ZDDX.js → chunk-LIEQJIGM.js} +3 -0
  13. package/dist/chunks/{chunk-DGMYACGJ.js → chunk-OXHHJWNC.js} +1 -1
  14. package/dist/chunks/{chunk-LXFVWZLM.js → chunk-PSOMGA3U.js} +3 -3
  15. package/dist/chunks/{conflict-IYJETSGT.js → conflict-H7EHQXYY.js} +2 -2
  16. package/dist/chunks/{create-flow-7JLC7UID.js → create-flow-VRVJEOBX.js} +6 -6
  17. package/dist/chunks/{ehr-MYRDCHZ4.js → ehr-SH2LM3NK.js} +528 -40
  18. package/dist/chunks/{env-3MBHAWBL.js → env-66FPSJDV.js} +2 -2
  19. package/dist/chunks/{factory-TZEVU4DU.js → factory-UH2TZBVA.js} +1 -1
  20. package/dist/chunks/{group-chat-KL3HFKRM.js → group-chat-CAKMMV7K.js} +3 -3
  21. package/dist/chunks/{invoice-OQP3TMKQ.js → invoice-UEAHSYAE.js} +279 -1
  22. package/dist/chunks/{lazy-dispatch-UH6HGK2I.js → lazy-dispatch-25XGTXLM.js} +2 -2
  23. package/dist/chunks/{meeting-C67EHQ4Z.js → meeting-VTBFW4HI.js} +10 -10
  24. package/dist/chunks/{recruit-stage-AHY5QAMF.js → recruit-stage-CAKZTUA7.js} +917 -85
  25. package/dist/chunks/{registry-XPWPGHYE.js → registry-JVQBLFQ5.js} +10 -10
  26. package/dist/chunks/{room-recommend-CNWE5WQK.js → room-recommend-5U55FMXZ.js} +4 -4
  27. package/dist/chunks/{schedule-YYNYBQIE.js → schedule-IDETODCA.js} +4 -4
  28. package/dist/cmd/action.js +14 -10
  29. package/dist/index.js +7 -7
  30. package/dist/shortcuts/ehr/host.js +2 -2
  31. package/dist/shortcuts/ehr/index.js +14 -3
  32. package/dist/shortcuts/ehr/manifest.js +5 -1
  33. package/dist/shortcuts/ehr/operations/recruit-candidate-import.js +40 -10
  34. package/dist/shortcuts/ehr/operations/recruit-interview-overview.js +258 -0
  35. package/dist/shortcuts/ehr/operations/recruit-position.js +10 -8
  36. package/dist/shortcuts/ehr/operations/recruit-stats.js +14 -1
  37. package/dist/shortcuts/ehr/operations/recruit-tag.js +173 -0
  38. package/dist/shortcuts/ehr/operations/recruit-write.js +137 -18
  39. package/dist/shortcuts/ehr/operations/recruit.js +180 -8
  40. package/dist/shortcuts/ehr/operations/registry.js +4 -0
  41. package/dist/shortcuts/ehr/operations.js +24 -0
  42. package/dist/shortcuts/ehr/recruit-stage/batch-store.js +78 -0
  43. package/dist/shortcuts/ehr/recruit-stage/context.js +231 -0
  44. package/dist/shortcuts/ehr/recruit-stage/continuation.js +74 -0
  45. package/dist/shortcuts/ehr/recruit-stage/errors.js +65 -0
  46. package/dist/shortcuts/ehr/recruit-stage/fs-scan.js +165 -0
  47. package/dist/shortcuts/ehr/recruit-stage/host.js +109 -0
  48. package/dist/shortcuts/ehr/recruit-stage/operations/interview-arrange.js +1049 -0
  49. package/dist/shortcuts/ehr/recruit-stage/operations/interview-feedback.js +295 -0
  50. package/dist/shortcuts/ehr/recruit-stage/operations/jd-create.js +961 -0
  51. package/dist/shortcuts/ehr/recruit-stage/operations/list.js +431 -0
  52. package/dist/shortcuts/ehr/recruit-stage/operations/registry.js +50 -0
  53. package/dist/shortcuts/ehr/recruit-stage/operations/resume-import.js +1647 -0
  54. package/dist/shortcuts/ehr/recruit-stage/operations/search.js +158 -0
  55. package/dist/shortcuts/ehr/recruit-stage/operations/types.js +34 -0
  56. package/dist/shortcuts/ehr/recruit-stage/runtime.js +31 -0
  57. package/dist/shortcuts/ehr/recruit-stage/school-tiers.json +318 -0
  58. package/dist/shortcuts/ehr/recruit-stage/shared.js +805 -0
  59. package/dist/shortcuts/invoice/host.js +3 -0
  60. package/dist/shortcuts/invoice/manifest.js +61 -0
  61. package/dist/shortcuts/invoice/operations/registry.js +2 -0
  62. package/dist/shortcuts/invoice/operations/reim-subsidy.js +233 -0
  63. package/dist/shortcuts/meeting/operations/eb/create-flow.js +93 -18
  64. package/dist/shortcuts/meeting/operations/eb/factory.js +5 -8
  65. package/dist/shortcuts/meeting/operations/eb/room-recommend.js +2 -13
  66. package/dist/shortcuts/meeting/operations/invitation.js +27 -4
  67. package/dist/shortcuts/recruit-stage/batch-store.js +78 -0
  68. package/dist/shortcuts/recruit-stage/fs-scan.js +165 -0
  69. package/dist/shortcuts/recruit-stage/operations/interview-arrange.js +277 -20
  70. package/dist/shortcuts/recruit-stage/operations/interview-feedback.js +31 -7
  71. package/dist/shortcuts/recruit-stage/operations/jd-create.js +106 -16
  72. package/dist/shortcuts/recruit-stage/operations/registry.js +12 -0
  73. package/dist/shortcuts/recruit-stage/operations/resume-import.js +273 -6
  74. package/dist/shortcuts/recruit-stage/operations/types.js +9 -0
  75. package/dist/shortcuts/recruit-stage/shared.js +60 -6
  76. package/docs/invoice.md +1 -0
  77. package/package.json +1 -1
  78. package/skills/weaver-e10-jinchengda/references/contract-compare-report-template.html +2 -2
  79. package/skills/weaver-e10-jucailin/SKILL.md +12 -3
  80. package/skills/weaver-e10-jucailin/archive/LEGACY-README.md +18 -0
  81. package/skills/weaver-e10-jucailin/archive/LEGACY-SKILL.md +239 -0
  82. package/skills/weaver-e10-jucailin/archive/LEGACY-openai.yaml +131 -0
  83. package/skills/weaver-e10-jucailin/archive/LEGACY-position-templates.md +221 -0
  84. package/skills/weaver-e10-jucailin/archive/LEGACY-recruit-arrange-interview.md +334 -0
  85. package/skills/weaver-e10-jucailin/archive/LEGACY-recruit-capability-check.md +127 -0
  86. package/skills/weaver-e10-jucailin/archive/LEGACY-recruit-check-install.md +65 -0
  87. package/skills/weaver-e10-jucailin/archive/LEGACY-recruit-detail-process.md +63 -0
  88. package/skills/weaver-e10-jucailin/archive/LEGACY-recruit-edit-interview-feedback.md +142 -0
  89. package/skills/weaver-e10-jucailin/archive/LEGACY-recruit-jd-create.md +114 -0
  90. package/skills/weaver-e10-jucailin/archive/LEGACY-recruit-jd-template.md +56 -0
  91. package/skills/weaver-e10-jucailin/archive/LEGACY-recruit-list-candidate.md +101 -0
  92. package/skills/weaver-e10-jucailin/archive/LEGACY-recruit-list-interview.md +148 -0
  93. package/skills/weaver-e10-jucailin/archive/LEGACY-recruit-match-candidates.md +77 -0
  94. package/skills/weaver-e10-jucailin/archive/LEGACY-recruit-output-links.md +72 -0
  95. package/skills/weaver-e10-jucailin/archive/LEGACY-recruit-resolve-creator.md +69 -0
  96. package/skills/weaver-e10-jucailin/archive/LEGACY-recruit-resolve-metadata.md +241 -0
  97. package/skills/weaver-e10-jucailin/archive/LEGACY-recruit-resume-import.md +457 -0
  98. package/skills/weaver-e10-jucailin/archive/LEGACY-recruit-resume-parse.md +128 -0
  99. package/skills/weaver-e10-jucailin/archive/LEGACY-recruit-search-candidate.md +146 -0
  100. package/skills/weaver-e10-jucailin/archive/LEGACY-recruit-urge-feedback.md +69 -0
  101. package/skills/weaver-e10-jucailin/lib/recruit-xiaoe-file.mjs +192 -0
  102. package/skills/weaver-e10-jucailin/lib/xiaoe-session.mjs +66 -0
  103. package/skills/weaver-e10-jucailin/references/recruit-create.md +19 -93
  104. package/skills/weaver-e10-jucailin/references/recruit-interview-overview.md +64 -0
  105. package/skills/weaver-e10-jucailin/references/recruit-read.md +63 -1
  106. package/skills/weaver-e10-jucailin/references/recruit-screening-to-interview-sop.md +95 -0
  107. package/skills/weaver-e10-jucailin/references/recruit-stage-ops.md +89 -0
  108. package/skills/weaver-e10-jucailin/references/recruit-tag.md +81 -0
  109. package/skills/weaver-e10-jucailin/references/recruit-write.md +53 -9
  110. package/skills/weaver-e10-meeting/SKILL.md +48 -4
  111. package/skills/weaver-e10-meeting/references/meeting-eb.md +1 -1
  112. package/skills/weaver-e10-recruit-stage/SKILL.md +8 -5
  113. package/skills/weaver-e10-recruit-stage/agents/openai.yaml +16 -6
  114. package/skills/weaver-e10-recruit-stage/lib/recruit-xiaoe-file.mjs +5 -1
  115. package/skills/weaver-e10-recruit-stage/references/position-templates.md +20 -1
  116. package/skills/weaver-e10-recruit-stage/references/recruit-jd-create.md +21 -0
  117. package/skills/weaver-e10-recruit-stage/references/recruit-resume-import.md +4 -0
  118. package/skills/weaver-e10-yepiaotong/SKILL.md +7 -5
  119. package/skills/weaver-e10-yepiaotong/references/invoice-import.md +1 -1
  120. package/skills/weaver-e10-yepiaotong/references/invoice-reim.md +9 -2
  121. package/skills/weaver-e10-yepiaotong/references/invoice-upload-and-validate.md +2 -0
  122. package/skills/weaver-e10-yepiaotong/references/invoice-validation-preview.md +2 -0
  123. package/skills/weaver-e10-yepiaotong/references/reim-api-reference.md +68 -6
  124. package/skills/weaver-e10-yepiaotong/references/reim-examples.md +3 -3
  125. package/skills/weaver-e10-yepiaotong/references/reim-form-fill-rules.md +8 -15
  126. package/skills/weaver-e10-yepiaotong/references/reim-matching-rules.md +6 -5
  127. package/skills/weaver-e10-yepiaotong/references/reim-phone-subsidy-rules.md +206 -92
  128. package/skills/weaver-e10-yepiaotong/references/reim-workflow.md +26 -21
  129. package/skills/weaver-e10-yepiaotong/references/source-manifest.json +35 -0
@@ -121,7 +121,15 @@ async function prepare(args, env) {
121
121
  const { createHash } = await import('node:crypto');
122
122
  const fp = createHash('sha256').update(JSON.stringify(willSubmit)).digest('hex');
123
123
  const continuation = await env.continuation.issue({ operation: 'recruit-stage.interview.feedback.edit.apply', fingerprint: fp,
124
- enumMaps: await dsOptionsSnapshot() });
124
+ enumMaps: await dsOptionsSnapshot(),
125
+ // 🔴 2026-11-07 修复(同 arrange/jd.create 的同类缺陷):apply 原来只从 args 取 talentId/result/comment,
126
+ // 导致「只带 confirm + continuation」时定位不到目标或指纹不符。现将这些参数签进 continuation。
127
+ argsSnapshot: {
128
+ talentId: t.talentId,
129
+ feedbackId: args.feedbackId ? String(args.feedbackId) : String(t.target.feedbackId),
130
+ result: args.result ? String(args.result) : undefined,
131
+ comment: args.comment !== undefined ? String(args.comment) : undefined,
132
+ } });
125
133
  return rsSuccess('recruit-stage.interview.feedback.edit.prepare', {
126
134
  mode: 'prepare',
127
135
  talentId: t.talentId,
@@ -139,6 +147,20 @@ async function prepare(args, env) {
139
147
  }
140
148
  : '⚠️ 未定位到「提交评价」按钮(getFormButtons 未取到保存按钮),仅能执行保存+写过程日志',
141
149
  willSubmit,
150
+ // 🔴 2026-11-07:本 op 此前无 preview(与 jd.create 同类缺陷)。把上方的中文字段收进 preview,
151
+ // 让「确认」这一步有统一的机器可读摘要,而不是只能靠人读散装字段。
152
+ preview: {
153
+ action: '提交/修改面试反馈',
154
+ 候选人: t.talentId,
155
+ 面试: t.target.planName,
156
+ 面试官: t.target.interviewer,
157
+ 反馈记录Id: t.target.feedbackId,
158
+ 当前反馈: (t.target.result ? '结果 ' + t.target.result : '') + (t.target.judgement ? ';评价 ' + t.target.judgement : ''),
159
+ 新反馈: (args.result ? '结果 ' + newResultName : '') + (args.comment !== undefined ? ';评价 ' + newComment : ''),
160
+ 将执行动作: analysis
161
+ ? { 保存反馈表单: 'saveFormData(全字段集 + updateTimeStamp 乐观锁)', 动作流: analysis.esbIds.length ? analysis.esbIds : '(该按钮无 esb 动作流)', 招聘API: analysis.jsCalls.map((c) => c.url) }
162
+ : '⚠️ 未定位到「提交评价」按钮,仅能执行保存+写过程日志',
163
+ },
142
164
  }, { continuation, fingerprint: fp, confirmHint: '用户明确确认后,携带 confirm:true 与 continuation 调用 apply' });
143
165
  }
144
166
  async function apply(args, env) {
@@ -148,19 +170,21 @@ async function apply(args, env) {
148
170
  throw rsValidationError('continuation_required', '缺少 continuation(来自 prepare 的 meta)');
149
171
  const payload = await env.continuation.verify(String(args.continuation), 'recruit-stage.interview.feedback.edit.apply');
150
172
  restoreDsOptions(payload.enumMaps);
151
- const t = await buildTarget(env, args);
173
+ // 合并 prepare 快照(显式传的优先),使 apply 只带 confirm + continuation 也能执行
174
+ const merged = { ...(payload.argsSnapshot || {}), ...args };
175
+ const t = await buildTarget(env, merged);
152
176
  // 重新取最新 updateTimeStamp(乐观锁)
153
177
  const rec2 = await getFormDataRecord(t.host, t.formId, String(t.target.feedbackId), t.objId);
154
178
  const details2 = toSubmitDetails(rec2.dataDetails);
155
179
  let newOptionId = null;
156
- if (args.result) {
180
+ if (merged.result) {
157
181
  const opts = await getDsOptions(t.host, t.objId, t.resultFid);
158
- newOptionId = opts[String(args.result)];
182
+ newOptionId = opts[String(merged.result)];
159
183
  if (!newOptionId)
160
- throw rsFail('未识别的面试结果「' + args.result + '」,可选:' + Object.keys(opts).join('/'));
184
+ throw rsFail('未识别的面试结果「' + merged.result + '」,可选:' + Object.keys(opts).join('/'));
161
185
  }
162
- const newComment = args.comment !== undefined ? String(args.comment) : t.target.judgement;
163
- const newResultName = args.result ? String(args.result) : t.target.result;
186
+ const newComment = merged.comment !== undefined ? String(merged.comment) : t.target.judgement;
187
+ const newResultName = merged.result ? String(merged.result) : t.target.result;
164
188
  const willSubmit = { feedbackId: String(t.target.feedbackId), result: newResultName, comment: newComment };
165
189
  const { createHash } = await import('node:crypto');
166
190
  if (payload.fingerprint !== createHash('sha256').update(JSON.stringify(willSubmit)).digest('hex')) {
@@ -41,9 +41,15 @@ const DEF_CURRENT_USER = ['recr_principal', 'employ_manager'];
41
41
  // 不传会导致后端必填校验失败、建职位直接报错(2026-11-06 实测:移除继承后 willSubmit 无薪资字段)。
42
42
  // 但历史薪资确实可能是脏数据(实测抓到 300 元月薪),因此不静默使用:
43
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,不再用脏值填坑。
44
51
  const DEF_FROM_REF = [
45
- 'position_nature', 'job_category', 'education', 'work_years',
46
- 'salary_min', 'salary_max',
52
+ 'position_nature', 'education', 'work_years',
47
53
  ];
48
54
  const DEF_STATUS = '招聘中';
49
55
  // 默认办公地点用「详细地址名称」声明,不写死记录 id:运行时到「办公地点」列表
@@ -658,31 +664,103 @@ async function prepare(args, env) {
658
664
  });
659
665
  // 参考检索默认关闭:环境职位数据重复严重(实测 836 条中「舟山民宿管家」30 条)且列表层
660
666
  // 无薪资/学历字段,参考价值低于请求成本。需要时显式传 referenceKeyword 才执行;
661
- // 岗位范式改由 references/position-templates.md 提供(零请求)。
667
+ // 岗位范式改由 references/recruit-stage/position-templates.md 提供(零请求)。
662
668
  const refs = args.referenceKeyword
663
669
  ? await fetchRecentReferences(ctx, jd, String(args.referenceKeyword))
664
670
  .catch((e) => ({ available: false, reason: e.message, items: [] }))
665
671
  : {
666
672
  available: false,
667
673
  skipped: true,
668
- reason: '未显式指定 referenceKeyword,已跳过同类职位参考检索(改用 references/position-templates.md 的岗位模板)',
674
+ reason: '未显式指定 referenceKeyword,已跳过同类职位参考检索;请改用 references/recruit-stage/position-templates.md 的岗位范式补齐 positionDuty / workRequest(该文件未覆盖的职位族须由用户提供)',
669
675
  items: [],
670
676
  };
671
677
  // fingerprint 必须基于完整 dataDetails(apply 阶段比对同一口径),回执里才做瘦身。
672
678
  const willSubmit = { formId: jd.formId, objId: jd.objId, dataDetails: jd.dataDetails };
673
679
  const fp = fingerprint(willSubmit);
674
680
  const continuation = await env.continuation.issue({ operation: 'recruit-stage.jd.create.apply', fingerprint: fp,
675
- enumMaps: await dsOptionsSnapshot() });
676
- // 回执瘦身:willSubmit 只输出字段名清单(不含内部 fieldId),continuation 提到首部——
677
- // 避免大输出被截断导致 Agent 取不到 continuation 而重复调用 prepare(实测多花 10.7s)。
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,不受裁剪影响。
678
697
  const invFieldKeys = {};
679
698
  for (const [k, v] of Object.entries(ctx.cache.fields[jd.objId] || {}))
680
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
+ };
681
757
  return rsSuccess('recruit-stage.jd.create.prepare', {
682
758
  mode: 'prepare',
683
759
  continuation,
684
760
  fingerprint: fp,
685
761
  ...jd.summary,
762
+ preview,
763
+ jdWarning,
686
764
  recentReferences: refs.items,
687
765
  recentReferencesNote: refs.skipped
688
766
  ? refs.reason
@@ -693,7 +771,10 @@ async function prepare(args, env) {
693
771
  formId: willSubmit.formId,
694
772
  objId: willSubmit.objId,
695
773
  fieldCount: willSubmit.dataDetails.length,
696
- 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
+ }),
697
778
  },
698
779
  }, {
699
780
  continuation,
@@ -708,20 +789,23 @@ async function apply(args, env) {
708
789
  throw rsValidationError('continuation_required', '缺少 continuation(来自 prepare 的 meta)');
709
790
  const payload = await env.continuation.verify(String(args.continuation), 'recruit-stage.jd.create.apply');
710
791
  restoreDsOptions(payload.enumMaps);
792
+ // 🔴 2026-11-07 修复:把 prepare 快照里的业务参数补回 args(显式传的优先),
793
+ // 使 apply 只带 confirm + continuation 也能执行,与协议文档一致。
794
+ const merged = { ...(payload.argsSnapshot || {}), ...args };
711
795
  const host = env.host;
712
796
  const session = await host.getSession();
713
797
  const ctx = { host, baseUrl: session.baseUrl.replace(/\/+$/, ''), appId: '', cache: await env.recruitContext() };
714
798
  ctx.appId = ctx.cache.appId;
715
- const positionName = String(args.positionName || '').trim();
799
+ const positionName = String(merged.positionName || '').trim();
716
800
  if (!positionName)
717
801
  throw rsValidationError('position_name_required', 'positionName 必填');
718
802
  const jd = await buildJd({
719
803
  ctx, positionName,
720
- duty: args.positionDuty ? String(args.positionDuty) : undefined,
721
- requestText: args.workRequest ? String(args.workRequest) : undefined,
722
- demandId: args.demandId ? String(args.demandId) : undefined,
723
- demandName: args.demandName ? String(args.demandName) : undefined,
724
- 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),
725
809
  });
726
810
  const willSubmit = { formId: jd.formId, objId: jd.objId, dataDetails: jd.dataDetails };
727
811
  if (payload.fingerprint !== fingerprint(willSubmit)) {
@@ -739,11 +823,17 @@ async function apply(args, env) {
739
823
  const rpaValidMsg = data.rpaValidMsg || null;
740
824
  // 页面真实响应:外层 status=true、data.status=false(业务子状态,不是失败)、fail=false、
741
825
  // successMsg=操作成功,且可能没有 positionPostId。旧逻辑强依赖 positionPostId 会把成功误判为 failed。
742
- const okByResponse = r2?.status !== false && r2?.fail !== false && data.fail !== true;
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;
743
830
  // 第三层门禁:写完回查记录与关键字段,作为最终判定(接口语义不一致时以落库为准)
831
+ // 🔴 2026-11-07 扩展:此前只回查 position_name/status/salary/work_location(实测 checked 恒为 3),
832
+ // 正文两个最容易被静默丢弃的字段(position_duty / work_request)不在核对范围——写没写进去摘要看不出来。
833
+ // 现把这两个多行文本也纳入严格比对(二者载体是 dataText,与单行文本不同,漏掉就会一直"假绿")。
744
834
  const verification = await verifySubmitted({
745
835
  host, formId: jd.formId, objId: jd.objId, dataId: formDataId,
746
- expected: expectedFields(jd.dataDetails, ctx.cache.fields[jd.objId] || {}, ['position_name', 'status', 'salary_min', 'salary_max', 'work_location'], ['position_name', 'status'], ['salary_min', 'salary_max', 'work_location']),
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']),
747
837
  });
748
838
  if (verification.mismatches.length)
749
839
  invalidateEnvCache(ctx.baseUrl, ctx.appId);
@@ -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
  }
@@ -23,6 +23,8 @@ import schoolTiers from '../school-tiers.json';
23
23
  import { rsSuccess, schemaOf } from './types.js';
24
24
  import { rsFail, rsValidationError, rsConfirmationError } from '../errors.js';
25
25
  import { objIdOf, formIdOf, saveFormData, getFormLayoutMeta, runSaveButtonEsbActions, getTableMapping, invertTableMapping, datasetSaveFormData, datasetUpdateFormData, checkUnique, getCandidateByPhone, buildCardUrl, buildTalentViewUrl, talentLinkExtra, findMenuNode, randHex32, getDsOptions, dsOptionsSnapshot, restoreDsOptions, invalidateEnvCache, verifySubmitted, expectedFields, probeCreatePermission, } from '../shared.js';
26
+ import { scanResumeSource, findStructuredJson } from '../fs-scan.js';
27
+ import { saveBatchItems, loadBatchItems } from '../batch-store.js';
26
28
  // 更新时不允许简历覆盖的字段(人工判定/流程状态,简历无权改写)
27
29
  const PROTECTED_UPDATE_KEYS = ['is_blacklist', 'recruit_status', 'candidate_status', 'data_status'];
28
30
  // ── 上传简历文件(两步:preUploadCheck 取 preUploadId → module/upload 带 file)→ fileid ──
@@ -1011,14 +1013,16 @@ const baseInput = {
1011
1013
  noSchoolTags: { type: 'boolean', description: '关闭学校归属标签自动推导' },
1012
1014
  updateTalentId: { type: 'string', description: '按简历更新已有人才(主表全量覆盖+明细整表覆盖;先 prepare 看差异)' },
1013
1015
  };
1014
- async function prepare(args, env) {
1016
+ async function prepare(args, env, opts = {}) {
1015
1017
  const host = env.host;
1016
1018
  const session = await host.getSession();
1017
1019
  const ctx = { host, baseUrl: session.baseUrl.replace(/\/+$/, ''), appId: '', cache: await env.recruitContext() };
1018
1020
  ctx.appId = ctx.cache.appId;
1019
- const perm = await probeCreatePermission(ctx.host, objIdOf(ctx.cache, 'talent_pool'));
1020
- if (perm === 'denied')
1021
- throw rsFail('当前账号没有「人才库」表单的创建权限,已阻断(未写入任何数据)');
1021
+ if (!opts.skipPermissionProbe) {
1022
+ const perm = await probeCreatePermission(ctx.host, objIdOf(ctx.cache, 'talent_pool'));
1023
+ if (perm === 'denied')
1024
+ throw rsFail('当前账号没有「人才库」表单的创建权限,已阻断(未写入任何数据)');
1025
+ }
1022
1026
  const argsT = args;
1023
1027
  if (!argsT.structured && !argsT.structuredFile && !argsT.fileId && !argsT.resumeFile) {
1024
1028
  throw rsValidationError('input_required', '需要 structured/structuredFile/fileId/resumeFile 之一');
@@ -1079,7 +1083,22 @@ async function prepare(args, env) {
1079
1083
  const willSubmit = { updateTalentId, mainTable: fingerprintMainTable(upMain), details: built.detailsPayload };
1080
1084
  const fp = fingerprint(willSubmit);
1081
1085
  const continuation = await env.continuation.issue({ operation: 'recruit-stage.resume.import.apply', fingerprint: fp,
1082
- enumMaps: await dsOptionsSnapshot() });
1086
+ enumMaps: await dsOptionsSnapshot(),
1087
+ // 🔴 2026-11-07 修复(同 arrange / jd.create / position.create 的同类缺陷):apply 只带
1088
+ // confirm + continuation 时,buildImport 需要的简历来源参数必须能从快照恢复,
1089
+ // 否则会报 resume_source_required(文档写法跑不通)。
1090
+ argsSnapshot: {
1091
+ file: args.file ? String(args.file) : undefined,
1092
+ structuredFile: args.structuredFile ? String(args.structuredFile) : undefined,
1093
+ fileId: args.fileId ? String(args.fileId) : undefined,
1094
+ resumeFile: args.resumeFile ? String(args.resumeFile) : undefined,
1095
+ channel: args.channel ? String(args.channel) : undefined,
1096
+ updateTalentId: args.updateTalentId ? String(args.updateTalentId) : undefined,
1097
+ useOcr: args.useOcr === true,
1098
+ noSchoolTags: args.noSchoolTags === true,
1099
+ structured: args.structured,
1100
+ tags: args.tags,
1101
+ } });
1083
1102
  return rsSuccess('recruit-stage.resume.import.prepare', {
1084
1103
  mode: 'prepare-update',
1085
1104
  action: '按简历更新已有人才',
@@ -1093,6 +1112,16 @@ async function prepare(args, env) {
1093
1112
  protectedSkipped,
1094
1113
  talentViewUrl: viewUrl,
1095
1114
  note: '以上为将写入的差异。确认后 apply 执行;全量覆盖会改掉人工修正过的值',
1115
+ // 🔴 2026-11-07:本 op 此前无 preview(与 jd.create 同类缺陷)。更新场景最关键的是「改哪些字段、跳过哪些」。
1116
+ preview: {
1117
+ action: '按简历更新已有人才(全量覆盖)',
1118
+ talentId: updateTalentId,
1119
+ 变更字段数: Array.isArray(changed) ? changed.length : 0,
1120
+ 变更明细: changed,
1121
+ 未变字段数: fieldDiff.filter((x) => x.change === 'same').length,
1122
+ 保护未覆盖: protectedSkipped,
1123
+ note: '全量覆盖会改掉人工修正过的值;确认逐项变更后再 apply',
1124
+ },
1096
1125
  }, { continuation, fingerprint: fp, confirmHint: '用户明确确认后,携带 confirm:true 与 continuation 调用 apply' });
1097
1126
  }
1098
1127
  // 查重与标签预检互不依赖 → 并行(标签清单分页通常多 RTT,与查重力求重叠)。
@@ -1151,13 +1180,35 @@ async function prepare(args, env) {
1151
1180
  const willSubmit = { formId: built.formId, objId: built.objId, mainTable: fingerprintMainTable(toDatasetMainTable(built.dataDetails, built.fields)), details: built.detailsPayload };
1152
1181
  const fp = fingerprint(willSubmit);
1153
1182
  const continuation = await env.continuation.issue({ operation: 'recruit-stage.resume.import.apply', fingerprint: fp,
1154
- enumMaps: await dsOptionsSnapshot() });
1183
+ enumMaps: await dsOptionsSnapshot(),
1184
+ // 🔴 2026-11-07 修复(同 arrange / jd.create / position.create 的同类缺陷):apply 只带
1185
+ // confirm + continuation 时,buildImport 需要的简历来源参数必须能从快照恢复,
1186
+ // 否则会报 resume_source_required(文档写法跑不通)。
1187
+ argsSnapshot: {
1188
+ file: args.file ? String(args.file) : undefined,
1189
+ structuredFile: args.structuredFile ? String(args.structuredFile) : undefined,
1190
+ fileId: args.fileId ? String(args.fileId) : undefined,
1191
+ resumeFile: args.resumeFile ? String(args.resumeFile) : undefined,
1192
+ channel: args.channel ? String(args.channel) : undefined,
1193
+ updateTalentId: args.updateTalentId ? String(args.updateTalentId) : undefined,
1194
+ useOcr: args.useOcr === true,
1195
+ noSchoolTags: args.noSchoolTags === true,
1196
+ structured: args.structured,
1197
+ tags: args.tags,
1198
+ } });
1155
1199
  return rsSuccess('recruit-stage.resume.import.prepare', {
1156
1200
  mode: 'prepare', ...summary,
1157
1201
  willSubmit,
1158
1202
  tagCheck,
1159
1203
  schoolTags: built.schoolTagInfo,
1160
1204
  onCommit: '提交后将:① dataset/v2/saveFormData 建人才(主表+明细一次写入)② 初始化人才批次 ③ 触发人才自动标签规则匹配 ④ 按标签(含学校归属自动推导)写入平台标签 ⑤ 输出人才卡片/人才库定位链接',
1205
+ // 🔴 2026-11-07:本 op 此前无 preview(与 jd.create 同类缺陷)。新建场景要把「建档字段 + 标签预检结果」一起给出来。
1206
+ preview: {
1207
+ ...summary,
1208
+ tagCheck,
1209
+ schoolTags: built.schoolTagInfo,
1210
+ onCommit: '提交后将:建人才 → 初始化批次 → 自动标签匹配 → 写平台标签 → 输出卡片与人才库链接',
1211
+ },
1161
1212
  }, { continuation, fingerprint: fp, confirmHint: '用户明确确认后,携带 confirm:true 与 continuation 调用 apply' });
1162
1213
  }
1163
1214
  async function apply(args, env) {
@@ -1166,6 +1217,11 @@ async function apply(args, env) {
1166
1217
  if (!args.continuation)
1167
1218
  throw rsValidationError('continuation_required', '缺少 continuation(来自 prepare 的 meta)');
1168
1219
  const payload = await env.continuation.verify(String(args.continuation), 'recruit-stage.resume.import.apply');
1220
+ // 合并 prepare 快照(显式传的优先),使 apply 只带 confirm + continuation 也能执行
1221
+ return applyCore({ ...(payload.argsSnapshot || {}), ...args }, env, payload);
1222
+ }
1223
+ /** 单份简历的落库执行体(供单条 apply 与批量 apply 复用;payload 由调用方校验)。 */
1224
+ async function applyCore(args, env, payload) {
1169
1225
  restoreDsOptions(payload.enumMaps);
1170
1226
  const host = env.host;
1171
1227
  const session = await host.getSession();
@@ -1350,6 +1406,185 @@ async function apply(args, env) {
1350
1406
  },
1351
1407
  });
1352
1408
  }
1409
+ // ── 批量简历导入(2026-11-06)────────────────────────────────────────────────
1410
+ // 输入可以是「一个文件夹」或「一个 zip 包」,也可以直接给 items(每项自带 structured)。
1411
+ // 逐份走与单条完全相同的 prepare → apply(上传原件 / 查重 / 明细写入 / 标签 / 回查),
1412
+ // 最后汇总成一张结果表。解析口径不变:structured 优先,useOcr 只在显式开启时兜底。
1413
+ const IMPORT_BATCH_MAX = 50;
1414
+ async function batchPrepare(args, env) {
1415
+ const explicit = Array.isArray(args.items) ? args.items : null;
1416
+ const scan = !explicit && args.source ? scanResumeSource(String(args.source)) : null;
1417
+ if (!explicit && !scan) {
1418
+ throw rsValidationError('source_required', '需要 source(文件夹或 .zip 路径)或 items([{file, structured?}])之一');
1419
+ }
1420
+ const structuredDir = args.structuredDir ? String(args.structuredDir) : undefined;
1421
+ const shared = {};
1422
+ for (const k of ['channel', 'useOcr', 'noSchoolTags'])
1423
+ if (args[k] !== undefined)
1424
+ shared[k] = args[k];
1425
+ if (Array.isArray(args.tags))
1426
+ shared.tags = args.tags;
1427
+ const entries = (explicit || scan.files).map((x, i) => {
1428
+ if (explicit) {
1429
+ const file = x?.file ? path.resolve(String(x.file)) : '';
1430
+ return {
1431
+ file, name: file ? path.basename(file) : `第${i + 1}项`,
1432
+ structured: x?.structured, structuredFile: x?.structuredFile,
1433
+ };
1434
+ }
1435
+ return { file: x.path, name: x.name, structured: undefined, structuredFile: undefined };
1436
+ });
1437
+ if (entries.length > IMPORT_BATCH_MAX) {
1438
+ throw rsValidationError('batch_too_many', `一次最多 ${IMPORT_BATCH_MAX} 份(当前 ${entries.length} 份);请分批执行`);
1439
+ }
1440
+ if (!entries.length) {
1441
+ throw rsValidationError('no_resume_files', '没有找到简历文件(支持 pdf/doc/docx/rtf/txt/wps;目录最多向下 4 层)');
1442
+ }
1443
+ const items = [];
1444
+ const ready = [];
1445
+ for (let i = 0; i < entries.length; i++) {
1446
+ const e = entries[i];
1447
+ const row = { index: i + 1, file: e.name, path: e.file || undefined };
1448
+ try {
1449
+ let structured = e.structured;
1450
+ let structuredFile = e.structuredFile ? path.resolve(String(e.structuredFile)) : '';
1451
+ if (!structured && !structuredFile && e.file) {
1452
+ const hit = findStructuredJson({ path: e.file, name: e.name, size: 0 }, structuredDir);
1453
+ if (hit)
1454
+ structuredFile = hit;
1455
+ }
1456
+ if (!structured && !structuredFile && !shared.useOcr) {
1457
+ row.status = 'needs_parse';
1458
+ row.message = '缺少结构化数据:请由大模型解析后以 items[].structured(或同名 .json)提供;扫描件可显式 useOcr:true';
1459
+ items.push(row);
1460
+ continue;
1461
+ }
1462
+ const r = await prepare({ ...shared, resumeFile: e.file || undefined, structured, structuredFile: structuredFile || undefined }, env, { skipPermissionProbe: i > 0 });
1463
+ const d = r.data || {};
1464
+ const meta = r.meta || {};
1465
+ const dup = d.duplicate || {};
1466
+ const blocked = dup.unique === false;
1467
+ row.name = d.parsed?.name;
1468
+ row.mobile = d.parsed?.mobile;
1469
+ row.hasStructured = !!(structured || structuredFile);
1470
+ row.duplicateNote = dup.note;
1471
+ if (blocked) {
1472
+ row.status = 'blocked';
1473
+ row.message = '查重未通过:' + (dup.note || '已存在同手机号人才');
1474
+ items.push(row);
1475
+ continue;
1476
+ }
1477
+ row.status = 'ready';
1478
+ items.push(row);
1479
+ ready.push({ index: i + 1, label: row.name || e.name, file: e.file, args: { ...shared, resumeFile: e.file || undefined, structured, structuredFile: structuredFile || undefined }, fingerprint: String(meta.fingerprint || '') });
1480
+ }
1481
+ catch (err) {
1482
+ row.status = 'failed';
1483
+ row.message = err?.message || 'prepare 失败';
1484
+ items.push(row);
1485
+ }
1486
+ }
1487
+ if (!ready.length) {
1488
+ return rsSuccess('recruit-stage.resume.import.batch.prepare', {
1489
+ mode: 'batch-prepare',
1490
+ total: items.length, ready: 0,
1491
+ blocked: items.filter((x) => x.status === 'blocked').length,
1492
+ needsParse: items.filter((x) => x.status === 'needs_parse').length,
1493
+ failed: items.filter((x) => x.status === 'failed').length,
1494
+ scanned: scan ? { root: scan.root, files: scan.files.length, warnings: scan.warnings } : undefined,
1495
+ items,
1496
+ hint: '没有可执行项,逐条看 items[].message(常见:缺少结构化 JSON、查重命中、格式不支持)',
1497
+ // 🔴 2026-11-07:本 op 此前无 preview。文件清单可能很大,preview 只保留「文件 + 状态 + 原因」。
1498
+ preview: {
1499
+ action: '批量简历导入 — 无可执行项',
1500
+ total: items.length,
1501
+ blocked: items.filter((x) => x.status === 'blocked').length,
1502
+ needsParse: items.filter((x) => x.status === 'needs_parse').length,
1503
+ failed: items.filter((x) => x.status === 'failed').length,
1504
+ reasons: items.map((x) => `${x.file}:${x.message || x.status}`),
1505
+ },
1506
+ });
1507
+ }
1508
+ const fp = createHash('sha256').update(JSON.stringify(ready.map((x) => [x.file, x.fingerprint]))).digest('hex');
1509
+ // 清单可能很大(每项带 structured),落盘暂存;token 只带路径与内容指纹
1510
+ const store = saveBatchItems('resume-import', ready);
1511
+ const continuation = await env.continuation.issue({
1512
+ operation: 'recruit-stage.resume.import.batch.apply',
1513
+ fingerprint: fp,
1514
+ enumMaps: await dsOptionsSnapshot(),
1515
+ batchFile: store.file,
1516
+ batchFingerprint: store.fingerprint,
1517
+ });
1518
+ return rsSuccess('recruit-stage.resume.import.batch.prepare', {
1519
+ mode: 'batch-prepare',
1520
+ total: items.length,
1521
+ ready: ready.length,
1522
+ blocked: items.filter((x) => x.status === 'blocked').length,
1523
+ needsParse: items.filter((x) => x.status === 'needs_parse').length,
1524
+ failed: items.filter((x) => x.status === 'failed').length,
1525
+ scanned: scan ? { root: scan.root, files: scan.files.length, warnings: scan.warnings } : undefined,
1526
+ items,
1527
+ note: '确认后带 confirm:true 与 meta.continuation 调 batch.apply;逐份建档,可能是 partial',
1528
+ // 🔴 2026-11-07:本 op 此前无 preview。preview 只列「文件 + 状态」,不复制 structured(体积会爆)。
1529
+ preview: {
1530
+ action: '批量简历导入(逐份建档,结果可能 partial)',
1531
+ total: items.length,
1532
+ ready: ready.length,
1533
+ blocked: items.filter((x) => x.status === 'blocked').length,
1534
+ needsParse: items.filter((x) => x.status === 'needs_parse').length,
1535
+ failed: items.filter((x) => x.status === 'failed').length,
1536
+ files: items.map((x) => `${x.file} — ${x.status}${x.message ? ':' + x.message : ''}`),
1537
+ scanned: scan ? { root: scan.root, files: scan.files.length, warnings: scan.warnings } : undefined,
1538
+ },
1539
+ }, {
1540
+ continuation,
1541
+ fingerprint: fp,
1542
+ confirmHint: '用户确认整批名单后,携带 confirm:true 与本 continuation 调用 recruit-stage.resume.import.batch.apply',
1543
+ });
1544
+ }
1545
+ async function batchApply(args, env) {
1546
+ if (args.confirm !== true) {
1547
+ throw rsConfirmationError('recruit-stage.resume.import.batch.apply', { hint: '批量写操作必须显式 confirm:true' });
1548
+ }
1549
+ if (!args.continuation)
1550
+ throw rsValidationError('continuation_required', '缺少 continuation(来自 batch.prepare 的 meta)');
1551
+ const batch = await env.continuation.verify(String(args.continuation), 'recruit-stage.resume.import.batch.apply');
1552
+ const items = loadBatchItems(batch.batchFile, batch.batchFingerprint);
1553
+ if (!items.length)
1554
+ throw rsValidationError('batch_empty', 'continuation 中没有可执行的简历');
1555
+ const results = [];
1556
+ for (const it of items) {
1557
+ try {
1558
+ const r = await applyCore({ ...(it.args || {}), confirm: true }, env, { fingerprint: it.fingerprint, enumMaps: batch.enumMaps });
1559
+ const d = r.data || {};
1560
+ results.push({
1561
+ index: it.index, file: path.basename(String(it.file || '')), name: it.label,
1562
+ status: d.result === 'partial' ? 'partial' : 'success',
1563
+ talentId: d.talentId, cardUrl: d.talentCardUrl, viewLink: d.viewLink,
1564
+ warnings: d.verifyWarnings && d.verifyWarnings.length ? d.verifyWarnings : undefined,
1565
+ });
1566
+ }
1567
+ catch (e) {
1568
+ results.push({ index: it.index, file: path.basename(String(it.file || '')), name: it.label, status: 'failed', message: e?.message || '执行失败' });
1569
+ }
1570
+ }
1571
+ const ok = results.filter((x) => x.status === 'success').length;
1572
+ const partial = results.filter((x) => x.status === 'partial').length;
1573
+ const failed = results.filter((x) => x.status === 'failed').length;
1574
+ const lines = [
1575
+ '| # | 文件 | 姓名 | 结果 | 说明 |',
1576
+ '|---|---|---|---|---|',
1577
+ ...results.map((x) => `| ${x.index} | ${x.file} | ${x.name || '-'} | ${x.status === 'success' ? '成功' : x.status === 'partial' ? '部分成功' : '失败'} | ${x.message || (x.warnings?.length ? x.warnings.join(';') : x.cardUrl ? '已建档' : '')} |`),
1578
+ ];
1579
+ return rsSuccess('recruit-stage.resume.import.batch.apply', {
1580
+ mode: 'batch-apply',
1581
+ result: failed || partial ? 'partial' : 'success',
1582
+ total: results.length, succeeded: ok, partial, failed,
1583
+ items: results,
1584
+ resultTable: lines.join('\n'),
1585
+ agentNote: '把 resultTable 原样放回答正文;失败/部分成功的条目要带 message 说明原因,不要只报总数。',
1586
+ });
1587
+ }
1353
1588
  export const resumeImportOperations = [
1354
1589
  {
1355
1590
  name: 'recruit-stage.resume.import.prepare',
@@ -1375,6 +1610,38 @@ export const resumeImportOperations = [
1375
1610
  inputSchema: schemaOf({ ...baseInput, confirm: { type: 'boolean' }, continuation: { type: 'string' } }, {}),
1376
1611
  handler: apply,
1377
1612
  },
1613
+ {
1614
+ name: 'recruit-stage.resume.import.batch.prepare',
1615
+ resource: 'recruit.resume',
1616
+ method: 'prepare',
1617
+ action: 'resume.import.batch.prepare',
1618
+ summary: '批量简历导入确认摘要:扫描文件夹或 zip、逐份上传/查重/字段映射,输出可执行/查重拦截/待解析清单(不建档);一次最多 50 份',
1619
+ capability: 'recruit.resume.import',
1620
+ risk: 'write',
1621
+ requiresConfirmation: true,
1622
+ inputSchema: schemaOf({
1623
+ source: { type: 'string', description: '简历文件夹或 .zip 包路径(与 items 二选一)' },
1624
+ items: { type: 'array', description: '显式清单 [{file, structured?, structuredFile?}],与 source 二选一', items: { type: 'object' } },
1625
+ structuredDir: { type: 'string', description: '结构化 JSON 目录(按同名 .json 自动匹配,可选)' },
1626
+ tags: { type: 'array', description: '统一追加的标签名', items: { type: 'string' } },
1627
+ channel: { type: 'string', description: '渠道(可选)' },
1628
+ useOcr: { type: 'boolean', description: '显式开启 OCR 兜底解析(闸门=checkResumeExtraction)' },
1629
+ noSchoolTags: { type: 'boolean', description: '不自动推导学校归属标签' },
1630
+ }, {}),
1631
+ handler: batchPrepare,
1632
+ },
1633
+ {
1634
+ name: 'recruit-stage.resume.import.batch.apply',
1635
+ resource: 'recruit.resume',
1636
+ method: 'apply',
1637
+ action: 'resume.import.batch.apply',
1638
+ summary: '用户确认后逐份建档(上传原件+主表明细+批次+标签+回查),返回逐份结果与 Markdown 表格;非原子批量,结果可能为 partial',
1639
+ capability: 'recruit.resume.import',
1640
+ risk: 'write',
1641
+ requiresConfirmation: true,
1642
+ inputSchema: schemaOf({ confirm: { type: 'boolean' }, continuation: { type: 'string' } }, { required: ['confirm', 'continuation'] }),
1643
+ handler: batchApply,
1644
+ },
1378
1645
  ];
1379
1646
  void findMenuNode;
1380
1647
  void randHex32;
@@ -5,6 +5,15 @@ export function rsSuccess(action, data, meta) {
5
5
  const payload = { ok: true, action, data };
6
6
  if (meta && Object.keys(meta).length > 0)
7
7
  payload.meta = meta;
8
+ // 兼容两套读法:常规组(candidate.*)把 continuation 放在 data.continuation,
9
+ // stage.* 组放在顶层 meta.continuation。这里把 meta 里的 continuation 镜像到 data,
10
+ // 使「读 data.continuation」与「读 meta.continuation」都能取到同一个值。
11
+ const cont = meta?.continuation;
12
+ if (typeof cont === 'string' && data && typeof data === 'object' && !Array.isArray(data)) {
13
+ const obj = data;
14
+ if (!(typeof obj.continuation === 'string' && obj.continuation))
15
+ obj.continuation = cont;
16
+ }
8
17
  return payload;
9
18
  }
10
19
  /** 构造「对象类型 + 严格禁止额外字段」的 JSON Schema。 */