weaver-work-cli 0.1.65 → 0.1.67
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-7SDA6WER.js} +3 -3
- package/dist/chunks/{chunk-IJDZ7VDC.js → chunk-33ANTJWB.js} +2 -2
- package/dist/chunks/{chunk-LRK7YND4.js → chunk-4PYLZORW.js} +7 -7
- package/dist/chunks/{chunk-SHX7XBYR.js → chunk-4WCVRDC5.js} +83 -33
- package/dist/chunks/{chunk-ZV3TYANI.js → chunk-6ZOSVKMT.js} +1 -1
- package/dist/chunks/{chunk-NZLFKBEM.js → chunk-DTJZOAO6.js} +6 -6
- package/dist/chunks/{chunk-F4ME3CGS.js → chunk-JU5OPHSY.js} +2 -2
- package/dist/chunks/{chunk-CUY64WP4.js → chunk-KS6LXSCA.js} +38 -38
- package/dist/chunks/{chunk-IT3SB7RV.js → chunk-LNWFHNVK.js} +2448 -318
- package/dist/chunks/{chunk-QT7GGCSY.js → chunk-MRYKV5HN.js} +32 -32
- package/dist/chunks/{chunk-K7QKQRSL.js → chunk-NP3ZZFGI.js} +24 -24
- package/dist/chunks/{chunk-E3OQSNF5.js → chunk-R6GGDZ2C.js} +1 -1
- package/dist/chunks/{chunk-6AW5LW4T.js → chunk-RU7ZZQQQ.js} +4 -4
- package/dist/chunks/{chunk-D6SWOUUP.js → chunk-TXXO4TJT.js} +2 -2
- package/dist/chunks/{chunk-JDZOYHAL.js → chunk-XARLZK6C.js} +1 -1
- package/dist/chunks/{conflict-76ZUL3E7.js → conflict-DYCSX7CN.js} +2 -2
- package/dist/chunks/{contract-INMS7SYQ.js → contract-N5WNHKHI.js} +94 -30
- package/dist/chunks/{create-flow-7WGKLRHH.js → create-flow-PABAGCK2.js} +6 -6
- package/dist/chunks/{entry-mode-3UMMMK6Z.js → entry-mode-C2WPJQJM.js} +3 -3
- package/dist/chunks/{env-7EGXNZR2.js → env-SEEXUXZF.js} +2 -2
- package/dist/chunks/{factory-BDERKTYX.js → factory-WNLDOLJZ.js} +1 -1
- package/dist/chunks/{group-chat-4E7EZMTJ.js → group-chat-DOS4XWUN.js} +3 -3
- package/dist/chunks/{invoice-MOGNB6HN.js → invoice-SMODTN2D.js} +7 -2
- package/dist/chunks/{lazy-dispatch-4WOIL3ZQ.js → lazy-dispatch-K25LTKQY.js} +2 -2
- package/dist/chunks/{meeting-2FMYZXG5.js → meeting-2IWXP5IL.js} +11 -11
- package/dist/chunks/{minute-doc-3DHMYMBE.js → minute-doc-N4OR5OLP.js} +2 -2
- package/dist/chunks/{registry-6UGQO35C.js → registry-ABKBGGGK.js} +2 -2
- package/dist/chunks/{registry-XXFMYPBM.js → registry-XOUVCSV4.js} +11 -11
- package/dist/chunks/{room-recommend-7LD2OHL5.js → room-recommend-TWIEVY44.js} +4 -4
- package/dist/chunks/{schedule-ZAYMZKTQ.js → schedule-XZ4UUX4E.js} +4 -4
- package/dist/chunks/{smart-extract-FOBSVNYW.js → smart-extract-DEBLJPCQ.js} +11 -11
- package/dist/chunks/{workflow-NYJJIT3D.js → workflow-D7LBN5MZ.js} +2 -2
- package/dist/cmd/refs/index.js +24 -23
- package/dist/core/output.js +134 -41
- package/dist/index.js +8 -8
- 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/invoice/manifest.js +1 -1
- package/dist/shortcuts/invoice/operations/get.js +2 -0
- package/dist/shortcuts/invoice/operations/shared.js +2 -0
- package/dist/shortcuts/invoice/projection.js +4 -1
- package/dist/shortcuts/smart-extract/operations/fill.js +14 -14
- package/dist/shortcuts/workflow/endpoints.js +2 -0
- package/dist/shortcuts/workflow/index.js +2 -2
- package/dist/shortcuts/workflow/operations/aiDeepRead/collect.js +1735 -0
- package/dist/shortcuts/workflow/operations/aiDeepRead/render.js +562 -0
- package/dist/shortcuts/workflow/operations/deepRead.js +447 -0
- package/dist/shortcuts/workflow/operations/form.js +28 -4
- package/dist/shortcuts/workflow/operations/read.js +18 -4
- package/dist/shortcuts/workflow/operations/registry.js +4 -0
- package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.collect.js +9 -0
- package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.core.js +3 -0
- package/dist/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.js +5 -0
- package/docs/agent-io-channel-design.md +21 -10
- package/docs/invoice.md +2 -0
- package/docs/smart-extract.md +1 -1
- package/docs/todo-smart-convert/data-contract.md +1 -1
- package/package.json +1 -1
- package/scripts/package-skill.mjs +13 -2
- 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/skills/weaver-e10-workflow/SKILL.md +15 -3
- package/skills/weaver-e10-workflow/aiDeepRead/config.json +151 -0
- package/skills/weaver-e10-workflow/aiDeepRead/templates//345/215/225/345/215/241/347/211/207-demo.html +64 -0
- package/skills/weaver-e10-workflow/aiDeepRead/templates//346/261/207/346/200/273/345/256/241/346/211/271-demo.html +310 -0
- package/skills/weaver-e10-workflow/references/todo-smart-convert.md +4 -2
- package/skills/weaver-e10-workflow/references/workflow-deep-read.md +201 -0
- package/skills/weaver-e10-workflow/tools/ai-deep-read.cjs +80 -0
- package/skills/weaver-e10-workflow/tools/todo-summary.cjs +80 -6
- package/skills/weaver-e10-yepiaotong/SKILL.md +30 -2
- package/skills/weaver-e10-yepiaotong/references/invoice-detail.md +2 -0
- package/skills/weaver-e10-yepiaotong/references/invoice-enterprise-list.md +2 -0
- package/skills/weaver-e10-yepiaotong/references/invoice-output-view.md +1 -0
- package/skills/weaver-e10-yepiaotong/references/invoice-personal-list.md +2 -0
- package/skills/weaver-e10-yepiaotong/references/invoice-reim.md +4 -4
- package/skills/weaver-e10-yepiaotong/references/reim-api-reference.md +16 -2
- package/skills/weaver-e10-yepiaotong/references/reim-examples.md +44 -9
- package/skills/weaver-e10-yepiaotong/references/reim-form-fill-rules.md +3 -1
- package/skills/weaver-e10-yepiaotong/references/reim-phone-subsidy-rules.md +16 -2
- package/skills/weaver-e10-yepiaotong/references/reim-workflow.md +61 -2
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
} from "./chunk-WRXSAVKO.js";
|
|
16
16
|
import {
|
|
17
17
|
stringifyForStdout
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-4WCVRDC5.js";
|
|
19
19
|
import {
|
|
20
20
|
stateRoot
|
|
21
21
|
} from "./chunk-AJ62BGAW.js";
|
|
@@ -239,6 +239,8 @@ var WORKFLOW_ENDPOINTS = {
|
|
|
239
239
|
/** 待办总数 / 列表 */
|
|
240
240
|
TODO_TOTAL: "/api/workflow/list/total/getTodoListTotal",
|
|
241
241
|
TODO_LIST: "/api/workflow/list/data/getTodoListData",
|
|
242
|
+
/** 列表行批量校验(2026-11-23 aiDeepRead 行过滤用:checkBatchOptRes[].canCheck) */
|
|
243
|
+
LIST_AUGMENT_BASE: "/api/workflow/list/augment/getListBaseAugment",
|
|
242
244
|
/** 待办分类树:流程大类/父类型下的工作流名称与归属类型。 */
|
|
243
245
|
TODO_TREE: "/api/workflow/list/tree/getTodoListTree",
|
|
244
246
|
/** 待办分组计数(按工作流/参与节点/参与身份三元组) */
|
|
@@ -3798,19 +3800,31 @@ function responseHasMoreFlag(response) {
|
|
|
3798
3800
|
}
|
|
3799
3801
|
return null;
|
|
3800
3802
|
}
|
|
3801
|
-
async function fetchRequestLogPage(env, requestId, current, pageSize) {
|
|
3803
|
+
async function fetchRequestLogPage(env, requestId, current, pageSize, options) {
|
|
3802
3804
|
const session = await env.host.getSession();
|
|
3803
3805
|
const normalizedCurrent = Math.max(1, current || 1);
|
|
3804
|
-
const normalizedPageSize = Math.max(1, Math.min(
|
|
3806
|
+
const normalizedPageSize = Math.max(1, Math.min(500, pageSize || 10));
|
|
3805
3807
|
const loadPage = async (page) => {
|
|
3806
|
-
const body = {
|
|
3808
|
+
const body = {
|
|
3809
|
+
requestId,
|
|
3810
|
+
// ★ 分页键发双份:`current` 是 CLI 旧口径,`pageNumber` 是服务端真实读取的键
|
|
3811
|
+
// (RequestPAServiceImpl.getRequestLog 只认 pageNumber,`current` 会被静默忽略 →
|
|
3812
|
+
// 恒返回第 1 页。2026-11-18 核对源码发现,aiDeepRead 翻页拉全量依赖此修复)。
|
|
3813
|
+
current: page,
|
|
3814
|
+
pageNumber: page,
|
|
3815
|
+
pageSize: normalizedPageSize
|
|
3816
|
+
};
|
|
3817
|
+
if (options?.datatype !== void 0) body.datatype = options.datatype;
|
|
3818
|
+
if (options?.notShowEmpty !== void 0) body.notShowEmpty = options.notShowEmpty;
|
|
3807
3819
|
if (session.userId) body.userId = session.userId;
|
|
3808
|
-
|
|
3820
|
+
const raw = await env.host.workflowRequest({
|
|
3809
3821
|
method: "POST",
|
|
3810
3822
|
path: WORKFLOW_ENDPOINTS.REQUEST_LOG,
|
|
3811
3823
|
operation: "workflow.requestLog",
|
|
3812
3824
|
body
|
|
3813
3825
|
});
|
|
3826
|
+
options?.captureRaw?.(raw, page);
|
|
3827
|
+
return raw;
|
|
3814
3828
|
};
|
|
3815
3829
|
const response = await loadPage(normalizedCurrent);
|
|
3816
3830
|
const items = extractRequestLogItems(response, normalizedPageSize * 2).slice(0, normalizedPageSize);
|
|
@@ -8651,11 +8665,22 @@ async function runCreateRequest(args, env, options = {}) {
|
|
|
8651
8665
|
});
|
|
8652
8666
|
}
|
|
8653
8667
|
const [details, valueAmbiguities, preview] = await resolveEntryValues(env, entries, context.layout.form_id);
|
|
8654
|
-
const merged = mergeDetails(context.defaults || [], details);
|
|
8655
8668
|
const isXiaoE = hasXiaoEEnv(env.ctx.env, env.ctx.getGlobalOptions?.());
|
|
8656
|
-
const
|
|
8669
|
+
const loadLinkageDetails = isXiaoE ? [] : await runFieldLinkage(
|
|
8670
|
+
env,
|
|
8671
|
+
linkageContextFromPayload(context),
|
|
8672
|
+
_entriesFromDefaults(context.defaults || []),
|
|
8673
|
+
null,
|
|
8674
|
+
null,
|
|
8675
|
+
false,
|
|
8676
|
+
null
|
|
8677
|
+
);
|
|
8678
|
+
const loadedState = mergeLinkageDetails(context.defaults || [], loadLinkageDetails);
|
|
8679
|
+
const withInput = mergeDetails(loadedState, details);
|
|
8680
|
+
const changeLinkageDetails = isXiaoE ? [] : await runFieldLinkage(env, linkageContextFromPayload(context), entries, null, withInput, false, loadedState);
|
|
8681
|
+
const linkageDetails = [...loadLinkageDetails, ...changeLinkageDetails];
|
|
8657
8682
|
const merged2 = fillDetailDefaultsByRow(
|
|
8658
|
-
mergeLinkageDetails(
|
|
8683
|
+
mergeLinkageDetails(withInput, changeLinkageDetails),
|
|
8659
8684
|
context.defaults || [],
|
|
8660
8685
|
userDetailRows(entries)
|
|
8661
8686
|
);
|
|
@@ -10120,16 +10145,256 @@ var workflowFormOperations = [
|
|
|
10120
10145
|
workflowEditApply
|
|
10121
10146
|
];
|
|
10122
10147
|
|
|
10123
|
-
// src/shortcuts/workflow/operations/
|
|
10124
|
-
|
|
10125
|
-
|
|
10126
|
-
|
|
10148
|
+
// src/shortcuts/workflow/operations/deepRead.ts
|
|
10149
|
+
import { readFileSync as readFileSync2 } from "node:fs";
|
|
10150
|
+
import { join as join4 } from "node:path";
|
|
10151
|
+
|
|
10152
|
+
// src/shortcuts/workflow/operations/todoSmartConvert/summaryCache.ts
|
|
10153
|
+
import { existsSync as existsSync2 } from "node:fs";
|
|
10154
|
+
import { chmod as chmod2, mkdir as mkdir2, readFile as readFile2, writeFile as writeFile2 } from "node:fs/promises";
|
|
10155
|
+
import { join, resolve as resolve2 } from "node:path";
|
|
10156
|
+
var CACHE_DIR_NAME = "cache";
|
|
10157
|
+
var SUMMARY_CACHE_FILE_NAME = "todo-summary-cache.json";
|
|
10158
|
+
var SUMMARY_CACHE_VERSION = 2;
|
|
10159
|
+
function uniqueDirs(dirs) {
|
|
10160
|
+
return [...new Set(dirs.filter((dir) => Boolean(dir)))];
|
|
10127
10161
|
}
|
|
10128
|
-
function
|
|
10162
|
+
function resolveSkillDir() {
|
|
10163
|
+
const explicit = process.env.WEAVER_WORK_CLI_SKILL_DIR?.trim();
|
|
10164
|
+
return explicit ? resolve2(explicit) : null;
|
|
10165
|
+
}
|
|
10166
|
+
function cacheRoots(ctx) {
|
|
10167
|
+
void ctx;
|
|
10168
|
+
const skillDir = resolveSkillDir();
|
|
10169
|
+
if (!skillDir) {
|
|
10170
|
+
return { preferred: null, fallback: null, inSkillDir: false, skillDir: null, refused: true };
|
|
10171
|
+
}
|
|
10172
|
+
const cacheDir = join(skillDir, CACHE_DIR_NAME);
|
|
10173
|
+
return { preferred: cacheDir, fallback: cacheDir, inSkillDir: true, skillDir, refused: false };
|
|
10174
|
+
}
|
|
10175
|
+
async function readCacheFile(roots, fileName) {
|
|
10176
|
+
if (roots.refused || !roots.preferred) return null;
|
|
10177
|
+
for (const dir of uniqueDirs([roots.preferred, roots.fallback])) {
|
|
10178
|
+
const file = join(dir, fileName);
|
|
10179
|
+
if (!existsSync2(file)) continue;
|
|
10180
|
+
try {
|
|
10181
|
+
return { text: await readFile2(file, "utf8"), file };
|
|
10182
|
+
} catch {
|
|
10183
|
+
continue;
|
|
10184
|
+
}
|
|
10185
|
+
}
|
|
10186
|
+
return null;
|
|
10187
|
+
}
|
|
10188
|
+
async function writeCacheFile(roots, fileName, payload) {
|
|
10189
|
+
if (roots.refused || !roots.preferred) return null;
|
|
10190
|
+
for (const dir of uniqueDirs([roots.preferred, roots.fallback])) {
|
|
10191
|
+
const file = join(dir, fileName);
|
|
10192
|
+
try {
|
|
10193
|
+
await mkdir2(dir, { recursive: true, mode: 448 });
|
|
10194
|
+
await writeFile2(file, payload, { mode: 384 });
|
|
10195
|
+
if (process.platform !== "win32") await chmod2(file, 384).catch(() => void 0);
|
|
10196
|
+
return file;
|
|
10197
|
+
} catch {
|
|
10198
|
+
continue;
|
|
10199
|
+
}
|
|
10200
|
+
}
|
|
10201
|
+
return null;
|
|
10202
|
+
}
|
|
10203
|
+
var SUMMARY_CACHE_TTL_MS = 7 * 24 * 60 * 60 * 1e3;
|
|
10204
|
+
var SUMMARY_CACHE_PRUNE_INTERVAL_MS = 3 * 24 * 60 * 60 * 1e3;
|
|
10205
|
+
function summaryCacheKey(requestId, lastFeedBackDateTime) {
|
|
10206
|
+
const stamp = String(lastFeedBackDateTime ?? "").trim();
|
|
10207
|
+
return `${requestId}__${stamp}`;
|
|
10208
|
+
}
|
|
10209
|
+
function promptTagOf(prompt) {
|
|
10210
|
+
return String(prompt ?? "").trim();
|
|
10211
|
+
}
|
|
10212
|
+
function entryMatches(entry, maxChars, pk, dv) {
|
|
10213
|
+
if (pk !== void 0 && entry.pk !== pk) return false;
|
|
10214
|
+
if (maxChars !== void 0 && entry.maxChars !== void 0 && entry.maxChars !== maxChars) return false;
|
|
10215
|
+
if (entry.dv !== void 0 && entry.dv !== dv) return false;
|
|
10216
|
+
return true;
|
|
10217
|
+
}
|
|
10218
|
+
function normalizeSummaryEntry(raw) {
|
|
10219
|
+
if (!raw || typeof raw !== "object") return null;
|
|
10220
|
+
const entry = raw;
|
|
10221
|
+
if (typeof entry.summary !== "string" || !entry.summary.trim()) return null;
|
|
10222
|
+
if (typeof entry.cachedAt !== "number" || !Number.isFinite(entry.cachedAt)) return null;
|
|
10223
|
+
const maxChars = typeof entry.maxChars === "number" && Number.isFinite(entry.maxChars) ? entry.maxChars : void 0;
|
|
10224
|
+
const pk = typeof entry.pk === "string" ? entry.pk : void 0;
|
|
10225
|
+
const dv = typeof entry.dv === "string" && entry.dv !== "" ? entry.dv : void 0;
|
|
10129
10226
|
return {
|
|
10130
|
-
|
|
10131
|
-
|
|
10227
|
+
summary: entry.summary,
|
|
10228
|
+
cachedAt: entry.cachedAt,
|
|
10229
|
+
...maxChars === void 0 ? {} : { maxChars },
|
|
10230
|
+
...pk === void 0 ? {} : { pk },
|
|
10231
|
+
...dv === void 0 ? {} : { dv }
|
|
10232
|
+
};
|
|
10233
|
+
}
|
|
10234
|
+
async function openSummaryCache(ctx) {
|
|
10235
|
+
const roots = cacheRoots(ctx);
|
|
10236
|
+
const stored = await readCacheFile(roots, SUMMARY_CACHE_FILE_NAME);
|
|
10237
|
+
const now = Date.now();
|
|
10238
|
+
const entries = /* @__PURE__ */ new Map();
|
|
10239
|
+
let prunedAt = 0;
|
|
10240
|
+
let loadedCount = 0;
|
|
10241
|
+
if (stored) {
|
|
10242
|
+
try {
|
|
10243
|
+
const parsed = JSON.parse(stored.text);
|
|
10244
|
+
prunedAt = typeof parsed.prunedAt === "number" ? parsed.prunedAt : 0;
|
|
10245
|
+
const versionOk = parsed.version === SUMMARY_CACHE_VERSION;
|
|
10246
|
+
const rawEntries = versionOk && parsed.entries && typeof parsed.entries === "object" ? parsed.entries : {};
|
|
10247
|
+
for (const [key, raw] of Object.entries(rawEntries)) {
|
|
10248
|
+
const entry = normalizeSummaryEntry(raw);
|
|
10249
|
+
if (!entry) continue;
|
|
10250
|
+
loadedCount += 1;
|
|
10251
|
+
if (now - entry.cachedAt > SUMMARY_CACHE_TTL_MS) continue;
|
|
10252
|
+
entries.set(key, entry);
|
|
10253
|
+
}
|
|
10254
|
+
} catch {
|
|
10255
|
+
}
|
|
10256
|
+
}
|
|
10257
|
+
const pruned = loadedCount - entries.size;
|
|
10258
|
+
const pruneDue = stored !== null && (prunedAt === 0 || now - prunedAt > SUMMARY_CACHE_PRUNE_INTERVAL_MS);
|
|
10259
|
+
let file = stored?.file ?? null;
|
|
10260
|
+
let dirty = false;
|
|
10261
|
+
const cache = {
|
|
10262
|
+
file,
|
|
10263
|
+
inSkillDir: roots.inSkillDir,
|
|
10264
|
+
size: entries.size,
|
|
10265
|
+
hits: 0,
|
|
10266
|
+
misses: 0,
|
|
10267
|
+
pruned,
|
|
10268
|
+
dirty: false,
|
|
10269
|
+
get(requestId, lastFeedBackDateTime, maxChars, pk, dv) {
|
|
10270
|
+
const key = summaryCacheKey(requestId, lastFeedBackDateTime);
|
|
10271
|
+
const entry = entries.get(key);
|
|
10272
|
+
if (entry && now - entry.cachedAt <= SUMMARY_CACHE_TTL_MS && entryMatches(entry, maxChars, pk, dv)) {
|
|
10273
|
+
cache.hits += 1;
|
|
10274
|
+
return entry.summary;
|
|
10275
|
+
}
|
|
10276
|
+
cache.misses += 1;
|
|
10277
|
+
return null;
|
|
10278
|
+
},
|
|
10279
|
+
has(requestId, lastFeedBackDateTime, maxChars, pk, dv) {
|
|
10280
|
+
const entry = entries.get(summaryCacheKey(requestId, lastFeedBackDateTime));
|
|
10281
|
+
return entry !== void 0 && entryMatches(entry, maxChars, pk, dv);
|
|
10282
|
+
},
|
|
10283
|
+
set(requestId, lastFeedBackDateTime, summary, maxChars, pk, dv) {
|
|
10284
|
+
const text = String(summary ?? "").trim();
|
|
10285
|
+
if (!requestId || !text) return false;
|
|
10286
|
+
entries.set(summaryCacheKey(requestId, lastFeedBackDateTime), {
|
|
10287
|
+
summary: text,
|
|
10288
|
+
cachedAt: Date.now(),
|
|
10289
|
+
...maxChars === void 0 ? {} : { maxChars },
|
|
10290
|
+
// 空串同样落库(见 entryMatches 注释):空口径与「缺 pk」必须能区分开。
|
|
10291
|
+
...pk === void 0 ? {} : { pk },
|
|
10292
|
+
...dv === void 0 || dv === "" ? {} : { dv }
|
|
10293
|
+
});
|
|
10294
|
+
dirty = true;
|
|
10295
|
+
cache.dirty = true;
|
|
10296
|
+
cache.size = entries.size;
|
|
10297
|
+
return true;
|
|
10298
|
+
},
|
|
10299
|
+
async save() {
|
|
10300
|
+
if (!dirty && !pruneDue) return file;
|
|
10301
|
+
const payload = {
|
|
10302
|
+
version: SUMMARY_CACHE_VERSION,
|
|
10303
|
+
prunedAt: Date.now(),
|
|
10304
|
+
entries: Object.fromEntries(entries)
|
|
10305
|
+
};
|
|
10306
|
+
const written = await writeCacheFile(roots, SUMMARY_CACHE_FILE_NAME, JSON.stringify(payload));
|
|
10307
|
+
if (written) {
|
|
10308
|
+
file = written;
|
|
10309
|
+
cache.file = written;
|
|
10310
|
+
dirty = false;
|
|
10311
|
+
cache.dirty = false;
|
|
10312
|
+
}
|
|
10313
|
+
return written;
|
|
10314
|
+
}
|
|
10132
10315
|
};
|
|
10316
|
+
if (pruneDue) await cache.save();
|
|
10317
|
+
return cache;
|
|
10318
|
+
}
|
|
10319
|
+
|
|
10320
|
+
// src/shortcuts/workflow/operations/aiDeepRead/collect.ts
|
|
10321
|
+
import { mkdirSync, writeFileSync } from "node:fs";
|
|
10322
|
+
import { tmpdir as tmpdir2 } from "node:os";
|
|
10323
|
+
import { join as join3 } from "node:path";
|
|
10324
|
+
|
|
10325
|
+
// src/shortcuts/workflow/operations/todoSmartConvert/todoListRows.ts
|
|
10326
|
+
var DISPLAY_ROW_FIELDS = [
|
|
10327
|
+
// 定位键
|
|
10328
|
+
"requestId",
|
|
10329
|
+
"requestid",
|
|
10330
|
+
"workflowid",
|
|
10331
|
+
"workflowId",
|
|
10332
|
+
"userMasterId",
|
|
10333
|
+
"userid",
|
|
10334
|
+
"isremark",
|
|
10335
|
+
"isremarktype",
|
|
10336
|
+
"nodeid",
|
|
10337
|
+
"currentNodeId",
|
|
10338
|
+
// 状态位
|
|
10339
|
+
"overdue",
|
|
10340
|
+
"userOverTime",
|
|
10341
|
+
"handleStatus",
|
|
10342
|
+
"requestlevel",
|
|
10343
|
+
"requestLevelShow",
|
|
10344
|
+
"requestlevelShow",
|
|
10345
|
+
"requestlevelTitle",
|
|
10346
|
+
// 展示字段
|
|
10347
|
+
"requestnamehtml",
|
|
10348
|
+
"requestnameTitle",
|
|
10349
|
+
"requestnametitle",
|
|
10350
|
+
"requestname",
|
|
10351
|
+
"creater",
|
|
10352
|
+
"creatername",
|
|
10353
|
+
"creatorName",
|
|
10354
|
+
"workflowname",
|
|
10355
|
+
"workflowName",
|
|
10356
|
+
"workflowTypeName",
|
|
10357
|
+
"requestmark",
|
|
10358
|
+
"flowstatusShow",
|
|
10359
|
+
"receivedatetime",
|
|
10360
|
+
"operatedatetime",
|
|
10361
|
+
// 最后反馈时间:`getTodoListData.displayData` 里的原始键是全小写,大小写变体一并保留。
|
|
10362
|
+
"lastfeedbackdatetime",
|
|
10363
|
+
"lastFeedbackDateTime",
|
|
10364
|
+
// 计划完成时间(2026-11-05 补):接口原始键是**驼峰** `planFinishDatetime`,且与
|
|
10365
|
+
// `minOverDateTime` / `curUserOverTime` 三者同值(实测 5 条:`2026-11-06 14:21:23`)。
|
|
10366
|
+
// 之前漏在白名单外 ⇒ `rowFromAny` 虽然写了 pick 也永远取不到,优先组规则想按到期时间判断就成了空谈。
|
|
10367
|
+
"planFinishDatetime",
|
|
10368
|
+
"planfinishdatetime"
|
|
10369
|
+
];
|
|
10370
|
+
function projectDisplayRows(response, extraFields) {
|
|
10371
|
+
const record = responseData(response);
|
|
10372
|
+
const raw = record?.data?.displayData ?? record?.displayData ?? [];
|
|
10373
|
+
const rows = Array.isArray(raw) ? raw : [];
|
|
10374
|
+
const projected = [];
|
|
10375
|
+
const extra = extraFields && extraFields.size > 0 ? extraFields : null;
|
|
10376
|
+
for (const row of rows) {
|
|
10377
|
+
if (!row || typeof row !== "object" || Array.isArray(row)) continue;
|
|
10378
|
+
const source = row;
|
|
10379
|
+
const picked = {};
|
|
10380
|
+
for (const key of DISPLAY_ROW_FIELDS) {
|
|
10381
|
+
const value = source[key];
|
|
10382
|
+
if (typeof value === "string" || typeof value === "number" || typeof value === "boolean" || key === "handleStatus" && value === null) {
|
|
10383
|
+
picked[key] = value;
|
|
10384
|
+
}
|
|
10385
|
+
}
|
|
10386
|
+
if (extra) {
|
|
10387
|
+
for (const [key, value] of Object.entries(source)) {
|
|
10388
|
+
if (key in picked) continue;
|
|
10389
|
+
if (!extra.has(key.toLowerCase())) continue;
|
|
10390
|
+
if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
|
|
10391
|
+
picked[key] = value;
|
|
10392
|
+
}
|
|
10393
|
+
}
|
|
10394
|
+
}
|
|
10395
|
+
if (Object.keys(picked).length > 0) projected.push(picked);
|
|
10396
|
+
}
|
|
10397
|
+
return projected;
|
|
10133
10398
|
}
|
|
10134
10399
|
|
|
10135
10400
|
// src/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.core.ts
|
|
@@ -10313,6 +10578,9 @@ var ALLOWED_INPUT_KEYS = [
|
|
|
10313
10578
|
"limit",
|
|
10314
10579
|
"pageSize",
|
|
10315
10580
|
"category",
|
|
10581
|
+
// originData(2026-11-24 用户定稿):摘要链路把 collect 各页 getTodoListData 原始响应体透出,
|
|
10582
|
+
// 由 skill 的 tools 脚本落盘 <skill>/originData/,产物 data 里以 originDataId 引用。
|
|
10583
|
+
"originData",
|
|
10316
10584
|
...COLLECT_FILTER_KEYS,
|
|
10317
10585
|
...COLLECT_ORDER_KEYS,
|
|
10318
10586
|
// smartGroupAdd(2026-11-13):产物落库字段,与 E10 WflSmartGroupAddParamsDto 同名
|
|
@@ -10615,174 +10883,6 @@ function readBoundedInt(value, name, fallback, min, max) {
|
|
|
10615
10883
|
import { existsSync as existsSync3, readFileSync } from "node:fs";
|
|
10616
10884
|
import { join as join2 } from "node:path";
|
|
10617
10885
|
|
|
10618
|
-
// src/shortcuts/workflow/operations/todoSmartConvert/summaryCache.ts
|
|
10619
|
-
import { existsSync as existsSync2 } from "node:fs";
|
|
10620
|
-
import { chmod as chmod2, mkdir as mkdir2, readFile as readFile2, writeFile as writeFile2 } from "node:fs/promises";
|
|
10621
|
-
import { join, resolve as resolve2 } from "node:path";
|
|
10622
|
-
var CACHE_DIR_NAME = "cache";
|
|
10623
|
-
var SUMMARY_CACHE_FILE_NAME = "todo-summary-cache.json";
|
|
10624
|
-
var SUMMARY_CACHE_VERSION = 2;
|
|
10625
|
-
function uniqueDirs(dirs) {
|
|
10626
|
-
return [...new Set(dirs.filter((dir) => Boolean(dir)))];
|
|
10627
|
-
}
|
|
10628
|
-
function resolveSkillDir() {
|
|
10629
|
-
const explicit = process.env.WEAVER_WORK_CLI_SKILL_DIR?.trim();
|
|
10630
|
-
return explicit ? resolve2(explicit) : null;
|
|
10631
|
-
}
|
|
10632
|
-
function cacheRoots(ctx) {
|
|
10633
|
-
void ctx;
|
|
10634
|
-
const skillDir = resolveSkillDir();
|
|
10635
|
-
if (!skillDir) {
|
|
10636
|
-
return { preferred: null, fallback: null, inSkillDir: false, skillDir: null, refused: true };
|
|
10637
|
-
}
|
|
10638
|
-
const cacheDir = join(skillDir, CACHE_DIR_NAME);
|
|
10639
|
-
return { preferred: cacheDir, fallback: cacheDir, inSkillDir: true, skillDir, refused: false };
|
|
10640
|
-
}
|
|
10641
|
-
async function readCacheFile(roots, fileName) {
|
|
10642
|
-
if (roots.refused || !roots.preferred) return null;
|
|
10643
|
-
for (const dir of uniqueDirs([roots.preferred, roots.fallback])) {
|
|
10644
|
-
const file = join(dir, fileName);
|
|
10645
|
-
if (!existsSync2(file)) continue;
|
|
10646
|
-
try {
|
|
10647
|
-
return { text: await readFile2(file, "utf8"), file };
|
|
10648
|
-
} catch {
|
|
10649
|
-
continue;
|
|
10650
|
-
}
|
|
10651
|
-
}
|
|
10652
|
-
return null;
|
|
10653
|
-
}
|
|
10654
|
-
async function writeCacheFile(roots, fileName, payload) {
|
|
10655
|
-
if (roots.refused || !roots.preferred) return null;
|
|
10656
|
-
for (const dir of uniqueDirs([roots.preferred, roots.fallback])) {
|
|
10657
|
-
const file = join(dir, fileName);
|
|
10658
|
-
try {
|
|
10659
|
-
await mkdir2(dir, { recursive: true, mode: 448 });
|
|
10660
|
-
await writeFile2(file, payload, { mode: 384 });
|
|
10661
|
-
if (process.platform !== "win32") await chmod2(file, 384).catch(() => void 0);
|
|
10662
|
-
return file;
|
|
10663
|
-
} catch {
|
|
10664
|
-
continue;
|
|
10665
|
-
}
|
|
10666
|
-
}
|
|
10667
|
-
return null;
|
|
10668
|
-
}
|
|
10669
|
-
var SUMMARY_CACHE_TTL_MS = 7 * 24 * 60 * 60 * 1e3;
|
|
10670
|
-
var SUMMARY_CACHE_PRUNE_INTERVAL_MS = 3 * 24 * 60 * 60 * 1e3;
|
|
10671
|
-
function summaryCacheKey(requestId, lastFeedBackDateTime) {
|
|
10672
|
-
const stamp = String(lastFeedBackDateTime ?? "").trim();
|
|
10673
|
-
return `${requestId}__${stamp}`;
|
|
10674
|
-
}
|
|
10675
|
-
function promptTagOf(prompt) {
|
|
10676
|
-
return String(prompt ?? "").trim();
|
|
10677
|
-
}
|
|
10678
|
-
function entryMatches(entry, maxChars, pk, dv) {
|
|
10679
|
-
if (pk !== void 0 && entry.pk !== pk) return false;
|
|
10680
|
-
if (maxChars !== void 0 && entry.maxChars !== void 0 && entry.maxChars !== maxChars) return false;
|
|
10681
|
-
if (entry.dv !== void 0 && entry.dv !== dv) return false;
|
|
10682
|
-
return true;
|
|
10683
|
-
}
|
|
10684
|
-
function normalizeSummaryEntry(raw) {
|
|
10685
|
-
if (!raw || typeof raw !== "object") return null;
|
|
10686
|
-
const entry = raw;
|
|
10687
|
-
if (typeof entry.summary !== "string" || !entry.summary.trim()) return null;
|
|
10688
|
-
if (typeof entry.cachedAt !== "number" || !Number.isFinite(entry.cachedAt)) return null;
|
|
10689
|
-
const maxChars = typeof entry.maxChars === "number" && Number.isFinite(entry.maxChars) ? entry.maxChars : void 0;
|
|
10690
|
-
const pk = typeof entry.pk === "string" ? entry.pk : void 0;
|
|
10691
|
-
const dv = typeof entry.dv === "string" && entry.dv !== "" ? entry.dv : void 0;
|
|
10692
|
-
return {
|
|
10693
|
-
summary: entry.summary,
|
|
10694
|
-
cachedAt: entry.cachedAt,
|
|
10695
|
-
...maxChars === void 0 ? {} : { maxChars },
|
|
10696
|
-
...pk === void 0 ? {} : { pk },
|
|
10697
|
-
...dv === void 0 ? {} : { dv }
|
|
10698
|
-
};
|
|
10699
|
-
}
|
|
10700
|
-
async function openSummaryCache(ctx) {
|
|
10701
|
-
const roots = cacheRoots(ctx);
|
|
10702
|
-
const stored = await readCacheFile(roots, SUMMARY_CACHE_FILE_NAME);
|
|
10703
|
-
const now = Date.now();
|
|
10704
|
-
const entries = /* @__PURE__ */ new Map();
|
|
10705
|
-
let prunedAt = 0;
|
|
10706
|
-
let loadedCount = 0;
|
|
10707
|
-
if (stored) {
|
|
10708
|
-
try {
|
|
10709
|
-
const parsed = JSON.parse(stored.text);
|
|
10710
|
-
prunedAt = typeof parsed.prunedAt === "number" ? parsed.prunedAt : 0;
|
|
10711
|
-
const versionOk = parsed.version === SUMMARY_CACHE_VERSION;
|
|
10712
|
-
const rawEntries = versionOk && parsed.entries && typeof parsed.entries === "object" ? parsed.entries : {};
|
|
10713
|
-
for (const [key, raw] of Object.entries(rawEntries)) {
|
|
10714
|
-
const entry = normalizeSummaryEntry(raw);
|
|
10715
|
-
if (!entry) continue;
|
|
10716
|
-
loadedCount += 1;
|
|
10717
|
-
if (now - entry.cachedAt > SUMMARY_CACHE_TTL_MS) continue;
|
|
10718
|
-
entries.set(key, entry);
|
|
10719
|
-
}
|
|
10720
|
-
} catch {
|
|
10721
|
-
}
|
|
10722
|
-
}
|
|
10723
|
-
const pruned = loadedCount - entries.size;
|
|
10724
|
-
const pruneDue = stored !== null && (prunedAt === 0 || now - prunedAt > SUMMARY_CACHE_PRUNE_INTERVAL_MS);
|
|
10725
|
-
let file = stored?.file ?? null;
|
|
10726
|
-
let dirty = false;
|
|
10727
|
-
const cache = {
|
|
10728
|
-
file,
|
|
10729
|
-
inSkillDir: roots.inSkillDir,
|
|
10730
|
-
size: entries.size,
|
|
10731
|
-
hits: 0,
|
|
10732
|
-
misses: 0,
|
|
10733
|
-
pruned,
|
|
10734
|
-
dirty: false,
|
|
10735
|
-
get(requestId, lastFeedBackDateTime, maxChars, pk, dv) {
|
|
10736
|
-
const key = summaryCacheKey(requestId, lastFeedBackDateTime);
|
|
10737
|
-
const entry = entries.get(key);
|
|
10738
|
-
if (entry && now - entry.cachedAt <= SUMMARY_CACHE_TTL_MS && entryMatches(entry, maxChars, pk, dv)) {
|
|
10739
|
-
cache.hits += 1;
|
|
10740
|
-
return entry.summary;
|
|
10741
|
-
}
|
|
10742
|
-
cache.misses += 1;
|
|
10743
|
-
return null;
|
|
10744
|
-
},
|
|
10745
|
-
has(requestId, lastFeedBackDateTime, maxChars, pk, dv) {
|
|
10746
|
-
const entry = entries.get(summaryCacheKey(requestId, lastFeedBackDateTime));
|
|
10747
|
-
return entry !== void 0 && entryMatches(entry, maxChars, pk, dv);
|
|
10748
|
-
},
|
|
10749
|
-
set(requestId, lastFeedBackDateTime, summary, maxChars, pk, dv) {
|
|
10750
|
-
const text = String(summary ?? "").trim();
|
|
10751
|
-
if (!requestId || !text) return false;
|
|
10752
|
-
entries.set(summaryCacheKey(requestId, lastFeedBackDateTime), {
|
|
10753
|
-
summary: text,
|
|
10754
|
-
cachedAt: Date.now(),
|
|
10755
|
-
...maxChars === void 0 ? {} : { maxChars },
|
|
10756
|
-
// 空串同样落库(见 entryMatches 注释):空口径与「缺 pk」必须能区分开。
|
|
10757
|
-
...pk === void 0 ? {} : { pk },
|
|
10758
|
-
...dv === void 0 || dv === "" ? {} : { dv }
|
|
10759
|
-
});
|
|
10760
|
-
dirty = true;
|
|
10761
|
-
cache.dirty = true;
|
|
10762
|
-
cache.size = entries.size;
|
|
10763
|
-
return true;
|
|
10764
|
-
},
|
|
10765
|
-
async save() {
|
|
10766
|
-
if (!dirty && !pruneDue) return file;
|
|
10767
|
-
const payload = {
|
|
10768
|
-
version: SUMMARY_CACHE_VERSION,
|
|
10769
|
-
prunedAt: Date.now(),
|
|
10770
|
-
entries: Object.fromEntries(entries)
|
|
10771
|
-
};
|
|
10772
|
-
const written = await writeCacheFile(roots, SUMMARY_CACHE_FILE_NAME, JSON.stringify(payload));
|
|
10773
|
-
if (written) {
|
|
10774
|
-
file = written;
|
|
10775
|
-
cache.file = written;
|
|
10776
|
-
dirty = false;
|
|
10777
|
-
cache.dirty = false;
|
|
10778
|
-
}
|
|
10779
|
-
return written;
|
|
10780
|
-
}
|
|
10781
|
-
};
|
|
10782
|
-
if (pruneDue) await cache.save();
|
|
10783
|
-
return cache;
|
|
10784
|
-
}
|
|
10785
|
-
|
|
10786
10886
|
// src/shortcuts/workflow/operations/todoSmartConvert/priorityExpr.ts
|
|
10787
10887
|
var PriorityExprError = class extends Error {
|
|
10788
10888
|
position;
|
|
@@ -11670,148 +11770,2167 @@ function evaluateFocusKeywords(conditions, resolve3, now = /* @__PURE__ */ new D
|
|
|
11670
11770
|
if (conditions.length === 0) return false;
|
|
11671
11771
|
return conditions.every((condition) => evaluateCondition2(condition, resolve3(condition[0]), now));
|
|
11672
11772
|
}
|
|
11673
|
-
var activeFile = null;
|
|
11674
|
-
var activeDir = null;
|
|
11675
|
-
function primeRules(ctx) {
|
|
11676
|
-
const loaded = loadRules({ ctx });
|
|
11677
|
-
activeFile = loaded.file;
|
|
11678
|
-
activeDir = loaded.dir;
|
|
11679
|
-
return loaded;
|
|
11773
|
+
var activeFile = null;
|
|
11774
|
+
var activeDir = null;
|
|
11775
|
+
function primeRules(ctx) {
|
|
11776
|
+
const loaded = loadRules({ ctx });
|
|
11777
|
+
activeFile = loaded.file;
|
|
11778
|
+
activeDir = loaded.dir;
|
|
11779
|
+
return loaded;
|
|
11780
|
+
}
|
|
11781
|
+
function activeRules() {
|
|
11782
|
+
if (!activeFile) {
|
|
11783
|
+
const loaded = loadRules();
|
|
11784
|
+
activeFile = loaded.file;
|
|
11785
|
+
activeDir = loaded.dir;
|
|
11786
|
+
}
|
|
11787
|
+
return activeFile;
|
|
11788
|
+
}
|
|
11789
|
+
function activeRuleFor(workflowName) {
|
|
11790
|
+
const name = String(workflowName ?? "").trim();
|
|
11791
|
+
if (!name) return null;
|
|
11792
|
+
return resolveRule(activeRules(), name)?.rule ?? null;
|
|
11793
|
+
}
|
|
11794
|
+
function generalRules() {
|
|
11795
|
+
return activeRules().generalRules ?? null;
|
|
11796
|
+
}
|
|
11797
|
+
var priorityExprCache = null;
|
|
11798
|
+
function priorityRuleSource() {
|
|
11799
|
+
const source = generalRules()?.priorityGroup?.rule?.trim();
|
|
11800
|
+
return source ? source : null;
|
|
11801
|
+
}
|
|
11802
|
+
function priorityRuleExpr() {
|
|
11803
|
+
const source = priorityRuleSource();
|
|
11804
|
+
if (!source) {
|
|
11805
|
+
priorityExprCache = null;
|
|
11806
|
+
return null;
|
|
11807
|
+
}
|
|
11808
|
+
if (priorityExprCache && priorityExprCache.source === source) return priorityExprCache.expr;
|
|
11809
|
+
const expr = parsePriorityRule(source);
|
|
11810
|
+
priorityExprCache = { source, expr };
|
|
11811
|
+
return expr;
|
|
11812
|
+
}
|
|
11813
|
+
function priorityRuleFields() {
|
|
11814
|
+
const expr = priorityRuleExpr();
|
|
11815
|
+
return expr ? collectPriorityFields(expr) : /* @__PURE__ */ new Set();
|
|
11816
|
+
}
|
|
11817
|
+
function prioritySort() {
|
|
11818
|
+
return parsePrioritySort(generalRules()?.priorityGroup?.sort);
|
|
11819
|
+
}
|
|
11820
|
+
function resetActiveRules() {
|
|
11821
|
+
activeFile = null;
|
|
11822
|
+
activeDir = null;
|
|
11823
|
+
priorityExprCache = null;
|
|
11824
|
+
}
|
|
11825
|
+
function excludeFieldsFor(workflowName) {
|
|
11826
|
+
return activeRuleFor(workflowName)?.excludeOriginFormDataFields ?? [];
|
|
11827
|
+
}
|
|
11828
|
+
function excludeTagOf(fields) {
|
|
11829
|
+
return [...fields].join("");
|
|
11830
|
+
}
|
|
11831
|
+
function excludeTagFor(workflowName) {
|
|
11832
|
+
return excludeTagOf(excludeFieldsFor(workflowName));
|
|
11833
|
+
}
|
|
11834
|
+
|
|
11835
|
+
// src/shortcuts/workflow/operations/aiDeepRead/collect.ts
|
|
11836
|
+
var DETAIL_CONCURRENCY = 20;
|
|
11837
|
+
var DETAIL_TIMEOUT_MS = 3e4;
|
|
11838
|
+
var DETAIL_RETRIES = 1;
|
|
11839
|
+
var MAX_PAGE_SIZE = 100;
|
|
11840
|
+
var LOG_PAGE_SIZE = 50;
|
|
11841
|
+
function normalizeGroupEntries(raw) {
|
|
11842
|
+
const warnings = [];
|
|
11843
|
+
const entries = [];
|
|
11844
|
+
if (!Array.isArray(raw)) {
|
|
11845
|
+
return { entries, warnings };
|
|
11846
|
+
}
|
|
11847
|
+
raw.forEach((item, idx) => {
|
|
11848
|
+
if (!item || typeof item !== "object") {
|
|
11849
|
+
warnings.push(`group[${idx}] \u4E0D\u662F\u5BF9\u8C61\uFF0C\u5DF2\u5FFD\u7565`);
|
|
11850
|
+
return;
|
|
11851
|
+
}
|
|
11852
|
+
const workflowName = String(item.workflowName ?? "").trim();
|
|
11853
|
+
const fieldsRaw = item.fields;
|
|
11854
|
+
const flowDetailPrompt = String(item.flowDetailPrompt ?? "").trim() || void 0;
|
|
11855
|
+
const requestLogPrompt = String(item.requestLogPrompt ?? "").trim() || void 0;
|
|
11856
|
+
if (!workflowName) {
|
|
11857
|
+
warnings.push(`group[${idx}] \u7F3A workflowName\uFF0C\u5DF2\u5FFD\u7565`);
|
|
11858
|
+
return;
|
|
11859
|
+
}
|
|
11860
|
+
if (!Array.isArray(fieldsRaw) || fieldsRaw.length === 0) {
|
|
11861
|
+
if (flowDetailPrompt || requestLogPrompt) {
|
|
11862
|
+
entries.push({ workflowName, fields: [], ...flowDetailPrompt ? { flowDetailPrompt } : {}, ...requestLogPrompt ? { requestLogPrompt } : {} });
|
|
11863
|
+
return;
|
|
11864
|
+
}
|
|
11865
|
+
warnings.push(`group[${idx}]\uFF08${workflowName}\uFF09\u7F3A fields \u6216\u4E3A\u7A7A\uFF0C\u5DF2\u5FFD\u7565`);
|
|
11866
|
+
return;
|
|
11867
|
+
}
|
|
11868
|
+
const fields = [];
|
|
11869
|
+
fieldsRaw.forEach((f, fIdx) => {
|
|
11870
|
+
if (!f || typeof f !== "object") {
|
|
11871
|
+
warnings.push(`group[${idx}].fields[${fIdx}] \u4E0D\u662F\u5BF9\u8C61\uFF0C\u5DF2\u5FFD\u7565`);
|
|
11872
|
+
return;
|
|
11873
|
+
}
|
|
11874
|
+
const rec = f;
|
|
11875
|
+
const field = String(rec.field ?? "").trim();
|
|
11876
|
+
const mode = String(rec.mode ?? "").trim().toLowerCase();
|
|
11877
|
+
if (!field) {
|
|
11878
|
+
warnings.push(`group[${idx}].fields[${fIdx}] \u7F3A field\uFF0C\u5DF2\u5FFD\u7565`);
|
|
11879
|
+
return;
|
|
11880
|
+
}
|
|
11881
|
+
if (mode === "rule") {
|
|
11882
|
+
const buckets = Array.isArray(rec.buckets) ? rec.buckets.map((b) => String(b).trim()).filter(Boolean) : [];
|
|
11883
|
+
if (buckets.length === 0) {
|
|
11884
|
+
warnings.push(`group[${idx}].fields[${fIdx}]\uFF08${field}\uFF09rule \u6A21\u5F0F\u7F3A buckets\uFF0C\u5DF2\u5FFD\u7565`);
|
|
11885
|
+
return;
|
|
11886
|
+
}
|
|
11887
|
+
fields.push({ field, mode: "rule", buckets });
|
|
11888
|
+
} else if (mode === "ai") {
|
|
11889
|
+
const categories = Array.isArray(rec.categories) ? rec.categories.map((c) => String(c).trim()).filter(Boolean) : [];
|
|
11890
|
+
const aiInput = String(rec.aiInput ?? "").trim() || "\u6D41\u7A0B\u6807\u9898";
|
|
11891
|
+
fields.push({
|
|
11892
|
+
field,
|
|
11893
|
+
mode: "ai",
|
|
11894
|
+
...categories.length > 0 ? { categories } : {},
|
|
11895
|
+
aiInput
|
|
11896
|
+
});
|
|
11897
|
+
} else {
|
|
11898
|
+
warnings.push(`group[${idx}].fields[${fIdx}]\uFF08${field}\uFF09mode \u53EA\u652F\u6301 rule/ai\uFF0C\u5F53\u524D ${mode}\uFF0C\u5DF2\u5FFD\u7565`);
|
|
11899
|
+
}
|
|
11900
|
+
});
|
|
11901
|
+
if (fields.length > 0 || flowDetailPrompt || requestLogPrompt) {
|
|
11902
|
+
entries.push({ workflowName, fields, ...flowDetailPrompt ? { flowDetailPrompt } : {}, ...requestLogPrompt ? { requestLogPrompt } : {} });
|
|
11903
|
+
} else {
|
|
11904
|
+
warnings.push(`group[${idx}]\uFF08${workflowName}\uFF09\u6CA1\u6709\u53EF\u7528\u5B57\u6BB5\uFF0C\u5DF2\u5FFD\u7565`);
|
|
11905
|
+
}
|
|
11906
|
+
});
|
|
11907
|
+
return { entries, warnings };
|
|
11908
|
+
}
|
|
11909
|
+
var DIMENSION_OTHER_KEY = "\u5176\u4ED6";
|
|
11910
|
+
function normalizeDataDimension(raw) {
|
|
11911
|
+
const warnings = [];
|
|
11912
|
+
const entries = [];
|
|
11913
|
+
if (raw === void 0 || raw === null) return { entries, warnings };
|
|
11914
|
+
let list = raw;
|
|
11915
|
+
if (!Array.isArray(list) && typeof list === "object") {
|
|
11916
|
+
const maybeEntries = list.entries;
|
|
11917
|
+
if (Array.isArray(maybeEntries)) {
|
|
11918
|
+
list = maybeEntries;
|
|
11919
|
+
} else {
|
|
11920
|
+
warnings.push("dataDimension \u4E0D\u662F\u6570\u7EC4\u4E14\u7F3A entries \u6570\u7EC4\uFF0C\u5DF2\u5FFD\u7565\uFF08HTML \u4E0D\u6E32\u67D3\u6570\u636E\u7EF4\u5EA6\u5206\u7C7B\uFF09");
|
|
11921
|
+
return { entries, warnings };
|
|
11922
|
+
}
|
|
11923
|
+
}
|
|
11924
|
+
if (!Array.isArray(list)) {
|
|
11925
|
+
warnings.push("dataDimension \u4E0D\u662F\u6570\u7EC4\uFF0C\u5DF2\u5FFD\u7565\uFF08HTML \u4E0D\u6E32\u67D3\u6570\u636E\u7EF4\u5EA6\u5206\u7C7B\uFF09");
|
|
11926
|
+
return { entries, warnings };
|
|
11927
|
+
}
|
|
11928
|
+
list.forEach((item, idx) => {
|
|
11929
|
+
if (!item || typeof item !== "object") {
|
|
11930
|
+
warnings.push(`dataDimension[${idx}] \u4E0D\u662F\u5BF9\u8C61\uFF0C\u5DF2\u5FFD\u7565`);
|
|
11931
|
+
return;
|
|
11932
|
+
}
|
|
11933
|
+
const key = String(item.key ?? "").trim();
|
|
11934
|
+
const rawList = item.isremark;
|
|
11935
|
+
if (!key) {
|
|
11936
|
+
warnings.push(`dataDimension[${idx}] \u7F3A key\uFF0C\u5DF2\u5FFD\u7565`);
|
|
11937
|
+
return;
|
|
11938
|
+
}
|
|
11939
|
+
if (!Array.isArray(rawList)) {
|
|
11940
|
+
warnings.push(`dataDimension[${idx}]\uFF08${key}\uFF09\u7F3A isremark \u6570\u7EC4\uFF0C\u5DF2\u5FFD\u7565`);
|
|
11941
|
+
return;
|
|
11942
|
+
}
|
|
11943
|
+
const isremark = rawList.map((v) => Number(v)).filter((n) => Number.isFinite(n));
|
|
11944
|
+
entries.push({ key, isremark });
|
|
11945
|
+
});
|
|
11946
|
+
return { entries, warnings };
|
|
11947
|
+
}
|
|
11948
|
+
function dimensionKeyOf(isremark, entries) {
|
|
11949
|
+
let n;
|
|
11950
|
+
if (typeof isremark === "number" && Number.isFinite(isremark)) {
|
|
11951
|
+
n = isremark;
|
|
11952
|
+
} else if (typeof isremark === "string" && isremark.trim() !== "" && Number.isFinite(Number(isremark.trim()))) {
|
|
11953
|
+
n = Number(isremark.trim());
|
|
11954
|
+
}
|
|
11955
|
+
if (n !== void 0) {
|
|
11956
|
+
const hit = entries.find((e) => e.isremark.includes(n));
|
|
11957
|
+
if (hit) return hit.key;
|
|
11958
|
+
}
|
|
11959
|
+
return DIMENSION_OTHER_KEY;
|
|
11960
|
+
}
|
|
11961
|
+
function promptEntriesOf(entries) {
|
|
11962
|
+
return entries.filter((e) => e.flowDetailPrompt || e.requestLogPrompt).map((e) => ({
|
|
11963
|
+
workflowName: e.workflowName,
|
|
11964
|
+
...e.flowDetailPrompt ? { flowDetailPrompt: e.flowDetailPrompt } : {},
|
|
11965
|
+
...e.requestLogPrompt ? { requestLogPrompt: e.requestLogPrompt } : {}
|
|
11966
|
+
}));
|
|
11967
|
+
}
|
|
11968
|
+
function promptMatch(a, b) {
|
|
11969
|
+
if (!a || !b) return false;
|
|
11970
|
+
return a.includes(b) || b.includes(a);
|
|
11971
|
+
}
|
|
11972
|
+
function resolvePromptsForBatch(promptEntries, workflowNames) {
|
|
11973
|
+
return promptEntries.filter((entry) => workflowNames.some((name) => promptMatch(entry.workflowName, name)));
|
|
11974
|
+
}
|
|
11975
|
+
var NUM = "-?\\d+(?:\\.\\d+)?";
|
|
11976
|
+
var NUM_RE = new RegExp(`^\\s*(${NUM})\\s*[-~\u81F3\u5230]\\s*(${NUM})\\s*$`);
|
|
11977
|
+
var LE_RE = new RegExp(`^\u5C0F\u4E8E\u7B49\u4E8E\\s*(${NUM})`);
|
|
11978
|
+
var LT_RE = new RegExp(`^\u5C0F\u4E8E(?!\u7B49\u4E8E)\\s*(${NUM})`);
|
|
11979
|
+
var GE_RE = new RegExp(`^\u5927\u4E8E\u7B49\u4E8E\\s*(${NUM})`);
|
|
11980
|
+
var GT_RE = new RegExp(`^\u5927\u4E8E(?!\u7B49\u4E8E)\\s*(${NUM})`);
|
|
11981
|
+
function parseBucketLabel(label) {
|
|
11982
|
+
const compact3 = label.replace(/(个小时|小时|天|日|个月|月|周|年|元|块|条|个|人|份|次|单|%|¥|¥)/g, "");
|
|
11983
|
+
let m = compact3.match(LE_RE);
|
|
11984
|
+
if (m) return { label, kind: "le", a: Number(m[1]) };
|
|
11985
|
+
m = compact3.match(GE_RE);
|
|
11986
|
+
if (m) return { label, kind: "ge", a: Number(m[1]) };
|
|
11987
|
+
m = compact3.match(LT_RE);
|
|
11988
|
+
if (m) return { label, kind: "lt", a: Number(m[1]) };
|
|
11989
|
+
m = compact3.match(GT_RE);
|
|
11990
|
+
if (m) return { label, kind: "gt", a: Number(m[1]) };
|
|
11991
|
+
m = compact3.match(NUM_RE);
|
|
11992
|
+
if (m) {
|
|
11993
|
+
const a = Number(m[1]);
|
|
11994
|
+
const b = Number(m[2]);
|
|
11995
|
+
if (b >= a) return { label, kind: "range", a, b };
|
|
11996
|
+
}
|
|
11997
|
+
return null;
|
|
11998
|
+
}
|
|
11999
|
+
function extractNumber(value) {
|
|
12000
|
+
const m = value.match(new RegExp(NUM));
|
|
12001
|
+
if (!m) return null;
|
|
12002
|
+
const n = Number(m[0]);
|
|
12003
|
+
return Number.isFinite(n) ? n : null;
|
|
12004
|
+
}
|
|
12005
|
+
var FALLBACK_BUCKET = "\u5176\u4ED6";
|
|
12006
|
+
function assignRuleBucket(value, matchers) {
|
|
12007
|
+
const num = extractNumber(value);
|
|
12008
|
+
if (num === null) return FALLBACK_BUCKET;
|
|
12009
|
+
for (const matcher of matchers) {
|
|
12010
|
+
if (matcher.kind === "le" && num <= matcher.a) return matcher.label;
|
|
12011
|
+
if (matcher.kind === "lt" && num < matcher.a) return matcher.label;
|
|
12012
|
+
if (matcher.kind === "ge" && num >= matcher.a) return matcher.label;
|
|
12013
|
+
if (matcher.kind === "gt" && num > matcher.a) return matcher.label;
|
|
12014
|
+
if (matcher.kind === "range" && num > matcher.a && num <= matcher.b) return matcher.label;
|
|
12015
|
+
}
|
|
12016
|
+
return FALLBACK_BUCKET;
|
|
12017
|
+
}
|
|
12018
|
+
function aiInputValueOf(aiInput, detail, row) {
|
|
12019
|
+
const title = String(detail?.basicInfo?.requestTitle ?? row?.requestNameTitle ?? "").trim();
|
|
12020
|
+
void aiInput;
|
|
12021
|
+
return title;
|
|
12022
|
+
}
|
|
12023
|
+
function buildGrouping(workflowName, groupEntries, rows, detailsPayload, warnings) {
|
|
12024
|
+
const rowByRequestId = /* @__PURE__ */ new Map();
|
|
12025
|
+
for (const row of rows) {
|
|
12026
|
+
if (row?.requestId) rowByRequestId.set(String(row.requestId), row);
|
|
12027
|
+
}
|
|
12028
|
+
const nameOf = (requestId, detail) => {
|
|
12029
|
+
return String(detail?.basicInfo?.workflowName ?? "").trim() || String(rowByRequestId.get(requestId)?.workflowName ?? "").trim() || workflowName;
|
|
12030
|
+
};
|
|
12031
|
+
const matchedKeys = [];
|
|
12032
|
+
const matchedFields = [];
|
|
12033
|
+
const findRuleField = (field) => matchedFields.find((f) => f.mode === "rule" && f.field === field);
|
|
12034
|
+
const findAiField = (field) => matchedFields.find((f) => f.mode === "ai" && f.field === field);
|
|
12035
|
+
for (const entry of groupEntries) {
|
|
12036
|
+
const key = entry.workflowName?.trim();
|
|
12037
|
+
if (!key) continue;
|
|
12038
|
+
const entryDetails = detailsPayload.filter(({ requestId, detail }) => {
|
|
12039
|
+
const name = nameOf(requestId, detail);
|
|
12040
|
+
return Boolean(name) && (name.includes(key) || key.includes(name));
|
|
12041
|
+
});
|
|
12042
|
+
if (entryDetails.length === 0) continue;
|
|
12043
|
+
matchedKeys.push(key);
|
|
12044
|
+
for (const groupField of entry.fields) {
|
|
12045
|
+
if (groupField.mode === "rule") {
|
|
12046
|
+
const matchers = [];
|
|
12047
|
+
const bucketLabels = [];
|
|
12048
|
+
for (const label of groupField.buckets ?? []) {
|
|
12049
|
+
const matcher = parseBucketLabel(label);
|
|
12050
|
+
if (matcher) {
|
|
12051
|
+
matchers.push(matcher);
|
|
12052
|
+
bucketLabels.push(label);
|
|
12053
|
+
} else {
|
|
12054
|
+
warnings.push(`\u4E8C\u6B21\u6761\u4EF6\u89C4\u5219\uFF1A\u5B57\u6BB5\u300C${groupField.field}\u300D\u6876\u6807\u7B7E\u300C${label}\u300D\u89E3\u6790\u5931\u8D25\uFF0C\u5DF2\u5FFD\u7565\uFF08\u5B81\u53EF\u6F0F\u914D\u4E0D\u8BEF\u914D\uFF09`);
|
|
12055
|
+
}
|
|
12056
|
+
}
|
|
12057
|
+
const assignment = [];
|
|
12058
|
+
const counts = {};
|
|
12059
|
+
for (const { requestId, detail } of entryDetails) {
|
|
12060
|
+
const fieldMeta = Array.isArray(detail?.formData?.fields) ? detail.formData.fields.find(
|
|
12061
|
+
(f) => String(f?.fieldName ?? "").trim() === groupField.field
|
|
12062
|
+
) : void 0;
|
|
12063
|
+
const value = String(fieldMeta?.value ?? "").trim();
|
|
12064
|
+
const bucket = assignRuleBucket(value, matchers);
|
|
12065
|
+
assignment.push({ requestId, value, bucket });
|
|
12066
|
+
counts[bucket] = (counts[bucket] ?? 0) + 1;
|
|
12067
|
+
}
|
|
12068
|
+
const existing = findRuleField(groupField.field);
|
|
12069
|
+
if (existing) {
|
|
12070
|
+
existing.assignment.push(...assignment);
|
|
12071
|
+
for (const [bucket, n] of Object.entries(counts)) {
|
|
12072
|
+
existing.counts[bucket] = (existing.counts[bucket] ?? 0) + n;
|
|
12073
|
+
}
|
|
12074
|
+
for (const label of [...bucketLabels, FALLBACK_BUCKET]) {
|
|
12075
|
+
if ((existing.counts[label] ?? 0) > 0 && !existing.buckets.includes(label)) existing.buckets.push(label);
|
|
12076
|
+
}
|
|
12077
|
+
continue;
|
|
12078
|
+
}
|
|
12079
|
+
const buckets = counts[FALLBACK_BUCKET] ? [...bucketLabels, FALLBACK_BUCKET] : bucketLabels;
|
|
12080
|
+
matchedFields.push({ field: groupField.field, mode: "rule", buckets, assignment, counts });
|
|
12081
|
+
} else {
|
|
12082
|
+
const inputs = entryDetails.map(({ requestId, detail }) => ({
|
|
12083
|
+
requestId,
|
|
12084
|
+
value: aiInputValueOf(groupField.aiInput ?? "\u6D41\u7A0B\u6807\u9898", detail, rowByRequestId.get(requestId))
|
|
12085
|
+
}));
|
|
12086
|
+
const existing = findAiField(groupField.field);
|
|
12087
|
+
if (existing) {
|
|
12088
|
+
existing.inputs.push(...inputs);
|
|
12089
|
+
for (const category of groupField.categories ?? []) {
|
|
12090
|
+
if (!existing.categories.includes(category)) existing.categories.push(category);
|
|
12091
|
+
}
|
|
12092
|
+
continue;
|
|
12093
|
+
}
|
|
12094
|
+
matchedFields.push({
|
|
12095
|
+
field: groupField.field,
|
|
12096
|
+
mode: "ai",
|
|
12097
|
+
categories: groupField.categories ?? [],
|
|
12098
|
+
aiInput: groupField.aiInput ?? "\u6D41\u7A0B\u6807\u9898",
|
|
12099
|
+
inputs
|
|
12100
|
+
});
|
|
12101
|
+
}
|
|
12102
|
+
}
|
|
12103
|
+
}
|
|
12104
|
+
if (matchedKeys.length === 0) {
|
|
12105
|
+
return { matched: false, fields: [] };
|
|
12106
|
+
}
|
|
12107
|
+
return { matched: true, matchedKey: matchedKeys[0], matchedKeys, fields: matchedFields };
|
|
12108
|
+
}
|
|
12109
|
+
function stopReasonOf(error) {
|
|
12110
|
+
const structured = error;
|
|
12111
|
+
if (structured?.type === "network") {
|
|
12112
|
+
return structured.subtype === "timeout" ? "http_timeout" : "network_error";
|
|
12113
|
+
}
|
|
12114
|
+
if (structured?.type === "authentication") return "login_expired";
|
|
12115
|
+
if (structured?.type === "api") return "api_error";
|
|
12116
|
+
return "unknown_error";
|
|
12117
|
+
}
|
|
12118
|
+
function isRetryable(error) {
|
|
12119
|
+
const structured = error;
|
|
12120
|
+
if (structured?.type === "network") return true;
|
|
12121
|
+
return structured?.retryable === true && structured?.type !== "authentication";
|
|
12122
|
+
}
|
|
12123
|
+
function rowsOf(response) {
|
|
12124
|
+
const priorityFields = priorityRuleFields();
|
|
12125
|
+
return projectDisplayRows(response, priorityFields).map((row) => rowFromAny(row, priorityFields)).filter((row) => row !== void 0);
|
|
12126
|
+
}
|
|
12127
|
+
function matchGuard(mode, target, rows, total) {
|
|
12128
|
+
const warnings = [];
|
|
12129
|
+
if (mode === "byTodo") {
|
|
12130
|
+
const idSet = new Set((target.workflowIds ?? []).map((v) => String(v).trim()).filter(Boolean));
|
|
12131
|
+
const outside = rows.filter((row) => row.workflowId && idSet.size > 0 && !idSet.has(String(row.workflowId)));
|
|
12132
|
+
const ignored = idSet.size > 0 && outside.length > 0;
|
|
12133
|
+
if (ignored) {
|
|
12134
|
+
warnings.push(
|
|
12135
|
+
`\u5217\u8868\u8FD4\u56DE ${rows.length} \u884C\u4E2D\u6709 ${outside.length} \u884C\u7684 workflowId \u4E0D\u5728\u914D\u7F6E\u96C6\u5408\u5185\uFF1Aparams.workflowids \u5B57\u9762\u952E\u53EF\u80FD\u88AB\u670D\u52A1\u7AEF\u9759\u9ED8\u5FFD\u7565\uFF08\u8FD4\u56DE\u4E86\u5168\u91CF\u5F85\u529E\uFF09\u3002\u8BF7\u6838\u5BF9\u53D6\u6570\u7ED3\u679C\u518D\u7EE7\u7EED\u3002`
|
|
12136
|
+
);
|
|
12137
|
+
}
|
|
12138
|
+
return {
|
|
12139
|
+
matchedRows: rows,
|
|
12140
|
+
guard: {
|
|
12141
|
+
key: "params.workflowids",
|
|
12142
|
+
configured: [...idSet],
|
|
12143
|
+
rowsSeen: rows.length,
|
|
12144
|
+
outsideWorkflowRows: outside.length,
|
|
12145
|
+
ignored
|
|
12146
|
+
},
|
|
12147
|
+
warnings
|
|
12148
|
+
};
|
|
12149
|
+
}
|
|
12150
|
+
if (mode === "byRequest") {
|
|
12151
|
+
const targetId = String(target.requestId ?? "");
|
|
12152
|
+
const matchedRows = rows.filter((row) => String(row.requestId ?? "") === targetId);
|
|
12153
|
+
const ignored = matchedRows.length === 0 && rows.length > 0;
|
|
12154
|
+
if (ignored) {
|
|
12155
|
+
warnings.push(
|
|
12156
|
+
`\u5217\u8868\u63A5\u53E3\u8FD4\u56DE\u4E86 ${rows.length} \u884C\u4F46\u6CA1\u6709\u4E00\u884C\u547D\u4E2D requestId=${targetId}\uFF1Aparams.requestId \u5B57\u9762\u952E\u53EF\u80FD\u88AB\u670D\u52A1\u7AEF\u9759\u9ED8\u5FFD\u7565\uFF08\u8FD4\u56DE\u4E86\u5168\u91CF\u5F85\u529E\uFF09\u3002\u8BF7\u6838\u5BF9\u53D6\u6570\u7ED3\u679C\u518D\u7EE7\u7EED\uFF0C\u5FC5\u8981\u65F6\u6539\u7528\u5DF2\u9A8C\u8BC1\u7684 params.requestIds \u5951\u7EA6\u3002`
|
|
12157
|
+
);
|
|
12158
|
+
}
|
|
12159
|
+
return {
|
|
12160
|
+
matchedRows,
|
|
12161
|
+
guard: { key: "params.requestId", targetId, rowsSeen: rows.length, matched: matchedRows.length, ignored },
|
|
12162
|
+
warnings
|
|
12163
|
+
};
|
|
12164
|
+
}
|
|
12165
|
+
const guard = { key: "params.workflowId", targetId: String(target.workflowId ?? ""), rowsSeen: rows.length, total };
|
|
12166
|
+
if (total !== null && rows.length > 0 && total > rows.length * 10) {
|
|
12167
|
+
warnings.push(
|
|
12168
|
+
`\u8BE5\u8303\u56F4 total=${total} \u8FDC\u5927\u4E8E\u672C\u6B21\u53D6\u6570\u6761\u6570\uFF1A\u82E5\u660E\u7EC6\u4E0E\u76EE\u6807\u5DE5\u4F5C\u6D41\u660E\u663E\u4E0D\u7B26\uFF0C\u8BF7\u6838\u5BF9 params.workflowId \u5B57\u9762\u952E\u662F\u5426\u88AB\u670D\u52A1\u7AEF\u63A5\u53D7\u3002`
|
|
12169
|
+
);
|
|
12170
|
+
}
|
|
12171
|
+
return { matchedRows: rows, guard, warnings };
|
|
12172
|
+
}
|
|
12173
|
+
var ORIGIN_LIST_FIELDS = [
|
|
12174
|
+
"requestId",
|
|
12175
|
+
"workflowId",
|
|
12176
|
+
"cid",
|
|
12177
|
+
"nodeid",
|
|
12178
|
+
"userid",
|
|
12179
|
+
"receivedatetime",
|
|
12180
|
+
"userMasterId",
|
|
12181
|
+
"rowKey",
|
|
12182
|
+
"flowstatus",
|
|
12183
|
+
"isremark",
|
|
12184
|
+
"viewdatetime",
|
|
12185
|
+
"lastCommonDateTime",
|
|
12186
|
+
"lastfeedbackoperator",
|
|
12187
|
+
"creatorMasterId",
|
|
12188
|
+
"nodetype",
|
|
12189
|
+
"creater",
|
|
12190
|
+
"datasrc",
|
|
12191
|
+
"module",
|
|
12192
|
+
"sysCode",
|
|
12193
|
+
"readMark"
|
|
12194
|
+
];
|
|
12195
|
+
function displayFieldOf(row, name) {
|
|
12196
|
+
if (name in row) return row[name];
|
|
12197
|
+
const lower = name.toLowerCase();
|
|
12198
|
+
for (const [k, v] of Object.entries(row)) {
|
|
12199
|
+
if (k.toLowerCase() === lower) return v;
|
|
12200
|
+
}
|
|
12201
|
+
return void 0;
|
|
12202
|
+
}
|
|
12203
|
+
function rawDisplayRowsOf(response) {
|
|
12204
|
+
const record = responseData(response);
|
|
12205
|
+
const raw = record?.data?.displayData ?? record?.displayData ?? [];
|
|
12206
|
+
return Array.isArray(raw) ? raw.filter((r) => r !== null && typeof r === "object" && !Array.isArray(r)) : [];
|
|
12207
|
+
}
|
|
12208
|
+
function localRowFilterReason(raw) {
|
|
12209
|
+
const rejectVal = displayFieldOf(raw, "isbereject");
|
|
12210
|
+
if (rejectVal !== void 0 && rejectVal !== null && String(rejectVal).trim() !== "" && Number(rejectVal) === 1) {
|
|
12211
|
+
return "reject";
|
|
12212
|
+
}
|
|
12213
|
+
const statusVal = displayFieldOf(raw, "flowstatus");
|
|
12214
|
+
if (statusVal !== void 0 && statusVal !== null && String(statusVal).trim() !== "" && Number(statusVal) === 0) {
|
|
12215
|
+
return "draft";
|
|
12216
|
+
}
|
|
12217
|
+
return null;
|
|
12218
|
+
}
|
|
12219
|
+
function buildOriginListData(raw) {
|
|
12220
|
+
const out = {};
|
|
12221
|
+
for (const field of ORIGIN_LIST_FIELDS) {
|
|
12222
|
+
const value = displayFieldOf(raw, field);
|
|
12223
|
+
if (value !== void 0 && value !== null) out[field] = value;
|
|
12224
|
+
}
|
|
12225
|
+
return out;
|
|
12226
|
+
}
|
|
12227
|
+
function parseAugmentCanCheck(response) {
|
|
12228
|
+
const map = /* @__PURE__ */ new Map();
|
|
12229
|
+
if (!response || typeof response !== "object") return map;
|
|
12230
|
+
const record = responseData(response);
|
|
12231
|
+
const list = record?.augmentRes ?? record?.data?.augmentRes;
|
|
12232
|
+
if (!Array.isArray(list)) return map;
|
|
12233
|
+
for (const item of list) {
|
|
12234
|
+
const requestId = String(item?.requestid ?? item?.requestId ?? "").trim();
|
|
12235
|
+
if (!requestId) continue;
|
|
12236
|
+
const canCheck = item?.checkBatchOptRes?.canCheck;
|
|
12237
|
+
if (typeof canCheck === "boolean") map.set(requestId, canCheck);
|
|
12238
|
+
}
|
|
12239
|
+
return map;
|
|
12240
|
+
}
|
|
12241
|
+
async function filterRowsByCanCheck(env, rows, rawByRequestId) {
|
|
12242
|
+
const stats = {
|
|
12243
|
+
augmentChecked: 0,
|
|
12244
|
+
droppedCanCheck: 0,
|
|
12245
|
+
augmentMissing: 0,
|
|
12246
|
+
augmentRequests: 0,
|
|
12247
|
+
error: void 0
|
|
12248
|
+
};
|
|
12249
|
+
const warnings = [];
|
|
12250
|
+
const participants = [];
|
|
12251
|
+
const passThrough = [];
|
|
12252
|
+
for (const row of rows) {
|
|
12253
|
+
const raw = rawByRequestId.get(String(row.requestId));
|
|
12254
|
+
if (!raw) {
|
|
12255
|
+
passThrough.push(row);
|
|
12256
|
+
warnings.push(`\u884C ${row.requestId} \u7F3A\u5C11\u539F\u59CB displayData \u6570\u636E\uFF0C\u8DF3\u8FC7 canCheck \u6821\u9A8C\uFF08\u6309\u4FDD\u7559\u5904\u7406\uFF09`);
|
|
12257
|
+
continue;
|
|
12258
|
+
}
|
|
12259
|
+
participants.push({ row, origin: buildOriginListData(raw) });
|
|
12260
|
+
}
|
|
12261
|
+
if (participants.length === 0) {
|
|
12262
|
+
return { kept: passThrough, stats, warnings };
|
|
12263
|
+
}
|
|
12264
|
+
const body = {
|
|
12265
|
+
originListDatas: participants.map((p) => p.origin),
|
|
12266
|
+
batchOptType: "batchSubmit",
|
|
12267
|
+
dimension: "todo"
|
|
12268
|
+
};
|
|
12269
|
+
let response;
|
|
12270
|
+
try {
|
|
12271
|
+
response = await env.host.workflowRequest({
|
|
12272
|
+
method: "POST",
|
|
12273
|
+
path: WORKFLOW_ENDPOINTS.LIST_AUGMENT_BASE,
|
|
12274
|
+
operation: "workflow.aiDeepRead.listAugment",
|
|
12275
|
+
body
|
|
12276
|
+
});
|
|
12277
|
+
stats.augmentRequests = 1;
|
|
12278
|
+
} catch (error) {
|
|
12279
|
+
stats.error = stopReasonOf(error);
|
|
12280
|
+
warnings.push(
|
|
12281
|
+
`getListBaseAugment \u8C03\u7528\u5931\u8D25\uFF08${stats.error}\uFF09\uFF1A\u672C\u9875 ${participants.length} \u884C\u6309\u4FDD\u7559\u5904\u7406\uFF08\u5B81\u53EF\u4FDD\u7559\u4E0D\u8BEF\u5220\uFF09`
|
|
12282
|
+
);
|
|
12283
|
+
return { kept: [...passThrough, ...participants.map((p) => p.row)], stats, warnings };
|
|
12284
|
+
}
|
|
12285
|
+
if (process.env.WEAVER_WORK_CLI_DUMP_DEEPREAD_DETAIL) {
|
|
12286
|
+
try {
|
|
12287
|
+
writeFileSync(
|
|
12288
|
+
join3(tmpdir2(), "weaver-deepread-augment.json"),
|
|
12289
|
+
JSON.stringify({ body, response }, null, 2),
|
|
12290
|
+
"utf-8"
|
|
12291
|
+
);
|
|
12292
|
+
} catch {
|
|
12293
|
+
}
|
|
12294
|
+
}
|
|
12295
|
+
const canCheckByRequestId = parseAugmentCanCheck(response);
|
|
12296
|
+
const kept = [...passThrough];
|
|
12297
|
+
for (const { row } of participants) {
|
|
12298
|
+
stats.augmentChecked += 1;
|
|
12299
|
+
const requestId = String(row.requestId);
|
|
12300
|
+
if (!canCheckByRequestId.has(requestId)) {
|
|
12301
|
+
stats.augmentMissing += 1;
|
|
12302
|
+
kept.push(row);
|
|
12303
|
+
continue;
|
|
12304
|
+
}
|
|
12305
|
+
if (canCheckByRequestId.get(requestId) === false) {
|
|
12306
|
+
stats.droppedCanCheck += 1;
|
|
12307
|
+
continue;
|
|
12308
|
+
}
|
|
12309
|
+
kept.push(row);
|
|
12310
|
+
}
|
|
12311
|
+
return { kept, stats, warnings };
|
|
12312
|
+
}
|
|
12313
|
+
async function fetchOneRawDetail(env, requestId, userId) {
|
|
12314
|
+
const body = {
|
|
12315
|
+
requestId,
|
|
12316
|
+
isGetRequestBaseInfo: true,
|
|
12317
|
+
// ★ 2026-11-18 用户定稿:签字意见不从本接口获取(改走 getRequestLog 专用接口)。
|
|
12318
|
+
// 附带收益:不再拉 workflowRequestLogs 巨量噪音,响应小、耗时短(实测 43MB/29s → 预期显著下降)。
|
|
12319
|
+
isGetRequestLog: false,
|
|
12320
|
+
isGetFormData: true,
|
|
12321
|
+
// ★ 不得把待办标已读
|
|
12322
|
+
isReadRequest: false
|
|
12323
|
+
};
|
|
12324
|
+
if (userId) body.userId = userId;
|
|
12325
|
+
const dumpFile = process.env.WEAVER_WORK_CLI_DUMP_DEEPREAD_DETAIL ? join3(tmpdir2(), `weaver-deepread-detail-${requestId}.json`) : null;
|
|
12326
|
+
let response;
|
|
12327
|
+
try {
|
|
12328
|
+
response = await env.host.workflowRequest({
|
|
12329
|
+
method: "POST",
|
|
12330
|
+
path: WORKFLOW_ENDPOINTS.REQUEST_DETAIL,
|
|
12331
|
+
operation: "workflow.aiDeepRead.detail",
|
|
12332
|
+
body,
|
|
12333
|
+
timeoutMs: DETAIL_TIMEOUT_MS
|
|
12334
|
+
});
|
|
12335
|
+
} finally {
|
|
12336
|
+
if (dumpFile) {
|
|
12337
|
+
try {
|
|
12338
|
+
writeFileSync(dumpFile, JSON.stringify({ path: WORKFLOW_ENDPOINTS.REQUEST_DETAIL, body, response }, null, 2), "utf-8");
|
|
12339
|
+
} catch {
|
|
12340
|
+
}
|
|
12341
|
+
}
|
|
12342
|
+
}
|
|
12343
|
+
return normalizeDetailResponse(response);
|
|
12344
|
+
}
|
|
12345
|
+
function formatMillis(value, withSeconds = true) {
|
|
12346
|
+
const n = typeof value === "number" ? value : Number.parseInt(String(value ?? "").trim(), 10);
|
|
12347
|
+
if (!Number.isFinite(n) || n <= 0) return void 0;
|
|
12348
|
+
const d = new Date(n);
|
|
12349
|
+
if (Number.isNaN(d.getTime())) return void 0;
|
|
12350
|
+
const pad = (x) => String(x).padStart(2, "0");
|
|
12351
|
+
const base = `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())} ${pad(d.getHours())}:${pad(d.getMinutes())}`;
|
|
12352
|
+
return withSeconds ? `${base}:${pad(d.getSeconds())}` : base;
|
|
12353
|
+
}
|
|
12354
|
+
function resolveLogPath(item, path) {
|
|
12355
|
+
let cur = item;
|
|
12356
|
+
for (const seg of path.split(".")) {
|
|
12357
|
+
if (cur === null || cur === void 0 || typeof cur !== "object") return void 0;
|
|
12358
|
+
if (Array.isArray(cur)) {
|
|
12359
|
+
if (seg === "size") return cur.length;
|
|
12360
|
+
cur = cur.map((el) => el && typeof el === "object" ? el[seg] : void 0).filter((v) => v !== void 0);
|
|
12361
|
+
continue;
|
|
12362
|
+
}
|
|
12363
|
+
cur = cur[seg];
|
|
12364
|
+
}
|
|
12365
|
+
return cur;
|
|
12366
|
+
}
|
|
12367
|
+
function looseKey(text) {
|
|
12368
|
+
return String(text ?? "").replace(/[^\p{L}\p{N}]/gu, "");
|
|
12369
|
+
}
|
|
12370
|
+
function parseLogRule(raw) {
|
|
12371
|
+
const containsIdx = raw.indexOf(" \u4E0D\u5305\u542B ");
|
|
12372
|
+
if (containsIdx > 0) {
|
|
12373
|
+
const path = raw.slice(0, containsIdx).trim();
|
|
12374
|
+
const keywords = raw.slice(containsIdx + 5).split(",").map((k) => k.trim()).filter(Boolean);
|
|
12375
|
+
if (path && keywords.length) return { kind: "notContains", path, keywords };
|
|
12376
|
+
return { kind: "unknown", raw };
|
|
12377
|
+
}
|
|
12378
|
+
const equalsIdx = raw.indexOf(" \u4E0D\u7B49\u4E8E ");
|
|
12379
|
+
if (equalsIdx > 0) {
|
|
12380
|
+
const path = raw.slice(0, equalsIdx).trim();
|
|
12381
|
+
const template = raw.slice(equalsIdx + 5).trim();
|
|
12382
|
+
if (path && template) return { kind: "notEquals", path, template };
|
|
12383
|
+
return { kind: "unknown", raw };
|
|
12384
|
+
}
|
|
12385
|
+
return { kind: "unknown", raw };
|
|
12386
|
+
}
|
|
12387
|
+
function renderTemplate(template, item, withSeconds) {
|
|
12388
|
+
return template.replace(/\$\{([^}]+)\}/g, (_m, exprRaw) => {
|
|
12389
|
+
const expr = String(exprRaw).trim();
|
|
12390
|
+
const colonIdx = expr.indexOf(":");
|
|
12391
|
+
const path = colonIdx >= 0 ? expr.slice(0, colonIdx).trim() : expr;
|
|
12392
|
+
const fmt = colonIdx >= 0 ? expr.slice(colonIdx + 1).trim() : "";
|
|
12393
|
+
const value = resolveLogPath(item, path);
|
|
12394
|
+
if (fmt) return formatMillis(value, withSeconds) ?? String(value ?? "");
|
|
12395
|
+
if (path === "addTime") return formatMillis(value, withSeconds) ?? String(value ?? "");
|
|
12396
|
+
return String(value ?? "");
|
|
12397
|
+
});
|
|
12398
|
+
}
|
|
12399
|
+
var TEMPLATE_PLACEHOLDER_RE = /\$\{([^}]+)\}/g;
|
|
12400
|
+
function isTimePlaceholderExpr(expr) {
|
|
12401
|
+
const colonIdx = expr.indexOf(":");
|
|
12402
|
+
if (colonIdx < 0) return false;
|
|
12403
|
+
return /[HMS]/.test(expr.slice(colonIdx + 1).toUpperCase());
|
|
12404
|
+
}
|
|
12405
|
+
function renderPrefixBeforeTime(template, item) {
|
|
12406
|
+
const re = new RegExp(TEMPLATE_PLACEHOLDER_RE.source, "g");
|
|
12407
|
+
let out = "";
|
|
12408
|
+
let lastIdx = 0;
|
|
12409
|
+
let m;
|
|
12410
|
+
while ((m = re.exec(template)) !== null) {
|
|
12411
|
+
const expr = m[1].trim();
|
|
12412
|
+
if (isTimePlaceholderExpr(expr)) {
|
|
12413
|
+
out += template.slice(lastIdx, m.index);
|
|
12414
|
+
return out;
|
|
12415
|
+
}
|
|
12416
|
+
out += template.slice(lastIdx, m.index) + String(resolveLogPath(item, expr) ?? "");
|
|
12417
|
+
lastIdx = re.lastIndex;
|
|
12418
|
+
}
|
|
12419
|
+
return null;
|
|
12420
|
+
}
|
|
12421
|
+
function isMinutePrecisionTimeShape(digitsOnly) {
|
|
12422
|
+
const m = /^(?:(\d{8}))?(\d{4})(\d{2})?$/.exec(digitsOnly);
|
|
12423
|
+
if (!m) return false;
|
|
12424
|
+
const hh = Number.parseInt(m[2].slice(0, 2), 10);
|
|
12425
|
+
const mi = Number.parseInt(m[2].slice(2), 10);
|
|
12426
|
+
if (hh > 23 || mi > 59) return false;
|
|
12427
|
+
if (m[3] !== void 0 && Number.parseInt(m[3], 10) > 59) return false;
|
|
12428
|
+
return true;
|
|
12429
|
+
}
|
|
12430
|
+
function hitDropRule(item, rules) {
|
|
12431
|
+
for (const rule of rules) {
|
|
12432
|
+
if (rule.kind === "notContains") {
|
|
12433
|
+
const value = String(resolveLogPath(item, rule.path) ?? "");
|
|
12434
|
+
if (rule.keywords.some((kw) => value.toLowerCase().includes(kw.toLowerCase()))) return true;
|
|
12435
|
+
} else if (rule.kind === "notEquals") {
|
|
12436
|
+
const value = looseKey(resolveLogPath(item, rule.path));
|
|
12437
|
+
if (!value) continue;
|
|
12438
|
+
if (renderPrefixBeforeTime(rule.template, item) !== null) {
|
|
12439
|
+
const prefix = looseKey(renderPrefixBeforeTime(rule.template, item));
|
|
12440
|
+
if (prefix && value.startsWith(prefix) && isMinutePrecisionTimeShape(value.slice(prefix.length).replace(/\D/g, ""))) {
|
|
12441
|
+
return true;
|
|
12442
|
+
}
|
|
12443
|
+
} else {
|
|
12444
|
+
const full = looseKey(renderTemplate(rule.template, item, true));
|
|
12445
|
+
const minute = looseKey(renderTemplate(rule.template, item, false));
|
|
12446
|
+
if (value === full || value === minute) return true;
|
|
12447
|
+
}
|
|
12448
|
+
}
|
|
12449
|
+
}
|
|
12450
|
+
return false;
|
|
12451
|
+
}
|
|
12452
|
+
var KEEP_LOGIN_USER_EXPR = "\u5F53\u524D\u767B\u5F55\u4EBA";
|
|
12453
|
+
var KEEP_OP_MAP = {
|
|
12454
|
+
"\u5305\u542B": "contains",
|
|
12455
|
+
"\u4E0D\u5305\u542B": "notContains",
|
|
12456
|
+
"<=": "le",
|
|
12457
|
+
"=<": "le",
|
|
12458
|
+
">=": "ge",
|
|
12459
|
+
"=>": "ge",
|
|
12460
|
+
"<": "lt",
|
|
12461
|
+
">": "gt",
|
|
12462
|
+
"=": "eq",
|
|
12463
|
+
"==": "eq"
|
|
12464
|
+
};
|
|
12465
|
+
function tokenizeKeep(raw) {
|
|
12466
|
+
const tokens = [];
|
|
12467
|
+
let buf = "";
|
|
12468
|
+
const flush = () => {
|
|
12469
|
+
if (buf.trim()) tokens.push(buf.trim());
|
|
12470
|
+
buf = "";
|
|
12471
|
+
};
|
|
12472
|
+
for (const ch of raw) {
|
|
12473
|
+
if (ch === "(" || ch === ")") {
|
|
12474
|
+
flush();
|
|
12475
|
+
tokens.push(ch);
|
|
12476
|
+
} else if (/\s/.test(ch)) {
|
|
12477
|
+
flush();
|
|
12478
|
+
} else {
|
|
12479
|
+
buf += ch;
|
|
12480
|
+
}
|
|
12481
|
+
}
|
|
12482
|
+
flush();
|
|
12483
|
+
return tokens.length ? tokens : null;
|
|
12484
|
+
}
|
|
12485
|
+
function parseKeepOr(tokens, pos) {
|
|
12486
|
+
let left = parseKeepAnd(tokens, pos);
|
|
12487
|
+
if (!left) return null;
|
|
12488
|
+
while (pos.i < tokens.length && tokens[pos.i].toLowerCase() === "or") {
|
|
12489
|
+
pos.i += 1;
|
|
12490
|
+
const right = parseKeepAnd(tokens, pos);
|
|
12491
|
+
if (!right) return null;
|
|
12492
|
+
left = { kind: "or", left, right };
|
|
12493
|
+
}
|
|
12494
|
+
return left;
|
|
12495
|
+
}
|
|
12496
|
+
function parseKeepAnd(tokens, pos) {
|
|
12497
|
+
let left = parseKeepAtom(tokens, pos);
|
|
12498
|
+
if (!left) return null;
|
|
12499
|
+
while (pos.i < tokens.length && tokens[pos.i].toLowerCase() === "and") {
|
|
12500
|
+
pos.i += 1;
|
|
12501
|
+
const right = parseKeepAtom(tokens, pos);
|
|
12502
|
+
if (!right) return null;
|
|
12503
|
+
left = { kind: "and", left, right };
|
|
12504
|
+
}
|
|
12505
|
+
return left;
|
|
12506
|
+
}
|
|
12507
|
+
function parseKeepAtom(tokens, pos) {
|
|
12508
|
+
if (pos.i >= tokens.length) return null;
|
|
12509
|
+
if (tokens[pos.i] === "(") {
|
|
12510
|
+
pos.i += 1;
|
|
12511
|
+
const inner = parseKeepOr(tokens, pos);
|
|
12512
|
+
if (!inner || pos.i >= tokens.length || tokens[pos.i] !== ")") return null;
|
|
12513
|
+
pos.i += 1;
|
|
12514
|
+
return inner;
|
|
12515
|
+
}
|
|
12516
|
+
const path = tokens[pos.i];
|
|
12517
|
+
const opTok = tokens[pos.i + 1];
|
|
12518
|
+
const value = tokens[pos.i + 2];
|
|
12519
|
+
if (!path || !opTok || value === void 0 || value === "(" || value === ")") return null;
|
|
12520
|
+
const op = KEEP_OP_MAP[opTok];
|
|
12521
|
+
if (!op) return null;
|
|
12522
|
+
pos.i += 3;
|
|
12523
|
+
return { kind: "cond", path, op, value };
|
|
12524
|
+
}
|
|
12525
|
+
function parseKeepExpression(raw) {
|
|
12526
|
+
const tokens = tokenizeKeep(raw);
|
|
12527
|
+
if (!tokens) return null;
|
|
12528
|
+
const pos = { i: 0 };
|
|
12529
|
+
const root = parseKeepOr(tokens, pos);
|
|
12530
|
+
if (!root || pos.i !== tokens.length) return null;
|
|
12531
|
+
return root;
|
|
12532
|
+
}
|
|
12533
|
+
function renderKeepValue(value, item, username) {
|
|
12534
|
+
return value.replace(/\$\{([^}]+)\}/g, (_m, exprRaw) => {
|
|
12535
|
+
const expr = String(exprRaw).trim();
|
|
12536
|
+
if (expr === KEEP_LOGIN_USER_EXPR) return username;
|
|
12537
|
+
const resolved = resolveLogPath(item, expr);
|
|
12538
|
+
if (expr === "addTime") return formatMillis(resolved) ?? String(resolved ?? "");
|
|
12539
|
+
return String(resolved ?? "");
|
|
12540
|
+
});
|
|
12541
|
+
}
|
|
12542
|
+
function evalKeepNode(node, item, username) {
|
|
12543
|
+
if (node.kind === "and") {
|
|
12544
|
+
return evalKeepNode(node.left, item, username) && evalKeepNode(node.right, item, username);
|
|
12545
|
+
}
|
|
12546
|
+
if (node.kind === "or") {
|
|
12547
|
+
return evalKeepNode(node.left, item, username) || evalKeepNode(node.right, item, username);
|
|
12548
|
+
}
|
|
12549
|
+
const actual = resolveLogPath(item, node.path);
|
|
12550
|
+
const expected = renderKeepValue(node.value, item, username);
|
|
12551
|
+
switch (node.op) {
|
|
12552
|
+
case "contains": {
|
|
12553
|
+
const needle = expected.toLowerCase();
|
|
12554
|
+
if (Array.isArray(actual)) {
|
|
12555
|
+
return actual.some((v) => String(v ?? "").toLowerCase().includes(needle));
|
|
12556
|
+
}
|
|
12557
|
+
return String(actual ?? "").toLowerCase().includes(needle);
|
|
12558
|
+
}
|
|
12559
|
+
case "notContains": {
|
|
12560
|
+
const needle = expected.toLowerCase();
|
|
12561
|
+
if (Array.isArray(actual)) {
|
|
12562
|
+
return !actual.some((v) => String(v ?? "").toLowerCase().includes(needle));
|
|
12563
|
+
}
|
|
12564
|
+
return !String(actual ?? "").toLowerCase().includes(needle);
|
|
12565
|
+
}
|
|
12566
|
+
case "le":
|
|
12567
|
+
return Number(actual) <= Number(expected);
|
|
12568
|
+
case "ge":
|
|
12569
|
+
return Number(actual) >= Number(expected);
|
|
12570
|
+
case "lt":
|
|
12571
|
+
return Number(actual) < Number(expected);
|
|
12572
|
+
case "gt":
|
|
12573
|
+
return Number(actual) > Number(expected);
|
|
12574
|
+
case "eq": {
|
|
12575
|
+
const joined = Array.isArray(actual) ? actual.join(",") : actual;
|
|
12576
|
+
return looseKey(joined) === looseKey(expected);
|
|
12577
|
+
}
|
|
12578
|
+
}
|
|
12579
|
+
}
|
|
12580
|
+
function cleanRequestLogs(rawItems, rule, workflowName, options) {
|
|
12581
|
+
const warnings = [];
|
|
12582
|
+
const applied = rule.filter.workflowName.length > 0 && rule.filter.workflowName.some((entry) => {
|
|
12583
|
+
const keyword = entry.trim();
|
|
12584
|
+
return keyword && workflowName.includes(keyword);
|
|
12585
|
+
});
|
|
12586
|
+
const parsed = applied ? rule.filter.rule.map(parseLogRule) : [];
|
|
12587
|
+
for (const r of parsed) {
|
|
12588
|
+
if (r.kind === "unknown") warnings.push(`filter \u89C4\u5219\u65E0\u6CD5\u89E3\u6790\uFF0C\u5DF2\u5FFD\u7565\uFF08\u5B81\u53EF\u6F0F\u5220\u4E0D\u8BEF\u5220\uFF09\uFF1A${r.raw}`);
|
|
12589
|
+
}
|
|
12590
|
+
const effectiveRules = parsed.filter((r) => r.kind !== "unknown");
|
|
12591
|
+
const keepRuleRaw = (rule.keepRule ?? "").trim();
|
|
12592
|
+
const keepNeedsLoginUser = keepRuleRaw.includes(`\${${KEEP_LOGIN_USER_EXPR}}`);
|
|
12593
|
+
const username = (options?.username ?? "").trim();
|
|
12594
|
+
let keepRoot = null;
|
|
12595
|
+
let keepApplied = false;
|
|
12596
|
+
if (keepRuleRaw) {
|
|
12597
|
+
if (keepNeedsLoginUser && !username) {
|
|
12598
|
+
warnings.push(`keep \u89C4\u5219\u5DF2\u914D\u7F6E\u4F46\u672A\u53D6\u5230\u5F53\u524D\u767B\u5F55\u4EBA\u59D3\u540D\uFF0Ckeep \u5DF2\u7981\u7528\uFF08\u5B81\u53EF\u4FDD\u7559\u4E0D\u8BEF\u5220\uFF09\uFF1A${keepRuleRaw}`);
|
|
12599
|
+
} else {
|
|
12600
|
+
keepRoot = parseKeepExpression(keepRuleRaw);
|
|
12601
|
+
if (!keepRoot) {
|
|
12602
|
+
warnings.push(`keep \u89C4\u5219\u65E0\u6CD5\u89E3\u6790\uFF0Ckeep \u5DF2\u7981\u7528\uFF08\u5B81\u53EF\u4FDD\u7559\u4E0D\u8BEF\u5220\uFF09\uFF1A${keepRuleRaw}`);
|
|
12603
|
+
} else {
|
|
12604
|
+
keepApplied = true;
|
|
12605
|
+
}
|
|
12606
|
+
}
|
|
12607
|
+
}
|
|
12608
|
+
let dropped = 0;
|
|
12609
|
+
let keepDropped = 0;
|
|
12610
|
+
let keepEvalErrors = 0;
|
|
12611
|
+
const cleaned = [];
|
|
12612
|
+
for (const item of rawItems) {
|
|
12613
|
+
if (applied && hitDropRule(item, effectiveRules)) {
|
|
12614
|
+
dropped += 1;
|
|
12615
|
+
continue;
|
|
12616
|
+
}
|
|
12617
|
+
if (keepApplied && keepRoot) {
|
|
12618
|
+
let keepHit = true;
|
|
12619
|
+
try {
|
|
12620
|
+
keepHit = evalKeepNode(keepRoot, item, username);
|
|
12621
|
+
} catch {
|
|
12622
|
+
keepHit = true;
|
|
12623
|
+
keepEvalErrors += 1;
|
|
12624
|
+
}
|
|
12625
|
+
if (!keepHit) {
|
|
12626
|
+
keepDropped += 1;
|
|
12627
|
+
continue;
|
|
12628
|
+
}
|
|
12629
|
+
}
|
|
12630
|
+
const row = {};
|
|
12631
|
+
for (const field of rule.needLogField) {
|
|
12632
|
+
const value = resolveLogPath(item, field);
|
|
12633
|
+
row[field] = field === "addTime" ? formatMillis(value) ?? value : value;
|
|
12634
|
+
}
|
|
12635
|
+
cleaned.push(row);
|
|
12636
|
+
}
|
|
12637
|
+
if (keepEvalErrors > 0) {
|
|
12638
|
+
warnings.push(`keep \u89C4\u5219\u6C42\u503C\u5F02\u5E38 ${keepEvalErrors} \u6761\uFF08\u6309\u4FDD\u7559\u5904\u7406\uFF0C\u5B81\u53EF\u4FDD\u7559\u4E0D\u8BEF\u5220\uFF09`);
|
|
12639
|
+
}
|
|
12640
|
+
return {
|
|
12641
|
+
cleaned,
|
|
12642
|
+
stats: { raw: rawItems.length, dropped, kept: cleaned.length, applied, keepApplied, keepDropped },
|
|
12643
|
+
warnings
|
|
12644
|
+
};
|
|
12645
|
+
}
|
|
12646
|
+
async function fetchRequestLogsCapped(env, requestId, userId, rule) {
|
|
12647
|
+
const maxLogCount = Math.max(1, rule.maxLogCount);
|
|
12648
|
+
const pageSize = Math.min(Math.max(1, rule.pageSize), 500);
|
|
12649
|
+
const maxPages = Math.min(Math.ceil(maxLogCount / pageSize) + 1, 100);
|
|
12650
|
+
const seenIds = /* @__PURE__ */ new Set();
|
|
12651
|
+
const rawItems = [];
|
|
12652
|
+
let pages = 0;
|
|
12653
|
+
let truncated = false;
|
|
12654
|
+
const rawPages = [];
|
|
12655
|
+
const captureRaw = (raw, page) => rawPages.push({ page, response: raw });
|
|
12656
|
+
const dumpEnabled = Boolean(process.env.WEAVER_WORK_CLI_DUMP_DEEPREAD_DETAIL);
|
|
12657
|
+
const collectPage = (response) => {
|
|
12658
|
+
const data = response?.data;
|
|
12659
|
+
let added = 0;
|
|
12660
|
+
if (Array.isArray(data)) {
|
|
12661
|
+
for (const item of data) {
|
|
12662
|
+
const id = String(item?.id ?? "");
|
|
12663
|
+
if (!id || seenIds.has(id)) continue;
|
|
12664
|
+
seenIds.add(id);
|
|
12665
|
+
rawItems.push(item);
|
|
12666
|
+
added += 1;
|
|
12667
|
+
if (rawItems.length >= maxLogCount) break;
|
|
12668
|
+
}
|
|
12669
|
+
}
|
|
12670
|
+
return added;
|
|
12671
|
+
};
|
|
12672
|
+
let processedRaw = 0;
|
|
12673
|
+
try {
|
|
12674
|
+
for (let page = 1; page <= maxPages; page += 1) {
|
|
12675
|
+
const logPage = await fetchRequestLogPage(env, requestId, page, pageSize, {
|
|
12676
|
+
datatype: rule.datatype,
|
|
12677
|
+
notShowEmpty: rule.notShowEmpty,
|
|
12678
|
+
captureRaw
|
|
12679
|
+
});
|
|
12680
|
+
pages += 1;
|
|
12681
|
+
while (processedRaw < rawPages.length) {
|
|
12682
|
+
collectPage(rawPages[processedRaw].response);
|
|
12683
|
+
processedRaw += 1;
|
|
12684
|
+
}
|
|
12685
|
+
if (rawItems.length >= maxLogCount) {
|
|
12686
|
+
truncated = logPage?.hasMore === true;
|
|
12687
|
+
break;
|
|
12688
|
+
}
|
|
12689
|
+
if (logPage?.hasMore !== true) break;
|
|
12690
|
+
}
|
|
12691
|
+
} catch (error) {
|
|
12692
|
+
if (dumpEnabled) dumpLogsResponse(requestId, rawPages, stopReasonOf(error), void 0, rule);
|
|
12693
|
+
return { rawItems, pages, fetchedAll: false, truncated, error: stopReasonOf(error) };
|
|
12694
|
+
}
|
|
12695
|
+
if (dumpEnabled) dumpLogsResponse(requestId, rawPages, void 0, rawItems.length, rule);
|
|
12696
|
+
return { rawItems, pages, fetchedAll: !truncated, truncated };
|
|
12697
|
+
}
|
|
12698
|
+
function dumpLogsResponse(requestId, rawPages, error, totalItems, rule) {
|
|
12699
|
+
try {
|
|
12700
|
+
writeFileSync(
|
|
12701
|
+
join3(tmpdir2(), `weaver-deepread-logs-${requestId}.json`),
|
|
12702
|
+
JSON.stringify({
|
|
12703
|
+
endpoint: "/api/workflow/core/paService/v1/getRequestLog",
|
|
12704
|
+
params: {
|
|
12705
|
+
datatype: rule?.datatype ?? 1,
|
|
12706
|
+
notShowEmpty: rule?.notShowEmpty ?? 1,
|
|
12707
|
+
pageSize: rule?.pageSize ?? LOG_PAGE_SIZE,
|
|
12708
|
+
maxLogCount: rule?.maxLogCount,
|
|
12709
|
+
pageNumber: "1..N"
|
|
12710
|
+
},
|
|
12711
|
+
totalItems,
|
|
12712
|
+
error,
|
|
12713
|
+
rawPages
|
|
12714
|
+
}, null, 2),
|
|
12715
|
+
"utf-8"
|
|
12716
|
+
);
|
|
12717
|
+
} catch {
|
|
12718
|
+
}
|
|
12719
|
+
}
|
|
12720
|
+
async function fetchCurrentUserName(env, userId) {
|
|
12721
|
+
try {
|
|
12722
|
+
const response = await env.host.workflowRequest({
|
|
12723
|
+
method: "GET",
|
|
12724
|
+
path: `/api/hrm/card/get/${userId}`,
|
|
12725
|
+
operation: "workflow.aiDeepRead.collect.currentUserCard"
|
|
12726
|
+
});
|
|
12727
|
+
const card = response?.data?.data ?? response?.data ?? {};
|
|
12728
|
+
return String(card?.username ?? card?.userName ?? card?.lastName ?? "").trim();
|
|
12729
|
+
} catch {
|
|
12730
|
+
return "";
|
|
12731
|
+
}
|
|
12732
|
+
}
|
|
12733
|
+
async function fetchRawDetailsBatch(env, requestIds, logRule, workflowName) {
|
|
12734
|
+
const startedAt = Date.now();
|
|
12735
|
+
const unique = [];
|
|
12736
|
+
const seen = /* @__PURE__ */ new Set();
|
|
12737
|
+
for (const raw of requestIds) {
|
|
12738
|
+
const id = String(raw ?? "").trim();
|
|
12739
|
+
if (!id || seen.has(id)) continue;
|
|
12740
|
+
seen.add(id);
|
|
12741
|
+
unique.push(id);
|
|
12742
|
+
}
|
|
12743
|
+
const session = await env.host.getSession();
|
|
12744
|
+
const userId = session.userId || void 0;
|
|
12745
|
+
const currentUserName = logRule.keepRule?.includes(`\${\u5F53\u524D\u767B\u5F55\u4EBA}`) && userId ? await fetchCurrentUserName(env, userId) : "";
|
|
12746
|
+
const details = /* @__PURE__ */ new Map();
|
|
12747
|
+
const failures = [];
|
|
12748
|
+
const logFailures = [];
|
|
12749
|
+
const concurrency = Math.min(DETAIL_CONCURRENCY, Math.max(unique.length, 1));
|
|
12750
|
+
let withLogs = 0;
|
|
12751
|
+
let fetched = 0;
|
|
12752
|
+
let cursor = 0;
|
|
12753
|
+
const worker = async () => {
|
|
12754
|
+
while (cursor < unique.length) {
|
|
12755
|
+
const index = cursor;
|
|
12756
|
+
cursor += 1;
|
|
12757
|
+
const requestId = unique[index];
|
|
12758
|
+
let attempt = 0;
|
|
12759
|
+
let lastError;
|
|
12760
|
+
while (attempt <= DETAIL_RETRIES) {
|
|
12761
|
+
try {
|
|
12762
|
+
const detail = await fetchOneRawDetail(env, requestId, userId);
|
|
12763
|
+
const detailWorkflowName = String(detail?.basicInfo?.workflowName ?? "").trim() || workflowName;
|
|
12764
|
+
const logs = await fetchRequestLogsCapped(env, requestId, userId, logRule);
|
|
12765
|
+
if (logs.error) logFailures.push({ requestId, error: logs.error });
|
|
12766
|
+
const { cleaned, stats: cleanStats, warnings: cleanWarnings } = cleanRequestLogs(
|
|
12767
|
+
logs.rawItems,
|
|
12768
|
+
logRule,
|
|
12769
|
+
detailWorkflowName,
|
|
12770
|
+
{ username: currentUserName }
|
|
12771
|
+
);
|
|
12772
|
+
detail.requestLog = cleaned.length > 0 ? {
|
|
12773
|
+
available: true,
|
|
12774
|
+
source: `getRequestLog \u6E05\u6D17\u540E\uFF08\u63D0\u53D6 needLogField=${logRule.needLogField.length} \u5B57\u6BB5, filter=${cleanStats.applied ? "\u5DF2\u542F\u7528" : "\u672A\u547D\u4E2D\u6D41\u7A0B\u672A\u542F\u7528"}, keep=${cleanStats.keepApplied ? "\u5DF2\u542F\u7528" : "\u672A\u542F\u7528"}, datatype=${logRule.datatype} \u4EC5\u6D41\u8F6C\u610F\u89C1, notShowEmpty=${logRule.notShowEmpty}, maxLogCount=${logRule.maxLogCount}\uFF09`,
|
|
12775
|
+
items: cleaned,
|
|
12776
|
+
pages: logs.pages,
|
|
12777
|
+
fetchedAll: logs.fetchedAll,
|
|
12778
|
+
truncated: logs.truncated,
|
|
12779
|
+
cleanStats,
|
|
12780
|
+
...cleanWarnings.length ? { warnings: cleanWarnings } : {}
|
|
12781
|
+
} : { available: false, ...logs.error ? { error: logs.error } : {} };
|
|
12782
|
+
details.set(requestId, detail);
|
|
12783
|
+
fetched += 1;
|
|
12784
|
+
if (cleaned.length > 0) withLogs += 1;
|
|
12785
|
+
lastError = void 0;
|
|
12786
|
+
break;
|
|
12787
|
+
} catch (error) {
|
|
12788
|
+
lastError = error;
|
|
12789
|
+
if (stopReasonOf(error) === "login_expired") throw error;
|
|
12790
|
+
attempt += 1;
|
|
12791
|
+
if (attempt > DETAIL_RETRIES || !isRetryable(error)) break;
|
|
12792
|
+
}
|
|
12793
|
+
}
|
|
12794
|
+
if (lastError !== void 0) {
|
|
12795
|
+
failures.push({ requestId, error: stopReasonOf(lastError) });
|
|
12796
|
+
details.set(requestId, { error: stopReasonOf(lastError) });
|
|
12797
|
+
}
|
|
12798
|
+
}
|
|
12799
|
+
};
|
|
12800
|
+
await Promise.all(Array.from({ length: concurrency }, () => worker()));
|
|
12801
|
+
return {
|
|
12802
|
+
details,
|
|
12803
|
+
stats: {
|
|
12804
|
+
requested: unique.length,
|
|
12805
|
+
fetched,
|
|
12806
|
+
failed: failures.length,
|
|
12807
|
+
withLogs,
|
|
12808
|
+
logFailed: logFailures.length,
|
|
12809
|
+
concurrency,
|
|
12810
|
+
durationMs: Date.now() - startedAt,
|
|
12811
|
+
failures: failures.slice(0, 20)
|
|
12812
|
+
}
|
|
12813
|
+
};
|
|
12814
|
+
}
|
|
12815
|
+
function writeCollectCache(payload, batchSize) {
|
|
12816
|
+
const skillDir = resolveSkillDir();
|
|
12817
|
+
const dir = skillDir ? join3(skillDir, "temp") : join3(tmpdir2(), "weaver-work-cli-aiDeepRead");
|
|
12818
|
+
mkdirSync(dir, { recursive: true });
|
|
12819
|
+
const stamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[-:T]/g, "").slice(0, 14);
|
|
12820
|
+
const cacheFile = join3(dir, `aiDeepRead-collect-${stamp}.json`);
|
|
12821
|
+
const json = JSON.stringify(payload, null, 2);
|
|
12822
|
+
writeFileSync(cacheFile, json, "utf-8");
|
|
12823
|
+
const rows = Array.isArray(payload.rows) ? payload.rows : [];
|
|
12824
|
+
const details = Array.isArray(payload.details) ? payload.details : [];
|
|
12825
|
+
const promptEntries = Array.isArray(payload.prompts) ? payload.prompts : [];
|
|
12826
|
+
const rowByRequestId = /* @__PURE__ */ new Map();
|
|
12827
|
+
for (const row of rows) {
|
|
12828
|
+
if (row?.requestId) rowByRequestId.set(String(row.requestId), row);
|
|
12829
|
+
}
|
|
12830
|
+
const size = Math.max(1, Math.floor(batchSize));
|
|
12831
|
+
const batches = [];
|
|
12832
|
+
for (let i = 0; i < details.length; i += size) {
|
|
12833
|
+
const slice = details.slice(i, i + size);
|
|
12834
|
+
const batchNo = Math.floor(i / size) + 1;
|
|
12835
|
+
const batchRows = slice.map((d) => d?.requestId ? rowByRequestId.get(String(d.requestId)) : void 0).filter(Boolean);
|
|
12836
|
+
const batchWorkflowNames = slice.map((d) => {
|
|
12837
|
+
const fromDetail = String(d?.detail?.basicInfo?.workflowName ?? "").trim();
|
|
12838
|
+
if (fromDetail) return fromDetail;
|
|
12839
|
+
const row = d?.requestId ? rowByRequestId.get(String(d.requestId)) : void 0;
|
|
12840
|
+
return String(row?.workflowname ?? row?.workflowName ?? "").trim();
|
|
12841
|
+
}).filter(Boolean);
|
|
12842
|
+
const batchPrompts = resolvePromptsForBatch(promptEntries, batchWorkflowNames);
|
|
12843
|
+
const batchPayload = {
|
|
12844
|
+
collectedAt: payload.collectedAt,
|
|
12845
|
+
mode: payload.mode,
|
|
12846
|
+
target: payload.target,
|
|
12847
|
+
sort: payload.sort,
|
|
12848
|
+
batchNo,
|
|
12849
|
+
batchTotal: Math.ceil(details.length / size),
|
|
12850
|
+
batchSize: size,
|
|
12851
|
+
rows: batchRows,
|
|
12852
|
+
details: slice,
|
|
12853
|
+
// 默认详读提示词(2026-11-24 用户定稿:唯一提示词源 = config defaultPrompt):
|
|
12854
|
+
// 每个批次文件都带 defaultPrompts 区块,未命中 prompts 条目的详读指令来源
|
|
12855
|
+
...payload.defaultPrompts && typeof payload.defaultPrompts === "object" ? { defaultPrompts: payload.defaultPrompts } : {},
|
|
12856
|
+
...batchPrompts.length > 0 ? { prompts: batchPrompts } : {}
|
|
12857
|
+
};
|
|
12858
|
+
const batchFile = join3(dir, `aiDeepRead-batch-${stamp}-${String(batchNo).padStart(2, "0")}.json`);
|
|
12859
|
+
const batchJson = JSON.stringify(batchPayload, null, 2);
|
|
12860
|
+
writeFileSync(batchFile, batchJson, "utf-8");
|
|
12861
|
+
batches.push({
|
|
12862
|
+
batchNo,
|
|
12863
|
+
file: batchFile,
|
|
12864
|
+
count: slice.length,
|
|
12865
|
+
bytes: Buffer.byteLength(batchJson, "utf-8")
|
|
12866
|
+
});
|
|
12867
|
+
}
|
|
12868
|
+
return { cacheFile, cacheBytes: Buffer.byteLength(json, "utf-8"), batches };
|
|
12869
|
+
}
|
|
12870
|
+
async function collectDeepReadRawData(args, env, effective) {
|
|
12871
|
+
const { mode, requestId, workflowId, workflowName, workflowIds, fetchWorkflowNames, fetch, count, requestLog, batchSize, group, dataDimension, originData, defaultPrompt } = effective;
|
|
12872
|
+
const warnings = [];
|
|
12873
|
+
const scope = String(fetch.scope ?? "todo");
|
|
12874
|
+
const scopePath = { todo: WORKFLOW_ENDPOINTS.TODO_LIST };
|
|
12875
|
+
const listPath = scopePath[scope];
|
|
12876
|
+
if (!listPath) {
|
|
12877
|
+
throw workflowValidationError(
|
|
12878
|
+
"deep_read_scope_unsupported",
|
|
12879
|
+
`aiDeepRead \u53D6\u6570\u8303\u56F4\u53EA\u652F\u6301 todo\uFF08\u5F53\u524D config.fetch.scope=${scope}\uFF09\uFF1B\u5176\u4F59\u8303\u56F4\u7684\u7AEF\u70B9\u4E0E\u5B57\u6BB5\u5951\u7EA6\u672A\u9A8C\u8BC1\uFF0C\u4E0D\u652F\u6301\u3002`,
|
|
12880
|
+
{ scope }
|
|
12881
|
+
);
|
|
12882
|
+
}
|
|
12883
|
+
const requestedCount = mode === "byRequest" ? 1 : Math.max(1, count);
|
|
12884
|
+
const pageSize = Math.min(Math.max(1, requestedCount), MAX_PAGE_SIZE);
|
|
12885
|
+
const sortText = `${fetch.orderBy}:${fetch.orderDirection}`;
|
|
12886
|
+
const collectStart = Date.now();
|
|
12887
|
+
const seen = /* @__PURE__ */ new Set();
|
|
12888
|
+
const rawRows = [];
|
|
12889
|
+
const rowFilter = {
|
|
12890
|
+
applied: mode !== "byRequest",
|
|
12891
|
+
checked: 0,
|
|
12892
|
+
droppedReject: 0,
|
|
12893
|
+
droppedDraft: 0,
|
|
12894
|
+
augmentChecked: 0,
|
|
12895
|
+
droppedCanCheck: 0,
|
|
12896
|
+
augmentMissing: 0,
|
|
12897
|
+
augmentRequests: 0
|
|
12898
|
+
};
|
|
12899
|
+
let pages = 0;
|
|
12900
|
+
let totalAvailable = null;
|
|
12901
|
+
let stoppedEarly = false;
|
|
12902
|
+
const configWfNames = (fetchWorkflowNames ?? []).map((v) => String(v).trim()).filter(Boolean);
|
|
12903
|
+
const paramFilterApplied = mode === "byOriginData" && Boolean(String(workflowName ?? "").trim());
|
|
12904
|
+
const listFilterApplied = mode === "byOriginData" && originData?.kind === "summary" && configWfNames.length > 0;
|
|
12905
|
+
const nameFilter = {
|
|
12906
|
+
applied: paramFilterApplied || listFilterApplied,
|
|
12907
|
+
workflowName: String(workflowName ?? "").trim(),
|
|
12908
|
+
names: listFilterApplied ? [...configWfNames] : [],
|
|
12909
|
+
checked: 0,
|
|
12910
|
+
dropped: 0,
|
|
12911
|
+
kept: 0
|
|
12912
|
+
};
|
|
12913
|
+
if (paramFilterApplied) {
|
|
12914
|
+
warnings.push(`originData \u56DE\u653E + workflowName=\u300C${nameFilter.workflowName}\u300D\uFF1A\u5217\u8868\u884C\u6309 workflowName \u7CBE\u786E\u76F8\u7B49\u8FC7\u6EE4\uFF0C\u4E0D\u5C5E\u4E8E\u8BE5\u5DE5\u4F5C\u6D41\u7684\u884C\u4E22\u5F03\uFF082026-11-24 \u7528\u6237\u5B9A\u7A3F\uFF1Btodo_query \u56DE\u653E\u8FC7\u6EE4\u540E\u4E0D\u8DB3\u6761\u6570\u7FFB\u9875\u8865\u8DB3\uFF0Ctodo_summary \u56DE\u653E\u4E0D\u8865\u8DB3\uFF09\u3002`);
|
|
12915
|
+
}
|
|
12916
|
+
if (listFilterApplied) {
|
|
12917
|
+
warnings.push(`originData \u56DE\u653E\uFF08todo_summary\uFF09+ config fetch.workflowNames=[${configWfNames.join("\u3001")}]\uFF1A\u5217\u8868\u884C\u6309 workflowName \u7CBE\u786E\u76F8\u7B49\u8FC7\u6EE4\uFF0C\u540D\u5355\u5916\u7684\u884C\u4E22\u5F03\uFF082026-11-24 \u7528\u6237\u5B9A\u7A3F\uFF1B\u4E0E\u63D0\u793A\u8BCD workflowName \u8FC7\u6EE4\u53D6\u4EA4\u96C6\uFF0C\u6587\u4EF6\u9875\u8017\u5C3D\u5373\u6B62\u4E0D\u8865\u8DB3\uFF09\u3002`);
|
|
12918
|
+
}
|
|
12919
|
+
const replaySummaryPages = originData?.kind === "summary" && Array.isArray(originData.payload) ? originData.payload : null;
|
|
12920
|
+
const replayQueryBase = originData?.kind === "query" && originData.payload && typeof originData.payload === "object" && !Array.isArray(originData.payload) ? structuredClone(originData.payload) : null;
|
|
12921
|
+
if (replaySummaryPages) {
|
|
12922
|
+
warnings.push(`\u5217\u8868\u53D6\u6570\u6765\u81EA originData \u56DE\u653E\uFF08${originData.id}\uFF0C\u6587\u4EF6\u542B ${replaySummaryPages.length} \u9875\u54CD\u5E94\u4F53\uFF09\uFF1A\u672A\u8C03\u7528 getTodoListData \u63A5\u53E3\uFF0C\u5176\u540E\u6B65\u9AA4\uFF08\u884C\u8FC7\u6EE4/\u622A\u65AD/\u8BE6\u60C5/\u610F\u89C1\uFF09\u7167\u65E7\uFF082026-11-24 \u7528\u6237\u5B9A\u7A3F\uFF09\u3002`);
|
|
12923
|
+
} else if (replayQueryBase) {
|
|
12924
|
+
warnings.push(`\u5217\u8868\u53D6\u6570\u8D70 originData \u56DE\u653E\uFF08${originData.id}\uFF09\uFF1A\u8BF7\u6C42\u62A5\u6587\u57FA\u7840\u90E8\u5206\u53D6\u81EA\u6587\u4EF6 listQuery\uFF0C\u4EC5 customDisplayPage \u6309 CLI \u7FFB\u9875\u903B\u8F91\u6539\u5199\uFF1Bparams.workflowids \u6309 config.fetch.workflowIds \u8865\u5145\u6CE8\u5165\uFF082026-11-24 \u7528\u6237\u5B9A\u7A3F\uFF09\u3002`);
|
|
12925
|
+
}
|
|
12926
|
+
for (let pageNo = 1; rawRows.length < requestedCount; pageNo += 1) {
|
|
12927
|
+
let response;
|
|
12928
|
+
if (replaySummaryPages) {
|
|
12929
|
+
response = replaySummaryPages[pageNo - 1];
|
|
12930
|
+
if (response === void 0 || response === null) {
|
|
12931
|
+
stoppedEarly = true;
|
|
12932
|
+
break;
|
|
12933
|
+
}
|
|
12934
|
+
} else {
|
|
12935
|
+
let query;
|
|
12936
|
+
if (replayQueryBase) {
|
|
12937
|
+
query = replayQueryBase;
|
|
12938
|
+
const replayWorkflowIds = (workflowIds ?? []).map((v) => String(v).trim()).filter(Boolean).join(",");
|
|
12939
|
+
query.params = {
|
|
12940
|
+
...query.params ?? {},
|
|
12941
|
+
...replayWorkflowIds ? { workflowids: replayWorkflowIds } : {}
|
|
12942
|
+
};
|
|
12943
|
+
query.customDisplayPage = { current: pageNo, size: pageSize };
|
|
12944
|
+
} else {
|
|
12945
|
+
const { query: builtQuery } = await buildSearchQuery(env, {
|
|
12946
|
+
category: scope,
|
|
12947
|
+
sort: sortText,
|
|
12948
|
+
current: pageNo,
|
|
12949
|
+
pageSize
|
|
12950
|
+
}, "list");
|
|
12951
|
+
query = builtQuery;
|
|
12952
|
+
query.params = {
|
|
12953
|
+
...query.params ?? {},
|
|
12954
|
+
...mode === "byRequest" ? { requestId: String(requestId) } : mode === "byWorkflow" ? { workflowId: String(workflowId) } : { workflowids: (workflowIds ?? []).map((v) => String(v).trim()).filter(Boolean).join(",") }
|
|
12955
|
+
};
|
|
12956
|
+
}
|
|
12957
|
+
response = await env.host.workflowRequest({
|
|
12958
|
+
method: "POST",
|
|
12959
|
+
path: listPath,
|
|
12960
|
+
operation: "workflow.aiDeepRead.list",
|
|
12961
|
+
body: query
|
|
12962
|
+
});
|
|
12963
|
+
}
|
|
12964
|
+
pages += 1;
|
|
12965
|
+
if (totalAvailable === null) totalAvailable = extractTotal(response);
|
|
12966
|
+
const pageRows = rowsOf(response);
|
|
12967
|
+
if (pageRows.length === 0) {
|
|
12968
|
+
stoppedEarly = true;
|
|
12969
|
+
break;
|
|
12970
|
+
}
|
|
12971
|
+
let candidateRows = pageRows;
|
|
12972
|
+
if (rowFilter.applied) {
|
|
12973
|
+
const rawByRequestId = /* @__PURE__ */ new Map();
|
|
12974
|
+
for (const raw of rawDisplayRowsOf(response)) {
|
|
12975
|
+
const id = String(displayFieldOf(raw, "requestid") ?? displayFieldOf(raw, "requestId") ?? "").trim();
|
|
12976
|
+
if (id) rawByRequestId.set(id, raw);
|
|
12977
|
+
}
|
|
12978
|
+
const locallyKept = [];
|
|
12979
|
+
for (const row of pageRows) {
|
|
12980
|
+
rowFilter.checked += 1;
|
|
12981
|
+
const raw = rawByRequestId.get(String(row.requestId));
|
|
12982
|
+
const reason = raw ? localRowFilterReason(raw) : null;
|
|
12983
|
+
if (reason === "reject") {
|
|
12984
|
+
rowFilter.droppedReject += 1;
|
|
12985
|
+
continue;
|
|
12986
|
+
}
|
|
12987
|
+
if (reason === "draft") {
|
|
12988
|
+
rowFilter.droppedDraft += 1;
|
|
12989
|
+
continue;
|
|
12990
|
+
}
|
|
12991
|
+
locallyKept.push(row);
|
|
12992
|
+
}
|
|
12993
|
+
const remaining = Math.max(0, requestedCount - rawRows.length);
|
|
12994
|
+
const toCheck = locallyKept.slice(0, remaining);
|
|
12995
|
+
const outcome = await filterRowsByCanCheck(env, toCheck, rawByRequestId);
|
|
12996
|
+
rowFilter.augmentChecked += outcome.stats.augmentChecked;
|
|
12997
|
+
rowFilter.droppedCanCheck += outcome.stats.droppedCanCheck;
|
|
12998
|
+
rowFilter.augmentMissing += outcome.stats.augmentMissing;
|
|
12999
|
+
rowFilter.augmentRequests += outcome.stats.augmentRequests;
|
|
13000
|
+
if (outcome.stats.error) rowFilter.error = outcome.stats.error;
|
|
13001
|
+
warnings.push(...outcome.warnings);
|
|
13002
|
+
candidateRows = outcome.kept;
|
|
13003
|
+
}
|
|
13004
|
+
let added = 0;
|
|
13005
|
+
for (const row of candidateRows) {
|
|
13006
|
+
if (rawRows.length >= requestedCount) break;
|
|
13007
|
+
if (row.requestId) {
|
|
13008
|
+
if (seen.has(row.requestId)) continue;
|
|
13009
|
+
seen.add(row.requestId);
|
|
13010
|
+
}
|
|
13011
|
+
if (nameFilter.applied) {
|
|
13012
|
+
nameFilter.checked += 1;
|
|
13013
|
+
const rowName = String(row.workflowName ?? "").trim();
|
|
13014
|
+
const passParam = !paramFilterApplied || rowName === nameFilter.workflowName;
|
|
13015
|
+
const passList = !listFilterApplied || nameFilter.names.includes(rowName);
|
|
13016
|
+
if (passParam && passList) {
|
|
13017
|
+
nameFilter.kept += 1;
|
|
13018
|
+
} else {
|
|
13019
|
+
nameFilter.dropped += 1;
|
|
13020
|
+
added += 1;
|
|
13021
|
+
continue;
|
|
13022
|
+
}
|
|
13023
|
+
}
|
|
13024
|
+
rawRows.push(row);
|
|
13025
|
+
added += 1;
|
|
13026
|
+
}
|
|
13027
|
+
if (added === 0) break;
|
|
13028
|
+
if (rawRows.length >= requestedCount) break;
|
|
13029
|
+
if (!replaySummaryPages && pageRows.length < pageSize) break;
|
|
13030
|
+
}
|
|
13031
|
+
if (nameFilter.applied && nameFilter.checked > 0 && nameFilter.kept === 0) {
|
|
13032
|
+
const criteria = [
|
|
13033
|
+
paramFilterApplied ? `workflowName=\u300C${nameFilter.workflowName}\u300D` : "",
|
|
13034
|
+
listFilterApplied ? `fetch.workflowNames=[${configWfNames.join("\u3001")}]` : ""
|
|
13035
|
+
].filter(Boolean).join(" \u4E14 ");
|
|
13036
|
+
warnings.push(
|
|
13037
|
+
`\u56DE\u653E\u6570\u636E ${nameFilter.checked} \u884C\u7684 workflowName \u5747\u4E0D\u6EE1\u8DB3\u8FC7\u6EE4\u6761\u4EF6\uFF08${criteria}\uFF0C\u7CBE\u786E\u76F8\u7B49\uFF09\u2014\u2014\u76EE\u6807\u8303\u56F4\u5185\u6CA1\u6709\u53EF\u8BE6\u8BFB\u7684\u6709\u6548\u5F85\u529E\uFF0C\u76F4\u63A5\u544A\u77E5\u7528\u6237\u5373\u53EF\u3002`
|
|
13038
|
+
);
|
|
13039
|
+
}
|
|
13040
|
+
if (rowFilter.applied && rawRows.length === 0 && rowFilter.checked > 0) {
|
|
13041
|
+
warnings.push(
|
|
13042
|
+
`\u5217\u8868\u8FD4\u56DE ${rowFilter.checked} \u884C\u4F46\u5168\u90E8\u88AB\u884C\u8FC7\u6EE4\u5254\u9664\uFF08\u9000\u56DE ${rowFilter.droppedReject} / \u8349\u7A3F ${rowFilter.droppedDraft} / canCheck=false ${rowFilter.droppedCanCheck}\uFF09\u2014\u2014\u6CA1\u6709\u53EF\u8BE6\u8BFB\u7684\u6709\u6548\u5F85\u529E\uFF0C\u76F4\u63A5\u544A\u77E5\u7528\u6237\u5373\u53EF\uFF0C\u4E0D\u5F97\u91CD\u8BD5\u6216\u6362\u53C2\u6570\u518D\u53D6\u3002`
|
|
13043
|
+
);
|
|
13044
|
+
}
|
|
13045
|
+
const listFetchMs = Date.now() - collectStart;
|
|
13046
|
+
let matchedRows;
|
|
13047
|
+
let guard;
|
|
13048
|
+
if (originData) {
|
|
13049
|
+
matchedRows = rawRows;
|
|
13050
|
+
guard = { key: "originData", originDataId: originData.id, kind: originData.kind, replayed: true };
|
|
13051
|
+
} else {
|
|
13052
|
+
const guardOutcome = matchGuard(
|
|
13053
|
+
mode,
|
|
13054
|
+
{ requestId, workflowId, workflowIds },
|
|
13055
|
+
rawRows,
|
|
13056
|
+
totalAvailable
|
|
13057
|
+
);
|
|
13058
|
+
matchedRows = guardOutcome.matchedRows;
|
|
13059
|
+
guard = guardOutcome.guard;
|
|
13060
|
+
warnings.push(...guardOutcome.warnings);
|
|
13061
|
+
}
|
|
13062
|
+
const rows = mode === "byRequest" ? matchedRows : rawRows;
|
|
13063
|
+
if (mode === "byRequest" && matchedRows.length === 0 && rawRows.length === 0) {
|
|
13064
|
+
warnings.push("\u5217\u8868\u63A5\u53E3\u6CA1\u6709\u8FD4\u56DE\u4EFB\u4F55\u660E\u7EC6\uFF1A\u8BF7\u786E\u8BA4 requestId \u662F\u5426\u6B63\u786E\u3001\u8BE5\u6D41\u7A0B\u662F\u5426\u5728\u5F53\u524D\u7528\u6237\u5F85\u529E\u4E2D");
|
|
13065
|
+
}
|
|
13066
|
+
if (rows.length === 0) {
|
|
13067
|
+
warnings.push(
|
|
13068
|
+
"\u5217\u8868\u8FD4\u56DE 0 \u6761\u2014\u2014\u7EC8\u6001\uFF082026-11-18 \u7528\u6237\u5B9A\u7A3F\uFF09\uFF1A\u76F4\u63A5\u544A\u77E5\u7528\u6237\u300C\u8BE5\u76EE\u6807\u4E0B\u6CA1\u6709\u7B26\u5408\u6761\u4EF6\u7684\u5F85\u529E\u300D\uFF0C\u4E0D\u5F97\u91CD\u8BD5\u3001\u4E0D\u5F97\u66F4\u6362 workflowId/requestId \u6216\u4EFB\u4F55\u53C2\u6570\u518D\u53D6\uFF08\u7528\u6237\u8F93\u5165\u7684 ID \u662F\u5426\u6B63\u786E\u7531\u7528\u6237\u81EA\u5DF1\u6838\u5B9E\uFF0Cagent \u4E0D\u8981\u4EE3\u4E3A\u731C\u6D4B\u6216\u6362 ID \u76F2\u8BD5\uFF09\u3002"
|
|
13069
|
+
);
|
|
13070
|
+
}
|
|
13071
|
+
const detailStart = Date.now();
|
|
13072
|
+
const detailIds = [...new Set(rows.map((row) => row.requestId).filter(Boolean))];
|
|
13073
|
+
const { details, stats: detailStats } = await fetchRawDetailsBatch(env, detailIds, requestLog, workflowName);
|
|
13074
|
+
const detailFetchMs = Date.now() - detailStart;
|
|
13075
|
+
const detailsPayload = detailIds.map((requestId2) => ({
|
|
13076
|
+
requestId: requestId2,
|
|
13077
|
+
detail: details.get(requestId2) ?? { error: "unknown_error" }
|
|
13078
|
+
}));
|
|
13079
|
+
const groupingStart = Date.now();
|
|
13080
|
+
const grouping = buildGrouping(workflowName, group ?? [], rows, detailsPayload, warnings);
|
|
13081
|
+
const groupingMs = Date.now() - groupingStart;
|
|
13082
|
+
const cacheStart = Date.now();
|
|
13083
|
+
let cacheFile;
|
|
13084
|
+
let cacheBytes = 0;
|
|
13085
|
+
let batches = [];
|
|
13086
|
+
if (rows.length > 0) {
|
|
13087
|
+
({ cacheFile, cacheBytes, batches } = writeCollectCache({
|
|
13088
|
+
collectedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
13089
|
+
mode,
|
|
13090
|
+
target: {
|
|
13091
|
+
requestId,
|
|
13092
|
+
workflowId,
|
|
13093
|
+
workflowName,
|
|
13094
|
+
...mode === "byTodo" ? { workflowIds: [...workflowIds] } : {},
|
|
13095
|
+
...originData ? { originDataId: originData.id } : {}
|
|
13096
|
+
},
|
|
13097
|
+
sort: sortText,
|
|
13098
|
+
requestedCount,
|
|
13099
|
+
rows,
|
|
13100
|
+
details: detailsPayload,
|
|
13101
|
+
grouping,
|
|
13102
|
+
// 数据维度分类(2026-11-23 用户定稿):条目随缓存持久化,render 按 rows.isremark 归类计数。
|
|
13103
|
+
dimensions: dataDimension,
|
|
13104
|
+
// 详读提示词(2026-11-23 用户定稿):config group 配置的 flowDetailPrompt/requestLogPrompt,
|
|
13105
|
+
// 主缓存留全量、批次文件按该批工作流名命中注入;
|
|
13106
|
+
// 默认详读提示词(2026-11-24 用户定稿:唯一提示词源 = config defaultPrompt):
|
|
13107
|
+
// 注入每个批次文件 defaultPrompts 区块,未命中 prompts 条目时 agent 使用
|
|
13108
|
+
prompts: promptEntriesOf(group),
|
|
13109
|
+
defaultPrompts: { ...defaultPrompt }
|
|
13110
|
+
}, batchSize));
|
|
13111
|
+
}
|
|
13112
|
+
const cacheWriteMs = Date.now() - cacheStart;
|
|
13113
|
+
return {
|
|
13114
|
+
mode,
|
|
13115
|
+
target: {
|
|
13116
|
+
requestId,
|
|
13117
|
+
workflowId,
|
|
13118
|
+
workflowName,
|
|
13119
|
+
...mode === "byTodo" ? { workflowIds: [...workflowIds] } : {},
|
|
13120
|
+
...originData ? { originDataId: originData.id } : {}
|
|
13121
|
+
},
|
|
13122
|
+
...originData ? { originData: { id: originData.id, kind: originData.kind, file: originData.file } } : {},
|
|
13123
|
+
rows,
|
|
13124
|
+
collectStats: {
|
|
13125
|
+
endpoint: replaySummaryPages ? `${listPath}\uFF08\u672A\u8C03\u7528\u2014\u2014originData \u56DE\u653E\uFF0C2026-11-24\uFF09` : listPath,
|
|
13126
|
+
pages,
|
|
13127
|
+
pageSize,
|
|
13128
|
+
requestedCount,
|
|
13129
|
+
fetched: rows.length,
|
|
13130
|
+
totalAvailable,
|
|
13131
|
+
matchGuard: guard,
|
|
13132
|
+
rowFilter,
|
|
13133
|
+
workflowNameFilter: nameFilter
|
|
13134
|
+
},
|
|
13135
|
+
detailStats,
|
|
13136
|
+
cacheFile: cacheFile ?? "",
|
|
13137
|
+
cacheBytes,
|
|
13138
|
+
batchSize,
|
|
13139
|
+
batches,
|
|
13140
|
+
grouping,
|
|
13141
|
+
// 详读提示词条目(2026-11-23 用户定稿):config group 配置了 flowDetailPrompt/requestLogPrompt
|
|
13142
|
+
// 的条目——批次文件 prompts 区块的来源;envelope 透出便于 statusNote 提示 agent 使用
|
|
13143
|
+
prompts: promptEntriesOf(group),
|
|
13144
|
+
// 默认详读提示词(2026-11-24 用户定稿:唯一提示词源 = config defaultPrompt):
|
|
13145
|
+
// 随主缓存/批次文件持久化(defaultPrompts 区块),未命中 prompts 条目时 agent 使用
|
|
13146
|
+
defaultPrompt: { ...defaultPrompt },
|
|
13147
|
+
timing: {
|
|
13148
|
+
listFetchMs,
|
|
13149
|
+
detailFetchMs,
|
|
13150
|
+
cacheWriteMs,
|
|
13151
|
+
groupingMs,
|
|
13152
|
+
totalMs: Date.now() - collectStart
|
|
13153
|
+
},
|
|
13154
|
+
detailBrief: detailBriefOf(detailsPayload),
|
|
13155
|
+
warnings
|
|
13156
|
+
};
|
|
13157
|
+
}
|
|
13158
|
+
function detailBriefOf(detailsPayload) {
|
|
13159
|
+
return detailsPayload.map(({ requestId, detail }) => ({
|
|
13160
|
+
requestId,
|
|
13161
|
+
workflowName: String(detail?.basicInfo?.workflowName ?? "").trim() || void 0,
|
|
13162
|
+
requestTitle: String(detail?.basicInfo?.requestTitle ?? "").trim() || void 0,
|
|
13163
|
+
formFieldCount: Array.isArray(detail?.formData?.fields) ? detail.formData.fields.length : void 0,
|
|
13164
|
+
signatureLogCount: Array.isArray(detail?.requestLog?.items) ? detail.requestLog.items.length : void 0,
|
|
13165
|
+
...detail?.error ? { error: detail.error } : {}
|
|
13166
|
+
}));
|
|
11680
13167
|
}
|
|
11681
|
-
|
|
11682
|
-
|
|
11683
|
-
|
|
11684
|
-
|
|
11685
|
-
|
|
13168
|
+
|
|
13169
|
+
// src/shortcuts/workflow/operations/deepRead.ts
|
|
13170
|
+
var DEEP_READ_DIR_NAME = "aiDeepRead";
|
|
13171
|
+
var DEEP_READ_CONFIG_FILE = "config.json";
|
|
13172
|
+
var DEEP_READ_TRIGGER_BY_REQUEST = "ai\u8BE6\u8BFB";
|
|
13173
|
+
var DEEP_READ_TRIGGER_BY_WORKFLOW = "\u6C47\u603B\u5BA1\u6279";
|
|
13174
|
+
var BUILTIN_DEFAULT_CONFIG = {
|
|
13175
|
+
schemaVersion: 6,
|
|
13176
|
+
batchAiReadCount: 20,
|
|
13177
|
+
/** byTodo(全局汇总审批,2026-11-23 用户定稿)取前 N 条的 N。 */
|
|
13178
|
+
batchAiReadGlobalCount: 50,
|
|
13179
|
+
/** AI 详读批次文件每批 detail 条数(2026-11-18 用户定稿 5 条/批:agent 逐批读取,避免上下文过长)。 */
|
|
13180
|
+
batchAiReadBatchSize: 5,
|
|
13181
|
+
/** 二次条件规则(config group 区块):默认未配置(grouping.matched=false,HTML 不加筛选条)。 */
|
|
13182
|
+
group: [],
|
|
13183
|
+
/** 数据维度分类(config dataDimension.entries,2026-11-23 用户定稿):按 isremark 分维度。 */
|
|
13184
|
+
dataDimension: [
|
|
13185
|
+
{ key: "\u5F85\u5904\u7406", isremark: [0, 1, 5, 6, 10, 11, 102] },
|
|
13186
|
+
{ key: "\u5F85\u9605", isremark: [20, 21, 30, 31, 40, 41, 50, 51, 60, 61, 70, 71, 80, 81] }
|
|
13187
|
+
],
|
|
13188
|
+
fetch: { scope: "todo", orderBy: "\u63A5\u6536\u65F6\u95F4", orderDirection: "desc", workflowIds: [], workflowNames: [] },
|
|
13189
|
+
/** 签字意见(getRequestLog)规则:maxLogCount=只拉前 N 条(2026-11-23 用户定稿 200);
|
|
13190
|
+
* datatype=1 仅流转意见;
|
|
13191
|
+
* notShowEmpty=1 过滤空意见;pageSize=每页条数;needLogField=清洗时从原始意见里
|
|
13192
|
+
* 提取的字段(点路径,addTime 毫秒时间戳自动格式化为 YYYY-MM-DD HH24:MI:SS);
|
|
13193
|
+
* filter=数据清洗剔除规则(命中即剔除,仅对 workflowName 命中的流程生效);
|
|
13194
|
+
* keepRule=保留规则(满足才保留,对所有流程生效;空串=不启用)。 */
|
|
13195
|
+
requestLog: {
|
|
13196
|
+
maxLogCount: 200,
|
|
13197
|
+
datatype: 1,
|
|
13198
|
+
notShowEmpty: 1,
|
|
13199
|
+
pageSize: 50,
|
|
13200
|
+
needLogField: ["commentor.id", "commentor.username", "content", "addTime", "stepName", "commentName"],
|
|
13201
|
+
filter: {
|
|
13202
|
+
workflowName: ["\u5185\u90E8\u7559\u8A00"],
|
|
13203
|
+
rule: [
|
|
13204
|
+
"content \u4E0D\u5305\u542B ok,\u786E\u8BA4,\u6536\u5230",
|
|
13205
|
+
"content \u4E0D\u7B49\u4E8E ${commentor.username} ${addTime:YYYY-MM-DD HH24:MI:SS}"
|
|
13206
|
+
]
|
|
13207
|
+
},
|
|
13208
|
+
keepRule: ""
|
|
13209
|
+
},
|
|
13210
|
+
workflowWhitelist: ["\u5185\u90E8\u7559\u8A00", "\u8BF7\u5047", "\u62A5\u9500"],
|
|
13211
|
+
workflowNameRequired: true,
|
|
13212
|
+
/** 默认详读提示词(2026-11-24 用户定稿:唯一提示词源在 config.json defaultPrompt;
|
|
13213
|
+
* 此内置值仅作 config 缺失/字段缺省时的兜底,语义与 config.json 保持一致):
|
|
13214
|
+
* 简要总结、150 字左右(由原「详细不精简 150-250 字」口径调整)。 */
|
|
13215
|
+
defaultPrompt: {
|
|
13216
|
+
detailPrompt: "\u5BF9\u6D41\u7A0B\u8BE6\u60C5\u505A\u7B80\u8981\u603B\u7ED3\uFF08150\u5B57\u5DE6\u53F3\uFF09\uFF1A\u6D41\u7A0B\u4E3B\u4F53\uFF08\u6807\u9898/\u7F16\u53F7/\u53D1\u8D77\u4EBA/\u53D1\u8D77\u65F6\u95F4/\u5F53\u524D\u8282\u70B9/\u72B6\u6001/\u91CD\u8981\u7A0B\u5EA6\uFF09\uFF0B\u8868\u5355\u5173\u952E\u4E1A\u52A1\u4FE1\u606F\uFF08\u6309\u4E1A\u52A1\u91CD\u8981\u6027\u63D0\u70BC fieldName: value\uFF0C\u91D1\u989D/\u5929\u6570/\u65E5\u671F\u7B49\u5173\u952E\u6570\u503C\u5FC5\u987B\u51C6\u786E\u5F15\u7528\u539F\u6587\uFF0C\u4E0D\u7167\u6284\u5168\u90E8\u5B57\u6BB5\uFF09\uFF0B\u6709\u65E0\u5F02\u5E38\u6216\u65F6\u6548\u538B\u529B\u3002",
|
|
13217
|
+
requestLogPrompt: "\u5BF9\u7B7E\u5B57\u610F\u89C1\u505A\u7B80\u8981\u603B\u7ED3\uFF08150\u5B57\u5DE6\u53F3\uFF09\uFF1A\u5BA1\u6279\u94FE\u8DEF\uFF08\u6309\u8282\u70B9\u5F52\u5E76\u6D41\u8F6C\u3001\u52A8\u4F5C\u5206\u5E03\uFF09\uFF0B\u610F\u89C1\u8981\u70B9\uFF08\u4EE3\u8868\u6027\u610F\u89C1\uFF1A\u4EBA\xB7\u65F6\u95F4\xB7\u52A8\u4F5C\xB7\u610F\u89C1\u539F\u6587\uFF09\uFF0B\u610F\u89C1\u503E\u5411\uFF08\u786E\u8BA4/\u540C\u610F\u7EDF\u8BA1\uFF0C\u5F02\u8BAE\u6216\u9644\u6761\u4EF6\u7684\u91CD\u70B9\u6807\u51FA\uFF09\uFF0B\u6709\u65E0\u963B\u585E\u6216\u5F85\u56DE\u5E94\u4E8B\u9879\uFF1B\u610F\u89C1\u7ED3\u8BBA\u53EA\u63CF\u8FF0\u610F\u89C1\u5185\u5BB9\u672C\u8EAB\uFF0C\u7981\u6B62\u51FA\u73B0\u300C\u6E05\u6D17\u540E\u4FDD\u7559N\u6761\u300D\u300C\u6570\u636E\u6E05\u6D17\u300D\u7B49\u8FC7\u7A0B\u6027\u53E3\u5F84\u6587\u6848\u3002"
|
|
11686
13218
|
}
|
|
11687
|
-
|
|
11688
|
-
|
|
11689
|
-
|
|
11690
|
-
|
|
11691
|
-
|
|
11692
|
-
|
|
11693
|
-
|
|
11694
|
-
|
|
11695
|
-
|
|
13219
|
+
};
|
|
13220
|
+
function loadDeepReadConfig() {
|
|
13221
|
+
const skillDir = resolveSkillDir();
|
|
13222
|
+
if (!skillDir) return { config: null, configFile: null };
|
|
13223
|
+
const configFile = join4(skillDir, DEEP_READ_DIR_NAME, DEEP_READ_CONFIG_FILE);
|
|
13224
|
+
try {
|
|
13225
|
+
const raw = readFileSync2(configFile, "utf-8");
|
|
13226
|
+
const parsed = JSON.parse(raw);
|
|
13227
|
+
if (!parsed || typeof parsed !== "object") return { config: null, configFile };
|
|
13228
|
+
return { config: parsed, configFile };
|
|
13229
|
+
} catch {
|
|
13230
|
+
return { config: null, configFile };
|
|
13231
|
+
}
|
|
13232
|
+
}
|
|
13233
|
+
function effectiveConfig(config) {
|
|
13234
|
+
const fetch = config?.fetch ?? {};
|
|
13235
|
+
const rawCount = config?.batchAiRead?.count;
|
|
13236
|
+
const parsedCount = typeof rawCount === "number" ? rawCount : Number.parseInt(typeof rawCount === "string" ? rawCount.trim() : "", 10);
|
|
13237
|
+
const rawBatchSize = config?.batchAiRead?.batchSize;
|
|
13238
|
+
const parsedBatchSize = typeof rawBatchSize === "number" ? rawBatchSize : Number.parseInt(typeof rawBatchSize === "string" ? rawBatchSize.trim() : "", 10);
|
|
13239
|
+
const rawGlobalCount = config?.batchAiRead?.globalCount;
|
|
13240
|
+
const parsedGlobalCount = typeof rawGlobalCount === "number" ? rawGlobalCount : Number.parseInt(typeof rawGlobalCount === "string" ? rawGlobalCount.trim() : "", 10);
|
|
13241
|
+
const { entries: groupEntries, warnings: groupWarnings } = normalizeGroupEntries(config?.group);
|
|
13242
|
+
const rawDimension = config?.dataDimension;
|
|
13243
|
+
const dimensionResult = rawDimension === void 0 ? { entries: [...BUILTIN_DEFAULT_CONFIG.dataDimension], warnings: [] } : normalizeDataDimension(rawDimension);
|
|
13244
|
+
const nameRequired = config?.entryValidation?.workflowNameRequired;
|
|
13245
|
+
const reqLog = config?.requestLog ?? {};
|
|
13246
|
+
const positiveInt = (v, fallback) => {
|
|
13247
|
+
const n = typeof v === "number" ? v : Number.parseInt(String(v ?? "").trim(), 10);
|
|
13248
|
+
return Number.isFinite(n) && n > 0 ? n : fallback;
|
|
13249
|
+
};
|
|
13250
|
+
return {
|
|
13251
|
+
schemaVersion: config?.schemaVersion ?? BUILTIN_DEFAULT_CONFIG.schemaVersion,
|
|
13252
|
+
fetch: {
|
|
13253
|
+
scope: fetch.scope ?? BUILTIN_DEFAULT_CONFIG.fetch.scope,
|
|
13254
|
+
orderBy: fetch.orderBy ?? BUILTIN_DEFAULT_CONFIG.fetch.orderBy,
|
|
13255
|
+
orderDirection: fetch.orderDirection ?? BUILTIN_DEFAULT_CONFIG.fetch.orderDirection
|
|
13256
|
+
},
|
|
13257
|
+
requestLog: {
|
|
13258
|
+
maxLogCount: positiveInt(reqLog.maxLogCount, BUILTIN_DEFAULT_CONFIG.requestLog.maxLogCount),
|
|
13259
|
+
datatype: positiveInt(reqLog.datatype, BUILTIN_DEFAULT_CONFIG.requestLog.datatype),
|
|
13260
|
+
notShowEmpty: positiveInt(reqLog.notShowEmpty, BUILTIN_DEFAULT_CONFIG.requestLog.notShowEmpty),
|
|
13261
|
+
pageSize: positiveInt(reqLog.pageSize, BUILTIN_DEFAULT_CONFIG.requestLog.pageSize),
|
|
13262
|
+
needLogField: Array.isArray(reqLog.needLogField) && reqLog.needLogField.length > 0 ? reqLog.needLogField.map((f) => String(f)) : [...BUILTIN_DEFAULT_CONFIG.requestLog.needLogField],
|
|
13263
|
+
filter: {
|
|
13264
|
+
workflowName: Array.isArray(reqLog.filter?.workflowName) ? reqLog.filter.workflowName.map((w) => String(w)) : [...BUILTIN_DEFAULT_CONFIG.requestLog.filter.workflowName],
|
|
13265
|
+
rule: Array.isArray(reqLog.filter?.rule) ? reqLog.filter.rule.map((r) => String(r)) : [...BUILTIN_DEFAULT_CONFIG.requestLog.filter.rule]
|
|
13266
|
+
},
|
|
13267
|
+
keepRule: typeof reqLog.keep?.rule === "string" ? reqLog.keep.rule.trim() : ""
|
|
13268
|
+
},
|
|
13269
|
+
workflowWhitelist: config?.workflow ?? [...BUILTIN_DEFAULT_CONFIG.workflowWhitelist],
|
|
13270
|
+
batchAiReadCount: Number.isFinite(parsedCount) && parsedCount > 0 ? parsedCount : BUILTIN_DEFAULT_CONFIG.batchAiReadCount,
|
|
13271
|
+
batchAiReadGlobalCount: Number.isFinite(parsedGlobalCount) && parsedGlobalCount > 0 ? parsedGlobalCount : BUILTIN_DEFAULT_CONFIG.batchAiReadGlobalCount,
|
|
13272
|
+
batchAiReadBatchSize: Number.isFinite(parsedBatchSize) && parsedBatchSize > 0 ? parsedBatchSize : BUILTIN_DEFAULT_CONFIG.batchAiReadBatchSize,
|
|
13273
|
+
/** byTodo 的 workflowId 集合(config fetch.workflowIds;空数组 = 未配置,byTodo 报错终止)。 */
|
|
13274
|
+
fetchWorkflowIds: Array.isArray(fetch.workflowIds) ? fetch.workflowIds.map((v) => String(v).trim()).filter(Boolean) : [...BUILTIN_DEFAULT_CONFIG.fetch.workflowIds],
|
|
13275
|
+
/** todo_summary 回放的 workflowName 白名单(config fetch.workflowNames,2026-11-24 用户定稿;
|
|
13276
|
+
* 空数组 = 未配置,不按名单过滤)。 */
|
|
13277
|
+
fetchWorkflowNames: Array.isArray(fetch.workflowNames) ? fetch.workflowNames.map((v) => String(v).trim()).filter(Boolean) : [...BUILTIN_DEFAULT_CONFIG.fetch.workflowNames],
|
|
13278
|
+
group: groupEntries,
|
|
13279
|
+
groupWarnings,
|
|
13280
|
+
/** 数据维度分类条目(规整化后,2026-11-23 用户定稿)。 */
|
|
13281
|
+
dataDimension: dimensionResult.entries,
|
|
13282
|
+
dataDimensionWarnings: dimensionResult.warnings,
|
|
13283
|
+
entryValidation: {
|
|
13284
|
+
workflowNameRequired: typeof nameRequired === "boolean" ? nameRequired : BUILTIN_DEFAULT_CONFIG.workflowNameRequired
|
|
13285
|
+
},
|
|
13286
|
+
/** 默认详读提示词(2026-11-24 用户定稿:唯一提示词源 = config defaultPrompt;简要总结 150 字左右)。 */
|
|
13287
|
+
defaultPrompt: {
|
|
13288
|
+
detailPrompt: typeof config?.defaultPrompt?.detailPrompt === "string" && config.defaultPrompt.detailPrompt.trim() ? config.defaultPrompt.detailPrompt.trim() : BUILTIN_DEFAULT_CONFIG.defaultPrompt.detailPrompt,
|
|
13289
|
+
requestLogPrompt: typeof config?.defaultPrompt?.requestLogPrompt === "string" && config.defaultPrompt.requestLogPrompt.trim() ? config.defaultPrompt.requestLogPrompt.trim() : BUILTIN_DEFAULT_CONFIG.defaultPrompt.requestLogPrompt
|
|
13290
|
+
}
|
|
13291
|
+
};
|
|
11696
13292
|
}
|
|
11697
|
-
|
|
11698
|
-
|
|
11699
|
-
|
|
11700
|
-
return
|
|
13293
|
+
function matchWhitelist(workflowName, whitelist) {
|
|
13294
|
+
const name = workflowName.trim();
|
|
13295
|
+
if (!name) return void 0;
|
|
13296
|
+
return whitelist.find((entry) => {
|
|
13297
|
+
const keyword = entry.trim();
|
|
13298
|
+
return keyword && name.includes(keyword);
|
|
13299
|
+
});
|
|
11701
13300
|
}
|
|
11702
|
-
|
|
11703
|
-
|
|
11704
|
-
|
|
11705
|
-
|
|
11706
|
-
|
|
13301
|
+
var DEEP_READ_ORIGIN_DATA_DIR = "originData";
|
|
13302
|
+
var ORIGIN_DATA_QUERY_PREFIX = "todo_query_";
|
|
13303
|
+
var ORIGIN_DATA_SUMMARY_PREFIX = "todo_summary_";
|
|
13304
|
+
function loadDeepReadOriginData(originDataId) {
|
|
13305
|
+
const id = originDataId.trim().replace(/\.json$/i, "");
|
|
13306
|
+
if (!id) return { data: null, error: "originDataId \u4E3A\u7A7A" };
|
|
13307
|
+
let kind;
|
|
13308
|
+
if (id.startsWith(ORIGIN_DATA_QUERY_PREFIX)) kind = "query";
|
|
13309
|
+
else if (id.startsWith(ORIGIN_DATA_SUMMARY_PREFIX)) kind = "summary";
|
|
13310
|
+
else return { data: null, error: `\u524D\u7F00\u4E0D\u8BC6\u522B\uFF08\u53EA\u652F\u6301 ${ORIGIN_DATA_QUERY_PREFIX}* / ${ORIGIN_DATA_SUMMARY_PREFIX}*\uFF09` };
|
|
13311
|
+
const skillDir = resolveSkillDir();
|
|
13312
|
+
if (!skillDir) return { data: null, error: "\u672A\u5B9A\u4F4D\u5230 skill \u76EE\u5F55\uFF08WEAVER_WORK_CLI_SKILL_DIR \u672A\u8BBE\u7F6E\uFF09" };
|
|
13313
|
+
const file = join4(skillDir, DEEP_READ_ORIGIN_DATA_DIR, `${id}.json`);
|
|
13314
|
+
let parsed;
|
|
13315
|
+
try {
|
|
13316
|
+
parsed = JSON.parse(readFileSync2(file, "utf-8"));
|
|
13317
|
+
} catch (error) {
|
|
13318
|
+
return { data: null, error: `\u6587\u4EF6\u8BFB\u53D6/\u89E3\u6790\u5931\u8D25\uFF08${file}\uFF09\uFF1A${error.message}` };
|
|
11707
13319
|
}
|
|
11708
|
-
if (
|
|
11709
|
-
|
|
11710
|
-
|
|
11711
|
-
|
|
11712
|
-
}
|
|
11713
|
-
|
|
11714
|
-
|
|
11715
|
-
|
|
11716
|
-
}
|
|
11717
|
-
|
|
11718
|
-
return
|
|
13320
|
+
if (kind === "query") {
|
|
13321
|
+
const listQuery = parsed?.listQuery;
|
|
13322
|
+
if (!listQuery || typeof listQuery !== "object" || Array.isArray(listQuery)) {
|
|
13323
|
+
return { data: null, error: "todo_query \u6587\u4EF6\u7F3A\u5C11 listQuery \u5BF9\u8C61\uFF08\u975E {listQuery,limit} \u5F62\u6001\uFF09" };
|
|
13324
|
+
}
|
|
13325
|
+
return { data: { id, kind, file, payload: listQuery } };
|
|
13326
|
+
}
|
|
13327
|
+
if (!Array.isArray(parsed)) {
|
|
13328
|
+
return { data: null, error: "todo_summary \u6587\u4EF6\u4E0D\u662F\u54CD\u5E94\u4F53\u6570\u7EC4\uFF08\u975E\u5404\u9875\u539F\u59CB\u54CD\u5E94\u4F53 \u5F62\u6001\uFF09" };
|
|
13329
|
+
}
|
|
13330
|
+
return { data: { id, kind, file, payload: parsed } };
|
|
11719
13331
|
}
|
|
11720
|
-
function
|
|
11721
|
-
|
|
11722
|
-
|
|
11723
|
-
|
|
13332
|
+
function workflowDeepReadOperations() {
|
|
13333
|
+
return [
|
|
13334
|
+
{
|
|
13335
|
+
name: "workflow.aiDeepRead",
|
|
13336
|
+
resource: "workflow",
|
|
13337
|
+
method: "aiDeepRead",
|
|
13338
|
+
action: "workflow.aiDeepRead",
|
|
13339
|
+
summary: "AI \u8BE6\u8BFB\uFF1A\u2460 \u6309 requestId \u5BF9\u5355\u6761\u6D41\u7A0B\u8BE6\u8BFB\uFF08\u89E6\u53D1\u8BCD ai\u8BE6\u8BFB\uFF09\uFF1B\u2461 \u6309 workflowId \u62C9\u53D6\u524D N \u6761\uFF08N = batchAiRead.count\uFF0C\u9ED8\u8BA4 20\uFF09\u9010\u6761\u8BE6\u8BFB\uFF08\u89E6\u53D1\u8BCD \u6C47\u603B\u5BA1\u6279\uFF09\uFF1B\u2462 \u5168\u5C40\u6C47\u603B\u5BA1\u6279\uFF082026-11-23\uFF1A\u89E6\u53D1\u8BCD \u6C47\u603B\u5BA1\u6279\u4E14\u4E0D\u5E26 ID\uFF09\u6309 config.fetch.workflowIds \u96C6\u5408\u8FC7\u6EE4\u53D6\u524D N \u6761\uFF08N = batchAiRead.globalCount\uFF0C\u9ED8\u8BA4 50\uFF09\u9010\u6761\u8BE6\u8BFB\uFF1B\u2463 originData \u56DE\u653E\uFF082026-11-24\uFF1A\u5E26 originDataId\uFF09\u5217\u8868\u53D6\u6570\u8D70 <skill>/originData/ \u6587\u4EF6\u56DE\u653E\uFF08todo_query_* \u62A5\u6587\u53D6\u6587\u4EF6\u4ECD\u8C03\u63A5\u53E3\u3001params \u8865\u5145\u6CE8\u5165 workflowids = config.fetch.workflowIds / todo_summary_* \u4E0D\u8C03\u63A5\u53E3\u76F4\u63A5\u7528\u6587\u4EF6\u54CD\u5E94\u4F53\uFF09\uFF0C\u4E0D\u9700\u8981 requestId/workflowId\uFF0C\u53EF\u5E26 workflowName\u2014\u2014\u5E26\u5219\u6309\u5217\u8868\u884C workflowName \u7CBE\u786E\u76F8\u7B49\u8FC7\u6EE4\uFF08query \u56DE\u653E\u7FFB\u9875\u8865\u8DB3 / summary \u56DE\u653E\u4E0D\u8865\u8DB3\uFF09\u4E14\u7167\u5E38\u8FC7\u767D\u540D\u5355\u3002\u2460\u2461 \u987B\u540C\u65F6\u5E26 workflowName \u4E14\u5728\u767D\u540D\u5355\u5185\uFF1B\u2462 \u4E0D\u9700\u8981 workflowName\uFF0C\u4F46 config \u672A\u914D\u7F6E\u96C6\u5408\u65F6\u62A5\u9519\u7EC8\u6B62",
|
|
13340
|
+
capability: "view",
|
|
13341
|
+
risk: "read",
|
|
13342
|
+
inputSchema: schemaOf({
|
|
13343
|
+
requestId: {
|
|
13344
|
+
...SCHEMA_REQUEST_ID,
|
|
13345
|
+
description: "\u5355\u6761\u8BE6\u8BFB\u6A21\u5F0F\uFF08\u89E6\u53D1\u8BCD\u300Cai\u8BE6\u8BFB\u300D\uFF09\uFF1A\u76EE\u6807\u6D41\u7A0B\u7684 requestId\u3002\u4E0E workflowId \u4E92\u65A5\uFF1B\u4E24\u8005\u90FD\u4E0D\u4F20\u65F6\u8FDB\u5165\u5168\u5C40\u6C47\u603B\u5BA1\u6279\u6A21\u5F0F\u3002"
|
|
13346
|
+
},
|
|
13347
|
+
workflowId: {
|
|
13348
|
+
oneOf: [{ type: "integer" }, { type: "string", pattern: "^\\d+$" }],
|
|
13349
|
+
description: "\u6309\u5DE5\u4F5C\u6D41\u6A21\u5F0F\uFF08\u89E6\u53D1\u8BCD\u300C\u6C47\u603B\u5BA1\u6279\u300D\uFF09\uFF1A\u5DE5\u4F5C\u6D41 ID\uFF0C\u62C9\u53D6\u8BE5\u5DE5\u4F5C\u6D41\u524D N \u6761\u5F85\u529E\u9010\u6761\u8BE6\u8BFB\u3002\u4E0E requestId \u4E92\u65A5\uFF1B\u4E24\u8005\u90FD\u4E0D\u4F20\u65F6\u8FDB\u5165\u5168\u5C40\u6C47\u603B\u5BA1\u6279\u6A21\u5F0F\uFF08\u6309 config.fetch.workflowIds \u96C6\u5408\u8FC7\u6EE4\uFF09\u3002"
|
|
13350
|
+
},
|
|
13351
|
+
workflowName: {
|
|
13352
|
+
type: "string",
|
|
13353
|
+
minLength: 1,
|
|
13354
|
+
description: "\u5DE5\u4F5C\u6D41\u540D\u79F0\uFF08\u4EC5 requestId/workflowId \u6A21\u5F0F\u5FC5\u4F20\uFF0C\u7528\u4E8E\u767D\u540D\u5355\u51C6\u5165\u6821\u9A8C\uFF1B\u5168\u5C40\u6C47\u603B\u5BA1\u6279\u6A21\u5F0F\u4E0D\u9700\u8981\uFF09\u3002\u7F3A\u5931\u65F6\u4E0E\u7528\u6237\u786E\u8BA4\uFF0C\u544A\u77E5\u300C\u9700\u8981\u5DE5\u4F5C\u6D41\u540D\u79F0\u624D\u80FD\u7EE7\u7EED ai\u8BE6\u8BFB/\u6C47\u603B\u5BA1\u6279\u300D\u3002"
|
|
13355
|
+
},
|
|
13356
|
+
originDataId: {
|
|
13357
|
+
type: "string",
|
|
13358
|
+
minLength: 1,
|
|
13359
|
+
description: "originData \u56DE\u653E\uFF082026-11-24 \u7528\u6237\u5B9A\u7A3F\uFF0C\u7B2C\u56DB\u6A21\u5F0F byOriginData\uFF09\uFF1A\u63D0\u793A\u8BCD\u5E26 originDataId \u65F6\u5217\u8868\u53D6\u6570\u8D70\u56DE\u653E\u2014\u2014todo_query_* \u4ECD\u8C03 getTodoListData \u4F46\u8BF7\u6C42\u62A5\u6587\u53D6 <skill>/originData/<originDataId>.json \u7684 listQuery\uFF08\u5E76\u5728 params \u8865\u5145\u6CE8\u5165 workflowids = config.fetch.workflowIds \u9017\u53F7\u62FC\u63A5\uFF0Cconfig \u672A\u914D\u7F6E\u65F6\u4E0D\u6CE8\u5165\uFF09\uFF1Btodo_summary_* \u4E0D\u8C03\u63A5\u53E3\uFF0C\u6587\u4EF6\u5185\u5BB9\u5373 getTodoListData \u5404\u9875\u54CD\u5E94\u4F53\u3002\u72EC\u7ACB\u6A21\u5F0F\uFF1A\u4E0D\u9700\u8981 requestId/workflowId\uFF0C\u76EE\u6807\u6821\u9A8C\u8C41\u514D\uFF1B\u53EF\u5E26 workflowName\u2014\u2014\u6B64\u65F6\u6309\u5217\u8868\u884C workflowName \u7CBE\u786E\u76F8\u7B49\u8FC7\u6EE4\uFF08todo_query \u56DE\u653E\u7FFB\u9875\u8865\u8DB3 / todo_summary \u56DE\u653E\u4E0D\u8865\u8DB3\uFF09\u4E14\u7167\u5E38\u8FC7\u767D\u540D\u5355\u3002\u6587\u4EF6\u7F3A\u5931/\u574F JSON/\u524D\u7F00\u4E0D\u8BC6\u522B\u65F6\u964D\u7EA7\u8D70\u5386\u53F2\u903B\u8F91\uFF08warning \u900F\u51FA\uFF09\u3002"
|
|
13360
|
+
}
|
|
13361
|
+
}),
|
|
13362
|
+
handler: async (args, env) => {
|
|
13363
|
+
const requestId = asString(args.requestId) ?? void 0;
|
|
13364
|
+
const workflowId = asString(args.workflowId) ?? void 0;
|
|
13365
|
+
const workflowName = asString(args.workflowName) ?? void 0;
|
|
13366
|
+
const originDataIdRaw = asString(args.originDataId) ?? void 0;
|
|
13367
|
+
let originData = null;
|
|
13368
|
+
const originDataWarnings = [];
|
|
13369
|
+
if (originDataIdRaw) {
|
|
13370
|
+
const loaded = loadDeepReadOriginData(originDataIdRaw);
|
|
13371
|
+
if (loaded.data) {
|
|
13372
|
+
originData = loaded.data;
|
|
13373
|
+
if (requestId || workflowId) {
|
|
13374
|
+
originDataWarnings.push(
|
|
13375
|
+
"originData \u56DE\u653E\u6A21\u5F0F\u4E0B requestId/workflowId \u4E0D\u53C2\u4E0E\u53D6\u6570\uFF0C\u5DF2\u5FFD\u7565\uFF08\u53D6\u6570\u8303\u56F4\u7531 originData \u6587\u4EF6" + (workflowName ? ` + workflowName \u7CBE\u786E\u8FC7\u6EE4` : "") + "\u51B3\u5B9A\uFF0C2026-11-24 \u7528\u6237\u5B9A\u7A3F\uFF09\u3002"
|
|
13376
|
+
);
|
|
13377
|
+
}
|
|
13378
|
+
} else {
|
|
13379
|
+
originDataWarnings.push(
|
|
13380
|
+
`originData \u56DE\u653E\u4E0D\u53EF\u7528\uFF08${loaded.error}\uFF09\uFF1A\u5DF2\u964D\u7EA7\u8D70\u5386\u53F2\u53D6\u6570\u903B\u8F91\uFF082026-11-24 \u7528\u6237\u5B9A\u7A3F\uFF09\u3002`
|
|
13381
|
+
);
|
|
13382
|
+
}
|
|
13383
|
+
}
|
|
13384
|
+
if (!originData && requestId && workflowId) {
|
|
13385
|
+
throw workflowValidationError(
|
|
13386
|
+
"deep_read_target_conflict",
|
|
13387
|
+
"requestId \u4E0E workflowId \u4E0D\u80FD\u540C\u65F6\u4F20\u5165\uFF1A\u5355\u6761\u8BE6\u8BFB\u7528 requestId\uFF0C\u6309\u5DE5\u4F5C\u6D41\u8BE6\u8BFB\u7528 workflowId\uFF0C\u5168\u5C40\u6C47\u603B\u5BA1\u6279\u4E24\u8005\u90FD\u4E0D\u4F20\u3002\u8BF7\u786E\u8BA4\u7528\u6237\u610F\u56FE\u540E\u91CD\u53D1\u3002",
|
|
13388
|
+
{ requestId, workflowId }
|
|
13389
|
+
);
|
|
13390
|
+
}
|
|
13391
|
+
const mode = originData ? "byOriginData" : requestId ? "byRequest" : workflowId ? "byWorkflow" : "byTodo";
|
|
13392
|
+
const { config, configFile } = loadDeepReadConfig();
|
|
13393
|
+
const effective = effectiveConfig(config);
|
|
13394
|
+
if (mode === "byTodo" && effective.fetchWorkflowIds.length === 0) {
|
|
13395
|
+
throw workflowValidationError(
|
|
13396
|
+
"deep_read_workflowids_missing",
|
|
13397
|
+
"\u5168\u5C40\u6C47\u603B\u5BA1\u6279\uFF08\u63D0\u793A\u8BCD\u542B\u300C\u6C47\u603B\u5BA1\u6279\u300D\u4E14\u4E0D\u5E26 requestId/workflowId\uFF09\u9700\u8981\u5728 aiDeepRead/config.json \u7684 fetch.workflowIds \u91CC\u914D\u7F6E workflowId \u96C6\u5408\uFF08\u53D6\u6570\u6309\u8BE5\u96C6\u5408\u8FC7\u6EE4\uFF0Cparams.workflowids \u9017\u53F7\u62FC\u63A5\u6CE8\u5165\uFF09\u3002\u5F53\u524D\u672A\u914D\u7F6E\u2014\u2014\u544A\u77E5\u7528\u6237\u5148\u5728 config \u91CC\u8865\u5145\u96C6\u5408\uFF0C\u6216\u6539\u7528\u5E26 workflowId \u7684\u6309\u5DE5\u4F5C\u6D41\u6C47\u603B\u5BA1\u6279\uFF1B\u4E0D\u5F97\u731C\u6D4B\u96C6\u5408\u5185\u5BB9\u3002",
|
|
13398
|
+
{ mode }
|
|
13399
|
+
);
|
|
13400
|
+
}
|
|
13401
|
+
if ((mode === "byRequest" || mode === "byWorkflow") && !workflowName && effective.entryValidation.workflowNameRequired) {
|
|
13402
|
+
throw workflowValidationError(
|
|
13403
|
+
"deep_read_workflow_name_missing",
|
|
13404
|
+
"aiDeepRead \u8981\u6C42 requestId/workflowId \u5FC5\u987B\u540C\u65F6\u5E26 workflowName\uFF08\u5DE5\u4F5C\u6D41\u540D\u79F0\uFF09\uFF1A\u8BF7\u76F4\u63A5\u4E0E\u7528\u6237\u786E\u8BA4\u76EE\u6807\u6D41\u7A0B/\u5DE5\u4F5C\u6D41\u7684\u5DE5\u4F5C\u6D41\u540D\u79F0\uFF0C\u5E76\u544A\u77E5\u300C\u9700\u8981\u5DE5\u4F5C\u6D41\u540D\u79F0\u624D\u80FD\u7EE7\u7EED ai\u8BE6\u8BFB/\u6C47\u603B\u5BA1\u6279\u300D\uFF0C\u62FF\u5230\u540E\u91CD\u53D1\u3002",
|
|
13405
|
+
{ requestId, workflowId }
|
|
13406
|
+
);
|
|
13407
|
+
}
|
|
13408
|
+
const matchedEntry = workflowName ? matchWhitelist(workflowName, effective.workflowWhitelist) : void 0;
|
|
13409
|
+
if ((mode === "byRequest" || mode === "byWorkflow") && effective.entryValidation.workflowNameRequired && !matchedEntry) {
|
|
13410
|
+
throw workflowValidationError(
|
|
13411
|
+
"deep_read_workflow_not_allowed",
|
|
13412
|
+
`\u5DE5\u4F5C\u6D41\u300C${workflowName}\u300D\u4E0D\u5728 aiDeepRead \u767D\u540D\u5355\u5185\uFF1A\u544A\u77E5\u7528\u6237\u8BE5\u5DE5\u4F5C\u6D41\u672A\u5F00\u653E ai\u8BE6\u8BFB/\u6C47\u603B\u5BA1\u6279\u5E76\u7EC8\u6B62\uFF0C\u4E0D\u7ED9\u5019\u9009\u3001\u4E0D\u8981\u8BD5\u56FE\u7ED5\u8DEF\u3002\u767D\u540D\u5355\u89C1 aiDeepRead/config.json \u7684 workflow \u533A\u5757\uFF08\u5305\u542B\u5339\u914D\uFF09\u3002`,
|
|
13413
|
+
{ workflowName, whitelist: effective.workflowWhitelist }
|
|
13414
|
+
);
|
|
13415
|
+
}
|
|
13416
|
+
if (mode === "byOriginData" && workflowName && !matchedEntry) {
|
|
13417
|
+
throw workflowValidationError(
|
|
13418
|
+
"deep_read_workflow_not_allowed",
|
|
13419
|
+
`\u5DE5\u4F5C\u6D41\u300C${workflowName}\u300D\u4E0D\u5728 aiDeepRead \u767D\u540D\u5355\u5185\uFF1A\u544A\u77E5\u7528\u6237\u8BE5\u5DE5\u4F5C\u6D41\u672A\u5F00\u653E ai\u8BE6\u8BFB/\u6C47\u603B\u5BA1\u6279\u5E76\u7EC8\u6B62\uFF0C\u4E0D\u7ED9\u5019\u9009\u3001\u4E0D\u8981\u8BD5\u56FE\u7ED5\u8DEF\u3002\u767D\u540D\u5355\u89C1 aiDeepRead/config.json \u7684 workflow \u533A\u5757\uFF08\u5305\u542B\u5339\u914D\uFF09\u3002`,
|
|
13420
|
+
{ workflowName, whitelist: effective.workflowWhitelist }
|
|
13421
|
+
);
|
|
13422
|
+
}
|
|
13423
|
+
const collect = await collectDeepReadRawData(args, env, {
|
|
13424
|
+
mode,
|
|
13425
|
+
...requestId && mode !== "byOriginData" ? { requestId } : {},
|
|
13426
|
+
...workflowId && mode !== "byOriginData" ? { workflowId } : {},
|
|
13427
|
+
workflowName: workflowName ?? "",
|
|
13428
|
+
workflowIds: effective.fetchWorkflowIds,
|
|
13429
|
+
fetchWorkflowNames: effective.fetchWorkflowNames,
|
|
13430
|
+
fetch: effective.fetch,
|
|
13431
|
+
count: mode === "byTodo" || mode === "byOriginData" ? effective.batchAiReadGlobalCount : effective.batchAiReadCount,
|
|
13432
|
+
batchSize: effective.batchAiReadBatchSize,
|
|
13433
|
+
group: effective.group,
|
|
13434
|
+
dataDimension: effective.dataDimension,
|
|
13435
|
+
requestLog: effective.requestLog,
|
|
13436
|
+
defaultPrompt: effective.defaultPrompt,
|
|
13437
|
+
...originData ? { originData: { id: originData.id, kind: originData.kind, file: originData.file, payload: originData.payload } } : {}
|
|
13438
|
+
});
|
|
13439
|
+
const batchNote = collect.batches.length > 1 ? `\u539F\u59CB\u6570\u636E\u5DF2\u6309 batchAiRead.batchSize=${collect.batchSize} \u6761/\u6279\u5207\u4E3A ${collect.batches.length} \u4E2A\u6279\u6B21\u6587\u4EF6\uFF08collect.batches \u987A\u5E8F\u5217\u51FA\uFF09\uFF1AAI \u8BE6\u8BFB\u5FC5\u987B\u9010\u6279\u6267\u884C\u2014\u2014\u6BCF\u8F6E\u53EA\u8BFB 1 \u4E2A\u6279\u6B21\u6587\u4EF6\uFF0C\u5BF9\u8BE5\u6279\u6BCF\u6761\u5B8C\u6210\u8BE6\u60C5\u8BE6\u8BFB+\u7B7E\u5B57\u610F\u89C1\u8BE6\u8BFB\u5E76\u8BB0\u4E0B\u7ED3\u8BBA\uFF0C\u7136\u540E\u4E22\u5F03\u8BE5\u6279\u539F\u6587\u518D\u8BFB\u4E0B\u4E00\u6279\uFF1B\u7981\u6B62\u4E00\u6B21\u6027\u8BFB\u5168\u91CF cacheFile\uFF08${collect.batches.length} \u6279\u5171 ${collect.detailStats.fetched} \u6761\uFF0C\u5168\u91CF\u8BFB\u5165\u4F1A\u5BFC\u81F4\u4E0A\u4E0B\u6587\u8FC7\u957F\uFF09\u3002` : "AI \u8BE6\u8BFB\u7531\u5F53\u524D agent \u6267\u884C\uFF1A\u8BFB\u6279\u6B21\u6587\u4EF6\uFF0C\u6309 references/workflow-deep-read.md \xA77.2 \u5BF9\u8BE6\u60C5\u4FE1\u606F\u548C\u7B7E\u5B57\u610F\u89C1\u4FE1\u606F\u5206\u522B\u505A\u4E00\u6B21\u8BE6\u8BFB\uFF0C\u5408\u5E76\u4E3A\u62A5\u544A\u8F93\u51FA\u7ED9\u7528\u6237\u3002";
|
|
13440
|
+
const groupingNote = collect.grouping.matched ? `\u5DF2\u751F\u6210\u4E8C\u6B21\u6761\u4EF6\u89C4\u5219\uFF08\u547D\u4E2D\u914D\u7F6E\u300C${(collect.grouping.matchedKeys ?? [collect.grouping.matchedKey]).filter(Boolean).join("\u3001")}\u300D\uFF0Ccollect.grouping\uFF09\uFF1Arule \u6A21\u5F0F\u5B57\u6BB5\u7684\u300CrequestId\u2192\u6876\u300D\u5DF2\u7531 CLI \u7B97\u597D\uFF1B\u6807 mode:"ai" \u7684\u5B57\u6BB5\u9700\u5728\u8BE6\u8BFB\u9636\u6BB5\u6309 aiInput\uFF08${collect.grouping.fields.filter((f) => f.mode === "ai").map((f) => f.aiInput).join("\u3001") || "\u6D41\u7A0B\u6807\u9898"}\uFF09\u628A\u6BCF\u6761\u5F52\u5165 categories \u7C7B\u76EE\u2014\u2014\u5F52\u7C7B\u7ED3\u679C\u4E0E rule \u6876\u4E00\u8D77\u7528\u4E8E HTML \u9876\u90E8\u7B5B\u9009\u6761\uFF08\u70B9\u51FB\u5206\u7EC4\u7B5B\u9009\u4E0B\u65B9\u5361\u7247\u5217\u8868\uFF0C\u591A\u5B57\u6BB5\u53EF\u7EC4\u5408\u8FC7\u6EE4\uFF09\u3002` : "\u672A\u914D\u7F6E\u4E8C\u6B21\u6761\u4EF6\u89C4\u5219\u6216\u672A\u547D\u4E2D\uFF08config.group\uFF09\uFF1AHTML \u4E0D\u52A0\u7B5B\u9009\u6761\uFF0C\u4FDD\u6301\u57FA\u7840\u7248\u5F0F\u3002";
|
|
13441
|
+
const promptsNote = `\u3010\u8BE6\u8BFB\u63D0\u793A\u8BCD\uFF082026-11-24 \u7528\u6237\u5B9A\u7A3F\uFF1A\u552F\u4E00\u63D0\u793A\u8BCD\u6E90 = config defaultPrompt\uFF0Cdoc/CLI \u4E0D\u518D\u53E6\u5B58\u63D0\u793A\u8BCD\u6587\u6848\uFF09\u3011${(collect.prompts?.length ?? 0) > 0 ? `\u5DF2\u914D\u7F6E ${collect.prompts.length} \u4E2A\u5DE5\u4F5C\u6D41\u7684\u4E13\u7528\u63D0\u793A\u8BCD\uFF08${collect.prompts.map((p) => p.workflowName).join("\u3001")}\uFF09\uFF1A\u6BCF\u4E2A\u6279\u6B21\u6587\u4EF6\u7684 **prompts \u533A\u5757**\u6309\u8BE5\u6279\u6570\u636E\u7684\u5DE5\u4F5C\u6D41\u540D\uFF08\u53CC\u5411\u5305\u542B\uFF09\u5217\u51FA\u547D\u4E2D\u6761\u76EE\u2014\u2014\u8BE6\u8BFB\u8BE5\u6279\u6BCF\u6761\u65F6\u6309\u5176\u5DE5\u4F5C\u6D41\u540D\u547D\u4E2D\u5BF9\u5E94\u6761\u76EE\uFF08flowDetailPrompt = \u8BE6\u60C5\u8BE6\u8BFB\u6307\u4EE4\u3001requestLogPrompt = \u610F\u89C1\u8BE6\u8BFB\u6307\u4EE4\uFF09\uFF0C**\u547D\u4E2D\u63D0\u793A\u8BCD\u65F6\u4EE5\u63D0\u793A\u8BCD\u4E3A\u51C6**\uFF1A\u8F93\u51FA\u683C\u5F0F\u3001\u6A21\u677F\u3001\u8BE6\u7565\u4E0E\u5B57\u6570\u5168\u90E8\u6309\u63D0\u793A\u8BCD\u6267\u884C\uFF08\u5982\u6A21\u677F\u5F0F\u63D0\u793A\u8BCD\u4E25\u683C\u6309\u6A21\u677F\u4EA7\u51FA\uFF09\u3002` : "\u672A\u914D\u7F6E\u5DE5\u4F5C\u6D41\u4E13\u7528\u63D0\u793A\u8BCD\uFF08config group \u6761\u76EE\u672A\u5E26 flowDetailPrompt/requestLogPrompt\uFF09\u3002"}\u672A\u547D\u4E2D\u4E13\u7528\u63D0\u793A\u8BCD\u6761\u76EE\u7684\u8BE6\u8BFB\u6307\u4EE4 = \u6BCF\u4E2A\u6279\u6B21\u6587\u4EF6\u7684 **defaultPrompts \u533A\u5757**\uFF08config defaultPrompt \u6CE8\u5165\u2014\u2014\u8BE6\u60C5/\u610F\u89C1\u5206\u522B\u7B80\u8981\u603B\u7ED3\u3001150 \u5B57\u5DE6\u53F3\uFF09\u3002`;
|
|
13442
|
+
const zeroRowsNote = collect.rows.length === 0 ? "\u30100 \u6761\u7EC8\u6001\u3011\u5217\u8868\u8FD4\u56DE 0 \u6761\uFF1A\u4EFB\u52A1\u5230\u6B64\u7ED3\u675F\u2014\u2014\u76F4\u63A5\u544A\u77E5\u7528\u6237\u300C\u8BE5\u76EE\u6807\u4E0B\u6CA1\u6709\u7B26\u5408\u6761\u4EF6\u7684\u5F85\u529E\u300D\uFF0C\u4E0D\u5F97\u91CD\u8BD5\u3001\u4E0D\u5F97\u66F4\u6362 workflowId/requestId \u6216\u53C2\u6570\u518D\u53D6\u3001\u4E0D\u8981\u751F\u6210\u62A5\u544A\u6216 HTML\u3002" : "";
|
|
13443
|
+
return workflowSuccess(
|
|
13444
|
+
"workflow.aiDeepRead",
|
|
13445
|
+
{
|
|
13446
|
+
status: "COLLECT_READY",
|
|
13447
|
+
statusNote: `${zeroRowsNote}${mode === "byTodo" ? "\u5168\u5C40\u6C47\u603B\u5BA1\u6279\uFF08byTodo\uFF0C2026-11-23 \u7528\u6237\u5B9A\u7A3F\uFF09\uFF1A\u5DF2\u6309 config.fetch.workflowIds \u96C6\u5408\u8FC7\u6EE4\u53D6\u6570\uFF08params.workflowids \u5B57\u9762\u952E\uFF0C\u5BF9\u8D26\u89C1 collect.matchGuard\uFF09\u3002" : ""}${mode === "byOriginData" && originData ? `\u3010originData \u56DE\u653E\uFF082026-11-24 \u7528\u6237\u5B9A\u7A3F\uFF09\u3011\u5217\u8868\u53D6\u6570\u8D70 originData \u56DE\u653E\uFF08${originData.id}\uFF0C${originData.kind === "summary" ? "todo_summary\uFF1A\u672A\u8C03\u7528 getTodoListData \u63A5\u53E3\uFF0C\u6587\u4EF6\u5404\u9875\u54CD\u5E94\u4F53\u76F4\u63A5\u4F5C\u4E3A\u5217\u8868\u6570\u636E\uFF0C\u5176\u540E\u6B65\u9AA4\u7167\u65E7" : "todo_query\uFF1A\u4ECD\u8C03\u7528 getTodoListData\uFF0C\u8BF7\u6C42\u62A5\u6587\u57FA\u7840\u90E8\u5206\u53D6\u81EA\u6587\u4EF6 listQuery\uFF0C\u4EC5\u5206\u9875\u6309 CLI \u7FFB\u9875\u903B\u8F91\u6539\u5199"}\uFF09${workflowName ? `\uFF1BworkflowName=\u300C${workflowName}\u300D\u53C2\u4E0E\u5217\u8868\u884C\u7CBE\u786E\u8FC7\u6EE4\uFF08\u7EDF\u8BA1\u89C1 collect.collectStats.workflowNameFilter\uFF09` : ""}\u3002` : ""}aiDeepRead collect \u9636\u6BB5\u5B8C\u6210\uFF1A\u5217\u8868\u539F\u59CB\u884C + \u8BE6\u60C5/\u7B7E\u5B57\u610F\u89C1\u5DF2\u83B7\u53D6\uFF08\u5404\u9636\u6BB5\u8017\u65F6\u89C1 collect.timing\uFF09\u3002\u4E3B\u7F13\u5B58 ${collect.cacheFile} \u4E3A\u5168\u91CF\u7559\u75D5\uFF08\u8BE6\u8BFB\u4E0D\u8981\u76F4\u63A5\u8BFB\u5B83\uFF09\uFF1B\u8BE6\u8BFB\u8F93\u5165 = collect.batches \u6279\u6B21\u6587\u4EF6\u3002${batchNote}${groupingNote}${promptsNote}\u6240\u6709\u6279\u6B21\u8BE6\u8BFB\u5B8C\u6210\u540E\uFF0C\u8C03\u7528 **workflow.aiDeepReadRender** \u751F\u6210 HTML\uFF082026-11-18 \u5B9A\u7A3F\uFF1AHTML \u7531 CLI \u673A\u68B0\u6E32\u67D3\uFF0Cagent \u4E0D\u5199 HTML\u3001\u4E0D\u8BFB\u6A21\u677F\uFF09\u2014\u2014\u5165\u53C2\uFF1AcacheFile\uFF08\u672C envelope \u7684 collect.cacheFile\uFF09+ conclusions\uFF08\u6BCF\u6761 requestId \u4E24\u6BB5\u7ED3\u8BBA\uFF1AdetailConclusion/opinionConclusion\uFF0C**\u7ED3\u8BBA\u6309\u63D0\u793A\u8BCD\u4EA7\u51FA\uFF082026-11-24 \u7528\u6237\u5B9A\u7A3F\uFF1A\u552F\u4E00\u63D0\u793A\u8BCD\u6E90 = config defaultPrompt\uFF09**\u2014\u2014\u547D\u4E2D prompts \u6761\u76EE\u7528\u5176\u63D0\u793A\u8BCD\u3001\u672A\u547D\u4E2D\u7528\u6279\u6B21\u6587\u4EF6 defaultPrompts\uFF0C\u9ED8\u8BA4\u7B80\u8981\u603B\u7ED3\u3001150 \u5B57\u5DE6\u53F3\uFF0C\u5173\u952E\u6570\u503C\u5FC5\u987B\u51C6\u786E\u5F15\u7528\u539F\u6587\uFF1B**detail.requestLog.available=false\uFF082026-11-24 \u7528\u6237\u5B9A\u7A3F\uFF09= \u610F\u89C1\u6309\u89C4\u5219\u6E05\u6D17\u540E\u65E0\u6570\u636E\uFF0CCLI \u4E0D\u518D\u5582\u539F\u59CB\u610F\u89C1\u2014\u2014opinionConclusion \u76F4\u63A5\u5199\u300C\u65E0\u300D\uFF0C\u7981\u6B62\u5F3A\u884C\u6458\u8981**\uFF09\uFF0C\u53EF\u9009 titleBadge/metaExtra\uFF09+ aiAssignments\uFF08grouping ai \u5B57\u6BB5\u7684\u5F52\u7C7B\u7ED3\u679C\uFF0C\u5982\u547D\u4E2D\uFF09+ timingRows\uFF08\u9636\u6BB5\u8017\u65F6\u884C\uFF1ACLI \u5404\u9879\u53D6 collect.timing\uFF0Cagent \u4FA7\u6279\u6B21\u8BFB\u53D6/\u8BE6\u60C5\u8BE6\u8BFB/\u7B7E\u5B57\u610F\u89C1\u8BE6\u8BFB/AI \u5206\u7EC4\u5206\u5F00\u8BA1\u65F6\uFF0C\u53E6\u52A0\u300C\u4EFB\u52A1\u603B\u8017\u65F6\uFF08\u5899\u949F\uFF09\u300D\u300C\u672A\u5F52\u96C6\u300D\u4E24\u884C\uFF09\u3002\u8BE6\u8BFB\u4E0E\u4EA7\u51FA\u5168\u7A0B\u8BB0\u5F55\u5404\u9636\u6BB5\u8017\u65F6\uFF0C\u6700\u7EC8\u62A5\u544A\u968F\u300C\u9636\u6BB5\u8017\u65F6\u300D\u4E00\u8282\u8F93\u51FA\u3002`,
|
|
13448
|
+
mode,
|
|
13449
|
+
target: collect.target,
|
|
13450
|
+
...collect.originData ? { originData: collect.originData } : {},
|
|
13451
|
+
workflow: mode === "byTodo" ? { name: void 0, matchedEntry: void 0, workflowIds: [...effective.fetchWorkflowIds] } : { name: workflowName, matchedEntry },
|
|
13452
|
+
trigger: mode === "byRequest" ? DEEP_READ_TRIGGER_BY_REQUEST : DEEP_READ_TRIGGER_BY_WORKFLOW,
|
|
13453
|
+
collect: {
|
|
13454
|
+
...collect.collectStats,
|
|
13455
|
+
rows: collect.rows,
|
|
13456
|
+
detailStats: collect.detailStats,
|
|
13457
|
+
detailBrief: collect.detailBrief,
|
|
13458
|
+
cacheFile: collect.cacheFile,
|
|
13459
|
+
cacheBytes: collect.cacheBytes,
|
|
13460
|
+
batchSize: collect.batchSize,
|
|
13461
|
+
batches: collect.batches,
|
|
13462
|
+
grouping: collect.grouping,
|
|
13463
|
+
timing: collect.timing
|
|
13464
|
+
},
|
|
13465
|
+
warnings: [...originDataWarnings, ...collect.warnings, ...effective.groupWarnings ?? [], ...effective.dataDimensionWarnings ?? []],
|
|
13466
|
+
config: effective
|
|
13467
|
+
},
|
|
13468
|
+
{
|
|
13469
|
+
configFile: configFile ?? "\u672A\u5B9A\u4F4D\u5230 skill \u76EE\u5F55\uFF08WEAVER_WORK_CLI_SKILL_DIR \u672A\u8BBE\u7F6E\uFF09\uFF0C\u5DF2\u4F7F\u7528\u5185\u7F6E\u9ED8\u8BA4\u914D\u7F6E",
|
|
13470
|
+
configOverridden: Boolean(config)
|
|
13471
|
+
}
|
|
13472
|
+
);
|
|
13473
|
+
}
|
|
13474
|
+
}
|
|
13475
|
+
];
|
|
11724
13476
|
}
|
|
11725
|
-
|
|
11726
|
-
|
|
13477
|
+
|
|
13478
|
+
// src/shortcuts/workflow/operations/aiDeepRead/render.ts
|
|
13479
|
+
import { existsSync as existsSync4, mkdirSync as mkdirSync2, readFileSync as readFileSync3, readdirSync, rmSync, writeFileSync as writeFileSync2 } from "node:fs";
|
|
13480
|
+
import { dirname as dirname2, join as join5 } from "node:path";
|
|
13481
|
+
function escapeHtml(s) {
|
|
13482
|
+
return String(s ?? "").replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
13483
|
+
}
|
|
13484
|
+
function renderFilterBarHtml(grouping, fieldsState, categories = [], multiWf = false) {
|
|
13485
|
+
const catRowsHtml = [];
|
|
13486
|
+
for (const row of categories) {
|
|
13487
|
+
const chips = [
|
|
13488
|
+
` <button class="chip active" data-cat="${escapeHtml(row.cat)}" data-value="__all__" onclick="toggleCategory(this)">\u5168\u90E8<span class="cnt">${row.totalCount}</span></button>`,
|
|
13489
|
+
...row.chips.filter((c) => c.count > 0).map((c) => ` <button class="chip" data-cat="${escapeHtml(row.cat)}" data-value="${escapeHtml(c.label)}" onclick="toggleCategory(this)">${escapeHtml(c.label)}<span class="cnt">${c.count}</span></button>`)
|
|
13490
|
+
];
|
|
13491
|
+
catRowsHtml.push(` <div class="filter-row">
|
|
13492
|
+
<span class="filter-field">${escapeHtml(row.label)}</span>
|
|
13493
|
+
${chips.join("\n")}
|
|
13494
|
+
</div>`);
|
|
13495
|
+
}
|
|
13496
|
+
const rowsHtml = [];
|
|
13497
|
+
for (const f of fieldsState) {
|
|
13498
|
+
const chips = f.buckets.map((b) => ({ label: b, count: f.counts[b] ?? 0 })).filter((c) => c.count > 0);
|
|
13499
|
+
if (chips.length === 0) continue;
|
|
13500
|
+
const chipsHtml = chips.map((c) => ` <button class="chip" data-field="${escapeHtml(f.field)}" data-bucket="${escapeHtml(c.label)}" onclick="toggleChip(this)">${escapeHtml(c.label)}<span class="cnt">${c.count}</span></button>`).join("\n");
|
|
13501
|
+
rowsHtml.push(` <div class="filter-row">
|
|
13502
|
+
<span class="filter-field">${escapeHtml(f.field)}</span>
|
|
13503
|
+
${chipsHtml}
|
|
13504
|
+
</div>`);
|
|
13505
|
+
}
|
|
13506
|
+
const topicGroup = rowsHtml.length > 0 ? ` <div class="topic-group" id="topicGroup"${multiWf ? ' data-multi-wf="1" style="display:none"' : ""}>
|
|
13507
|
+
${rowsHtml.join("\n")}
|
|
13508
|
+
</div>` : "";
|
|
13509
|
+
if (catRowsHtml.length === 0 && !topicGroup) return "";
|
|
13510
|
+
return ` <div class="filter-bar" id="filterBar">
|
|
13511
|
+
${[...catRowsHtml, topicGroup].filter(Boolean).join("\n")}
|
|
13512
|
+
<button class="filter-clear" onclick="clearFilters()">\u6E05\u9664\u7B5B\u9009</button>
|
|
13513
|
+
</div>
|
|
13514
|
+
<div class="no-match" id="noMatch">\u5F53\u524D\u7B5B\u9009\u6761\u4EF6\u4E0B\u6CA1\u6709\u5361\u7247</div>`;
|
|
13515
|
+
}
|
|
13516
|
+
function stayDurationText(receivedTime, now = /* @__PURE__ */ new Date()) {
|
|
13517
|
+
const raw = String(receivedTime ?? "").trim();
|
|
13518
|
+
if (!raw) return void 0;
|
|
13519
|
+
const start = new Date(raw.includes("T") ? raw : raw.replace(" ", "T"));
|
|
13520
|
+
if (isNaN(start.getTime())) return void 0;
|
|
13521
|
+
const diffMs = Math.max(0, now.getTime() - start.getTime());
|
|
13522
|
+
const minutes = Math.floor(diffMs / 6e4);
|
|
13523
|
+
if (minutes < 60) return `${minutes} \u5206\u949F`;
|
|
13524
|
+
const hours = Math.floor(minutes / 60);
|
|
13525
|
+
if (hours < 24) return `${hours} \u5C0F\u65F6`;
|
|
13526
|
+
const days = Math.floor(hours / 24);
|
|
13527
|
+
const restHours = hours % 24;
|
|
13528
|
+
return restHours > 0 ? `${days} \u5929 ${restHours} \u5C0F\u65F6` : `${days} \u5929`;
|
|
13529
|
+
}
|
|
13530
|
+
function summaryLogLine(detail) {
|
|
13531
|
+
const items = Array.isArray(detail?.requestLog?.items) ? detail.requestLog.items : [];
|
|
13532
|
+
if (items.length === 0) return "\u65E0\u7B7E\u5B57\u610F\u89C1";
|
|
13533
|
+
const first = items[0] ?? {};
|
|
13534
|
+
const who = String(first.commentor?.username ?? first.username ?? "").trim();
|
|
13535
|
+
const time = String(first.addTime ?? "").trim();
|
|
13536
|
+
const action = String(first.commentName ?? "").trim();
|
|
13537
|
+
const text = String(first.machiningRemark ?? "").trim();
|
|
13538
|
+
const head = [who, time, action].filter(Boolean).join(" ");
|
|
13539
|
+
return `${items.length} \u6761\u7B7E\u5B57\u610F\u89C1\uFF1A${head}${text ? `\u300C${text}\u300D` : ""}`.trim();
|
|
13540
|
+
}
|
|
13541
|
+
function buildCardHtml(card, con, buckets, logLine, hasFilterBar) {
|
|
13542
|
+
const badgeMark = card.requestMark ? ` <span class="badge">\u7F16\u53F7 ${escapeHtml(card.requestMark)}</span>` : "";
|
|
13543
|
+
const badgeWarn = con?.titleBadge ? `<span class="badge warn">${escapeHtml(con.titleBadge)}</span>` : "";
|
|
13544
|
+
const meta = [
|
|
13545
|
+
{ label: "\u53D1\u8D77\u4EBA", value: card.creatorName },
|
|
13546
|
+
{ label: "\u53D1\u8D77\u65F6\u95F4", value: card.createdAt },
|
|
13547
|
+
{ label: "\u5DF2\u505C\u7559", value: stayDurationText(card.receivedTime) },
|
|
13548
|
+
{ label: "\u5F53\u524D\u8282\u70B9", value: card.currentNode },
|
|
13549
|
+
...con?.metaExtra ?? []
|
|
13550
|
+
].filter((m) => m.value !== void 0 && m.value !== null && String(m.value).trim() !== "");
|
|
13551
|
+
const metaHtml = meta.map((m) => ` <span><span class="label">${escapeHtml(m.label)}</span>${escapeHtml(String(m.value))}</span>`).join("\n");
|
|
13552
|
+
const bucketsAttr = hasFilterBar && Object.keys(buckets).length > 0 ? ` data-buckets='${escapeHtml(JSON.stringify(buckets))}'` : "";
|
|
13553
|
+
const miss = (s) => s && String(s).trim() !== "" ? escapeHtml(String(s).trim()) : "\uFF08\u8BE5\u6761\u672A\u8BE6\u8BFB\uFF0C\u7ED3\u8BBA\u7F3A\u5931\uFF09";
|
|
13554
|
+
return ` <div class="card" data-requestid="${escapeHtml(card.requestId)}"${bucketsAttr} onclick="toggleCard(this)">
|
|
13555
|
+
<div class="card-title"><span class="card-check"></span>${miss(card.title)}${badgeMark}${badgeWarn}</div>
|
|
13556
|
+
<div class="meta-grid">
|
|
13557
|
+
${metaHtml}
|
|
13558
|
+
</div>
|
|
13559
|
+
<div class="section-title">\u8BE6\u60C5\u6458\u8981</div>
|
|
13560
|
+
<div class="conclusion-bar">${miss(con?.detailConclusion)}</div>
|
|
13561
|
+
<div class="section-title">\u610F\u89C1\u6458\u8981</div>
|
|
13562
|
+
<div class="conclusion-bar">${miss(con?.opinionConclusion)}</div>
|
|
13563
|
+
<div class="log-count">${escapeHtml(logLine ?? "\u65E0\u7B7E\u5B57\u610F\u89C1")}</div>
|
|
13564
|
+
</div>`;
|
|
13565
|
+
}
|
|
13566
|
+
function buildSingleCardInner(card, con) {
|
|
13567
|
+
const meta = [
|
|
13568
|
+
{ label: "\u53D1\u8D77\u4EBA", value: card.creatorName },
|
|
13569
|
+
{ label: "\u53D1\u8D77\u65F6\u95F4", value: card.createdAt },
|
|
13570
|
+
{ label: "\u5DF2\u505C\u7559", value: stayDurationText(card.receivedTime) },
|
|
13571
|
+
{ label: "\u5F53\u524D\u8282\u70B9", value: card.currentNode },
|
|
13572
|
+
...con?.metaExtra ?? []
|
|
13573
|
+
].filter((m) => m.value !== void 0 && m.value !== null && String(m.value).trim() !== "");
|
|
13574
|
+
const metaHtml = meta.map((m) => ` <span><span class="label">${escapeHtml(m.label)}</span>${escapeHtml(String(m.value))}</span>`).join("\n");
|
|
13575
|
+
const rid = escapeHtml(card.requestId);
|
|
13576
|
+
const miss = (s) => s && String(s).trim() !== "" ? escapeHtml(String(s).trim()) : "\uFF08\u8BE5\u6761\u672A\u8BE6\u8BFB\uFF0C\u7ED3\u8BBA\u7F3A\u5931\uFF09";
|
|
13577
|
+
return ` <div class="card-title">${miss(card.title)}</div>
|
|
13578
|
+
<div class="meta-grid">
|
|
13579
|
+
${metaHtml}
|
|
13580
|
+
</div>
|
|
13581
|
+
|
|
13582
|
+
<div class="section-title">\u8BE6\u60C5\u6458\u8981</div>
|
|
13583
|
+
<div class="conclusion-bar">${miss(con?.detailConclusion)}</div>
|
|
13584
|
+
|
|
13585
|
+
<div class="section-title">\u610F\u89C1\u6458\u8981</div>
|
|
13586
|
+
<div class="conclusion-bar">${miss(con?.opinionConclusion)}</div>
|
|
13587
|
+
|
|
13588
|
+
<textarea class="op-textarea" placeholder="\u586B\u5199\u610F\u89C1"></textarea>
|
|
13589
|
+
<div class="op-buttons">
|
|
13590
|
+
<button class="btn" onclick="alert('\u9000\u56DE\uFF08\u6F14\u793A\uFF09\uFF1ArequestId=${rid}')">\u9000\u56DE</button>
|
|
13591
|
+
<button class="btn primary" onclick="alert('\u6279\u51C6\uFF08\u6F14\u793A\uFF09\uFF1ArequestId=${rid}')">\u6279\u51C6</button>
|
|
13592
|
+
</div>`;
|
|
13593
|
+
}
|
|
13594
|
+
function mergedFieldState(grouping, aiAssignments) {
|
|
13595
|
+
const aiByField = /* @__PURE__ */ new Map();
|
|
13596
|
+
for (const a of Array.isArray(aiAssignments) ? aiAssignments : []) {
|
|
13597
|
+
if (!a || !a.requestId || !a.field || !a.bucket) continue;
|
|
13598
|
+
if (!aiByField.has(a.field)) aiByField.set(a.field, /* @__PURE__ */ new Map());
|
|
13599
|
+
aiByField.get(a.field).set(String(a.requestId), String(a.bucket));
|
|
13600
|
+
}
|
|
13601
|
+
return grouping.fields.map((f) => {
|
|
13602
|
+
if (f.mode === "rule") {
|
|
13603
|
+
const counts2 = {};
|
|
13604
|
+
for (const b of f.buckets) counts2[b] = 0;
|
|
13605
|
+
for (const a of f.assignment) counts2[a.bucket] = (counts2[a.bucket] ?? 0) + 1;
|
|
13606
|
+
const byId2 = new Map(f.assignment.map((a) => [a.requestId, a.bucket]));
|
|
13607
|
+
return { field: f.field, mode: "rule", buckets: f.buckets, counts: counts2, bucketsOf: (rid) => byId2.get(rid) };
|
|
13608
|
+
}
|
|
13609
|
+
const counts = {};
|
|
13610
|
+
for (const c of [...f.categories, "\u5176\u4ED6"]) counts[c] = 0;
|
|
13611
|
+
const byId = /* @__PURE__ */ new Map();
|
|
13612
|
+
for (const [rid, bucket] of aiByField.get(f.field) ?? []) {
|
|
13613
|
+
byId.set(rid, bucket);
|
|
13614
|
+
counts[bucket] = (counts[bucket] ?? 0) + 1;
|
|
13615
|
+
}
|
|
13616
|
+
const buckets = [...f.categories, ...counts["\u5176\u4ED6"] > 0 ? ["\u5176\u4ED6"] : []];
|
|
13617
|
+
return { field: f.field, mode: "ai", buckets, counts, bucketsOf: (rid) => byId.get(rid) };
|
|
13618
|
+
});
|
|
11727
13619
|
}
|
|
11728
|
-
function
|
|
11729
|
-
|
|
13620
|
+
function loadTemplate(mode) {
|
|
13621
|
+
const skillDir = resolveSkillDir();
|
|
13622
|
+
if (!skillDir) {
|
|
13623
|
+
throw workflowValidationError("deep_read_template_missing", "\u672A\u89E3\u6790\u5230 skill \u76EE\u5F55\uFF1A\u65E0\u6CD5\u8BFB\u53D6 aiDeepRead/templates/ \u6A21\u677F\uFF08\u5FC5\u987B\u7ECF tools/ai-deep-read.cjs \u8C03\u7528\uFF09\u3002");
|
|
13624
|
+
}
|
|
13625
|
+
const templateFile = join5(skillDir, "aiDeepRead", "templates", mode === "byRequest" ? "\u5355\u5361\u7247-demo.html" : "\u6C47\u603B\u5BA1\u6279-demo.html");
|
|
13626
|
+
if (!existsSync4(templateFile)) {
|
|
13627
|
+
throw workflowValidationError("deep_read_template_missing", `\u6A21\u677F\u7F3A\u5931\uFF1A${templateFile}`);
|
|
13628
|
+
}
|
|
13629
|
+
return { html: readFileSync3(templateFile, "utf-8"), templateFile };
|
|
11730
13630
|
}
|
|
11731
|
-
function
|
|
11732
|
-
|
|
13631
|
+
function loadFetchWorkflowNames() {
|
|
13632
|
+
try {
|
|
13633
|
+
const skillDir = resolveSkillDir();
|
|
13634
|
+
if (!skillDir) return [];
|
|
13635
|
+
const configFile = join5(skillDir, "aiDeepRead", "config.json");
|
|
13636
|
+
if (!existsSync4(configFile)) return [];
|
|
13637
|
+
const parsed = JSON.parse(readFileSync3(configFile, "utf-8"));
|
|
13638
|
+
const names = parsed?.fetch?.workflowNames;
|
|
13639
|
+
return Array.isArray(names) ? names.map((v) => String(v).trim()).filter(Boolean) : [];
|
|
13640
|
+
} catch {
|
|
13641
|
+
return [];
|
|
13642
|
+
}
|
|
11733
13643
|
}
|
|
11734
|
-
|
|
11735
|
-
|
|
11736
|
-
|
|
11737
|
-
|
|
11738
|
-
|
|
11739
|
-
|
|
11740
|
-
|
|
11741
|
-
|
|
11742
|
-
|
|
11743
|
-
|
|
11744
|
-
|
|
11745
|
-
|
|
11746
|
-
|
|
11747
|
-
|
|
11748
|
-
|
|
11749
|
-
"isremark",
|
|
11750
|
-
"isremarktype",
|
|
11751
|
-
"nodeid",
|
|
11752
|
-
"currentNodeId",
|
|
11753
|
-
// 状态位
|
|
11754
|
-
"overdue",
|
|
11755
|
-
"userOverTime",
|
|
11756
|
-
"handleStatus",
|
|
11757
|
-
"requestlevel",
|
|
11758
|
-
"requestLevelShow",
|
|
11759
|
-
"requestlevelShow",
|
|
11760
|
-
"requestlevelTitle",
|
|
11761
|
-
// 展示字段
|
|
11762
|
-
"requestnamehtml",
|
|
11763
|
-
"requestnameTitle",
|
|
11764
|
-
"requestnametitle",
|
|
11765
|
-
"requestname",
|
|
11766
|
-
"creater",
|
|
11767
|
-
"creatername",
|
|
11768
|
-
"creatorName",
|
|
11769
|
-
"workflowname",
|
|
11770
|
-
"workflowName",
|
|
11771
|
-
"workflowTypeName",
|
|
11772
|
-
"requestmark",
|
|
11773
|
-
"flowstatusShow",
|
|
11774
|
-
"receivedatetime",
|
|
11775
|
-
"operatedatetime",
|
|
11776
|
-
// 最后反馈时间:`getTodoListData.displayData` 里的原始键是全小写,大小写变体一并保留。
|
|
11777
|
-
"lastfeedbackdatetime",
|
|
11778
|
-
"lastFeedbackDateTime",
|
|
11779
|
-
// 计划完成时间(2026-11-05 补):接口原始键是**驼峰** `planFinishDatetime`,且与
|
|
11780
|
-
// `minOverDateTime` / `curUserOverTime` 三者同值(实测 5 条:`2026-11-06 14:21:23`)。
|
|
11781
|
-
// 之前漏在白名单外 ⇒ `rowFromAny` 虽然写了 pick 也永远取不到,优先组规则想按到期时间判断就成了空谈。
|
|
11782
|
-
"planFinishDatetime",
|
|
11783
|
-
"planfinishdatetime"
|
|
11784
|
-
];
|
|
11785
|
-
function projectDisplayRows(response, extraFields) {
|
|
11786
|
-
const record = responseData(response);
|
|
11787
|
-
const raw = record?.data?.displayData ?? record?.displayData ?? [];
|
|
11788
|
-
const rows = Array.isArray(raw) ? raw : [];
|
|
11789
|
-
const projected = [];
|
|
11790
|
-
const extra = extraFields && extraFields.size > 0 ? extraFields : null;
|
|
11791
|
-
for (const row of rows) {
|
|
11792
|
-
if (!row || typeof row !== "object" || Array.isArray(row)) continue;
|
|
11793
|
-
const source = row;
|
|
11794
|
-
const picked = {};
|
|
11795
|
-
for (const key of DISPLAY_ROW_FIELDS) {
|
|
11796
|
-
const value = source[key];
|
|
11797
|
-
if (typeof value === "string" || typeof value === "number" || typeof value === "boolean" || key === "handleStatus" && value === null) {
|
|
11798
|
-
picked[key] = value;
|
|
13644
|
+
function cleanupTempArtifacts(cacheFile) {
|
|
13645
|
+
const removed = [];
|
|
13646
|
+
try {
|
|
13647
|
+
const base = cacheFile.split("/").pop() ?? "";
|
|
13648
|
+
const m = base.match(/^aiDeepRead-collect-(\d{14})\.json$/);
|
|
13649
|
+
if (!m) return removed;
|
|
13650
|
+
const stamp = m[1];
|
|
13651
|
+
const dir = dirname2(cacheFile);
|
|
13652
|
+
for (const name of readdirSync(dir)) {
|
|
13653
|
+
if (name === `aiDeepRead-collect-${stamp}.json` || name.match(new RegExp(`^aiDeepRead-batch-${stamp}-\\d{2}\\.json$`))) {
|
|
13654
|
+
try {
|
|
13655
|
+
rmSync(join5(dir, name), { force: true });
|
|
13656
|
+
removed.push(name);
|
|
13657
|
+
} catch {
|
|
13658
|
+
}
|
|
11799
13659
|
}
|
|
11800
13660
|
}
|
|
11801
|
-
|
|
11802
|
-
|
|
11803
|
-
|
|
11804
|
-
|
|
11805
|
-
|
|
11806
|
-
|
|
13661
|
+
} catch {
|
|
13662
|
+
}
|
|
13663
|
+
return removed;
|
|
13664
|
+
}
|
|
13665
|
+
function renderSummaryHtml(templateHtml, opts) {
|
|
13666
|
+
let html = templateHtml;
|
|
13667
|
+
html = html.replace(/<title>[\s\S]*?<\/title>/, `<title>\u6C47\u603B\u5BA1\u6279</title>`);
|
|
13668
|
+
html = html.replace(/<div class="sub">[\s\S]*?<\/div>/, `<div class="sub">${escapeHtml(opts.subtitle)}</div>`);
|
|
13669
|
+
const filterStart = html.indexOf("<!-- ======== \u9876\u90E8\u7B5B\u9009\u6761");
|
|
13670
|
+
const filterEndMarker = "-->";
|
|
13671
|
+
if (filterStart >= 0) {
|
|
13672
|
+
const filterEnd = html.indexOf(filterEndMarker, filterStart);
|
|
13673
|
+
if (filterEnd >= 0) {
|
|
13674
|
+
html = html.slice(0, filterStart) + opts.filterBarHtml + html.slice(filterEnd + filterEndMarker.length);
|
|
13675
|
+
}
|
|
13676
|
+
}
|
|
13677
|
+
const listStart = html.search(/<div id="cardList"[^>]*>/);
|
|
13678
|
+
const listEndAnchor = html.indexOf("<!-- ======== \u5E95\u90E8\uFF1A\u63D0\u4EA4");
|
|
13679
|
+
if (listStart >= 0 && listEndAnchor > listStart) {
|
|
13680
|
+
html = html.slice(0, listStart) + '<div id="cardList">\n' + opts.cardsHtml + "\n </div>\n\n " + html.slice(listEndAnchor);
|
|
13681
|
+
}
|
|
13682
|
+
return html;
|
|
13683
|
+
}
|
|
13684
|
+
function renderSingleHtml(templateHtml, opts) {
|
|
13685
|
+
let html = templateHtml;
|
|
13686
|
+
html = html.replace(/<title>[\s\S]*?<\/title>/, `<title>ai\u8BE6\u8BFB \xB7 ${escapeHtml(opts.title)}</title>`);
|
|
13687
|
+
const bodyStart = html.indexOf("<body>");
|
|
13688
|
+
const head = html.slice(0, bodyStart + "<body>".length);
|
|
13689
|
+
return `${head}
|
|
13690
|
+
<div class="page">
|
|
13691
|
+
<div class="card">
|
|
13692
|
+
${opts.cardInner}
|
|
13693
|
+
</div>
|
|
13694
|
+
</div>
|
|
13695
|
+
</body>
|
|
13696
|
+
</html>
|
|
13697
|
+
`;
|
|
13698
|
+
}
|
|
13699
|
+
function workflowDeepReadRenderOperations() {
|
|
13700
|
+
return [
|
|
13701
|
+
{
|
|
13702
|
+
name: "workflow.aiDeepReadRender",
|
|
13703
|
+
resource: "workflow",
|
|
13704
|
+
method: "aiDeepReadRender",
|
|
13705
|
+
action: "workflow.aiDeepReadRender",
|
|
13706
|
+
summary: "AI \u8BE6\u8BFB\u7B2C\u4E09\u9636\u6BB5\u6E32\u67D3\uFF08CLI \u673A\u68B0\u751F\u6210 HTML\uFF09\uFF1A\u8F93\u5165 collect \u4E3B\u7F13\u5B58\u8DEF\u5F84 + agent \u4E24\u6BB5\u7ED3\u8BBA\uFF08\u6BCF\u6761 \u8BE6\u60C5\u7ED3\u8BBA/\u610F\u89C1\u7ED3\u8BBA\uFF0C2026-11-18 \u4E8C\u6B21\u5B9A\u7A3F\uFF09+ ai \u5206\u7EC4\u5F52\u7C7B + \u9636\u6BB5\u8017\u65F6\u884C\uFF0C\u6309 skill \u6A21\u677F\u751F\u6210\u81EA\u5305\u542B HTML\u3002\u7B5B\u9009\u6761\u8BA1\u6570\u4E0E\u5361\u7247\u5206\u6876\u540C\u6E90\u4E8E\u7F13\u5B58\u4E2D\u7684 grouping\uFF0C0 \u8BA1\u6570\u6876\u4E0D\u6E32\u67D3",
|
|
13707
|
+
capability: "view",
|
|
13708
|
+
risk: "read",
|
|
13709
|
+
inputSchema: schemaOf({
|
|
13710
|
+
cacheFile: {
|
|
13711
|
+
type: "string",
|
|
13712
|
+
minLength: 1,
|
|
13713
|
+
description: "collect \u4E3B\u7F13\u5B58\u6587\u4EF6\u7EDD\u5BF9\u8DEF\u5F84\uFF08workflow.aiDeepRead envelope \u7684 data.collect.cacheFile\uFF09\u3002"
|
|
13714
|
+
},
|
|
13715
|
+
conclusions: {
|
|
13716
|
+
type: "array",
|
|
13717
|
+
description: "agent \u8BE6\u8BFB\u4EA7\u51FA\u7684\u6BCF\u6761\u7ED3\u8BBA\uFF08\u4E24\u6BB5\u5FC5\u586B\uFF1AdetailConclusion/opinionConclusion\uFF0C\u7ED3\u8BBA\u8BE6\u7EC6\u3001\u5B57\u6570\u591A\uFF1BdetailSummary/opinionSummary \u5DF2\u5E9F\u5F03\u53EF\u9009\uFF09\u3002",
|
|
13718
|
+
items: {
|
|
13719
|
+
type: "object",
|
|
13720
|
+
properties: {
|
|
13721
|
+
requestId: { type: "string" },
|
|
13722
|
+
detailSummary: { type: "string" },
|
|
13723
|
+
detailConclusion: { type: "string" },
|
|
13724
|
+
opinionSummary: { type: "string" },
|
|
13725
|
+
opinionConclusion: { type: "string" },
|
|
13726
|
+
titleBadge: { type: "string", description: "\u53EF\u9009\u6807\u9898\u8B66\u793A\u5FBD\u6807\uFF08\u5982 \u660E\u5929\u5230\u671F\uFF09" },
|
|
13727
|
+
metaExtra: {
|
|
13728
|
+
type: "array",
|
|
13729
|
+
items: { type: "object", properties: { label: { type: "string" }, value: { type: "string" } }, required: ["label", "value"] }
|
|
13730
|
+
}
|
|
13731
|
+
},
|
|
13732
|
+
required: ["requestId", "detailConclusion", "opinionConclusion"]
|
|
13733
|
+
}
|
|
13734
|
+
},
|
|
13735
|
+
aiAssignments: {
|
|
13736
|
+
type: "array",
|
|
13737
|
+
description: "grouping ai \u6A21\u5F0F\u5B57\u6BB5\u7684\u5F52\u7C7B\u7ED3\u679C\uFF08grouping \u547D\u4E2D\u4E14\u5B58\u5728 ai \u5B57\u6BB5\u65F6\u5FC5\u4F20\uFF09\u3002",
|
|
13738
|
+
items: {
|
|
13739
|
+
type: "object",
|
|
13740
|
+
properties: {
|
|
13741
|
+
requestId: { type: "string" },
|
|
13742
|
+
field: { type: "string" },
|
|
13743
|
+
bucket: { type: "string" }
|
|
13744
|
+
},
|
|
13745
|
+
required: ["requestId", "field", "bucket"]
|
|
13746
|
+
}
|
|
13747
|
+
},
|
|
13748
|
+
timingRows: {
|
|
13749
|
+
type: "array",
|
|
13750
|
+
description: "\u9636\u6BB5\u8017\u65F6\u8868\u884C\uFF082026-11-19 \u5B9A\u7A3F\uFF1A\u4EC5\u4F9B\u5BF9\u8BDD\u4FA7\u300C\u9636\u6BB5\u8017\u65F6\u300D\u4E00\u8282\u7EDF\u8BA1\uFF0CHTML \u4EA7\u7269\u4E0D\u518D\u6E32\u67D3\u8017\u65F6\u9762\u677F\uFF1B\u542B \u4EFB\u52A1\u603B\u8017\u65F6\uFF08\u5899\u949F\uFF09\u4E0E \u672A\u5F52\u96C6 \u4E24\u884C\uFF09\u3002",
|
|
13751
|
+
items: {
|
|
13752
|
+
type: "object",
|
|
13753
|
+
properties: {
|
|
13754
|
+
stage: { type: "string" },
|
|
13755
|
+
desc: { type: "string" },
|
|
13756
|
+
ms: { type: "number" },
|
|
13757
|
+
text: { type: "string" },
|
|
13758
|
+
highlight: { type: "boolean" }
|
|
13759
|
+
},
|
|
13760
|
+
required: ["stage"]
|
|
13761
|
+
}
|
|
13762
|
+
},
|
|
13763
|
+
outputFile: {
|
|
13764
|
+
type: "string",
|
|
13765
|
+
minLength: 1,
|
|
13766
|
+
description: "\u8F93\u51FA HTML \u7EDD\u5BF9\u8DEF\u5F84\uFF08\u53EF\u9009\uFF1B\u9ED8\u8BA4\u5199\u5230\u4E3B\u7F13\u5B58\u540C\u76EE\u5F55 aiDeepRead-render-<\u65F6\u95F4\u6233>.html\uFF09\u3002"
|
|
13767
|
+
}
|
|
13768
|
+
}, { required: ["cacheFile"] }),
|
|
13769
|
+
handler: async (args, _env) => {
|
|
13770
|
+
const started = Date.now();
|
|
13771
|
+
const cacheFile = asString(args.cacheFile)?.trim();
|
|
13772
|
+
if (!cacheFile) {
|
|
13773
|
+
throw workflowValidationError("deep_read_render_input_missing", "cacheFile \u5FC5\u4F20\uFF1Acollect \u4E3B\u7F13\u5B58\u7684\u7EDD\u5BF9\u8DEF\u5F84\uFF08envelope data.collect.cacheFile\uFF09\u3002");
|
|
13774
|
+
}
|
|
13775
|
+
if (!existsSync4(cacheFile)) {
|
|
13776
|
+
throw workflowValidationError("deep_read_render_cache_missing", `\u4E3B\u7F13\u5B58\u4E0D\u5B58\u5728\uFF1A${cacheFile}\uFF08\u5148\u6267\u884C workflow.aiDeepRead collect\uFF09`);
|
|
13777
|
+
}
|
|
13778
|
+
let cache;
|
|
13779
|
+
try {
|
|
13780
|
+
cache = JSON.parse(readFileSync3(cacheFile, "utf-8"));
|
|
13781
|
+
} catch (e) {
|
|
13782
|
+
throw workflowValidationError("deep_read_render_cache_invalid", `\u4E3B\u7F13\u5B58\u4E0D\u662F\u5408\u6CD5 JSON\uFF1A${cacheFile}\uFF08${e?.message ?? e}\uFF09`);
|
|
13783
|
+
}
|
|
13784
|
+
const mode = cache.mode === "byRequest" ? "byRequest" : cache.mode === "byTodo" ? "byTodo" : "byWorkflow";
|
|
13785
|
+
const rows = Array.isArray(cache.rows) ? cache.rows : [];
|
|
13786
|
+
const detailById = /* @__PURE__ */ new Map();
|
|
13787
|
+
for (const d of Array.isArray(cache.details) ? cache.details : []) {
|
|
13788
|
+
if (d?.requestId) detailById.set(String(d.requestId), d.detail ?? {});
|
|
13789
|
+
}
|
|
13790
|
+
const grouping = cache.grouping ?? { matched: false, fields: [] };
|
|
13791
|
+
const warnings = [];
|
|
13792
|
+
const conclusions = Array.isArray(args.conclusions) ? args.conclusions : [];
|
|
13793
|
+
const conByRid = /* @__PURE__ */ new Map();
|
|
13794
|
+
for (const c of conclusions) {
|
|
13795
|
+
if (!c?.requestId) {
|
|
13796
|
+
warnings.push("conclusions \u4E2D\u6709\u4E00\u6761\u7F3A\u5C11 requestId\uFF0C\u5DF2\u5FFD\u7565");
|
|
13797
|
+
continue;
|
|
13798
|
+
}
|
|
13799
|
+
const rid = String(c.requestId);
|
|
13800
|
+
conByRid.set(rid, c);
|
|
13801
|
+
const missing = ["detailConclusion", "opinionConclusion"].filter((k) => !(typeof c[k] === "string" && String(c[k]).trim() !== ""));
|
|
13802
|
+
if (missing.length > 0) {
|
|
13803
|
+
warnings.push(`requestId ${rid} \u7684\u7ED3\u8BBA\u7F3A\u5B57\u6BB5\uFF1A${missing.join("/")}\u2014\u2014\u5361\u7247\u4F1A\u6E32\u67D3\u300C\uFF08\u8BE5\u6761\u672A\u8BE6\u8BFB\uFF0C\u7ED3\u8BBA\u7F3A\u5931\uFF09\u300D\u5360\u4F4D\uFF0C\u9700\u8865\u8BE6\u8BFB\u540E\u91CD\u65B0\u6E32\u67D3`);
|
|
13804
|
+
}
|
|
13805
|
+
}
|
|
13806
|
+
for (const rid of conByRid.keys()) {
|
|
13807
|
+
if (!detailById.has(rid)) warnings.push(`\u7ED3\u8BBA\u91CC\u7684 requestId ${rid} \u4E0D\u5728\u4E3B\u7F13\u5B58\u4E2D\uFF0C\u5DF2\u5FFD\u7565`);
|
|
13808
|
+
}
|
|
13809
|
+
const fieldsState = mergedFieldState(grouping, args.aiAssignments ?? []);
|
|
13810
|
+
const hasFilterBar = fieldsState.some((f) => f.buckets.some((b) => (f.counts[b] ?? 0) > 0));
|
|
13811
|
+
const cardSourceOf = (row) => {
|
|
13812
|
+
const bi = detailById.get(String(row.requestId))?.basicInfo ?? {};
|
|
13813
|
+
return {
|
|
13814
|
+
requestId: String(row.requestId),
|
|
13815
|
+
title: String(bi.requestTitle ?? row.requestNameTitle ?? "").trim() || String(row.requestId),
|
|
13816
|
+
requestMark: String(bi.requestMark ?? "").trim() || void 0,
|
|
13817
|
+
creatorName: String(bi.creatorName ?? row.createrName ?? "").trim() || void 0,
|
|
13818
|
+
createdAt: String(bi.createdAt ?? "").trim() || void 0,
|
|
13819
|
+
receivedTime: String(row.receivedTime ?? row.receiveDateTime ?? "").trim() || void 0,
|
|
13820
|
+
currentNode: String(bi.currentNode ?? "").trim() || void 0,
|
|
13821
|
+
flowStatus: String(bi.flowStatus ?? row.flowStatus ?? "").trim() || void 0,
|
|
13822
|
+
requestLevel: String(bi.requestLevel ?? row.requestLevelShow ?? "").trim() || void 0
|
|
13823
|
+
};
|
|
13824
|
+
};
|
|
13825
|
+
const { html: templateHtml, templateFile } = loadTemplate(mode);
|
|
13826
|
+
const stamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[-:T]/g, "").slice(0, 14);
|
|
13827
|
+
const outputFile = asString(args.outputFile)?.trim() || join5(dirname2(cacheFile), `aiDeepRead-render-${stamp}.html`);
|
|
13828
|
+
let html;
|
|
13829
|
+
let cardCount = 0;
|
|
13830
|
+
if (mode === "byRequest") {
|
|
13831
|
+
const row = rows[0] ?? { requestId: [...detailById.keys()][0] ?? "" };
|
|
13832
|
+
const card = cardSourceOf(row);
|
|
13833
|
+
const con = conByRid.get(card.requestId);
|
|
13834
|
+
html = renderSingleHtml(templateHtml, {
|
|
13835
|
+
title: card.title,
|
|
13836
|
+
cardInner: buildSingleCardInner(card, con)
|
|
13837
|
+
});
|
|
13838
|
+
cardCount = 1;
|
|
13839
|
+
} else {
|
|
13840
|
+
const dimEntries = normalizeDataDimension(cache.dimensions).entries;
|
|
13841
|
+
const wfCountMap = /* @__PURE__ */ new Map();
|
|
13842
|
+
const dimCountMap = /* @__PURE__ */ new Map();
|
|
13843
|
+
for (const row of rows) {
|
|
13844
|
+
const wfName = String(row.workflowName ?? "").trim();
|
|
13845
|
+
if (wfName) wfCountMap.set(wfName, (wfCountMap.get(wfName) ?? 0) + 1);
|
|
13846
|
+
const dimKey = dimensionKeyOf(row.isremark, dimEntries);
|
|
13847
|
+
dimCountMap.set(dimKey, (dimCountMap.get(dimKey) ?? 0) + 1);
|
|
13848
|
+
}
|
|
13849
|
+
const multiWf = wfCountMap.size > 1;
|
|
13850
|
+
const categories = [];
|
|
13851
|
+
if (multiWf) {
|
|
13852
|
+
categories.push({
|
|
13853
|
+
cat: "wf",
|
|
13854
|
+
label: "\u5DE5\u4F5C\u6D41",
|
|
13855
|
+
chips: [...wfCountMap.entries()].map(([label, count]) => ({ label, count })),
|
|
13856
|
+
totalCount: rows.length
|
|
13857
|
+
});
|
|
13858
|
+
}
|
|
13859
|
+
if (dimEntries.length > 0) {
|
|
13860
|
+
const otherCount = dimCountMap.get("\u5176\u4ED6") ?? 0;
|
|
13861
|
+
categories.push({
|
|
13862
|
+
cat: "dim",
|
|
13863
|
+
label: "\u6570\u636E\u7EF4\u5EA6",
|
|
13864
|
+
chips: [
|
|
13865
|
+
...dimEntries.map((e) => ({ label: e.key, count: dimCountMap.get(e.key) ?? 0 })),
|
|
13866
|
+
...otherCount > 0 ? [{ label: "\u5176\u4ED6", count: otherCount }] : []
|
|
13867
|
+
],
|
|
13868
|
+
totalCount: rows.length
|
|
13869
|
+
});
|
|
13870
|
+
}
|
|
13871
|
+
const hasCategoryBar = categories.length > 0;
|
|
13872
|
+
const cardsHtml = rows.map((row) => {
|
|
13873
|
+
const card = cardSourceOf(row);
|
|
13874
|
+
const con = conByRid.get(card.requestId);
|
|
13875
|
+
if (!con) warnings.push(`requestId ${card.requestId} \u65E0\u7ED3\u8BBA\uFF08\u8BE6\u8BFB\u7F3A\u5931\u6216\u6279\u6B21\u8DF3\u8FC7\uFF09\uFF0C\u5361\u7247\u4EE5\u5360\u4F4D\u6587\u6848\u6E32\u67D3`);
|
|
13876
|
+
const buckets = {};
|
|
13877
|
+
for (const f of fieldsState) {
|
|
13878
|
+
const b = f.bucketsOf(card.requestId);
|
|
13879
|
+
if (b) buckets[f.field] = b;
|
|
13880
|
+
}
|
|
13881
|
+
if (multiWf && String(row.workflowName ?? "").trim()) buckets.__wf = String(row.workflowName).trim();
|
|
13882
|
+
if (dimEntries.length > 0) buckets.__dim = dimensionKeyOf(row.isremark, dimEntries);
|
|
13883
|
+
return buildCardHtml(card, con, buckets, summaryLogLine(detailById.get(card.requestId)), hasFilterBar || hasCategoryBar);
|
|
13884
|
+
}).join("\n\n");
|
|
13885
|
+
const filterBarHtml = renderFilterBarHtml(grouping, fieldsState, categories, multiWf);
|
|
13886
|
+
const wfNames = loadFetchWorkflowNames();
|
|
13887
|
+
const scopeLabel = wfNames.length > 0 ? wfNames.join("\u3001") : "fetch.workflowNames";
|
|
13888
|
+
const subtitle = `\u5F53\u524D\u6570\u636E\u7EDF\u8BA1\u8303\u56F4\uFF1A${scopeLabel}\u4E0B\u7684\u6570\u636E\uFF0C\u4E0D\u5305\u62EC\uFF1A\u8349\u7A3F\u3001\u88AB\u9000\u56DE\u53CA\u8BE6\u60C5\u5B58\u5728\u5FC5\u586B\u5B57\u6BB5`;
|
|
13889
|
+
html = renderSummaryHtml(templateHtml, { subtitle, cardsHtml, filterBarHtml });
|
|
13890
|
+
cardCount = rows.length;
|
|
11807
13891
|
}
|
|
13892
|
+
mkdirSync2(dirname2(outputFile), { recursive: true });
|
|
13893
|
+
writeFileSync2(outputFile, html, "utf-8");
|
|
13894
|
+
const bytes = Buffer.byteLength(html, "utf-8");
|
|
13895
|
+
const cleaned = cleanupTempArtifacts(cacheFile);
|
|
13896
|
+
return workflowSuccess(
|
|
13897
|
+
"workflow.aiDeepReadRender",
|
|
13898
|
+
{
|
|
13899
|
+
status: "RENDER_READY",
|
|
13900
|
+
statusNote: `HTML \u5DF2\u751F\u6210\uFF1A${outputFile}\uFF08${cardCount} \u6761\u5361\u7247\uFF0C${bytes} \u5B57\u8282\uFF0C\u6A21\u677F ${templateFile}\uFF09\u3002\u7528 present_files \u6253\u5F00\u9884\u89C8\u5373\u53EF\u4EA4\u4ED8\u3002\u6E32\u67D3\u4E3A CLI \u673A\u68B0\u66FF\u6362\uFF08\u540C\u6E90 grouping + agent \u7ED3\u8BBA\uFF09\uFF0C\u65E0\u9700\u518D\u4EBA\u5DE5\u6838\u5BF9\u6837\u5F0F\u3002`,
|
|
13901
|
+
mode,
|
|
13902
|
+
outputFile,
|
|
13903
|
+
bytes,
|
|
13904
|
+
cardCount,
|
|
13905
|
+
hasFilterBar,
|
|
13906
|
+
timingRowsReceived: (args.timingRows ?? []).length,
|
|
13907
|
+
renderMs: Date.now() - started,
|
|
13908
|
+
tempCleaned: cleaned,
|
|
13909
|
+
warnings
|
|
13910
|
+
}
|
|
13911
|
+
);
|
|
11808
13912
|
}
|
|
11809
13913
|
}
|
|
11810
|
-
|
|
11811
|
-
|
|
11812
|
-
|
|
13914
|
+
];
|
|
13915
|
+
}
|
|
13916
|
+
|
|
13917
|
+
// src/shortcuts/workflow/operations/todoSmartConvert/todoOutputPlanner.ts
|
|
13918
|
+
function mergeWarnings(meta, warnings) {
|
|
13919
|
+
const list = [...new Set((warnings ?? []).filter((item) => typeof item === "string" && item.trim() !== ""))];
|
|
13920
|
+
return list.length > 0 ? { ...meta ?? {}, warnings: list } : meta;
|
|
13921
|
+
}
|
|
13922
|
+
function planTodoOutput(options) {
|
|
13923
|
+
return {
|
|
13924
|
+
data: options.data,
|
|
13925
|
+
meta: mergeWarnings(options.meta, options.warnings)
|
|
13926
|
+
};
|
|
11813
13927
|
}
|
|
11814
13928
|
|
|
13929
|
+
// src/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.collect.ts
|
|
13930
|
+
import { writeFileSync as writeFileSync3 } from "node:fs";
|
|
13931
|
+
import { tmpdir as tmpdir3 } from "node:os";
|
|
13932
|
+
import { join as join6 } from "node:path";
|
|
13933
|
+
|
|
11815
13934
|
// src/shortcuts/workflow/operations/todoSmartConvert/todoSmartConvert.categoryCounts.ts
|
|
11816
13935
|
import { isDeepStrictEqual } from "node:util";
|
|
11817
13936
|
var CATEGORY_TABS = ["0", "7", "5", "8", "6", "1"];
|
|
@@ -12230,7 +14349,7 @@ function cleanFieldText(raw) {
|
|
|
12230
14349
|
text = text.replace(/\{[^{}]{0,800}\}/g, " ");
|
|
12231
14350
|
return text.replace(/\s+/g, " ").trim();
|
|
12232
14351
|
}
|
|
12233
|
-
function
|
|
14352
|
+
function stopReasonOf2(error) {
|
|
12234
14353
|
const structured = error;
|
|
12235
14354
|
if (structured?.type === "network") {
|
|
12236
14355
|
return structured.subtype === "timeout" ? "http_timeout" : "network_error";
|
|
@@ -12239,7 +14358,7 @@ function stopReasonOf(error) {
|
|
|
12239
14358
|
if (structured?.type === "api") return "api_error";
|
|
12240
14359
|
return "unknown_error";
|
|
12241
14360
|
}
|
|
12242
|
-
function
|
|
14361
|
+
function isRetryable2(error) {
|
|
12243
14362
|
const structured = error;
|
|
12244
14363
|
if (structured?.type === "network") return true;
|
|
12245
14364
|
return structured?.retryable === true && structured?.type !== "authentication";
|
|
@@ -12333,13 +14452,13 @@ async function fetchRequestDetailsBatch(env, requestIds, options = {}) {
|
|
|
12333
14452
|
break;
|
|
12334
14453
|
} catch (error) {
|
|
12335
14454
|
lastError = error;
|
|
12336
|
-
if (
|
|
14455
|
+
if (stopReasonOf2(error) === "login_expired") throw error;
|
|
12337
14456
|
attempt += 1;
|
|
12338
|
-
if (attempt > retries || !
|
|
14457
|
+
if (attempt > retries || !isRetryable2(error)) break;
|
|
12339
14458
|
}
|
|
12340
14459
|
}
|
|
12341
14460
|
if (lastError !== void 0) {
|
|
12342
|
-
const reason =
|
|
14461
|
+
const reason = stopReasonOf2(lastError);
|
|
12343
14462
|
failures.push({ requestId, error: reason });
|
|
12344
14463
|
details.set(requestId, {
|
|
12345
14464
|
requestId,
|
|
@@ -12988,6 +15107,8 @@ async function collectRawTodos(args, env) {
|
|
|
12988
15107
|
}
|
|
12989
15108
|
const seen = /* @__PURE__ */ new Set();
|
|
12990
15109
|
const items = [];
|
|
15110
|
+
const keepOrigin = args.originData === true;
|
|
15111
|
+
const originPages = [];
|
|
12991
15112
|
let duplicateCount = 0;
|
|
12992
15113
|
let totalAvailable = null;
|
|
12993
15114
|
let pages = 0;
|
|
@@ -13010,8 +15131,8 @@ async function collectRawTodos(args, env) {
|
|
|
13010
15131
|
if (category === "todo" && !listQuery) listQuery = structuredClone(query);
|
|
13011
15132
|
if (process.env.WEAVER_WORK_CLI_DUMP_LIST_BODY) {
|
|
13012
15133
|
try {
|
|
13013
|
-
|
|
13014
|
-
|
|
15134
|
+
writeFileSync3(
|
|
15135
|
+
join6(tmpdir3(), `weaver-list-body-page${pageNo}.json`),
|
|
13015
15136
|
JSON.stringify({ path: listPath, body: query }, null, 2)
|
|
13016
15137
|
);
|
|
13017
15138
|
} catch {
|
|
@@ -13024,10 +15145,11 @@ async function collectRawTodos(args, env) {
|
|
|
13024
15145
|
body: query
|
|
13025
15146
|
});
|
|
13026
15147
|
pages += 1;
|
|
15148
|
+
if (keepOrigin) originPages.push(structuredClone(response));
|
|
13027
15149
|
if (process.env.WEAVER_WORK_CLI_DUMP_LIST_RESP) {
|
|
13028
15150
|
try {
|
|
13029
|
-
|
|
13030
|
-
|
|
15151
|
+
writeFileSync3(
|
|
15152
|
+
join6(tmpdir3(), `weaver-list-resp-page${pageNo}.json`),
|
|
13031
15153
|
JSON.stringify(response, null, 2)
|
|
13032
15154
|
);
|
|
13033
15155
|
} catch {
|
|
@@ -13312,6 +15434,7 @@ async function collectRawTodos(args, env) {
|
|
|
13312
15434
|
groupInfo,
|
|
13313
15435
|
/** 详情状态;详情由后续阶段按需获取。 */
|
|
13314
15436
|
detailStats,
|
|
15437
|
+
...keepOrigin ? { originData: originPages } : {},
|
|
13315
15438
|
warnings,
|
|
13316
15439
|
markdown: header
|
|
13317
15440
|
};
|
|
@@ -15279,6 +17402,11 @@ var inputSchema = schemaOf({
|
|
|
15279
17402
|
}
|
|
15280
17403
|
},
|
|
15281
17404
|
withDetailContext: { type: "boolean", description: "smartGroup \u662F\u5426\u540C\u8FDB\u7A0B\u751F\u6210\u5355\u6761\u6458\u8981\u4E0A\u4E0B\u6587\u3002" },
|
|
17405
|
+
originData: {
|
|
17406
|
+
type: "boolean",
|
|
17407
|
+
default: false,
|
|
17408
|
+
description: "\u4EC5 collect\uFF1Atrue \u65F6\u5728\u8FD4\u56DE data \u4E2D\u900F\u51FA originData\uFF08\u6BCF\u9875 getTodoListData \u539F\u59CB\u54CD\u5E94\u4F53\u539F\u6837\u6570\u7EC4\uFF0C\u6309\u7FFB\u9875\u987A\u5E8F\uFF09\uFF0C\u4F9B skill \u811A\u672C\u843D\u76D8 originData \u76EE\u5F55\u5E76\u5728\u4EA7\u7269 data.originDataId \u5F15\u7528\uFF1B\u666E\u901A\u67E5\u8BE2\u4E0E\u6458\u8981\u56DE\u586B\u9636\u6BB5\u4E0D\u9700\u8981\u3002"
|
|
17409
|
+
},
|
|
15282
17410
|
withSubGroup: { type: "boolean", description: "summary \u56DE\u586B\u540E\u662F\u5426\u540C\u8FDB\u7A0B\u63A5\u7740\u505A ai \u4E8C\u6B21\u5206\u7EC4\uFF08stage=subGroup \u7B49\u4EF7\uFF09\u3002" },
|
|
15283
17411
|
withGroupSummaryContext: { type: "boolean", description: "summary \u662F\u5426\u540C\u8FDB\u7A0B\u751F\u6210\u7EC4\u6458\u8981\u4E0A\u4E0B\u6587\u3002" },
|
|
15284
17412
|
detailPrefetch: { type: "boolean", description: "\u5E9F\u5F03\u517C\u5BB9\u53C2\u6570\uFF0C\u5DF2\u5FFD\u7565\uFF1Bcollect \u53EA\u5728\u7ED9\u4E86 groupFocus \u4E14\u610F\u56FE\u9002\u7528\u4E8E\u672C\u7EC4\u65F6\u6309\u9700\u9884\u53D6\u5206\u7EC4\u5B57\u6BB5\uFF08\u8D70\u8BE6\u60C5\u7F13\u5B58\uFF09\u3002" },
|
|
@@ -17915,7 +20043,9 @@ function buildRegistry() {
|
|
|
17915
20043
|
...workflowReadOperations,
|
|
17916
20044
|
...workflowFormOperations,
|
|
17917
20045
|
...workflowWriteOperations,
|
|
17918
|
-
...workflowTodoSmartConvertOperations
|
|
20046
|
+
...workflowTodoSmartConvertOperations,
|
|
20047
|
+
...workflowDeepReadOperations(),
|
|
20048
|
+
...workflowDeepReadRenderOperations()
|
|
17919
20049
|
];
|
|
17920
20050
|
for (const definition of definitions) {
|
|
17921
20051
|
if (registry.has(definition.name)) {
|