weaver-work-cli 0.1.69 → 0.1.71

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 (232) hide show
  1. package/dist/chunks/{archive-VUTREF3P.js → archive-5P33NAUN.js} +22 -5
  2. package/dist/chunks/{archive-oa-VXXO4RTB.js → archive-oa-YTY5D7DG.js} +17 -5
  3. package/dist/chunks/{asset-45U6TY7I.js → asset-3Q5MFQBX.js} +22 -5
  4. package/dist/chunks/{asset-idle-YCRBMTIT.js → asset-idle-PQPNYIS7.js} +15 -5
  5. package/dist/chunks/{attachment-content-7BEDNQ3O.js → attachment-content-7CN7JB6B.js} +3 -3
  6. package/dist/chunks/{blog-5AML4WMG.js → blog-MFHHK6ZR.js} +25 -5
  7. package/dist/chunks/{caizhilian-3P7BUNHT.js → caizhilian-OZ435AYW.js} +22 -8
  8. package/dist/chunks/{calendar-2HUXM3CZ.js → calendar-TNJXS5UC.js} +15 -5
  9. package/dist/chunks/{chunk-H2NRTGZR.js → chunk-2DNCKZRX.js} +3 -3
  10. package/dist/chunks/{chunk-DVFA3ODS.js → chunk-35A56FJ7.js} +12 -0
  11. package/dist/chunks/{chunk-HG6INLH6.js → chunk-6MMSLE6K.js} +23 -6
  12. package/dist/chunks/{chunk-UVWW5ABZ.js → chunk-B4NINGP2.js} +3 -3
  13. package/dist/chunks/{chunk-LRKKKO5A.js → chunk-DRJYPXKC.js} +3 -4
  14. package/dist/chunks/{chunk-3TZURS7M.js → chunk-EJLP63UO.js} +1 -1
  15. package/dist/chunks/{chunk-FMAZ42HS.js → chunk-FRMDHZSN.js} +11 -11
  16. package/dist/chunks/{chunk-MLJK4KLE.js → chunk-G7ZM2VOX.js} +34 -34
  17. package/dist/chunks/{chunk-LSVA7QA6.js → chunk-GB2MCJPG.js} +3 -1
  18. package/dist/chunks/{chunk-3CBURKSY.js → chunk-ICNUOWLL.js} +4 -4
  19. package/dist/chunks/{chunk-GTAFCAVP.js → chunk-IZCQU5D5.js} +1 -1
  20. package/dist/chunks/{chunk-BEYEXCWU.js → chunk-LU2SPJYY.js} +2 -2
  21. package/dist/chunks/{chunk-E7VWE2XI.js → chunk-MD5RXRI3.js} +3 -3
  22. package/dist/chunks/{chunk-VZUH3LKI.js → chunk-MZVQKQP5.js} +167 -157
  23. package/dist/chunks/{chunk-67AN5YJT.js → chunk-OFCF23FY.js} +9 -9
  24. package/dist/chunks/{chunk-ERAE4GHX.js → chunk-OPTJ6IF7.js} +1 -1
  25. package/dist/chunks/{chunk-727VKJQK.js → chunk-OZ7CJC7W.js} +2 -2
  26. package/dist/chunks/{chunk-T24EBWAZ.js → chunk-P3AFNAJ6.js} +48 -21
  27. package/dist/chunks/{chunk-4XYRTXRR.js → chunk-Q3EXRNB4.js} +1 -1
  28. package/dist/chunks/{chunk-QYDSTYGG.js → chunk-SKWKCLJX.js} +3 -3
  29. package/dist/chunks/{chunk-DSBV4GRK.js → chunk-SSS75WXW.js} +3 -3
  30. package/dist/chunks/{chunk-I5XB4MZT.js → chunk-SUWR5QEG.js} +94 -65
  31. package/dist/chunks/{chunk-YR3K53BU.js → chunk-VJWVB55R.js} +2 -2
  32. package/dist/chunks/{chunk-JAIZY37Z.js → chunk-VMVMEIL3.js} +4 -4
  33. package/dist/chunks/chunk-WM33BSIL.js +136 -0
  34. package/dist/chunks/{chunk-6DH73Q5H.js → chunk-X2C5CGGM.js} +52 -51
  35. package/dist/chunks/{chunk-ELF5TPSG.js → chunk-XLSJC6JZ.js} +6 -6
  36. package/dist/chunks/{chunk-U3OO3IZF.js → chunk-YN5SD4TX.js} +20 -7
  37. package/dist/chunks/{conflict-VKCRXHUV.js → conflict-Y4PXZ2YQ.js} +2 -2
  38. package/dist/chunks/{contract-3PMHUASH.js → contract-C3BGUMBM.js} +48 -5
  39. package/dist/chunks/{cowork-FZBTTBYX.js → cowork-2AWG4QLA.js} +37 -8
  40. package/dist/chunks/{create-flow-WYPLBLRK.js → create-flow-LOUOK46Z.js} +6 -6
  41. package/dist/chunks/{data-2YZ6A6TL.js → data-BSFYMXVO.js} +99 -184
  42. package/dist/chunks/{ebuilder-form-AWPTMZBZ.js → ebuilder-form-LAAMTD2Y.js} +17 -7
  43. package/dist/chunks/{ehr-MNPR4TE5.js → ehr-36KEX5SH.js} +62 -13
  44. package/dist/chunks/{entry-mode-BCJ7RPFC.js → entry-mode-6N2IGCS4.js} +3 -3
  45. package/dist/chunks/{env-SCVCHBN2.js → env-QYLS3EB3.js} +2 -2
  46. package/dist/chunks/{esb-GSB5QCEX.js → esb-PTYS3E67.js} +17 -7
  47. package/dist/chunks/{factory-CBXYOEBF.js → factory-LPFPKZ4T.js} +1 -1
  48. package/dist/chunks/{fna-XBSNUS2V.js → fna-JNHCLRDE.js} +15 -5
  49. package/dist/chunks/{group-chat-RFL4U7RF.js → group-chat-QP2WX4QJ.js} +3 -3
  50. package/dist/chunks/{host-2UMNXX5H.js → host-57LSRSE7.js} +4 -4
  51. package/dist/chunks/{host-NVDG3NC6.js → host-7BVR7CQ3.js} +4 -4
  52. package/dist/chunks/{host-SYPCA63D.js → host-C2BLBIID.js} +4 -4
  53. package/dist/chunks/{host-XVWBOSEN.js → host-K2ZKNXME.js} +4 -4
  54. package/dist/chunks/{host-R7BP3CTI.js → host-NS36QFLR.js} +6 -4
  55. package/dist/chunks/{host-BD44ASOD.js → host-QXFKQXNX.js} +4 -4
  56. package/dist/chunks/{hrm-FZUDJAND.js → hrm-FSGO4NSH.js} +15 -6
  57. package/dist/chunks/{im-F5NENPD7.js → im-2BFGS2XO.js} +16 -6
  58. package/dist/chunks/{invoice-DS6FLU55.js → invoice-JKLTTHSZ.js} +27 -6
  59. package/dist/chunks/{jiuchuanhui-PY2WEBUH.js → jiuchuanhui-PTABJE7V.js} +1294 -1134
  60. package/dist/chunks/{lazy-dispatch-F6O2EPGR.js → lazy-dispatch-YN2ZP3CS.js} +6 -6
  61. package/dist/chunks/{mail-ZEOSANEJ.js → mail-YNO7ZZUK.js} +116 -97
  62. package/dist/chunks/{meeting-N2AGGLVI.js → meeting-NIDHDBCB.js} +29 -16
  63. package/dist/chunks/{minute-doc-C62EZOJH.js → minute-doc-G3QAT7DE.js} +4 -4
  64. package/dist/chunks/{okr-OZUMTMCL.js → okr-QC52G6AJ.js} +15 -5
  65. package/dist/chunks/{operations-LQY3FTPH.js → operations-2WHIF5WV.js} +1 -1
  66. package/dist/chunks/{operations-UTUWFJTX.js → operations-MQV32ITT.js} +5 -5
  67. package/dist/chunks/{performance-GBKM5G2Y.js → performance-3MQ3AHDQ.js} +97 -11
  68. package/dist/chunks/{plan-C2NENH42.js → plan-ISINIEPY.js} +15 -5
  69. package/dist/chunks/{project-FAJ2P3UR.js → project-IJ6DVKT7.js} +18 -5
  70. package/dist/chunks/{reception-NH6MJFPR.js → reception-3H5LUG2I.js} +17 -7
  71. package/dist/chunks/{recruit-stage-DPEFHLSE.js → recruit-stage-MIOJXP6W.js} +412 -85
  72. package/dist/chunks/{registry-7US3QQXV.js → registry-3GQRYP2R.js} +12 -12
  73. package/dist/chunks/{registry-Y2HWS6JS.js → registry-3S7AVMXR.js} +4 -4
  74. package/dist/chunks/{registry-FTPUUHWC.js → registry-NHHKOEU3.js} +5 -5
  75. package/dist/chunks/{room-recommend-LMNF76YS.js → room-recommend-IOKBJVYP.js} +4 -4
  76. package/dist/chunks/{schedule-4QE2THAP.js → schedule-IB6EUARH.js} +4 -4
  77. package/dist/chunks/{smart-extract-GTYKF5TJ.js → smart-extract-N2TK3CEF.js} +19 -6
  78. package/dist/chunks/{workflow-KXYTQZ2H.js → workflow-RINBAL2M.js} +22 -8
  79. package/dist/cmd/auth/index.js +23 -0
  80. package/dist/cmd/e10/index.js +2 -1
  81. package/dist/cmd/index.js +2 -0
  82. package/dist/core/manifest-view.js +207 -0
  83. package/dist/core/output.js +38 -8
  84. package/dist/index.js +35 -35
  85. package/dist/internal/e10/auth/crypto.js +18 -8
  86. package/dist/internal/e10/auth/error-log.js +1 -2
  87. package/dist/internal/e10/auth/messages.js +2 -3
  88. package/dist/internal/e10/auth/xiaoe.js +1 -1
  89. package/dist/internal/e10/tls-policy.js +61 -13
  90. package/dist/shortcuts/archive/index.js +11 -2
  91. package/dist/shortcuts/archive/operations/download.js +1 -0
  92. package/dist/shortcuts/archive/operations/flow-url.js +3 -0
  93. package/dist/shortcuts/archive/operations/prelib.js +2 -0
  94. package/dist/shortcuts/archive/operations/upload.js +1 -0
  95. package/dist/shortcuts/archive-oa/index.js +11 -2
  96. package/dist/shortcuts/archive-oa/operations/borrow-car.js +2 -0
  97. package/dist/shortcuts/asset/index.js +11 -2
  98. package/dist/shortcuts/asset/manifest.js +7 -0
  99. package/dist/shortcuts/asset-idle/index.js +11 -2
  100. package/dist/shortcuts/blog/index.js +11 -2
  101. package/dist/shortcuts/blog/manifest.js +10 -0
  102. package/dist/shortcuts/caizhilian/host.js +20 -4
  103. package/dist/shortcuts/caizhilian/index.js +12 -2
  104. package/dist/shortcuts/caizhilian/manifest.js +4 -25
  105. package/dist/shortcuts/caizhilian/operations/handlers/search.js +34 -0
  106. package/dist/shortcuts/caizhilian/operations/registry.js +25 -1
  107. package/dist/shortcuts/calendar/index.js +11 -2
  108. package/dist/shortcuts/contract/index.js +11 -2
  109. package/dist/shortcuts/contract/manifest.js +32 -0
  110. package/dist/shortcuts/contract/operations/write.js +3 -0
  111. package/dist/shortcuts/cowork/index.js +21 -5
  112. package/dist/shortcuts/cowork/manifest.js +3 -0
  113. package/dist/shortcuts/cowork/operations/discuss-write.js +2 -0
  114. package/dist/shortcuts/cowork/operations/item-write.js +3 -0
  115. package/dist/shortcuts/cowork/operations/member-write.js +2 -0
  116. package/dist/shortcuts/cowork/operations/permission-write.js +2 -0
  117. package/dist/shortcuts/cowork/operations/review-write.js +1 -0
  118. package/dist/shortcuts/data/errors.js +16 -29
  119. package/dist/shortcuts/data/host.js +16 -7
  120. package/dist/shortcuts/data/index.js +12 -41
  121. package/dist/shortcuts/data/manifest.js +5 -44
  122. package/dist/shortcuts/data/operations/attend.js +2 -2
  123. package/dist/shortcuts/data/operations/conf.js +0 -88
  124. package/dist/shortcuts/data/operations/ds.js +4 -4
  125. package/dist/shortcuts/data/operations/index.js +1 -5
  126. package/dist/shortcuts/data/operations/module.js +40 -14
  127. package/dist/shortcuts/data/operations/query.js +2 -2
  128. package/dist/shortcuts/ebuilder-form/index.js +11 -2
  129. package/dist/shortcuts/ebuilder-form/manifest.js +12 -0
  130. package/dist/shortcuts/ehr/index.js +11 -2
  131. package/dist/shortcuts/ehr/operations/attend-write.js +51 -8
  132. package/dist/shortcuts/esb/index.js +11 -2
  133. package/dist/shortcuts/esb/manifest.js +2 -0
  134. package/dist/shortcuts/fna/index.js +11 -2
  135. package/dist/shortcuts/hrm/index.js +11 -1
  136. package/dist/shortcuts/im/index.js +11 -2
  137. package/dist/shortcuts/invoice/index.js +11 -2
  138. package/dist/shortcuts/invoice/manifest.js +8 -0
  139. package/dist/shortcuts/jiuchuanhui/cache.js +49 -35
  140. package/dist/shortcuts/jiuchuanhui/host.js +37 -5
  141. package/dist/shortcuts/jiuchuanhui/index.js +57 -7
  142. package/dist/shortcuts/jiuchuanhui/manifest.js +38 -1
  143. package/dist/shortcuts/jiuchuanhui/operations/customer-quick.js +110 -0
  144. package/dist/shortcuts/jiuchuanhui/operations/datajson.js +11 -56
  145. package/dist/shortcuts/jiuchuanhui/operations/esb.js +9 -16
  146. package/dist/shortcuts/jiuchuanhui/operations/generic.js +8 -30
  147. package/dist/shortcuts/jiuchuanhui/operations/registry.js +8 -2
  148. package/dist/shortcuts/jiuchuanhui/operations/shared.js +0 -10
  149. package/dist/shortcuts/mail/errors.js +14 -0
  150. package/dist/shortcuts/mail/index.js +23 -6
  151. package/dist/shortcuts/mail/manifest.js +11 -4
  152. package/dist/shortcuts/mail/operations/mail-blacklist.js +6 -6
  153. package/dist/shortcuts/mail/operations/mail-contacts.js +10 -10
  154. package/dist/shortcuts/mail/operations/mail-manage.js +15 -14
  155. package/dist/shortcuts/mail/operations/mail-read.js +7 -25
  156. package/dist/shortcuts/mail/operations/mail-send.js +12 -12
  157. package/dist/shortcuts/mail/operations/mail-sign.js +10 -10
  158. package/dist/shortcuts/mail/operations/mail-template.js +10 -10
  159. package/dist/shortcuts/meeting/index.js +11 -2
  160. package/dist/shortcuts/meeting/operations/invitation-publish.js +1 -0
  161. package/dist/shortcuts/okr/index.js +11 -2
  162. package/dist/shortcuts/performance/index.js +62 -3
  163. package/dist/shortcuts/performance/operations/flow-detail.js +5 -4
  164. package/dist/shortcuts/performance/scheme-validate.js +7 -0
  165. package/dist/shortcuts/performance/shared.js +40 -2
  166. package/dist/shortcuts/plan/index.js +11 -2
  167. package/dist/shortcuts/project/index.js +11 -2
  168. package/dist/shortcuts/project/operations/write.js +3 -0
  169. package/dist/shortcuts/reception/index.js +11 -2
  170. package/dist/shortcuts/reception/manifest.js +2 -2
  171. package/dist/shortcuts/reception/operations/ask.js +3 -0
  172. package/dist/shortcuts/recruit-stage/index.js +22 -3
  173. package/dist/shortcuts/recruit-stage/manifest.js +2 -0
  174. package/dist/shortcuts/recruit-stage/operations/jd-create.js +33 -16
  175. package/dist/shortcuts/recruit-stage/operations/profile.js +186 -0
  176. package/dist/shortcuts/recruit-stage/operations/registry.js +2 -0
  177. package/dist/shortcuts/recruit-stage/operations/resume-import.js +76 -47
  178. package/dist/shortcuts/recruit-stage/operations/search.js +151 -16
  179. package/dist/shortcuts/recruit-stage/operations/tag.js +17 -3
  180. package/dist/shortcuts/recruit-stage/shared.js +11 -1
  181. package/dist/shortcuts/smart-extract/index.js +11 -2
  182. package/dist/shortcuts/smart-extract/manifest.js +1 -0
  183. package/dist/shortcuts/smart-extract/operations/save.js +2 -0
  184. package/dist/shortcuts/workflow/index.js +21 -1
  185. package/dist/shortcuts/workflow/operations/aiDeepRead/collect.js +5 -2
  186. package/dist/shortcuts/workflow/operations/read.js +2 -2
  187. package/dist/shortcuts/workflow/operations/write.js +1 -1
  188. package/docs/caizhilian.md +1 -1
  189. package/docs/contract.md +1 -0
  190. package/docs/data.md +22 -22
  191. package/docs/e10-auth.md +41 -33
  192. package/docs/ehr.md +2 -0
  193. package/docs/jiuchuanhui.md +17 -5
  194. package/docs/reception.md +4 -3
  195. package/package.json +1 -1
  196. package/scripts/pysite/__pycache__/sitecustomize.cpython-312.pyc +0 -0
  197. package/scripts/pysite/__pycache__/sitecustomize.cpython-313.pyc +0 -0
  198. package/scripts/pysite/sitecustomize.py +41 -0
  199. package/skill-template/domains/data.md +4 -4
  200. package/skills/weaver-e10-caizhilian/SKILL.md +1 -1
  201. package/skills/weaver-e10-caizhilian/references/org-browser.md +1 -0
  202. package/skills/weaver-e10-cowork/SKILL.md +3 -1
  203. package/skills/weaver-e10-data/SKILL.md +12 -16
  204. package/skills/weaver-e10-data/references/config-center.md +6 -7
  205. package/skills/weaver-e10-data/references/datasource.md +1 -1
  206. package/skills/weaver-e10-data/references/scene-and-misc.md +2 -2
  207. package/skills/weaver-e10-jiuchuanhui/SKILL.md +51 -90
  208. package/skills/weaver-e10-jiuchuanhui/references/cache.md +17 -13
  209. package/skills/weaver-e10-jiuchuanhui/references/clue.md +2 -2
  210. package/skills/weaver-e10-jiuchuanhui/references/customer.md +49 -11
  211. package/skills/weaver-e10-jiuchuanhui/references/discovery-config.md +3 -3
  212. package/skills/weaver-e10-jiuchuanhui/references/jiuchuanhui-entry.md +9 -7
  213. package/skills/weaver-e10-jiuchuanhui/references/sale.md +2 -2
  214. package/skills/weaver-e10-jucailin/references/attend-write.md +1 -1
  215. package/skills/weaver-e10-mail/SKILL.md +4 -1
  216. package/skills/weaver-e10-mail/references/mail-read.md +4 -2
  217. package/skills/weaver-e10-mail/references/safety-boundaries.md +1 -0
  218. package/skills/weaver-e10-okr/references/source-manifest.json +3 -3
  219. package/skills/weaver-e10-performance/SKILL.md +9 -7
  220. package/skills/weaver-e10-performance/agents/openai.yaml +4 -2
  221. package/skills/weaver-e10-performance/references/flow-assess.md +19 -6
  222. package/skills/weaver-e10-recruit-stage/SKILL.md +125 -20
  223. package/skills/weaver-e10-recruit-stage/lib/recruit-write-helper.mjs +359 -0
  224. package/skills/weaver-e10-recruit-stage/references/env-fixed-values.md +87 -0
  225. package/skills/weaver-e10-recruit-stage/references/recruit-jd-create.md +9 -2
  226. package/skills/weaver-e10-recruit-stage/references/recruit-tag-recommend.md +1 -0
  227. package/skills/weaver-e10-recruit-stage/templates/match-report.html +177 -0
  228. package/skills/weaver-e10-shared/SKILL.md +22 -1
  229. package/skills/weaver-e10-shared/references/e10-auth-and-session.md +2 -2
  230. package/skills/weaver-e10-workflow/SKILL.md +1 -1
  231. package/skills/weaver-e10-workflow/references/workflow-deep-read.md +8 -3
  232. package/skills/weaver-e10-yimiaoban/references/source-manifest.json +3 -3
@@ -0,0 +1,110 @@
1
+ import { readFile } from 'node:fs/promises';
2
+ import { jiuchuanhuiCacheFile } from '../cache.js';
3
+ import { jiuchuanhuiValidationError } from '../errors.js';
4
+ import { asNonEmptyString } from './shared.js';
5
+ export const CUSTOMER_SEARCH_SCOPES = {
6
+ mine: { mine: '', all: '-1', customerSea: '-1' },
7
+ all: { mine: '-1', all: '', customerSea: '-1' },
8
+ 'open-sea': { mine: '-1', all: '-1', customerSea: '' },
9
+ };
10
+ const STATUS_PAGE_SIZE = 100;
11
+ const STATUS_MAX_PAGES = 5;
12
+ function addSuccessStatusIds(ids, rows) {
13
+ for (const row of rows) {
14
+ const status = row?.mainTable ?? row;
15
+ const fields = status;
16
+ const label = String(fields?.state_name ?? '').trim() || String(fields?.name ?? '').trim();
17
+ if (label !== '成功客户' && label !== '成功')
18
+ continue;
19
+ const id = String(fields?.id ?? '').trim();
20
+ if (/^[1-9]\d*$/u.test(id))
21
+ ids.add(id);
22
+ }
23
+ }
24
+ async function cachedCustomerStatuses(context) {
25
+ const { tenantKey, userId } = await context.host.getSession();
26
+ if (!tenantKey || !userId)
27
+ return [];
28
+ try {
29
+ const raw = await readFile(jiuchuanhuiCacheFile(tenantKey, userId), 'utf8');
30
+ const rows = JSON.parse(raw.replace(/^\uFEFF/u, ''))?.ebuilder?.customer_status;
31
+ return Array.isArray(rows) && rows.length < STATUS_PAGE_SIZE * STATUS_MAX_PAGES ? rows : [];
32
+ }
33
+ catch {
34
+ return [];
35
+ }
36
+ }
37
+ function uniqueSuccessStatusId(ids) {
38
+ if (ids.size > 1) {
39
+ throw jiuchuanhuiValidationError('customer_success_status_ambiguous', '找到多个成功客户状态,请确认要使用的客户状态', {
40
+ statusIds: [...ids],
41
+ });
42
+ }
43
+ return ids.values().next().value;
44
+ }
45
+ async function resolveSuccessStatus(search, context) {
46
+ const ids = new Set();
47
+ addSuccessStatusIds(ids, await cachedCustomerStatuses(context));
48
+ const cachedId = uniqueSuccessStatusId(ids);
49
+ if (cachedId)
50
+ return cachedId;
51
+ for (let pageNo = 1; pageNo <= STATUS_MAX_PAGES; pageNo += 1) {
52
+ const { response } = await search.execute({ pageNo, pageSize: STATUS_PAGE_SIZE }, context);
53
+ // This lookup supplies the filter for the next request. The final customer response is passed through.
54
+ const rows = response.value?.datajson?.datas;
55
+ if (response.httpStatus < 200 || response.httpStatus >= 300 || !Array.isArray(rows)) {
56
+ throw jiuchuanhuiValidationError('customer_success_status_lookup_failed', '无法读取客户状态字典,请确认需要使用的客户状态', { httpStatus: response.httpStatus });
57
+ }
58
+ addSuccessStatusIds(ids, rows);
59
+ const statusId = uniqueSuccessStatusId(ids);
60
+ if (rows.length < STATUS_PAGE_SIZE) {
61
+ if (statusId)
62
+ return statusId;
63
+ throw jiuchuanhuiValidationError('customer_success_status_not_found', '当前租户未找到“成功”或“成功客户”状态,请确认客户状态名称');
64
+ }
65
+ }
66
+ throw jiuchuanhuiValidationError('customer_success_status_lookup_incomplete', '客户状态字典未查完,请确认需要使用的客户状态');
67
+ }
68
+ export class CustomerQuickSearchOperation {
69
+ name;
70
+ customerSearch;
71
+ defaultScope;
72
+ customerStatusSearch;
73
+ constructor(name, customerSearch, defaultScope, customerStatusSearch) {
74
+ this.name = name;
75
+ this.customerSearch = customerSearch;
76
+ this.defaultScope = defaultScope;
77
+ this.customerStatusSearch = customerStatusSearch;
78
+ }
79
+ async execute(input, context) {
80
+ const { customer_name, pageNo, pageSize, count, scope = this.defaultScope, ...unsupported } = input;
81
+ const unexpected = Object.keys(unsupported);
82
+ if (!this.customerStatusSearch && Object.hasOwn(input, 'scope'))
83
+ unexpected.push('scope');
84
+ if (unexpected.length) {
85
+ throw jiuchuanhuiValidationError('field_unsupported', `快捷查询不支持以下参数:${unexpected.join('、')}`, { fields: unexpected });
86
+ }
87
+ if (typeof scope !== 'string' || !Object.hasOwn(CUSTOMER_SEARCH_SCOPES, scope)) {
88
+ throw jiuchuanhuiValidationError('input_invalid', 'scope 必须是 mine、all 或 open-sea');
89
+ }
90
+ if (pageNo !== undefined && (!Number.isSafeInteger(pageNo) || pageNo < 1)) {
91
+ throw jiuchuanhuiValidationError('input_invalid', 'pageNo 必须是正整数');
92
+ }
93
+ if (pageSize !== undefined && (!Number.isSafeInteger(pageSize) || pageSize < 1 || pageSize > 200)) {
94
+ throw jiuchuanhuiValidationError('input_invalid', 'pageSize 必须是 1 到 200 之间的整数');
95
+ }
96
+ if (count !== undefined && typeof count !== 'boolean') {
97
+ throw jiuchuanhuiValidationError('input_invalid', 'count 必须是布尔值');
98
+ }
99
+ const customerName = customer_name === undefined ? undefined : asNonEmptyString(customer_name, 'customer_name');
100
+ const status = this.customerStatusSearch ? await resolveSuccessStatus(this.customerStatusSearch, context) : undefined;
101
+ return this.customerSearch.execute({
102
+ ...CUSTOMER_SEARCH_SCOPES[scope],
103
+ customer_name: customerName,
104
+ pageNo,
105
+ pageSize,
106
+ count,
107
+ status,
108
+ }, context);
109
+ }
110
+ }
@@ -1,6 +1,6 @@
1
1
  import { CONTINUATION_TTL_SECONDS } from '../../../core/continuation-ttl.js';
2
2
  import { jiuchuanhuiConfirmationError, jiuchuanhuiPartialError, jiuchuanhuiValidationError, isJiuchuanhuiNetworkError, } from '../errors.js';
3
- import { asObject, asPositiveString, byIdBody, datasBody, listBody, listRecords, pagingFrom, resultDataIds, sessionMatches, stripForbiddenKeys, workflow, } from './shared.js';
3
+ import { asObject, asPositiveString, byIdBody, datasBody, listBody, pagingFrom, resultDataIds, sessionMatches, stripForbiddenKeys, workflow, } from './shared.js';
4
4
  /**
5
5
  * datajson 创建/更新写操作(saveFormData / updateFormData)。
6
6
  * prepare -> apply 确认链;apply 校验 confirm + continuation + 会话一致后提交。
@@ -106,20 +106,12 @@ export class DatajsonDetailOperation {
106
106
  async execute(input, { host }) {
107
107
  const id = asPositiveString(String(input.id ?? input.dataId), 'id');
108
108
  const session = await host.getSession();
109
- const result = await host.request({
109
+ const response = await host.query({
110
110
  path: this.path,
111
111
  body: byIdBody(id, session.userId),
112
112
  operation: this.name,
113
113
  });
114
- return {
115
- status: 'COMPLETE',
116
- data: {
117
- id,
118
- ...(result && typeof result === 'object' ? { raw: result } : {}),
119
- mainTable: extractMainTable(result),
120
- detail: result,
121
- },
122
- };
114
+ return { response };
123
115
  }
124
116
  }
125
117
  /**
@@ -140,26 +132,14 @@ export class DatajsonSearchOperation {
140
132
  const session = await host.getSession();
141
133
  const query = buildSearchQuery(input, pageNo, pageSize);
142
134
  const main = listBody(session.userId, pageNo, pageSize, {});
143
- const listPromise = host.request({ path: this.path, query, body: main, operation: this.name });
144
- const countPromise = input.count === true && this.countPath
145
- ? host.request({ path: this.countPath, query: withoutPaging(query), body: listBody(session.userId, 1, 1, {}), operation: `${this.name}.count` })
146
- : undefined;
147
- const [listResult, countResult] = countPromise
148
- ? await Promise.all([listPromise, countPromise])
149
- : [await listPromise, undefined];
150
- const records = listRecords(listResult);
151
- const total = extractCount(countResult);
152
- return {
153
- status: 'COMPLETE',
154
- data: {
155
- items: records,
156
- total,
157
- pageNo,
158
- pageSize,
159
- hasMore: total === undefined ? records.length >= pageSize : pageNo * pageSize < total,
160
- query,
161
- },
162
- };
135
+ const listPromise = host.query({ path: this.path, query, body: main, operation: this.name });
136
+ if (input.count !== true || !this.countPath)
137
+ return { response: await listPromise };
138
+ const [response, countResponse] = await Promise.all([
139
+ listPromise,
140
+ host.query({ path: this.countPath, query: withoutPaging(query), body: listBody(session.userId, 1, 1, {}), operation: `${this.name}.count` }),
141
+ ]);
142
+ return { response, countResponse };
163
143
  }
164
144
  }
165
145
  function buildSearchQuery(input, pageNo, pageSize) {
@@ -188,28 +168,3 @@ function withoutPaging(query) {
188
168
  delete next.pageSize;
189
169
  return next;
190
170
  }
191
- function extractCount(value) {
192
- if (!value || typeof value !== 'object')
193
- return undefined;
194
- const root = value;
195
- const datas = root.datajson?.datas;
196
- const raw = Array.isArray(datas) ? datas[0] : datas;
197
- const num = Number(raw ?? root.total ?? root.count);
198
- return Number.isFinite(num) ? num : undefined;
199
- }
200
- function extractMainTable(value) {
201
- if (!value || typeof value !== 'object')
202
- return undefined;
203
- const root = value;
204
- const mt = root.datajson?.mainTable;
205
- if (mt && typeof mt === 'object' && !Array.isArray(mt))
206
- return mt;
207
- const datas = root.datajson?.datas;
208
- if (Array.isArray(datas) && datas[0] && typeof datas[0] === 'object') {
209
- const first = datas[0];
210
- if (first.mainTable && typeof first.mainTable === 'object')
211
- return first.mainTable;
212
- return first;
213
- }
214
- return undefined;
215
- }
@@ -1,5 +1,6 @@
1
1
  import { CONTINUATION_TTL_SECONDS } from '../../../core/continuation-ttl.js';
2
2
  import { jiuchuanhuiConfirmationError, jiuchuanhuiPartialError, jiuchuanhuiValidationError, isJiuchuanhuiNetworkError, } from '../errors.js';
3
+ import { getJiuchuanhuiOperationContract } from '../manifest.js';
3
4
  import { asObject, asNonEmptyString, esbBody, esbOutcome, sessionMatches, workflow } from './shared.js';
4
5
  /**
5
6
  * ESB 写操作模板。所有 ESB 动作流写操作(新建/修改/转移/释放/领取/状态变更/赢单/输单/无效/暂停/重启/完成计划)
@@ -20,6 +21,12 @@ export class EsbWritePrepareOperation {
20
21
  }
21
22
  async execute(input, { host, continuation }) {
22
23
  const mainTable = normalizeMainTable(input.mainTable, this.mainTableKeys);
24
+ const properties = getJiuchuanhuiOperationContract(this.name)?.inputSchema.properties;
25
+ const missing = properties?.mainTable?.required?.filter((key) => !Object.hasOwn(mainTable, key)
26
+ || mainTable[key] === undefined || mainTable[key] === null || mainTable[key] === '');
27
+ if (missing?.length) {
28
+ throw jiuchuanhuiValidationError('field_required', `缺少必填参数:${missing.join('、')}`, { fields: missing });
29
+ }
23
30
  const preview = summaryOf(mainTable);
24
31
  const session = await host.getSession();
25
32
  const continuationToken = await continuation.issue({
@@ -117,26 +124,12 @@ export class EsbReadOperation {
117
124
  async execute(input, { host }) {
118
125
  const mainTable = normalizeMainTable(input.mainTable ?? input, this.mainTableKeys);
119
126
  const session = await host.getSession();
120
- const result = await host.request({
127
+ const response = await host.query({
121
128
  path: '/api/esb/server/event/triggerActionFlow',
122
129
  body: esbBody(mainTable, this.uniqueIndent, session.userId),
123
130
  operation: this.name,
124
131
  });
125
- const { resultCode, resultMsg } = esbOutcome(result);
126
- if (resultCode !== 200) {
127
- throw jiuchuanhuiValidationError('esb_read_failed', `动作流查询失败(resultCode=${resultCode}):${resultMsg}`);
128
- }
129
- const customData = result?.actionData?.responseData?.customData;
130
- return {
131
- status: 'COMPLETE',
132
- data: {
133
- resultCode,
134
- resultMsg,
135
- ...(customData && typeof customData === 'object' ? { customData } : {}),
136
- mainTable: customData?.mainTable,
137
- raw: result,
138
- },
139
- };
132
+ return { response };
140
133
  }
141
134
  }
142
135
  function normalizeMainTable(raw, allowedKeys) {
@@ -24,19 +24,13 @@ export class GetQueryOperation {
24
24
  continue;
25
25
  query[key] = Array.isArray(value) ? value.join(',') : value;
26
26
  }
27
- const result = await host.request({
27
+ const response = await host.query({
28
28
  method: 'GET',
29
29
  path: this.path,
30
30
  query,
31
31
  operation: this.name,
32
32
  });
33
- return {
34
- status: 'COMPLETE',
35
- data: {
36
- ...(result && typeof result === 'object' ? { raw: result } : { raw: result }),
37
- query,
38
- },
39
- };
33
+ return { response };
40
34
  }
41
35
  }
42
36
  /** POST raw body 接口(bodyMode=raw):params 原样透传。 */
@@ -62,18 +56,13 @@ export class RawPostOperation {
62
56
  query[key] = String(value);
63
57
  }
64
58
  }
65
- const result = await host.request({
59
+ const response = await host.query({
66
60
  path: this.path,
67
61
  query,
68
62
  body,
69
63
  operation: this.name,
70
64
  });
71
- return {
72
- status: 'COMPLETE',
73
- data: {
74
- ...(result && typeof result === 'object' ? { raw: result } : { raw: result }),
75
- },
76
- };
65
+ return { response };
77
66
  }
78
67
  }
79
68
  /** 占位符路径 raw POST(browser-option-search:path 含 {customBrowserType})。 */
@@ -96,17 +85,12 @@ export class PathParamsPostOperation {
96
85
  path = path.replace(`{${name}}`, encodeURIComponent(String(value)));
97
86
  }
98
87
  const body = input.params && typeof input.params === 'object' ? input.params : {};
99
- const result = await host.request({
88
+ const response = await host.query({
100
89
  path,
101
90
  body,
102
91
  operation: this.name,
103
92
  });
104
- return {
105
- status: 'COMPLETE',
106
- data: {
107
- ...(result && typeof result === 'object' ? { raw: result } : { raw: result }),
108
- },
109
- };
93
+ return { response };
110
94
  }
111
95
  }
112
96
  /** GET 文件预览/下载(get-file-preview):fileId 等 query,save 输出到本地。 */
@@ -129,18 +113,12 @@ export class FilePreviewOperation {
129
113
  query.appId = input.appId;
130
114
  if (input.customParam !== undefined)
131
115
  query.customParam = typeof input.customParam === 'string' ? input.customParam : JSON.stringify(input.customParam);
132
- const result = await host.request({
116
+ const response = await host.query({
133
117
  method: 'GET',
134
118
  path: '/api/file/preview',
135
119
  query,
136
120
  operation: this.name,
137
121
  });
138
- return {
139
- status: 'COMPLETE',
140
- data: {
141
- ...(result && typeof result === 'object' ? { raw: result } : { raw: result }),
142
- fileId,
143
- },
144
- };
122
+ return { response };
145
123
  }
146
124
  }
@@ -1,6 +1,7 @@
1
1
  import { jiuchuanhuiValidationError } from '../errors.js';
2
2
  import { jiuchuanhuiOperations } from '../manifest.js';
3
3
  import { CacheInitOperation } from '../cache.js';
4
+ import { CustomerQuickSearchOperation } from './customer-quick.js';
4
5
  import { DatajsonDetailOperation, DatajsonSearchOperation, DatajsonWriteApplyOperation, DatajsonWritePrepareOperation, } from './datajson.js';
5
6
  import { EsbReadOperation, EsbWriteApplyOperation, EsbWritePrepareOperation, } from './esb.js';
6
7
  import { FilePreviewOperation, GetQueryOperation, PathParamsPostOperation, } from './generic.js';
@@ -12,6 +13,8 @@ import { FilePreviewOperation, GetQueryOperation, PathParamsPostOperation, } fro
12
13
  */
13
14
  function buildRegistry() {
14
15
  const registry = new Map();
16
+ const customerSearch = new DatajsonSearchOperation('jiuchuanhui.customer.search', '/api/ebuilder/form/formdata/v2/getFormDataList/ebcustomer_search_api', '/api/ebuilder/form/formdata/v2/getFormDataCount/ebcustomer_search_count_api');
17
+ const customerStatusSearch = new DatajsonSearchOperation('jiuchuanhui.customer.status.search', '/api/ebuilder/form/formdata/v2/getFormDataList/ebcustomer_status_search_api');
15
18
  const handlers = [
16
19
  // ===== 发现与缓存 =====
17
20
  new CacheInitOperation(),
@@ -25,9 +28,12 @@ function buildRegistry() {
25
28
  new DatajsonWritePrepareOperation('jiuchuanhui.customer.create.prepare', 'jiuchuanhui.customer.create.apply'),
26
29
  new DatajsonWriteApplyOperation('jiuchuanhui.customer.create.apply', '/api/ebuilder/form/formdata/v2/saveFormData/customer_create_api'),
27
30
  new DatajsonDetailOperation('jiuchuanhui.customer.get', '/api/ebuilder/form/formdata/v2/getFormDataByPk/customer_get_api'),
28
- new DatajsonSearchOperation('jiuchuanhui.customer.search', '/api/ebuilder/form/formdata/v2/getFormDataList/ebcustomer_search_api', '/api/ebuilder/form/formdata/v2/getFormDataCount/ebcustomer_search_count_api'),
31
+ customerSearch,
32
+ new CustomerQuickSearchOperation('jiuchuanhui.customer.mine.search', customerSearch, 'mine'),
33
+ new CustomerQuickSearchOperation('jiuchuanhui.customer.success.search', customerSearch, 'mine', customerStatusSearch),
34
+ new CustomerQuickSearchOperation('jiuchuanhui.customer.open-sea.customers.search', customerSearch, 'open-sea'),
29
35
  new DatajsonSearchOperation('jiuchuanhui.customer.type.search', '/api/ebuilder/form/formdata/v2/getFormDataList/ebcustomer_type_search_api'),
30
- new DatajsonSearchOperation('jiuchuanhui.customer.status.search', '/api/ebuilder/form/formdata/v2/getFormDataList/ebcustomer_status_search_api'),
36
+ customerStatusSearch,
31
37
  new DatajsonSearchOperation('jiuchuanhui.customer.industry.search', '/api/ebuilder/form/formdata/v2/getFormDataList/ebcustomer_industry_search_api'),
32
38
  new DatajsonSearchOperation('jiuchuanhui.customer.open-sea.search', '/api/ebuilder/form/formdata/v2/getFormDataList/customer_open_sea_search_api'),
33
39
  new DatajsonWritePrepareOperation('jiuchuanhui.customer.update.prepare', 'jiuchuanhui.customer.update.apply'),
@@ -122,16 +122,6 @@ function stripForbidden(value) {
122
122
  export function stripForbiddenKeys(value) {
123
123
  return stripForbidden(value);
124
124
  }
125
- /** 从 datajson-list 响应中安全提取 records 数组。 */
126
- export function listRecords(value) {
127
- if (!value || typeof value !== 'object')
128
- return [];
129
- const root = value;
130
- const datas = root.datajson?.datas;
131
- if (Array.isArray(datas))
132
- return datas;
133
- return [];
134
- }
135
125
  /** datajson 类创建/更新成功后的 dataIds。 */
136
126
  export function resultDataIds(value) {
137
127
  if (!value || typeof value !== 'object')
@@ -38,6 +38,20 @@ export function mailNetworkError(subtype, message, options = {}) {
38
38
  exitCode: ExitCode.NetworkError,
39
39
  });
40
40
  }
41
+ /** 上游契约异常:调用通了但响应缺字段 / 响应体是业务失败(对应平台码 E-0004)。 */
42
+ export function mailUpstreamError(subtype, message, details) {
43
+ return new MailCliError('upstream', subtype, message, {
44
+ details,
45
+ exitCode: ExitCode.NetworkError,
46
+ });
47
+ }
48
+ /** 环境能力未开通 / 发送策略拦截(对应平台码 E-0005)。 */
49
+ export function mailRestrictedError(subtype, message, details) {
50
+ return new MailCliError('policy', subtype, message, {
51
+ details,
52
+ exitCode: ExitCode.PolicyError,
53
+ });
54
+ }
41
55
  export function mailConfirmationError(action, details) {
42
56
  return new MailCliError('confirmation', 'required', '该操作需要明确确认', {
43
57
  details: { action, ...details },
@@ -1,6 +1,7 @@
1
1
  import { readFile } from 'node:fs/promises';
2
2
  import { ExitCode, isCliError, toErrorEnvelope } from '../../core/errors.js';
3
- import { reportPlatformError } from '../../core/error-codes.js';
3
+ import { shouldReportPlatformError, toPlatformError } from '../../core/error-codes.js';
4
+ import { MANIFEST_LIST_COMPACT_PATHS, manifestView, schemaOptionsOf } from '../../core/manifest-view.js';
4
5
  import { createMailContinuationSigner } from './continuation.js';
5
6
  import { createMailHost } from './host.js';
6
7
  import { mailManifest } from './manifest.js';
@@ -47,7 +48,7 @@ function parseJsonInput(raw, label) {
47
48
  try {
48
49
  const parsed = JSON.parse(stripBom(raw));
49
50
  if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) {
50
- throw new Error('input must be an object');
51
+ throw mailValidationError('input_invalid', label + ' 必须是 JSON 对象');
51
52
  }
52
53
  return parsed;
53
54
  }
@@ -84,8 +85,16 @@ async function executeAndPrint(ctx, operation, input) {
84
85
  ctx.output.write(successEnvelope(operation, result), { json: true });
85
86
  }
86
87
  catch (error) {
87
- reportPlatformError(error);
88
- console.error(JSON.stringify(failureEnvelope(error), null, 2));
88
+ // 与 ehr 对齐(审计 G-06):单段 JSON、顶层带平台码,避免“先一行 JSON 再一段 JSON”
89
+ // 导致 stderr 无法一次解析,也避免多行 JSON 里根本没有 E-XXXX。
90
+ const env = failureEnvelope(error);
91
+ if (shouldReportPlatformError(error)) {
92
+ const pe = toPlatformError(error);
93
+ console.error(JSON.stringify({ ...env, code: pe.code, message: pe.message }, null, 2));
94
+ }
95
+ else {
96
+ console.error(JSON.stringify(env, null, 2));
97
+ }
89
98
  process.exitCode = isCliError(error) ? error.exitCode : ExitCode.GeneralError;
90
99
  }
91
100
  }
@@ -97,8 +106,16 @@ export const mailShortcut = {
97
106
  const mail = program.command('mail').description('泛微E10邮件管理(查询/发送/管理)');
98
107
  mail.command('schema')
99
108
  .description('Print mail operation manifest for agents')
100
- .action(action((ctx) => {
101
- ctx.output.write(mailManifest, { json: true });
109
+ .option('--list', '只列操作清单(name/summary/risk),全量不截断;判断"有没有某操作"用这个')
110
+ .option('--full', '打印完整 manifest(超 stdout 预算会落本地 ref,用 refs get 分页取)')
111
+ .option('--operation <name>', '只输出单个操作的完整契约(含 inputSchema,体积远低于预算)')
112
+ .action(action((ctx, options) => {
113
+ const schema = schemaOptionsOf(options);
114
+ ctx.output.write(manifestView(mailManifest, schema), {
115
+ json: true,
116
+ // 只有 --list 单行化:条目多、缩进空白能吃掉近一半体积,且对读模型无收益。
117
+ ...(schema.list === true ? { compactPaths: MANIFEST_LIST_COMPACT_PATHS } : {}),
118
+ });
102
119
  }));
103
120
  mail.command('run')
104
121
  .description('Run a mail operation with JSON input')
@@ -4,10 +4,17 @@ import { mailOperationDefinitions } from './operations/registry.js';
4
4
  * - mail.delete.batch:物理永久删除,不可逆、无法撤销,破坏性最强,暂缓实现。
5
5
  * - mail.resend:重发依赖「邮件发送日志 id」(mailRemindLogId),源技能未封装日志查询接口,
6
6
  * 无法获得该 id 时如实提示,不臆造;暂缓实现。
7
+ * - mail.clearlog.list:2026-11-27 审计实测本环境 `getEmailClearLogList` 返回 HTTP 404,
8
+ * E10 服务端接口不存在或未装配;调用必然失败的入口不下发给模型,待确认目标版本后恢复。
7
9
  * 其余读操作与写操作(发送/回复/转发/存草稿、标星、已读、待办、移动、逻辑删除、文件夹、
8
10
  * 联系人、分组、模板、签名、黑名单、附件上传/下载、撤回)均已可用。不得编造或绕过。
9
11
  */
10
- const MAIL_WITHHELD = ['mail.delete.batch', 'mail.resend'];
12
+ const MAIL_WITHHELD_REASONS = {
13
+ 'mail.delete.batch': '物理永久删除(deleteMailResourceBatch)不可逆、无法撤销,破坏性最强;如确需执行,请在确认风险后以单独授权方式处理,不在常规 CLI 提供。',
14
+ 'mail.resend': '重发邮件(resendMail)依赖「邮件发送日志 id」(mailRemindLogId),源技能未封装日志查询接口,无法获得该 id 时如实提示,不臆造;暂缓实现。',
15
+ 'mail.clearlog.list': '邮件清理日志接口(getEmailClearLogList)在本环境实测 HTTP 404,E10 服务端不存在或未装配;调用必然失败,暂不提供,待确认目标版本后恢复。',
16
+ };
17
+ const MAIL_WITHHELD = Object.keys(MAIL_WITHHELD_REASONS);
11
18
  function buildOperations() {
12
19
  return mailOperationDefinitions().map((definition) => ({
13
20
  name: definition.name,
@@ -29,10 +36,10 @@ export const mailManifest = {
29
36
  sourceSkill: 'weaver-e10-mail',
30
37
  capabilities: ['mail'],
31
38
  operations: buildOperations(),
39
+ // 2026-11-27 审计 MA-04 / G-10:首屏先给被扣下的能力总数,避免截断后模型误判"这里只有这些"。
40
+ withheldCount: MAIL_WITHHELD.length,
32
41
  withheldOperations: MAIL_WITHHELD.map((name) => ({
33
42
  name,
34
- reason: name === 'mail.delete.batch'
35
- ? '物理永久删除(deleteMailResourceBatch)不可逆、无法撤销,破坏性最强;如确需执行,请在确认风险后以单独授权方式处理,不在常规 CLI 提供。'
36
- : '重发邮件(resendMail)依赖「邮件发送日志 id」(mailRemindLogId),源技能未封装日志查询接口,无法获得该 id 时如实提示,不臆造;暂缓实现。',
43
+ reason: MAIL_WITHHELD_REASONS[name],
37
44
  })),
38
45
  };
@@ -1,5 +1,5 @@
1
1
  import { CONTINUATION_TTL_MS } from '../../../core/continuation-ttl.js';
2
- import { mailValidationError } from '../errors.js';
2
+ import { mailConfirmationError, mailValidationError } from '../errors.js';
3
3
  import { WRITE, mailSuccess, schemaOf, SCHEMA_STRING } from './types.js';
4
4
  const BLACKLIST_SCHEMA = schemaOf({
5
5
  operateType: { type: 'string', description: 'add / delete' },
@@ -11,18 +11,18 @@ const BLACKLIST_SCHEMA = schemaOf({
11
11
  function buildBlacklistBody(args) {
12
12
  const operateType = String(args.operateType || 'add').toLowerCase();
13
13
  if (operateType !== 'add' && operateType !== 'delete')
14
- throw new Error('operateType 必须是 add 或 delete');
14
+ throw mailValidationError('operate_type_invalid', 'operateType 必须是 add 或 delete');
15
15
  const body = { operateType };
16
16
  if (operateType === 'add') {
17
17
  const mailAddress = String(args.mailAddress || '').trim();
18
18
  if (!mailAddress)
19
- throw new Error('add 操作必须提供 mailAddress(邮箱地址)');
19
+ throw mailValidationError('mail_address_required', 'add 操作必须提供 mailAddress(邮箱地址)');
20
20
  body.mailAddress = mailAddress;
21
21
  }
22
22
  else {
23
23
  const id = String(args.id || '').trim();
24
24
  if (!id)
25
- throw new Error('delete 操作必须提供 id(黑名单记录 id)');
25
+ throw mailValidationError('id_required', 'delete 操作必须提供 id(黑名单记录 id)');
26
26
  body.id = id;
27
27
  }
28
28
  return body;
@@ -64,9 +64,9 @@ const opBlacklistOperateApply = {
64
64
  inputSchema: BLACKLIST_SCHEMA,
65
65
  async handler(args, env) {
66
66
  if (args.confirm !== true)
67
- throw new Error('mail.blacklist.operate.apply 必须传入 confirm=true 与 prepare 返回的 continuation');
67
+ throw mailConfirmationError('mail.blacklist.operate.apply');
68
68
  if (!args.continuation)
69
- throw new Error('mail.blacklist.operate.apply 必须传入 prepare 返回的 continuation');
69
+ throw mailValidationError('continuation_required', 'mail.blacklist.operate.apply 需要 prepare 返回的 continuation');
70
70
  const lease = await env.continuation.verify(String(args.continuation), 'mail.blacklist.operate.apply');
71
71
  const session = await env.host.getSession();
72
72
  if (lease.baseUrl !== session.baseUrl || lease.profile !== session.profile || lease.userId !== session.userId) {
@@ -1,5 +1,5 @@
1
1
  import { CONTINUATION_TTL_MS } from '../../../core/continuation-ttl.js';
2
- import { mailValidationError } from '../errors.js';
2
+ import { mailConfirmationError, mailValidationError } from '../errors.js';
3
3
  import { WRITE, mailSuccess, schemaOf, SCHEMA_STRING } from './types.js';
4
4
  // ---------------------------------------------------------------------------
5
5
  // 联系人 新增/编辑(prepare/apply)
@@ -19,9 +19,9 @@ function buildContactBody(args) {
19
19
  const name = String(args.mailUserName || '').trim();
20
20
  const address = String(args.mailAddress || '').trim();
21
21
  if (!name)
22
- throw new Error('mailUserName(姓名)必填');
22
+ throw mailValidationError('user_name_required', 'mailUserName(姓名)必填');
23
23
  if (!address)
24
- throw new Error('mailAddress(邮箱地址)必填');
24
+ throw mailValidationError('mail_address_required', 'mailAddress(邮箱地址)必填');
25
25
  const body = {
26
26
  mailUserName: name,
27
27
  mailAddress: address,
@@ -74,9 +74,9 @@ const opContactSaveApply = {
74
74
  inputSchema: CONTACT_SCHEMA,
75
75
  async handler(args, env) {
76
76
  if (args.confirm !== true)
77
- throw new Error('mail.contacts.save.apply 必须传入 confirm=true 与 prepare 返回的 continuation');
77
+ throw mailConfirmationError('mail.contacts.save.apply');
78
78
  if (!args.continuation)
79
- throw new Error('mail.contacts.save.apply 必须传入 prepare 返回的 continuation');
79
+ throw mailValidationError('continuation_required', 'mail.contacts.save.apply 需要 prepare 返回的 continuation');
80
80
  const lease = await env.continuation.verify(String(args.continuation), 'mail.contacts.save.apply');
81
81
  const session = await env.host.getSession();
82
82
  if (lease.baseUrl !== session.baseUrl || lease.profile !== session.profile || lease.userId !== session.userId) {
@@ -97,7 +97,7 @@ const opContactDelete = {
97
97
  async handler(args, env) {
98
98
  const id = String(args.id || '').trim();
99
99
  if (!id)
100
- throw new Error('id(联系人 id)必填');
100
+ throw mailValidationError('id_required', 'id(联系人 id)必填');
101
101
  const value = (await env.host.request({ path: '/api/mail/base/contacts/delContacts', method: 'POST', body: { ids: id } }));
102
102
  return mailSuccess('mail.contacts.delete', value?.data ?? true, { id });
103
103
  },
@@ -114,7 +114,7 @@ const GROUP_SCHEMA = schemaOf({
114
114
  function buildGroupBody(args) {
115
115
  const groupName = String(args.groupName || '').trim();
116
116
  if (!groupName)
117
- throw new Error('groupName(分组名)必填');
117
+ throw mailValidationError('group_name_required', 'groupName(分组名)必填');
118
118
  const body = { groupName };
119
119
  if (args.id)
120
120
  body.groupId = String(args.id);
@@ -157,9 +157,9 @@ const opGroupSaveApply = {
157
157
  inputSchema: GROUP_SCHEMA,
158
158
  async handler(args, env) {
159
159
  if (args.confirm !== true)
160
- throw new Error('mail.contacts.group.save.apply 必须传入 confirm=true 与 prepare 返回的 continuation');
160
+ throw mailConfirmationError('mail.contacts.group.save.apply');
161
161
  if (!args.continuation)
162
- throw new Error('mail.contacts.group.save.apply 必须传入 prepare 返回的 continuation');
162
+ throw mailValidationError('continuation_required', 'mail.contacts.group.save.apply 需要 prepare 返回的 continuation');
163
163
  const lease = await env.continuation.verify(String(args.continuation), 'mail.contacts.group.save.apply');
164
164
  const session = await env.host.getSession();
165
165
  if (lease.baseUrl !== session.baseUrl || lease.profile !== session.profile || lease.userId !== session.userId) {
@@ -180,7 +180,7 @@ const opGroupDelete = {
180
180
  async handler(args, env) {
181
181
  const id = String(args.id || '').trim();
182
182
  if (!id)
183
- throw new Error('id(分组 id)必填');
183
+ throw mailValidationError('id_required', 'id(分组 id)必填');
184
184
  const value = (await env.host.request({ path: '/api/mail/base/contacts/delContactsGroup', method: 'POST', body: { groupId: id } }));
185
185
  return mailSuccess('mail.contacts.group.delete', value?.data ?? true, { id });
186
186
  },