weaver-work-cli 0.1.50 → 0.1.52

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 (167) hide show
  1. package/README.md +1 -1
  2. package/dist/chunks/{attachment-content-EJYIOJPH.js → attachment-content-MBYYSQIX.js} +3 -3
  3. package/dist/chunks/{chunk-RYFRGTUV.js → chunk-7UOXOGFL.js} +4 -4
  4. package/dist/chunks/{chunk-BFKLQLBK.js → chunk-D3TDNRFE.js} +7 -7
  5. package/dist/chunks/{chunk-3NCFFHB2.js → chunk-DZOC77ZD.js} +1 -1
  6. package/dist/chunks/{chunk-K67FODVC.js → chunk-IRMA3GVP.js} +1 -1
  7. package/dist/chunks/{chunk-WNJUGI2F.js → chunk-KLZ3ULQQ.js} +1 -1
  8. package/dist/chunks/{chunk-6T53BSWZ.js → chunk-LALWNK6M.js} +9 -0
  9. package/dist/chunks/{chunk-HARQF5IP.js → chunk-LM2H7SZI.js} +25 -25
  10. package/dist/chunks/{chunk-YB3AJYPY.js → chunk-LTRLF6MM.js} +4 -4
  11. package/dist/chunks/{chunk-7ECB22G3.js → chunk-RPRFIG6I.js} +23 -23
  12. package/dist/chunks/{chunk-MCZG6HPM.js → chunk-RWFRZSIP.js} +2 -2
  13. package/dist/chunks/{chunk-7AYQJSFY.js → chunk-ZRHKGQRQ.js} +2 -2
  14. package/dist/chunks/{conflict-C4UDHCWV.js → conflict-D2HYKBMH.js} +2 -2
  15. package/dist/chunks/{contract-VUC6JOPG.js → contract-MFOFMM2J.js} +3837 -262
  16. package/dist/chunks/{create-flow-6OG2LYBD.js → create-flow-7ZATJVTM.js} +6 -6
  17. package/dist/chunks/{data-QO7QWOIV.js → data-WK5CQXNF.js} +17 -32
  18. package/dist/chunks/{env-WP57TF2S.js → env-5DO4YENS.js} +2 -2
  19. package/dist/chunks/{factory-VUXI7N5C.js → factory-3M7D7WJC.js} +1 -1
  20. package/dist/chunks/{group-chat-UQRGXILK.js → group-chat-B2HT5NEO.js} +3 -3
  21. package/dist/chunks/{invoice-E7GOITEU.js → invoice-V7ZTITUO.js} +725 -205
  22. package/dist/chunks/{meeting-4BBLVAWM.js → meeting-HZOX3CBB.js} +10 -10
  23. package/dist/chunks/{recruit-stage-FKWS5UQF.js → recruit-stage-XCMVEQA2.js} +718 -131
  24. package/dist/chunks/{registry-V4CHRQDI.js → registry-KYPFFQIH.js} +1 -1
  25. package/dist/chunks/{registry-5CRCN2TV.js → registry-SJHSBO5G.js} +10 -10
  26. package/dist/chunks/{room-recommend-AYR3UG7R.js → room-recommend-5AHR4YQV.js} +4 -4
  27. package/dist/chunks/{schedule-JZEFIXUS.js → schedule-KZPJUPC2.js} +4 -4
  28. package/dist/chunks/smart-extract-IXHCZE4R.js +2846 -0
  29. package/dist/chunks/{workflow-3ZAF2J5E.js → workflow-UHKCZJMY.js} +1 -1
  30. package/dist/index.js +11 -6
  31. package/dist/shortcuts/contract/manifest.js +151 -0
  32. package/dist/shortcuts/contract/operations/card-action.js +585 -0
  33. package/dist/shortcuts/contract/operations/card-ebdf-list.js +315 -0
  34. package/dist/shortcuts/contract/operations/card-plan.js +327 -0
  35. package/dist/shortcuts/contract/operations/card-risk-report.js +565 -0
  36. package/dist/shortcuts/contract/operations/elements-build.js +714 -0
  37. package/dist/shortcuts/contract/operations/elements-spec.js +216 -0
  38. package/dist/shortcuts/contract/operations/first-screen.js +563 -0
  39. package/dist/shortcuts/contract/operations/flow.js +81 -25
  40. package/dist/shortcuts/contract/operations/modeltext.js +132 -0
  41. package/dist/shortcuts/contract/operations/op-resolver.js +22 -0
  42. package/dist/shortcuts/contract/operations/quote.js +131 -25
  43. package/dist/shortcuts/contract/operations/registry.js +20 -0
  44. package/dist/shortcuts/contract/operations/review.js +73 -58
  45. package/dist/shortcuts/contract/operations/summary-validate.js +293 -0
  46. package/dist/shortcuts/contract/operations/summary.js +4 -2
  47. package/dist/shortcuts/contract/operations/upload.js +48 -7
  48. package/dist/shortcuts/contract/prewarm-cache.js +90 -0
  49. package/dist/shortcuts/contract/prewarm.js +88 -0
  50. package/dist/shortcuts/contract/upload-cache.js +49 -4
  51. package/dist/shortcuts/data/index.js +1 -6
  52. package/dist/shortcuts/data/manifest.js +2 -2
  53. package/dist/shortcuts/data/operations/index.js +1 -1
  54. package/dist/shortcuts/data/operations/query.js +23 -46
  55. package/dist/shortcuts/index.js +5 -0
  56. package/dist/shortcuts/invoice/index.js +0 -12
  57. package/dist/shortcuts/invoice/manifest.js +200 -49
  58. package/dist/shortcuts/invoice/operations/registry.js +4 -2
  59. package/dist/shortcuts/invoice/operations/reim-relation.js +438 -0
  60. package/dist/shortcuts/invoice/operations/shared.js +3 -19
  61. package/dist/shortcuts/invoice/operations/upload-and-validate.js +109 -73
  62. package/dist/shortcuts/recruit-stage/operations/interview-arrange.js +4 -2
  63. package/dist/shortcuts/recruit-stage/operations/jd-create.js +6 -2
  64. package/dist/shortcuts/recruit-stage/operations/list.js +217 -1
  65. package/dist/shortcuts/recruit-stage/operations/resume-import.js +144 -158
  66. package/dist/shortcuts/recruit-stage/operations/search.js +348 -0
  67. package/dist/shortcuts/recruit-stage/shared.js +5 -0
  68. package/dist/shortcuts/recruit-stage/tag-lookup.js +136 -0
  69. package/dist/shortcuts/smart-extract/constants.js +79 -0
  70. package/dist/shortcuts/smart-extract/continuation.js +71 -0
  71. package/dist/shortcuts/smart-extract/errors.js +68 -0
  72. package/dist/shortcuts/smart-extract/host.js +191 -0
  73. package/dist/shortcuts/smart-extract/index.js +105 -0
  74. package/dist/shortcuts/smart-extract/ledger.js +70 -0
  75. package/dist/shortcuts/smart-extract/manifest.js +35 -0
  76. package/dist/shortcuts/smart-extract/operations/attachment.js +212 -0
  77. package/dist/shortcuts/smart-extract/operations/batch.js +67 -0
  78. package/dist/shortcuts/smart-extract/operations/config.js +118 -0
  79. package/dist/shortcuts/smart-extract/operations/fill.js +489 -0
  80. package/dist/shortcuts/smart-extract/operations/preview.js +174 -0
  81. package/dist/shortcuts/smart-extract/operations/registry.js +34 -0
  82. package/dist/shortcuts/smart-extract/operations/save.js +355 -0
  83. package/dist/shortcuts/smart-extract/operations/shared.js +191 -0
  84. package/dist/shortcuts/smart-extract/operations/structure.js +401 -0
  85. package/dist/shortcuts/smart-extract/operations/target.js +167 -0
  86. package/dist/shortcuts/smart-extract/operations/types.js +22 -0
  87. package/dist/shortcuts/smart-extract/operations/validate.js +408 -0
  88. package/dist/shortcuts/workflow/operations/read.js +19 -1
  89. package/docs/SKILL.md +1 -1
  90. package/docs/_catalog.md +3 -0
  91. package/docs/agent-invoice.md +5 -7
  92. package/docs/data.md +5 -1
  93. package/docs/fna.md +14 -1
  94. package/docs/invoice.md +7 -5
  95. package/docs/smart-extract.md +156 -0
  96. package/package.json +1 -1
  97. package/skill-template/business-info.json +16 -1
  98. package/skill-template/domains/qiyecheng.md +2 -0
  99. package/skill-template/domains/smart-extract.md +16 -0
  100. package/skill-template/domains/yepiaotong.md +2 -2
  101. package/skills/weaver-e10-data/references/scene-and-misc.md +4 -3
  102. package/skills/weaver-e10-jinchengda/SKILL.md +159 -11
  103. package/skills/weaver-e10-jinchengda/references/contract-action-card.md +8 -3
  104. package/skills/weaver-e10-jinchengda/references/contract-action-engine.md +4 -3
  105. package/skills/weaver-e10-jinchengda/references/contract-element-save-record.md +8 -7
  106. package/skills/weaver-e10-jinchengda/references/contract-field-extract-new-customer.md +21 -6
  107. package/skills/weaver-e10-jinchengda/references/contract-field-extract-other-flows.md +3 -1
  108. package/skills/weaver-e10-jinchengda/references/contract-flow-launch.md +1 -1
  109. package/skills/weaver-e10-jinchengda/references/contract-modeltext-library.md +128 -0
  110. package/skills/weaver-e10-jinchengda/references/contract-multi-file.md +90 -0
  111. package/skills/weaver-e10-jinchengda/references/contract-quote-to-contract.md +124 -5
  112. package/skills/weaver-e10-jinchengda/scripts/contract_first_screen.py +200 -0
  113. package/skills/weaver-e10-jinchengda/scripts/fill_contract_from_quote.py +572 -0
  114. package/skills/weaver-e10-jinchengda/scripts/quote_screen.py +560 -0
  115. package/skills/weaver-e10-jinchengda/scripts/triage_contract.py +894 -0
  116. package/skills/weaver-e10-jinchengda/scripts/validate_action_card.py +10 -0
  117. package/skills/weaver-e10-qiyecheng/SKILL.md +37 -0
  118. package/skills/weaver-e10-qiyecheng/references/ai-check-audit.md +14 -0
  119. package/skills/weaver-e10-qiyecheng/references/budget.md +14 -0
  120. package/skills/weaver-e10-qiyecheng/references/catalog.md +25 -0
  121. package/skills/weaver-e10-qiyecheng/references/expense-center.md +8 -0
  122. package/skills/weaver-e10-qiyecheng/references/expense-chart.md +9 -0
  123. package/skills/weaver-e10-qiyecheng/references/invoice-writeoff.md +13 -0
  124. package/skills/weaver-e10-qiyecheng/references/loan-management.md +14 -0
  125. package/skills/weaver-e10-qiyecheng/references/self-hosted-mode.md +239 -0
  126. package/skills/weaver-e10-qiyecheng/references/source-manifest.json +34 -27
  127. package/skills/weaver-e10-recruit-stage/SKILL.md +62 -4
  128. package/skills/weaver-e10-recruit-stage/agents/openai.yaml +42 -8
  129. package/skills/weaver-e10-recruit-stage/references/env-ziyong.md +79 -0
  130. package/skills/weaver-e10-recruit-stage/references/recruit-arrange-interview.md +11 -3
  131. package/skills/weaver-e10-recruit-stage/references/recruit-edit-interview-feedback.md +3 -2
  132. package/skills/weaver-e10-recruit-stage/references/recruit-interview-not-attended.md +153 -0
  133. package/skills/weaver-e10-recruit-stage/references/recruit-jd-create.md +7 -4
  134. package/skills/weaver-e10-recruit-stage/references/recruit-match-candidates.md +1 -1
  135. package/skills/weaver-e10-recruit-stage/references/recruit-my-positions.md +66 -0
  136. package/skills/weaver-e10-recruit-stage/references/recruit-output-links.md +156 -42
  137. package/skills/weaver-e10-recruit-stage/references/recruit-resume-import-batch.md +122 -0
  138. package/skills/weaver-e10-recruit-stage/references/recruit-resume-import.md +36 -8
  139. package/skills/weaver-e10-recruit-stage/references/recruit-search-by-tag.md +157 -0
  140. package/skills/weaver-e10-recruit-stage/references/recruit-utterance-glossary.md +35 -0
  141. package/skills/weaver-e10-smart-extract/SKILL.md +169 -0
  142. package/skills/weaver-e10-smart-extract/references/api-contract.md +71 -0
  143. package/skills/weaver-e10-smart-extract/references/result-format.md +102 -0
  144. package/skills/weaver-e10-smart-extract/references/troubleshooting.md +105 -0
  145. package/skills/weaver-e10-workflow/references/workflow-query.md +1 -1
  146. package/skills/weaver-e10-workflow/references/workflow-view.md +1 -1
  147. package/skills/weaver-e10-yepiaotong/SKILL.md +46 -33
  148. package/skills/weaver-e10-yepiaotong/references/invoice-add.md +2 -0
  149. package/skills/weaver-e10-yepiaotong/references/invoice-file-upload.md +1 -1
  150. package/skills/weaver-e10-yepiaotong/references/invoice-import.md +19 -2
  151. package/skills/weaver-e10-yepiaotong/references/invoice-ocr-preview.md +8 -2
  152. package/skills/weaver-e10-yepiaotong/references/invoice-reim-relation.md +407 -0
  153. package/skills/weaver-e10-yepiaotong/references/invoice-reim.md +12 -8
  154. package/skills/weaver-e10-yepiaotong/references/invoice-upload-and-validate.md +97 -39
  155. package/skills/weaver-e10-yepiaotong/references/reim-api-reference.md +91 -2
  156. package/skills/weaver-e10-yepiaotong/references/reim-examples.md +1 -1
  157. package/skills/weaver-e10-yepiaotong/references/reim-form-fill-rules.md +12 -12
  158. package/skills/weaver-e10-yepiaotong/references/reim-matching-rules.md +8 -4
  159. package/skills/weaver-e10-yepiaotong/references/reim-phone-subsidy-rules.md +136 -91
  160. package/skills/weaver-e10-yepiaotong/references/reim-workflow.md +109 -23
  161. package/skills/weaver-e10-yepiaotong/references/source-manifest.json +110 -43
  162. package/dist/shortcuts/invoice/operations/validate-preview.js +0 -40
  163. package/skills/weaver-e10-jinchengda/scripts/plan_actions.py +0 -279
  164. package/skills/weaver-e10-jinchengda/scripts/render_action_card.py +0 -450
  165. package/skills/weaver-e10-jinchengda/scripts/render_ebdf_list_card.py +0 -265
  166. package/skills/weaver-e10-jinchengda/scripts/render_risk_report.py +0 -358
  167. package/skills/weaver-e10-yepiaotong/references/invoice-validation-preview.md +0 -40
@@ -3,6 +3,7 @@ import { flowPageUrl } from './page.js';
3
3
  import { loadFormContext, inspectUploadField, resolveUploadFieldId } from './form-info.js';
4
4
  import { requireNonEmptyString } from './shared.js';
5
5
  import { assertContractDocument, uploadFile } from './upload.js';
6
+ import { lookupFileModule } from '../upload-cache.js';
6
7
  /**
7
8
  * 四个合同流程的固定 workflowId / fieldId。
8
9
  * 这些是业务常量(不是环境 ID),但流程页面里的其他 ID 仍需运行时解析。
@@ -40,6 +41,12 @@ function requestIdOf(value) {
40
41
  const text = String(candidate).trim();
41
42
  return text ? text : undefined;
42
43
  }
44
+ function optionalText(value) {
45
+ if (value === undefined || value === null)
46
+ return undefined;
47
+ const text = String(value).trim();
48
+ return text ? text : undefined;
49
+ }
43
50
  export const contractFlowOperations = [
44
51
  {
45
52
  name: 'contract.flow.page',
@@ -92,34 +99,80 @@ export const contractFlowOperations = [
92
99
  name: 'contract.flow.launch',
93
100
  async execute(input, { host }) {
94
101
  const flow = resolveFlow(input.flow);
95
- const path = requireNonEmptyString(input.path, 'path', 1000);
96
- assertContractDocument(path);
102
+ // 入参二选一(2026-11-12 用户定稿):
103
+ // - path:本地上传(最常用)
104
+ // - fileId:复用会话里已有的文件;若它当初不是 workflow 上传的,表单附件挂不住,需要 path 重新上传
105
+ const rawPath = optionalText(input.path);
106
+ const presetFileId = optionalText(input.fileId);
107
+ if (!rawPath && !presetFileId) {
108
+ throw contractValidationError('file_required', '必须提供 path(本地上传)或 fileId(复用会话已有文件)之一');
109
+ }
110
+ if (rawPath)
111
+ assertContractDocument(rawPath);
97
112
  // 先解析上传字段(O-3c):宁可多三次只读请求,也不把合同挂到一个可能失效的 fieldId 上。
98
113
  const formContext = await loadFormContext(host, flow.workflowId);
99
114
  const uploadField = resolveUploadFieldId(formContext.layout, flow.fieldId, flow.label);
100
- const baseParam = await host.contractRequest({
101
- method: 'POST',
102
- path: '/api/workflow/core/flowPage/loadBaseParam',
103
- query: { isCreate: 1, workflowId: flow.workflowId },
104
- body: { workflowId: flow.workflowId, isCreate: 1, isMobile: 0 },
105
- });
106
- const requestId = requestIdOf(baseParam);
107
- if (!requestId) {
108
- throw contractValidationError('request_id_missing', 'loadBaseParam 未返回 requestInfo.requestId,已停止上传,避免文件挂到错误流程', { workflowId: flow.workflowId });
109
- }
110
- const uploaded = await uploadFile(host, {
111
- path,
112
- module: 'workflow',
113
- extraFields: {
114
- authModule: 'workflow',
115
- source: 'form',
116
- fieldId: uploadField.fieldId,
117
- sourceRefId: requestId,
118
- refId: requestId,
119
- folderId: '300',
120
- },
121
- });
115
+ // 判断已有 fileId 能否直接复用:只有确认它本就是 workflow 上传的才行。
116
+ // 未知(缓存过期 / 换环境 / 别处传的)一律按"不是 workflow"处理,重新上传。
122
117
  const session = await host.getSession();
118
+ let presetModule = null;
119
+ if (presetFileId) {
120
+ presetModule = await lookupFileModule({
121
+ fileId: presetFileId,
122
+ baseUrl: session.baseUrl,
123
+ userId: session.userId ?? '',
124
+ });
125
+ }
126
+ const canReuse = presetFileId !== undefined && presetModule === 'workflow';
127
+ let uploaded;
128
+ let fileSource;
129
+ let reuploadReason;
130
+ if (canReuse) {
131
+ uploaded = {
132
+ fileId: presetFileId,
133
+ name: '',
134
+ size: 0,
135
+ md5: '',
136
+ module: 'workflow',
137
+ reused: true,
138
+ prewarmed: true,
139
+ };
140
+ fileSource = 'reused';
141
+ }
142
+ else if (rawPath) {
143
+ // 需要真正上传:先拿 requestId,再把文件挂到流程表单字段上。
144
+ const baseParam = await host.contractRequest({
145
+ method: 'POST',
146
+ path: '/api/workflow/core/flowPage/loadBaseParam',
147
+ query: { isCreate: 1, workflowId: flow.workflowId },
148
+ body: { workflowId: flow.workflowId, isCreate: 1, isMobile: 0 },
149
+ });
150
+ const requestId = requestIdOf(baseParam);
151
+ if (!requestId) {
152
+ throw contractValidationError('request_id_missing', 'loadBaseParam 未返回 requestInfo.requestId,已停止上传,避免文件挂到错误流程', { workflowId: flow.workflowId });
153
+ }
154
+ uploaded = await uploadFile(host, {
155
+ path: rawPath,
156
+ module: 'workflow',
157
+ extraFields: {
158
+ authModule: 'workflow',
159
+ source: 'form',
160
+ fieldId: uploadField.fieldId,
161
+ sourceRefId: requestId,
162
+ refId: requestId,
163
+ folderId: '300',
164
+ },
165
+ });
166
+ fileSource = presetFileId ? 'reuploaded' : 'uploaded';
167
+ if (presetFileId) {
168
+ reuploadReason = presetModule
169
+ ? `已有文件的 module 是 ${presetModule},表单附件必须用 workflow 上传的文件,已重新上传`
170
+ : '已有文件的 module 未知,无法确认能挂到表单附件字段,已重新上传';
171
+ }
172
+ }
173
+ else {
174
+ throw contractValidationError('reupload_required', `fileId ${presetFileId} 不是 workflow 上传的文件(或无法确认),表单附件挂不住;请同时提供 path 以便重新上传`, { fileId: presetFileId, module: presetModule });
175
+ }
123
176
  return {
124
177
  status: 'COMPLETE',
125
178
  data: {
@@ -129,8 +182,11 @@ export const contractFlowOperations = [
129
182
  fieldId: uploadField.fieldId,
130
183
  fieldIdPreset: flow.fieldId,
131
184
  fieldIdSource: uploadField.state,
132
- requestId,
133
185
  file: uploaded,
186
+ fileSource,
187
+ presetFileId,
188
+ presetFileModule: presetModule,
189
+ reuploadReason,
134
190
  url: flowPageUrl(session.baseUrl, flow.workflowId, uploaded.fileId),
135
191
  page: { width: 1000 },
136
192
  },
@@ -0,0 +1,132 @@
1
+ /**
2
+ * 范文库(「合同范文管理」EB 表单)查询。
3
+ *
4
+ * 术语约定:今承达技能内「模板」等同于「范文」(模板 == 范文),
5
+ * 因此本文件服务的是**范文库**,与合同模板库(`contract.template.*` → `/api/ebd/contract/tplinfo/**`)
6
+ * 是两个互不相通的对象,取数链路与字段都不同,禁止互相代替。
7
+ */
8
+ const MODEL_TEXT_OBJ_ID = '1290191829260230657';
9
+ const MODEL_TEXT_LIST_ID = '1290191833571975256';
10
+ const LIST_DATAS_PATH = '/api/ebuilder/form/list/getListDatas';
11
+ function dataOf(value) {
12
+ return value?.data ?? {};
13
+ }
14
+ /** 列表接口在不同环境下会把行放在 data / rows / records / list,按出现顺序取第一个数组。 */
15
+ function rowsOf(value) {
16
+ const data = dataOf(value);
17
+ for (const candidate of [data.data, data.rows, data.records, data.list]) {
18
+ if (Array.isArray(candidate))
19
+ return candidate;
20
+ }
21
+ return Array.isArray(data) ? data : [];
22
+ }
23
+ /** 真实总数:部分接口把总数放在 pagination.mainRecordTotal,total 恒为 0 时以它为准。 */
24
+ function totalOf(value, rows) {
25
+ const data = dataOf(value);
26
+ const candidates = [
27
+ data.total,
28
+ data.count,
29
+ data.pagination?.mainRecordTotal,
30
+ data.pagination?.total,
31
+ ];
32
+ for (const candidate of candidates) {
33
+ const parsed = Number(candidate);
34
+ if (Number.isFinite(parsed) && parsed > 0)
35
+ return parsed;
36
+ }
37
+ return rows.length;
38
+ }
39
+ const PERSON_NAME_KEYS = ['name', 'label', 'text', 'showName', 'userName', 'username'];
40
+ /** creator / updater 是 JSON 数组字符串([{id,name}]),偶发是纯名称;只输出姓名,绝不透出人员 ID。 */
41
+ function personName(value) {
42
+ if (typeof value !== 'string' || !value)
43
+ return undefined;
44
+ try {
45
+ const parsed = JSON.parse(value);
46
+ if (Array.isArray(parsed) && parsed.length) {
47
+ const first = parsed[0];
48
+ if (typeof first === 'string' && first && !/^\d+$/.test(first))
49
+ return first;
50
+ if (first && typeof first === 'object') {
51
+ for (const key of PERSON_NAME_KEYS) {
52
+ const candidate = first[key];
53
+ if (typeof candidate === 'string' && candidate && !/^\d+$/.test(candidate))
54
+ return candidate;
55
+ }
56
+ }
57
+ }
58
+ }
59
+ catch {
60
+ // 非 JSON 时按纯名称处理
61
+ }
62
+ return /^\d+$/.test(value) ? undefined : value;
63
+ }
64
+ async function listModelText(host, pageNo, pageSize, tableuid) {
65
+ const value = await host.contractRequest({
66
+ method: 'POST',
67
+ path: LIST_DATAS_PATH,
68
+ // ebbusinessid 与 listId 同值,缺它接口取不到该视图的业务上下文。
69
+ headers: { ebbusinessid: MODEL_TEXT_LIST_ID },
70
+ query: { passid: MODEL_TEXT_OBJ_ID, cid: MODEL_TEXT_OBJ_ID },
71
+ body: {
72
+ current: pageNo,
73
+ requiredMatch: 1,
74
+ tableuid: tableuid ?? '',
75
+ mapResult: '1',
76
+ recheckQuery: '1',
77
+ terminal: 'PC',
78
+ searchParamData: {
79
+ type: 'and',
80
+ searchType: '2',
81
+ commonSearchFields: {},
82
+ groupFields: {},
83
+ },
84
+ listId: MODEL_TEXT_LIST_ID,
85
+ isFollow: 0,
86
+ isShareToMe: 0,
87
+ filterCondition: {},
88
+ browser: 'Chrome',
89
+ },
90
+ });
91
+ const rows = rowsOf(value);
92
+ return { rows, total: totalOf(value, rows) };
93
+ }
94
+ /** 范文库列表;本技能内「模板」=「范文」,查模板即查范文。 */
95
+ export const contractModelTextListOperation = {
96
+ name: 'contract.modeltext.list',
97
+ async execute(input, { host }) {
98
+ const pageNo = typeof input.pageNo === 'number' && input.pageNo >= 1 ? input.pageNo : 1;
99
+ const pageSize = typeof input.pageSize === 'number' && input.pageSize >= 1
100
+ ? Math.min(input.pageSize, 200)
101
+ : 50;
102
+ const tableuid = typeof input.tableuid === 'string' && input.tableuid.trim()
103
+ ? input.tableuid.trim()
104
+ : undefined;
105
+ const { rows, total } = await listModelText(host, pageNo, pageSize, tableuid);
106
+ const session = await host.getSession();
107
+ return {
108
+ status: 'COMPLETE',
109
+ data: {
110
+ path: LIST_DATAS_PATH,
111
+ listUrl: `${session.baseUrl}/sp/ebdfpage/list/${MODEL_TEXT_LIST_ID}`,
112
+ total,
113
+ pageNo,
114
+ pageSize,
115
+ returned: rows.length,
116
+ modelTexts: rows.map((row) => ({
117
+ id: row.id ?? row.rowKey ?? row.form_data_id,
118
+ fileName: row.file_name,
119
+ classification: row.classification_id,
120
+ createTime: row.create_time,
121
+ updateTime: row.update_time,
122
+ creator: personName(row.creator),
123
+ updater: personName(row.updater),
124
+ })),
125
+ hint: '本命令读的是范文库(「合同范文管理」);本技能内「模板」== 「范文」,不要与合同模板库 contract.template.list 混用',
126
+ },
127
+ };
128
+ },
129
+ };
130
+ export const contractModelTextOperations = [
131
+ contractModelTextListOperation,
132
+ ];
@@ -0,0 +1,22 @@
1
+ /**
2
+ * operation 解析器中转(避免 registry ↔ 编排层循环依赖)。
3
+ *
4
+ * 背景:编排层需要在**进程内**调用其它 operation(省掉子进程启动开销),
5
+ * 但直接 `import { getContractOperation } from './registry.js'` 会与 registry
6
+ * 形成循环依赖:registry 加载时导入编排层,编排层又反向导入 registry。
7
+ * 虽然函数声明会被提升、实际调用发生在 execute 阶段,但依赖加载顺序在打包
8
+ * 与不同运行时下并不完全等价,属于不该赌的隐性风险。
9
+ *
10
+ * 因此这里只放一个可变引用:registry 完成构建后注入解析器,编排层通过
11
+ * `resolveOperation` 取用。本文件不导入 registry,循环即被切断。
12
+ */
13
+ let resolver = null;
14
+ export function setOperationResolver(fn) {
15
+ resolver = fn;
16
+ }
17
+ export function resolveOperation(name) {
18
+ if (!resolver) {
19
+ throw new Error(`contract operation resolver 尚未注入:${name}`);
20
+ }
21
+ return resolver(name);
22
+ }
@@ -117,6 +117,88 @@ function fmtNum(v) {
117
117
  return String(v);
118
118
  return f === Math.trunc(f) ? f.toLocaleString('en-US') : f.toLocaleString('en-US', { minimumFractionDigits: 2, maximumFractionDigits: 2 });
119
119
  }
120
+ const META_FIELDS = [
121
+ {
122
+ key: 'customer',
123
+ labels: ['客户名称', '客户全称', '客户单位', '用户名称', '甲方名称', '采购方', '购买方', '订购方', '最终用户', '客户', '甲方', '需方'],
124
+ valid: (v) => v.length >= 2 && v.length <= 80 && /[\u4e00-\u9fa5A-Za-z]/u.test(v),
125
+ },
126
+ {
127
+ key: 'quote_date',
128
+ labels: ['报价日期', '报价时间', '报价日'],
129
+ valid: (v) => /\d{4}/u.test(v),
130
+ },
131
+ {
132
+ key: 'sales',
133
+ labels: ['客户经理', '销售经理', '销售代表', '报价人', '商务经理'],
134
+ valid: (v) => v.length >= 1 && v.length <= 30 && !/^\d+$/u.test(v),
135
+ },
136
+ {
137
+ key: 'phone',
138
+ labels: ['联系电话', '联系方式', '客户电话', '手机号码', '手机'],
139
+ valid: (v) => /^[\d\-+() ]{6,}$/u.test(v.replace(/\s+/gu, '')),
140
+ },
141
+ ];
142
+ function escapeRe(s) {
143
+ return s.replace(/[.*+?^${}()|[\]\\]/gu, '\\$&');
144
+ }
145
+ /** 值本身是另一个字段的标签(如「客户经理:」)时不能当值用。 */
146
+ function isLabelLike(v) {
147
+ const bare = v.trim().replace(/[::]$/u, '').trim();
148
+ if (!bare)
149
+ return true;
150
+ return META_FIELDS.some((f) => f.labels.includes(bare));
151
+ }
152
+ function cleanMetaValue(v) {
153
+ return v.replace(/^[\s::\-—_]+/u, '').replace(/[\s::]+$/u, '').trim();
154
+ }
155
+ function extractQuoteMeta(rows) {
156
+ const meta = { customer: '', quote_date: '', sales: '', phone: '' };
157
+ const bestScore = {};
158
+ const consider = (field, raw, score) => {
159
+ const v = cleanMetaValue(raw);
160
+ if (!v || isLabelLike(v) || !field.valid(v))
161
+ return;
162
+ if (score > (bestScore[field.key] ?? 0)) {
163
+ meta[field.key] = v;
164
+ bestScore[field.key] = score;
165
+ }
166
+ };
167
+ for (let r = 0; r < rows.length; r++) {
168
+ const row = rows[r] ?? [];
169
+ for (let c = 0; c < row.length; c++) {
170
+ const cell = cleanMetaValue(row[c] ?? '');
171
+ if (!cell)
172
+ continue;
173
+ for (const field of META_FIELDS) {
174
+ for (const label of field.labels) {
175
+ // ① 同格内联:标签在本格开头,冒号后即值
176
+ const inline = new RegExp(`^${escapeRe(label)}\\s*[::]\\s*(.+)$`, 'u').exec(cell);
177
+ if (inline && inline[1]) {
178
+ consider(field, inline[1], 100);
179
+ continue;
180
+ }
181
+ // 标签独占一格(可带冒号)→ 右邻格 / 下邻格
182
+ if (cell.replace(/[::]$/u, '').trim() !== label)
183
+ continue;
184
+ for (let j = c + 1; j < row.length; j++) {
185
+ const v = cleanMetaValue(row[j] ?? '');
186
+ if (!v)
187
+ continue;
188
+ if (isLabelLike(v))
189
+ break; // 撞到下一个标签,说明本字段确实没值
190
+ consider(field, v, 95);
191
+ break;
192
+ }
193
+ const below = cleanMetaValue(rows[r + 1]?.[c] ?? '');
194
+ if (below && !isLabelLike(below))
195
+ consider(field, below, 80);
196
+ }
197
+ }
198
+ }
199
+ }
200
+ return meta;
201
+ }
120
202
  export function parseQuote(buffer, sheetName, keepRemark = false, includeZero = false) {
121
203
  const names = listSheetNames(buffer);
122
204
  if (names.length === 0)
@@ -166,25 +248,8 @@ export function parseQuote(buffer, sheetName, keepRemark = false, includeZero =
166
248
  return i;
167
249
  return null;
168
250
  };
169
- // ---- 元信息
170
- const meta = { customer: '', quote_date: '', sales: '', phone: '' };
171
- for (const row of rows) {
172
- const joined = row.join('');
173
- for (const [label, key] of [['客户名称', 'customer'], ['报价日期', 'quote_date'], ['客户经理', 'sales'], ['联系电话', 'phone']]) {
174
- if (!joined.includes(label) || meta[key])
175
- continue;
176
- const i = firstIdx(row, [label + ':', label + ':', label]);
177
- if (i === null)
178
- continue;
179
- for (let j = i + 1; j < row.length; j++) {
180
- const v = row[j];
181
- if (v && v.replace(/[::]$/u, '') !== label && !['报价日期', '客户经理', '联系电话'].some((x) => v.startsWith(x))) {
182
- meta[key] = v.replace(/[::]$/u, '');
183
- break;
184
- }
185
- }
186
- }
187
- }
251
+ // ---- 元信息:同格内联 / 分列 / 竖排 / 同行多字段,统一走 extractQuoteMeta
252
+ const meta = extractQuoteMeta(rows);
188
253
  // ---- 项目总价区
189
254
  const totals = {};
190
255
  for (const row of rows) {
@@ -298,8 +363,12 @@ export function parseQuote(buffer, sheetName, keepRemark = false, includeZero =
298
363
  if (final !== undefined && standard !== undefined && final !== standard) {
299
364
  warnings.push(`存在折扣:标准价 ${standard} → 最终优惠报价 ${final},合同金额应以最终优惠报价为准`);
300
365
  }
301
- if (!meta.customer)
302
- warnings.push('报价单未填写『客户名称』,签约主体必须由用户提供');
366
+ // 2026-11-12:已覆盖同格内联、分列、竖排三种形态;仍取不到才告警,
367
+ // 且只报「未能自动定位」——不得断言「未填写」,也不得据此向用户索要。
368
+ if (!meta.customer) {
369
+ warnings.push('未能自动定位『客户名称』(已尝试标签同格内联、右邻格、下邻格三种形态)。' +
370
+ '这不代表文件未填写:请用 contract.quote.extract 取原始网格行,由模型在网格中确认客户全称后再交用户核对。');
371
+ }
303
372
  return { source_sheet: sheet, available_sheets: names, meta, totals, sections, checks, warnings };
304
373
  }
305
374
  // ---------------------------------------------------------------- docx 报价书解析
@@ -490,8 +559,10 @@ export function normalizeParsedQuote(input) {
490
559
  if (t)
491
560
  meta[k] = t;
492
561
  }
493
- if (!meta.customer)
494
- warnings.push('报价书未给出客户名称,签约主体必须由用户提供');
562
+ if (!meta.customer) {
563
+ warnings.push('未从报价书中识别到客户名称(可能写法非常规)。这不代表文件未填写:'
564
+ + '请由模型从原文确认客户全称后再交用户核对。');
565
+ }
495
566
  return {
496
567
  source_sheet: 'docx',
497
568
  available_sheets: ['正文'],
@@ -681,14 +752,49 @@ export const contractQuoteOperations = [
681
752
  type: 'object',
682
753
  additionalProperties: false,
683
754
  properties: {
684
- path: { type: 'string', description: '.docx 报价书路径' },
755
+ path: { type: 'string', description: '.docx / .xlsx 报价书路径' },
756
+ sheet: { type: 'string', description: '.xlsx 工作表名(可选,默认第一个)' },
685
757
  },
686
758
  required: ['path'],
687
759
  },
688
760
  async execute(input) {
689
761
  const path = resolve(String(input.path));
762
+ // 2026-11-11:xlsx 也必须能无损提取。xlsx 是 ZIP 内的 XML,模型无法直读,
763
+ // 所以「解包 + 单元格还原成文本」这层必须由代码完成;
764
+ // 但语义判定(客户名在哪、哪张表是汇总、税率)一律交模型。
765
+ if (/\.xlsx$/iu.test(path)) {
766
+ const buf = readFileSync(path);
767
+ const sheets = listSheetNames(buf);
768
+ const wanted = input.sheet ? String(input.sheet) : '';
769
+ const idx = wanted ? Math.max(0, sheets.indexOf(wanted)) : 0;
770
+ const grid = readGrid(buf, idx);
771
+ const rows = [];
772
+ for (let r = 1; r <= grid.maxRow; r++) {
773
+ const line = [];
774
+ const rowMap = grid.values.get(r);
775
+ for (let c = 1; c <= grid.maxCol; c++) {
776
+ line.push(rowMap?.get(c)?.text ?? '');
777
+ }
778
+ rows.push(line);
779
+ }
780
+ return {
781
+ status: 'DONE',
782
+ data: {
783
+ kind: 'xlsx',
784
+ sheet: sheets[idx] ?? null,
785
+ sheets,
786
+ rows,
787
+ counts: {
788
+ rows: rows.length,
789
+ cols: rows.reduce((m, r) => Math.max(m, r.length), 0),
790
+ },
791
+ note: '零语义判断:只还原单元格文本。请模型读 rows 判定 meta(客户全称/日期/税率等)、'
792
+ + '哪张表是汇总表(is_summary=true),产出 JSON 后交 contract.quote.normalize 校验金额。',
793
+ },
794
+ };
795
+ }
690
796
  if (!/\.docx$/iu.test(path)) {
691
- throw contractValidationError('file_type_unsupported', '无损提取只针对 .docx 报价书;.xlsx 结构规整,请直接用 contract.quote.parse。');
797
+ throw contractValidationError('file_type_unsupported', '无损提取支持 .xlsx / .docx;.xls / .doc 老格式请先另存为新格式。');
692
798
  }
693
799
  const extracted = extractQuoteDocx(readFileSync(path));
694
800
  return { status: 'DONE', data: extracted };
@@ -5,11 +5,19 @@ import { contractClauseInsertOperations } from './clause-insert.js';
5
5
  import { contractClauseLibraryOperations } from './clause-library.js';
6
6
  import { contractClauseReferenceOperations } from './clause-reference.js';
7
7
  import { contractCardOperations } from './card.js';
8
+ import { contractCardPlanOperations } from './card-plan.js';
9
+ import { contractCardEbdfListOperations } from './card-ebdf-list.js';
10
+ import { contractCardRiskReportOperations } from './card-risk-report.js';
11
+ import { contractCardActionOperations } from './card-action.js';
8
12
  import { contractCompareOperations } from './compare.js';
9
13
  import { contractCreditPageOperations } from './credit-page.js';
10
14
  import { contractCustomerOperations } from './customer.js';
15
+ import { contractElementsBuildOperations } from './elements-build.js';
11
16
  import { contractFileDownloadOperations } from './file-download.js';
17
+ import { contractFirstScreenOperations } from './first-screen.js';
18
+ import { setOperationResolver } from './op-resolver.js';
12
19
  import { contractFlowOperations } from './flow.js';
20
+ import { contractModelTextOperations } from './modeltext.js';
13
21
  import { contractPerformanceOperations } from './performance.js';
14
22
  import { contractQuoteOperations } from './quote.js';
15
23
  import { contractRecommendOperations } from './recommend.js';
@@ -18,17 +26,21 @@ import { contractReviewOperations } from './review.js';
18
26
  import { contractSaveRecognizeOperations } from './save-recognize.js';
19
27
  import { contractSubjectOperations } from './subject.js';
20
28
  import { contractSummaryOperations } from './summary.js';
29
+ import { contractSummaryValidateOperations } from './summary-validate.js';
21
30
  import { contractTemplateOperations } from './template.js';
22
31
  import { contractWorkflowOperations } from './workflow.js';
23
32
  function buildRegistry() {
24
33
  const registry = new Map();
25
34
  const handlers = [
26
35
  ...contractTemplateOperations,
36
+ ...contractModelTextOperations,
27
37
  ...contractClauseLibraryOperations,
28
38
  ...contractClauseInsertOperations,
29
39
  ...contractClauseReferenceOperations,
30
40
  ...contractSubjectOperations,
31
41
  ...contractCustomerOperations,
42
+ ...contractElementsBuildOperations,
43
+ ...contractFirstScreenOperations,
32
44
  ...contractWorkflowOperations,
33
45
  ...contractRequestOperations,
34
46
  ...contractReviewOperations,
@@ -41,7 +53,12 @@ function buildRegistry() {
41
53
  ...contractAssistantOperations,
42
54
  ...contractPerformanceOperations,
43
55
  ...contractSummaryOperations,
56
+ ...contractSummaryValidateOperations,
44
57
  ...contractCardOperations,
58
+ ...contractCardPlanOperations,
59
+ ...contractCardEbdfListOperations,
60
+ ...contractCardRiskReportOperations,
61
+ ...contractCardActionOperations,
45
62
  ...contractQuoteOperations,
46
63
  ];
47
64
  for (const handler of handlers) {
@@ -61,6 +78,9 @@ function buildRegistry() {
61
78
  return registry;
62
79
  }
63
80
  const contractOperationRegistry = buildRegistry();
81
+ // 编排层(first-screen)需要在进程内调用其它 operation;通过 resolver 注入,
82
+ // 避免 registry ↔ 编排层形成循环依赖。
83
+ setOperationResolver(getContractOperation);
64
84
  export function getContractOperation(operation) {
65
85
  const handler = contractOperationRegistry.get(operation);
66
86
  if (!handler) {