weaver-work-cli 0.1.28 → 0.1.31

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 (219) hide show
  1. package/dist/chunks/archive-U766FTFH.js +2537 -0
  2. package/dist/chunks/archive-oa-DMWEKX3L.js +1317 -0
  3. package/dist/chunks/asset-TCR7VDEV.js +2109 -0
  4. package/dist/chunks/attachment-content-AQNX5N3S.js +23 -0
  5. package/dist/chunks/blog-EVZWGDVM.js +2157 -0
  6. package/dist/chunks/caizhilian-JOWS6SL5.js +10087 -0
  7. package/dist/chunks/calendar-5WNCV66Q.js +1195 -0
  8. package/dist/chunks/chunk-2DUV44UX.js +15606 -0
  9. package/dist/chunks/chunk-324YPTC2.js +1607 -0
  10. package/dist/chunks/chunk-65QMVWHS.js +231 -0
  11. package/dist/chunks/chunk-6V7ZLF34.js +387 -0
  12. package/dist/chunks/chunk-AC7KJWC5.js +358 -0
  13. package/dist/chunks/chunk-AJ62BGAW.js +29 -0
  14. package/dist/chunks/chunk-BUSC6UAE.js +43 -0
  15. package/dist/chunks/chunk-CVZ2JOSW.js +62 -0
  16. package/dist/chunks/chunk-D4LTJSJD.js +477 -0
  17. package/dist/chunks/chunk-EG6ZU444.js +654 -0
  18. package/dist/chunks/chunk-EZALDOQH.js +383 -0
  19. package/dist/chunks/chunk-FMPJJYYI.js +106 -0
  20. package/dist/chunks/chunk-G2JSIUWF.js +769 -0
  21. package/dist/chunks/chunk-GCG2NMWR.js +703 -0
  22. package/dist/chunks/chunk-GPMFD4RD.js +75 -0
  23. package/dist/chunks/chunk-H3WDBYJW.js +508 -0
  24. package/dist/chunks/chunk-H6XSTSLM.js +2357 -0
  25. package/dist/chunks/chunk-J7RJTZSV.js +5556 -0
  26. package/dist/chunks/chunk-LUSPKZKY.js +53 -0
  27. package/dist/chunks/chunk-NIAJ5ZCG.js +73 -0
  28. package/dist/chunks/chunk-NOODWMCL.js +584 -0
  29. package/dist/chunks/chunk-OOUTBLZ4.js +51 -0
  30. package/dist/chunks/chunk-P26ZWSKU.js +73 -0
  31. package/dist/chunks/chunk-QWY6PGL6.js +3472 -0
  32. package/dist/chunks/chunk-R2IJAK7T.js +464 -0
  33. package/dist/chunks/chunk-R7O5PUWO.js +205 -0
  34. package/dist/chunks/chunk-RCGYCOMG.js +6962 -0
  35. package/dist/chunks/chunk-VZTXRG6X.js +403 -0
  36. package/dist/chunks/chunk-WHD4XMRP.js +161 -0
  37. package/dist/chunks/chunk-YLCYX7LE.js +371 -0
  38. package/dist/chunks/chunk-ZEDWSH32.js +68 -0
  39. package/dist/chunks/continuation-2CKSBLA6.js +11 -0
  40. package/dist/chunks/continuation-HZIZRZBX.js +13 -0
  41. package/dist/chunks/continuation-NLECEJPX.js +11 -0
  42. package/dist/chunks/ebuilder-form-NJ4YK6CC.js +2276 -0
  43. package/dist/chunks/ehr-MMYN36VA.js +5241 -0
  44. package/dist/chunks/employee-SAK2QYXX.js +11 -0
  45. package/dist/chunks/esb-HIWHOU7Q.js +141 -0
  46. package/dist/chunks/fna-KBACQTA5.js +1444 -0
  47. package/dist/chunks/host-3OHS5QUX.js +21 -0
  48. package/dist/chunks/host-IG6KEH5Q.js +19 -0
  49. package/dist/chunks/host-KQL5N4HO.js +23 -0
  50. package/dist/chunks/host-LLSZQCWR.js +17 -0
  51. package/dist/chunks/hrm-LYEC67ZQ.js +244 -0
  52. package/dist/chunks/im-RN2UKAEU.js +252 -0
  53. package/dist/chunks/invoice-EEPHLAF6.js +5179 -0
  54. package/dist/chunks/jiuchuanhui-WVVZYSJE.js +1940 -0
  55. package/dist/chunks/lazy-dispatch-MDOFFL2S.js +28 -0
  56. package/dist/chunks/mail-LNQLTF6L.js +2695 -0
  57. package/dist/chunks/meeting-XSD3BDVQ.js +504 -0
  58. package/dist/chunks/msg-parse-4GSQ2WTO.js +41 -0
  59. package/dist/chunks/okr-TMWTIU2K.js +2482 -0
  60. package/dist/chunks/plan-A2FSFA7T.js +2025 -0
  61. package/dist/chunks/project-T26QLBQF.js +1361 -0
  62. package/dist/chunks/registry-2VLUAESA.js +14 -0
  63. package/dist/chunks/registry-JCFEYXOE.js +18 -0
  64. package/dist/chunks/registry-NYPYMZXG.js +16 -0
  65. package/dist/chunks/registry-Q7OQJ3SU.js +19 -0
  66. package/dist/chunks/registry-ZJMJVWFA.js +19 -0
  67. package/dist/chunks/room-recommend-UR4ZDZS6.js +20 -0
  68. package/dist/chunks/schedule-5L2PM4M6.js +24 -0
  69. package/dist/chunks/state-Y2XBP6YE.js +15 -0
  70. package/dist/chunks/workflow-TR6PG2SL.js +245 -0
  71. package/dist/cmd/argv.js +45 -0
  72. package/dist/cmd/docs/index.js +3 -3
  73. package/dist/cmd/lazy-dispatch.js +20 -0
  74. package/dist/cmd/root.js +2 -4
  75. package/dist/cmd/setup/index.js +2 -2
  76. package/dist/cmd/skills/index.js +2 -2
  77. package/dist/core/package-paths.js +47 -0
  78. package/dist/index.js +163 -7
  79. package/dist/internal/e10/auth/xiaoe.js +3 -3
  80. package/dist/internal/e10/request-runtime.js +18 -62
  81. package/dist/internal/skills/detector.js +2 -2
  82. package/dist/shortcuts/contract/data/performance-catalog.js +1306 -0
  83. package/dist/shortcuts/contract/host.js +91 -35
  84. package/dist/shortcuts/contract/index.js +213 -0
  85. package/dist/shortcuts/contract/manifest.js +928 -0
  86. package/dist/shortcuts/contract/ooxml/docx.js +295 -0
  87. package/dist/shortcuts/contract/ooxml/xlsx.js +221 -0
  88. package/dist/shortcuts/contract/ooxml/zip.js +158 -0
  89. package/dist/shortcuts/contract/operations/assistant.js +1156 -0
  90. package/dist/shortcuts/contract/operations/clause-library.js +522 -0
  91. package/dist/shortcuts/contract/operations/compare.js +193 -0
  92. package/dist/shortcuts/contract/operations/credit-page.js +34 -0
  93. package/dist/shortcuts/contract/operations/flow.js +98 -0
  94. package/dist/shortcuts/contract/operations/page.js +66 -0
  95. package/dist/shortcuts/contract/operations/performance.js +733 -0
  96. package/dist/shortcuts/contract/operations/quote.js +557 -0
  97. package/dist/shortcuts/contract/operations/recommend.js +78 -0
  98. package/dist/shortcuts/contract/operations/registry.js +18 -0
  99. package/dist/shortcuts/contract/operations/review.js +83 -0
  100. package/dist/shortcuts/contract/operations/shared.js +37 -0
  101. package/dist/shortcuts/contract/operations/upload.js +108 -0
  102. package/dist/shortcuts/contract/operations/write.js +3 -2
  103. package/dist/shortcuts/index.js +140 -40
  104. package/dist/shortcuts/invoice/host.js +2 -1
  105. package/dist/shortcuts/invoice/manifest.js +36 -12
  106. package/dist/shortcuts/invoice/operations/issuing-qys.js +132 -36
  107. package/dist/shortcuts/invoice/operations/reim-auto.js +9 -0
  108. package/dist/shortcuts/invoice/operations/reim.js +81 -5
  109. package/dist/shortcuts/invoice/operations/shared.js +12 -5
  110. package/dist/shortcuts/meeting/host.js +45 -3
  111. package/dist/shortcuts/meeting/invitation/docx.js +442 -0
  112. package/dist/shortcuts/meeting/operations/attachment-content.js +418 -0
  113. package/dist/shortcuts/meeting/operations/attachment.js +442 -0
  114. package/dist/shortcuts/meeting/operations/eb/cache.js +57 -0
  115. package/dist/shortcuts/meeting/operations/eb/catalog.js +343 -28
  116. package/dist/shortcuts/meeting/operations/eb/conflict.js +372 -11
  117. package/dist/shortcuts/meeting/operations/eb/create-flow.js +710 -0
  118. package/dist/shortcuts/meeting/operations/eb/decision.js +47 -1
  119. package/dist/shortcuts/meeting/operations/eb/factory.js +129 -11
  120. package/dist/shortcuts/meeting/operations/eb/index.js +122 -2
  121. package/dist/shortcuts/meeting/operations/eb/room-recommend.js +378 -0
  122. package/dist/shortcuts/meeting/operations/eb/room-summary.js +84 -0
  123. package/dist/shortcuts/meeting/operations/eb/schedule.js +450 -0
  124. package/dist/shortcuts/meeting/operations/from-group-chat.js +576 -0
  125. package/dist/shortcuts/meeting/operations/invitation.js +458 -0
  126. package/dist/shortcuts/meeting/operations/minute-content.js +266 -0
  127. package/dist/shortcuts/meeting/operations/pipeline.js +489 -0
  128. package/dist/shortcuts/meeting/operations/qrcode.js +131 -0
  129. package/dist/shortcuts/meeting/operations/receipts.js +1 -1
  130. package/dist/shortcuts/meeting/operations/registry.js +18 -0
  131. package/dist/shortcuts/meeting/operations/summary.js +276 -0
  132. package/dist/shortcuts/meeting/operations/task-notify.js +325 -0
  133. package/dist/shortcuts/meeting/operations.js +42 -1
  134. package/dist/shortcuts/meeting/qr/encoder.js +427 -0
  135. package/dist/shortcuts/meeting/qr/render.js +103 -0
  136. package/dist/shortcuts/workflow/index.js +3 -0
  137. package/dist/shortcuts/workflow/operations/form.js +17 -5
  138. package/dist/shortcuts/workflow/operations/read.js +13 -6
  139. package/dist/shortcuts/workflow/operations/registry.js +2 -0
  140. package/dist/shortcuts/workflow/operations/todoSmartConvert/businessRules.js +331 -0
  141. package/dist/shortcuts/workflow/operations/todoSmartConvert/detailFieldRules.js +133 -0
  142. package/dist/shortcuts/workflow/operations/todoSmartConvert/summaryCache.js +326 -0
  143. package/dist/shortcuts/workflow/operations/todoSmartConvert/todoDetailCache.js +113 -0
  144. package/dist/shortcuts/workflow/operations/todoSmartConvert/todoDetailFetcher.js +259 -0
  145. package/dist/shortcuts/workflow/operations/todoSmartConvert/todoListRows.js +64 -0
  146. package/dist/shortcuts/workflow/operations/todoSmartConvert/todoOutputPlanner.js +28 -0
  147. package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.aggregate.js +70 -0
  148. package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.collect.js +267 -0
  149. package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.core.js +392 -0
  150. package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.detail.js +165 -0
  151. package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.group.js +448 -0
  152. package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.groupSummary.js +348 -0
  153. package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.js +222 -0
  154. package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.pipeline.js +66 -0
  155. package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.smartGroup.js +502 -0
  156. package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.summary.js +540 -0
  157. package/docs/_catalog.md +1 -0
  158. package/docs/contract.md +39 -4
  159. package/docs/invoice.md +7 -7
  160. package/docs/todo-smart-convert/README.md +171 -0
  161. package/docs/todo-smart-convert/data-contract.md +236 -0
  162. package/docs/todo-smart-convert/mock/ai-todo-query-target.json +209 -0
  163. package/docs/todo-smart-convert/subgroup-rules.md +245 -0
  164. package/package.json +3 -2
  165. package/scripts/bundle.mjs +63 -0
  166. package/scripts/package-skill.mjs +1 -1
  167. package/skill-template/business-info.json +25 -4
  168. package/skill-template/domains/jinchengda.md +16 -3
  169. package/skill-template/domains/yepiaotong.md +3 -3
  170. package/skills/weaver-e10-jinchengda/SKILL.md +111 -31
  171. package/skills/weaver-e10-jinchengda/references/contract-agent-entry.md +7 -13
  172. package/skills/weaver-e10-jinchengda/references/contract-ai-assistant.md +150 -0
  173. package/skills/weaver-e10-jinchengda/references/contract-ai-review.md +87 -0
  174. package/skills/weaver-e10-jinchengda/references/contract-clause-library-crud.md +111 -0
  175. package/skills/weaver-e10-jinchengda/references/contract-clause-recommender.md +0 -15
  176. package/skills/weaver-e10-jinchengda/references/contract-clause-reference-save.md +0 -13
  177. package/skills/weaver-e10-jinchengda/references/contract-credit-page.md +50 -0
  178. package/skills/weaver-e10-jinchengda/references/contract-disabled-capabilities.md +4 -2
  179. package/skills/weaver-e10-jinchengda/references/contract-doc-compare.md +74 -0
  180. package/skills/weaver-e10-jinchengda/references/contract-flow-launch.md +84 -0
  181. package/skills/weaver-e10-jinchengda/references/contract-performance-query.md +29 -0
  182. package/skills/weaver-e10-jinchengda/references/contract-quote-to-contract.md +28 -0
  183. package/skills/weaver-e10-jinchengda/references/contract-request-status.md +2 -21
  184. package/skills/weaver-e10-jinchengda/references/contract-request-write.md +0 -24
  185. package/skills/weaver-e10-jinchengda/references/contract-signing-subjects.md +0 -15
  186. package/skills/weaver-e10-jinchengda/references/contract-subject-create.md +0 -17
  187. package/skills/weaver-e10-jinchengda/references/contract-template-recommend.md +70 -0
  188. package/skills/weaver-e10-jinchengda/references/contract-template-selector.md +0 -15
  189. package/skills/weaver-e10-jinchengda/references/contract-workflow-discovery.md +0 -15
  190. package/skills/weaver-e10-jinchengda/references/source-manifest.json +1168 -152
  191. package/skills/weaver-e10-meeting/SKILL.md +493 -17
  192. package/skills/weaver-e10-meeting/references/meeting-change.md +4 -4
  193. package/skills/weaver-e10-meeting/references/meeting-create.md +6 -6
  194. package/skills/weaver-e10-meeting/references/meeting-eb.md +503 -27
  195. package/skills/weaver-e10-meeting/references/meeting-invitation.md +113 -0
  196. package/skills/weaver-e10-meeting/references/meeting-lifecycle.md +6 -6
  197. package/skills/weaver-e10-meeting/references/meeting-minute-file.md +425 -0
  198. package/skills/weaver-e10-meeting/references/meeting-queries.md +4 -4
  199. package/skills/weaver-e10-meeting/references/meeting-receipts-signs.md +15 -15
  200. package/skills/weaver-e10-meeting/references/meeting-verification.md +19 -11
  201. package/skills/weaver-e10-meeting.zip +0 -0
  202. package/skills/weaver-e10-workflow/SKILL.md +23 -1
  203. package/skills/weaver-e10-workflow/references/todo-smart-convert.md +282 -0
  204. package/skills/weaver-e10-workflow/scripts/todo-summary.cjs +695 -0
  205. package/skills/weaver-e10-yepiaotong/SKILL.md +15 -11
  206. package/skills/weaver-e10-yepiaotong/references/invoice-enterprise-list.md +1 -1
  207. package/skills/weaver-e10-yepiaotong/references/invoice-issuing-examples.md +10 -7
  208. package/skills/weaver-e10-yepiaotong/references/invoice-issuing-form-fill-rules.md +41 -14
  209. package/skills/weaver-e10-yepiaotong/references/invoice-issuing-workflow.md +54 -26
  210. package/skills/weaver-e10-yepiaotong/references/invoice-personal-list.md +6 -5
  211. package/skills/weaver-e10-yepiaotong/references/invoice-reim.md +14 -11
  212. package/skills/weaver-e10-yepiaotong/references/reim-api-reference.md +97 -56
  213. package/skills/weaver-e10-yepiaotong/references/reim-examples.md +84 -60
  214. package/skills/weaver-e10-yepiaotong/references/reim-form-fill-rules.md +142 -105
  215. package/skills/weaver-e10-yepiaotong/references/reim-matching-rules.md +53 -194
  216. package/skills/weaver-e10-yepiaotong/references/reim-phone-subsidy-rules.md +7 -7
  217. package/skills/weaver-e10-yepiaotong/references/reim-workflow.md +164 -72
  218. package/skills/weaver-e10-yepiaotong/references/source-manifest.json +8 -2
  219. package/templates/meeting/invitation.docx +0 -0
@@ -0,0 +1,193 @@
1
+ import { contractValidationError } from '../errors.js';
2
+ import { comparePageUrl } from './page.js';
3
+ import { requireNonEmptyString } from './shared.js';
4
+ import { uploadFile } from './upload.js';
5
+ const DEFAULT_PAGE_SIZE = 20;
6
+ const VERSION_PAGE_SIZE = 100;
7
+ function text(value) {
8
+ if (typeof value === 'string' && value.trim())
9
+ return value;
10
+ if (typeof value === 'number' && Number.isFinite(value))
11
+ return String(value);
12
+ return undefined;
13
+ }
14
+ function mapDocument(item) {
15
+ return {
16
+ id: text(item.id),
17
+ name: item.name,
18
+ folderPathName: item.folderPathName,
19
+ creatorName: item.docCreatorName,
20
+ authorName: item.docAuthorName,
21
+ lastUpdateTime: item.docLastUpdateTime,
22
+ createTime: item.docCreateTime,
23
+ contentType: item.contentType,
24
+ attachmentCount: item.countOfAttachment,
25
+ fileSize: item.docMetadata?.fileSize,
26
+ docStatus: item.docMetadata?.docStatus,
27
+ note: '这里的 id 是文档 ID,不是比对页需要的 fileId;确认 fileId 后再调用 contract.compare.page',
28
+ };
29
+ }
30
+ function mapVersion(item) {
31
+ return {
32
+ fileId: text(item.fileId) ?? text(item.id) ?? text(item.fileid),
33
+ docId: text(item.docId),
34
+ fileName: item.fileName ?? item.name,
35
+ version: item.version ?? item.versionNo,
36
+ size: item.fileSize ?? item.size,
37
+ creator: item.creatorName ?? item.creator,
38
+ createTime: item.createTime ?? item.uploadTime,
39
+ };
40
+ }
41
+ export const contractCompareOperations = [
42
+ {
43
+ name: 'contract.compare.upload',
44
+ async execute(input, { host }) {
45
+ const paths = input.paths;
46
+ if (!Array.isArray(paths) || paths.length === 0) {
47
+ throw contractValidationError('paths_required', 'paths 必须是非空的本地文件路径数组(基准文件在前,比对文件在后)');
48
+ }
49
+ if (paths.length > 2) {
50
+ throw contractValidationError('paths_too_many', '文档比对一次只接受 1~2 个文件:基准文件在前,比对文件在后');
51
+ }
52
+ const files = [];
53
+ for (const rawPath of paths) {
54
+ const path = requireNonEmptyString(rawPath, 'paths[]', 1000);
55
+ // 比对走独立 module,不能与审查/流程上传混用。
56
+ files.push(await uploadFile(host, { path, module: 'docCompared' }));
57
+ }
58
+ return {
59
+ status: 'COMPLETE',
60
+ data: {
61
+ files,
62
+ note: '基准文件与比对文件都拿到 fileId 后,再用 contract.compare.page 打开比对页;只比对一个文件的历史版本时改用 contract.compare.versions',
63
+ },
64
+ };
65
+ },
66
+ },
67
+ {
68
+ name: 'contract.compare.search',
69
+ async execute(input, { host }) {
70
+ const keyword = requireNonEmptyString(input.keyword, 'keyword', 200).trim();
71
+ const pageNo = Number.isInteger(input.pageNo) && input.pageNo > 0 ? input.pageNo : 1;
72
+ const pageSize = Number.isInteger(input.pageSize) && input.pageSize > 0 ? Math.min(input.pageSize, 100) : DEFAULT_PAGE_SIZE;
73
+ const value = await host.contractRequest({
74
+ method: 'POST',
75
+ path: '/api/doc/documents/list',
76
+ body: {
77
+ conditions: [
78
+ { id: 'name', type: 'string', value: keyword },
79
+ { id: 'itsEqual_author', type: 'string', value: 'eq' },
80
+ { id: 'itsEqual_creator', type: 'string', value: 'eq' },
81
+ { id: 'itsBelong_label', type: 'string', value: 'eq' },
82
+ { id: 'itsBelong_myTag', type: 'string', value: 'eq' },
83
+ { id: 'itsBelong_folder', type: 'string', value: 'eq' },
84
+ ],
85
+ keywords: keyword,
86
+ customConditions: [],
87
+ pageNo,
88
+ pageSize,
89
+ },
90
+ });
91
+ const data = (value?.data ?? {});
92
+ const list = Array.isArray(data.list) ? data.list : [];
93
+ return {
94
+ status: 'COMPLETE',
95
+ data: {
96
+ keyword,
97
+ total: data.total,
98
+ pageNo: data.pageNo ?? pageNo,
99
+ pageSize,
100
+ documents: list.map(mapDocument),
101
+ hint: list.length > 1 ? '命中多条时必须让用户确认具体文档,禁止自动选第一条' : undefined,
102
+ },
103
+ };
104
+ },
105
+ },
106
+ {
107
+ name: 'contract.compare.versions',
108
+ async execute(input, { host }) {
109
+ const fileId = requireNonEmptyString(input.fileId, 'fileId', 64);
110
+ const docId = text(input.docId);
111
+ const pageNo = Number.isInteger(input.pageNo) && input.pageNo > 0 ? input.pageNo : 1;
112
+ const body = {
113
+ pageNo,
114
+ pageSize: VERSION_PAGE_SIZE,
115
+ id: fileId,
116
+ startTime: '',
117
+ endTime: '',
118
+ userIds: '',
119
+ pauuid: '0c18b0f471184d8fa584501465fa5827',
120
+ endType: 'Windows',
121
+ module: 'document',
122
+ maxUploadSize: '5000',
123
+ mobile: false,
124
+ enterprisePan: false,
125
+ customParam: '{"fromPCDoc":1}',
126
+ authModule: 'document',
127
+ notLoggedIn: false,
128
+ autoSelect: false,
129
+ coordinateFlag: false,
130
+ deepClean: false,
131
+ publicFileHost: '',
132
+ tempFileType: '1',
133
+ create: false,
134
+ batchCollaboration: false,
135
+ fileId,
136
+ };
137
+ if (docId)
138
+ body.docId = docId;
139
+ const value = await host.contractRequest({
140
+ method: 'POST',
141
+ path: '/api/file/base/upload/findVersionList',
142
+ body,
143
+ });
144
+ const data = (value?.data ?? {});
145
+ const list = Array.isArray(data.list) ? data.list : Array.isArray(data) ? data : [];
146
+ return {
147
+ status: 'COMPLETE',
148
+ data: {
149
+ fileId,
150
+ total: data.total,
151
+ versions: list.map(mapVersion),
152
+ hint: list.length > 1 ? '多版本时让用户选择目标版本,禁止自动选第一条' : undefined,
153
+ },
154
+ };
155
+ },
156
+ },
157
+ {
158
+ name: 'contract.compare.page',
159
+ async execute(input, { host }) {
160
+ const baseFileId = requireNonEmptyString(input.baseFileId, 'baseFileId', 64);
161
+ const baseFileName = requireNonEmptyString(input.baseFileName, 'baseFileName', 300);
162
+ const compareFileId = requireNonEmptyString(input.compareFileId, 'compareFileId', 64);
163
+ const compareFileName = requireNonEmptyString(input.compareFileName, 'compareFileName', 300);
164
+ const session = await host.getSession();
165
+ return {
166
+ status: 'COMPLETE',
167
+ data: {
168
+ url: comparePageUrl(session.baseUrl, { fileId: baseFileId, fileName: baseFileName }, { fileId: compareFileId, fileName: compareFileName }),
169
+ page: { width: 1000 },
170
+ note: 'url 保持字面方括号与中文原样,不做整体编码',
171
+ },
172
+ };
173
+ },
174
+ },
175
+ {
176
+ name: 'contract.compare.diff',
177
+ async execute(input, { host }) {
178
+ const baseFileId = requireNonEmptyString(input.baseFileId, 'baseFileId', 64);
179
+ const compareFileId = requireNonEmptyString(input.compareFileId, 'compareFileId', 64);
180
+ const value = await host.contractRequest({
181
+ method: 'POST',
182
+ path: '/api/ebd/contract/ai/getCompareRes',
183
+ // 两个字段都是数组,即使只有一个文件也不能传字符串。
184
+ body: { baseFileIds: [baseFileId], compareFileIds: [compareFileId] },
185
+ timeoutMs: 120_000,
186
+ });
187
+ return {
188
+ status: 'COMPLETE',
189
+ data: { baseFileId, compareFileId, result: value },
190
+ };
191
+ },
192
+ },
193
+ ];
@@ -0,0 +1,34 @@
1
+ import { contractValidationError } from '../errors.js';
2
+ import { creditPageUrl } from './page.js';
3
+ import { requireNonEmptyString } from './shared.js';
4
+ const MAX_SUBJECTS = 20;
5
+ export const contractCreditPageOperations = [
6
+ {
7
+ name: 'contract.credit.page',
8
+ async execute(input, { host }) {
9
+ if (!Array.isArray(input.names) || input.names.length === 0) {
10
+ throw contractValidationError('names_required', 'names 必须是非空的企业全称数组');
11
+ }
12
+ if (input.names.length > MAX_SUBJECTS) {
13
+ throw contractValidationError('names_too_many', `一次最多查询 ${MAX_SUBJECTS} 个主体`);
14
+ }
15
+ const names = input.names.map((raw, index) => {
16
+ const name = requireNonEmptyString(raw, `names[${index}]`, 200).trim();
17
+ if (name.length < 4) {
18
+ throw contractValidationError('name_not_full', `names[${index}] 看起来不是营业执照全称("${name}");简称查不到,请补齐全称并先让用户确认`);
19
+ }
20
+ return name;
21
+ });
22
+ const session = await host.getSession();
23
+ return {
24
+ status: 'COMPLETE',
25
+ data: {
26
+ names,
27
+ url: creditPageUrl(session.baseUrl, names),
28
+ page: { title: '资信查询', activate: true, width: 1000 },
29
+ note: '本能力只打开资信页面,不调用资信数据接口;从合同抽取的主体必须先让用户确认全称',
30
+ },
31
+ };
32
+ },
33
+ },
34
+ ];
@@ -0,0 +1,98 @@
1
+ import { contractValidationError } from '../errors.js';
2
+ import { flowPageUrl } from './page.js';
3
+ import { requireNonEmptyString } from './shared.js';
4
+ import { assertContractDocument, uploadFile } from './upload.js';
5
+ /**
6
+ * 四个合同流程的固定 workflowId / fieldId。
7
+ * 这些是业务常量(不是环境 ID),但流程页面里的其他 ID 仍需运行时解析。
8
+ */
9
+ export const FLOW_PRESETS = [
10
+ { key: '契约锁', label: '契约锁合同审批流程', workflowId: '100003460000002066', fieldId: '100003720000025579' },
11
+ { key: '新客户', label: '新客户购买合同审批流程', workflowId: '1269716062340284522', fieldId: '1269716066559755048' },
12
+ { key: '老客户增值', label: '老客户增值合同审批流程', workflowId: '1283761429944369334', fieldId: '100003720000039590' },
13
+ { key: '常规二次销售', label: '常规二次销售合同审批流程', workflowId: '1283761687634100307', fieldId: '100003720000029309' },
14
+ ];
15
+ export function resolveFlow(value) {
16
+ const raw = requireNonEmptyString(value, 'flow', 64).trim();
17
+ const exact = FLOW_PRESETS.find((preset) => preset.key === raw || preset.label === raw);
18
+ if (exact)
19
+ return exact;
20
+ const fuzzy = FLOW_PRESETS.filter((preset) => raw.includes(preset.key) || preset.label.includes(raw));
21
+ if (fuzzy.length === 1)
22
+ return fuzzy[0];
23
+ throw contractValidationError('flow_unknown', `flow 必须是以下之一:${FLOW_PRESETS.map((preset) => preset.key).join(' / ')};未指定时必须先询问用户,不能替用户选择`);
24
+ }
25
+ function requestIdOf(value) {
26
+ const root = (value ?? {});
27
+ const candidate = root.requestInfo?.requestId
28
+ ?? root.data?.requestInfo?.requestId
29
+ ?? root.data?.requestId
30
+ ?? root.requestId;
31
+ if (candidate === undefined || candidate === null)
32
+ return undefined;
33
+ const text = String(candidate).trim();
34
+ return text ? text : undefined;
35
+ }
36
+ export const contractFlowOperations = [
37
+ {
38
+ name: 'contract.flow.page',
39
+ async execute(input, { host }) {
40
+ const flow = resolveFlow(input.flow);
41
+ const session = await host.getSession();
42
+ return {
43
+ status: 'COMPLETE',
44
+ data: {
45
+ flow: flow.key,
46
+ flowLabel: flow.label,
47
+ workflowId: flow.workflowId,
48
+ url: flowPageUrl(session.baseUrl, flow.workflowId),
49
+ page: { width: 1000 },
50
+ },
51
+ };
52
+ },
53
+ },
54
+ {
55
+ name: 'contract.flow.launch',
56
+ async execute(input, { host }) {
57
+ const flow = resolveFlow(input.flow);
58
+ const path = requireNonEmptyString(input.path, 'path', 1000);
59
+ assertContractDocument(path);
60
+ const baseParam = await host.contractRequest({
61
+ method: 'POST',
62
+ path: '/api/workflow/core/flowPage/loadBaseParam',
63
+ query: { isCreate: 1, workflowId: flow.workflowId },
64
+ body: { workflowId: flow.workflowId, isCreate: 1, isMobile: 0 },
65
+ });
66
+ const requestId = requestIdOf(baseParam);
67
+ if (!requestId) {
68
+ throw contractValidationError('request_id_missing', 'loadBaseParam 未返回 requestInfo.requestId,已停止上传,避免文件挂到错误流程', { workflowId: flow.workflowId });
69
+ }
70
+ const uploaded = await uploadFile(host, {
71
+ path,
72
+ module: 'workflow',
73
+ extraFields: {
74
+ authModule: 'workflow',
75
+ source: 'form',
76
+ fieldId: flow.fieldId,
77
+ sourceRefId: requestId,
78
+ refId: requestId,
79
+ folderId: '300',
80
+ },
81
+ });
82
+ const session = await host.getSession();
83
+ return {
84
+ status: 'COMPLETE',
85
+ data: {
86
+ flow: flow.key,
87
+ flowLabel: flow.label,
88
+ workflowId: flow.workflowId,
89
+ fieldId: flow.fieldId,
90
+ requestId,
91
+ file: uploaded,
92
+ url: flowPageUrl(session.baseUrl, flow.workflowId, uploaded.fileId),
93
+ page: { width: 1000 },
94
+ },
95
+ };
96
+ },
97
+ },
98
+ ];
@@ -0,0 +1,66 @@
1
+ /**
2
+ * 页面地址构造。
3
+ *
4
+ * 源资料的硬约束:这些 sp 页面地址**不做整体编码**,`:`、`/`、`?`、`&`、`=`、`[`、`]`
5
+ * 与中文文件名一律保持原样;只有资信查询的 `name[N]` 参数值需要单独 encodeURIComponent。
6
+ * 因此这里全部用字符串拼接,不用 URL / URLSearchParams(它们会把中文和方括号编码掉)。
7
+ */
8
+ export function baseOf(baseUrl) {
9
+ return baseUrl.replace(/\/+$/u, '');
10
+ }
11
+ /** 合同智能审查页:spfiles[N][fileid|name|docId],索引从 0 开始,三个参数缺一不可。 */
12
+ export function reviewPageUrl(baseUrl, files) {
13
+ const segments = [];
14
+ files.forEach((file, index) => {
15
+ segments.push(`spfiles[${index}][fileid]=${file.fileId}`);
16
+ segments.push(`spfiles[${index}][name]=${file.name}`);
17
+ if (file.docId)
18
+ segments.push(`spfiles[${index}][docId]=${file.docId}`);
19
+ });
20
+ return `${baseOf(baseUrl)}/sp/contract/business/ai-contract?${segments.join('&')}`;
21
+ }
22
+ export const COMPARE_OPTION_DEFAULTS = {
23
+ 'options[ignoreImages]': '0',
24
+ 'options[ignoreSpace]': '1',
25
+ 'options[ignorePageHeader]': '0',
26
+ 'options[ignorePunctuation]': '1',
27
+ 'options[conversionAngle]': '0',
28
+ 'options[conversionStyle]': '0',
29
+ 'options[conversionSpecialSymbols]': '0',
30
+ 'options[ignoreMark]': '1',
31
+ 'options[ignoreWatermark]': '1',
32
+ 'options[ignoreSeal]': '1',
33
+ };
34
+ /** 文档比对页:baseFileId/baseFileName + compareFileId/compareFileName + 固定 options。 */
35
+ export function comparePageUrl(baseUrl, base, compare, options = COMPARE_OPTION_DEFAULTS) {
36
+ const segments = [
37
+ `baseFileId=${base.fileId}`,
38
+ `baseFileName=${base.fileName}`,
39
+ `compareFileId=${compare.fileId}`,
40
+ `compareFileName=${compare.fileName}`,
41
+ ...Object.entries(options).map(([key, value]) => `${key}=${value}`),
42
+ ];
43
+ return `${baseOf(baseUrl)}/sp/contract/business/doc-compare?${segments.join('&')}`;
44
+ }
45
+ /** 企业资信页:name[N] 索引从 0 始,只对参数值做一次 encodeURIComponent。 */
46
+ export function creditPageUrl(baseUrl, names) {
47
+ const segments = names.map((name, index) => `name[${index}]=${encodeURIComponent(name)}`);
48
+ return `${baseOf(baseUrl)}/sp/contract/business/credit?${segments.join('&')}`;
49
+ }
50
+ /** 流程发起页;带 fileId 时追加 automaticFormFilling=true 触发自动回填。 */
51
+ export function flowPageUrl(baseUrl, workflowId, fileId) {
52
+ const base = `${baseOf(baseUrl)}/sp/workflow/flowpage/create/${workflowId}?workflowId=${workflowId}&isCreate=1`;
53
+ return fileId ? `${base}&fileId=${fileId}&automaticFormFilling=true` : base;
54
+ }
55
+ /** 范文推荐结果页。 */
56
+ export function recommendPageUrl(baseUrl, cacheKey) {
57
+ return `${baseOf(baseUrl)}/sp/contract/business/template-list?recommendKey=${cacheKey}`;
58
+ }
59
+ /** 条款库页(源资料要求每次条款库操作后都打开,tab=1 固定)。 */
60
+ export function clauseLibraryPageUrl(baseUrl) {
61
+ return `${baseOf(baseUrl)}/sp/contract/terms-library?tab=1`;
62
+ }
63
+ /** 智能助手设置页。 */
64
+ export function aiSettingPageUrl(baseUrl) {
65
+ return `${baseOf(baseUrl)}/sp/contract/business/ai-setting`;
66
+ }