weaver-work-cli 0.1.65 → 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.
- package/dist/chunks/{attachment-content-QUM27QNB.js → attachment-content-NRBGS5XG.js} +3 -3
- package/dist/chunks/{chunk-F4ME3CGS.js → chunk-2BAZJCG7.js} +2 -2
- package/dist/chunks/{chunk-SHX7XBYR.js → chunk-4WCVRDC5.js} +83 -33
- package/dist/chunks/{chunk-IJDZ7VDC.js → chunk-5FQT7GSN.js} +2 -2
- package/dist/chunks/{chunk-E3OQSNF5.js → chunk-AAOYOPHW.js} +1 -1
- package/dist/chunks/{chunk-LRK7YND4.js → chunk-BZ6HAY2U.js} +7 -7
- package/dist/chunks/{chunk-6AW5LW4T.js → chunk-EYEJW5SG.js} +4 -4
- package/dist/chunks/{chunk-CUY64WP4.js → chunk-GOZ75GHU.js} +38 -38
- package/dist/chunks/{chunk-JDZOYHAL.js → chunk-M7IEDTRI.js} +1 -1
- package/dist/chunks/{chunk-NZLFKBEM.js → chunk-NNXZMBIB.js} +6 -6
- package/dist/chunks/{chunk-K7QKQRSL.js → chunk-NP3ZZFGI.js} +24 -24
- package/dist/chunks/{chunk-QT7GGCSY.js → chunk-SAADVUK6.js} +32 -32
- package/dist/chunks/{chunk-IT3SB7RV.js → chunk-VWQGF3KW.js} +15 -4
- package/dist/chunks/{chunk-D6SWOUUP.js → chunk-YFX5JKOY.js} +2 -2
- package/dist/chunks/{chunk-ZV3TYANI.js → chunk-YT73QQMS.js} +1 -1
- package/dist/chunks/{conflict-76ZUL3E7.js → conflict-LJYKIUJM.js} +2 -2
- package/dist/chunks/{contract-INMS7SYQ.js → contract-N5WNHKHI.js} +94 -30
- package/dist/chunks/{create-flow-7WGKLRHH.js → create-flow-75MCKXGI.js} +6 -6
- package/dist/chunks/{entry-mode-3UMMMK6Z.js → entry-mode-3PI6A7JD.js} +3 -3
- package/dist/chunks/{env-7EGXNZR2.js → env-FI62FOKK.js} +2 -2
- package/dist/chunks/{factory-BDERKTYX.js → factory-HLS4SDQM.js} +1 -1
- package/dist/chunks/{group-chat-4E7EZMTJ.js → group-chat-MFBVOLKY.js} +3 -3
- package/dist/chunks/{lazy-dispatch-4WOIL3ZQ.js → lazy-dispatch-K25LTKQY.js} +2 -2
- package/dist/chunks/{meeting-2FMYZXG5.js → meeting-ROWDB3DO.js} +11 -11
- package/dist/chunks/{minute-doc-3DHMYMBE.js → minute-doc-ABMO2UDX.js} +2 -2
- package/dist/chunks/{registry-6UGQO35C.js → registry-NLAO2W6T.js} +2 -2
- package/dist/chunks/{registry-XXFMYPBM.js → registry-QV6IPRVM.js} +11 -11
- package/dist/chunks/{room-recommend-7LD2OHL5.js → room-recommend-P54PQTCN.js} +4 -4
- package/dist/chunks/{schedule-ZAYMZKTQ.js → schedule-BEBFGMT6.js} +4 -4
- package/dist/chunks/{smart-extract-FOBSVNYW.js → smart-extract-DEBLJPCQ.js} +11 -11
- package/dist/chunks/{workflow-NYJJIT3D.js → workflow-LBFFZZN2.js} +2 -2
- package/dist/cmd/refs/index.js +24 -23
- package/dist/core/output.js +134 -41
- package/dist/index.js +7 -7
- package/dist/shortcuts/contract/manifest.js +11 -4
- package/dist/shortcuts/contract/operations/first-screen.js +41 -19
- package/dist/shortcuts/contract/operations/flow.js +2 -0
- package/dist/shortcuts/contract/operations/ledger.js +58 -8
- package/dist/shortcuts/contract/operations/quote-recognize.js +31 -9
- package/dist/shortcuts/contract/operations/quote-submit.js +4 -1
- package/dist/shortcuts/contract/operations/upload.js +21 -1
- package/dist/shortcuts/contract/upload-cache.js +2 -2
- package/dist/shortcuts/smart-extract/operations/fill.js +14 -14
- package/dist/shortcuts/workflow/index.js +2 -2
- package/dist/shortcuts/workflow/operations/form.js +28 -4
- package/docs/agent-io-channel-design.md +21 -10
- package/docs/smart-extract.md +1 -1
- package/docs/todo-smart-convert/data-contract.md +1 -1
- package/package.json +1 -1
- package/skills/weaver-e10-jinchengda/SKILL.md +67 -31
- package/skills/weaver-e10-jinchengda/references/contract-ai-review.md +18 -18
- package/skills/weaver-e10-jinchengda/references/contract-clause-insert.md +4 -4
- package/skills/weaver-e10-jinchengda/references/contract-clause-library-crud.md +1 -1
- package/skills/weaver-e10-jinchengda/references/contract-command-index.md +2 -2
- package/skills/weaver-e10-jinchengda/references/contract-compare-report.md +6 -6
- package/skills/weaver-e10-jinchengda/references/contract-credit-page.md +3 -3
- package/skills/weaver-e10-jinchengda/references/contract-disabled-capabilities.md +1 -1
- package/skills/weaver-e10-jinchengda/references/contract-doc-compare.md +6 -6
- package/skills/weaver-e10-jinchengda/references/contract-doc-triage.md +7 -7
- package/skills/weaver-e10-jinchengda/references/contract-element-save-record.md +9 -9
- package/skills/weaver-e10-jinchengda/references/contract-execution-rules.md +3 -3
- package/skills/weaver-e10-jinchengda/references/contract-field-extract-new-customer.md +11 -11
- package/skills/weaver-e10-jinchengda/references/contract-field-extract-other-flows.md +18 -18
- package/skills/weaver-e10-jinchengda/references/contract-flow-launch.md +4 -4
- package/skills/weaver-e10-jinchengda/references/contract-ledger-catalog.md +18 -15
- package/skills/weaver-e10-jinchengda/references/contract-ledger-query-playbook.md +51 -28
- package/skills/weaver-e10-jinchengda/references/contract-ledger-rules.md +6 -6
- package/skills/weaver-e10-jinchengda/references/contract-modeltext-library.md +1 -1
- package/skills/weaver-e10-jinchengda/references/contract-multi-file.md +20 -9
- package/skills/weaver-e10-jinchengda/references/contract-object-detect.md +18 -18
- package/skills/weaver-e10-jinchengda/references/contract-open-web-pages.md +9 -9
- package/skills/weaver-e10-jinchengda/references/contract-performance-query.md +4 -4
- package/skills/weaver-e10-jinchengda/references/contract-quote-to-contract.md +42 -30
- package/skills/weaver-e10-jinchengda/references/contract-template-recommend.md +1 -1
- package/skills/weaver-e10-jinchengda/references/contract-type-fingerprints.md +8 -8
- package/skills/weaver-e10-jinchengda/references/contract-workflow-discovery.md +1 -1
- package/skills/weaver-e10-jinchengda/references/orchestration.md +2 -2
- package/skills/weaver-e10-jucailin/references/recruit-interview-overview.md +1 -1
- package/skills/weaver-e10-shared/references/json-output-contract.md +4 -3
- package/skills/weaver-e10-smart-extract/SKILL.md +1 -1
package/dist/core/output.js
CHANGED
|
@@ -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
|
-
/**
|
|
11
|
-
|
|
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
|
|
24
|
-
*
|
|
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
|
-
|
|
67
|
-
|
|
68
|
-
|
|
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,
|
|
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 (
|
|
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,
|
|
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 (
|
|
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
|
-
*
|
|
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
|
|
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
|
-
...
|
|
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,
|
|
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,
|
|
367
|
-
if (
|
|
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,
|
|
468
|
+
function fitEnvelope(value, leading, extraWarnings, budgetChars) {
|
|
382
469
|
const hasRef = leading.resultPersisted === true;
|
|
383
|
-
const { body, truncations } = slimmedBody(value,
|
|
470
|
+
const { body, truncations } = slimmedBody(value, budgetChars, hasRef);
|
|
384
471
|
let envelope = withLeadingMeta(value, withTruncationNotice(leading, truncations), body, extraWarnings);
|
|
385
|
-
if (
|
|
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 (
|
|
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
|
-
?
|
|
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 =
|
|
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
|
|
491
|
-
if (
|
|
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}
|
|
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
|
-
|
|
634
|
+
previewTruncated: true,
|
|
544
635
|
sha256: meta.sha256,
|
|
545
636
|
expiresAt: meta.expiresAt,
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
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-
|
|
11
|
-
import "./chunks/chunk-
|
|
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-
|
|
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-
|
|
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-
|
|
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-
|
|
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-
|
|
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: '
|
|
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
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
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: {
|
|
@@ -545,6 +545,45 @@ function normalizeRoutePerson(raw) {
|
|
|
545
545
|
}
|
|
546
546
|
return out.length ? out : null;
|
|
547
547
|
}
|
|
548
|
+
/**
|
|
549
|
+
* 人员/团队条件「只给了姓名、或 id 不合法」时,给出**先解析人员 ID** 的可执行动作。
|
|
550
|
+
*
|
|
551
|
+
* 事故(2026-11-23 用户反馈):用户说「查一下吴洋洋的业绩」,模型**直接开卡且没带人员筛选**,
|
|
552
|
+
* 理由是「台账卡片只接受人员 ID,我这边没有可靠的人员 ID 来源,所以把条件留给页面」。
|
|
553
|
+
* 真实原因是 **skill 从没提过 CLI 早就有 `im.person.resolve`**(实测 `{name:"吴洋洋"}` →
|
|
554
|
+
* `uid = 732851919151005700`,正是台账要的那个 ID)——模型只知道「必须传 ID、不能猜」,
|
|
555
|
+
* 于是把用户明确给的条件**静默降级**成「交给页面」,用户拿到的是一张全量卡。
|
|
556
|
+
*
|
|
557
|
+
* 因此这里不静默:把「缺 ID」变成一条带 `requiredAction` / `command` / `forbiddenClaims` 的显式结论,
|
|
558
|
+
* 并在调用方**扣住卡片**——逼出「先解析 ID 再出卡」。
|
|
559
|
+
*/
|
|
560
|
+
function buildPersonLookup(conditions, unsupported) {
|
|
561
|
+
const field = ['person', 'team'].find((name) => unsupported.includes(name));
|
|
562
|
+
if (!field)
|
|
563
|
+
return null;
|
|
564
|
+
const raw = conditions[field];
|
|
565
|
+
const keyword = isRecord(raw)
|
|
566
|
+
? String(raw.name ?? '').trim()
|
|
567
|
+
: String(raw ?? '').trim();
|
|
568
|
+
return {
|
|
569
|
+
field,
|
|
570
|
+
keyword,
|
|
571
|
+
reason: '台账人员字段与卡片人员筛选键**都要求人员 ID**:传姓名不会报错,但会被静默忽略、'
|
|
572
|
+
+ '返回全量(实测 直销业绩 like 姓名 → 451,275 条 = 全量),用户会误以为看到的就是这个人的数据,'
|
|
573
|
+
+ '比"查不到"更危险。而 CLI **本来就能按姓名解析**,不存在"没有 ID 来源"。',
|
|
574
|
+
requiredAction: `先解析「${keyword}」的人员 ID,再用 conditions.${field}={"id":"<uid>","name":"${keyword}"} 重跑本命令`
|
|
575
|
+
+ '(拿到 ID 后本命令会直接把卡片一起返回)。',
|
|
576
|
+
command: `weaver-work-cli --json im run im.person.resolve --input <含 {"name":"${keyword}"} 的 json>`,
|
|
577
|
+
altCommand: `weaver-work-cli --json hrm run hrm.employee.query --input <含 {"username":"${keyword}","full":true} 的 json>`,
|
|
578
|
+
idSource: '人员 ID 取 im.person.resolve 的 `uid`(= hrm.employee.query 的 `id`);'
|
|
579
|
+
+ '**不是** `userid`、也**不是** `cid`(这两个是别的值,填错等于没筛选)。',
|
|
580
|
+
forbiddenClaims: [
|
|
581
|
+
'不要说「我这边没有可靠的人员 ID 来源」——先跑上面的命令',
|
|
582
|
+
'不要把人员条件丢给页面筛选后直接开卡——那会出来一张全量数据的卡',
|
|
583
|
+
'不要凭姓名猜一个 ID 填进去',
|
|
584
|
+
],
|
|
585
|
+
};
|
|
586
|
+
}
|
|
548
587
|
/**
|
|
549
588
|
* 台账入口路由判定(本地,零接口)。
|
|
550
589
|
*
|
|
@@ -723,6 +762,11 @@ export const contractLedgerRouteOperation = {
|
|
|
723
762
|
route = 'card';
|
|
724
763
|
reasons.push('未命中统计信号,按看台账处理;落不了的条件留给页面筛选');
|
|
725
764
|
}
|
|
765
|
+
// ── 人员/团队条件用不了时**不静默降级**(2026-11-23 事故,见 buildPersonLookup 注释)
|
|
766
|
+
const personLookup = buildPersonLookup(conditions, unsupported);
|
|
767
|
+
if (personLookup) {
|
|
768
|
+
reasons.push(`人员条件缺人员 ID(只拿到「${personLookup.keyword}」):必须先用 im.person.resolve 解析,不得开无筛选的卡`);
|
|
769
|
+
}
|
|
726
770
|
const prefillKeys = Object.keys(prefill);
|
|
727
771
|
// comParamsJson 是**字符串**入参:提示里必须给双层序列化后的字符串字面量。
|
|
728
772
|
// 事故(2026-11-20):这里原本只 JSON.stringify 一次,渲染出 `comParamsJson={"xsjl":[…]}`,
|
|
@@ -733,10 +777,11 @@ export const contractLedgerRouteOperation = {
|
|
|
733
777
|
// ── route=card 时**顺带把卡片也生成好**(2026-11-20,省 1 轮)
|
|
734
778
|
// 卡片构造是纯本地计算(`contract.ledger.card` 不访问业务接口),进程内调用即可。
|
|
735
779
|
// 失败**绝不影响路由结论**:路由是判定,卡片是产物;产物失败降级回 nextCommand 提示。
|
|
780
|
+
// ⛔ 但**人员条件缺 ID 时故意不建卡**:否则模型会照旧把这张"没有筛选"的卡发出去。
|
|
736
781
|
let card = null;
|
|
737
782
|
let cardSelfCheck = null;
|
|
738
783
|
let cardError = null;
|
|
739
|
-
if (route === 'card') {
|
|
784
|
+
if (route === 'card' && !personLookup) {
|
|
740
785
|
try {
|
|
741
786
|
const built = await contractLedgerCardOperation.execute({ menu, comParamsJson: JSON.stringify(prefill) }, context);
|
|
742
787
|
card = built?.data?.card ?? null;
|
|
@@ -746,12 +791,14 @@ export const contractLedgerRouteOperation = {
|
|
|
746
791
|
cardError = error instanceof Error ? error.message : String(error);
|
|
747
792
|
}
|
|
748
793
|
}
|
|
749
|
-
const nextCommand =
|
|
750
|
-
?
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
794
|
+
const nextCommand = personLookup
|
|
795
|
+
? `${personLookup.command}(拿到 uid 后重跑本命令:conditions.${personLookup.field}={"id":"<uid>","name":"${personLookup.keyword}"})`
|
|
796
|
+
: route === 'card'
|
|
797
|
+
? (card
|
|
798
|
+
? '(卡片已随本响应返回:顶层 data.card 直接作为 <browsertool> 输出,无需再调 contract.ledger.card)'
|
|
799
|
+
: 'weaver-work-cli --json contract run contract.ledger.card --input <args.json>'
|
|
800
|
+
+ `(menu=${menu}${prefillHint})`)
|
|
801
|
+
: 'contract.ledger.metrics 取口径 → contract.performance.list.query 取数 → contract.ledger.aggregate 汇总';
|
|
755
802
|
return {
|
|
756
803
|
status: 'COMPLETE',
|
|
757
804
|
data: {
|
|
@@ -769,10 +816,13 @@ export const contractLedgerRouteOperation = {
|
|
|
769
816
|
card,
|
|
770
817
|
cardSelfCheck,
|
|
771
818
|
...(cardError ? { cardError } : {}),
|
|
819
|
+
...(personLookup ? { personLookup } : {}),
|
|
772
820
|
conditions,
|
|
773
821
|
note: 'route=card 时禁止先进取数链路;只有统计信号或显式 intent 才走 ledger-query。'
|
|
774
822
|
+ '「业绩」二字、年月、「某个人的 / 某个团队的」都不是统计信号。本 operation 不访问业务接口。'
|
|
775
|
-
+ 'route=card 时顶层已带构建好的 data.card(本地零接口),直接用;data.card 为 null 时才按 nextCommand 自建。'
|
|
823
|
+
+ 'route=card 时顶层已带构建好的 data.card(本地零接口),直接用;data.card 为 null 时才按 nextCommand 自建。'
|
|
824
|
+
+ '⚠️ 出现 personLookup 时:**先按它的 command 解析人员 ID 再重跑本命令**,'
|
|
825
|
+
+ '此时 card 故意为 null——不要绕开它去自建一张没有人员筛选的卡。',
|
|
776
826
|
},
|
|
777
827
|
};
|
|
778
828
|
},
|