weaver-work-cli 0.1.70 → 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 (214) 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-DMU7KNZ7.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-KDOJW5LH.js → chunk-EJLP63UO.js} +1 -1
  15. package/dist/chunks/{chunk-HAORST2G.js → chunk-FRMDHZSN.js} +11 -11
  16. package/dist/chunks/{chunk-GWM5TLIK.js → chunk-G7ZM2VOX.js} +34 -34
  17. package/dist/chunks/{chunk-LSVA7QA6.js → chunk-GB2MCJPG.js} +3 -1
  18. package/dist/chunks/{chunk-L2A3COWV.js → chunk-ICNUOWLL.js} +4 -4
  19. package/dist/chunks/{chunk-GTAFCAVP.js → chunk-IZCQU5D5.js} +1 -1
  20. package/dist/chunks/{chunk-7CINV2BU.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-X6PMJQGO.js → chunk-OFCF23FY.js} +6 -6
  24. package/dist/chunks/{chunk-IVCOZCAW.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-LJE7RZNC.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-XIBMZEDB.js → chunk-VJWVB55R.js} +2 -2
  32. package/dist/chunks/{chunk-EHH363SP.js → chunk-VMVMEIL3.js} +4 -4
  33. package/dist/chunks/chunk-WM33BSIL.js +136 -0
  34. package/dist/chunks/{chunk-GFOFUH6O.js → chunk-X2C5CGGM.js} +52 -51
  35. package/dist/chunks/{chunk-4W6BSNIL.js → chunk-XLSJC6JZ.js} +6 -6
  36. package/dist/chunks/{chunk-U3OO3IZF.js → chunk-YN5SD4TX.js} +20 -7
  37. package/dist/chunks/{conflict-YW5BULJ3.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-5OBS3B3V.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-L65OWPFM.js → entry-mode-6N2IGCS4.js} +3 -3
  45. package/dist/chunks/{env-XW7LYIME.js → env-QYLS3EB3.js} +2 -2
  46. package/dist/chunks/{esb-GSB5QCEX.js → esb-PTYS3E67.js} +17 -7
  47. package/dist/chunks/{factory-MHFZZAGH.js → factory-LPFPKZ4T.js} +1 -1
  48. package/dist/chunks/{fna-XBSNUS2V.js → fna-JNHCLRDE.js} +15 -5
  49. package/dist/chunks/{group-chat-EEOLO5NM.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-JCBUR563.js → jiuchuanhui-PTABJE7V.js} +19 -6
  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-PCD5EPBF.js → meeting-NIDHDBCB.js} +29 -16
  63. package/dist/chunks/{minute-doc-WTZJVCHG.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-SMVTPK6T.js → performance-3MQ3AHDQ.js} +92 -7
  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-ZQ7OONCB.js → registry-3GQRYP2R.js} +12 -12
  73. package/dist/chunks/{registry-3B3OAJYX.js → registry-3S7AVMXR.js} +4 -4
  74. package/dist/chunks/{registry-FTPUUHWC.js → registry-NHHKOEU3.js} +5 -5
  75. package/dist/chunks/{room-recommend-73NBN3RU.js → room-recommend-IOKBJVYP.js} +4 -4
  76. package/dist/chunks/{schedule-SDBOBBUQ.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-OWHWLAOX.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/index.js +15 -1
  140. package/dist/shortcuts/jiuchuanhui/manifest.js +2 -0
  141. package/dist/shortcuts/mail/errors.js +14 -0
  142. package/dist/shortcuts/mail/index.js +23 -6
  143. package/dist/shortcuts/mail/manifest.js +11 -4
  144. package/dist/shortcuts/mail/operations/mail-blacklist.js +6 -6
  145. package/dist/shortcuts/mail/operations/mail-contacts.js +10 -10
  146. package/dist/shortcuts/mail/operations/mail-manage.js +15 -14
  147. package/dist/shortcuts/mail/operations/mail-read.js +7 -25
  148. package/dist/shortcuts/mail/operations/mail-send.js +12 -12
  149. package/dist/shortcuts/mail/operations/mail-sign.js +10 -10
  150. package/dist/shortcuts/mail/operations/mail-template.js +10 -10
  151. package/dist/shortcuts/meeting/index.js +11 -2
  152. package/dist/shortcuts/meeting/operations/invitation-publish.js +1 -0
  153. package/dist/shortcuts/okr/index.js +11 -2
  154. package/dist/shortcuts/performance/index.js +62 -3
  155. package/dist/shortcuts/performance/scheme-validate.js +7 -0
  156. package/dist/shortcuts/performance/shared.js +40 -2
  157. package/dist/shortcuts/plan/index.js +11 -2
  158. package/dist/shortcuts/project/index.js +11 -2
  159. package/dist/shortcuts/project/operations/write.js +3 -0
  160. package/dist/shortcuts/reception/index.js +11 -2
  161. package/dist/shortcuts/reception/manifest.js +2 -2
  162. package/dist/shortcuts/reception/operations/ask.js +3 -0
  163. package/dist/shortcuts/recruit-stage/index.js +22 -3
  164. package/dist/shortcuts/recruit-stage/manifest.js +2 -0
  165. package/dist/shortcuts/recruit-stage/operations/jd-create.js +33 -16
  166. package/dist/shortcuts/recruit-stage/operations/profile.js +186 -0
  167. package/dist/shortcuts/recruit-stage/operations/registry.js +2 -0
  168. package/dist/shortcuts/recruit-stage/operations/resume-import.js +76 -47
  169. package/dist/shortcuts/recruit-stage/operations/search.js +151 -16
  170. package/dist/shortcuts/recruit-stage/operations/tag.js +17 -3
  171. package/dist/shortcuts/recruit-stage/shared.js +11 -1
  172. package/dist/shortcuts/smart-extract/index.js +11 -2
  173. package/dist/shortcuts/smart-extract/manifest.js +1 -0
  174. package/dist/shortcuts/smart-extract/operations/save.js +2 -0
  175. package/dist/shortcuts/workflow/index.js +21 -1
  176. package/dist/shortcuts/workflow/operations/read.js +2 -2
  177. package/dist/shortcuts/workflow/operations/write.js +1 -1
  178. package/docs/caizhilian.md +1 -1
  179. package/docs/contract.md +1 -0
  180. package/docs/data.md +22 -22
  181. package/docs/e10-auth.md +41 -33
  182. package/docs/ehr.md +2 -0
  183. package/docs/reception.md +4 -3
  184. package/package.json +1 -1
  185. package/scripts/pysite/__pycache__/sitecustomize.cpython-312.pyc +0 -0
  186. package/scripts/pysite/__pycache__/sitecustomize.cpython-313.pyc +0 -0
  187. package/scripts/pysite/sitecustomize.py +41 -0
  188. package/skill-template/domains/data.md +4 -4
  189. package/skills/weaver-e10-caizhilian/SKILL.md +1 -1
  190. package/skills/weaver-e10-caizhilian/references/org-browser.md +1 -0
  191. package/skills/weaver-e10-cowork/SKILL.md +3 -1
  192. package/skills/weaver-e10-data/SKILL.md +12 -16
  193. package/skills/weaver-e10-data/references/config-center.md +6 -7
  194. package/skills/weaver-e10-data/references/datasource.md +1 -1
  195. package/skills/weaver-e10-data/references/scene-and-misc.md +2 -2
  196. package/skills/weaver-e10-jiuchuanhui/SKILL.md +6 -4
  197. package/skills/weaver-e10-jiuchuanhui/references/clue.md +2 -2
  198. package/skills/weaver-e10-jiuchuanhui/references/customer.md +18 -8
  199. package/skills/weaver-e10-jiuchuanhui/references/sale.md +2 -2
  200. package/skills/weaver-e10-jucailin/references/attend-write.md +1 -1
  201. package/skills/weaver-e10-mail/SKILL.md +4 -1
  202. package/skills/weaver-e10-mail/references/mail-read.md +4 -2
  203. package/skills/weaver-e10-mail/references/safety-boundaries.md +1 -0
  204. package/skills/weaver-e10-okr/references/source-manifest.json +3 -3
  205. package/skills/weaver-e10-performance/SKILL.md +8 -6
  206. package/skills/weaver-e10-recruit-stage/SKILL.md +125 -20
  207. package/skills/weaver-e10-recruit-stage/lib/recruit-write-helper.mjs +359 -0
  208. package/skills/weaver-e10-recruit-stage/references/env-fixed-values.md +87 -0
  209. package/skills/weaver-e10-recruit-stage/references/recruit-jd-create.md +9 -2
  210. package/skills/weaver-e10-recruit-stage/references/recruit-tag-recommend.md +1 -0
  211. package/skills/weaver-e10-recruit-stage/templates/match-report.html +177 -0
  212. package/skills/weaver-e10-shared/SKILL.md +22 -1
  213. package/skills/weaver-e10-shared/references/e10-auth-and-session.md +2 -2
  214. package/skills/weaver-e10-yimiaoban/references/source-manifest.json +3 -3
@@ -1,6 +1,7 @@
1
1
  import { readFile } from 'node:fs/promises';
2
2
  import { ExitCode, isCliError, toErrorEnvelope } from '../../core/errors.js';
3
3
  import { reportPlatformError } from '../../core/error-codes.js';
4
+ import { MANIFEST_LIST_COMPACT_PATHS, manifestView, schemaOptionsOf } from '../../core/manifest-view.js';
4
5
  import { createEsbContinuationSigner } from './continuation.js';
5
6
  import { createEsbHost } from './host.js';
6
7
  import { esbManifest } from './manifest.js';
@@ -99,8 +100,16 @@ export const esbShortcut = {
99
100
  const esb = program.command('esb').description('泛微E10 ESB 中心自定义触发动作流(取入参模板 / 确认后触发)');
100
101
  esb.command('schema')
101
102
  .description('Print esb operation manifest for agents')
102
- .action(action((ctx) => {
103
- ctx.output.write(esbManifest, { json: true });
103
+ .option('--list', '只列操作清单(name/summary/risk),全量不截断;判断"有没有某操作"用这个')
104
+ .option('--full', '打印完整 manifest(超 stdout 预算会落本地 ref,用 refs get 分页取)')
105
+ .option('--operation <name>', '只输出单个操作的完整契约(含 inputSchema,体积远低于预算)')
106
+ .action(action((ctx, options) => {
107
+ const schema = schemaOptionsOf(options);
108
+ ctx.output.write(manifestView(esbManifest, schema), {
109
+ json: true,
110
+ // 只有 --list 单行化:条目多、缩进空白能吃掉近一半体积,且对读模型无收益。
111
+ ...(schema.list === true ? { compactPaths: MANIFEST_LIST_COMPACT_PATHS } : {}),
112
+ });
104
113
  }));
105
114
  esb.command('run')
106
115
  .description('Run an esb operation with JSON input')
@@ -43,6 +43,7 @@ export const esbOperations = [
43
43
  name: 'esb.trigger.prepare',
44
44
  summary: '触发前的只读回查与请求体组装,签发 apply 所需的 continuation(不产生业务副作用)',
45
45
  risk: 'read-before-write',
46
+ requiresConfirmation: true,
46
47
  inputSchema: {
47
48
  type: 'object',
48
49
  additionalProperties: false,
@@ -55,6 +56,7 @@ export const esbOperations = [
55
56
  name: 'esb.trigger.apply',
56
57
  summary: '按 continuation 执行动作流触发(高风险写操作,可能产生业务副作用)',
57
58
  risk: 'high-risk-write',
59
+ requiresConfirmation: true,
58
60
  inputSchema: {
59
61
  type: 'object',
60
62
  additionalProperties: false,
@@ -1,6 +1,7 @@
1
1
  import { readFile } from 'node:fs/promises';
2
2
  import { ExitCode, isCliError, toErrorEnvelope } from '../../core/errors.js';
3
3
  import { reportPlatformError } from '../../core/error-codes.js';
4
+ import { MANIFEST_LIST_COMPACT_PATHS, manifestView, schemaOptionsOf } from '../../core/manifest-view.js';
4
5
  import { createFnaContinuationSigner } from './continuation.js';
5
6
  import { createFnaHost } from './host.js';
6
7
  import { fnaManifest } from './manifest.js';
@@ -98,8 +99,16 @@ export const fnaShortcut = {
98
99
  const fna = program.command('fna').description('泛微E10齐业成费控中心(预算查询/费用中心/借款管理/发票核销)');
99
100
  fna.command('schema')
100
101
  .description('Print fna operation manifest for agents')
101
- .action(action((ctx) => {
102
- ctx.output.write(fnaManifest, { json: true });
102
+ .option('--list', '只列操作清单(name/summary/risk),全量不截断;判断"有没有某操作"用这个')
103
+ .option('--full', '打印完整 manifest(超 stdout 预算会落本地 ref,用 refs get 分页取)')
104
+ .option('--operation <name>', '只输出单个操作的完整契约(含 inputSchema,体积远低于预算)')
105
+ .action(action((ctx, options) => {
106
+ const schema = schemaOptionsOf(options);
107
+ ctx.output.write(manifestView(fnaManifest, schema), {
108
+ json: true,
109
+ // 只有 --list 单行化:条目多、缩进空白能吃掉近一半体积,且对读模型无收益。
110
+ ...(schema.list === true ? { compactPaths: MANIFEST_LIST_COMPACT_PATHS } : {}),
111
+ });
103
112
  }));
104
113
  fna.command('run')
105
114
  .description('Run an fna operation with JSON input')
@@ -1,6 +1,7 @@
1
1
  import { readFile } from 'node:fs/promises';
2
2
  import { ExitCode, isCliError, toErrorEnvelope } from '../../core/errors.js';
3
3
  import { reportPlatformError } from '../../core/error-codes.js';
4
+ import { manifestView } from '../../core/manifest-view.js';
4
5
  import { createHrmHost } from './host.js';
5
6
  import { hrmManifest } from './manifest.js';
6
7
  import { executeHrmOperation } from './operations.js';
@@ -143,9 +144,18 @@ export const hrmShortcut = {
143
144
  const hrm = program.command('hrm').description('泛微E10组织管理(员工查询/组织架构/岗位查询)');
144
145
  hrm.command('schema')
145
146
  .description('Print hrm operation manifest for agents')
147
+ // `--list` 是本模块的默认行为(默认就输出精简索引),保留声明只为跨域统一。
148
+ .option('--list', '只列操作索引(name/summary/参数名/必填项),与默认输出一致,全量不截断')
149
+ .option('--operation <name>', '只输出单个操作的完整契约(含 inputSchema,体积远低于预算)')
146
150
  .option('--full', 'print full manifest with complete inputSchema')
147
151
  .action(action((ctx, options) => {
148
- if (asOptions(options).full === true) {
152
+ const opts = asOptions(options);
153
+ const requested = String(opts.operation ?? '').trim();
154
+ if (requested) {
155
+ ctx.output.write(manifestView(hrmManifest, { operation: requested }), { json: true });
156
+ return;
157
+ }
158
+ if (opts.full === true) {
149
159
  ctx.output.write(hrmManifest, { json: true });
150
160
  return;
151
161
  }
@@ -1,5 +1,6 @@
1
1
  import { readFile } from 'node:fs/promises';
2
2
  import { ExitCode, isCliError, toErrorEnvelope } from '../../core/errors.js';
3
+ import { MANIFEST_LIST_COMPACT_PATHS, manifestView, schemaOptionsOf } from '../../core/manifest-view.js';
3
4
  import { createImContinuationSigner } from './continuation.js';
4
5
  import { printImFailure, registerImTrace } from './diagnostics.js';
5
6
  import { imValidationError } from './errors.js';
@@ -238,8 +239,16 @@ export const imShortcut = {
238
239
  .option('--trace', '每个 E10 请求在 stderr 打一行 [trace](method/path/op/status/耗时,不含凭证)');
239
240
  im.command('schema')
240
241
  .description('Print im operation manifest for agents')
241
- .action(action((ctx) => {
242
- ctx.output.write(imManifest, { json: true });
242
+ .option('--list', '只列操作清单(name/summary/risk),全量不截断;判断"有没有某操作"用这个')
243
+ .option('--full', '打印完整 manifest(超 stdout 预算会落本地 ref,用 refs get 分页取)')
244
+ .option('--operation <name>', '只输出单个操作的完整契约(含 inputSchema,体积远低于预算)')
245
+ .action(action((ctx, options) => {
246
+ const schema = schemaOptionsOf(options);
247
+ ctx.output.write(manifestView(imManifest, schema), {
248
+ json: true,
249
+ // 只有 --list 单行化:条目多、缩进空白能吃掉近一半体积,且对读模型无收益。
250
+ ...(schema.list === true ? { compactPaths: MANIFEST_LIST_COMPACT_PATHS } : {}),
251
+ });
243
252
  }));
244
253
  withJsonInputOptions(im.command('run')
245
254
  .description('Run an im operation with JSON input')
@@ -2,6 +2,7 @@ import { readFile } from 'node:fs/promises';
2
2
  import { Option } from 'commander';
3
3
  import { ExitCode, isCliError, toErrorEnvelope } from '../../core/errors.js';
4
4
  import { reportPlatformError } from '../../core/error-codes.js';
5
+ import { MANIFEST_LIST_COMPACT_PATHS, manifestView, schemaOptionsOf } from '../../core/manifest-view.js';
5
6
  import { createInvoiceContinuationSigner } from './continuation.js';
6
7
  import { createInvoiceHost } from './host.js';
7
8
  import { invoiceManifest } from './manifest.js';
@@ -145,8 +146,16 @@ export const invoiceShortcut = {
145
146
  const invoice = program.command('invoice').description('E10 业票通发票管理');
146
147
  invoice.command('schema')
147
148
  .description('Print invoice operation manifest for agents')
148
- .action(action((ctx) => {
149
- ctx.output.write(invoiceManifest, { json: true });
149
+ .option('--list', '只列操作清单(name/summary/risk),全量不截断;判断"有没有某操作"用这个')
150
+ .option('--full', '打印完整 manifest(超 stdout 预算会落本地 ref,用 refs get 分页取)')
151
+ .option('--operation <name>', '只输出单个操作的完整契约(含 inputSchema,体积远低于预算)')
152
+ .action(action((ctx, options) => {
153
+ const schema = schemaOptionsOf(options);
154
+ ctx.output.write(manifestView(invoiceManifest, schema), {
155
+ json: true,
156
+ // 只有 --list 单行化:条目多、缩进空白能吃掉近一半体积,且对读模型无收益。
157
+ ...(schema.list === true ? { compactPaths: MANIFEST_LIST_COMPACT_PATHS } : {}),
158
+ });
150
159
  }));
151
160
  withInvoiceOptions(invoice.command('run')
152
161
  .description('Run an invoice operation with JSON input')
@@ -687,6 +687,7 @@ export const invoiceOperations = [
687
687
  {
688
688
  name: 'invoice.import.prepare',
689
689
  risk: 'read-before-write',
690
+ requiresConfirmation: true,
690
691
  inputSchema: {
691
692
  type: 'object',
692
693
  additionalProperties: false,
@@ -713,6 +714,7 @@ export const invoiceOperations = [
713
714
  {
714
715
  name: 'invoice.import.apply',
715
716
  risk: 'high-risk-write',
717
+ requiresConfirmation: true,
716
718
  inputSchema: {
717
719
  type: 'object',
718
720
  additionalProperties: false,
@@ -735,6 +737,7 @@ export const invoiceOperations = [
735
737
  {
736
738
  name: 'invoice.add.prepare',
737
739
  risk: 'read-before-write',
740
+ requiresConfirmation: true,
738
741
  inputSchema: {
739
742
  type: 'object',
740
743
  additionalProperties: false,
@@ -749,6 +752,7 @@ export const invoiceOperations = [
749
752
  {
750
753
  name: 'invoice.add.apply',
751
754
  risk: 'high-risk-write',
755
+ requiresConfirmation: true,
752
756
  inputSchema: {
753
757
  type: 'object',
754
758
  additionalProperties: false,
@@ -764,6 +768,7 @@ export const invoiceOperations = [
764
768
  {
765
769
  name: 'invoice.update.prepare',
766
770
  risk: 'read-before-write',
771
+ requiresConfirmation: true,
767
772
  inputSchema: {
768
773
  type: 'object',
769
774
  additionalProperties: false,
@@ -798,6 +803,7 @@ export const invoiceOperations = [
798
803
  {
799
804
  name: 'invoice.update.apply',
800
805
  risk: 'high-risk-write',
806
+ requiresConfirmation: true,
801
807
  inputSchema: {
802
808
  type: 'object',
803
809
  additionalProperties: false,
@@ -827,6 +833,7 @@ export const invoiceOperations = [
827
833
  {
828
834
  name: 'invoice.delete.prepare',
829
835
  risk: 'read-before-write',
836
+ requiresConfirmation: true,
830
837
  inputSchema: {
831
838
  type: 'object',
832
839
  additionalProperties: false,
@@ -841,6 +848,7 @@ export const invoiceOperations = [
841
848
  {
842
849
  name: 'invoice.delete.apply',
843
850
  risk: 'high-risk-write',
851
+ requiresConfirmation: true,
844
852
  inputSchema: {
845
853
  type: 'object',
846
854
  additionalProperties: false,
@@ -1,6 +1,7 @@
1
1
  import { readFile } from 'node:fs/promises';
2
2
  import { ExitCode, isCliError, toErrorEnvelope } from '../../core/errors.js';
3
3
  import { reportPlatformError, shouldReportPlatformError, toPlatformError } from '../../core/error-codes.js';
4
+ import { MANIFEST_LIST_COMPACT_PATHS, manifestView } from '../../core/manifest-view.js';
4
5
  import { createJiuchuanhuiContinuationSigner } from './continuation.js';
5
6
  import { createJiuchuanhuiHost } from './host.js';
6
7
  import { getJiuchuanhuiOperationContract, jiuchuanhuiManifest } from './manifest.js';
@@ -123,16 +124,29 @@ export const jiuchuanhuiShortcut = {
123
124
  const jiuchuanhui = program.command('jiuchuanhui').description('泛微E10九氚汇营销管理');
124
125
  jiuchuanhui.command('schema')
125
126
  .description('Print jiuchuanhui operation manifest for agents')
127
+ .option('--list', '只列操作清单(name/summary/risk),全量不截断;判断"有没有某操作"用这个')
128
+ .option('--full', '打印完整 manifest(超 stdout 预算会落本地 ref,用 refs get 分页取)')
126
129
  .option('--operation <name>', 'print the contract for one operation')
127
130
  .action(action((ctx, options) => {
128
- const { operation } = asOptions(options);
131
+ const { operation, list } = asOptions(options);
129
132
  if (operation === undefined) {
133
+ if (list === true) {
134
+ // 完整 manifest 有 73,937 字符,超过预算后 operations 只剩 20/90,入参定义几乎全丢。
135
+ ctx.output.write(manifestView(jiuchuanhuiManifest, { list: true }), {
136
+ json: true,
137
+ compactPaths: MANIFEST_LIST_COMPACT_PATHS,
138
+ });
139
+ return;
140
+ }
130
141
  ctx.output.write(jiuchuanhuiManifest, { json: true });
131
142
  return;
132
143
  }
133
144
  const contract = getJiuchuanhuiOperationContract(operation);
134
145
  if (!contract)
135
146
  throw jiuchuanhuiValidationError('operation_unknown', `九氚汇不支持操作:${operation}`);
147
+ // 保持原契约:这里输出**裸 contract 对象**(`jiuchuanhui-operations.test.ts` 用 deepEqual 锁定),
148
+ // 与 invoice/caizhilian/meeting 的 `{operation: ...}` 包裹结构不同,属于历史不一致,
149
+ // 铺开统一时再收敛,不在此处破坏既有断言。
136
150
  ctx.output.write(contract, { json: true });
137
151
  }));
138
152
  jiuchuanhui.command('run')
@@ -32,6 +32,7 @@ function writePair(baseName, title, props, required = [], fixed = {}, withPrepar
32
32
  list.push({
33
33
  name: `${baseName}.prepare`,
34
34
  risk: 'read-before-write',
35
+ requiresConfirmation: true,
35
36
  fixed: { ...fixed, stage: 'prepare' },
36
37
  inputSchema: {
37
38
  type: 'object',
@@ -51,6 +52,7 @@ function writePair(baseName, title, props, required = [], fixed = {}, withPrepar
51
52
  list.push({
52
53
  name: `${baseName}.apply`,
53
54
  risk: 'high-risk-write',
55
+ requiresConfirmation: true,
54
56
  fixed: { ...fixed, stage: 'apply' },
55
57
  inputSchema: {
56
58
  type: '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
  },
@@ -3,6 +3,7 @@ import { statSync, readFileSync } from 'node:fs';
3
3
  import { extname } from 'node:path';
4
4
  import { mailRandomKey } from '../host.js';
5
5
  import { WRITE, mailSuccess, schemaOf, SCHEMA_STRING } from './types.js';
6
+ import { mailValidationError, mailUpstreamError } from '../errors.js';
6
7
  const MIME_BY_EXT = {
7
8
  txt: 'text/plain',
8
9
  html: 'text/html',
@@ -48,7 +49,7 @@ const opStar = {
48
49
  const id = String(args.id || '').trim();
49
50
  const star = String(args.star ?? '1');
50
51
  if (!id)
51
- throw new Error('id(邮件 id)必填');
52
+ throw mailValidationError('id_required', 'id(邮件 id)必填');
52
53
  const value = (await env.host.request({
53
54
  path: '/api/mail/base/resource/starMail',
54
55
  method: 'POST',
@@ -69,7 +70,7 @@ const opReadStatus = {
69
70
  const id = String(args.id || '').trim();
70
71
  const read = String(args.read ?? '1');
71
72
  if (!id)
72
- throw new Error('id(邮件 id)必填');
73
+ throw mailValidationError('id_required', 'id(邮件 id)必填');
73
74
  const value = (await env.host.request({
74
75
  path: '/api/mail/base/resource/setMailReadStatus',
75
76
  method: 'POST',
@@ -114,7 +115,7 @@ const opWaitAdd = {
114
115
  async handler(args, env) {
115
116
  const id = String(args.id || '').trim();
116
117
  if (!id)
117
- throw new Error('id(邮件 id)必填');
118
+ throw mailValidationError('id_required', 'id(邮件 id)必填');
118
119
  const content = args.title ? String(args.title) : await fetchSubject(env, id);
119
120
  const processTime = args.endDate ? String(args.endDate) : '';
120
121
  const reminderTime = args.reminderTime ? String(args.reminderTime) : '';
@@ -144,9 +145,9 @@ const opMoveFolder = {
144
145
  const id = String(args.id || '').trim();
145
146
  const folder = String(args.folder || '').trim();
146
147
  if (!id)
147
- throw new Error('id(邮件 id)必填');
148
+ throw mailValidationError('id_required', 'id(邮件 id)必填');
148
149
  if (!folder)
149
- throw new Error('folder(目标文件夹 id)必填');
150
+ throw mailValidationError('folder_required', 'folder(目标文件夹 id)必填');
150
151
  const value = (await env.host.request({
151
152
  path: '/api/mail/base/resource/moveMailToFolder',
152
153
  method: 'POST',
@@ -166,7 +167,7 @@ const opDeleteMove = {
166
167
  async handler(args, env) {
167
168
  const id = String(args.id || '').trim();
168
169
  if (!id)
169
- throw new Error('id(邮件 id)必填');
170
+ throw mailValidationError('id_required', 'id(邮件 id)必填');
170
171
  const value = (await env.host.request({
171
172
  path: '/api/mail/base/resource/deleteMailResourceByMoveBatch',
172
173
  method: 'POST',
@@ -190,7 +191,7 @@ const opFolderCreate = {
190
191
  async handler(args, env) {
191
192
  const name = String(args.name || '').trim();
192
193
  if (!name)
193
- throw new Error('name(文件夹名)必填');
194
+ throw mailValidationError('folder_name_required', 'name(文件夹名)必填');
194
195
  const body = { name };
195
196
  if (args.id)
196
197
  body.id = String(args.id);
@@ -209,7 +210,7 @@ const opFolderDelete = {
209
210
  async handler(args, env) {
210
211
  const id = String(args.id || '').trim();
211
212
  if (!id)
212
- throw new Error('id(文件夹 id)必填');
213
+ throw mailValidationError('id_required', 'id(文件夹 id)必填');
213
214
  const value = (await env.host.request({ path: '/api/mail/base/setting/folder/deleteMailFolder', method: 'POST', body: { id } }));
214
215
  return mailSuccess('mail.folder.delete', value?.data ?? 'SUCCESS', { id });
215
216
  },
@@ -225,7 +226,7 @@ const opRecall = {
225
226
  async handler(args, env) {
226
227
  const id = String(args.id || '').trim();
227
228
  if (!id)
228
- throw new Error('id(邮件 id)必填');
229
+ throw mailValidationError('id_required', 'id(邮件 id)必填');
229
230
  const value = (await env.host.request({ path: '/api/mail/base/recallMail', method: 'POST', body: { mailResourceId: id, ids: id } }));
230
231
  const d = value?.data || {};
231
232
  return mailSuccess('mail.recall', { success: d.success === 1, msg: d.msg }, { id });
@@ -242,7 +243,7 @@ const opAttachmentUpload = {
242
243
  async handler(args, env) {
243
244
  const filePath = String(args.file || '').trim();
244
245
  if (!filePath)
245
- throw new Error('file(本地文件路径)必填');
246
+ throw mailValidationError('file_required', 'file(本地文件路径)必填');
246
247
  const name = args.name ? String(args.name) : filePath.split(/[\\/]/).pop() || 'attachment';
247
248
  let buffer;
248
249
  let size;
@@ -252,7 +253,7 @@ const opAttachmentUpload = {
252
253
  buffer = readFileSync(filePath);
253
254
  }
254
255
  catch {
255
- throw new Error('无法读取本地文件:' + filePath);
256
+ throw mailValidationError('file_unreadable', '无法读取本地文件:' + filePath);
256
257
  }
257
258
  const md5 = createHash('md5').update(buffer).digest('hex');
258
259
  const lastModified = Date.now();
@@ -275,7 +276,7 @@ const opAttachmentUpload = {
275
276
  }));
276
277
  const preUploadId = precheck?.data?.preUploadId;
277
278
  if (!preUploadId)
278
- throw new Error('附件预检未返回 preUploadId:' + JSON.stringify(precheck?.data).slice(0, 200));
279
+ throw mailUpstreamError('attachment_precheck_contract', '附件预检未返回 preUploadId:' + JSON.stringify(precheck?.data).slice(0, 200));
279
280
  const upload = (await env.host.request({
280
281
  path: '/api/file/module/upload',
281
282
  method: 'POST',
@@ -283,7 +284,7 @@ const opAttachmentUpload = {
283
284
  }));
284
285
  const fileid = upload?.data?.fileid;
285
286
  if (!fileid)
286
- throw new Error('附件上传未返回 fileid:' + JSON.stringify(upload?.data).slice(0, 200));
287
+ throw mailUpstreamError('attachment_upload_contract', '附件上传未返回 fileid:' + JSON.stringify(upload?.data).slice(0, 200));
287
288
  await env.host.request({
288
289
  path: '/api/mail/base/add/addPermissionFile',
289
290
  method: 'POST',
@@ -303,7 +304,7 @@ const opAttachmentDownload = {
303
304
  async handler(args, env) {
304
305
  const ids = String(args.ids || '').trim();
305
306
  if (!ids)
306
- throw new Error('ids(附件 id)必填');
307
+ throw mailValidationError('ids_required', 'ids(附件 id)必填');
307
308
  const value = (await env.host.request({
308
309
  path: '/api/mail/base/file/batchDownload',
309
310
  method: 'POST',