weaver-work-cli 0.1.8 → 0.1.20

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 (263) hide show
  1. package/README.md +11 -11
  2. package/dist/cmd/action.js +76 -0
  3. package/dist/cmd/index.js +2 -0
  4. package/dist/cmd/refs/index.js +103 -0
  5. package/dist/cmd/register.js +31 -0
  6. package/dist/cmd/root.js +1 -0
  7. package/dist/cmd/setup/index.js +25 -5
  8. package/dist/cmd/skills/index.js +37 -5
  9. package/dist/core/connector.js +54 -0
  10. package/dist/core/context.js +2 -1
  11. package/dist/core/input.js +48 -0
  12. package/dist/core/output.js +298 -3
  13. package/dist/core/refs.js +432 -0
  14. package/dist/core/state.js +26 -0
  15. package/dist/internal/e10/auth/commands.js +2 -2
  16. package/dist/internal/e10/auth/session.js +14 -0
  17. package/dist/internal/e10/auth/xiaoe.js +116 -51
  18. package/dist/internal/e10/request-runtime.js +5 -0
  19. package/dist/internal/skills/install.js +148 -28
  20. package/dist/internal/skills/reader.js +12 -9
  21. package/dist/shortcuts/blog/continuation.js +74 -0
  22. package/dist/shortcuts/blog/errors.js +60 -0
  23. package/dist/shortcuts/blog/host.js +175 -0
  24. package/dist/shortcuts/blog/index.js +324 -0
  25. package/dist/shortcuts/blog/manifest.js +415 -0
  26. package/dist/shortcuts/blog/operations/comment.js +125 -0
  27. package/dist/shortcuts/blog/operations/comments.js +31 -0
  28. package/dist/shortcuts/blog/operations/edit.js +131 -0
  29. package/dist/shortcuts/blog/operations/export.js +46 -0
  30. package/dist/shortcuts/blog/operations/like.js +80 -0
  31. package/dist/shortcuts/blog/operations/publish.js +157 -0
  32. package/dist/shortcuts/blog/operations/query-user.js +58 -0
  33. package/dist/shortcuts/blog/operations/query.js +96 -0
  34. package/dist/shortcuts/blog/operations/registry.js +54 -0
  35. package/dist/shortcuts/blog/operations/remind.js +176 -0
  36. package/dist/shortcuts/blog/operations/shared.js +330 -0
  37. package/dist/shortcuts/blog/operations/types.js +16 -0
  38. package/dist/shortcuts/blog/operations.js +9 -0
  39. package/dist/shortcuts/caizhilian/continuation.js +70 -0
  40. package/dist/shortcuts/caizhilian/errors.js +53 -0
  41. package/dist/shortcuts/caizhilian/host.js +190 -0
  42. package/dist/shortcuts/caizhilian/index.js +186 -0
  43. package/dist/shortcuts/caizhilian/manifest.js +42 -0
  44. package/dist/shortcuts/caizhilian/operations/api.js +801 -0
  45. package/dist/shortcuts/caizhilian/operations/confirm.js +75 -0
  46. package/dist/shortcuts/caizhilian/operations/files.js +306 -0
  47. package/dist/shortcuts/caizhilian/operations/form.js +170 -0
  48. package/dist/shortcuts/caizhilian/operations/handlers/collab.js +611 -0
  49. package/dist/shortcuts/caizhilian/operations/handlers/document.js +890 -0
  50. package/dist/shortcuts/caizhilian/operations/handlers/file-collection.js +346 -0
  51. package/dist/shortcuts/caizhilian/operations/handlers/file-upload.js +192 -0
  52. package/dist/shortcuts/caizhilian/operations/handlers/fileops.js +570 -0
  53. package/dist/shortcuts/caizhilian/operations/handlers/folder.js +969 -0
  54. package/dist/shortcuts/caizhilian/operations/handlers/search.js +318 -0
  55. package/dist/shortcuts/caizhilian/operations/handlers/setting-attach.js +294 -0
  56. package/dist/shortcuts/caizhilian/operations/handlers/setting-backup.js +423 -0
  57. package/dist/shortcuts/caizhilian/operations/handlers/setting-encrypt.js +238 -0
  58. package/dist/shortcuts/caizhilian/operations/handlers/setting-storage.js +364 -0
  59. package/dist/shortcuts/caizhilian/operations/handlers/system.js +106 -0
  60. package/dist/shortcuts/caizhilian/operations/registry.js +151 -0
  61. package/dist/shortcuts/caizhilian/operations/shared.js +408 -0
  62. package/dist/shortcuts/caizhilian/operations/specs.js +623 -0
  63. package/dist/shortcuts/caizhilian/operations/types.js +57 -0
  64. package/dist/shortcuts/caizhilian/operations.js +21 -0
  65. package/dist/shortcuts/contract/continuation.js +70 -0
  66. package/dist/shortcuts/contract/errors.js +62 -0
  67. package/dist/shortcuts/contract/host.js +205 -0
  68. package/dist/shortcuts/contract/index.js +318 -0
  69. package/dist/shortcuts/contract/manifest.js +596 -0
  70. package/dist/shortcuts/contract/operations/clause-reference.js +78 -0
  71. package/dist/shortcuts/contract/operations/form-info.js +371 -0
  72. package/dist/shortcuts/contract/operations/read.js +118 -0
  73. package/dist/shortcuts/contract/operations/registry.js +43 -0
  74. package/dist/shortcuts/contract/operations/request.js +300 -0
  75. package/dist/shortcuts/contract/operations/shared.js +133 -0
  76. package/dist/shortcuts/contract/operations/subject.js +157 -0
  77. package/dist/shortcuts/contract/operations/template.js +81 -0
  78. package/dist/shortcuts/contract/operations/types.js +7 -0
  79. package/dist/shortcuts/contract/operations/workflow.js +52 -0
  80. package/dist/shortcuts/contract/operations/write.js +131 -0
  81. package/dist/shortcuts/contract/operations.js +8 -0
  82. package/dist/shortcuts/hrm/index.js +83 -2
  83. package/dist/shortcuts/hrm/operations/employee.js +160 -30
  84. package/dist/shortcuts/hrm/operations/org.js +17 -3
  85. package/dist/shortcuts/hrm/operations/position.js +18 -2
  86. package/dist/shortcuts/index.js +5 -1
  87. package/dist/shortcuts/invoice/index.js +74 -36
  88. package/dist/shortcuts/invoice/manifest.js +674 -4
  89. package/dist/shortcuts/invoice/markdown.js +172 -0
  90. package/dist/shortcuts/invoice/operations/add.js +3 -3
  91. package/dist/shortcuts/invoice/operations/delete.js +2 -2
  92. package/dist/shortcuts/invoice/operations/get.js +10 -2
  93. package/dist/shortcuts/invoice/operations/import.js +2 -2
  94. package/dist/shortcuts/invoice/operations/registry.js +8 -1
  95. package/dist/shortcuts/invoice/operations/reim-auto.js +719 -0
  96. package/dist/shortcuts/invoice/operations/reim.js +85 -2
  97. package/dist/shortcuts/invoice/operations/shared.js +75 -8
  98. package/dist/shortcuts/invoice/operations/update.js +2 -2
  99. package/dist/shortcuts/invoice/operations/upload-and-validate.js +93 -0
  100. package/dist/shortcuts/invoice/operations/validate-preview.js +2 -1
  101. package/dist/shortcuts/invoice/projection.js +328 -0
  102. package/dist/shortcuts/meeting/host.js +18 -1
  103. package/dist/shortcuts/meeting/manifest.js +30 -18
  104. package/dist/shortcuts/meeting/operations/eb/catalog.js +390 -0
  105. package/dist/shortcuts/meeting/operations/eb/conflict.js +389 -0
  106. package/dist/shortcuts/meeting/operations/eb/factory.js +389 -0
  107. package/dist/shortcuts/meeting/operations/eb/index.js +22 -0
  108. package/dist/shortcuts/meeting/operations/env.js +8 -1
  109. package/dist/shortcuts/meeting/operations/registry.js +2 -0
  110. package/dist/shortcuts/meeting/operations/signs.js +216 -2
  111. package/dist/shortcuts/workflow/endpoints.js +2 -1
  112. package/dist/shortcuts/workflow/errors.js +8 -2
  113. package/dist/shortcuts/workflow/host.js +6 -3
  114. package/dist/shortcuts/workflow/operations/form.js +931 -589
  115. package/dist/shortcuts/workflow/operations/read.js +128 -205
  116. package/dist/shortcuts/workflow/operations/shared.js +21 -0
  117. package/dist/shortcuts/workflow/operations/write.js +750 -52
  118. package/dist/shortcuts/workflow/operations.js +36 -10
  119. package/docs/_catalog.md +6 -0
  120. package/docs/agent-invoice.md +5 -1
  121. package/docs/agent-io-channel-design.md +468 -0
  122. package/docs/agent-skill-install.md +9 -4
  123. package/docs/blog.md +123 -0
  124. package/docs/caizhilian.md +304 -0
  125. package/docs/contract.md +91 -0
  126. package/docs/e10-auth.md +2 -2
  127. package/docs/hrm.md +19 -9
  128. package/docs/invoice.md +5 -1
  129. package/docs/meeting.md +1 -1
  130. package/docs/operation-manual.md +15 -3
  131. package/docs/skill-review-2026-09-19.md +2 -2
  132. package/package.json +2 -2
  133. package/scripts/package-skill.mjs +32 -20
  134. package/skill-template/business-info.json +113 -14
  135. package/skill-template/domains/blog.md +24 -0
  136. package/skill-template/domains/caizhilian.md +22 -0
  137. package/skill-template/domains/jinchengda.md +23 -0
  138. package/skill-template/domains/meeting.md +1 -1
  139. package/skill-template/domains/workflow.md +1 -1
  140. package/skill-template/skill-template.md +1 -1
  141. package/skills/weaver-e10-blog/SKILL.md +111 -0
  142. package/skills/weaver-e10-blog/references/blog-comment.md +51 -0
  143. package/skills/weaver-e10-blog/references/blog-comments.md +39 -0
  144. package/skills/weaver-e10-blog/references/blog-default-permission.md +38 -0
  145. package/skills/weaver-e10-blog/references/blog-disabled-capabilities.md +11 -0
  146. package/skills/weaver-e10-blog/references/blog-edit.md +51 -0
  147. package/skills/weaver-e10-blog/references/blog-export.md +42 -0
  148. package/skills/weaver-e10-blog/references/blog-like.md +50 -0
  149. package/skills/weaver-e10-blog/references/blog-publish.md +52 -0
  150. package/skills/weaver-e10-blog/references/blog-query-user.md +45 -0
  151. package/skills/weaver-e10-blog/references/blog-query.md +49 -0
  152. package/skills/weaver-e10-blog/references/blog-remind.md +51 -0
  153. package/skills/weaver-e10-blog/references/blog-resolve-users.md +38 -0
  154. package/skills/weaver-e10-blog/references/source-manifest.json +1540 -0
  155. package/skills/weaver-e10-caizhilian/SKILL.md +216 -0
  156. package/skills/weaver-e10-caizhilian/references/agent-entry.md +106 -0
  157. package/skills/weaver-e10-caizhilian/references/collaboration.md +112 -0
  158. package/skills/weaver-e10-caizhilian/references/document.md +111 -0
  159. package/skills/weaver-e10-caizhilian/references/file-collection.md +136 -0
  160. package/skills/weaver-e10-caizhilian/references/file-upload.md +309 -0
  161. package/skills/weaver-e10-caizhilian/references/files.md +120 -0
  162. package/skills/weaver-e10-caizhilian/references/folder.md +118 -0
  163. package/skills/weaver-e10-caizhilian/references/org-browser.md +104 -0
  164. package/skills/weaver-e10-caizhilian/references/setting-attach.md +410 -0
  165. package/skills/weaver-e10-caizhilian/references/setting-backup.md +372 -0
  166. package/skills/weaver-e10-caizhilian/references/setting-encrypt.md +399 -0
  167. package/skills/weaver-e10-caizhilian/references/setting-storage.md +603 -0
  168. package/skills/weaver-e10-caizhilian/references/source-manifest.json +5079 -0
  169. package/skills/weaver-e10-caizhilian/references/withheld.md +93 -0
  170. package/skills/weaver-e10-caizhilian/references/write-protocol.md +120 -0
  171. package/skills/weaver-e10-calendar/SKILL.md +4 -3
  172. package/skills/weaver-e10-ebuilder-form/SKILL.md +4 -9
  173. package/skills/weaver-e10-ebuilder-form/references/context-routing.md +0 -9
  174. package/skills/weaver-e10-ebuilder-form/references/custom-api.md +1 -5
  175. package/skills/weaver-e10-ebuilder-form/references/fields-browser.md +1 -5
  176. package/skills/weaver-e10-ebuilder-form/references/list-nlist.md +1 -5
  177. package/skills/weaver-e10-ebuilder-form/references/openapi-read.md +1 -5
  178. package/skills/weaver-e10-ebuilder-form/references/openapi-write.md +1 -5
  179. package/skills/weaver-e10-esb/SKILL.md +2 -2
  180. package/skills/weaver-e10-esb/references/source-manifest.json +9 -9
  181. package/skills/weaver-e10-hrm/SKILL.md +54 -6
  182. package/skills/weaver-e10-hrm/references/employee.md +89 -15
  183. package/skills/weaver-e10-hrm/references/org.md +7 -4
  184. package/skills/weaver-e10-hrm/references/position.md +14 -7
  185. package/skills/weaver-e10-hrm/references/source-manifest.json +1 -1
  186. package/skills/weaver-e10-jinchengda/SKILL.md +166 -0
  187. package/skills/weaver-e10-jinchengda/references/contract-agent-entry.md +82 -0
  188. package/skills/weaver-e10-jinchengda/references/contract-clause-recommender.md +69 -0
  189. package/skills/weaver-e10-jinchengda/references/contract-clause-reference-save.md +78 -0
  190. package/skills/weaver-e10-jinchengda/references/contract-disabled-capabilities.md +27 -0
  191. package/skills/weaver-e10-jinchengda/references/contract-request-status.md +71 -0
  192. package/skills/weaver-e10-jinchengda/references/contract-request-write.md +94 -0
  193. package/skills/weaver-e10-jinchengda/references/contract-signing-subjects.md +89 -0
  194. package/skills/weaver-e10-jinchengda/references/contract-subject-create.md +77 -0
  195. package/skills/weaver-e10-jinchengda/references/contract-template-selector.md +66 -0
  196. package/skills/weaver-e10-jinchengda/references/contract-workflow-discovery.md +94 -0
  197. package/skills/weaver-e10-jinchengda/references/source-manifest.json +259 -0
  198. package/skills/weaver-e10-jiuchuanhui/SKILL.md +5 -11
  199. package/skills/weaver-e10-jucailin/SKILL.md +4 -3
  200. package/skills/weaver-e10-mail/SKILL.md +4 -11
  201. package/skills/weaver-e10-meeting/SKILL.md +66 -32
  202. package/skills/weaver-e10-meeting/references/meeting-change.md +5 -2
  203. package/skills/weaver-e10-meeting/references/meeting-create.md +2 -1
  204. package/skills/weaver-e10-meeting/references/meeting-eb.md +114 -0
  205. package/skills/weaver-e10-meeting/references/meeting-lifecycle.md +9 -8
  206. package/skills/weaver-e10-meeting/references/meeting-receipts-signs.md +35 -7
  207. package/skills/weaver-e10-meeting/references/meeting-update.md +1 -1
  208. package/skills/weaver-e10-okr/SKILL.md +6 -11
  209. package/skills/weaver-e10-okr/references/source-manifest.json +3 -3
  210. package/skills/weaver-e10-plan/SKILL.md +3 -3
  211. package/skills/weaver-e10-plan/references/plan-collect-and-compose.md +1 -1
  212. package/skills/weaver-e10-plan/references/plan-overview-and-routing.md +1 -1
  213. package/skills/weaver-e10-plan/references/source-manifest.json +13 -13
  214. package/skills/weaver-e10-qiyecheng/SKILL.md +4 -10
  215. package/skills/weaver-e10-qiyecheng/references/source-manifest.json +9 -9
  216. package/skills/weaver-e10-shared/SKILL.md +36 -25
  217. package/skills/weaver-e10-shared/references/e10-auth-and-session.md +10 -31
  218. package/skills/weaver-e10-shared/references/json-output-contract.md +20 -11
  219. package/skills/weaver-e10-shijingran/SKILL.md +2 -1
  220. package/skills/weaver-e10-shijingran/references/source-manifest.json +9 -9
  221. package/skills/weaver-e10-skill-maker/SKILL.md +4 -10
  222. package/skills/weaver-e10-skill-maker/references/business-skill-generation.md +5 -3
  223. package/skills/weaver-e10-skill-maker/references/module-cli-generation.md +12 -27
  224. package/skills/weaver-e10-skill-maker/references/module-gap-audit-and-repair.md +17 -5
  225. package/skills/weaver-e10-skill-maker/references/source-update-detection.md +4 -27
  226. package/skills/weaver-e10-wenshuding/SKILL.md +5 -16
  227. package/skills/weaver-e10-wenshuding/references/source-manifest.json +7 -7
  228. package/skills/weaver-e10-workflow/SKILL.md +32 -37
  229. package/skills/weaver-e10-workflow/references/source-manifest.json +39 -75
  230. package/skills/weaver-e10-workflow/references/workflow-batch.md +90 -29
  231. package/skills/weaver-e10-workflow/references/workflow-create.md +79 -109
  232. package/skills/weaver-e10-workflow/references/workflow-memory.md +19 -9
  233. package/skills/weaver-e10-workflow/references/workflow-operate.md +2 -2
  234. package/skills/weaver-e10-workflow/references/workflow-query.md +38 -20
  235. package/skills/weaver-e10-workflow/references/workflow-share.md +18 -2
  236. package/skills/weaver-e10-workflow/references/workflow-view.md +3 -4
  237. package/skills/weaver-e10-yepiaotong/SKILL.md +75 -39
  238. package/skills/weaver-e10-yepiaotong/references/invoice-detail.md +22 -1
  239. package/skills/weaver-e10-yepiaotong/references/invoice-enterprise-list.md +3 -1
  240. package/skills/weaver-e10-yepiaotong/references/invoice-output-view.md +135 -0
  241. package/skills/weaver-e10-yepiaotong/references/invoice-personal-list.md +15 -3
  242. package/skills/weaver-e10-yepiaotong/references/invoice-reim.md +1 -1
  243. package/skills/weaver-e10-yepiaotong/references/invoice-summarize.py +217 -0
  244. package/skills/weaver-e10-yepiaotong/references/invoice-upload-and-validate.md +88 -0
  245. package/skills/weaver-e10-yepiaotong/references/invoice-validation-preview.md +7 -2
  246. package/skills/weaver-e10-yepiaotong/references/reim-api-reference.md +89 -9
  247. package/skills/weaver-e10-yepiaotong/references/reim-examples.md +1 -0
  248. package/skills/weaver-e10-yepiaotong/references/reim-expense-subject-rules.md +70 -49
  249. package/skills/weaver-e10-yepiaotong/references/reim-fast-path.md +119 -0
  250. package/skills/weaver-e10-yepiaotong/references/reim-form-fill-rules.md +55 -36
  251. package/skills/weaver-e10-yepiaotong/references/reim-matching-rules.md +4 -0
  252. package/skills/weaver-e10-yepiaotong/references/reim-phone-subsidy-rules.md +149 -0
  253. package/skills/weaver-e10-yepiaotong/references/reim-workflow.md +125 -5
  254. package/skills/weaver-e10-yepiaotong/references/source-manifest.json +430 -63
  255. package/skills/weaver-e10-yimiaoban/SKILL.md +4 -12
  256. package/skills/weaver-e10-yimiaoban/references/source-manifest.json +3 -3
  257. package/skills/weaver-e10-ziguanjia/SKILL.md +2 -1
  258. package/skills/weaver-e10-ziguanjia/references/ziguanjia-agent-entry.md +3 -3
  259. package/tools/weaver-skill-detector-1.0.13/SKILL.md +9 -9
  260. package/tools/weaver-skill-detector-1.0.13/references/checklist.md +3 -3
  261. package/tools/weaver-skill-detector-1.0.13/scripts/__pycache__/validate_skill.cpython-313.pyc +0 -0
  262. package/tools/weaver-skill-detector-1.0.13/scripts/validate_skill.py +98 -91
  263. package/scripts/sync-connector-skills.mjs +0 -172
@@ -0,0 +1,318 @@
1
+ import { readFile } from 'node:fs/promises';
2
+ import { ExitCode, isCliError, toErrorEnvelope } from '../../core/errors.js';
3
+ import { createContractContinuationSigner } from './continuation.js';
4
+ import { contractValidationError } from './errors.js';
5
+ import { createContractHost } from './host.js';
6
+ import { contractManifest } from './manifest.js';
7
+ import { executeContractOperation } from './operations.js';
8
+ function asOptions(value) {
9
+ return value && typeof value === 'object' && !Array.isArray(value) ? value : {};
10
+ }
11
+ function optionName(flag) {
12
+ const match = /--([^<\s[]+)/u.exec(flag);
13
+ if (!match)
14
+ return flag;
15
+ const parts = match[1].split('-');
16
+ return parts[0] + parts.slice(1).map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join('');
17
+ }
18
+ async function readStdin() {
19
+ const chunks = [];
20
+ for await (const chunk of process.stdin) {
21
+ chunks.push(Buffer.isBuffer(chunk) ? Buffer.from(chunk) : chunk);
22
+ }
23
+ return Buffer.concat(chunks).toString('utf8');
24
+ }
25
+ export async function inputFrom(options, extra = {}) {
26
+ const opts = asOptions(options);
27
+ let input = {};
28
+ if (opts.input && opts.inputJson) {
29
+ throw contractValidationError('input_conflict', '不能同时传 --input 和 --input-json');
30
+ }
31
+ if (opts.inputJson)
32
+ input = parseJsonInput(String(opts.inputJson), '--input-json');
33
+ if (opts.input) {
34
+ let raw;
35
+ try {
36
+ raw = opts.input === '-' ? await readStdin() : await readFile(String(opts.input), 'utf8');
37
+ }
38
+ catch {
39
+ throw contractValidationError('input_unreadable', `无法读取 --input:${String(opts.input)}`);
40
+ }
41
+ input = parseJsonInput(raw, '--input');
42
+ }
43
+ return {
44
+ ...input,
45
+ ...Object.fromEntries(Object.entries(extra).filter(([, value]) => value !== undefined && value !== '')),
46
+ };
47
+ }
48
+ function parseJsonInput(raw, label) {
49
+ try {
50
+ const parsed = JSON.parse(raw.replace(/^/u, ''));
51
+ if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) {
52
+ throw new Error('input must be an object');
53
+ }
54
+ return parsed;
55
+ }
56
+ catch {
57
+ throw contractValidationError('input_invalid', `${label} 不是合法 JSON 对象`);
58
+ }
59
+ }
60
+ function mapOptions(options, specs) {
61
+ const opts = asOptions(options);
62
+ const result = {};
63
+ for (const spec of specs) {
64
+ if (!spec.key)
65
+ continue;
66
+ const value = opts[optionName(spec.flag)];
67
+ if (value === undefined || value === null || value === '')
68
+ continue;
69
+ if (spec.kind === 'int') {
70
+ const parsed = Number(value);
71
+ if (Number.isInteger(parsed))
72
+ result[spec.key] = parsed;
73
+ }
74
+ else if (spec.kind === 'bool') {
75
+ if (typeof value === 'boolean')
76
+ result[spec.key] = value;
77
+ }
78
+ else {
79
+ result[spec.key] = String(value);
80
+ }
81
+ }
82
+ return result;
83
+ }
84
+ function successEnvelope(operation, result) {
85
+ return {
86
+ schemaVersion: 1,
87
+ ok: true,
88
+ operation,
89
+ data: result.data,
90
+ meta: { status: result.status },
91
+ warnings: [],
92
+ };
93
+ }
94
+ function failureEnvelope(error) {
95
+ const structured = error;
96
+ return {
97
+ schemaVersion: 1,
98
+ ok: false,
99
+ ...(structured?.partialData === undefined ? {} : { data: structured.partialData }),
100
+ error: toErrorEnvelope(error),
101
+ };
102
+ }
103
+ async function executeAndPrint(ctx, operation, input) {
104
+ try {
105
+ const result = await executeContractOperation(operation, input, {
106
+ host: createContractHost(ctx),
107
+ continuation: createContractContinuationSigner(ctx),
108
+ });
109
+ ctx.output.write(successEnvelope(operation, result), { json: true });
110
+ }
111
+ catch (error) {
112
+ console.error(JSON.stringify(failureEnvelope(error), null, 2));
113
+ process.exitCode = isCliError(error) ? error.exitCode : ExitCode.GeneralError;
114
+ }
115
+ }
116
+ const JSON_INPUT_FLAGS = [
117
+ { flag: '--input <path>', description: 'JSON input file, or - for stdin' },
118
+ { flag: '--input-json <json>', description: 'inline JSON input object' },
119
+ ];
120
+ const CONTINUATION_FLAGS = [
121
+ { flag: '--continuation <token>', description: 'continuation token from prepare', key: 'continuation' },
122
+ { flag: '--yes', description: 'confirm the write operation', key: 'confirm', kind: 'bool' },
123
+ ];
124
+ export const contractShortcut = {
125
+ name: 'contract',
126
+ description: '泛微E10今承达合同管理 CLI',
127
+ category: 'shortcut',
128
+ register({ program, action }) {
129
+ const wrap = (handler) => action(handler);
130
+ const registerCommand = (parent, name, description, operation, specs = []) => {
131
+ const command = parent.command(name).description(description);
132
+ for (const spec of [...specs, ...JSON_INPUT_FLAGS])
133
+ command.option(spec.flag, spec.description);
134
+ command.action(wrap(async (ctx, options) => {
135
+ await executeAndPrint(ctx, operation, await inputFrom(options, mapOptions(options, specs)));
136
+ }));
137
+ return command;
138
+ };
139
+ const contract = program.command('contract').description('泛微E10今承达合同管理');
140
+ contract.command('schema')
141
+ .description('Print contract operation manifest for agents')
142
+ .action(wrap((ctx) => {
143
+ ctx.output.write(contractManifest, { json: true });
144
+ }));
145
+ const run = contract.command('run')
146
+ .description('Run a contract operation with JSON input')
147
+ .argument('<operation>', 'operation name, e.g. contract.type.tree');
148
+ for (const spec of JSON_INPUT_FLAGS)
149
+ run.option(spec.flag, spec.description);
150
+ run.action(wrap(async (ctx, operation, options) => {
151
+ await executeAndPrint(ctx, String(operation), await inputFrom(options));
152
+ }));
153
+ const type = contract.command('type').description('Contract type commands');
154
+ registerCommand(type, 'tree', 'List all contract types', 'contract.type.tree');
155
+ const template = contract.command('template').description('Contract template commands');
156
+ registerCommand(template, 'tree', 'List template category tree', 'contract.template.tree', [
157
+ { flag: '--tree-name <name>', description: 'tree name filter', key: 'treeName' },
158
+ { flag: '--parent-id <id>', description: 'parent node id', key: 'parentId' },
159
+ { flag: '--tree-type <type>', description: 'tree type', key: 'treeType', kind: 'int' },
160
+ { flag: '--app-id <id>', description: 'application id', key: 'appId' },
161
+ ]);
162
+ registerCommand(template, 'list', 'List templates with paging', 'contract.template.list', [
163
+ { flag: '--template-name <name>', description: 'template name keyword', key: 'templateName' },
164
+ { flag: '--belong-id <id>', description: 'template category id', key: 'belongId' },
165
+ { flag: '--contract-type <id>', description: 'contract type id', key: 'contractType' },
166
+ { flag: '--template-status <status>', description: '0 disabled, 1 enabled', key: 'templateStatus', kind: 'int' },
167
+ { flag: '--page-no <n>', description: 'page number', key: 'pageNo', kind: 'int' },
168
+ { flag: '--page-size <n>', description: 'page size', key: 'pageSize', kind: 'int' },
169
+ ]);
170
+ registerCommand(template, 'detail', 'Get template detail by id', 'contract.template.detail', [
171
+ { flag: '--id <id>', description: 'template id', key: 'id' },
172
+ ]);
173
+ const clause = contract.command('clause').description('Contract clause commands');
174
+ registerCommand(clause, 'tree', 'List clause category tree', 'contract.clause.tree');
175
+ registerCommand(clause, 'list', 'List clauses with paging', 'contract.clause.list', [
176
+ { flag: '--belong-id <id>', description: 'clause category id', key: 'belongId' },
177
+ { flag: '--clause-name <name>', description: 'clause name keyword', key: 'clauseName' },
178
+ { flag: '--contract-type <id>', description: 'contract type id', key: 'contractType' },
179
+ { flag: '--page-no <n>', description: 'page number', key: 'pageNo', kind: 'int' },
180
+ { flag: '--page-size <n>', description: 'page size', key: 'pageSize', kind: 'int' },
181
+ ]);
182
+ registerCommand(clause, 'groups', 'List clause groups', 'contract.clause.group.list', [
183
+ { flag: '--belong-id <id>', description: 'clause category id', key: 'belongId' },
184
+ { flag: '--contract-type <id>', description: 'contract type id', key: 'contractType' },
185
+ { flag: '--page-no <n>', description: 'page number', key: 'pageNo', kind: 'int' },
186
+ { flag: '--page-size <n>', description: 'page size', key: 'pageSize', kind: 'int' },
187
+ ]);
188
+ registerCommand(clause, 'search', 'Search clauses', 'contract.clause.search', [
189
+ { flag: '--title <title>', description: 'clause title keyword', key: 'title' },
190
+ { flag: '--tag-id <id>', description: 'clause tag id', key: 'tagId' },
191
+ { flag: '--content <text>', description: 'clause content keyword', key: 'content' },
192
+ { flag: '--page-num <n>', description: 'page number', key: 'pageNum', kind: 'int' },
193
+ { flag: '--page-size <n>', description: 'page size', key: 'pageSize', kind: 'int' },
194
+ ]);
195
+ registerCommand(clause, 'tags', 'List clause tags', 'contract.clause.tags', [
196
+ { flag: '--label <label>', description: 'tag label', key: 'label' },
197
+ { flag: '--page-num <n>', description: 'page number', key: 'pageNum', kind: 'int' },
198
+ { flag: '--page-size <n>', description: 'page size', key: 'pageSize', kind: 'int' },
199
+ ]);
200
+ const reference = clause.command('reference').description('Clause reference commands');
201
+ registerCommand(reference, 'get', 'Query referenced clauses of a contract document', 'contract.clause.reference.get', [
202
+ { flag: '--file-id <id>', description: 'contract file id', key: 'fileId' },
203
+ { flag: '--request-id <id>', description: 'workflow request id', key: 'requestId' },
204
+ { flag: '--clause-id <id>', description: 'clause id', key: 'clauseId' },
205
+ { flag: '--page-num <n>', description: 'page number', key: 'pageNum', kind: 'int' },
206
+ { flag: '--page-size <n>', description: 'page size', key: 'pageSize', kind: 'int' },
207
+ ]);
208
+ registerCommand(reference, 'save-prepare', 'Prepare clause reference write', 'contract.clause.reference.save.prepare', [
209
+ { flag: '--file-id <id>', description: 'contract file id', key: 'fileId' },
210
+ { flag: '--request-id <id>', description: 'workflow request id', key: 'requestId' },
211
+ { flag: '--file-name <name>', description: 'contract file name', key: 'fileName' },
212
+ { flag: '--request-name <name>', description: 'workflow request name', key: 'requestName' },
213
+ ]);
214
+ registerCommand(reference, 'save-apply', 'Apply a prepared clause reference write', 'contract.clause.reference.save.apply', [
215
+ { flag: '--file-id <id>', description: 'contract file id', key: 'fileId' },
216
+ { flag: '--request-id <id>', description: 'workflow request id', key: 'requestId' },
217
+ { flag: '--file-name <name>', description: 'contract file name', key: 'fileName' },
218
+ { flag: '--request-name <name>', description: 'workflow request name', key: 'requestName' },
219
+ ...CONTINUATION_FLAGS,
220
+ ]);
221
+ const subject = contract.command('subject').description('Signing subject commands');
222
+ registerCommand(subject, 'app', 'Resolve application id by tag', 'contract.subject.app', [
223
+ { flag: '--tag <tag>', description: 'application tag, default 合同管理', key: 'tag' },
224
+ ]);
225
+ registerCommand(subject, 'form', 'Resolve form object by tag', 'contract.subject.form', [
226
+ { flag: '--app-id <id>', description: 'application id', key: 'appId' },
227
+ { flag: '--tag <tag>', description: 'form tag', key: 'tag' },
228
+ ]);
229
+ registerCommand(subject, 'fields', 'Read form field definitions', 'contract.subject.fields', [
230
+ { flag: '--app-id <id>', description: 'application id', key: 'appId' },
231
+ { flag: '--obj-id <id>', description: 'form object id', key: 'objId' },
232
+ ]);
233
+ registerCommand(subject, 'options', 'Read selectable field options', 'contract.subject.options', [
234
+ { flag: '--app-id <id>', description: 'application id', key: 'appId' },
235
+ { flag: '--obj-id <id>', description: 'form object id', key: 'objId' },
236
+ { flag: '--field-name <id>', description: 'field metadata id', key: 'fieldName' },
237
+ ]);
238
+ registerCommand(subject, 'query', 'Query signing subject records', 'contract.subject.query', [
239
+ { flag: '--obj-id <id>', description: 'form object id', key: 'objId' },
240
+ { flag: '--page-no <n>', description: 'page number', key: 'pageNo', kind: 'int' },
241
+ { flag: '--page-size <n>', description: 'page size', key: 'pageSize', kind: 'int' },
242
+ { flag: '--return-detail <y|n>', description: 'return detail tables', key: 'isReturnDetail' },
243
+ ]);
244
+ registerCommand(subject, 'create-prepare', 'Prepare signing subject creation', 'contract.subject.create.prepare', [
245
+ { flag: '--obj-id <id>', description: 'form object id', key: 'objId' },
246
+ ]);
247
+ registerCommand(subject, 'create-apply', 'Apply a prepared signing subject creation', 'contract.subject.create.apply', [
248
+ { flag: '--obj-id <id>', description: 'form object id', key: 'objId' },
249
+ ...CONTINUATION_FLAGS,
250
+ ]);
251
+ const workflow = contract.command('workflow').description('Workflow metadata commands');
252
+ registerCommand(workflow, 'query', 'Query workflow by name', 'contract.workflow.query', [
253
+ { flag: '--workflow-name <name>', description: 'workflow name', key: 'workflowName' },
254
+ { flag: '--workflow-type <type>', description: 'workflow type id', key: 'workflowType' },
255
+ { flag: '--status <status>', description: '1 enabled, 2 history, 5 disabled, 9 template', key: 'status' },
256
+ ]);
257
+ registerCommand(workflow, 'list', 'List workflows the user can create', 'contract.workflow.list', [
258
+ { flag: '--wfp-code <code>', description: '0 personal, 1 team', key: 'wfpCode', kind: 'int' },
259
+ { flag: '--filter-hide <value>', description: 'pass 1 to filter hidden', key: 'filterHide' },
260
+ ]);
261
+ registerCommand(workflow, 'form-info', 'Read workflow form definition', 'contract.workflow.form.info', [
262
+ { flag: '--workflow-id <id>', description: 'workflow id', key: 'workflowId' },
263
+ ]);
264
+ registerCommand(workflow, 'field-options', 'Read selectable field options', 'contract.workflow.field.options', [
265
+ { flag: '--field-id <id>', description: 'field id', key: 'fieldId' },
266
+ { flag: '--page-no <n>', description: 'page number', key: 'pageNo', kind: 'int' },
267
+ { flag: '--page-size <n>', description: 'page size', key: 'pageSize', kind: 'int' },
268
+ ]);
269
+ const request = contract.command('request').description('Contract approval request commands');
270
+ registerCommand(request, 'create-prepare', 'Prepare workflow request creation', 'contract.request.create.prepare', [
271
+ { flag: '--workflow-id <id>', description: 'workflow id', key: 'workflowId' },
272
+ { flag: '--requestname <name>', description: 'request title', key: 'requestname' },
273
+ { flag: '--remark <text>', description: 'remark', key: 'remark' },
274
+ ]);
275
+ registerCommand(request, 'create-apply', 'Apply a prepared workflow request creation', 'contract.request.create.apply', [
276
+ { flag: '--workflow-id <id>', description: 'workflow id', key: 'workflowId' },
277
+ { flag: '--requestname <name>', description: 'request title', key: 'requestname' },
278
+ { flag: '--remark <text>', description: 'remark', key: 'remark' },
279
+ ...CONTINUATION_FLAGS,
280
+ ]);
281
+ registerCommand(request, 'save-prepare', 'Prepare workflow form data save', 'contract.request.save.prepare', [
282
+ { flag: '--request-id <id>', description: 'request id', key: 'requestId' },
283
+ { flag: '--workflow-id <id>', description: 'workflow id', key: 'workflowId' },
284
+ ]);
285
+ registerCommand(request, 'save-apply', 'Apply a prepared workflow form data save', 'contract.request.save.apply', [
286
+ { flag: '--request-id <id>', description: 'request id', key: 'requestId' },
287
+ { flag: '--workflow-id <id>', description: 'workflow id', key: 'workflowId' },
288
+ ...CONTINUATION_FLAGS,
289
+ ]);
290
+ registerCommand(request, 'submit-prepare', 'Prepare contract approval submission', 'contract.request.submit.prepare', [
291
+ { flag: '--request-id <id>', description: 'request id', key: 'requestId' },
292
+ { flag: '--request-name <name>', description: 'request title', key: 'requestName' },
293
+ { flag: '--remark <text>', description: 'remark', key: 'remark' },
294
+ ]);
295
+ registerCommand(request, 'submit-apply', 'Apply a prepared contract approval submission', 'contract.request.submit.apply', [
296
+ { flag: '--request-id <id>', description: 'request id', key: 'requestId' },
297
+ { flag: '--request-name <name>', description: 'request title', key: 'requestName' },
298
+ { flag: '--remark <text>', description: 'remark', key: 'remark' },
299
+ ...CONTINUATION_FLAGS,
300
+ ]);
301
+ registerCommand(request, 'supervise-prepare', 'Prepare approval reminder', 'contract.request.supervise.prepare', [
302
+ { flag: '--request-id <id>', description: 'request id', key: 'requestId' },
303
+ { flag: '--remark <text>', description: 'reminder remark', key: 'remark' },
304
+ ]);
305
+ registerCommand(request, 'supervise-apply', 'Apply a prepared approval reminder', 'contract.request.supervise.apply', [
306
+ { flag: '--request-id <id>', description: 'request id', key: 'requestId' },
307
+ { flag: '--remark <text>', description: 'reminder remark', key: 'remark' },
308
+ ...CONTINUATION_FLAGS,
309
+ ]);
310
+ registerCommand(request, 'status', 'Read workflow request status', 'contract.request.status', [
311
+ { flag: '--request-id <id>', description: 'request id', key: 'requestId' },
312
+ ]);
313
+ registerCommand(request, 'log', 'Read workflow request logs', 'contract.request.log', [
314
+ { flag: '--request-id <id>', description: 'request id', key: 'requestId' },
315
+ { flag: '--other-params <json>', description: 'paging params JSON', key: 'otherParams' },
316
+ ]);
317
+ },
318
+ };