weaver-work-cli 0.1.64 → 0.1.66

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 (91) hide show
  1. package/dist/chunks/{attachment-content-JQDW3BIB.js → attachment-content-NRBGS5XG.js} +3 -3
  2. package/dist/chunks/{chunk-RMOH2GMF.js → chunk-2BAZJCG7.js} +2 -2
  3. package/dist/chunks/{chunk-SHX7XBYR.js → chunk-4WCVRDC5.js} +83 -33
  4. package/dist/chunks/{chunk-KDFEHDIB.js → chunk-5FQT7GSN.js} +2 -2
  5. package/dist/chunks/{chunk-3PCXBG4H.js → chunk-AAOYOPHW.js} +1 -1
  6. package/dist/chunks/{chunk-5QQKLR6H.js → chunk-BZ6HAY2U.js} +7 -7
  7. package/dist/chunks/{chunk-I3MOFD6Q.js → chunk-EYEJW5SG.js} +4 -4
  8. package/dist/chunks/{chunk-SCMHG23G.js → chunk-GOZ75GHU.js} +38 -38
  9. package/dist/chunks/{chunk-4AFWOGOV.js → chunk-M7IEDTRI.js} +1 -1
  10. package/dist/chunks/{chunk-XHSEK2VM.js → chunk-NNXZMBIB.js} +6 -6
  11. package/dist/chunks/{chunk-K7QKQRSL.js → chunk-NP3ZZFGI.js} +24 -24
  12. package/dist/chunks/{chunk-INVYKG4I.js → chunk-SAADVUK6.js} +32 -32
  13. package/dist/chunks/{chunk-YTFNMQO4.js → chunk-VWQGF3KW.js} +103 -19
  14. package/dist/chunks/{chunk-AGSO3PIK.js → chunk-YFX5JKOY.js} +2 -2
  15. package/dist/chunks/{chunk-KYDXWYFB.js → chunk-YT73QQMS.js} +1 -1
  16. package/dist/chunks/{conflict-UUC7AFUI.js → conflict-LJYKIUJM.js} +2 -2
  17. package/dist/chunks/{contract-INMS7SYQ.js → contract-N5WNHKHI.js} +94 -30
  18. package/dist/chunks/{create-flow-YOR4QTAJ.js → create-flow-75MCKXGI.js} +6 -6
  19. package/dist/chunks/{entry-mode-S2ENJ6GZ.js → entry-mode-3PI6A7JD.js} +3 -3
  20. package/dist/chunks/{env-ZSAXU5PJ.js → env-FI62FOKK.js} +2 -2
  21. package/dist/chunks/{factory-N76QQA53.js → factory-HLS4SDQM.js} +1 -1
  22. package/dist/chunks/{group-chat-UM665WDZ.js → group-chat-MFBVOLKY.js} +3 -3
  23. package/dist/chunks/{lazy-dispatch-4WOIL3ZQ.js → lazy-dispatch-K25LTKQY.js} +2 -2
  24. package/dist/chunks/{meeting-MMTYDHXA.js → meeting-ROWDB3DO.js} +11 -11
  25. package/dist/chunks/{minute-doc-LCSBWGJ3.js → minute-doc-ABMO2UDX.js} +2 -2
  26. package/dist/chunks/{registry-BAWCWV4D.js → registry-NLAO2W6T.js} +2 -2
  27. package/dist/chunks/{registry-FNI5E76J.js → registry-QV6IPRVM.js} +11 -11
  28. package/dist/chunks/{room-recommend-I7QQRHEL.js → room-recommend-P54PQTCN.js} +4 -4
  29. package/dist/chunks/{schedule-3P7EWGNZ.js → schedule-BEBFGMT6.js} +4 -4
  30. package/dist/chunks/{smart-extract-FOBSVNYW.js → smart-extract-DEBLJPCQ.js} +11 -11
  31. package/dist/chunks/{workflow-U2KKTVQY.js → workflow-LBFFZZN2.js} +2 -2
  32. package/dist/cmd/refs/index.js +24 -23
  33. package/dist/core/output.js +134 -41
  34. package/dist/index.js +7 -7
  35. package/dist/shortcuts/contract/manifest.js +11 -4
  36. package/dist/shortcuts/contract/operations/first-screen.js +41 -19
  37. package/dist/shortcuts/contract/operations/flow.js +2 -0
  38. package/dist/shortcuts/contract/operations/ledger.js +58 -8
  39. package/dist/shortcuts/contract/operations/quote-recognize.js +31 -9
  40. package/dist/shortcuts/contract/operations/quote-submit.js +4 -1
  41. package/dist/shortcuts/contract/operations/upload.js +21 -1
  42. package/dist/shortcuts/contract/upload-cache.js +2 -2
  43. package/dist/shortcuts/smart-extract/operations/fill.js +14 -14
  44. package/dist/shortcuts/workflow/index.js +2 -2
  45. package/dist/shortcuts/workflow/operations/form.js +28 -4
  46. package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.categoryCounts.js +64 -0
  47. package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.collect.js +15 -0
  48. package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.core.js +4 -0
  49. package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.js +4 -0
  50. package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.prepareQuery.js +4 -0
  51. package/docs/agent-io-channel-design.md +21 -10
  52. package/docs/smart-extract.md +1 -1
  53. package/docs/todo-smart-convert/data-contract.md +1 -1
  54. package/package.json +1 -1
  55. package/skills/weaver-e10-jinchengda/SKILL.md +67 -31
  56. package/skills/weaver-e10-jinchengda/references/contract-ai-review.md +18 -18
  57. package/skills/weaver-e10-jinchengda/references/contract-clause-insert.md +4 -4
  58. package/skills/weaver-e10-jinchengda/references/contract-clause-library-crud.md +1 -1
  59. package/skills/weaver-e10-jinchengda/references/contract-command-index.md +2 -2
  60. package/skills/weaver-e10-jinchengda/references/contract-compare-report.md +6 -6
  61. package/skills/weaver-e10-jinchengda/references/contract-credit-page.md +3 -3
  62. package/skills/weaver-e10-jinchengda/references/contract-disabled-capabilities.md +1 -1
  63. package/skills/weaver-e10-jinchengda/references/contract-doc-compare.md +6 -6
  64. package/skills/weaver-e10-jinchengda/references/contract-doc-triage.md +7 -7
  65. package/skills/weaver-e10-jinchengda/references/contract-element-save-record.md +9 -9
  66. package/skills/weaver-e10-jinchengda/references/contract-execution-rules.md +3 -3
  67. package/skills/weaver-e10-jinchengda/references/contract-field-extract-new-customer.md +11 -11
  68. package/skills/weaver-e10-jinchengda/references/contract-field-extract-other-flows.md +18 -18
  69. package/skills/weaver-e10-jinchengda/references/contract-flow-launch.md +4 -4
  70. package/skills/weaver-e10-jinchengda/references/contract-ledger-catalog.md +18 -15
  71. package/skills/weaver-e10-jinchengda/references/contract-ledger-query-playbook.md +51 -28
  72. package/skills/weaver-e10-jinchengda/references/contract-ledger-rules.md +6 -6
  73. package/skills/weaver-e10-jinchengda/references/contract-modeltext-library.md +1 -1
  74. package/skills/weaver-e10-jinchengda/references/contract-multi-file.md +20 -9
  75. package/skills/weaver-e10-jinchengda/references/contract-object-detect.md +18 -18
  76. package/skills/weaver-e10-jinchengda/references/contract-open-web-pages.md +9 -9
  77. package/skills/weaver-e10-jinchengda/references/contract-performance-query.md +4 -4
  78. package/skills/weaver-e10-jinchengda/references/contract-quote-to-contract.md +42 -30
  79. package/skills/weaver-e10-jinchengda/references/contract-template-recommend.md +1 -1
  80. package/skills/weaver-e10-jinchengda/references/contract-type-fingerprints.md +8 -8
  81. package/skills/weaver-e10-jinchengda/references/contract-workflow-discovery.md +1 -1
  82. package/skills/weaver-e10-jinchengda/references/orchestration.md +2 -2
  83. package/skills/weaver-e10-jucailin/references/recruit-interview-overview.md +1 -1
  84. package/skills/weaver-e10-shared/references/json-output-contract.md +4 -3
  85. package/skills/weaver-e10-smart-extract/SKILL.md +1 -1
  86. package/skills/weaver-e10-workflow/SKILL.md +40 -16
  87. package/skills/weaver-e10-workflow/aigroup/default.json +1 -1
  88. package/skills/weaver-e10-workflow/references/todo-dialogue.md +30 -27
  89. package/skills/weaver-e10-workflow/references/todo-smart-convert.md +90 -22
  90. package/skills/weaver-e10-workflow/references/workflow-view.md +18 -2
  91. package/skills/weaver-e10-workflow/tools/todo-summary.cjs +240 -43
@@ -1,7 +1,7 @@
1
1
  import { CliError, ExitCode } from '../../core/errors.js';
2
2
  import { listRefs, pickValue, pruneRefs, readRef, readTextWindow, readWindow } from '../../core/refs.js';
3
3
  import { refsDir } from '../../core/state.js';
4
- import { bytesOf, DEFAULT_RESULT_THRESHOLD_BYTES, refMaxBytes, refMaxCount, resultThresholdBytes, } from '../../core/output.js';
4
+ import { charsOf, defaultResultThresholdChars, refMaxBytes, refMaxCount, resultThresholdChars, } from '../../core/output.js';
5
5
  /** 解析 `7d` / `24h` / `30m` / `90s` / 纯毫秒数。 */
6
6
  function parseDuration(value) {
7
7
  const raw = value.trim().toLowerCase();
@@ -50,9 +50,9 @@ export const refsCommand = {
50
50
  if (!id)
51
51
  throw new CliError('refId 不能为空', ExitCode.UsageError);
52
52
  const record = readRef(ctx, id);
53
- const configuredLimit = resultThresholdBytes(ctx);
54
- const displayLimit = configuredLimit > 0 ? configuredLimit : DEFAULT_RESULT_THRESHOLD_BYTES;
55
- if (bytesOf(record.envelope) > displayLimit) {
53
+ const configuredLimit = resultThresholdChars(ctx);
54
+ const displayLimit = configuredLimit > 0 ? configuredLimit : defaultResultThresholdChars();
55
+ if (charsOf(record.envelope) > displayLimit) {
56
56
  throw new CliError(`结果太大,不能安全地一次显示。请用 refs get ${id} <json-path> 读取需要的字段。`, ExitCode.UsageError);
57
57
  }
58
58
  // 用户主动查看完整结果,不再二次落盘。
@@ -95,19 +95,20 @@ export const refsCommand = {
95
95
  }
96
96
  const record = readRef(ctx, id);
97
97
  const picked = pickValue(record.envelope, jsonPath);
98
- const configuredLimit = resultThresholdBytes(ctx);
99
- const displayLimit = configuredLimit > 0 ? configuredLimit : DEFAULT_RESULT_THRESHOLD_BYTES;
98
+ const configuredLimit = resultThresholdChars(ctx);
99
+ const displayLimit = configuredLimit > 0 ? configuredLimit : defaultResultThresholdChars();
100
100
  if (typeof picked === 'string') {
101
101
  if (hasArrayWindow) {
102
102
  throw new CliError('字符串请使用 --char-offset / --char-limit 分段读取', ExitCode.UsageError);
103
103
  }
104
- const bytes = bytesOf(picked);
105
- if (!hasTextWindow && bytes <= displayLimit) {
104
+ const chars = charsOf(picked);
105
+ if (!hasTextWindow && chars <= displayLimit) {
106
106
  ctx.output.write(picked, { json: true, persist: false });
107
107
  return;
108
108
  }
109
109
  const totalChars = Array.from(picked).length;
110
- const perChar = totalChars > 0 ? Math.max(1, Math.ceil(bytes / totalChars)) : 1;
110
+ // 源码字符 → 序列化字符的膨胀比(换行/引号要转义),用来把字符预算折算成分段长度。
111
+ const perChar = totalChars > 0 ? Math.max(1, Math.ceil(chars / totalChars)) : 1;
111
112
  const autoLimit = Math.max(1, Math.floor((displayLimit - 2048) / perChar));
112
113
  const pageOf = (size) => {
113
114
  const window = readTextWindow(picked, charOffset, size);
@@ -131,10 +132,10 @@ export const refsCommand = {
131
132
  let size = requestedCharLimit ?? autoLimit;
132
133
  let page = pageOf(size);
133
134
  for (let round = 0; round < 8; round += 1) {
134
- const pageBytes = bytesOf(page);
135
- if (pageBytes <= displayLimit || size <= 1)
135
+ const pageChars = charsOf(page);
136
+ if (pageChars <= displayLimit || size <= 1)
136
137
  break;
137
- size = Math.max(1, Math.floor((size * displayLimit) / pageBytes) - 1);
138
+ size = Math.max(1, Math.floor((size * displayLimit) / pageChars) - 1);
138
139
  page = pageOf(size);
139
140
  }
140
141
  ctx.output.write(page, { json: true, persist: false });
@@ -147,18 +148,18 @@ export const refsCommand = {
147
148
  if (hasArrayWindow) {
148
149
  throw new CliError('--offset / --limit 只能用于数组字段', ExitCode.UsageError);
149
150
  }
150
- const bytes = bytesOf(picked);
151
- if (bytes > displayLimit) {
152
- throw new CliError(`${jsonPath} 是单个非文本值,约 ${bytes} 字节,超过单次输出预算 ${displayLimit} 字节。`
151
+ const chars = charsOf(picked);
152
+ if (chars > displayLimit) {
153
+ throw new CliError(`${jsonPath} 是单个非文本值,约 ${chars} 字符,超过单次输出预算 ${displayLimit} 字符。`
153
154
  + '请改用更细的 JSON 路径取值,或走业务命令的导出能力。', ExitCode.UsageError);
154
155
  }
155
156
  ctx.output.write(picked, { json: true, persist: false });
156
157
  return;
157
158
  }
158
159
  const total = picked.length;
159
- const bytes = bytesOf(picked);
160
- // 未给 --limit 但整段装不下时,按"平均每条字节"估一个能装下的批量,自动只回一批。
161
- const perItem = total > 0 ? Math.max(1, Math.ceil(bytes / total)) : 1;
160
+ const chars = charsOf(picked);
161
+ // 未给 --limit 但整段装不下时,按"平均每条字符"估一个能装下的批量,自动只回一批。
162
+ const perItem = total > 0 ? Math.max(1, Math.ceil(chars / total)) : 1;
162
163
  const autoLimit = Math.max(1, Math.floor((displayLimit - 2048) / perItem));
163
164
  const pageOf = (size) => {
164
165
  const window = readWindow(picked, offset, size);
@@ -178,14 +179,14 @@ export const refsCommand = {
178
179
  ...(nextHint === undefined ? {} : { largeOutputNotice: nextHint }),
179
180
  };
180
181
  };
181
- // 平均字节估不准(条目长短不一、缩进空白),按实际序列化结果回压,最多收敛 4 轮。
182
- let size = requestedLimit ?? (bytes > displayLimit ? autoLimit : Math.max(total - offset, 1));
182
+ // 平均字符估不准(条目长短不一、缩进空白),按实际序列化结果回压,最多收敛 4 轮。
183
+ let size = requestedLimit ?? (chars > displayLimit ? autoLimit : Math.max(total - offset, 1));
183
184
  let page = pageOf(size);
184
185
  for (let round = 0; round < 4; round += 1) {
185
- const pageBytes = bytesOf(page);
186
- if (pageBytes <= displayLimit || size <= 1)
186
+ const pageChars = charsOf(page);
187
+ if (pageChars <= displayLimit || size <= 1)
187
188
  break;
188
- size = Math.max(1, Math.floor((size * displayLimit) / pageBytes) - 1);
189
+ size = Math.max(1, Math.floor((size * displayLimit) / pageChars) - 1);
189
190
  page = pageOf(size);
190
191
  }
191
192
  ctx.output.write(page, { json: true, persist: false });
@@ -7,8 +7,35 @@ export function writeRawJson(outputPath, value) {
7
7
  writeFileSync(absolutePath, JSON.stringify(value, null, 2), 'utf-8');
8
8
  return absolutePath;
9
9
  }
10
- /** 宿主实测约 24-32 KB 后会把 stdout 截断成约 2048 B 预览,取保守值。 */
11
- export const DEFAULT_RESULT_THRESHOLD_BYTES = 24 * 1024;
10
+ /**
11
+ * stdout 预算按**字符数**计,对齐宿主(WorkBuddy / codebuddy 运行时)的截断口径。
12
+ *
13
+ * 宿主的 `resolveMaxShellOutputLength()` 按字符计单条命令输出上限:默认 30,000 字符,
14
+ * 可用 `BASH_MAX_OUTPUT_LENGTH` 覆盖、硬顶 150,000。超线后整段写入 `<persisted-output>`
15
+ * 的 txt,模型只拿到前 2,048 **字节**的预览加文件路径。
16
+ *
17
+ * 早期实现按 UTF-8 字节算 24 KB,对中文业务数据严重偏保守:30,000 字符最多可达 90 KB 字节,
18
+ * 而 24 KB 字节对中文表单通常只够 8,000–13,000 字符。实测同一份 10 条客户记录 42,959 字节 /
19
+ * 22,519 字符:旧实现按字节判超线、砍到 5 条;新口径整 10 条保留。
20
+ */
21
+ export const HOST_OUTPUT_MAX_CHARS_FALLBACK = 30_000;
22
+ /** 宿主侧硬顶:`Math.min(BASH_MAX_OUTPUT_LENGTH, 150000)`。 */
23
+ const HOST_OUTPUT_HARD_MAX_CHARS = 150_000;
24
+ /** 给宿主可能的包装文本留余量,并保证 refId 落在 2 KB 预览内。 */
25
+ const HOST_OUTPUT_RESERVE_CHARS = 2_000;
26
+ /** 低于这个预算就没有精简余地了。 */
27
+ const MIN_RESULT_THRESHOLD_CHARS = 2_048;
28
+ /** 宿主单条输出上限(字符)。读不到 `BASH_MAX_OUTPUT_LENGTH` 时用实测默认值。 */
29
+ export function hostOutputMaxChars(env = process.env) {
30
+ const raw = Number(env.BASH_MAX_OUTPUT_LENGTH);
31
+ return Number.isFinite(raw) && raw > 0
32
+ ? Math.min(Math.floor(raw), HOST_OUTPUT_HARD_MAX_CHARS)
33
+ : HOST_OUTPUT_MAX_CHARS_FALLBACK;
34
+ }
35
+ /** 默认预算 = 宿主上限 − 余量(缺省 28,000 字符)。 */
36
+ export function defaultResultThresholdChars(env = process.env) {
37
+ return Math.max(MIN_RESULT_THRESHOLD_CHARS, hostOutputMaxChars(env) - HOST_OUTPUT_RESERVE_CHARS);
38
+ }
12
39
  /** 比 continuation 的 10 分钟更长:读结果往往要跨多步任务。 */
13
40
  export const DEFAULT_REF_TTL_MS = 30 * 60_000;
14
41
  export const DEFAULT_REF_MAX_COUNT = 50;
@@ -20,8 +47,11 @@ const KEEP_ALL = Number.MAX_SAFE_INTEGER;
20
47
  *
21
48
  * 原顺序一上来就把数组切到 10 条,于是"查 100 条"这种请求必然看到 10 条,模型再回头重查,
22
49
  * 客户侧就是接口限流。反过来:先把每条里的长文本压短、条目一条不丢,绝大多数列表结果都能
23
- * 完整落在预算内(100 条 × 每条约 200 B ≈ 20 KB);只有字段已经压到 40 字符还超线,才退化为
24
- * 减少条目——此时 `previewOmitted` 会明确写出原始条数。
50
+ * 完整落在预算内(100 条 × 每条约 200 字符 ≈ 20,000 字符);只有字段已经压到 40 字符还超线,
51
+ * 才退化为减少条目——此时 `previewOmitted` 会明确写出原始条数。
52
+ *
53
+ * 条目档位补了 8 / 6 两档(2026-11-23):10 条的结果原先没有中间档,第一个生效的档位就是 5,
54
+ * 一步砍掉一半,模型看到 5 条就断定"服务端只返回 5 条"。降级要平滑。
25
55
  */
26
56
  const COMPACT_TIERS = [
27
57
  { array: KEEP_ALL, string: 200 },
@@ -30,6 +60,8 @@ const COMPACT_TIERS = [
30
60
  { array: 50, string: 40 },
31
61
  { array: 20, string: 40 },
32
62
  { array: 10, string: 40 },
63
+ { array: 8, string: 40 },
64
+ { array: 6, string: 30 },
33
65
  { array: 5, string: 20 },
34
66
  { array: 2, string: 20 },
35
67
  { array: 1, string: 20 },
@@ -63,9 +95,14 @@ function numeric(ctx, envName, configKey, fallback) {
63
95
  return fromConfig;
64
96
  return fallback;
65
97
  }
66
- export function resultThresholdBytes(ctx) {
67
- const value = numeric(ctx, 'WEAVER_WORK_CLI_REF_THRESHOLD', 'resultThreshold', DEFAULT_RESULT_THRESHOLD_BYTES);
68
- return value === 0 || value >= 2 * 1024 ? Math.floor(value) : DEFAULT_RESULT_THRESHOLD_BYTES;
98
+ /**
99
+ * `WEAVER_WORK_CLI_REF_THRESHOLD` / `io.resultThreshold` 沿用原名,**单位是字符**(0 = 关闭落盘)。
100
+ * 配置值低于最小预算(或非数字)时回落到按宿主上限推导的默认值。
101
+ */
102
+ export function resultThresholdChars(ctx) {
103
+ const fallback = defaultResultThresholdChars();
104
+ const value = numeric(ctx, 'WEAVER_WORK_CLI_REF_THRESHOLD', 'resultThreshold', fallback);
105
+ return value === 0 || value >= MIN_RESULT_THRESHOLD_CHARS ? Math.floor(value) : fallback;
69
106
  }
70
107
  export function refTtlMs(ctx) {
71
108
  const value = numeric(ctx, 'WEAVER_WORK_CLI_REF_TTL_MS', 'refTtlMs', DEFAULT_REF_TTL_MS);
@@ -82,6 +119,15 @@ export function refMaxBytes(ctx) {
82
119
  export function bytesOf(value) {
83
120
  return Buffer.byteLength(JSON.stringify(value ?? null, null, 2), 'utf8');
84
121
  }
122
+ /**
123
+ * 与宿主对齐的计数口径:序列化后的字符数(UTF-16 code unit),**不是** UTF-8 字节。
124
+ *
125
+ * 宿主按字符截断,中文一个字算 1 个字符却占 3 个字节;用字节做预算会让中文数据
126
+ * 被提前三倍压缩。所有"装不装得下"的判断都用这个口径。
127
+ */
128
+ export function charsOf(value) {
129
+ return JSON.stringify(value ?? null, null, 2).length;
130
+ }
85
131
  /** 链接类字段不参与截断:被截断的 URL 无法点击或调用。 */
86
132
  function isLinkField(key) {
87
133
  if (!key)
@@ -144,15 +190,15 @@ function compactValue(value, arrayLimit, stringLimit, depth = 0, key, path = '',
144
190
  }
145
191
  return value;
146
192
  }
147
- /** 逐档收紧,尽量让精简版本身也落在 stdout 预算内。 */
148
- export function compactForStdout(value, budgetBytes, sink) {
193
+ /** 逐档收紧,尽量让精简版本身也落在 stdout 预算内(预算是字符数,见 `charsOf`)。 */
194
+ export function compactForStdout(value, budgetChars, sink) {
149
195
  let current = value;
150
196
  let last = [];
151
197
  for (const tier of COMPACT_TIERS) {
152
198
  const truncations = [];
153
199
  current = compactValue(value, tier.array, tier.string, 0, undefined, '', (item) => truncations.push(item));
154
200
  last = truncations;
155
- if (bytesOf(current) <= budgetBytes)
201
+ if (charsOf(current) <= budgetChars)
156
202
  break;
157
203
  }
158
204
  for (const item of last)
@@ -165,7 +211,7 @@ export function compactForStdout(value, budgetBytes, sink) {
165
211
  * 不能只压 `data`:像 `invoice schema` 这类命令的 envelope 没有 data 键,
166
212
  * 大字段是 `operations` / `withheldOperations`,只压 data 等于没压。
167
213
  */
168
- export function compactRecord(value, budgetBytes, keepKeys, sink) {
214
+ export function compactRecord(value, budgetChars, keepKeys, sink) {
169
215
  let current = value;
170
216
  let last = [];
171
217
  for (const tier of COMPACT_TIERS) {
@@ -178,7 +224,7 @@ export function compactRecord(value, budgetBytes, keepKeys, sink) {
178
224
  }
179
225
  current = out;
180
226
  last = truncations;
181
- if (bytesOf(out) <= budgetBytes)
227
+ if (charsOf(out) <= budgetChars)
182
228
  break;
183
229
  }
184
230
  for (const item of last)
@@ -335,7 +381,46 @@ function previewTruncatedFieldsOf(truncations) {
335
381
  ]));
336
382
  }
337
383
  /**
338
- * 前置一段"这是预览"的硬提示,并给出 `previewOmitted` 机读索引。
384
+ * 恢复指引:把"下一步怎么取全量"写成可复制的命令。
385
+ *
386
+ * 只写"这是预览"没用——真机见过模型看到 5 条就断定"服务端只返回 5 条",改分页参数反复重查
387
+ * (一次任务打了 19 次接口)。模型缺的不是免责声明,是**下一步做什么**。所以这里把 refId、
388
+ * 被裁的路径、剩余条数和续读命令一起前置到 `data` 之前。
389
+ *
390
+ * 只在整数组路径(不含 `[N]`)上给命令:`refs get` 按路径取数组,元素级模板路径喂不进去。
391
+ */
392
+ function recoveryOf(leading, truncations) {
393
+ const refId = typeof leading.refId === 'string' ? leading.refId.trim() : '';
394
+ if (!refId || leading.resultPersisted !== true)
395
+ return undefined;
396
+ const groups = dedupeByTemplate(truncations).sort(byOmitted);
397
+ const array = groups.find((item) => item.kind === 'array');
398
+ const text = groups.find((item) => item.kind === 'string');
399
+ if (!array && !text)
400
+ return undefined;
401
+ const out = {
402
+ refId,
403
+ note: '完整结果已暂存在本地 ref:不要重新调用业务接口取同一批数据,也不要拿预览判断条数或分页。',
404
+ };
405
+ if (array) {
406
+ const path = normalizePath(array.path);
407
+ const remaining = array.total - array.shown;
408
+ out.items = { path, total: array.total, shown: array.shown, remaining };
409
+ if (!path.includes('[') && remaining > 0) {
410
+ out.readRemainingItems = `weaver-work-cli refs get ${refId} ${path}`
411
+ + ` --offset ${array.shown} --limit ${Math.min(remaining, 50)}`;
412
+ }
413
+ }
414
+ if (text) {
415
+ const path = normalizePath(text.path);
416
+ if (!path.includes('[')) {
417
+ out.readTruncatedText = `weaver-work-cli refs get ${refId} ${path} --char-offset 0 --char-limit 2000`;
418
+ }
419
+ }
420
+ return out;
421
+ }
422
+ /**
423
+ * 前置一段"这是预览"的硬提示,并给出 `previewOmitted` / `recovery` 机读索引。
339
424
  *
340
425
  * 没有截断时原样返回 `leading`,保证小结果的信封逐字节不变。
341
426
  */
@@ -343,28 +428,30 @@ function withTruncationNotice(leading, truncations) {
343
428
  const detail = describeTruncations(truncations);
344
429
  if (!detail)
345
430
  return leading;
346
- const refId = String(leading.refId ?? '<refId>');
347
- const recovery = leading.resultPersisted === true
348
- ? `取全量用 --input-ref ${refId},或 refs get ${refId} <字段路径>。`
349
- : '完整结果未能暂存,无法恢复。';
350
- const notice = `${String(leading.largeOutputNotice ?? '')}⚠️ stdout 仅为预览,不是全量:`
351
- + `${detail}。${recovery}`;
431
+ const persisted = leading.resultPersisted === true;
352
432
  const omitted = previewOmittedOf(truncations);
433
+ const recovery = recoveryOf(leading, truncations);
353
434
  const truncatedFields = previewTruncatedFieldsOf(truncations);
435
+ const tail = persisted
436
+ ? (recovery ? '' : '完整结果在本地 ref,用 refs get 按路径取,不要重新调用业务接口。')
437
+ : '完整结果未能暂存,无法恢复。';
438
+ const notice = `⚠️ stdout 仅为预览,不是全量(不要据此判断条数或分页):${detail}。${tail}`;
439
+ const { largeOutputNotice: rawNotice, ...rest } = leading;
354
440
  return {
355
- ...leading,
441
+ ...rest,
356
442
  ...(omitted ? { previewOmitted: omitted } : {}),
443
+ ...(recovery ? { recovery } : {}),
444
+ largeOutputNotice: `${String(rawNotice ?? '')}${notice}`,
357
445
  ...(truncatedFields ? { previewTruncatedFields: truncatedFields } : {}),
358
- largeOutputNotice: notice,
359
446
  };
360
447
  }
361
- function slimmedBody(value, threshold, hasRef) {
448
+ function slimmedBody(value, thresholdChars, hasRef) {
362
449
  const base = value && typeof value === 'object' && !Array.isArray(value)
363
450
  ? value
364
451
  : { data: value };
365
452
  const truncations = [];
366
- const compacted = compactRecord(base, threshold, ENVELOPE_KEEP_KEYS, (item) => truncations.push(item));
367
- if (bytesOf(compacted) <= threshold)
453
+ const compacted = compactRecord(base, thresholdChars, ENVELOPE_KEEP_KEYS, (item) => truncations.push(item));
454
+ if (charsOf(compacted) <= thresholdChars)
368
455
  return { body: compacted, truncations };
369
456
  return { body: skeletonOf(base, ENVELOPE_KEEP_KEYS, hasRef), truncations: skeletonTruncations(base) };
370
457
  }
@@ -378,32 +465,33 @@ function skeletonTruncations(base) {
378
465
  }
379
466
  return out;
380
467
  }
381
- function fitEnvelope(value, leading, extraWarnings, budgetBytes) {
468
+ function fitEnvelope(value, leading, extraWarnings, budgetChars) {
382
469
  const hasRef = leading.resultPersisted === true;
383
- const { body, truncations } = slimmedBody(value, budgetBytes, hasRef);
470
+ const { body, truncations } = slimmedBody(value, budgetChars, hasRef);
384
471
  let envelope = withLeadingMeta(value, withTruncationNotice(leading, truncations), body, extraWarnings);
385
- if (bytesOf(envelope) <= budgetBytes)
472
+ if (charsOf(envelope) <= budgetChars)
386
473
  return envelope;
387
474
  const base = value && typeof value === 'object' && !Array.isArray(value)
388
475
  ? value
389
476
  : { data: value };
390
477
  envelope = withLeadingMeta(value, withTruncationNotice(leading, skeletonTruncations(base)), skeletonOf(base, ENVELOPE_KEEP_KEYS, leading.resultPersisted === true), extraWarnings);
391
- if (bytesOf(envelope) <= budgetBytes)
478
+ if (charsOf(envelope) <= budgetChars)
392
479
  return envelope;
393
480
  const persisted = leading.resultPersisted === true;
394
481
  const refId = String(leading.refId ?? '').slice(0, 80);
395
482
  const finalOmitted = previewOmittedOf(skeletonTruncations(base));
396
483
  const finalNotice = persisted
397
- ? `结果已精简,使用 --input-ref ${refId} 读取。`
484
+ ? `结果已精简:完整内容在本地 ref ${refId},用 refs get ${refId} <路径> 取,不要重新调用业务接口。`
398
485
  : '结果无法暂存;stdout 仅保留精简内容,完整结果不可恢复。';
399
486
  const finalDetail = describeTruncations(skeletonTruncations(base));
400
487
  return {
401
488
  ...(persisted ? { refId } : {}),
402
489
  resultPersisted: persisted,
403
- outputBytes: Number(leading.outputBytes) || 0,
404
- largeOutputNotice: finalDetail ? `${finalNotice}⚠️ 预览不是全量:${finalDetail}。` : finalNotice,
405
490
  previewTruncated: true,
406
491
  ...(finalOmitted ? { previewOmitted: finalOmitted } : {}),
492
+ outputChars: Number(leading.outputChars) || 0,
493
+ outputBytes: Number(leading.outputBytes) || 0,
494
+ largeOutputNotice: finalDetail ? `${finalNotice}⚠️ 预览不是全量:${finalDetail}。` : finalNotice,
407
495
  schemaVersion: typeof base.schemaVersion === 'number' || typeof base.schemaVersion === 'string'
408
496
  ? String(base.schemaVersion).slice(0, 20)
409
497
  : 1,
@@ -483,13 +571,15 @@ export class Output {
483
571
  console.log(stringifyForStdout(this.prepare(value, options), options.compactPaths));
484
572
  }
485
573
  prepare(value, options) {
486
- const threshold = resultThresholdBytes(this.ctx);
574
+ const threshold = resultThresholdChars(this.ctx);
487
575
  if (options.persist === false || threshold <= 0)
488
576
  return value;
489
577
  const finalBudget = Math.max(1024, threshold - 1024);
490
- const bytes = bytesOf(value);
491
- if (bytes <= threshold)
578
+ const chars = charsOf(value);
579
+ if (chars <= threshold)
492
580
  return value;
581
+ // 字节数只用于回报(refs list / 通知文案),预算判断一律走字符。
582
+ const bytes = bytesOf(value);
493
583
  const limits = { maxCount: refMaxCount(this.ctx), maxBytes: refMaxBytes(this.ctx) };
494
584
  const warnings = [];
495
585
  try {
@@ -511,7 +601,7 @@ export class Output {
511
601
  warnings.push('ref_store_over_limit');
512
602
  if (retention?.cleanupIncomplete)
513
603
  warnings.push('ref_gc_incomplete');
514
- return fitEnvelope(value, this.leadingFor(meta, bytes, retention), warnings, finalBudget);
604
+ return fitEnvelope(value, this.leadingFor(meta, bytes, chars, retention), warnings, finalBudget);
515
605
  }
516
606
  catch (error) {
517
607
  // 落盘失败绝不静默截断:标注 degraded,让调用方知道这份结果不完整。
@@ -523,15 +613,16 @@ export class Output {
523
613
  : code === 'EACCES' || code === 'EPERM'
524
614
  ? 'CLI 暂存目录无写入权限'
525
615
  : '无法写入 CLI 暂存目录';
526
- process.stderr.write(`[weaver-work-cli] 结果 ${bytes} 字节超过 stdout 预算 ${threshold} 字节且落盘失败,输出已精简:${message}\n`);
616
+ process.stderr.write(`[weaver-work-cli] 结果 ${chars} 字符(${bytes} 字节)超过 stdout 预算 ${threshold} 字符且落盘失败,输出已精简:${message}\n`);
527
617
  return fitEnvelope(value, {
528
618
  outputBytes: bytes,
619
+ outputChars: chars,
529
620
  resultPersisted: false,
530
621
  largeOutputNotice: `结果超过 stdout 限制且无法暂存;当前内容已精简,可能不完整:${message.slice(0, 160)}`,
531
622
  }, ['result_persist_failed'], finalBudget);
532
623
  }
533
624
  }
534
- leadingFor(meta, bytes, retention) {
625
+ leadingFor(meta, bytes, chars, retention) {
535
626
  const retentionNotice = retention?.cleanupIncomplete
536
627
  ? ' 部分旧引用暂时无法删除,CLI 会在后续命令重试。'
537
628
  : retention?.overLimit
@@ -540,12 +631,14 @@ export class Output {
540
631
  return {
541
632
  refId: meta.refId,
542
633
  resultPersisted: true,
543
- outputBytes: bytes,
634
+ previewTruncated: true,
544
635
  sha256: meta.sha256,
545
636
  expiresAt: meta.expiresAt,
546
- previewTruncated: true,
547
- largeOutputNotice: `结果 ${bytes} 字节已暂存。使用 --input-ref ${meta.refId} 引用;`
548
- + `取单个字段时加 --pick-as <字段名>。`
637
+ outputChars: chars,
638
+ outputBytes: bytes,
639
+ largeOutputNotice: `结果 ${chars} 字符已超 stdout 预算 ${resultThresholdChars(this.ctx)} 字符,全量已暂存为本地 ref。`
640
+ + `取全量用 refs get ${meta.refId} <路径>(或 --input-ref ${meta.refId} 喂给下一条命令),`
641
+ + '不要重新调用业务接口。'
549
642
  + retentionNotice,
550
643
  };
551
644
  }
package/dist/index.js CHANGED
@@ -7,8 +7,8 @@ import {
7
7
  firstPositionalToken,
8
8
  registerCommands,
9
9
  toCommandMetadata
10
- } from "./chunks/chunk-K7QKQRSL.js";
11
- import "./chunks/chunk-SHX7XBYR.js";
10
+ } from "./chunks/chunk-NP3ZZFGI.js";
11
+ import "./chunks/chunk-4WCVRDC5.js";
12
12
  import "./chunks/chunk-AJ62BGAW.js";
13
13
  import "./chunks/chunk-WSHIOSGM.js";
14
14
  import "./chunks/chunk-6N4JPNFL.js";
@@ -31,7 +31,7 @@ function lazyShortcut(definition) {
31
31
  placeholder.allowExcessArguments(true);
32
32
  placeholder.helpOption(false);
33
33
  placeholder.action(async () => {
34
- const { dispatchLazyShortcut } = await import("./chunks/lazy-dispatch-4WOIL3ZQ.js");
34
+ const { dispatchLazyShortcut } = await import("./chunks/lazy-dispatch-K25LTKQY.js");
35
35
  await dispatchLazyShortcut(definition, shortcutMetadata());
36
36
  });
37
37
  }
@@ -96,7 +96,7 @@ var builtinShortcuts = [
96
96
  lazyShortcut({
97
97
  name: "meeting",
98
98
  description: "\u6CDB\u5FAEE10\u4F1A\u8BAE\u7BA1\u7406 CLI\uFF08\u6807\u51C6\u7248\uFF1A\u67E5\u8BE2/\u51B2\u7A81/\u9884\u7EA6/\u56DE\u6267/\u7B7E\u5230\uFF09",
99
- load: async () => (await import("./chunks/meeting-MMTYDHXA.js")).meetingShortcut
99
+ load: async () => (await import("./chunks/meeting-ROWDB3DO.js")).meetingShortcut
100
100
  }),
101
101
  lazyShortcut({
102
102
  name: "okr",
@@ -146,7 +146,7 @@ var builtinShortcuts = [
146
146
  lazyShortcut({
147
147
  name: "workflow",
148
148
  description: "\u6CDB\u5FAEE10\u6D41\u7A0B\u667A\u80FD\u52A9\u624B CLI\uFF08\u67E5\u8BE2/\u67E5\u770B/\u64CD\u4F5C/\u6279\u91CF/\u53D1\u8D77/\u4FEE\u6539\uFF09",
149
- load: async () => (await import("./chunks/workflow-U2KKTVQY.js")).workflowShortcut
149
+ load: async () => (await import("./chunks/workflow-LBFFZZN2.js")).workflowShortcut
150
150
  }),
151
151
  lazyShortcut({
152
152
  name: "blog",
@@ -161,7 +161,7 @@ var builtinShortcuts = [
161
161
  lazyShortcut({
162
162
  name: "contract",
163
163
  description: "\u6CDB\u5FAEE10\u4ECA\u627F\u8FBE\u5408\u540C\u7BA1\u7406 CLI",
164
- load: async () => (await import("./chunks/contract-INMS7SYQ.js")).contractShortcut
164
+ load: async () => (await import("./chunks/contract-N5WNHKHI.js")).contractShortcut
165
165
  }),
166
166
  lazyShortcut({
167
167
  name: "reception",
@@ -171,7 +171,7 @@ var builtinShortcuts = [
171
171
  lazyShortcut({
172
172
  name: "smart-extract",
173
173
  description: "\u6CDB\u5FAEE10\u667A\u80FD\u62BD\u53D6 CLI\uFF08\u8868\u5355\u7ED3\u6784 / \u9644\u4EF6\u6B63\u6587 / \u6821\u9A8C\u5E76\u843D\u5E93\uFF0C\u8FD4\u56DE aiExtraId\uFF09",
174
- load: async () => (await import("./chunks/smart-extract-FOBSVNYW.js")).smartExtractShortcut
174
+ load: async () => (await import("./chunks/smart-extract-DEBLJPCQ.js")).smartExtractShortcut
175
175
  }),
176
176
  lazyShortcut({
177
177
  name: "data",
@@ -484,8 +484,8 @@ const quoteContracts = [
484
484
  fileId: { type: 'string', minLength: 1, description: 'flow.launch 返回的 workflow fileId(唯一来源)' },
485
485
  flow: { type: 'string', enum: ['契约锁', '新客户', '常规二次销售', '老客户增值'], description: '合同类型;不传则按报价单类型标识识别,判不出返回 needsConfirm 待确认' },
486
486
  customerName: { type: 'string', minLength: 1, description: '报价单客户全称(即最终用户)' },
487
- contractTitle: { type: 'string', maxLength: 400, description: '合同名称;缺省按「客户全称 + 合同管理系统软件产品及实施服务购买合同」生成' },
488
- contractFileName: { type: 'string', maxLength: 400, description: '合同文件落盘名;缺省与 contractTitle 同名,通用名(如「合同」)会被纠正为合同名称' },
487
+ contractTitle: { type: 'string', maxLength: 400, description: '合同名称;缺省按 §5.2 规则「{客户全称}协同办公系统(e-cology)软件产品及实施服务购买合同」生成' },
488
+ contractFileName: { type: 'string', maxLength: 400, description: '合同文件落盘名;缺省与 contractTitle 同名,通用名(如「合同」)会被纠正为规范合同名(§5.2)。⚠️ 本项目不要用它改上传名——上传名由 quotescreen.submit 统一决定' },
489
489
  totalAmount: {
490
490
  anyOf: [{ type: 'number' }, { type: 'string' }, { type: 'object' }],
491
491
  description: '报价单最终优惠报价(不是标准价合计)。三选一:① 纯数值(如 809166.76);② 可唯一归一的字符串(如 "¥809,166.76");③ **推荐**值引用 {"$quote":"<解析结果.json 绝对路径>#totals.final_total"},真值由本进程读、金额不经过模型上下文。传脱敏占位符 [[MONEY_*]] 会被 total_amount_placeholder 拒收',
@@ -514,8 +514,8 @@ const quoteContracts = [
514
514
  anyOf: [{ type: 'number' }, { type: 'string' }, { type: 'object' }],
515
515
  description: '报价单最终优惠报价(不是标准价合计)。三选一:① 纯数值(如 809166.76);② 可唯一归一的字符串(如 "¥809,166.76");③ **推荐**值引用 {"$quote":"<解析结果.json 绝对路径>#totals.final_total"}。传脱敏占位符 [[MONEY_*]] 会被 total_amount_placeholder 拒收',
516
516
  },
517
- contractTitle: { type: 'string', maxLength: 400, description: '合同名称;缺省按「客户全称 + 合同管理系统软件产品及实施服务购买合同」生成' },
518
- fileName: { type: 'string', maxLength: 400, description: '合同文件名;缺省取 contractPath 的文件名,通用名(如「合同」)会被纠正为合同名称' },
517
+ contractTitle: { type: 'string', maxLength: 400, description: '合同名称;缺省按 §5.2 规则「{客户全称}协同办公系统(e-cology)软件产品及实施服务购买合同」生成。**建议照实传真实标题**——它同时决定上传文件名' },
518
+ fileName: { type: 'string', maxLength: 400, description: '合同文件名(**就是上传到 E10 的附件名**);缺省取 contractPath 的文件名,通用名(如「合同」「合同文件」)会被纠正为规范合同名(§5.2)并一路透传到上传;返回值 expectedFileName 即实际生效的附件名' },
519
519
  ourCompany: { type: 'string', description: '我方签约主体,默认「泛微网络科技股份有限公司」' },
520
520
  sections: { type: 'array', items: { type: 'object' }, description: '报价单费用分节(name + amount),用于归纳合同背景说明' },
521
521
  background: { type: 'string', maxLength: 2000, description: '合同背景说明;不传按报价单分节自动归纳' },
@@ -1357,6 +1357,13 @@ export const contractOperations = [
1357
1357
  inputSchema: readSchema({
1358
1358
  flow: { type: 'string', enum: ['契约锁', '新客户', '老客户增值', '常规二次销售'] },
1359
1359
  path: { type: 'string', minLength: 1, maxLength: 1000 },
1360
+ fileName: {
1361
+ type: 'string',
1362
+ maxLength: 200,
1363
+ description: '上传到文件服务时用的文件名(纯文件名,不含路径);缺省取 path 的 basename。'
1364
+ + '**代码生成的文件必须传规范合同名**(报价单转合同链路由 quotescreen.submit 自动透传),'
1365
+ + '否则 E10 附件列表里会出现「合同.docx」这种无法辨识的名字',
1366
+ },
1360
1367
  }, ['flow', 'path']),
1361
1368
  },
1362
1369
  {
@@ -44,6 +44,43 @@ function pyTruthy(value) {
44
44
  function truthyText(value) {
45
45
  return pyTruthy(value) ? String(value) : '';
46
46
  }
47
+ /**
48
+ * 收口「即将提交」的识别记录内容:补全 `attachmentIds`(**全部**附件 ID,逗号拼接)与
49
+ * `attachmentFileId`(主文件),剔除附件字段行,并把**最终**内容回写到自动产物。
50
+ *
51
+ * ⛔ 为什么必须"先收口、再把最终内容落盘"(2026-11-23 实测,多文件):
52
+ * 原先 `recognize_auto.json` 在补 `attachmentIds` **之前**就写盘 —— 磁盘存档里只有主文件
53
+ * 一个 ID(实测 `1340965476650696739`),而真实请求带的是全部两个 ID。**存档必须等于请求**:
54
+ * 否则排障的人打开存档会得出「随附文件没进识别记录」的错误结论,去修一个不存在的问题。
55
+ *
56
+ * `artifactPath` 只传 CLI 自己生成的产物路径;用户显式传入的 `recognizeFile` 传 null,不得覆盖。
57
+ */
58
+ export function finalizeRecognizePayload(payload, ids, artifactPath = null) {
59
+ const primary = truthyText(ids.workflowFileId);
60
+ if (primary) {
61
+ // 多附件:attachmentIds 为全部文件 ID 逗号拼接;attachmentFileId 取主文件。
62
+ // 列表缺失或全为空时退化为单文件(不编造、不静默丢主文件)。
63
+ const all = Array.isArray(ids.workflowFileIds)
64
+ ? ids.workflowFileIds.map((item) => truthyText(item)).filter((item) => item)
65
+ : [];
66
+ payload.attachmentIds = (all.length ? all : [primary]).join(',');
67
+ payload.attachmentFileId = primary;
68
+ }
69
+ // 存储接口不得接收附件字段:附件只由流程组件 customParams 透传赋值
70
+ try {
71
+ const rows = (payload.recognizeResult?.mainTable?.rows ?? []);
72
+ for (const row of rows) {
73
+ const list = Array.isArray(row.fieldResults) ? row.fieldResults : [];
74
+ row.fieldResults = list.filter((item) => !String(item?.fieldInfo ?? '').endsWith(ATTACHMENT_FIELD_SUFFIX));
75
+ }
76
+ }
77
+ catch {
78
+ // 结构异常时保持原样,交由下游校验
79
+ }
80
+ if (artifactPath)
81
+ writeFileSync(artifactPath, JSON.stringify(payload), 'utf8');
82
+ return payload;
83
+ }
47
84
  function isFile(path) {
48
85
  try {
49
86
  return existsSync(path) && statSync(path).isFile();
@@ -358,25 +395,10 @@ export const contractFirstScreenOperation = {
358
395
  out.warn.push(`recognizeResult 文件无法解析:${error instanceof Error ? error.message : String(error)}`);
359
396
  return out;
360
397
  }
361
- if (result.workflowFileId) {
362
- // 多附件:attachmentIds 为全部文件 ID 逗号拼接;attachmentFileId 取主文件
363
- const allIds = Array.isArray(result.workflowFileIds) && result.workflowFileIds.length
364
- ? result.workflowFileIds
365
- : [String(result.workflowFileId)];
366
- payload.attachmentIds = allIds.join(',');
367
- payload.attachmentFileId = result.workflowFileId;
368
- }
369
- // 存储接口不得接收附件字段:附件只由流程组件 customParams 透传赋值
370
- try {
371
- const rows = (payload.recognizeResult?.mainTable?.rows ?? []);
372
- for (const row of rows) {
373
- const list = Array.isArray(row.fieldResults) ? row.fieldResults : [];
374
- row.fieldResults = list.filter((item) => !String(item?.fieldInfo ?? '').endsWith(ATTACHMENT_FIELD_SUFFIX));
375
- }
376
- }
377
- catch {
378
- // 结构异常时保持原样,交由下游校验
379
- }
398
+ // 收口后再落盘:存档必须等于请求(见 finalizeRecognizePayload 注释)。
399
+ // 用户显式传入的 recognizeFile 不覆盖,只回写 CLI 自己生成的 recognize_auto.json。
400
+ const autoArtifact = join(outDir, 'recognize_auto.json');
401
+ payload = finalizeRecognizePayload(payload, { workflowFileId: result.workflowFileId, workflowFileIds: result.workflowFileIds }, recPath === autoArtifact ? recPath : null);
380
402
  const rows = (payload.recognizeResult?.mainTable?.rows ?? []);
381
403
  const hasFields = rows.length > 0 && Array.isArray(rows[0].fieldResults) && rows[0].fieldResults.length > 0;
382
404
  if (!hasFields) {
@@ -170,6 +170,8 @@ export const contractFlowOperations = [
170
170
  uploaded = await uploadFile(host, {
171
171
  path: rawPath,
172
172
  module: 'workflow',
173
+ // 规范文件名(可选):报价单转合同链路由代码算好并透传,避免附件名等于本地临时名(如「合同.docx」)
174
+ fileName: optionalText(input.fileName),
173
175
  // 预热的 flowId = 本轮流程 workflowId(助手 URL 上的同一个值)
174
176
  prewarmFlowId: flow.workflowId,
175
177
  extraFields: {