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
@@ -0,0 +1,90 @@
1
+ import { mkdir, readFile, writeFile } from 'node:fs/promises';
2
+ import { homedir } from 'node:os';
3
+ import { dirname, resolve } from 'node:path';
4
+ const CACHE_VERSION = 1;
5
+ const MAX_ENTRIES = 500;
6
+ /** 预审记录本身有时效,预热标记 2 小时后失效,避免误跳过真正需要的重跑。 */
7
+ const DEFAULT_TTL_MS = 2 * 60 * 60 * 1000;
8
+ function cacheRoot() {
9
+ const home = process.env.WEAVER_WORK_CLI_HOME
10
+ || process.env.WORK_CLI_HOME
11
+ || resolve(homedir(), '.weaver-work-cli');
12
+ return resolve(home, 'contract');
13
+ }
14
+ export function prewarmCacheFilePath() {
15
+ return resolve(cacheRoot(), 'prewarm-cache.json');
16
+ }
17
+ function ttlMs() {
18
+ const raw = process.env.WEAVER_CONTRACT_PREWARM_CACHE_TTL_MS;
19
+ if (raw === undefined)
20
+ return DEFAULT_TTL_MS;
21
+ const parsed = Number(raw);
22
+ return Number.isFinite(parsed) && parsed >= 0 ? parsed : DEFAULT_TTL_MS;
23
+ }
24
+ export function isPrewarmCacheEnabled() {
25
+ return ttlMs() > 0;
26
+ }
27
+ /** 预热去重键:fileId + 环境 + 用户,任一不同都视为不同文件。 */
28
+ export function prewarmKey(input) {
29
+ return `${input.baseUrl}|${input.userId}|${input.fileId}`;
30
+ }
31
+ async function readCache() {
32
+ try {
33
+ const raw = (await readFile(prewarmCacheFilePath(), 'utf8')).replace(/^\uFEFF/u, '');
34
+ const parsed = JSON.parse(raw);
35
+ if (!parsed || parsed.version !== CACHE_VERSION || typeof parsed.entries !== 'object') {
36
+ return { version: CACHE_VERSION, entries: {} };
37
+ }
38
+ return parsed;
39
+ }
40
+ catch {
41
+ return { version: CACHE_VERSION, entries: {} };
42
+ }
43
+ }
44
+ async function writeCache(cache) {
45
+ try {
46
+ const path = prewarmCacheFilePath();
47
+ await mkdir(dirname(path), { recursive: true });
48
+ await writeFile(path, JSON.stringify(cache), 'utf8');
49
+ }
50
+ catch {
51
+ // 缓存写不进去不影响业务:最坏情况就是多预热一次。
52
+ }
53
+ }
54
+ /** 该 fileId 是否已经预热过(未过期)。 */
55
+ export async function wasPrewarmed(key) {
56
+ if (!isPrewarmCacheEnabled())
57
+ return false;
58
+ const cache = await readCache();
59
+ const at = cache.entries[key];
60
+ if (at === undefined)
61
+ return false;
62
+ if (Date.now() - at > ttlMs()) {
63
+ delete cache.entries[key];
64
+ await writeCache(cache);
65
+ return false;
66
+ }
67
+ return true;
68
+ }
69
+ /** 预热成功后登记,供同一轮后续步骤跳过重复调用。 */
70
+ export async function markPrewarmed(key) {
71
+ if (!isPrewarmCacheEnabled())
72
+ return;
73
+ const cache = await readCache();
74
+ cache.entries[key] = Date.now();
75
+ const keys = Object.keys(cache.entries);
76
+ if (keys.length > MAX_ENTRIES) {
77
+ keys
78
+ .sort((a, b) => cache.entries[a] - cache.entries[b])
79
+ .slice(0, keys.length - MAX_ENTRIES)
80
+ .forEach((stale) => delete cache.entries[stale]);
81
+ }
82
+ await writeCache(cache);
83
+ }
84
+ /** 清空预热标记,供排查或强制重跑使用。 */
85
+ export async function clearPrewarmCache() {
86
+ const cache = await readCache();
87
+ const count = Object.keys(cache.entries).length;
88
+ await writeCache({ version: CACHE_VERSION, entries: {} });
89
+ return count;
90
+ }
@@ -0,0 +1,88 @@
1
+ import { isPrewarmCacheEnabled, markPrewarmed, prewarmKey, wasPrewarmed } from './prewarm-cache.js';
2
+ /**
3
+ * 合同预审预热(`saveInternalRecord`)。
4
+ *
5
+ * 业务口径(2026-11-12 用户定稿):
6
+ * 1. **文件上传后就触发预热**,与上传时用的 module 无关(workflow / ebContract / docCompared 都一样);
7
+ * 2. 一整轮处理**只需要预热一次**,因此这里用 `ensurePrewarmed` 做本地去重;
8
+ * 3. 预审与 module 无关,审查页直接用会话里已有的 fileId 即可。
9
+ *
10
+ * 预热只是加速手段:失败不抛异常,收敛成 `{ ok: false, error }` 交给调用方汇总成 warnings。
11
+ */
12
+ /** 预审预热流程 ID(固定业务常量,禁止替换)。 */
13
+ export const AI_REVIEW_PREWARM_FLOW_ID = '1269716062340284522';
14
+ const PREWARM_PATH = '/api/ebd/contract/ai/saveInternalRecord';
15
+ const PREWARM_TIMEOUT_MS = 30_000;
16
+ async function prewarmOne(host, fileId) {
17
+ try {
18
+ await host.contractRequest({
19
+ method: 'POST',
20
+ path: PREWARM_PATH,
21
+ body: { flowId: AI_REVIEW_PREWARM_FLOW_ID, fileId },
22
+ timeoutMs: PREWARM_TIMEOUT_MS,
23
+ // 触发型接口:成功时响应体为空,代表"预审已在执行"。
24
+ // 不能走业务码判定,否则空体会被判成业务失败。
25
+ okOnHttpSuccess: true,
26
+ });
27
+ return { fileId, ok: true };
28
+ }
29
+ catch (error) {
30
+ const message = error instanceof Error ? error.message : String(error);
31
+ const structured = error;
32
+ const code = structured?.code === undefined ? '' : ` code=${String(structured.code)}`;
33
+ const raw = typeof structured?.details?.raw === 'string'
34
+ ? ` raw=${String(structured.details.raw).slice(0, 300)}`
35
+ : '';
36
+ return { fileId, ok: false, error: `${message}${code}${raw}` };
37
+ }
38
+ }
39
+ /**
40
+ * 按需预热:已预热过的 fileId 直接跳过,未预热的并行触发。
41
+ *
42
+ * `force: true` 时会忽略去重标记强制重跑(仅用于显式补触发命令)。
43
+ * 本函数**不抛异常**,调用方据 `failCount` 汇总 warning 即可。
44
+ */
45
+ export async function ensurePrewarmed(host, fileIds, options = {}) {
46
+ const unique = Array.from(new Set(fileIds.map((item) => String(item).trim()).filter(Boolean)));
47
+ const force = options.force === true;
48
+ let baseUrl = '';
49
+ let userId = '';
50
+ try {
51
+ const session = await host.getSession();
52
+ baseUrl = session.baseUrl ?? '';
53
+ userId = session.userId ?? '';
54
+ }
55
+ catch {
56
+ // 拿不到会话时退化为"不去重",宁可多预热一次也不阻断主流程。
57
+ }
58
+ const results = await Promise.all(unique.map(async (fileId) => {
59
+ if (!force && isPrewarmCacheEnabled() && baseUrl) {
60
+ const key = prewarmKey({ fileId, baseUrl, userId });
61
+ if (await wasPrewarmed(key)) {
62
+ return { fileId, ok: true, skipped: true };
63
+ }
64
+ }
65
+ const result = await prewarmOne(host, fileId);
66
+ if (result.ok && isPrewarmCacheEnabled() && baseUrl) {
67
+ await markPrewarmed(prewarmKey({ fileId, baseUrl, userId }));
68
+ }
69
+ return result;
70
+ }));
71
+ return {
72
+ flowId: AI_REVIEW_PREWARM_FLOW_ID,
73
+ enabled: true,
74
+ okCount: results.filter((item) => item.ok).length,
75
+ failCount: results.filter((item) => !item.ok).length,
76
+ skippedCount: results.filter((item) => item.skipped === true).length,
77
+ results,
78
+ };
79
+ }
80
+ /** 无条件预热(显式补触发用),不去重。 */
81
+ export async function prewarmAll(host, fileIds) {
82
+ const unique = Array.from(new Set(fileIds.map((item) => String(item).trim()).filter(Boolean)));
83
+ return Promise.all(unique.map((fileId) => prewarmOne(host, fileId)));
84
+ }
85
+ /** 单文件无条件预热。 */
86
+ export async function prewarmOneFile(host, fileId) {
87
+ return prewarmOne(host, fileId);
88
+ }
@@ -4,6 +4,7 @@ import { homedir } from 'node:os';
4
4
  import { dirname, resolve } from 'node:path';
5
5
  const CACHE_VERSION = 1;
6
6
  const MAX_ENTRIES = 200;
7
+ const MAX_FILE_MODULES = 500;
7
8
  const DEFAULT_TTL_MS = 24 * 60 * 60 * 1000;
8
9
  function cacheRoot() {
9
10
  const home = process.env.WEAVER_WORK_CLI_HOME
@@ -39,12 +40,19 @@ async function readCache() {
39
40
  const raw = (await readFile(cacheFilePath(), 'utf8')).replace(/^\uFEFF/u, '');
40
41
  const parsed = JSON.parse(raw);
41
42
  if (!parsed || parsed.version !== CACHE_VERSION || typeof parsed.entries !== 'object') {
42
- return { version: CACHE_VERSION, entries: {} };
43
+ return { version: CACHE_VERSION, entries: {}, fileModules: {} };
43
44
  }
44
- return parsed;
45
+ return {
46
+ version: CACHE_VERSION,
47
+ entries: parsed.entries ?? {},
48
+ // 旧版本缓存文件没有这个字段,读出来时补空对象即可。
49
+ fileModules: (parsed.fileModules && typeof parsed.fileModules === 'object')
50
+ ? parsed.fileModules
51
+ : {},
52
+ };
45
53
  }
46
54
  catch {
47
- return { version: CACHE_VERSION, entries: {} };
55
+ return { version: CACHE_VERSION, entries: {}, fileModules: {} };
48
56
  }
49
57
  }
50
58
  async function writeCache(cache) {
@@ -95,10 +103,47 @@ export async function rememberUpload(key, entry) {
95
103
  }
96
104
  await writeCache(cache);
97
105
  }
106
+ /** 登记 fileId → module,供流程侧判断能否直接复用附件文件。 */
107
+ export async function rememberFileModule(input) {
108
+ if (!isCacheEnabled() || !input.fileId)
109
+ return;
110
+ const cache = await readCache();
111
+ cache.fileModules[`${input.baseUrl}|${input.userId}|${input.fileId}`] = {
112
+ module: input.module,
113
+ updatedAt: Date.now(),
114
+ };
115
+ const keys = Object.keys(cache.fileModules);
116
+ if (keys.length > MAX_FILE_MODULES) {
117
+ keys
118
+ .sort((a, b) => cache.fileModules[a].updatedAt - cache.fileModules[b].updatedAt)
119
+ .slice(0, keys.length - MAX_FILE_MODULES)
120
+ .forEach((stale) => delete cache.fileModules[stale]);
121
+ }
122
+ await writeCache(cache);
123
+ }
124
+ /**
125
+ * 反查某个 fileId 当初是用哪个 module 上传的。
126
+ * 返回 null 表示未知(缓存过期、从未在本机上传、或换了环境/账号)。
127
+ * 调用方对 null 要按"不是 workflow"处理,即重新上传。
128
+ */
129
+ export async function lookupFileModule(input) {
130
+ if (!isCacheEnabled() || !input.fileId)
131
+ return null;
132
+ const cache = await readCache();
133
+ const entry = cache.fileModules[`${input.baseUrl}|${input.userId}|${input.fileId}`];
134
+ if (!entry)
135
+ return null;
136
+ if (Date.now() - entry.updatedAt > ttlMs()) {
137
+ delete cache.fileModules[`${input.baseUrl}|${input.userId}|${input.fileId}`];
138
+ await writeCache(cache);
139
+ return null;
140
+ }
141
+ return entry.module;
142
+ }
98
143
  /** 清空缓存,供显式刷新或多份副本排查时使用。 */
99
144
  export async function clearUploadCache() {
100
145
  const cache = await readCache();
101
146
  const count = Object.keys(cache.entries).length;
102
- await writeCache({ version: CACHE_VERSION, entries: {} });
147
+ await writeCache({ version: CACHE_VERSION, entries: {}, fileModules: {} });
103
148
  return count;
104
149
  }
@@ -109,12 +109,7 @@ export const dataShortcut = {
109
109
  .option('--schema <schema>', '库名')
110
110
  .option('--table-id <id>', '数据集 / 流程 ID')
111
111
  .option('--dsl <json|@file>', 'DSL 查询体')
112
- .option('--debug [bool]', '回显 SQL(true/false)')
113
- .option('--dimension <key>', '后端 confKey(URL query,恒定发送)')
114
- .option('--conf-group <group>', 'confGroup(URL query,恒定发送)')
115
- .option('--confGroup <group>', '同 --conf-group')
116
- .option('--username <name>', '问句中出现的人名(无则传空)')
117
- .option('--start-date <ym>', '问句日期起始年月(无则传空)')
112
+ .requiredOption('--question-context <json|@file>', '问句上下文,含 dimensions / timeRanges')
118
113
  .action(action(async (ctx, options) => {
119
114
  await run(ctx, 'data.dsl.query', toInput(options), false);
120
115
  }));
@@ -7,8 +7,8 @@ import { operationDefinitions } from './operations/index.js';
7
7
  */
8
8
  const INPUT_SCHEMAS = {
9
9
  'data.dsl.query': {
10
- required: ['conn', 'model', 'schema', 'dsl'],
11
- optional: ['table_id', 'debug', 'dimension', 'conf_group', 'username', 'start_date'],
10
+ required: ['conn', 'model', 'schema', 'dsl', 'question_context'],
11
+ optional: ['table_id'],
12
12
  },
13
13
  'data.ds.groups': { required: [], optional: ['pattern'] },
14
14
  'data.ds.find': {
@@ -8,7 +8,7 @@ import { confAdd, confAddFile, confBatch, confBatchFile, confDelete, confGet, co
8
8
  import { moduleCall } from './module.js';
9
9
  import { sceneGroups, sceneItems, sceneSearch } from './scene.js';
10
10
  const DEFINITIONS = [
11
- { name: 'data.dsl.query', summary: '直接执行 DSL 查询(executeQueryDsl),ds list/chart/stat/count 的底层入口', capability: 'dsl', handler: executeQuery, command: 'query' },
11
+ { name: 'data.dsl.query', summary: '直接执行 DSL 查询(executeQueryDsl;与 ds list/chart/stat/count 为独立通道)', capability: 'dsl', handler: executeQuery, command: 'query' },
12
12
  { name: 'data.ds.groups', summary: '内置数据源分组清单(仅用于 ds find 的默认扫描候选集)', capability: 'discovery', handler: dsGroups, command: 'ds groups' },
13
13
  { name: 'data.ds.find', summary: '按关键词跨分组找表(进程内并发扇出 + 本地过滤 + 路由建议)', capability: 'discovery', handler: dsFind, command: 'ds find' },
14
14
  { name: 'data.ds.describe', summary: '一次并发取回字段元数据 + 词库,并给出关联字段/通道提示', capability: 'discovery', handler: dsDescribe, command: 'ds describe' },
@@ -1,68 +1,30 @@
1
1
  import { needArg } from '../host.js';
2
2
  import { dataValidationError } from '../errors.js';
3
- import { readJsonArg, renderTable } from './shared.js';
4
- /** `executeQueryDsl` 的 4 个 URL query 参数——**恒定发送**,值允许为空。 */
5
- const QUERY_PARAM_ALIASES = [
6
- ['dimension', 'dimension'],
7
- ['confGroup', 'conf-group'],
8
- ['username', 'username'],
9
- ['startDate', 'start-date'],
10
- ];
11
- function argStr(input, key) {
12
- const value = input[key];
13
- // 裸开关(只写 --username 不给值)与未传都归一为空值
14
- if (value === undefined || value === null || value === true)
15
- return '';
16
- return String(value).trim();
17
- }
18
- /**
19
- * 拼 4 个恒定 query。
20
- *
21
- * 后端签名为 `executeQueryDsl(@RequestBody DslQueryVo, @RequestParam confKey,
22
- * @RequestParam confGroup, @RequestParam username, @RequestParam startDate, Employee)`,
23
- * `@RequestParam` 的 required 校验看「键是否存在」而非「值是否非空」——缺键即失败、空值合法。
24
- * 早前「空串就不带」会把最常见的情况(问句里没有人名/日期)直接打成 400/500。
25
- */
26
- function buildQueryString(input) {
27
- return '?' + QUERY_PARAM_ALIASES
28
- .map(([name, flag]) => {
29
- const snake = flag.replace(/-/g, '_');
30
- const raw = argStr(input, name) || argStr(input, snake) || argStr(input, flag);
31
- return `${encodeURIComponent(name)}=${encodeURIComponent(raw)}`;
32
- })
33
- .join('&');
34
- }
3
+ import { readJsonArg, renderTable, scanTips, tipsLines } from './shared.js';
35
4
  /**
36
5
  * DSL 直查:`POST /api/dw/dsl/executeQueryDsl`。
37
6
  *
38
- * 这是整条问数链路的底层入口,`ds list/chart/stat/count` 都是它的封装。技能里有 9 条现成调用,
39
- * 参数形式(`--conn/--model/--schema/--dsl`)必须逐字保留。
7
+ * 与 `ds list/chart/stat/count` 是独立通道:本命令发送 DslQuery,后者分别请求数据源的 get*Datas 接口。
40
8
  */
41
9
  export async function executeQuery(input, host) {
42
10
  const conn = needArg(input, 'conn');
43
11
  const model = needArg(input, 'model');
44
12
  const schema = needArg(input, 'schema');
45
13
  const dslRaw = needArg(input, 'dsl');
14
+ const questionContextRaw = needArg(input, 'question_context', 'question-context');
46
15
  const dslQuery = readJsonArg(dslRaw, '--dsl');
16
+ const questionContext = readJsonArg(questionContextRaw, '--question-context');
47
17
  const body = {
48
18
  connId: conn,
49
19
  model,
50
20
  schema,
51
21
  tableId: input.table_id || input.tableId || '',
52
22
  dslQuery,
23
+ questionContext,
53
24
  };
54
- if (input.debug !== undefined && input.debug !== null && input.debug !== '') {
55
- const flag = String(input.debug).toLowerCase();
56
- if (flag === 'true' || flag === '1')
57
- body.debug = true;
58
- else if (flag === 'false' || flag === '0')
59
- body.debug = false;
60
- else
61
- throw dataValidationError('debug_invalid', `--debug 值必须为 true 或 false(当前: ${input.debug})`);
62
- }
63
25
  const response = await host.request({
64
26
  method: 'POST',
65
- path: `/api/dw/dsl/executeQueryDsl${buildQueryString(input)}`,
27
+ path: '/api/dw/dsl/executeQueryDsl',
66
28
  body,
67
29
  headers: { 'Content-Type': 'application/json;charset=utf-8' },
68
30
  });
@@ -74,12 +36,27 @@ export async function executeQuery(input, host) {
74
36
  }
75
37
  }
76
38
  const payload = response?.data;
77
- const rows = Array.isArray(payload) ? payload : (payload && Array.isArray(payload.records) ? payload.records : []);
39
+ const rows = Array.isArray(payload)
40
+ ? payload
41
+ : Array.isArray(payload?.dataList)
42
+ ? payload.dataList
43
+ : Array.isArray(payload?.records)
44
+ ? payload.records
45
+ : [];
46
+ const tips = scanTips(response);
78
47
  const lines = [];
79
48
  if (payload && !Array.isArray(payload) && payload.sql)
80
49
  lines.push(`SQL: ${payload.sql}`);
81
50
  if (String(code) !== '200' && code !== undefined)
82
51
  lines.push(`code=${code} msg=${response?.msg || ''}`);
83
- lines.push(rows.length ? renderTable(`结果 ${rows.length} 行`, rows) : '(空:0 行)');
52
+ // 后端正常保证两类提示互斥;异常响应同时出现时,人读输出以 tipTimeout 为最高优先级。
53
+ lines.push(...tipsLines(tips.tipTimeout ? {
54
+ tipTimeout: true,
55
+ tipTimeoutMsg: tips.tipTimeoutMsg,
56
+ } : tips));
57
+ if (tips.tipTimeout)
58
+ lines.push('(平台未执行数据返回:请按上述提示收窄时间范围)');
59
+ else
60
+ lines.push(rows.length ? renderTable(`结果 ${rows.length} 行`, rows) : '(空:0 行)');
84
61
  return { data: response, text: lines.join('\n') };
85
62
  }
@@ -150,6 +150,11 @@ export const builtinShortcuts = [
150
150
  description: '泛微客户参观接待流程 CLI(面板/行程单与内部方案/填单页预填)',
151
151
  load: async () => (await import('./reception/index.js')).receptionShortcut,
152
152
  }),
153
+ lazyShortcut({
154
+ name: 'smart-extract',
155
+ description: '泛微E10智能抽取 CLI(表单结构 / 附件正文 / 校验并落库,返回 aiExtraId)',
156
+ load: async () => (await import('./smart-extract/index.js')).smartExtractShortcut,
157
+ }),
153
158
  lazyShortcut({
154
159
  name: 'data',
155
160
  description: '泛微E10数据助手 CLI(数据源查询 / 配置中心 / 场景定位)',
@@ -219,18 +219,6 @@ export const invoiceShortcut = {
219
219
  url: opts.url,
220
220
  }), projectionFrom(options));
221
221
  }));
222
- const validate = invoice.command('validate').description('Invoice validation commands');
223
- withInvoiceOptions(validate.command('preview')
224
- .description('Validate an existing invoice without saving validation result')
225
- .option('--fid <fid>', 'invoice fid')
226
- .option('--scope <scope>', 'personal or enterprise'))
227
- .action(action(async (ctx, options) => {
228
- const opts = asOptions(options);
229
- await executeAndPrint(ctx, 'invoice.validate.preview', await inputFrom(options, {
230
- fid: opts.fid,
231
- scope: opts.scope,
232
- }), projectionFrom(options));
233
- }));
234
222
  const importCommand = invoice.command('import').description('Invoice file import commands');
235
223
  withInvoiceOptions(importCommand.command('prepare')
236
224
  .description('Prepare a confirmed invoice file import')