@stalfh233/omc-cli 0.6.80 → 0.6.82
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/coverage/m1-coverage-manifest-v1.json +7 -2
- package/dist/artifacts.js +28 -5
- package/dist/capability-overview.js +4 -4
- package/dist/cli.js +72 -36
- package/dist/endpoints.js +12 -0
- package/dist/env-export.js +4 -0
- package/dist/human-summary.js +8 -0
- package/dist/lanes/b2-registration-contract.js +11 -0
- package/dist/lanes/b2-registration-coverage.js +1 -0
- package/dist/lanes/businessrule-contract.js +6 -4
- package/dist/lanes/businessrule.js +243 -18
- package/dist/lanes/rule-graph.js +21 -5
- package/dist/lanes/servicelog.js +376 -0
- package/dist/lanes/workflow-contract.js +20 -2
- package/dist/lanes/workflow-coverage.js +2 -0
- package/dist/lanes/workflow.js +478 -25
- package/dist/model-purge.js +12 -3
- package/dist/read-shapes.js +15 -7
- package/dist/recipes/businessrule.js +1 -1
- package/dist/refusal-guidance.js +4 -3
- package/dist/rule-support.js +309 -28
- package/dist/session-account.js +66 -0
- package/dist/tool-search.js +8 -1
- package/dist/tools.js +2 -0
- package/package.json +3 -3
- package/skills/omc-capabilities.md +5 -5
|
@@ -0,0 +1,376 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { ENDPOINTS } from "../endpoints.js";
|
|
4
|
+
import { capabilityArg, environmentArg } from "../args.js";
|
|
5
|
+
import { governedRead } from "../read.js";
|
|
6
|
+
import { writeArtifact } from "../support.js";
|
|
7
|
+
import { defineTool, ToolRefusalError } from "../tool-types.js";
|
|
8
|
+
import { wireCallWith404Fallback } from "../wire.js";
|
|
9
|
+
import { B2_LANE_CONTRACT } from "./b2-registration-contract.js";
|
|
10
|
+
/**
|
|
11
|
+
* Business-service invocation logs (`h_log_biz_service`) — the only place that
|
|
12
|
+
* records what a rule actually sent to an integration endpoint (params), what
|
|
13
|
+
* came back (result) and whether it failed (bizServiceStatus). Wire facts live
|
|
14
|
+
* in B2_LANE_CONTRACT.wire.logFace; the short version:
|
|
15
|
+
*
|
|
16
|
+
* GET /api/log/list_bizservicelog?code&methodName&dataTitle&startTime&endTime&page&size&status
|
|
17
|
+
*
|
|
18
|
+
* `page` is REQUIRED and 0-based (LogManagerController.java:239). The server
|
|
19
|
+
* filters code/methodName as LIKE-contains (comma → IN), dataTitle likewise,
|
|
20
|
+
* `startTime >= startTime` AND `endTime <= endTime`, and always orders
|
|
21
|
+
* startTime DESC. schemaCode/bizObjectId are NOT query parameters on this face
|
|
22
|
+
* (BizServiceLogModel carries them on the row; the controller ignores them), so
|
|
23
|
+
* those two selectors are matched client-side over a bounded number of wire
|
|
24
|
+
* pages and the scan accounting is reported instead of pretending a full scan.
|
|
25
|
+
*
|
|
26
|
+
* A log table grows without bound; an unfiltered query is exactly the 60s
|
|
27
|
+
* socket-timeout trap the manual JDBC route hit. So the tool is fail-closed:
|
|
28
|
+
* no selector → refusal, and the time window defaults to the last 60 minutes.
|
|
29
|
+
*/
|
|
30
|
+
const DEFAULT_WINDOW_MINUTES = 60;
|
|
31
|
+
const DEFAULT_LIMIT = 20;
|
|
32
|
+
const MAX_LIMIT = 100;
|
|
33
|
+
/** Client-side matching (schemaCode/bizObjectId) reads at most this many wire pages. */
|
|
34
|
+
const CLIENT_FILTER_SCAN_PAGES = 5;
|
|
35
|
+
/** One-line params/result summary length. */
|
|
36
|
+
const SUMMARY_CHARS = 240;
|
|
37
|
+
/** Full params/result payloads above this size go to an artifact file. */
|
|
38
|
+
const FULL_PAYLOAD_ARTIFACT_BYTES = 4096;
|
|
39
|
+
const TIME_PATTERN = /^\d{4}-\d{2}-\d{2}(?:[ T]\d{2}:\d{2}(?::\d{2})?)?$/;
|
|
40
|
+
const B2_LANE = B2_LANE_CONTRACT.lane;
|
|
41
|
+
const B2_TOOLS = B2_LANE_CONTRACT.tools;
|
|
42
|
+
const pad = (value) => String(value).padStart(2, "0");
|
|
43
|
+
/** Platform-local wall clock (the log columns are wall-clock strings, no TZ). */
|
|
44
|
+
function formatLocal(date) {
|
|
45
|
+
return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())} ${pad(date.getHours())}:${pad(date.getMinutes())}:${pad(date.getSeconds())}`;
|
|
46
|
+
}
|
|
47
|
+
/** Best-effort parse of the same shapes the wire accepts (date or 19-char datetime). */
|
|
48
|
+
function parseLocal(value) {
|
|
49
|
+
const match = value.match(/^(\d{4})-(\d{2})-(\d{2})(?:[ T](\d{2}):(\d{2})(?::(\d{2}))?)?$/);
|
|
50
|
+
if (!match)
|
|
51
|
+
return undefined;
|
|
52
|
+
const [, year, month, day, hour, minute, second] = match;
|
|
53
|
+
return new Date(Number(year), Number(month) - 1, Number(day), Number(hour ?? 0), Number(minute ?? 0), Number(second ?? 0));
|
|
54
|
+
}
|
|
55
|
+
/** `T` is accepted on input; the platform's DateUtility expects a space. */
|
|
56
|
+
const wireTime = (value) => value.replace("T", " ");
|
|
57
|
+
/** Single-line summary of a free-form log column, with the original byte size. */
|
|
58
|
+
function summarize(value) {
|
|
59
|
+
if (value === null || value === undefined)
|
|
60
|
+
return { text: null, bytes: 0, truncated: false };
|
|
61
|
+
const full = typeof value === "string" ? value : JSON.stringify(value);
|
|
62
|
+
const bytes = Buffer.byteLength(full, "utf8");
|
|
63
|
+
const oneLine = full.replace(/\s+/g, " ").trim();
|
|
64
|
+
if (oneLine.length <= SUMMARY_CHARS)
|
|
65
|
+
return { text: oneLine, bytes, truncated: false };
|
|
66
|
+
return { text: `${oneLine.slice(0, SUMMARY_CHARS)}…`, bytes, truncated: true };
|
|
67
|
+
}
|
|
68
|
+
const RULE_KEYS = ["ruleCode", "ruleName", "nodeCode", "nodeName"];
|
|
69
|
+
/** extensionLog is the caller-supplied trace context (rule/node) in the usual case. */
|
|
70
|
+
function ruleOf(raw) {
|
|
71
|
+
if (raw === null || raw === undefined)
|
|
72
|
+
return undefined;
|
|
73
|
+
const text = typeof raw === "string" ? raw : JSON.stringify(raw);
|
|
74
|
+
if (!text)
|
|
75
|
+
return undefined;
|
|
76
|
+
try {
|
|
77
|
+
const parsed = JSON.parse(text);
|
|
78
|
+
if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
|
|
79
|
+
const picked = {};
|
|
80
|
+
for (const key of RULE_KEYS) {
|
|
81
|
+
const value = parsed[key];
|
|
82
|
+
if (typeof value === "string" && value.length > 0)
|
|
83
|
+
picked[key] = value;
|
|
84
|
+
}
|
|
85
|
+
if (Object.keys(picked).length > 0)
|
|
86
|
+
return picked;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
catch {
|
|
90
|
+
// Fall through: an unparseable extensionLog is still evidence — surface it
|
|
91
|
+
// as a truncated raw string rather than dropping it.
|
|
92
|
+
}
|
|
93
|
+
return { raw: summarize(text).text ?? text };
|
|
94
|
+
}
|
|
95
|
+
const statusOf = (value) => {
|
|
96
|
+
if (value === 1 || value === "1" || value === "FAILURE")
|
|
97
|
+
return { status: "failure", statusName: "失败" };
|
|
98
|
+
if (value === 2 || value === "2" || value === "SUCCESS")
|
|
99
|
+
return { status: "success", statusName: "成功" };
|
|
100
|
+
return { status: null };
|
|
101
|
+
};
|
|
102
|
+
export function registerServiceLogLane(tools) {
|
|
103
|
+
tools.push(defineTool({
|
|
104
|
+
name: "servicelog.search",
|
|
105
|
+
layer: "low",
|
|
106
|
+
kind: "read",
|
|
107
|
+
lane: B2_LANE,
|
|
108
|
+
search: {
|
|
109
|
+
intents: [
|
|
110
|
+
"业务服务日志", "业务服务调用日志", "服务调用日志", "接口调用日志", "调用记录",
|
|
111
|
+
"接口调用记录", "调接口记录", "业务集成日志", "规则传了什么参数", "规则到底传了什么参数",
|
|
112
|
+
"接口传了什么参数", "接口返回了什么",
|
|
113
|
+
],
|
|
114
|
+
},
|
|
115
|
+
scope: B2_TOOLS["servicelog.search"].scope,
|
|
116
|
+
description: B2_TOOLS["servicelog.search"].description,
|
|
117
|
+
inputSchema: {
|
|
118
|
+
environment: environmentArg,
|
|
119
|
+
code: z.string().min(1).optional().describe("业务服务编码(服务侧叫 serviceCode);平台按 LIKE 包含匹配,逗号分隔=精确 IN"),
|
|
120
|
+
methodName: z.string().min(1).optional().describe("业务方法名(LIKE 包含;逗号分隔=精确 IN)"),
|
|
121
|
+
dataTitle: z.string().min(1).optional().describe("数据标题(LIKE 包含)"),
|
|
122
|
+
schemaCode: z.string().min(1).optional().describe("模型编码:平台列表端点没有这个过滤参数,本工具在扫描页内客户端精确匹配"),
|
|
123
|
+
bizObjectId: z.string().min(1).optional().describe("业务对象 id:同上,客户端精确匹配(规则排查最常用)"),
|
|
124
|
+
status: z.union([z.literal(0), z.literal(1), z.literal(2)]).optional().describe("1=失败 2=成功 0=全部(平台只有成功/失败两态)"),
|
|
125
|
+
startTime: z.string().regex(TIME_PATTERN).optional().describe("开始时间:yyyy-MM-dd 或 yyyy-MM-dd HH:mm:ss(平台按 startTime>= 过滤)"),
|
|
126
|
+
endTime: z.string().regex(TIME_PATTERN).optional().describe("结束时间:同上(平台按 endTime<= 过滤)"),
|
|
127
|
+
minutes: z.number().int().min(1).max(1440).optional().describe(`未给时间时向前取多少分钟(默认 ${DEFAULT_WINDOW_MINUTES})`),
|
|
128
|
+
limit: z.number().int().min(1).max(MAX_LIMIT).optional().describe(`每页条数(默认 ${DEFAULT_LIMIT},上限 ${MAX_LIMIT})`),
|
|
129
|
+
page: z.number().int().min(0).optional().describe("wire 页码,从 0 开始(时间倒序的第几页)"),
|
|
130
|
+
capability: capabilityArg,
|
|
131
|
+
},
|
|
132
|
+
handler: async (ctx, args, self) => governedRead(ctx, self, args, async (session) => {
|
|
133
|
+
const hasSelector = args.code !== undefined || args.methodName !== undefined || args.dataTitle !== undefined
|
|
134
|
+
|| args.schemaCode !== undefined || args.bizObjectId !== undefined;
|
|
135
|
+
if (!hasSelector) {
|
|
136
|
+
throw new ToolRefusalError({
|
|
137
|
+
status: "refused",
|
|
138
|
+
blocker: "servicelog-filter-required",
|
|
139
|
+
message: "没有任何过滤条件——业务服务日志表会无限增长,无过滤查询正是全表扫描超时的来源;本工具 fail-closed,不提供「查全部」。至少给 code / methodName / dataTitle / schemaCode / bizObjectId 之一(时间窗默认最近 60 分钟,也可传 startTime/endTime 或 minutes)。",
|
|
140
|
+
nextCommand: `omc call servicelog.search --args '{"bizObjectId":"<单据id>","minutes":60}'`,
|
|
141
|
+
examples: [
|
|
142
|
+
{ why: "规则给这个单据调过哪些接口、传了什么参数", args: { bizObjectId: "<bizObjectId>" } },
|
|
143
|
+
{ why: "某个集成服务最近一小时的失败调用", args: { code: "<服务编码>", status: 1, minutes: 60 } },
|
|
144
|
+
{ why: "按模型 + 方法名缩小", args: { schemaCode: "<模型code>", methodName: "<方法名>", startTime: "2026-01-01 00:00:00", endTime: "2026-01-01 23:59:59" } },
|
|
145
|
+
],
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
const limit = args.limit ?? DEFAULT_LIMIT;
|
|
149
|
+
const startPage = args.page ?? 0;
|
|
150
|
+
const minutes = args.minutes ?? DEFAULT_WINDOW_MINUTES;
|
|
151
|
+
const now = new Date();
|
|
152
|
+
let startTime = args.startTime;
|
|
153
|
+
let endTime = args.endTime;
|
|
154
|
+
let windowSource;
|
|
155
|
+
if (startTime === undefined && endTime === undefined) {
|
|
156
|
+
startTime = formatLocal(new Date(now.getTime() - minutes * 60_000));
|
|
157
|
+
endTime = formatLocal(now);
|
|
158
|
+
windowSource = "default";
|
|
159
|
+
}
|
|
160
|
+
else if (startTime !== undefined && endTime === undefined) {
|
|
161
|
+
endTime = formatLocal(now);
|
|
162
|
+
windowSource = "explicit-start";
|
|
163
|
+
}
|
|
164
|
+
else if (startTime === undefined && endTime !== undefined) {
|
|
165
|
+
const end = parseLocal(endTime);
|
|
166
|
+
startTime = formatLocal(new Date((end ?? now).getTime() - minutes * 60_000));
|
|
167
|
+
windowSource = "explicit-end";
|
|
168
|
+
}
|
|
169
|
+
else {
|
|
170
|
+
windowSource = "explicit";
|
|
171
|
+
}
|
|
172
|
+
const clientFilter = args.schemaCode !== undefined || args.bizObjectId !== undefined;
|
|
173
|
+
const fetchPage = async (page) => {
|
|
174
|
+
const query = {
|
|
175
|
+
page: String(page),
|
|
176
|
+
size: String(limit),
|
|
177
|
+
startTime: wireTime(startTime),
|
|
178
|
+
endTime: wireTime(endTime),
|
|
179
|
+
};
|
|
180
|
+
if (args.code !== undefined)
|
|
181
|
+
query.code = args.code;
|
|
182
|
+
if (args.methodName !== undefined)
|
|
183
|
+
query.methodName = args.methodName;
|
|
184
|
+
if (args.dataTitle !== undefined)
|
|
185
|
+
query.dataTitle = args.dataTitle;
|
|
186
|
+
// status=0 is the平台「全部」值; omitting it keeps the query identical.
|
|
187
|
+
if (args.status !== undefined && args.status !== 0)
|
|
188
|
+
query.status = String(args.status);
|
|
189
|
+
let endpointFamily;
|
|
190
|
+
const result = await wireCallWith404Fallback(session, [
|
|
191
|
+
{ path: ENDPOINTS.bizServiceLogList, query },
|
|
192
|
+
{ path: ENDPOINTS.bizServiceLogListSinglePrefix, query },
|
|
193
|
+
], (failed, next) => { endpointFamily = { used: next.path, reason: `${failed.path} HTTP 404(该部署只在单前缀挂载日志控制器,已下探)` }; });
|
|
194
|
+
const envelope = result.data;
|
|
195
|
+
const content = envelope && Array.isArray(envelope.content)
|
|
196
|
+
? envelope.content.filter((row) => Boolean(row) && typeof row === "object")
|
|
197
|
+
: [];
|
|
198
|
+
return {
|
|
199
|
+
content,
|
|
200
|
+
totalElements: typeof envelope?.totalElements === "number" ? envelope.totalElements : null,
|
|
201
|
+
totalPages: typeof envelope?.totalPages === "number" ? envelope.totalPages : null,
|
|
202
|
+
endpointFamily,
|
|
203
|
+
path: result.path,
|
|
204
|
+
};
|
|
205
|
+
};
|
|
206
|
+
const matches = (row) => (args.schemaCode === undefined || row.schemaCode === args.schemaCode)
|
|
207
|
+
&& (args.bizObjectId === undefined || row.bizObjectId === args.bizObjectId);
|
|
208
|
+
let rows = [];
|
|
209
|
+
let totalElements = null;
|
|
210
|
+
let totalPages = null;
|
|
211
|
+
let wireCalls = 0;
|
|
212
|
+
let rowsFetched = 0;
|
|
213
|
+
let endpointFamily;
|
|
214
|
+
let usedPath = ENDPOINTS.bizServiceLogList;
|
|
215
|
+
let rowFilter;
|
|
216
|
+
if (!clientFilter) {
|
|
217
|
+
const page = await fetchPage(startPage);
|
|
218
|
+
wireCalls = 1;
|
|
219
|
+
rowsFetched = page.content.length;
|
|
220
|
+
rows = page.content;
|
|
221
|
+
totalElements = page.totalElements;
|
|
222
|
+
totalPages = page.totalPages;
|
|
223
|
+
endpointFamily = page.endpointFamily;
|
|
224
|
+
usedPath = page.path;
|
|
225
|
+
}
|
|
226
|
+
else {
|
|
227
|
+
// Wire paging is startTime DESC; scan a bounded page window from `page`
|
|
228
|
+
// and match the two row-only selectors locally. `exhausted:false` says
|
|
229
|
+
// the scan stopped before the end — never read it as "no such call".
|
|
230
|
+
const matched = [];
|
|
231
|
+
let scannedPages = 0;
|
|
232
|
+
let scannedElements = 0;
|
|
233
|
+
let exhausted = false;
|
|
234
|
+
let moreLikely = false;
|
|
235
|
+
for (let offset = 0; offset < CLIENT_FILTER_SCAN_PAGES; offset += 1) {
|
|
236
|
+
const page = await fetchPage(startPage + offset);
|
|
237
|
+
wireCalls += 1;
|
|
238
|
+
scannedPages += 1;
|
|
239
|
+
totalElements = page.totalElements;
|
|
240
|
+
totalPages = page.totalPages;
|
|
241
|
+
endpointFamily = page.endpointFamily ?? endpointFamily;
|
|
242
|
+
usedPath = page.path;
|
|
243
|
+
scannedElements += page.content.length;
|
|
244
|
+
rowsFetched += page.content.length;
|
|
245
|
+
for (const row of page.content)
|
|
246
|
+
if (matches(row))
|
|
247
|
+
matched.push(row);
|
|
248
|
+
if (matched.length >= limit) {
|
|
249
|
+
moreLikely = true;
|
|
250
|
+
break;
|
|
251
|
+
}
|
|
252
|
+
const noNextPage = page.totalPages !== null && startPage + offset + 1 >= page.totalPages;
|
|
253
|
+
if (page.content.length < limit || noNextPage) {
|
|
254
|
+
exhausted = true;
|
|
255
|
+
break;
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
rows = matched.slice(0, limit);
|
|
259
|
+
rowFilter = {
|
|
260
|
+
...(args.schemaCode !== undefined ? { schemaCode: args.schemaCode } : {}),
|
|
261
|
+
...(args.bizObjectId !== undefined ? { bizObjectId: args.bizObjectId } : {}),
|
|
262
|
+
matched: matched.length,
|
|
263
|
+
returned: rows.length,
|
|
264
|
+
scannedPages,
|
|
265
|
+
scannedElements,
|
|
266
|
+
exhausted,
|
|
267
|
+
...(moreLikely ? { moreLikely: true } : {}),
|
|
268
|
+
...(matched.length > rows.length ? { truncatedMatches: matched.length - rows.length } : {}),
|
|
269
|
+
};
|
|
270
|
+
}
|
|
271
|
+
const full = [];
|
|
272
|
+
let fullPayloadBytes = 0;
|
|
273
|
+
const logs = rows.map((row) => {
|
|
274
|
+
const params = summarize(row.params);
|
|
275
|
+
const result = summarize(row.result);
|
|
276
|
+
const detail = typeof row.detail === "string" && row.detail.length > 0 ? summarize(row.detail) : undefined;
|
|
277
|
+
fullPayloadBytes += params.bytes + result.bytes;
|
|
278
|
+
full.push({ id: row.id ?? null, startTime: row.startTime ?? null, code: row.code ?? null, methodName: row.methodName ?? null, params: row.params ?? null, result: row.result ?? null });
|
|
279
|
+
const status = statusOf(row.bizServiceStatus);
|
|
280
|
+
const rule = ruleOf(row.extensionLog);
|
|
281
|
+
return {
|
|
282
|
+
startTime: row.startTime ?? null,
|
|
283
|
+
...(typeof row.endTime === "string" && row.endTime !== row.startTime ? { endTime: row.endTime } : {}),
|
|
284
|
+
usedTime: row.usedTime ?? null,
|
|
285
|
+
code: row.code ?? null,
|
|
286
|
+
methodName: row.methodName ?? null,
|
|
287
|
+
status: status.status,
|
|
288
|
+
...(typeof row.bizServiceStatusName === "string" ? { statusName: row.bizServiceStatusName } : {}),
|
|
289
|
+
dataTitle: row.dataTitle ?? null,
|
|
290
|
+
schemaCode: row.schemaCode ?? null,
|
|
291
|
+
bizObjectId: row.bizObjectId ?? null,
|
|
292
|
+
...(rule ? { rule } : {}),
|
|
293
|
+
params: params.text,
|
|
294
|
+
paramsBytes: params.bytes,
|
|
295
|
+
...(params.truncated ? { paramsTruncated: true } : {}),
|
|
296
|
+
result: result.text,
|
|
297
|
+
resultBytes: result.bytes,
|
|
298
|
+
...(result.truncated ? { resultTruncated: true } : {}),
|
|
299
|
+
...(detail ? { detail: detail.text, ...(detail.truncated ? { detailTruncated: true } : {}) } : {}),
|
|
300
|
+
};
|
|
301
|
+
});
|
|
302
|
+
// Full params/result over the threshold leave the envelope; the summary
|
|
303
|
+
// above already answers "what did the rule send" for normal payloads.
|
|
304
|
+
let payload;
|
|
305
|
+
if (fullPayloadBytes > FULL_PAYLOAD_ARTIFACT_BYTES) {
|
|
306
|
+
const artifact = writeArtifact(ctx, `servicelog-${randomUUID().slice(0, 8)}.json`, {
|
|
307
|
+
window: { startTime, endTime },
|
|
308
|
+
rows: full,
|
|
309
|
+
});
|
|
310
|
+
payload = {
|
|
311
|
+
payloadFile: artifact.detailFile,
|
|
312
|
+
payloadSha256: artifact.detailSha256,
|
|
313
|
+
payloadBytes: fullPayloadBytes,
|
|
314
|
+
payloadHint: `完整 params/result 共 ${fullPayloadBytes}B 已外置(单行摘要见 logs);用 jq 定向取回(例如 jq '.rows[0].params' <payloadFile>),勿整份读入。params 侧平台入库上限 2000 字符。`,
|
|
315
|
+
};
|
|
316
|
+
}
|
|
317
|
+
const returned = logs.length;
|
|
318
|
+
const hasMore = clientFilter
|
|
319
|
+
? (rowFilter?.exhausted === false || rowFilter?.moreLikely === true)
|
|
320
|
+
: (totalPages !== null ? startPage + wireCalls < totalPages : null);
|
|
321
|
+
const nextPage = clientFilter
|
|
322
|
+
? (rowFilter?.exhausted === false && rowFilter.moreLikely !== true ? startPage + wireCalls : undefined)
|
|
323
|
+
: (hasMore === true ? startPage + 1 : undefined);
|
|
324
|
+
const notes = [
|
|
325
|
+
"服务端过滤 code/methodName(LIKE 包含,逗号=精确 IN)、dataTitle、时间(startTime>= 且 endTime<= 两列)、status;schemaCode/bizObjectId 不在平台列表参数里,本工具在扫描页内客户端匹配。",
|
|
326
|
+
"日志异步落库(刚触发的调用可能晚数秒才可见);历史按平台保留天数清理。params 入库上限 2000 字符(更长的部分平台已截断),result 无此上限但可能很大。",
|
|
327
|
+
windowSource === "default"
|
|
328
|
+
? `未给时间,默认窗口最近 ${minutes} 分钟(本机时钟,与平台同时区才可直接用;跨时区请显式 startTime/endTime)。`
|
|
329
|
+
: "时间窗为显式传入(按字符串原样上送;平台按 startTime>=、endTime<= 两列过滤)。",
|
|
330
|
+
...(clientFilter ? [`schemaCode/bizObjectId 是客户端匹配:最多扫 ${CLIENT_FILTER_SCAN_PAGES} 个 wire 页(约 ${limit * CLIENT_FILTER_SCAN_PAGES} 行),exhausted:false 表示扫描被上限截断——未命中不代表没有更早的调用。`] : []),
|
|
331
|
+
...(typeof rowFilter?.truncatedMatches === "number" ? [`扫描到的命中数(${String(rowFilter.matched)})超过 limit,只回前 ${returned} 条——提高 limit 重查;page 是 wire 页码(时间倒序),不是命中偏移。`] : []),
|
|
332
|
+
...(endpointFamily ? [`端点下探:${endpointFamily.reason}`] : []),
|
|
333
|
+
...(payload ? [payload.payloadHint] : []),
|
|
334
|
+
];
|
|
335
|
+
const emptyHint = returned === 0
|
|
336
|
+
? "0 条先核对:① code 是 LIKE 包含匹配(crm_expiry 能命中 crm_expiry_service);② 日志异步落库,稍后重试;③ 时间窗/时区是否覆盖到;④ schemaCode/bizObjectId 是客户端匹配、且扫描有页数上限。"
|
|
337
|
+
: undefined;
|
|
338
|
+
return {
|
|
339
|
+
window: { startTime, endTime, minutes, source: windowSource },
|
|
340
|
+
filters: {
|
|
341
|
+
...(args.code !== undefined ? { code: args.code } : {}),
|
|
342
|
+
...(args.methodName !== undefined ? { methodName: args.methodName } : {}),
|
|
343
|
+
...(args.dataTitle !== undefined ? { dataTitle: args.dataTitle } : {}),
|
|
344
|
+
...(args.status !== undefined ? { status: args.status } : {}),
|
|
345
|
+
...(args.schemaCode !== undefined ? { schemaCode: args.schemaCode } : {}),
|
|
346
|
+
...(args.bizObjectId !== undefined ? { bizObjectId: args.bizObjectId } : {}),
|
|
347
|
+
},
|
|
348
|
+
paging: {
|
|
349
|
+
page: startPage,
|
|
350
|
+
size: limit,
|
|
351
|
+
totalElements,
|
|
352
|
+
totalPages,
|
|
353
|
+
returned,
|
|
354
|
+
hasMore,
|
|
355
|
+
...(nextPage !== undefined ? { nextPage } : {}),
|
|
356
|
+
...(nextPage !== undefined ? { nextCommand: `omc call servicelog.search --args '${JSON.stringify({ ...plannableFilters(args), page: nextPage })}'` } : {}),
|
|
357
|
+
},
|
|
358
|
+
...(rowFilter ? { rowFilter } : {}),
|
|
359
|
+
logs,
|
|
360
|
+
...(emptyHint ? { emptyHint } : {}),
|
|
361
|
+
notes,
|
|
362
|
+
wire: { path: usedPath, calls: wireCalls, rowsFetched },
|
|
363
|
+
...(payload ?? {}),
|
|
364
|
+
};
|
|
365
|
+
}, { target: `servicelog.search:${JSON.stringify(args)}` }),
|
|
366
|
+
}));
|
|
367
|
+
}
|
|
368
|
+
/** Echo the human filters into the copyable next command (never the paging/window defaults). */
|
|
369
|
+
function plannableFilters(args) {
|
|
370
|
+
const picked = {};
|
|
371
|
+
for (const key of ["code", "methodName", "dataTitle", "status", "schemaCode", "bizObjectId", "startTime", "endTime", "limit"])
|
|
372
|
+
if (args[key] !== undefined)
|
|
373
|
+
picked[key] = args[key];
|
|
374
|
+
return picked;
|
|
375
|
+
}
|
|
376
|
+
//# sourceMappingURL=servicelog.js.map
|
|
@@ -69,6 +69,7 @@ export const WORKFLOW_WIRE = Object.freeze({
|
|
|
69
69
|
authoringChain: "workflow.create (header) → workflow.update (write draft template) → workflow.publish",
|
|
70
70
|
bindPoint: "startEventHandler|cancelEventHandler|activateEventHandler|endEventHandler{bizActions:[<ruleCode>], bizActionType:\"BIZ_RULE\"} (flow level; NODE level = activities[<activityCode>].{beforeActivate|afterActivate|endActivity|cancelActivity|activityApproved|activityRejected|jobSubmitted|jobRejected} with the same ActivityEventHandler shape)",
|
|
71
71
|
bindRuleChain: "workflow.bindRule reads the draft, merges the handler selected by `handler` (start|cancel|activate|end, default end — flow level) or by `activityCode` + `nodeEvent` (node level), workflow/update, then workflow/publish + published-face readback",
|
|
72
|
+
unbindRuleChain: "workflow.unbindRule mirrors workflow.bindRule's two target forms and REMOVES the listed ruleCodes from the handler's bizActions (others preserved); an emptied handler is written back as the platform's canonical unbound shape — handler object kept, bizActions/bizActionType null (WorkflowTemplateController's own template JSON; CollectionUtils.isEmpty treats null and [] alike). Absent codes are refused with the handler's existing codes (workflow-unbind-rule-absent). It NEVER disables the rule (it may be bound elsewhere — check rule.references kind=rule first).",
|
|
72
73
|
renderCompat: "workflow.update/publish/bindRule fail closed on 8.6.26 ActivityType values, unique non-empty activityCode values, rules references, and non-empty `x, y` points; missing points are derived from activity geometry and every write readback carries workflowRenderCompat with activities, rules, START/END, points, and danglingViolations",
|
|
73
74
|
bindRuleScope: "flow level: all four WorkflowTemplateModel event handlers (startEventHandler/cancelEventHandler/activateEventHandler/endEventHandler), each an ActivityEventHandler carrying bizActions + bizActionType=BIZ_RULE; `handler` defaults to end. node level: the eight ActivityEventHandler fields on each activity row (beforeActivate/afterActivate/endActivity/cancelActivity/activityApproved/activityRejected/jobSubmitted/jobRejected), selected by `activityCode` + `nodeEvent`",
|
|
74
75
|
boundRuleMustBeEnabled: "流程事件绑定的规则**必须启用**:禁用/未发布的规则(rule.save 落 DRAFT/DISABLED 态)绑到事件处理器后设计器显示「失效·未启用」且事件不会执行它(真机 2026-10-08 SCM 沙盒)。workflow.bindRule 会先把绑定的自定义规则 publish+enable(rule.enable 链,回读 enabledRuleCodes/alreadyEnabledRuleCodes),并对不存在的 code 报 workflow-bind-rule-absent",
|
|
@@ -108,6 +109,7 @@ export const WORKFLOW_LANE_CONTRACT = Object.freeze({
|
|
|
108
109
|
authoringChain: WORKFLOW_WIRE.authoringChain,
|
|
109
110
|
bindPoint: WORKFLOW_WIRE.bindPoint,
|
|
110
111
|
bindRuleChain: WORKFLOW_WIRE.bindRuleChain,
|
|
112
|
+
unbindRuleChain: WORKFLOW_WIRE.unbindRuleChain,
|
|
111
113
|
renderCompat: WORKFLOW_WIRE.renderCompat,
|
|
112
114
|
bindRuleScope: WORKFLOW_WIRE.bindRuleScope,
|
|
113
115
|
boundRuleMustBeEnabled: WORKFLOW_WIRE.boundRuleMustBeEnabled,
|
|
@@ -128,6 +130,7 @@ export const WORKFLOW_LANE_CONTRACT = Object.freeze({
|
|
|
128
130
|
authoringChain: Object.freeze([behaviorBinding("test/ticket-112-workflow-template-merge.test.ts#workflow.publish also merges onto the draft", assertWorkflowContract)]),
|
|
129
131
|
bindPoint: Object.freeze([emitterBinding("lanes/workflow-contract.WORKFLOW_EVENT_HANDLER_FIELDS", assertWorkflowContract)]),
|
|
130
132
|
bindRuleChain: Object.freeze([behaviorBinding("test/issue-14-workflow-bind-rule.test.ts#workflow.bindRule merges endEventHandler", assertWorkflowContract)]),
|
|
133
|
+
unbindRuleChain: Object.freeze([behaviorBinding("test/r85-workflow-unbind.test.ts#r85 unbind:flow 级解绑——命中/保留他绑/移空 canonical 态/absent 拒(issue 01)", assertWorkflowContract)]),
|
|
131
134
|
renderCompat: Object.freeze([behaviorBinding("test/ticket-112-workflow-template-merge.test.ts#workflow shorthand maps legal activities and derives points into workflowRenderCompat", assertWorkflowContract)]),
|
|
132
135
|
bindRuleScope: Object.freeze([behaviorBinding("test/issue-14-workflow-bind-rule.test.ts#workflow.bindRule binds start/cancel/end handlers independently", assertWorkflowContract)]),
|
|
133
136
|
boundRuleMustBeEnabled: Object.freeze([behaviorBinding("test/issue-14-workflow-bind-rule.test.ts#workflow.bindRule ENABLES a bound custom rule", assertWorkflowContract)]),
|
|
@@ -154,7 +157,14 @@ export const WORKFLOW_LANE_CONTRACT = Object.freeze({
|
|
|
154
157
|
}),
|
|
155
158
|
"workflow.get_published": Object.freeze({
|
|
156
159
|
scope: WORKFLOW_SCOPE,
|
|
157
|
-
description: "Read the current PUBLISHED workflow template (`/api/api/workflow/get_published`). **默认返回 workflowSummary(activities + ruleBindings),不是整份正文**;节点级规则绑定按活动投影在 `workflowSummary.activities[].bizActions`({节点事件:[规则码]};流程级看 ruleBindings
|
|
160
|
+
description: "Read the current PUBLISHED workflow template (`/api/api/workflow/get_published`). **默认返回 workflowSummary(activities + ruleBindings),不是整份正文**;节点级规则绑定按活动投影在 `workflowSummary.activities[].bizActions`({节点事件:[规则码]};流程级看 ruleBindings),SYSTEM_ACTIVITY 顶层绑定(规则绑在系统活动节点本身、激活时执行)看 `activities[].systemBizActions`——三个面看完再下「没绑」结论。完整正文加 --full,或 `--jq 'data.activities[code=<活动>].<节点事件>.bizActions'` 这类**叶子**路径——对父节点 data.activities 取值会再次被折叠。在 workflow.publish / workflow.bindRule 之后用它确认发布后的绑定点。",
|
|
161
|
+
}),
|
|
162
|
+
// R79 三期 T-A:应用内流程清单(注意:不能放在 tools 的首位——
|
|
163
|
+
// lane-contracts 的 assertDescriptionsDerive 用首个 tool 的 scope 匹配契约
|
|
164
|
+
// markdown,首位必须是 workflow.get_draft 的 WORKFLOW_SCOPE)。
|
|
165
|
+
"workflow.list": Object.freeze({
|
|
166
|
+
scope: "application workflow inventory (model-indexed)",
|
|
167
|
+
description: "应用内流程清单。平台**没有**流程模板清单端点——本面以模型为索引(平台惯例每模型至多一条流程;workflowCode 通常是 `<模型code>_flow`,以逐模型解析为准):应用树取模型 → 逐模型解析流程(isworkflow→getWorkflow)→ 读 get_published 摘要。行 `{modelCode,workflowCode,exists,published,ruleBindingCount}`;无流程的模型如实列 exists:false(不是错误),ruleBindingCount 含 flow 级 handler 与节点级事件绑定的规则码总数。上限 50 模型:超出回 partial + omittedModels,点查用 workflow.get_published {schemaCode}。查某条规则被哪些流程绑定用 rule.references kind=rule。",
|
|
158
168
|
}),
|
|
159
169
|
"workflow.create": Object.freeze({
|
|
160
170
|
scope: WORKFLOW_SCOPE,
|
|
@@ -174,7 +184,11 @@ export const WORKFLOW_LANE_CONTRACT = Object.freeze({
|
|
|
174
184
|
}),
|
|
175
185
|
"workflow.bindRule": Object.freeze({
|
|
176
186
|
scope: WORKFLOW_SCOPE,
|
|
177
|
-
description: "Bind a business rule to one of a workflow's event handlers (BIZ_RULE). **Flow level**: `handler` = `start`→startEventHandler, `cancel`→cancelEventHandler, `activate`→activateEventHandler, `end`→endEventHandler (default `end`). **Node level**(节点级事件): pass `activityCode` + `nodeEvent` instead of `handler`, one of `beforeActivate|afterActivate|endActivity|cancelActivity|activityApproved|activityRejected|jobSubmitted|jobRejected` (e.g. `{activityCode:\"Activity2\",nodeEvent:\"endActivity\"}` = 申请人提交离开该节点时). The two forms are mutually exclusive; `nodeEvent` without `activityCode`, or a code absent from the draft, is refused with the available codes. Reads the draft, merges `{ bizActions:[<ruleCode>], bizActionType:\"BIZ_RULE\" }` into the selected handler(节点级写到 `activities[i][nodeEvent]`,其余字段原样保留), writes via `/api/api/workflow/update`, publishes, and reads back the published face. **A workflow-bound rule MUST be enabled**(rule.save 落 DRAFT/DISABLED 的规则绑上后设计器显示「失效·未启用」且事件不执行它):本工具先把自定义规则 publish+enable,回读 `enabledRuleCodes`/`alreadyEnabledRuleCodes`;不存在的 code 报 `workflow-bind-rule-absent`。四个 flow handler 是 WorkflowTemplateModel 上同构的 ActivityEventHandler 字段。Pass `publish:false` to leave the template draft-only.",
|
|
187
|
+
description: "Bind a business rule to one of a workflow's event handlers (BIZ_RULE). **Flow level**: `handler` = `start`→startEventHandler, `cancel`→cancelEventHandler, `activate`→activateEventHandler, `end`→endEventHandler (default `end`). **Node level**(节点级事件): pass `activityCode` + `nodeEvent` instead of `handler`, one of `beforeActivate|afterActivate|endActivity|cancelActivity|activityApproved|activityRejected|jobSubmitted|jobRejected` (e.g. `{activityCode:\"Activity2\",nodeEvent:\"endActivity\"}` = 申请人提交离开该节点时). The two forms are mutually exclusive; `nodeEvent` without `activityCode`, or a code absent from the draft, is refused with the available codes. Reads the draft, merges `{ bizActions:[<ruleCode>], bizActionType:\"BIZ_RULE\" }` into the selected handler(节点级写到 `activities[i][nodeEvent]`,其余字段原样保留), writes via `/api/api/workflow/update`, publishes, and reads back the published face. **A workflow-bound rule MUST be enabled**(rule.save 落 DRAFT/DISABLED 的规则绑上后设计器显示「失效·未启用」且事件不执行它):本工具先把自定义规则 publish+enable,回读 `enabledRuleCodes`/`alreadyEnabledRuleCodes`;不存在的 code 报 `workflow-bind-rule-absent`。四个 flow handler 是 WorkflowTemplateModel 上同构的 ActivityEventHandler 字段。Pass `publish:false` to leave the template draft-only. 误绑撤销用 `workflow.unbindRule`(镜像本工具的两种目标形态做减法)。",
|
|
188
|
+
}),
|
|
189
|
+
"workflow.unbindRule": Object.freeze({
|
|
190
|
+
scope: WORKFLOW_SCOPE,
|
|
191
|
+
description: "Unbind business rules from a workflow event handler — the inverse of `workflow.bindRule`(bindRule 是 merge 语义,误绑此前只能导出整模板手改回写). Same two target forms: `handler`(flow 级 start|cancel|activate|end,缺省 end)或 `activityCode` + `nodeEvent`(八节点事件,与 bindRule 同枚举),二选一。从目标 handler 的 bizActions 里**只移除列出的 ruleCode(s)**,其余绑定原样保留;移空后按平台 canonical 未绑态写回(handler 对象保留、bizActions/bizActionType 置 null——平台判空 null 与 [] 等价)。ruleCode 不在该 handler 时报 `workflow-unbind-rule-absent`(带现有 codes)。**不自动 disable 规则**——规则可能还被其它流程/事件绑定着;确认无引用先 `rule.references kind=rule`,要停用再单独 `rule.disable`。写路径与 bindRule 同构:get_draft → workflow/update → publish → get_published 读回。Pass `publish:false` to leave the template draft-only.",
|
|
178
192
|
}),
|
|
179
193
|
"workflow.delete": Object.freeze({
|
|
180
194
|
scope: WORKFLOW_SCOPE,
|
|
@@ -248,12 +262,14 @@ export function assertWorkflowContract() {
|
|
|
248
262
|
if (!WORKFLOW_WIRE.renderCompat.includes("workflowRenderCompat"))
|
|
249
263
|
throw new Error("workflow contract must pin workflow render compatibility readback");
|
|
250
264
|
assertDescriptionCarries(WORKFLOW_LANE_CONTRACT, "workflow.get_draft", ["get_draft", "endEventHandler"]);
|
|
265
|
+
assertDescriptionCarries(WORKFLOW_LANE_CONTRACT, "workflow.list", ["模型为索引", "exists:false", "ruleBindingCount", "50", "kind=rule", "partial"]);
|
|
251
266
|
assertDescriptionCarries(WORKFLOW_LANE_CONTRACT, "workflow.get_published", ["get_published", "workflow.publish"]);
|
|
252
267
|
assertDescriptionCarries(WORKFLOW_LANE_CONTRACT, "workflow.create", ["workflow/create", "workflow.update", "workflow.publish"]);
|
|
253
268
|
assertDescriptionCarries(WORKFLOW_LANE_CONTRACT, "workflow.update", ["workflow/update", "template", "rules", "activityType", "propertyPermissions", "CLI_ARGS_MAX_BYTES", "workflow-merge-would-drop-routes"]);
|
|
254
269
|
assertDescriptionCarries(WORKFLOW_LANE_CONTRACT, "workflow.publish", ["workflow/publish", "template"]);
|
|
255
270
|
assertDescriptionCarries(WORKFLOW_LANE_CONTRACT, "workflow.setButtons", ["buttonPermission", "customBtns", "childTableBtns", "formButtonCodes", "form-button-absent", "publish:false"]);
|
|
256
271
|
assertDescriptionCarries(WORKFLOW_LANE_CONTRACT, "workflow.bindRule", ["startEventHandler", "cancelEventHandler", "activateEventHandler", "endEventHandler", "bizActions", "bizActionType", "BIZ_RULE", "publish:false", "enabledRuleCodes", "workflow-bind-rule-absent", "activityCode", "nodeEvent", "endActivity", "activityApproved"]);
|
|
272
|
+
assertDescriptionCarries(WORKFLOW_LANE_CONTRACT, "workflow.unbindRule", ["bizActions", "workflow-unbind-rule-absent", "publish:false", "activityCode", "nodeEvent", "rule.disable", "rule.references"]);
|
|
257
273
|
assertDescriptionCarries(WORKFLOW_LANE_CONTRACT, "workflow.permissions", ["list_permission", "40009", "PART_VISIABLE"]);
|
|
258
274
|
assertDescriptionCarries(WORKFLOW_LANE_CONTRACT, "workflow.addPermission", ["create_permission", "unitType", "unitId"]);
|
|
259
275
|
assertDescriptionCarries(WORKFLOW_LANE_CONTRACT, "workflow.removePermission", ["delete_permission", "permissionId"]);
|
|
@@ -292,6 +308,8 @@ export function assertWorkflowContract() {
|
|
|
292
308
|
throw new Error("workflow contract must pin the authoring chain ending in publish");
|
|
293
309
|
if (!WORKFLOW_WIRE.bindRuleChain.includes("workflow/update"))
|
|
294
310
|
throw new Error("workflow contract must pin the bind-rule write step");
|
|
311
|
+
if (!WORKFLOW_WIRE.unbindRuleChain.includes("workflow-unbind-rule-absent") || !WORKFLOW_WIRE.unbindRuleChain.includes("NEVER disables"))
|
|
312
|
+
throw new Error("workflow contract must pin the unbind-rule absent refusal and the no-auto-disable rule");
|
|
295
313
|
if (!WORKFLOW_WIRE.bindRuleScope.includes("startEventHandler") || !WORKFLOW_WIRE.bindRuleScope.includes("endEventHandler"))
|
|
296
314
|
throw new Error("workflow contract must pin the full event-handler scope");
|
|
297
315
|
if (!WORKFLOW_WIRE.boundRuleMustBeEnabled.includes("必须启用") || !WORKFLOW_WIRE.boundRuleMustBeEnabled.includes("rule.enable"))
|
|
@@ -10,12 +10,14 @@ export const WORKFLOW_COVERAGE = declareLaneCoverage(WORKFLOW_LANE_CONTRACT.lane
|
|
|
10
10
|
"r11 2026-10-23 (1.1.25): node form-button visibility = activity.buttonPermission.customBtns[].enabled; ActionPermissionHandler.setProcessButtonPermission filters FORM buttons by it (Playwright + backend source)",
|
|
11
11
|
],
|
|
12
12
|
tools: [
|
|
13
|
+
claim("workflow.list", T["workflow.list"].scope),
|
|
13
14
|
claim("workflow.get_draft", T["workflow.get_draft"].scope),
|
|
14
15
|
claim("workflow.get_published", T["workflow.get_published"].scope),
|
|
15
16
|
claim("workflow.create", T["workflow.create"].scope),
|
|
16
17
|
claim("workflow.update", T["workflow.update"].scope),
|
|
17
18
|
claim("workflow.publish", T["workflow.publish"].scope),
|
|
18
19
|
claim("workflow.bindRule", T["workflow.bindRule"].scope),
|
|
20
|
+
claim("workflow.unbindRule", T["workflow.unbindRule"].scope),
|
|
19
21
|
claim("workflow.setButtons", T["workflow.setButtons"].scope),
|
|
20
22
|
claim("workflow.delete", T["workflow.delete"].scope),
|
|
21
23
|
claim("workflow.permissions", T["workflow.permissions"].scope),
|