weaver-work-cli 0.1.60 → 0.1.62

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 (139) hide show
  1. package/dist/chunks/{archive-4SQAVTIB.js → archive-S2VKZWQ3.js} +2 -2
  2. package/dist/chunks/{archive-oa-W2UEJ67L.js → archive-oa-HEDSIUUY.js} +2 -2
  3. package/dist/chunks/{asset-EGZEABBI.js → asset-HYH4W357.js} +2 -2
  4. package/dist/chunks/{asset-idle-EBUZBB6M.js → asset-idle-N7REBNGL.js} +2 -2
  5. package/dist/chunks/{attachment-content-I6WHKGR2.js → attachment-content-VYYA75FR.js} +3 -3
  6. package/dist/chunks/{blog-2YKMWOWI.js → blog-SLMZZICV.js} +2 -2
  7. package/dist/chunks/{caizhilian-5NM4X5HG.js → caizhilian-RV43KKBT.js} +4 -4
  8. package/dist/chunks/{calendar-H4QTJCUY.js → calendar-DMVZ4OLY.js} +2 -2
  9. package/dist/chunks/{chunk-VLL6JOB4.js → chunk-6XSSAUNW.js} +4 -4
  10. package/dist/chunks/{chunk-VQWPQTEY.js → chunk-BIA2NKUG.js} +4 -4
  11. package/dist/chunks/{chunk-VMCCRWFO.js → chunk-BQYX2UX5.js} +2 -2
  12. package/dist/chunks/{chunk-XF7S6FQW.js → chunk-DTCQFTHW.js} +1 -1
  13. package/dist/chunks/{chunk-CPG6NLN4.js → chunk-E5YD5JWR.js} +1 -1
  14. package/dist/chunks/{chunk-PH7N4UFT.js → chunk-EGANE35F.js} +1 -1
  15. package/dist/chunks/{chunk-Z4IPY5GV.js → chunk-H6YOMI3U.js} +2 -2
  16. package/dist/chunks/{chunk-HHH4K3YY.js → chunk-ILALC2N6.js} +1 -1
  17. package/dist/chunks/{chunk-WINR2Q6K.js → chunk-KXJA42EA.js} +86 -19
  18. package/dist/chunks/{chunk-CQ4OVCKG.js → chunk-KY3R42RS.js} +2 -2
  19. package/dist/chunks/{chunk-WVH5ESDA.js → chunk-NRYDJN4J.js} +1 -1
  20. package/dist/chunks/{chunk-TGM7BWEH.js → chunk-P6TXQK75.js} +2 -2
  21. package/dist/chunks/{chunk-6YWHRXEQ.js → chunk-QBDXJS2W.js} +119 -9
  22. package/dist/chunks/{chunk-2IGZUMNG.js → chunk-SHX7XBYR.js} +180 -18
  23. package/dist/chunks/{chunk-P7RXQDCA.js → chunk-T2KVJFWJ.js} +4 -4
  24. package/dist/chunks/{chunk-FMNCSYIG.js → chunk-TEZHIB6T.js} +2 -2
  25. package/dist/chunks/{chunk-HMIIVM2L.js → chunk-UBGWIXU3.js} +97 -45
  26. package/dist/chunks/{chunk-5N222HK6.js → chunk-UBRWONP4.js} +2 -2
  27. package/dist/chunks/{chunk-7U5YHCW7.js → chunk-UQFPF4EX.js} +2 -2
  28. package/dist/chunks/{chunk-4GG72JAT.js → chunk-V2LASYKO.js} +2 -2
  29. package/dist/chunks/{chunk-BDBTZVYA.js → chunk-VBFBMM7G.js} +55 -55
  30. package/dist/chunks/{chunk-YHSOCGKO.js → chunk-VNYOUAWV.js} +11 -11
  31. package/dist/chunks/{chunk-SFM3M2L3.js → chunk-WIWDVETN.js} +19 -3
  32. package/dist/chunks/{chunk-44KJ7WFA.js → chunk-XT77MP54.js} +2 -2
  33. package/dist/chunks/{chunk-JFKMPRZB.js → chunk-YI2YMW5N.js} +50 -3
  34. package/dist/chunks/{conflict-QMDLS2EW.js → conflict-GFJRS6I7.js} +2 -2
  35. package/dist/chunks/{contract-LLRKMLQQ.js → contract-U3ZGNRWB.js} +2 -2
  36. package/dist/chunks/{cowork-2RDFBZWB.js → cowork-EX7PKIDK.js} +2 -2
  37. package/dist/chunks/{create-flow-5ODJ7WJO.js → create-flow-EJZD434E.js} +6 -6
  38. package/dist/chunks/{data-LVDFIRNG.js → data-FOODGAMF.js} +278 -121
  39. package/dist/chunks/{ebuilder-form-7WA6X6ZI.js → ebuilder-form-I2EOKODG.js} +3 -3
  40. package/dist/chunks/{ehr-52GBKNJR.js → ehr-TE4RFNID.js} +2 -2
  41. package/dist/chunks/{entry-mode-73BJML22.js → entry-mode-ZOLSXEGX.js} +9 -5
  42. package/dist/chunks/{env-OHFS76HV.js → env-TID5NFR6.js} +2 -2
  43. package/dist/chunks/{esb-HJSXCEOM.js → esb-7L6MHYLB.js} +4 -4
  44. package/dist/chunks/{factory-FRTA2LP4.js → factory-OG7BPMH5.js} +1 -1
  45. package/dist/chunks/{fna-OBACRT3J.js → fna-6V2ENR3Y.js} +2 -2
  46. package/dist/chunks/{group-chat-KBFRPCR2.js → group-chat-5DKPWIHL.js} +3 -3
  47. package/dist/chunks/{host-TTSGY5NZ.js → host-3DLYA54R.js} +3 -3
  48. package/dist/chunks/{host-KJT3G5D2.js → host-GOJHHTPY.js} +3 -3
  49. package/dist/chunks/{host-KOWUMNAY.js → host-OGBHL75G.js} +3 -3
  50. package/dist/chunks/{host-MFXRA2MY.js → host-ONZC6AE7.js} +3 -3
  51. package/dist/chunks/{host-W4JCNRFS.js → host-TJ5VVHM7.js} +3 -3
  52. package/dist/chunks/{host-2BKMPWDH.js → host-VTPAWDZV.js} +3 -3
  53. package/dist/chunks/{hrm-AK3WGBMN.js → hrm-2N7NFQDZ.js} +3 -3
  54. package/dist/chunks/{im-JZSBPO4Z.js → im-XCH47ZBN.js} +3 -3
  55. package/dist/chunks/{invoice-6XDMPCWB.js → invoice-5KJ7T774.js} +198 -331
  56. package/dist/chunks/{jiuchuanhui-K4EQU6GK.js → jiuchuanhui-PL6DRPBM.js} +2 -2
  57. package/dist/chunks/{lazy-dispatch-GCA6HDOB.js → lazy-dispatch-UATEN7H7.js} +5 -5
  58. package/dist/chunks/{mail-IKVCQCVZ.js → mail-Q7Z4CQ4D.js} +2 -2
  59. package/dist/chunks/{meeting-ARHVWK7G.js → meeting-5E3BNARL.js} +13 -13
  60. package/dist/chunks/{minute-doc-547KSYKR.js → minute-doc-NXRE5C77.js} +4 -4
  61. package/dist/chunks/{okr-KV43FPPX.js → okr-3O3XNYOK.js} +2 -2
  62. package/dist/chunks/{operations-6NXJ7RTE.js → operations-EZWG72FH.js} +4 -4
  63. package/dist/chunks/performance-Y7CPNSOR.js +1295 -0
  64. package/dist/chunks/{plan-WOYR4WEG.js → plan-BLGPZF5M.js} +2 -2
  65. package/dist/chunks/{project-CQJKBUIL.js → project-6MZMLJMP.js} +2 -2
  66. package/dist/chunks/{reception-MPBU3JXC.js → reception-F2VT2X52.js} +2 -2
  67. package/dist/chunks/{recruit-stage-USTTRHOX.js → recruit-stage-4ETIBMIW.js} +2 -2
  68. package/dist/chunks/{registry-GURQG4ZV.js → registry-3FYSWV3U.js} +3 -3
  69. package/dist/chunks/{registry-SS5J2FZQ.js → registry-7RS74TCK.js} +4 -4
  70. package/dist/chunks/{registry-H5HQ5QNH.js → registry-I4DVPDMU.js} +11 -11
  71. package/dist/chunks/{room-recommend-3UBROMZE.js → room-recommend-GWCVKCXW.js} +4 -4
  72. package/dist/chunks/{schedule-FTUQML6O.js → schedule-6AN63MJQ.js} +4 -4
  73. package/dist/chunks/{smart-extract-APX2PNIN.js → smart-extract-SR4SJJKN.js} +3 -3
  74. package/dist/chunks/{workflow-WMPW3WSB.js → workflow-KF7FA2UQ.js} +7 -7
  75. package/dist/cmd/refs/index.js +124 -4
  76. package/dist/core/output.js +199 -26
  77. package/dist/core/refs.js +36 -0
  78. package/dist/index.js +38 -33
  79. package/dist/internal/e10/auth/xiaoe.js +25 -3
  80. package/dist/shortcuts/caizhilian/operations/files.js +86 -15
  81. package/dist/shortcuts/data/index.js +12 -2
  82. package/dist/shortcuts/data/manifest.js +4 -2
  83. package/dist/shortcuts/data/operations/attribution.js +229 -0
  84. package/dist/shortcuts/data/operations/ds.js +87 -90
  85. package/dist/shortcuts/data/operations/index.js +3 -1
  86. package/dist/shortcuts/index.js +5 -0
  87. package/dist/shortcuts/invoice/manifest.js +30 -62
  88. package/dist/shortcuts/invoice/operations/registry.js +2 -2
  89. package/dist/shortcuts/invoice/operations/reim-customer.js +111 -0
  90. package/dist/shortcuts/invoice/operations/shared.js +0 -204
  91. package/dist/shortcuts/meeting/operations/eb/create-flow.js +84 -16
  92. package/dist/shortcuts/meeting/operations/eb/entry-mode.js +61 -7
  93. package/dist/shortcuts/performance/continuation.js +74 -0
  94. package/dist/shortcuts/performance/errors.js +65 -0
  95. package/dist/shortcuts/performance/host.js +105 -0
  96. package/dist/shortcuts/performance/index.js +109 -0
  97. package/dist/shortcuts/performance/manifest.js +30 -0
  98. package/dist/shortcuts/performance/operations/hrm-resolve.js +114 -0
  99. package/dist/shortcuts/performance/operations/registry.js +44 -0
  100. package/dist/shortcuts/performance/operations/scheme-detail.js +70 -0
  101. package/dist/shortcuts/performance/operations/scheme-draft.js +116 -0
  102. package/dist/shortcuts/performance/operations/scheme-publish.js +158 -0
  103. package/dist/shortcuts/performance/operations/types.js +32 -0
  104. package/dist/shortcuts/performance/scheme-validate.js +307 -0
  105. package/dist/shortcuts/performance/shared.js +158 -0
  106. package/docs/agent-invoice.md +1 -1
  107. package/docs/agent-io-channel-design.md +67 -3
  108. package/docs/data.md +2 -1
  109. package/docs/invoice.md +0 -2
  110. package/package.json +1 -1
  111. package/scripts/xiaoe_env.py +6 -1
  112. package/skill-template/business-info.json +19 -0
  113. package/skill-template/domains/performance.md +18 -0
  114. package/skill-template/domains/yepiaotong.md +0 -1
  115. package/skills/weaver-e10-caizhilian/SKILL.md +1 -1
  116. package/skills/weaver-e10-data/references/datasource.md +2 -1
  117. package/skills/weaver-e10-meeting/SKILL.md +5 -3
  118. package/skills/weaver-e10-performance/SKILL.md +202 -0
  119. package/skills/weaver-e10-performance/agents/openai.yaml +74 -0
  120. package/skills/weaver-e10-performance/references/default-assembly.md +108 -0
  121. package/skills/weaver-e10-performance/references/entity-resolution.md +69 -0
  122. package/skills/weaver-e10-performance/references/enums-and-normalization.md +80 -0
  123. package/skills/weaver-e10-performance/references/examples.md +146 -0
  124. package/skills/weaver-e10-performance/references/extraction-guide.md +144 -0
  125. package/skills/weaver-e10-performance/references/scheme-edit-req-fields.md +185 -0
  126. package/skills/weaver-e10-performance/references/scheme-setting-page.md +62 -0
  127. package/skills/weaver-e10-performance/scripts/parse_appraisal_doc.py +483 -0
  128. package/skills/weaver-e10-shared/references/json-output-contract.md +5 -0
  129. package/skills/weaver-e10-yepiaotong/SKILL.md +16 -9
  130. package/skills/weaver-e10-yepiaotong/references/invoice-reim-relation.md +9 -7
  131. package/skills/weaver-e10-yepiaotong/references/invoice-reim.md +15 -11
  132. package/skills/weaver-e10-yepiaotong/references/reim-api-reference.md +29 -25
  133. package/skills/weaver-e10-yepiaotong/references/reim-customer-search.md +89 -0
  134. package/skills/weaver-e10-yepiaotong/references/reim-examples.md +35 -37
  135. package/skills/weaver-e10-yepiaotong/references/reim-form-fill-rules.md +66 -63
  136. package/skills/weaver-e10-yepiaotong/references/reim-workflow.md +50 -71
  137. package/skills/weaver-e10-yepiaotong/references/source-manifest.json +34 -95
  138. package/dist/shortcuts/invoice/operations/browse-field.js +0 -17
  139. package/skills/weaver-e10-yepiaotong/references/invoice-browse-field-data.md +0 -204
@@ -13,12 +13,31 @@ export const DEFAULT_RESULT_THRESHOLD_BYTES = 24 * 1024;
13
13
  export const DEFAULT_REF_TTL_MS = 30 * 60_000;
14
14
  export const DEFAULT_REF_MAX_COUNT = 50;
15
15
  export const DEFAULT_REF_MAX_BYTES = 200 * 1024 * 1024;
16
+ /** `slice(0, KEEP_ALL)` 等价于不切,用于"只压字段、不丢条目"的前几档。 */
17
+ const KEEP_ALL = Number.MAX_SAFE_INTEGER;
18
+ /**
19
+ * 逐档收紧的顺序是**先压字段、后才切条目**(2026-11-18 调整)。
20
+ *
21
+ * 原顺序一上来就把数组切到 10 条,于是"查 100 条"这种请求必然看到 10 条,模型再回头重查,
22
+ * 客户侧就是接口限流。反过来:先把每条里的长文本压短、条目一条不丢,绝大多数列表结果都能
23
+ * 完整落在预算内(100 条 × 每条约 200 B ≈ 20 KB);只有字段已经压到 40 字符还超线,才退化为
24
+ * 减少条目——此时 `previewOmitted` 会明确写出原始条数。
25
+ */
16
26
  const COMPACT_TIERS = [
17
- { array: 10, string: 200 },
18
- { array: 5, string: 80 },
19
- { array: 2, string: 40 },
27
+ { array: KEEP_ALL, string: 200 },
28
+ { array: KEEP_ALL, string: 80 },
29
+ { array: KEEP_ALL, string: 40 },
30
+ { array: 50, string: 40 },
31
+ { array: 20, string: 40 },
32
+ { array: 10, string: 40 },
33
+ { array: 5, string: 20 },
34
+ { array: 2, string: 20 },
20
35
  { array: 1, string: 20 },
21
36
  ];
37
+ /** 顶部 `previewOmitted` 最多列几条,避免这份"元信息"自己把预算吃掉。 */
38
+ const MAX_OMISSION_ENTRIES = 6;
39
+ /** 提示语里最多点名几处截断(模型优先看 `largeOutputNotice`)。 */
40
+ const MAX_OMISSION_IN_NOTICE = 2;
22
41
  function numberFromEnv(name) {
23
42
  const raw = process.env[name];
24
43
  if (raw === undefined || raw.trim() === '')
@@ -69,38 +88,75 @@ function isLinkField(key) {
69
88
  return false;
70
89
  return /(?:^|[a-z0-9])(?:url|urls|uri|href|link|links)$/i.test(key);
71
90
  }
72
- function compactValue(value, arrayLimit, stringLimit, depth = 0, key) {
91
+ /**
92
+ * 不能因为预览压缩而改变的判别字段。
93
+ *
94
+ * 这里只保护通常很短、但一个字符都不能错的值:ID/编号/状态/金额/日期/分页信号/校验值。
95
+ * 正文、描述、OCR 原文等大字段不在此列,仍通过 ref 按需取回。
96
+ */
97
+ function isIntegrityField(key) {
98
+ if (!key)
99
+ return false;
100
+ const normalized = key.replace(/[^a-z0-9]/gi, '').toLowerCase();
101
+ return [
102
+ 'id', 'ids', 'fid', 'uuid', 'guid',
103
+ 'code', 'codes', 'number', 'numbers', 'no',
104
+ 'status', 'state', 'amount', 'total', 'count',
105
+ 'date', 'time', 'timestamp',
106
+ 'hash', 'sha256',
107
+ 'hasmore', 'offset', 'limit', 'pagesize', 'pageno',
108
+ 'nextoffset', 'nextpagetoken',
109
+ ].some((suffix) => normalized === suffix || normalized.endsWith(suffix));
110
+ }
111
+ function childPath(path, key) {
112
+ return path ? `${path}.${key}` : key;
113
+ }
114
+ function compactValue(value, arrayLimit, stringLimit, depth = 0, key, path = '', sink) {
73
115
  if (depth > 6)
74
116
  return '<omitted: too deep>';
75
- // 链接字段整体豁免;数组元素继承父字段名,因此 openUrls / links 里的每条 URL 也完整保留
76
- const limit = isLinkField(key) ? Number.MAX_SAFE_INTEGER : stringLimit;
117
+ // 链接和判别字段整体豁免;数组元素继承父字段名,因此 links / ids 里的值也完整保留。
118
+ const limit = isLinkField(key) || isIntegrityField(key) ? Number.MAX_SAFE_INTEGER : stringLimit;
77
119
  if (typeof value === 'string') {
78
- return value.length > limit
79
- ? `${value.slice(0, limit)}…(truncated ${value.length - limit} chars)`
80
- : value;
120
+ if (value.length > limit) {
121
+ const chars = Array.from(value);
122
+ if (chars.length <= limit)
123
+ return value;
124
+ sink?.({ path, kind: 'string', total: chars.length, shown: limit });
125
+ return `${chars.slice(0, limit).join('')}…(truncated ${chars.length - limit} chars)`;
126
+ }
127
+ return value;
81
128
  }
82
129
  if (Array.isArray(value)) {
130
+ // 只有真被切掉的数组才登记:`slice` 后长度变短,JSON 里看不出任何痕迹。
131
+ if (value.length > arrayLimit) {
132
+ sink?.({ path, kind: 'array', total: value.length, shown: arrayLimit });
133
+ }
83
134
  return value
84
135
  .slice(0, arrayLimit)
85
- .map((item) => compactValue(item, arrayLimit, limit, depth + 1, key));
136
+ .map((item, index) => compactValue(item, arrayLimit, limit, depth + 1, key, `${path}[${index}]`, sink));
86
137
  }
87
138
  if (value && typeof value === 'object') {
88
139
  const out = {};
89
140
  for (const [name, inner] of Object.entries(value)) {
90
- out[name] = compactValue(inner, arrayLimit, stringLimit, depth + 1, name);
141
+ out[name] = compactValue(inner, arrayLimit, stringLimit, depth + 1, name, childPath(path, name), sink);
91
142
  }
92
143
  return out;
93
144
  }
94
145
  return value;
95
146
  }
96
147
  /** 逐档收紧,尽量让精简版本身也落在 stdout 预算内。 */
97
- export function compactForStdout(value, budgetBytes) {
148
+ export function compactForStdout(value, budgetBytes, sink) {
98
149
  let current = value;
150
+ let last = [];
99
151
  for (const tier of COMPACT_TIERS) {
100
- current = compactValue(value, tier.array, tier.string);
152
+ const truncations = [];
153
+ current = compactValue(value, tier.array, tier.string, 0, undefined, '', (item) => truncations.push(item));
154
+ last = truncations;
101
155
  if (bytesOf(current) <= budgetBytes)
102
- return current;
156
+ break;
103
157
  }
158
+ for (const item of last)
159
+ sink?.(item);
104
160
  return current;
105
161
  }
106
162
  /**
@@ -109,17 +165,24 @@ export function compactForStdout(value, budgetBytes) {
109
165
  * 不能只压 `data`:像 `invoice schema` 这类命令的 envelope 没有 data 键,
110
166
  * 大字段是 `operations` / `withheldOperations`,只压 data 等于没压。
111
167
  */
112
- export function compactRecord(value, budgetBytes, keepKeys) {
168
+ export function compactRecord(value, budgetBytes, keepKeys, sink) {
113
169
  let current = value;
170
+ let last = [];
114
171
  for (const tier of COMPACT_TIERS) {
115
172
  const out = {};
173
+ const truncations = [];
116
174
  for (const [key, inner] of Object.entries(value)) {
117
- out[key] = keepKeys.includes(key) ? inner : compactValue(inner, tier.array, tier.string);
175
+ out[key] = keepKeys.includes(key)
176
+ ? inner
177
+ : compactValue(inner, tier.array, tier.string, 0, key, key, (item) => truncations.push(item));
118
178
  }
119
179
  current = out;
180
+ last = truncations;
120
181
  if (bytesOf(out) <= budgetBytes)
121
- return out;
182
+ break;
122
183
  }
184
+ for (const item of last)
185
+ sink?.(item);
123
186
  return current;
124
187
  }
125
188
  /** 兜底:逐档压缩后仍超预算时,只留判别字段与占位符,保证指针必然落在前 2048 B 内。 */
@@ -200,37 +263,147 @@ function withLeadingMeta(value, leading, body, extraWarnings) {
200
263
  warnings: [...compactWarnings, ...extraWarnings],
201
264
  };
202
265
  }
266
+ /** 丢得最多的一批排前面:模型最需要先知道"哪个数组被砍得最狠"。 */
267
+ function byOmitted(left, right) {
268
+ return (right.total - right.shown) - (left.total - left.shown);
269
+ }
270
+ /**
271
+ * 把 `data.items[0].blob` / `data.items[7].blob` 收敛成 `data.items[].blob`。
272
+ *
273
+ * 逐条登记会让提示语变成"共 3600 字符…共 3600 字符…另有 8 处",既吵又没信息量;
274
+ * 同一模板路径截断一次就够了。
275
+ */
276
+ function normalizePath(path) {
277
+ return path.replace(/\[\d+\]/g, '[]');
278
+ }
279
+ /** 按模板路径去重,保留丢得最多的那一条。 */
280
+ function dedupeByTemplate(truncations) {
281
+ const seen = new Map();
282
+ for (const item of [...truncations].sort(byOmitted)) {
283
+ const key = `${item.kind}:${normalizePath(item.path)}`;
284
+ if (!seen.has(key))
285
+ seen.set(key, item);
286
+ }
287
+ return [...seen.values()];
288
+ }
289
+ /**
290
+ * 把截断翻译成一句人话:`data.items 共 92 条,仅显示 5 条`。
291
+ *
292
+ * 只说 `previewTruncated: true` 不够——实测模型会把它当"体积提示"扫过去,然后拿 5 条预览当
293
+ * "服务端只返回 5 条"写进结论。带上**原始条数**才能真正阻止这个误判。
294
+ */
295
+ function describeTruncations(truncations) {
296
+ const groups = dedupeByTemplate(truncations);
297
+ const arrays = groups.filter((item) => item.kind === 'array');
298
+ const strings = groups.filter((item) => item.kind === 'string');
299
+ const parts = [];
300
+ for (const item of arrays.slice(0, MAX_OMISSION_IN_NOTICE)) {
301
+ parts.push(`${normalizePath(item.path)} 共 ${item.total} 条,仅显示 ${item.shown} 条`);
302
+ }
303
+ for (const item of strings.slice(0, MAX_OMISSION_IN_NOTICE)) {
304
+ parts.push(`${normalizePath(item.path)} 共 ${item.total} 字符,仅保留前 ${item.shown} 字符`);
305
+ }
306
+ if (!parts.length)
307
+ return '';
308
+ const hidden = groups.length - parts.length;
309
+ return hidden > 0 ? `${parts.join(';')};另有 ${hidden} 处被截断` : parts.join(';');
310
+ }
311
+ /** 机读索引:数组的条目缩减。 */
312
+ function previewOmittedOf(truncations) {
313
+ const arrays = dedupeByTemplate(truncations)
314
+ .filter((item) => item.kind === 'array')
315
+ .sort(byOmitted)
316
+ .slice(0, MAX_OMISSION_ENTRIES);
317
+ if (!arrays.length)
318
+ return undefined;
319
+ return Object.fromEntries(arrays.map((item) => [
320
+ normalizePath(item.path),
321
+ { total: item.total, shown: item.shown },
322
+ ]));
323
+ }
324
+ /** 机读索引:长字符串的预览缩减,防止下游把前 N 字符当成完整值。 */
325
+ function previewTruncatedFieldsOf(truncations) {
326
+ const strings = dedupeByTemplate(truncations)
327
+ .filter((item) => item.kind === 'string')
328
+ .sort(byOmitted)
329
+ .slice(0, MAX_OMISSION_ENTRIES);
330
+ if (!strings.length)
331
+ return undefined;
332
+ return Object.fromEntries(strings.map((item) => [
333
+ normalizePath(item.path),
334
+ { unit: 'chars', total: item.total, shown: item.shown },
335
+ ]));
336
+ }
337
+ /**
338
+ * 前置一段"这是预览"的硬提示,并给出 `previewOmitted` 机读索引。
339
+ *
340
+ * 没有截断时原样返回 `leading`,保证小结果的信封逐字节不变。
341
+ */
342
+ function withTruncationNotice(leading, truncations) {
343
+ const detail = describeTruncations(truncations);
344
+ if (!detail)
345
+ 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}`;
352
+ const omitted = previewOmittedOf(truncations);
353
+ const truncatedFields = previewTruncatedFieldsOf(truncations);
354
+ return {
355
+ ...leading,
356
+ ...(omitted ? { previewOmitted: omitted } : {}),
357
+ ...(truncatedFields ? { previewTruncatedFields: truncatedFields } : {}),
358
+ largeOutputNotice: notice,
359
+ };
360
+ }
203
361
  function slimmedBody(value, threshold, hasRef) {
204
362
  const base = value && typeof value === 'object' && !Array.isArray(value)
205
363
  ? value
206
364
  : { data: value };
207
- const compacted = compactRecord(base, threshold, ENVELOPE_KEEP_KEYS);
365
+ const truncations = [];
366
+ const compacted = compactRecord(base, threshold, ENVELOPE_KEEP_KEYS, (item) => truncations.push(item));
208
367
  if (bytesOf(compacted) <= threshold)
209
- return compacted;
210
- return skeletonOf(base, ENVELOPE_KEEP_KEYS, hasRef);
368
+ return { body: compacted, truncations };
369
+ return { body: skeletonOf(base, ENVELOPE_KEEP_KEYS, hasRef), truncations: skeletonTruncations(base) };
370
+ }
371
+ /** 骨架兜底时只剩 `<omitted: N items>`,条数从顶层数组里取,保证提示仍然准确。 */
372
+ function skeletonTruncations(base) {
373
+ const out = [];
374
+ for (const [key, inner] of Object.entries(base)) {
375
+ if (Array.isArray(inner) && inner.length > 0 && !ENVELOPE_KEEP_KEYS.includes(key)) {
376
+ out.push({ path: key, kind: 'array', total: inner.length, shown: 0 });
377
+ }
378
+ }
379
+ return out;
211
380
  }
212
381
  function fitEnvelope(value, leading, extraWarnings, budgetBytes) {
213
382
  const hasRef = leading.resultPersisted === true;
214
- const body = slimmedBody(value, budgetBytes, hasRef);
215
- let envelope = withLeadingMeta(value, leading, body, extraWarnings);
383
+ const { body, truncations } = slimmedBody(value, budgetBytes, hasRef);
384
+ let envelope = withLeadingMeta(value, withTruncationNotice(leading, truncations), body, extraWarnings);
216
385
  if (bytesOf(envelope) <= budgetBytes)
217
386
  return envelope;
218
387
  const base = value && typeof value === 'object' && !Array.isArray(value)
219
388
  ? value
220
389
  : { data: value };
221
- envelope = withLeadingMeta(value, leading, skeletonOf(base, ENVELOPE_KEEP_KEYS, leading.resultPersisted === true), extraWarnings);
390
+ envelope = withLeadingMeta(value, withTruncationNotice(leading, skeletonTruncations(base)), skeletonOf(base, ENVELOPE_KEEP_KEYS, leading.resultPersisted === true), extraWarnings);
222
391
  if (bytesOf(envelope) <= budgetBytes)
223
392
  return envelope;
224
393
  const persisted = leading.resultPersisted === true;
225
394
  const refId = String(leading.refId ?? '').slice(0, 80);
395
+ const finalOmitted = previewOmittedOf(skeletonTruncations(base));
396
+ const finalNotice = persisted
397
+ ? `结果已精简,使用 --input-ref ${refId} 读取。`
398
+ : '结果无法暂存;stdout 仅保留精简内容,完整结果不可恢复。';
399
+ const finalDetail = describeTruncations(skeletonTruncations(base));
226
400
  return {
227
401
  ...(persisted ? { refId } : {}),
228
402
  resultPersisted: persisted,
229
403
  outputBytes: Number(leading.outputBytes) || 0,
230
- largeOutputNotice: persisted
231
- ? `结果已精简,使用 --input-ref ${refId} 读取。`
232
- : '结果无法暂存;stdout 仅保留精简内容,完整结果不可恢复。',
404
+ largeOutputNotice: finalDetail ? `${finalNotice}⚠️ 预览不是全量:${finalDetail}。` : finalNotice,
233
405
  previewTruncated: true,
406
+ ...(finalOmitted ? { previewOmitted: finalOmitted } : {}),
234
407
  schemaVersion: typeof base.schemaVersion === 'number' || typeof base.schemaVersion === 'string'
235
408
  ? String(base.schemaVersion).slice(0, 20)
236
409
  : 1,
package/dist/core/refs.js CHANGED
@@ -374,6 +374,42 @@ export function pruneRefs(ctx, options = {}) {
374
374
  cleanupIncomplete,
375
375
  };
376
376
  }
377
+ /**
378
+ * 按 offset/limit 切一段数组,返回带总数与续读偏移的窗口。
379
+ *
380
+ * 存在意义:`refs get <refId> data.items` 若一次吐出 100 条,会再次撞上 stdout 预算被二次精简,
381
+ * 于是"取全量 → 又只剩 10 条 → 再取"形成死循环。分批读保证每次都是**完整条目 + 明确续读位置**。
382
+ */
383
+ export function readWindow(items, offset, limit) {
384
+ const total = items.length;
385
+ const start = Math.min(Math.max(Math.floor(offset) || 0, 0), total);
386
+ const size = Math.max(Math.floor(limit) || 0, 1);
387
+ const end = Math.min(start + size, total);
388
+ return {
389
+ offset: start,
390
+ returned: end - start,
391
+ total,
392
+ hasMore: end < total,
393
+ ...(end < total ? { nextOffset: end } : {}),
394
+ items: items.slice(start, end),
395
+ };
396
+ }
397
+ /** 按 Unicode 字符而不是 UTF-16 code unit 分段,避免把 emoji 切成乱码。 */
398
+ export function readTextWindow(text, charOffset, charLimit) {
399
+ const chars = Array.from(text);
400
+ const totalChars = chars.length;
401
+ const start = Math.min(Math.max(Math.floor(charOffset) || 0, 0), totalChars);
402
+ const size = Math.max(Math.floor(charLimit) || 0, 1);
403
+ const end = Math.min(start + size, totalChars);
404
+ return {
405
+ charOffset: start,
406
+ returnedChars: end - start,
407
+ totalChars,
408
+ hasMore: end < totalChars,
409
+ ...(end < totalChars ? { nextCharOffset: end } : {}),
410
+ text: chars.slice(start, end).join(''),
411
+ };
412
+ }
377
413
  /** 轻量 JSON 路径取值,支持 `a.b[0].c`、`$.data.items[0].fid`,并允许省略 `data.` 前缀。 */
378
414
  export function pickValue(value, path) {
379
415
  let cursor = value;
package/dist/index.js CHANGED
@@ -7,13 +7,13 @@ import {
7
7
  firstPositionalToken,
8
8
  registerCommands,
9
9
  toCommandMetadata
10
- } from "./chunks/chunk-6YWHRXEQ.js";
11
- import "./chunks/chunk-2IGZUMNG.js";
12
- import "./chunks/chunk-FMNCSYIG.js";
10
+ } from "./chunks/chunk-QBDXJS2W.js";
11
+ import "./chunks/chunk-SHX7XBYR.js";
13
12
  import "./chunks/chunk-AJ62BGAW.js";
13
+ import "./chunks/chunk-TEZHIB6T.js";
14
14
  import "./chunks/chunk-6N4JPNFL.js";
15
- import "./chunks/chunk-WVH5ESDA.js";
16
- import "./chunks/chunk-SFM3M2L3.js";
15
+ import "./chunks/chunk-NRYDJN4J.js";
16
+ import "./chunks/chunk-WIWDVETN.js";
17
17
  import "./chunks/chunk-SHYQUBY3.js";
18
18
  import "./chunks/chunk-UG5G54VL.js";
19
19
  import "./chunks/chunk-BUSC6UAE.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-GCA6HDOB.js");
34
+ const { dispatchLazyShortcut } = await import("./chunks/lazy-dispatch-UATEN7H7.js");
35
35
  await dispatchLazyShortcut(definition, shortcutMetadata());
36
36
  });
37
37
  }
@@ -41,137 +41,142 @@ var builtinShortcuts = [
41
41
  lazyShortcut({
42
42
  name: "invoice",
43
43
  description: "E10 \u4E1A\u7968\u901A\u53D1\u7968\u7BA1\u7406 CLI",
44
- load: async () => (await import("./chunks/invoice-6XDMPCWB.js")).invoiceShortcut
44
+ load: async () => (await import("./chunks/invoice-5KJ7T774.js")).invoiceShortcut
45
45
  }),
46
46
  lazyShortcut({
47
47
  name: "ehr",
48
48
  description: "\u6CDB\u5FAEE10\u805A\u624D\u6797\uFF08\u4EBA\u4E8B/\u51FA\u52E4/\u85AA\u916C\uFF09CLI",
49
- load: async () => (await import("./chunks/ehr-52GBKNJR.js")).ehrShortcut
49
+ load: async () => (await import("./chunks/ehr-TE4RFNID.js")).ehrShortcut
50
50
  }),
51
51
  lazyShortcut({
52
52
  name: "recruit-stage",
53
53
  description: "\u6CDB\u5FAEE10\u62DB\u8058\u52A9\u624B\uFF08JD\u751F\u6210/\u7B80\u5386\u5EFA\u6863/AI\u9762\u8BD5\u9080\u7EA6\uFF09CLI",
54
- load: async () => (await import("./chunks/recruit-stage-USTTRHOX.js")).recruitStageShortcut
54
+ load: async () => (await import("./chunks/recruit-stage-4ETIBMIW.js")).recruitStageShortcut
55
+ }),
56
+ lazyShortcut({
57
+ name: "performance",
58
+ description: "\u6CDB\u5FAEE10\u7EE9\u6548\u65B9\u6848\uFF08\u6587\u6863\u5BFC\u5165/\u5B9E\u4F53\u89E3\u6790/\u843D\u8349\u7A3F/\u786E\u8BA4\u53D1\u5E03\uFF09CLI",
59
+ load: async () => (await import("./chunks/performance-Y7CPNSOR.js")).performanceShortcut
55
60
  }),
56
61
  lazyShortcut({
57
62
  name: "cowork",
58
63
  description: "\u6CDB\u5FAEE10\u534F\u4F5C\u533A\uFF08\u534F\u4F5C\u4E8B\u9879/\u8BA8\u8BBA/\u5BA1\u6279/\u5171\u4EAB\u6743\u9650\uFF09CLI",
59
- load: async () => (await import("./chunks/cowork-2RDFBZWB.js")).coworkShortcut
64
+ load: async () => (await import("./chunks/cowork-EX7PKIDK.js")).coworkShortcut
60
65
  }),
61
66
  lazyShortcut({
62
67
  name: "archive",
63
68
  description: "E10 \u6587\u4E66\u5B9A\u6863\u6848\u7BA1\u7406 CLI",
64
- load: async () => (await import("./chunks/archive-4SQAVTIB.js")).archiveShortcut
69
+ load: async () => (await import("./chunks/archive-S2VKZWQ3.js")).archiveShortcut
65
70
  }),
66
71
  lazyShortcut({
67
72
  name: "archive-oa",
68
73
  description: "E10 \u6863\u6848\u5B9A\u4F4D\u4E0E OA \u5546\u52A1\u5408\u540C\u501F\u9605 CLI",
69
- load: async () => (await import("./chunks/archive-oa-W2UEJ67L.js")).archiveOaShortcut
74
+ load: async () => (await import("./chunks/archive-oa-HEDSIUUY.js")).archiveOaShortcut
70
75
  }),
71
76
  lazyShortcut({
72
77
  name: "calendar",
73
78
  description: "\u6CDB\u5FAEE10\u65E5\u7A0B\u7BA1\u7406 CLI\uFF08\u521B\u5EFA/\u67E5\u8BE2/\u66F4\u65B0/\u5220\u9664/\u5B57\u5178\uFF09",
74
- load: async () => (await import("./chunks/calendar-H4QTJCUY.js")).calendarShortcut
79
+ load: async () => (await import("./chunks/calendar-DMVZ4OLY.js")).calendarShortcut
75
80
  }),
76
81
  lazyShortcut({
77
82
  name: "fna",
78
83
  description: "\u6CDB\u5FAEE10\u9F50\u4E1A\u6210\u8D39\u63A7\u4E2D\u5FC3\uFF08\u9884\u7B97/\u8D39\u7528\u4E2D\u5FC3/\u501F\u6B3E\u7BA1\u7406/\u53D1\u7968\u6838\u9500\uFF09CLI",
79
- load: async () => (await import("./chunks/fna-OBACRT3J.js")).fnaShortcut
84
+ load: async () => (await import("./chunks/fna-6V2ENR3Y.js")).fnaShortcut
80
85
  }),
81
86
  lazyShortcut({
82
87
  name: "hrm",
83
88
  description: "\u6CDB\u5FAEE10\u7EC4\u7EC7\u7BA1\u7406\uFF08\u5458\u5DE5/\u7EC4\u7EC7/\u5C97\u4F4D\u67E5\u8BE2\uFF09CLI",
84
- load: async () => (await import("./chunks/hrm-AK3WGBMN.js")).hrmShortcut
89
+ load: async () => (await import("./chunks/hrm-2N7NFQDZ.js")).hrmShortcut
85
90
  }),
86
91
  lazyShortcut({
87
92
  name: "mail",
88
93
  description: "\u6CDB\u5FAEE10\u90AE\u4EF6\u7BA1\u7406 CLI",
89
- load: async () => (await import("./chunks/mail-IKVCQCVZ.js")).mailShortcut
94
+ load: async () => (await import("./chunks/mail-Q7Z4CQ4D.js")).mailShortcut
90
95
  }),
91
96
  lazyShortcut({
92
97
  name: "meeting",
93
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",
94
- load: async () => (await import("./chunks/meeting-ARHVWK7G.js")).meetingShortcut
99
+ load: async () => (await import("./chunks/meeting-5E3BNARL.js")).meetingShortcut
95
100
  }),
96
101
  lazyShortcut({
97
102
  name: "okr",
98
103
  description: "\u6CDB\u5FAEE10 OKR \u76EE\u6807\u7BA1\u7406 CLI\uFF08\u76EE\u6807\u67E5\u8BE2/\u65B0\u5EFA/\u7F16\u8F91\u3001\u5173\u952E\u6210\u679C\u3001\u76EE\u6807\u5BF9\u9F50\u3001\u8BC4\u8BBA\uFF09",
99
- load: async () => (await import("./chunks/okr-KV43FPPX.js")).okrShortcut
104
+ load: async () => (await import("./chunks/okr-3O3XNYOK.js")).okrShortcut
100
105
  }),
101
106
  lazyShortcut({
102
107
  name: "plan",
103
108
  description: "\u6CDB\u5FAEE10\u8BA1\u5212\u62A5\u544A CLI\uFF08\u67E5\u8BE2/\u65B0\u5EFA/\u4FEE\u6539/\u53D1\u5E03/\u64A4\u56DE/\u63D0\u4EA4\u63D0\u9192/\u8BC4\u8BBA\uFF09",
104
- load: async () => (await import("./chunks/plan-WOYR4WEG.js")).planShortcut
109
+ load: async () => (await import("./chunks/plan-BLGPZF5M.js")).planShortcut
105
110
  }),
106
111
  lazyShortcut({
107
112
  name: "esb",
108
113
  description: "\u6CDB\u5FAEE10 ESB \u4E2D\u5FC3\u81EA\u5B9A\u4E49\u89E6\u53D1\u52A8\u4F5C\u6D41 CLI",
109
- load: async () => (await import("./chunks/esb-HJSXCEOM.js")).esbShortcut
114
+ load: async () => (await import("./chunks/esb-7L6MHYLB.js")).esbShortcut
110
115
  }),
111
116
  lazyShortcut({
112
117
  name: "ebuilder-form",
113
118
  description: "\u6CDB\u5FAEE10 eBuilder \u8868\u5355\u83DC\u5355\u3001\u5217\u8868\u548C\u8868\u5355\u6570\u636E CLI",
114
- load: async () => (await import("./chunks/ebuilder-form-7WA6X6ZI.js")).ebuilderFormShortcut
119
+ load: async () => (await import("./chunks/ebuilder-form-I2EOKODG.js")).ebuilderFormShortcut
115
120
  }),
116
121
  lazyShortcut({
117
122
  name: "jiuchuanhui",
118
123
  description: "\u6CDB\u5FAEE10\u4E5D\u6C1A\u6C47\u8425\u9500\u7BA1\u7406 CLI\uFF08\u5BA2\u6237/\u8054\u7CFB\u4EBA/\u5546\u673A/\u7EBF\u7D22/\u8054\u7CFB\u8BA1\u5212/\u516C\u6D77\uFF09",
119
- load: async () => (await import("./chunks/jiuchuanhui-K4EQU6GK.js")).jiuchuanhuiShortcut
124
+ load: async () => (await import("./chunks/jiuchuanhui-PL6DRPBM.js")).jiuchuanhuiShortcut
120
125
  }),
121
126
  lazyShortcut({
122
127
  name: "asset",
123
128
  description: "E10 \u8D44\u4EA7\u7BA1\u7406\uFF08\u8D44\u7BA1\u5BB6\uFF09CLI",
124
- load: async () => (await import("./chunks/asset-EGZEABBI.js")).assetShortcut
129
+ load: async () => (await import("./chunks/asset-HYH4W357.js")).assetShortcut
125
130
  }),
126
131
  lazyShortcut({
127
132
  name: "asset-idle",
128
133
  description: "E10 \u95F2\u7F6E\u8D44\u4EA7\u5224\u5B9A\u7ED3\u679C\u67E5\u8BE2 CLI\uFF08\u5206\u9875\u83B7\u53D6/\u805A\u5408\u7EDF\u8BA1\uFF09",
129
- load: async () => (await import("./chunks/asset-idle-EBUZBB6M.js")).assetIdleShortcut
134
+ load: async () => (await import("./chunks/asset-idle-N7REBNGL.js")).assetIdleShortcut
130
135
  }),
131
136
  lazyShortcut({
132
137
  name: "im",
133
138
  description: "\u6CDB\u5FAEE10\u6613\u79D2\u529E\uFF08\u5373\u65F6\u901A\u8BAF\uFF09CLI",
134
- load: async () => (await import("./chunks/im-JZSBPO4Z.js")).imShortcut
139
+ load: async () => (await import("./chunks/im-XCH47ZBN.js")).imShortcut
135
140
  }),
136
141
  lazyShortcut({
137
142
  name: "project",
138
143
  description: "\u6CDB\u5FAEE10\u4E8B\u4E95\u7136\u9879\u76EE\u7BA1\u7406 CLI\uFF08\u9879\u76EE/\u4EFB\u52A1\u67E5\u8BE2\u4E0E\u786E\u8BA4\u5199\u5165\uFF09",
139
- load: async () => (await import("./chunks/project-CQJKBUIL.js")).projectShortcut
144
+ load: async () => (await import("./chunks/project-6MZMLJMP.js")).projectShortcut
140
145
  }),
141
146
  lazyShortcut({
142
147
  name: "workflow",
143
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",
144
- load: async () => (await import("./chunks/workflow-WMPW3WSB.js")).workflowShortcut
149
+ load: async () => (await import("./chunks/workflow-KF7FA2UQ.js")).workflowShortcut
145
150
  }),
146
151
  lazyShortcut({
147
152
  name: "blog",
148
153
  description: "\u6CDB\u5FAEE10\u5DE5\u4F5C\u65E5\u62A5 CLI\uFF08\u67E5\u8BE2/\u53D1\u5E03/\u7F16\u8F91/\u8BC4\u8BBA/\u70B9\u8D5E/\u63D0\u9192/\u5BFC\u51FA\uFF09",
149
- load: async () => (await import("./chunks/blog-2YKMWOWI.js")).blogShortcut
154
+ load: async () => (await import("./chunks/blog-SLMZZICV.js")).blogShortcut
150
155
  }),
151
156
  lazyShortcut({
152
157
  name: "caizhilian",
153
158
  description: "\u6CDB\u5FAEE10\u91C7\u77E5\u8FDE\uFF08\u6587\u6863\u4E2D\u5FC3\uFF09CLI",
154
- load: async () => (await import("./chunks/caizhilian-5NM4X5HG.js")).caizhilianShortcut
159
+ load: async () => (await import("./chunks/caizhilian-RV43KKBT.js")).caizhilianShortcut
155
160
  }),
156
161
  lazyShortcut({
157
162
  name: "contract",
158
163
  description: "\u6CDB\u5FAEE10\u4ECA\u627F\u8FBE\u5408\u540C\u7BA1\u7406 CLI",
159
- load: async () => (await import("./chunks/contract-LLRKMLQQ.js")).contractShortcut
164
+ load: async () => (await import("./chunks/contract-U3ZGNRWB.js")).contractShortcut
160
165
  }),
161
166
  lazyShortcut({
162
167
  name: "reception",
163
168
  description: "\u6CDB\u5FAE\u5BA2\u6237\u53C2\u89C2\u63A5\u5F85\u6D41\u7A0B CLI\uFF08\u9762\u677F/\u884C\u7A0B\u5355\u4E0E\u5185\u90E8\u65B9\u6848/\u586B\u5355\u9875\u9884\u586B\uFF09",
164
- load: async () => (await import("./chunks/reception-MPBU3JXC.js")).receptionShortcut
169
+ load: async () => (await import("./chunks/reception-F2VT2X52.js")).receptionShortcut
165
170
  }),
166
171
  lazyShortcut({
167
172
  name: "smart-extract",
168
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",
169
- load: async () => (await import("./chunks/smart-extract-APX2PNIN.js")).smartExtractShortcut
174
+ load: async () => (await import("./chunks/smart-extract-SR4SJJKN.js")).smartExtractShortcut
170
175
  }),
171
176
  lazyShortcut({
172
177
  name: "data",
173
178
  description: "\u6CDB\u5FAEE10\u6570\u636E\u52A9\u624B CLI\uFF08\u6570\u636E\u6E90\u67E5\u8BE2 / \u914D\u7F6E\u4E2D\u5FC3 / \u573A\u666F\u5B9A\u4F4D\uFF09",
174
- load: async () => (await import("./chunks/data-LVDFIRNG.js")).dataShortcut
179
+ load: async () => (await import("./chunks/data-FOODGAMF.js")).dataShortcut
175
180
  })
176
181
  ];
177
182
  function shortcutMetadata() {
@@ -73,6 +73,21 @@ export const XIAOE_BUNDLED_ENV_SCRIPT_SOURCE = 'bundled scripts/xiaoe_env.py';
73
73
  export const XIAOE_ETEAMID_TTL_MS = 7_200_000;
74
74
  const XIAOE_DIAGNOSTIC_MAX_LENGTH = 300;
75
75
  const XIAOE_SCRIPT_DIAGNOSTIC_MAX_LENGTH = 2_000;
76
+ /**
77
+ * 换票接口 `/spec-apps/api/app/rpachat/skill/extend/eteamId` 的业务码实测语义
78
+ * (拿真实/伪造 token 直接打该接口验证过):
79
+ * - `0000` / `200` 成功,`data.eteamId` 是 E10 一次性票据;
80
+ * - `3006` Authorization 缺失或被拒(`token无效,禁止登录!`)→ 登录态失效;
81
+ * - `2001` `未找到可用的e10系统`——domain 在该小E 账号下匹配不到已绑定的 E10
82
+ * 系统(域名写错、账号未绑定,或 domain 不是 `https://` 小写裸域名);
83
+ * - `4000` domain 命中 eteams 但该账号没建过通用型应用。
84
+ * 只打裸业务码没法区分这几种,恢复日志会全部归到「凭证不可用」。
85
+ */
86
+ const XIAOE_EXCHANGE_CODE_HINTS = {
87
+ '2001': 'The XiaoE account is not bound to an E10 system on this domain; check the E10 baseUrl and the XiaoE-side binding.',
88
+ '3006': 'The XiaoE session token was rejected; sign in to the XiaoE client again.',
89
+ '4000': 'No generic app has been created for this domain on the eteams side.',
90
+ };
76
91
  /** 换票失败原因可能夹带服务端回显,落进结构化错误前先抹掉已知密钥。 */
77
92
  function redactXiaoEDiagnostic(message, secrets, maxLength = XIAOE_DIAGNOSTIC_MAX_LENGTH) {
78
93
  let text = message;
@@ -1100,9 +1115,16 @@ async function fetchXiaoEClientEteamId(credential, domain) {
1100
1115
  : {};
1101
1116
  if ((businessCode !== '0000' && businessCode !== 0 && businessCode !== 200) || !readString(businessData, 'eteamId')) {
1102
1117
  const codeText = businessCode === undefined ? 'missing' : String(businessCode);
1103
- throw tagXiaoEError(`XiaoE client token exchange failed with business code ${codeText}.`, {
1104
- errorKind: 'credential',
1105
- });
1118
+ // 上游 `msg` 是唯一能区分「登录态过期(3006)」「域名匹配不到 E10 系统(2001)」
1119
+ // 「应用未创建(4000)」的证据;只留一个裸业务码的话,恢复日志无法归因。
1120
+ const upstreamMessage = redactXiaoEDiagnostic(readString(payload, 'msg', 'message', 'errmsg'), [credential.authToken], XIAOE_DIAGNOSTIC_MAX_LENGTH);
1121
+ const hint = XIAOE_EXCHANGE_CODE_HINTS[codeText];
1122
+ const upstreamDetail = [
1123
+ upstreamMessage ? `upstream says "${upstreamMessage}"` : '',
1124
+ `domain ${requestedDomain}`,
1125
+ ].filter(Boolean).join('; ');
1126
+ throw tagXiaoEError(`XiaoE client token exchange failed with business code ${codeText} (${upstreamDetail}).`
1127
+ + (hint ? ` ${hint}` : ''), { errorKind: 'credential' });
1106
1128
  }
1107
1129
  return payload;
1108
1130
  }