weaver-work-cli 0.1.47 → 0.1.49

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (229) hide show
  1. package/dist/chunks/{archive-oa-BBDP7AKJ.js → archive-oa-57R2FYHV.js} +565 -17
  2. package/dist/chunks/{attachment-content-MCXQBD6N.js → attachment-content-MU2LPI5P.js} +3 -3
  3. package/dist/chunks/{chunk-J2VEB5K3.js → chunk-2BQESR2U.js} +2 -2
  4. package/dist/chunks/{chunk-727FH2NI.js → chunk-2IGZUMNG.js} +15 -2
  5. package/dist/chunks/{chunk-IP4CWQCF.js → chunk-3NV2ETZR.js} +8 -8
  6. package/dist/chunks/{chunk-OXHHJWNC.js → chunk-3X7VOSBA.js} +1 -1
  7. package/dist/chunks/chunk-5QYE52LG.js +223 -0
  8. package/dist/chunks/{chunk-IRMIEDXN.js → chunk-6GWU63YF.js} +1 -1
  9. package/dist/chunks/{chunk-3YV7PKRL.js → chunk-6QYNE6HE.js} +12 -212
  10. package/dist/chunks/{chunk-Q4OYAQYH.js → chunk-72MI3MBX.js} +4 -0
  11. package/dist/chunks/{chunk-AD46OMQK.js → chunk-BRRW7CWA.js} +121 -46
  12. package/dist/chunks/{chunk-76H3IKH6.js → chunk-D2QRZUW4.js} +221 -37
  13. package/dist/chunks/{chunk-GSZTA43P.js → chunk-EJVA5ZVB.js} +2 -2
  14. package/dist/chunks/{chunk-4RWS2YYL.js → chunk-GEOMANP7.js} +3 -3
  15. package/dist/chunks/{chunk-LIEQJIGM.js → chunk-GR76ZDDX.js} +0 -3
  16. package/dist/chunks/{chunk-O6CMPO65.js → chunk-IW7A2IQY.js} +16 -146
  17. package/dist/chunks/chunk-JEQHNNSS.js +158 -0
  18. package/dist/chunks/{chunk-6V5ZPKHV.js → chunk-K3BT54CU.js} +4 -4
  19. package/dist/chunks/{chunk-6AXKWFKG.js → chunk-KV5SOWMS.js} +4 -4
  20. package/dist/chunks/{chunk-JB34OE7R.js → chunk-NBEWUR7L.js} +1 -1
  21. package/dist/chunks/{chunk-PSOMGA3U.js → chunk-ZKEUGS2U.js} +36 -7
  22. package/dist/chunks/{conflict-H7EHQXYY.js → conflict-6347A7YK.js} +2 -2
  23. package/dist/chunks/{contract-3QLAGYQL.js → contract-N6P2HIIE.js} +425 -187
  24. package/dist/chunks/{create-flow-VRVJEOBX.js → create-flow-7WG7LVX5.js} +6 -6
  25. package/dist/chunks/data-QO7QWOIV.js +2525 -0
  26. package/dist/chunks/{ehr-SH2LM3NK.js → ehr-XI4BIVR2.js} +16 -5
  27. package/dist/chunks/{employee-NOHNXC46.js → employee-DR5Y64TI.js} +2 -1
  28. package/dist/chunks/{env-66FPSJDV.js → env-LHRKSLG6.js} +2 -2
  29. package/dist/chunks/{factory-UH2TZBVA.js → factory-2H7Z4RWJ.js} +1 -1
  30. package/dist/chunks/{group-chat-CAKMMV7K.js → group-chat-EW6PNDDT.js} +3 -3
  31. package/dist/chunks/{hrm-UNKCCCGP.js → hrm-YGIR3HGF.js} +4 -2
  32. package/dist/chunks/{im-NJB7ZYMH.js → im-3RCNL5GT.js} +107 -1
  33. package/dist/chunks/{invoice-UEAHSYAE.js → invoice-FXWH5GPO.js} +2 -71
  34. package/dist/chunks/{lazy-dispatch-25XGTXLM.js → lazy-dispatch-XSAHDK6Z.js} +3 -3
  35. package/dist/chunks/{meeting-VTBFW4HI.js → meeting-N2FQBHXI.js} +10 -10
  36. package/dist/chunks/org-NFE7X7FK.js +12 -0
  37. package/dist/chunks/{reception-5WITA44R.js → reception-MYOKJULO.js} +905 -116
  38. package/dist/chunks/{recruit-stage-CAKZTUA7.js → recruit-stage-FKWS5UQF.js} +118 -29
  39. package/dist/chunks/{registry-VWXWPVAG.js → registry-3UGIWH53.js} +4 -2
  40. package/dist/chunks/{registry-AQVGHUM6.js → registry-7VZ6YJUF.js} +2 -2
  41. package/dist/chunks/{registry-PVUZQDDQ.js → registry-BUTEDK3C.js} +1 -1
  42. package/dist/chunks/{registry-JVQBLFQ5.js → registry-CKUVBS53.js} +10 -10
  43. package/dist/chunks/{room-recommend-5U55FMXZ.js → room-recommend-MBCYENQ2.js} +4 -4
  44. package/dist/chunks/{schedule-IDETODCA.js → schedule-5IFMCXME.js} +4 -4
  45. package/dist/chunks/{workflow-BSYT5TGL.js → workflow-2TRU2ZSP.js} +5 -5
  46. package/dist/core/refs.js +19 -2
  47. package/dist/index.js +20 -15
  48. package/dist/shortcuts/archive-oa/constants.js +42 -0
  49. package/dist/shortcuts/archive-oa/host.js +2 -2
  50. package/dist/shortcuts/archive-oa/index.js +38 -0
  51. package/dist/shortcuts/archive-oa/operations/borrow-car.js +117 -3
  52. package/dist/shortcuts/archive-oa/operations/contract-modules.js +57 -0
  53. package/dist/shortcuts/archive-oa/operations/contract.js +23 -8
  54. package/dist/shortcuts/archive-oa/operations/my-borrow-contract.js +271 -0
  55. package/dist/shortcuts/archive-oa/operations/registry.js +9 -4
  56. package/dist/shortcuts/archive-oa/operations/shared.js +41 -5
  57. package/dist/shortcuts/contract/index.js +9 -1
  58. package/dist/shortcuts/contract/manifest.js +14 -2
  59. package/dist/shortcuts/contract/operations/card.js +231 -0
  60. package/dist/shortcuts/contract/operations/registry.js +2 -0
  61. package/dist/shortcuts/contract/operations/review.js +16 -5
  62. package/dist/shortcuts/contract/operations/summary.js +25 -17
  63. package/dist/shortcuts/data/errors.js +64 -0
  64. package/dist/shortcuts/data/host.js +140 -0
  65. package/dist/shortcuts/data/index.js +429 -0
  66. package/dist/shortcuts/data/manifest.js +133 -0
  67. package/dist/shortcuts/data/operations/attend.js +62 -0
  68. package/dist/shortcuts/data/operations/conf.js +384 -0
  69. package/dist/shortcuts/data/operations/ds.js +686 -0
  70. package/dist/shortcuts/data/operations/field.js +68 -0
  71. package/dist/shortcuts/data/operations/index.js +65 -0
  72. package/dist/shortcuts/data/operations/module.js +383 -0
  73. package/dist/shortcuts/data/operations/noun.js +102 -0
  74. package/dist/shortcuts/data/operations/query.js +85 -0
  75. package/dist/shortcuts/data/operations/scene.js +235 -0
  76. package/dist/shortcuts/data/operations/shared.js +279 -0
  77. package/dist/shortcuts/ehr/operations/recruit-write.js +22 -5
  78. package/dist/shortcuts/ehr/recruit-stage/operations/interview-arrange.js +28 -12
  79. package/dist/shortcuts/ehr/recruit-stage/operations/resume-import.js +21 -13
  80. package/dist/shortcuts/ehr/recruit-stage/shared.js +90 -8
  81. package/dist/shortcuts/im/index.js +128 -0
  82. package/dist/shortcuts/im/operations/session.js +6 -0
  83. package/dist/shortcuts/index.js +5 -0
  84. package/dist/shortcuts/invoice/host.js +0 -3
  85. package/dist/shortcuts/invoice/manifest.js +0 -1
  86. package/dist/shortcuts/invoice/operations/reim-subsidy.js +1 -71
  87. package/dist/shortcuts/meeting/operations/eb/conflict.js +26 -3
  88. package/dist/shortcuts/meeting/operations/eb/continuation-alias.js +63 -0
  89. package/dist/shortcuts/meeting/operations/eb/create-flow.js +71 -12
  90. package/dist/shortcuts/meeting/operations/eb/factory.js +5 -3
  91. package/dist/shortcuts/meeting/operations/eb/member-expand.js +200 -0
  92. package/dist/shortcuts/meeting/operations/registry.js +2 -0
  93. package/dist/shortcuts/reception/constants.js +11 -0
  94. package/dist/shortcuts/reception/host.js +33 -1
  95. package/dist/shortcuts/reception/index.js +22 -1
  96. package/dist/shortcuts/reception/manifest.js +55 -2
  97. package/dist/shortcuts/reception/operations/ask.js +37 -1
  98. package/dist/shortcuts/reception/operations/compose.js +124 -3
  99. package/dist/shortcuts/reception/operations/doc.js +59 -0
  100. package/dist/shortcuts/reception/operations/docrender.js +25 -1
  101. package/dist/shortcuts/reception/operations/leads.js +245 -0
  102. package/dist/shortcuts/reception/operations/markdown.js +22 -0
  103. package/dist/shortcuts/reception/operations/panels.js +84 -21
  104. package/dist/shortcuts/reception/operations/registry.js +2 -0
  105. package/dist/shortcuts/reception/operations/render.js +76 -3
  106. package/dist/shortcuts/reception/operations/restaurant-rooms.js +118 -0
  107. package/dist/shortcuts/reception/operations/restaurant.js +264 -0
  108. package/dist/shortcuts/reception/operations/restaurantrooms.js +42 -0
  109. package/dist/shortcuts/reception/operations/schedule.js +7 -1
  110. package/dist/shortcuts/reception/upload.js +22 -6
  111. package/dist/shortcuts/recruit-stage/operations/interview-arrange.js +28 -12
  112. package/dist/shortcuts/recruit-stage/operations/resume-import.js +21 -13
  113. package/dist/shortcuts/recruit-stage/shared.js +99 -14
  114. package/docs/SKILL.md +1 -0
  115. package/docs/_catalog.md +3 -0
  116. package/docs/archive-oa.md +4 -2
  117. package/docs/data.md +149 -0
  118. package/docs/reception.md +59 -5
  119. package/package.json +1 -1
  120. package/scripts/check-skill-sync.mjs +188 -0
  121. package/scripts/package-skill.mjs +17 -3
  122. package/skill-template/business-info.json +23 -0
  123. package/skill-template/domains/archive-oa.md +2 -1
  124. package/skill-template/domains/data.md +15 -0
  125. package/skill-template/master-skill-template.md +1 -0
  126. package/skill-template/skill-template.md +1 -0
  127. package/skills/weaver-e10-archive-oa/SKILL.md +35 -7
  128. package/skills/weaver-e10-archive-oa/references/borrow-car.md +32 -7
  129. package/skills/weaver-e10-archive-oa/references/contract-search.md +105 -4
  130. package/skills/weaver-e10-archive-oa/references/disabled-capabilities.md +2 -2
  131. package/skills/weaver-e10-archive-oa/references/my-borrow-contract.md +97 -0
  132. package/skills/weaver-e10-archive-oa/references/my-borrow.md +6 -1
  133. package/skills/weaver-e10-archive-oa/references/qys-contract-search.md +48 -2
  134. package/skills/weaver-e10-calendar/SKILL.md +1 -1
  135. package/skills/weaver-e10-calendar/references/calendar-query.md +1 -1
  136. package/skills/weaver-e10-calendar/references/calendar-write.md +9 -9
  137. package/skills/weaver-e10-cowork/SKILL.md +9 -6
  138. package/skills/weaver-e10-data/SKILL.md +118 -0
  139. package/skills/weaver-e10-data/references/config-center.md +90 -0
  140. package/skills/weaver-e10-data/references/datasource.md +136 -0
  141. package/skills/weaver-e10-data/references/scene-and-misc.md +82 -0
  142. package/skills/weaver-e10-jinchengda/SKILL.md +10 -7
  143. package/skills/weaver-e10-jinchengda/references/contract-action-card-template.html +17 -0
  144. package/skills/weaver-e10-jinchengda/references/contract-action-card.md +263 -35
  145. package/skills/weaver-e10-jinchengda/references/contract-action-engine.md +8 -5
  146. package/skills/weaver-e10-jinchengda/references/contract-ai-assistant.md +1 -1
  147. package/skills/weaver-e10-jinchengda/references/contract-ai-review.md +175 -22
  148. package/skills/weaver-e10-jinchengda/references/contract-command-index.md +2 -2
  149. package/skills/weaver-e10-jinchengda/references/contract-credit-page.md +1 -1
  150. package/skills/weaver-e10-jinchengda/references/contract-doc-compare.md +1 -1
  151. package/skills/weaver-e10-jinchengda/references/contract-doc-triage.md +124 -19
  152. package/skills/weaver-e10-jinchengda/references/contract-element-extract.md +2 -2
  153. package/skills/weaver-e10-jinchengda/references/contract-execution-rules.md +4 -4
  154. package/skills/weaver-e10-jinchengda/references/contract-field-extract-other-flows.md +6 -0
  155. package/skills/weaver-e10-jinchengda/references/contract-flow-launch.md +1 -1
  156. package/skills/weaver-e10-jinchengda/references/contract-performance-query.md +1 -1
  157. package/skills/weaver-e10-jinchengda/references/contract-quote-to-contract.md +1 -1
  158. package/skills/weaver-e10-jinchengda/references/contract-risk-report-template.html +178 -0
  159. package/skills/weaver-e10-jinchengda/references/contract-template-recommend.md +1 -1
  160. package/skills/weaver-e10-jinchengda/references/orchestration.md +7 -7
  161. package/skills/weaver-e10-jinchengda/scripts/plan_actions.py +279 -0
  162. package/skills/weaver-e10-jinchengda/scripts/render_action_card.py +450 -0
  163. package/skills/weaver-e10-jinchengda/scripts/render_risk_report.py +358 -0
  164. package/skills/weaver-e10-jinchengda/scripts/validate_action_card.py +505 -0
  165. package/skills/weaver-e10-jucailin/SKILL.md +7 -4
  166. package/skills/weaver-e10-jucailin/references/recruit-create.md +3 -2
  167. package/skills/weaver-e10-jucailin/references/recruit-read.md +2 -1
  168. package/skills/weaver-e10-jucailin/references/recruit-stage-ops.md +3 -3
  169. package/skills/weaver-e10-jucailin/references/safety-boundaries.md +30 -2
  170. package/skills/weaver-e10-mail/SKILL.md +17 -4
  171. package/skills/weaver-e10-meeting/SKILL.md +129 -412
  172. package/skills/weaver-e10-meeting/references/create-flow.md +188 -0
  173. package/skills/weaver-e10-meeting/references/create-guardrails.md +234 -0
  174. package/skills/weaver-e10-meeting/references/pitfalls.md +40 -0
  175. package/skills/weaver-e10-reception-flow/SKILL.md +77 -19
  176. package/skills/weaver-e10-reception-flow/data/fields-snapshot.json +628 -26
  177. package/skills/weaver-e10-reception-flow/references/fields-snapshot.md +96 -26
  178. package/skills/weaver-e10-reception-flow/references/guide.md +4 -3
  179. package/skills/weaver-e10-reception-flow/scripts/render.py +84 -3
  180. package/skills/weaver-e10-recruit-stage/SKILL.md +45 -12
  181. package/skills/weaver-e10-recruit-stage/agents/openai.yaml +78 -8
  182. package/skills/weaver-e10-recruit-stage/references/position-templates.md +5 -0
  183. package/skills/weaver-e10-recruit-stage/references/recruit-arrange-interview.md +1 -1
  184. package/skills/weaver-e10-recruit-stage/references/recruit-edit-interview-feedback.md +1 -1
  185. package/skills/weaver-e10-recruit-stage/references/recruit-jd-create.md +40 -11
  186. package/skills/weaver-e10-recruit-stage/references/recruit-list-candidate.md +1 -1
  187. package/skills/weaver-e10-recruit-stage/references/recruit-list-interview.md +1 -1
  188. package/skills/weaver-e10-recruit-stage/references/recruit-match-candidates.md +1 -1
  189. package/skills/weaver-e10-recruit-stage/references/recruit-resume-import.md +16 -0
  190. package/skills/weaver-e10-recruit-stage/references/recruit-resume-parse.md +1 -1
  191. package/skills/weaver-e10-recruit-stage/references/recruit-search-candidate.md +1 -1
  192. package/skills/weaver-e10-recruit-stage/references/recruit-urge-feedback.md +1 -1
  193. package/skills/weaver-e10-recruit-stage/references/recruit-utterance-glossary.md +169 -0
  194. package/skills/weaver-e10-shijingran/SKILL.md +6 -2
  195. package/skills/weaver-e10-shijingran/references/source-manifest.json +5 -4
  196. package/skills/weaver-e10-workflow/SKILL.md +1 -1
  197. package/skills/weaver-e10-yepiaotong/SKILL.md +8 -4
  198. package/skills/weaver-e10-yepiaotong/references/invoice-issuing-workflow.md +1 -1
  199. package/skills/weaver-e10-yepiaotong/references/invoice-reim.md +1 -1
  200. package/skills/weaver-e10-yepiaotong/references/reim-api-reference.md +2 -2
  201. package/skills/weaver-e10-yepiaotong/references/reim-form-fill-rules.md +1 -1
  202. package/skills/weaver-e10-yepiaotong/references/reim-phone-subsidy-rules.md +1 -1
  203. package/skills/weaver-e10-yepiaotong/references/reim-workflow.md +1 -0
  204. package/skills/weaver-e10-yimiaoban/SKILL.md +2 -1
  205. package/skills/weaver-e10-yimiaoban/references/msg-write.md +32 -0
  206. package/skills/weaver-e10-yimiaoban/references/session-sysmsg.md +3 -0
  207. package/skills/weaver-e10-yimiaoban/references/source-manifest.json +11 -11
  208. package/dist/chunks/{ebuilder-form-GWDTKEI2.js → ebuilder-form-CBYI6CQ6.js} +3 -3
  209. /package/{skills → docs/legacy}/weaver-e10-jucailin/archive/LEGACY-README.md +0 -0
  210. /package/{skills → docs/legacy}/weaver-e10-jucailin/archive/LEGACY-SKILL.md +0 -0
  211. /package/{skills → docs/legacy}/weaver-e10-jucailin/archive/LEGACY-openai.yaml +0 -0
  212. /package/{skills → docs/legacy}/weaver-e10-jucailin/archive/LEGACY-position-templates.md +0 -0
  213. /package/{skills → docs/legacy}/weaver-e10-jucailin/archive/LEGACY-recruit-arrange-interview.md +0 -0
  214. /package/{skills → docs/legacy}/weaver-e10-jucailin/archive/LEGACY-recruit-capability-check.md +0 -0
  215. /package/{skills → docs/legacy}/weaver-e10-jucailin/archive/LEGACY-recruit-check-install.md +0 -0
  216. /package/{skills → docs/legacy}/weaver-e10-jucailin/archive/LEGACY-recruit-detail-process.md +0 -0
  217. /package/{skills → docs/legacy}/weaver-e10-jucailin/archive/LEGACY-recruit-edit-interview-feedback.md +0 -0
  218. /package/{skills → docs/legacy}/weaver-e10-jucailin/archive/LEGACY-recruit-jd-create.md +0 -0
  219. /package/{skills → docs/legacy}/weaver-e10-jucailin/archive/LEGACY-recruit-jd-template.md +0 -0
  220. /package/{skills → docs/legacy}/weaver-e10-jucailin/archive/LEGACY-recruit-list-candidate.md +0 -0
  221. /package/{skills → docs/legacy}/weaver-e10-jucailin/archive/LEGACY-recruit-list-interview.md +0 -0
  222. /package/{skills → docs/legacy}/weaver-e10-jucailin/archive/LEGACY-recruit-match-candidates.md +0 -0
  223. /package/{skills → docs/legacy}/weaver-e10-jucailin/archive/LEGACY-recruit-output-links.md +0 -0
  224. /package/{skills → docs/legacy}/weaver-e10-jucailin/archive/LEGACY-recruit-resolve-creator.md +0 -0
  225. /package/{skills → docs/legacy}/weaver-e10-jucailin/archive/LEGACY-recruit-resolve-metadata.md +0 -0
  226. /package/{skills → docs/legacy}/weaver-e10-jucailin/archive/LEGACY-recruit-resume-import.md +0 -0
  227. /package/{skills → docs/legacy}/weaver-e10-jucailin/archive/LEGACY-recruit-resume-parse.md +0 -0
  228. /package/{skills → docs/legacy}/weaver-e10-jucailin/archive/LEGACY-recruit-search-candidate.md +0 -0
  229. /package/{skills → docs/legacy}/weaver-e10-jucailin/archive/LEGACY-recruit-urge-feedback.md +0 -0
@@ -0,0 +1,85 @@
1
+ import { needArg } from '../host.js';
2
+ import { dataValidationError } from '../errors.js';
3
+ import { readJsonArg, renderTable } from './shared.js';
4
+ /** `executeQueryDsl` 的 4 个 URL query 参数——**恒定发送**,值允许为空。 */
5
+ const QUERY_PARAM_ALIASES = [
6
+ ['dimension', 'dimension'],
7
+ ['confGroup', 'conf-group'],
8
+ ['username', 'username'],
9
+ ['startDate', 'start-date'],
10
+ ];
11
+ function argStr(input, key) {
12
+ const value = input[key];
13
+ // 裸开关(只写 --username 不给值)与未传都归一为空值
14
+ if (value === undefined || value === null || value === true)
15
+ return '';
16
+ return String(value).trim();
17
+ }
18
+ /**
19
+ * 拼 4 个恒定 query。
20
+ *
21
+ * 后端签名为 `executeQueryDsl(@RequestBody DslQueryVo, @RequestParam confKey,
22
+ * @RequestParam confGroup, @RequestParam username, @RequestParam startDate, Employee)`,
23
+ * `@RequestParam` 的 required 校验看「键是否存在」而非「值是否非空」——缺键即失败、空值合法。
24
+ * 早前「空串就不带」会把最常见的情况(问句里没有人名/日期)直接打成 400/500。
25
+ */
26
+ function buildQueryString(input) {
27
+ return '?' + QUERY_PARAM_ALIASES
28
+ .map(([name, flag]) => {
29
+ const snake = flag.replace(/-/g, '_');
30
+ const raw = argStr(input, name) || argStr(input, snake) || argStr(input, flag);
31
+ return `${encodeURIComponent(name)}=${encodeURIComponent(raw)}`;
32
+ })
33
+ .join('&');
34
+ }
35
+ /**
36
+ * DSL 直查:`POST /api/dw/dsl/executeQueryDsl`。
37
+ *
38
+ * 这是整条问数链路的底层入口,`ds list/chart/stat/count` 都是它的封装。技能里有 9 条现成调用,
39
+ * 参数形式(`--conn/--model/--schema/--dsl`)必须逐字保留。
40
+ */
41
+ export async function executeQuery(input, host) {
42
+ const conn = needArg(input, 'conn');
43
+ const model = needArg(input, 'model');
44
+ const schema = needArg(input, 'schema');
45
+ const dslRaw = needArg(input, 'dsl');
46
+ const dslQuery = readJsonArg(dslRaw, '--dsl');
47
+ const body = {
48
+ connId: conn,
49
+ model,
50
+ schema,
51
+ tableId: input.table_id || input.tableId || '',
52
+ dslQuery,
53
+ };
54
+ if (input.debug !== undefined && input.debug !== null && input.debug !== '') {
55
+ const flag = String(input.debug).toLowerCase();
56
+ if (flag === 'true' || flag === '1')
57
+ body.debug = true;
58
+ else if (flag === 'false' || flag === '0')
59
+ body.debug = false;
60
+ else
61
+ throw dataValidationError('debug_invalid', `--debug 值必须为 true 或 false(当前: ${input.debug})`);
62
+ }
63
+ const response = await host.request({
64
+ method: 'POST',
65
+ path: `/api/dw/dsl/executeQueryDsl${buildQueryString(input)}`,
66
+ body,
67
+ headers: { 'Content-Type': 'application/json;charset=utf-8' },
68
+ });
69
+ const code = response?.code;
70
+ if (code !== undefined && String(code) !== '200' && String(code) !== '0') {
71
+ const message = String(response?.msg || '');
72
+ if (/没有权限|无权限|权限不足|未授权|无权访问|无查询权限/i.test(message)) {
73
+ throw dataValidationError('permission_denied', '当前用户对该数据无查询权限,请检查登录态是否有效或联系管理员开通', 4);
74
+ }
75
+ }
76
+ const payload = response?.data;
77
+ const rows = Array.isArray(payload) ? payload : (payload && Array.isArray(payload.records) ? payload.records : []);
78
+ const lines = [];
79
+ if (payload && !Array.isArray(payload) && payload.sql)
80
+ lines.push(`SQL: ${payload.sql}`);
81
+ if (String(code) !== '200' && code !== undefined)
82
+ lines.push(`code=${code} msg=${response?.msg || ''}`);
83
+ lines.push(rows.length ? renderTable(`结果 ${rows.length} 行`, rows) : '(空:0 行)');
84
+ return { data: response, text: lines.join('\n') };
85
+ }
@@ -0,0 +1,235 @@
1
+ import { needArg } from '../host.js';
2
+ import { dataApiError, dataValidationError } from '../errors.js';
3
+ /**
4
+ * 场景定位元数据(`getSceneGroups`)。
5
+ *
6
+ * 这是**元数据定位**接口,不取业务数据 —— 技能「禁手工 HTTP」的明确例外项。
7
+ * 取数仍必须走 module call / query / ds / hrm,不得用本命令替代取数。
8
+ *
9
+ * 形状口径:默认输出**顶层一律为数组**(groups = 分组数组;items = 分组数组,元素内含 datasets);
10
+ * `--json` 为接口原样返回(同为数组)⇒ 默认与 --json 的差异仅在于字段是否裁剪,顶层形状不翻转。
11
+ */
12
+ const SCENE_PATH = '/api/dw/newetl/chatBi/getSceneGroups';
13
+ const SCENE_CLIENTS = ['agent', 'all', 'connector'];
14
+ function sceneClient(input) {
15
+ const client = input.client === undefined ? 'agent' : String(input.client).trim();
16
+ if (!SCENE_CLIENTS.includes(client)) {
17
+ throw dataValidationError('client_invalid', `--client 值必须为 ${SCENE_CLIENTS.join('|')}(当前: ${input.client})`);
18
+ }
19
+ return client;
20
+ }
21
+ /** 发一次 scene 元数据请求,返回解包后的 data。 */
22
+ async function sceneRequest(host, params) {
23
+ const response = await host.request({ method: 'GET', path: SCENE_PATH, query: params, operation: 'scene' });
24
+ // 业务错误校验:E10 常见形态 { code:401|-1, msg },HTTP 仍为 200
25
+ if (response && typeof response === 'object' && !Array.isArray(response)) {
26
+ const bad = (response.code !== undefined && Number(response.code) !== 0) || response.fail === true;
27
+ if (bad) {
28
+ throw dataApiError('scene_business_error', `getSceneGroups 返回业务错误:code=${response.code} msg=${response.msg || response.message || '(无 msg)'}`
29
+ + '(常见:401「暂无权限!」= 该接口在当前环境未开放或账号无权限;-1「token为空或失效」= 登录态失效,请重新登录)', { code: response.code });
30
+ }
31
+ }
32
+ // 兼容 ResultBean 包装({ code, data })与裸数组
33
+ return response && typeof response === 'object' && !Array.isArray(response) && 'data' in response ? response.data : response;
34
+ }
35
+ function asArray(data) {
36
+ return Array.isArray(data) ? data : (data == null ? [] : [data]);
37
+ }
38
+ function slimItem(dataset) {
39
+ const item = {
40
+ id: String(dataset.id ?? ''),
41
+ datasetName: dataset.datasetName ?? '',
42
+ datasetType: dataset.datasetType ?? '',
43
+ sourceId: dataset.sourceId ?? '',
44
+ };
45
+ // 取数通道参数(接口已下发时带出)
46
+ if (dataset.moduleName)
47
+ item.moduleName = dataset.moduleName;
48
+ if (dataset.sourceType)
49
+ item.sourceType = dataset.sourceType;
50
+ if (dataset.sourceGroupId)
51
+ item.sourceGroupId = dataset.sourceGroupId;
52
+ if (dataset.appId)
53
+ item.appId = dataset.appId;
54
+ item.datasetDesc = dataset.datasetDesc ?? '';
55
+ // 前向兼容:后端一旦下发 datasetLogic,自动带出
56
+ if (dataset.datasetLogic !== undefined)
57
+ item.datasetLogic = dataset.datasetLogic;
58
+ return item;
59
+ }
60
+ export async function sceneGroups(input, host) {
61
+ const data = await sceneRequest(host, { datasetClient: sceneClient(input) });
62
+ const arr = asArray(data);
63
+ if (data != null && !Array.isArray(data)) {
64
+ process.stderr.write(`# 注意:接口返回非数组形态(${typeof data}),已按单元素数组处理\n`);
65
+ }
66
+ process.stderr.write(`# 分组 ${arr.length} 个\n`);
67
+ const out = arr.map((group) => ({
68
+ groupId: String(group.groupId ?? ''),
69
+ groupName: group.groupName ?? '',
70
+ itemCount: Number(group.itemCount ?? 0),
71
+ groupDesc: group.groupDesc ?? '',
72
+ }));
73
+ return { data: out, text: JSON.stringify(out, null, 1) };
74
+ }
75
+ export async function sceneItems(input, host) {
76
+ const group = input.group || input.group_id;
77
+ if (!group)
78
+ throw dataValidationError('missing_argument', '缺少必填参数 --group <groupId>');
79
+ const data = await sceneRequest(host, { datasetClient: sceneClient(input), groupId: String(group) });
80
+ const arr = asArray(data);
81
+ const out = arr.map((entry) => {
82
+ const datasets = (entry.datasets || []).map(slimItem);
83
+ return {
84
+ groupId: String(entry.groupId ?? group),
85
+ groupName: entry.groupName ?? '',
86
+ itemCount: Number(entry.itemCount ?? datasets.length),
87
+ datasets,
88
+ };
89
+ });
90
+ const total = out.reduce((sum, entry) => sum + entry.datasets.length, 0);
91
+ if (!out.length) {
92
+ process.stderr.write('# 未找到该分组\n');
93
+ return { data: [], text: '[]' };
94
+ }
95
+ process.stderr.write(`# 条目 ${total} 条\n`);
96
+ return { data: out, text: JSON.stringify(out, null, 1) };
97
+ }
98
+ function keywordsOf(raw) {
99
+ return String(raw ?? '')
100
+ .split(/[,,、;;\s]+/)
101
+ .map((item) => item.trim())
102
+ .filter(Boolean);
103
+ }
104
+ function hitScore(text, keywords) {
105
+ const hay = String(text ?? '').toLowerCase();
106
+ if (!hay)
107
+ return 0;
108
+ let score = 0;
109
+ for (const keyword of keywords)
110
+ if (hay.includes(keyword.toLowerCase()))
111
+ score += 1;
112
+ return score;
113
+ }
114
+ /**
115
+ * 关键词候选召回:**后端 keyword 过滤优先,本地打分兜底**。
116
+ *
117
+ * 后端支持 `keyword`(单数)query 参数:① 分组级命中 → 返回该分组及其全部条目;
118
+ * ② 仅条目级命中 → 只返回命中条目 + 父分组;③ 全不命中 → 空数组。
119
+ * 因此正确姿势是把关键词交给后端,只有未命中/老服务端不支持时才回退本地打分。
120
+ */
121
+ export async function sceneSearch(input, host) {
122
+ const client = sceneClient(input);
123
+ const keywords = keywordsOf(input.keywords ?? input.keyword);
124
+ if (!keywords.length)
125
+ throw dataValidationError('missing_argument', '缺少必填参数 --keywords <词1,词2>(也可用空格 / 、 分隔)');
126
+ const maxGroups = Math.max(1, Number(input.max_groups ?? 3) || 3);
127
+ const maxItems = Math.max(1, Number(input.max_items ?? 12) || 12);
128
+ const scope = input.scope_group_id == null ? '' : String(input.scope_group_id).trim();
129
+ const serverFilter = String(input.server_filter ?? 'auto').trim().toLowerCase();
130
+ if (!['auto', 'on', 'off'].includes(serverFilter)) {
131
+ throw dataValidationError('server_filter_invalid', `--server-filter 值必须为 auto|on|off(当前: ${input.server_filter})`);
132
+ }
133
+ const inScope = (group) => !scope || String(group.groupId) === scope;
134
+ const keywordJoined = keywords.join(',');
135
+ let pool = [];
136
+ let requests = 0;
137
+ let usedServer = false;
138
+ // ① 优先把关键词交给后端过滤
139
+ if (serverFilter !== 'off') {
140
+ try {
141
+ const raw = await sceneRequest(host, { datasetClient: client, keyword: keywordJoined });
142
+ requests += 1;
143
+ const hit = asArray(raw).filter((group) => group && group.groupId !== undefined && inScope(group));
144
+ if (hit.length) {
145
+ pool = hit;
146
+ usedServer = true;
147
+ }
148
+ else if (serverFilter === 'auto') {
149
+ process.stderr.write(`# 后端 keyword 未命中,回退本地打分(keyword=${keywordJoined})\n`);
150
+ }
151
+ }
152
+ catch (error) {
153
+ if (serverFilter === 'on')
154
+ throw error;
155
+ process.stderr.write(`# [warn] 带 keyword 的召回失败,回退本地打分:${error?.message || error}\n`);
156
+ }
157
+ }
158
+ // ② 决定候选分组
159
+ let scored;
160
+ if (usedServer) {
161
+ scored = pool
162
+ .map((group) => ({
163
+ group,
164
+ score: hitScore(group.groupName, keywords) * 3 + hitScore(group.groupDesc, keywords),
165
+ items: Array.isArray(group.datasets) ? group.datasets : null,
166
+ }))
167
+ .sort((a, b) => (b.score - a.score) || ((b.items || []).length - (a.items || []).length))
168
+ .slice(0, maxGroups);
169
+ }
170
+ else if (serverFilter === 'on') {
171
+ scored = [];
172
+ }
173
+ else {
174
+ // 回退本地打分:必须拿到完整分组骨架(后端未命中时 pool 为空,不能复用)
175
+ if (!pool.length) {
176
+ const raw = await sceneRequest(host, { datasetClient: client });
177
+ requests += 1;
178
+ pool = asArray(raw).filter((group) => group && group.groupId !== undefined && inScope(group));
179
+ }
180
+ scored = pool
181
+ .map((group) => ({
182
+ group,
183
+ score: hitScore(group.groupName, keywords) * 3 + hitScore(group.groupDesc, keywords),
184
+ items: null,
185
+ }))
186
+ .filter((candidate) => candidate.score > 0)
187
+ .sort((a, b) => b.score - a.score)
188
+ .slice(0, maxGroups);
189
+ }
190
+ const out = [];
191
+ for (const candidate of scored) {
192
+ const group = candidate.group;
193
+ let items = candidate.items ?? [];
194
+ if (!candidate.items) {
195
+ const one = await sceneRequest(host, { datasetClient: client, groupId: String(group.groupId) });
196
+ requests += 1;
197
+ const arr = asArray(one);
198
+ const hit = arr.find((entry) => entry && String(entry.groupId) === String(group.groupId)) || arr[0] || {};
199
+ items = Array.isArray(hit.datasets) ? hit.datasets : [];
200
+ }
201
+ const ranked = items
202
+ .map((dataset) => ({ dataset, score: hitScore(dataset.datasetName, keywords) * 3 + hitScore(dataset.datasetDesc, keywords) }))
203
+ .sort((a, b) => b.score - a.score);
204
+ // 后端过滤过 ⇒ 条目是「后端给的」,本地只排序不筛(分组级命中时未命中关键词的条目同样可能相关,
205
+ // 按字面分剔除会造成「57 条只剩 20 条」的丢量)。只有本地打分路径才需要 score>0 过滤。
206
+ const ordered = usedServer
207
+ ? ranked
208
+ : (() => {
209
+ const matched = ranked.filter((entry) => entry.score > 0);
210
+ return matched.length ? matched : ranked;
211
+ })();
212
+ const serverPartial = usedServer && Number(group.itemCount ?? items.length) > items.length;
213
+ const keep = usedServer && serverPartial ? ordered : ordered.slice(0, maxItems);
214
+ const entry = {
215
+ groupId: String(group.groupId),
216
+ groupName: group.groupName ?? '',
217
+ groupDesc: group.groupDesc ?? '',
218
+ itemCount: Number(group.itemCount ?? items.length),
219
+ datasets: keep.map((item) => slimItem(item.dataset)),
220
+ };
221
+ // 前向兼容:后端下发 groupLogic 时自动带出
222
+ if (group.groupLogic !== undefined)
223
+ entry.groupLogic = group.groupLogic;
224
+ out.push(entry);
225
+ }
226
+ const itemTotal = out.reduce((sum, group) => sum + group.datasets.length, 0);
227
+ const filterMode = usedServer ? '后端 keyword' : (serverFilter === 'on' ? '后端 keyword(无命中)' : '本地打分');
228
+ if (!out.length) {
229
+ process.stderr.write(`# 未命中任何分组(关键词:${keywords.join(',')};`
230
+ + `${serverFilter === 'on' ? '后端 keyword 无命中,已按 --server-filter on 不回退' : `候选池 ${pool.length} 组`})\n`);
231
+ }
232
+ process.stderr.write(`# 关键词 ${keywords.join(',')} | 候选分组 ${out.length} 个 | 条目 ${itemTotal} 条 | 请求 ${requests} 次 | 过滤方式 ${filterMode}\n`);
233
+ return { data: out, text: JSON.stringify(out, null, 1) };
234
+ }
235
+ export { needArg };
@@ -0,0 +1,279 @@
1
+ import { readFileSync } from 'node:fs';
2
+ import { dataValidationError } from '../errors.js';
3
+ /**
4
+ * 把 JSON 文本里的长整数(≥16 位)预置为字符串。
5
+ *
6
+ * E10 的雪花 ID 是 19 位,超出 `Number.MAX_SAFE_INTEGER`(2^53-1);`JSON.parse` 直接解析会
7
+ * 把末几位归零(`1060565684758507544` → `1060565684758507500`),再原样下发就查不到任何数据、
8
+ * 且后端不报错。e10-data 用同样的「先引号化再解析」策略,这里保持口径一致。
9
+ */
10
+ function quoteLongInts(raw) {
11
+ return raw.replace(/([:[,]\s*)(-?\d{16,})(?=\s*[,}\]])/g, '$1"$2"');
12
+ }
13
+ export function parseJsonSafe(raw) {
14
+ return JSON.parse(quoteLongInts(String(raw).replace(/^\uFEFF+/, '')));
15
+ }
16
+ /** `@file` 读文件,其余按内联 JSON 解析。 */
17
+ export function readJsonArg(value, label) {
18
+ if (value === undefined || value === null || value === true)
19
+ return undefined;
20
+ const raw = String(value);
21
+ const text = raw.startsWith('@') ? readFileSync(raw.slice(1), 'utf-8') : raw;
22
+ try {
23
+ return parseJsonSafe(text);
24
+ }
25
+ catch (error) {
26
+ throw dataValidationError('json_invalid', `${label} 不是合法 JSON:${error.message}`);
27
+ }
28
+ }
29
+ /** `@file` 读文件,其余按逗号分隔的列表。 */
30
+ export function readListArg(value) {
31
+ if (value === undefined || value === null || value === true)
32
+ return '';
33
+ const raw = String(value);
34
+ return raw.startsWith('@') ? readFileSync(raw.slice(1), 'utf-8').trim() : raw;
35
+ }
36
+ export function splitList(value) {
37
+ const raw = readListArg(value);
38
+ if (!raw)
39
+ return [];
40
+ return raw.split(',').map((item) => item.trim()).filter(Boolean);
41
+ }
42
+ export function dynamicParams(session) {
43
+ return {
44
+ eteamsId: session.eteamsId,
45
+ userId: session.userId || '',
46
+ tenantKey: session.tenantKey || '',
47
+ langId: 7,
48
+ formatDate: 'yyyy-MM-dd HH:mm:ss',
49
+ isPublic: false,
50
+ };
51
+ }
52
+ export function baseDto(session, tableId, groupId, pageNo, pageSize, queryType) {
53
+ return {
54
+ tableId: String(tableId),
55
+ groupId,
56
+ pageNo,
57
+ pageSize,
58
+ queryType,
59
+ containDetailTable: false,
60
+ needFormat: true,
61
+ dynamicParams: dynamicParams(session),
62
+ };
63
+ }
64
+ /** appId 只认显式传入(v0.1.14 起不自动解析、不做缺失拦截)。 */
65
+ export function applyAppId(dto, appId) {
66
+ if (typeof appId === 'string' && appId !== '' && appId !== 'auto')
67
+ dto.appId = appId;
68
+ return dto;
69
+ }
70
+ // ---------------------------------------------------------------- 条件树
71
+ function normRelationship(value) {
72
+ return value === '0' || value === 0 || value === false ? '0' : '1';
73
+ }
74
+ function isConditionGroup(node) {
75
+ return !!node && Array.isArray(node.conditionList) && node.conditionList.length > 0;
76
+ }
77
+ function buildConditionNode(node, key, parentKey) {
78
+ if (isConditionGroup(node)) {
79
+ return {
80
+ key,
81
+ relationship: normRelationship(node.relationship),
82
+ isParent: true,
83
+ parentNode: parentKey,
84
+ mainField: node.mainField !== false,
85
+ conditionList: node.conditionList.map((child, index) => buildConditionNode(child, `${key}_${index}`, key)),
86
+ };
87
+ }
88
+ const fieldId = (node && (node.fieldId || node.conditionId)) || '';
89
+ if (!fieldId) {
90
+ throw dataValidationError('where_invalid', '--where 条件缺少字段:叶子须提供 fieldId(或 conditionId),条件组须提供非空 conditionList');
91
+ }
92
+ return {
93
+ key,
94
+ relationship: '1',
95
+ isParent: false,
96
+ parentNode: parentKey,
97
+ objId: node.objId || '',
98
+ conditionId: fieldId,
99
+ fieldName: node.fieldName || fieldId,
100
+ conditionType: node.conditionType || '',
101
+ compareType: node.compareType,
102
+ conditionValue: node.conditionValue ?? '',
103
+ fieldValue: node.fieldValue || '',
104
+ mainField: node.mainField !== false,
105
+ ignoreCaseMark: node.ignoreCaseMark || false,
106
+ };
107
+ }
108
+ /** `--where`:数组 = AND 根(元素可为叶子或内嵌条件组),对象 = 完整条件树。 */
109
+ export function parseWhere(value) {
110
+ if (value === undefined || value === null || value === '' || value === true)
111
+ return null;
112
+ const raw = readJsonArg(value, '--where');
113
+ if (!raw)
114
+ return null;
115
+ const rootKey = `root_${Date.now()}`;
116
+ if (Array.isArray(raw)) {
117
+ const children = [];
118
+ raw.forEach((node, index) => {
119
+ if (node && typeof node === 'object')
120
+ children.push(buildConditionNode(node, `${rootKey}_${index}`, rootKey));
121
+ });
122
+ if (!children.length)
123
+ return null;
124
+ return { key: rootKey, relationship: '1', isParent: true, parentNode: '', mainField: true, conditionList: children };
125
+ }
126
+ if (typeof raw !== 'object')
127
+ throw dataValidationError('where_invalid', '--where 须为条件数组或条件树对象');
128
+ if (!Array.isArray(raw.conditionList) || !raw.conditionList.length)
129
+ return null;
130
+ return buildConditionNode(raw, rootKey, '');
131
+ }
132
+ /** `--stat`:单个对象或数组;聚合键走 aggregator(大写枚举)。 */
133
+ export function parseStat(value) {
134
+ const raw = readJsonArg(value, '--stat');
135
+ const list = Array.isArray(raw) ? raw : [raw];
136
+ return list.map((item) => ({
137
+ fieldId: item.fieldId,
138
+ fieldName: item.fieldId,
139
+ objId: '',
140
+ mainField: true,
141
+ aggregator: item.aggregator || 'SUM',
142
+ ...(item.fieldAlias ? { fieldAlias: item.fieldAlias } : {}),
143
+ }));
144
+ }
145
+ /** `--order`:`field asc, field2 desc`。 */
146
+ export function parseOrder(value) {
147
+ const raw = readListArg(value);
148
+ if (!raw)
149
+ return [];
150
+ return raw.split(',').filter((item) => item.trim()).map((item) => {
151
+ const [field, direction] = item.trim().split(/\s+/);
152
+ return {
153
+ fieldId: field,
154
+ fieldName: field,
155
+ objId: '',
156
+ isAsc: (direction || 'asc').toLowerCase() !== 'desc',
157
+ mainField: true,
158
+ };
159
+ });
160
+ }
161
+ const TIP_FLAG_KEYS = {
162
+ tipTimeout: ['tipTimeout'],
163
+ tipTimelimit: ['tipTimelimit', 'tipTimeLimit'],
164
+ };
165
+ const TIP_MSG_KEYS = {
166
+ tipTimeoutMsg: ['tipTimeoutMsg', 'tipTimeoutMessage'],
167
+ tipTimelimitMsg: ['tipTimelimitMsg', 'tipTimeLimitMsg', 'tipTimelimitMessage', 'tipTimeLimitMessage'],
168
+ };
169
+ const TIP_SCAN_MAX_DEPTH = 4;
170
+ const TIP_SCAN_MAX_ITEMS = 20;
171
+ function tipTruthy(value) {
172
+ if (value === true)
173
+ return true;
174
+ if (typeof value === 'number')
175
+ return value === 1;
176
+ if (typeof value === 'string')
177
+ return ['true', '1', 'yes', 'y'].includes(value.trim().toLowerCase());
178
+ return false;
179
+ }
180
+ /**
181
+ * 递归扫描响应体,取出四个平台范围提示字段。
182
+ *
183
+ * 平台在「查询范围被收窄」或「范围过大不予查询」时只把标记塞在响应内层
184
+ * (`data.tipTimelimit` / `data.data.tipTimeout`),层级随通道不同而不同。不提出来的话,
185
+ * 下游会把局部数据当全区间结论、把 tipTimeout 误读成「0 行」。原样透出、不翻译不改写。
186
+ */
187
+ export function scanTips(node, depth = 0, acc = {}) {
188
+ if (!node || typeof node !== 'object' || depth > TIP_SCAN_MAX_DEPTH)
189
+ return acc;
190
+ if (Array.isArray(node)) {
191
+ for (const item of node.slice(0, TIP_SCAN_MAX_ITEMS))
192
+ scanTips(item, depth + 1, acc);
193
+ return acc;
194
+ }
195
+ for (const [key, aliases] of Object.entries(TIP_FLAG_KEYS)) {
196
+ if (acc[key] !== undefined)
197
+ continue;
198
+ for (const alias of aliases) {
199
+ if (tipTruthy(node[alias])) {
200
+ acc[key] = true;
201
+ break;
202
+ }
203
+ }
204
+ }
205
+ for (const [key, aliases] of Object.entries(TIP_MSG_KEYS)) {
206
+ if (acc[key] !== undefined)
207
+ continue;
208
+ for (const alias of aliases) {
209
+ const value = node[alias];
210
+ if (value !== undefined && value !== null && String(value).trim() !== '') {
211
+ acc[key] = String(value).trim();
212
+ break;
213
+ }
214
+ }
215
+ }
216
+ let seen = 0;
217
+ for (const value of Object.values(node)) {
218
+ if (seen++ >= TIP_SCAN_MAX_ITEMS)
219
+ break;
220
+ if (value && typeof value === 'object')
221
+ scanTips(value, depth + 1, acc);
222
+ }
223
+ return acc;
224
+ }
225
+ /** 只保留四个规范字段(存在才带,顺序固定),供 JSON 输出顶层透出。 */
226
+ export function tipFields(tips) {
227
+ const out = {};
228
+ if (tips.tipTimeout)
229
+ out.tipTimeout = true;
230
+ if (tips.tipTimeoutMsg)
231
+ out.tipTimeoutMsg = tips.tipTimeoutMsg;
232
+ if (tips.tipTimelimit)
233
+ out.tipTimelimit = true;
234
+ if (tips.tipTimelimitMsg)
235
+ out.tipTimelimitMsg = tips.tipTimelimitMsg;
236
+ return out;
237
+ }
238
+ /** 人读模式:命中时打 `[!]` 行(与 module call 的 flags 同形态;文案逐字照抄平台原文)。 */
239
+ export function tipsLines(tips) {
240
+ const lines = [];
241
+ if (tips.tipTimeout) {
242
+ lines.push(`[!] tipTimeout=true|平台提示(数据范围过大,不是 0 行,count 记 null):${tips.tipTimeoutMsg || '(平台未给出文案)'}`);
243
+ }
244
+ if (tips.tipTimelimit) {
245
+ lines.push(`[!] tipTimelimit=true|平台提示(数据已返回,但实际查询范围被收窄):${tips.tipTimelimitMsg || '(平台未给出文案)'}`);
246
+ }
247
+ return lines;
248
+ }
249
+ // ---------------------------------------------------------------- 人读渲染
250
+ export function cell(value) {
251
+ if (value === null || value === undefined)
252
+ return '';
253
+ if (typeof value === 'object') {
254
+ const text = JSON.stringify(value);
255
+ return text.length > 80 ? `${text.slice(0, 80)}…` : text;
256
+ }
257
+ return String(value);
258
+ }
259
+ /** 表格式人读输出(`== title ==` + 制表符分隔列)。 */
260
+ export function renderTable(title, rows, columns) {
261
+ const lines = [];
262
+ if (title)
263
+ lines.push(`== ${title} ==`);
264
+ if (!rows || !rows.length) {
265
+ lines.push('(空)');
266
+ return lines.join('\n');
267
+ }
268
+ if (columns) {
269
+ lines.push(columns.join('\t'));
270
+ for (const row of rows)
271
+ lines.push(columns.map((column) => cell(row?.[column])).join('\t'));
272
+ return lines.join('\n');
273
+ }
274
+ for (const row of rows.slice(0, 100))
275
+ lines.push(JSON.stringify(row));
276
+ if (rows.length > 100)
277
+ lines.push(`... 共 ${rows.length} 行(--json 取全量)`);
278
+ return lines.join('\n');
279
+ }
@@ -194,16 +194,29 @@ async function runEsb(host, objId, dataIds, esbActionIds) {
194
194
  }
195
195
  /** ds/options 运行时解析枚举(面试方式/轮次/结果等):name → optionId */
196
196
  export async function getDsOptions(host, objId, fieldId, groupId) {
197
+ const { map } = await getDsOptionsFull(host, objId, fieldId, groupId);
198
+ return map;
199
+ }
200
+ /**
201
+ * 全量版:map 排除 archive=1 的禁用项(实测 AI面试(小程序) 是唯一 archive:"1",选中会被后端
202
+ * 静默丢弃/落脏值),disabled 单独列出供「已禁用」精确报错。2026-11-09 实证。
203
+ */
204
+ export async function getDsOptionsFull(host, objId, fieldId, groupId) {
197
205
  const response = (await host.request({
198
206
  path: '/api/ebuilder/common/ds/options',
199
207
  query: { fieldName: fieldId, objId, sourceType: 'FORM', groupId },
200
208
  }));
201
209
  const map = {};
210
+ const disabled = [];
202
211
  for (const option of response?.data || []) {
203
- if (option?.name && option?.id)
212
+ if (!option?.name || !option?.id)
213
+ continue;
214
+ if (String(option.archive) === '1')
215
+ disabled.push({ name: String(option.name), id: String(option.id) });
216
+ else
204
217
  map[option.name] = String(option.id);
205
218
  }
206
- return map;
219
+ return { map, disabled };
207
220
  }
208
221
  /**
209
222
  * 人员名称 → userId。
@@ -827,10 +840,13 @@ async function buildInterviewPlan(env, cache, args) {
827
840
  throw ehrValidationError('recruit_field_missing', `面试计划表单缺少字段 ${key}(环境缓存 ds/fields 未解析到,请重建环境缓存后重试)`);
828
841
  }
829
842
  }
830
- const typeMap = await getDsOptions(host, objId, fieldIdOf('interview_type'), cache.appId);
831
- const typeOptionId = typeMap[type];
843
+ const typeFull = await getDsOptionsFull(host, objId, fieldIdOf('interview_type'), cache.appId);
844
+ const typeOptionId = typeFull.map[type];
832
845
  if (!typeOptionId) {
833
- throw ehrValidationError('enum_invalid', `面试方式「${type}」不在枚举中(${Object.keys(typeMap).join(' / ')})`);
846
+ if (typeFull.disabled.some((d) => d.name === type)) {
847
+ throw ehrValidationError('enum_disabled', `面试方式「${type}」已禁用(该枚举项 archive=1),请改用其它面试方式`);
848
+ }
849
+ throw ehrValidationError('enum_invalid', `面试方式「${type}」不在枚举中(${Object.keys(typeFull.map).join(' / ')})`);
834
850
  }
835
851
  const sessionMap = await getDsOptions(host, objId, fieldIdOf('interview_session'), cache.appId);
836
852
  const sessionOptionId = sessionMap[session];
@@ -985,6 +1001,7 @@ const interviewArrangePrepare = {
985
1001
  : {}),
986
1002
  notify: notify ? '将触发「新建日程」面试通知动作流(外部通知)' : '面试通知默认不触发',
987
1003
  },
1004
+ deprecated: '本入口副作用不含页面按钮动作流(无新建EB日程/创建视频会议/AI面试提醒)且不并入页面默认值,建议改用 recruit-stage.interview.arrange.*(能力相同、副作用完整)',
988
1005
  willSubmit: { formId: plan.formId, objId: plan.objId, dataDetails: plan.dataDetails },
989
1006
  continuation: token,
990
1007
  expiresInSeconds: CONTINUATION_TTL_SECONDS,