@stalfh233/omc-cli 0.8.32 → 0.8.33
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/arg-vocabulary.js +223 -0
- package/dist/artifact-cmd.js +443 -0
- package/dist/batch-call.js +56 -3
- package/dist/call-command.js +70 -0
- package/dist/call-execute.js +228 -0
- package/dist/call-input.js +557 -0
- package/dist/call-output.js +240 -0
- package/dist/cli.js +13 -1359
- package/dist/command-transport.js +4 -1
- package/dist/form-support.js +14 -3
- package/dist/intent/plan-apply.js +14 -24
- package/dist/lanes/datarule.js +21 -0
- package/dist/lanes/field.js +31 -0
- package/dist/lanes/list-view-shapes.js +8 -1
- package/dist/lanes/list-view.js +64 -2
- package/dist/lanes/runtime-data/aggregate-support.js +209 -0
- package/dist/lanes/runtime-data/aggregate.js +679 -0
- package/dist/lanes/runtime-data/field-options.js +52 -0
- package/dist/lanes/runtime-data/lane.js +4 -0
- package/dist/lanes/runtime-data/record-delete.js +419 -0
- package/dist/lanes/runtime-data/record-read.js +984 -0
- package/dist/lanes/runtime-data/record-write.js +562 -0
- package/dist/lanes/runtime-data/registration.js +22 -0
- package/dist/lanes/runtime-data/shapes.js +594 -0
- package/dist/lanes/runtime-data/submission.js +1293 -0
- package/dist/lanes/runtime-data/write-support.js +875 -0
- package/dist/lanes/runtime-data.js +10 -5590
- package/dist/lanes/workflow/approval-ops.js +983 -0
- package/dist/lanes/workflow/instance-read.js +284 -0
- package/dist/lanes/workflow/lifecycle-write.js +1499 -0
- package/dist/lanes/workflow/permissions.js +571 -0
- package/dist/lanes/workflow/recovery.js +361 -0
- package/dist/lanes/workflow/registration.js +14 -0
- package/dist/lanes/workflow/shapes.js +811 -0
- package/dist/lanes/workflow/template-fetch.js +197 -0
- package/dist/lanes/workflow/template-merge.js +1351 -0
- package/dist/lanes/workflow/template-read.js +327 -0
- package/dist/lanes/workflow.js +11 -6312
- package/dist/read-projection.js +442 -0
- package/dist/read.js +40 -335
- package/dist/rollback.js +17 -23
- package/dist/runtime-support.js +1 -1
- package/dist/verification.js +39 -0
- package/dist/write-coordinator.js +152 -0
- package/dist/write-outcome.js +295 -0
- package/dist/write.js +34 -115
- package/package.json +3 -3
- package/skills/omc-refusals.md +1 -1
- package/skills/omc-start-here.md +2 -2
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { ENDPOINTS } from "../../endpoints.js";
|
|
3
|
+
import { capabilityArg, environmentArg } from "../../args.js";
|
|
4
|
+
import { governedRead } from "../../read.js";
|
|
5
|
+
import { ToolRefusalError, defineTool } from "../../tool-types.js";
|
|
6
|
+
import { wireCall, WireError } from "../../wire.js";
|
|
7
|
+
import { diagnoseInstanceActivity, getInstanceBaseInfo, listInstanceActivities, listWorkItemsByParticipant, resolveBizObjectIdByInstance, searchWorkItems, wireString } from "../../workflow-support.js";
|
|
8
|
+
import { resolvePermissionActor } from "../../identity.js";
|
|
9
|
+
import { WORKFLOW_LANE, WORKFLOW_TOOLS, workItemListCompactProjection } from "./shapes.js";
|
|
10
|
+
import { participantFallbackWarnings } from "./recovery.js";
|
|
11
|
+
export function registerInstanceReadTools(tools) {
|
|
12
|
+
tools.push(defineTool({
|
|
13
|
+
name: "workitem.list",
|
|
14
|
+
search: { intents: ["查我的待办", "我的待办", "待办列表", "查待办", "等审批"] },
|
|
15
|
+
layer: "low",
|
|
16
|
+
kind: "read",
|
|
17
|
+
lane: WORKFLOW_LANE,
|
|
18
|
+
scope: WORKFLOW_TOOLS["workitem.list"].scope,
|
|
19
|
+
description: WORKFLOW_TOOLS["workitem.list"].description,
|
|
20
|
+
inputSchema: {
|
|
21
|
+
environment: environmentArg,
|
|
22
|
+
workflowInstanceId: z
|
|
23
|
+
.string()
|
|
24
|
+
.optional()
|
|
25
|
+
.describe("exact-match client-side filter on the returned items' instanceId (server filterWorkflowInstanceId 是 NOT-equal 排除,不可用)。本面=当前登录人待办:过滤回 total:0 ≠ 实例没待办(待办在别人名下,查别人用 participant 参数);看实例全活动链用 workflow.instanceActivity"),
|
|
26
|
+
workflowCode: z.string().optional(),
|
|
27
|
+
schemaCode: z.string().optional(),
|
|
28
|
+
participant: z
|
|
29
|
+
.string()
|
|
30
|
+
.optional()
|
|
31
|
+
.describe("按**指定用户**的待办查询(用户 id)。省略=当前登录人。用它查别人名下的待办——全局搜索会按登录人过滤,查不到别人的(审批走不通时的第一个诊断手段)"),
|
|
32
|
+
state: z
|
|
33
|
+
.enum(["PENDING", "NOTSTARTED", "INPROGRESS", "DRAFT", "PAUSE", "FINISHED"])
|
|
34
|
+
.optional()
|
|
35
|
+
.describe("待办状态过滤(DRAFT=发起人草稿态待办)。走 list_workitems 端点原生过滤:给了 participant 按该用户;没给则自动解析当前登录人(解析失败回退 search_workitems 并在回执 stateFilter 标注未生效——该端点会静默丢弃 state)。默认不过滤(当前人在办)"),
|
|
36
|
+
// r35: an agent sent page:1 expecting the first page and read
|
|
37
|
+
// `total:1 / count:0` as a contradiction — the page index is ZERO-based
|
|
38
|
+
// (like data.list). Say so at the parameter itself.
|
|
39
|
+
page: z.number().int().min(0).optional().describe("页号,0 基(与 data.list 一致);默认 0"),
|
|
40
|
+
size: z
|
|
41
|
+
.number()
|
|
42
|
+
.int()
|
|
43
|
+
.min(1)
|
|
44
|
+
.max(200)
|
|
45
|
+
.optional()
|
|
46
|
+
.describe("page size; defaults to 200 when workflowInstanceId is set (single-page scan) else 20"),
|
|
47
|
+
capability: capabilityArg,
|
|
48
|
+
},
|
|
49
|
+
handler: async (ctx, args, self) => governedRead(ctx, self, args, async (session) => {
|
|
50
|
+
// `participant` takes the JPA-spec endpoint: it can answer "what is
|
|
51
|
+
// pending for user X" and it does not resolve templates, so a dangling
|
|
52
|
+
// reference elsewhere cannot take it down.
|
|
53
|
+
//
|
|
54
|
+
// r85(retro issue 10):`state` 也必须走 list_workitems——search_workitems
|
|
55
|
+
// 的服务端组装 WorkItemQuerySpec 时**静默丢弃 state 参数**(RuntimeController
|
|
56
|
+
// .searchWorkitems 反编译 1046-1082:无 setState,对照 listFinishedWorkItems
|
|
57
|
+
// :1123 有),传了也无效;list_workitems 原生按 status 精确过滤(含 DRAFT,
|
|
58
|
+
// WorkflowInstanceController:2242-2254)。没给 participant 时先解析当前登录
|
|
59
|
+
// 人,保持「我的待办」口径;解析失败回退 search_workitems 并如实标注
|
|
60
|
+
// stateFilter.applied:false。
|
|
61
|
+
const searchWorkItemsSelf = async () => {
|
|
62
|
+
try {
|
|
63
|
+
return await searchWorkItems(session, {
|
|
64
|
+
...(args.workflowInstanceId ? { instanceId: args.workflowInstanceId } : {}),
|
|
65
|
+
...(args.workflowCode ? { workflowCode: args.workflowCode } : {}),
|
|
66
|
+
...(args.schemaCode ? { schemaCode: args.schemaCode } : {}),
|
|
67
|
+
page: args.page ?? 0,
|
|
68
|
+
size: args.size ?? (args.workflowInstanceId ? 200 : 20),
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
catch (error) {
|
|
72
|
+
// r14: one work item pointing at a missing workflow-template row makes
|
|
73
|
+
// the WHOLE search NPE (buildTempEntity → BeanUtils.copyProperties
|
|
74
|
+
// (null,…)). The probe hit this eight times consecutively because the
|
|
75
|
+
// message said only "50000 服务异常". Name the cause and the way round
|
|
76
|
+
// it instead of leaving a dead end.
|
|
77
|
+
if (!(error instanceof WireError) || error.kind !== "business" || error.errcode !== 50000)
|
|
78
|
+
throw error;
|
|
79
|
+
throw new ToolRefusalError({
|
|
80
|
+
status: "refused",
|
|
81
|
+
blocker: "workitem-search-unavailable",
|
|
82
|
+
retryable: false,
|
|
83
|
+
cause: "平台全局待办搜索会给每条待办解析流程模板(buildTempEntity);只要有一条待办指向已删除的 h_workflow_template 行,整页查询就抛 NPE → 50000。这是平台侧脏引用,不是本工具的入参问题。",
|
|
84
|
+
workaround: [
|
|
85
|
+
"① 按流程收窄(这一步不解析模板,最可靠):omc call workitem.list --env <env> --args '{\"workflowCode\":\"<流程code>\"}'",
|
|
86
|
+
"② 按人查(能查别人名下的待办):omc call workitem.list --env <env> --args '{\"participant\":\"<用户id>\"}'",
|
|
87
|
+
"③ 只看某实例走到哪:omc call workflow.instanceActivity --env <env> --args '{\"workflowInstanceId\":\"<实例id>\"}'",
|
|
88
|
+
],
|
|
89
|
+
message: "平台全局待办搜索当前不可用(50000):有一条待办指向已删除的流程模板,整页解析直接 NPE——**与你传的参数无关,重试不会变好**。" +
|
|
90
|
+
"改用带范围的查询:按 `workflowCode` 收窄,或按 `participant` 查某人的待办(这两条走 JPA 查询,不做模板解析)。" +
|
|
91
|
+
"若要彻底恢复全局搜索,需要维护者清掉那条脏待办(平台侧数据修复)。",
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
let page;
|
|
96
|
+
let stateFilter;
|
|
97
|
+
let selfParticipantId = null;
|
|
98
|
+
if (args.participant !== undefined) {
|
|
99
|
+
page = await listWorkItemsByParticipant(session, {
|
|
100
|
+
participant: args.participant,
|
|
101
|
+
...(args.state !== undefined ? { status: args.state } : {}),
|
|
102
|
+
...(args.workflowCode !== undefined ? { workflowCode: args.workflowCode } : {}),
|
|
103
|
+
page: args.page ?? 0,
|
|
104
|
+
size: args.size ?? 20,
|
|
105
|
+
});
|
|
106
|
+
if (args.state !== undefined)
|
|
107
|
+
stateFilter = { requested: args.state, applied: true, via: "list_workitems" };
|
|
108
|
+
}
|
|
109
|
+
else if (args.state !== undefined) {
|
|
110
|
+
const actor = await resolvePermissionActor(session);
|
|
111
|
+
selfParticipantId = actor.userId;
|
|
112
|
+
if (actor.userId !== null) {
|
|
113
|
+
page = await listWorkItemsByParticipant(session, {
|
|
114
|
+
participant: actor.userId,
|
|
115
|
+
status: args.state,
|
|
116
|
+
...(args.workflowCode !== undefined ? { workflowCode: args.workflowCode } : {}),
|
|
117
|
+
page: args.page ?? 0,
|
|
118
|
+
size: args.size ?? (args.workflowInstanceId ? 200 : 20),
|
|
119
|
+
});
|
|
120
|
+
stateFilter = { requested: args.state, applied: true, via: "list_workitems(self)" };
|
|
121
|
+
}
|
|
122
|
+
else {
|
|
123
|
+
page = await searchWorkItemsSelf();
|
|
124
|
+
stateFilter = {
|
|
125
|
+
requested: args.state,
|
|
126
|
+
applied: false,
|
|
127
|
+
via: "search_workitems",
|
|
128
|
+
note: "当前登录人 id 解析失败,回退到 search_workitems(服务端注入登录人,但该端点静默丢弃 state 参数——本结果的 state 过滤未生效,DRAFT 等非在办态可能查不全;重试或显式传 participant:<用户id>)",
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
else {
|
|
133
|
+
page = await searchWorkItemsSelf();
|
|
134
|
+
}
|
|
135
|
+
// r32(2026-10-31):`participant` 分支此前忽略 workflowInstanceId——按人查
|
|
136
|
+
// 时同回全部实例的待办,与参数语义(exact-match 过滤)不符。两个分支统一
|
|
137
|
+
// 在客户端做实例过滤。
|
|
138
|
+
const selected = args.workflowInstanceId !== undefined
|
|
139
|
+
? page.items.filter((item) => wireString(item.instanceId) === args.workflowInstanceId)
|
|
140
|
+
: page.items;
|
|
141
|
+
// Resolve the in-flight bizObject id per distinct instance. Authoritative
|
|
142
|
+
// source: getBizObjectByWfInstanceId -> BizObjectCreatedModel.id/schemaCode.
|
|
143
|
+
// Best-effort: a failed lookup leaves the identity null, never drops the todo.
|
|
144
|
+
const objectByInstance = new Map();
|
|
145
|
+
for (const item of selected) {
|
|
146
|
+
const instanceId = wireString(item.instanceId);
|
|
147
|
+
if (!instanceId || objectByInstance.has(instanceId))
|
|
148
|
+
continue;
|
|
149
|
+
objectByInstance.set(instanceId, await resolveBizObjectIdByInstance(session, instanceId));
|
|
150
|
+
}
|
|
151
|
+
const items = selected.map((item) => {
|
|
152
|
+
const instanceId = wireString(item.instanceId);
|
|
153
|
+
const linked = instanceId ? objectByInstance.get(instanceId) : undefined;
|
|
154
|
+
return {
|
|
155
|
+
workItemId: wireString(item.id),
|
|
156
|
+
workflowInstanceId: instanceId,
|
|
157
|
+
workflowCode: wireString(item.workflowCode),
|
|
158
|
+
activityCode: wireString(item.activityCode),
|
|
159
|
+
activityName: wireString(item.activityName),
|
|
160
|
+
state: wireString(item.state),
|
|
161
|
+
sequenceNo: wireString(item.sequenceNo),
|
|
162
|
+
originator: wireString(item.originator),
|
|
163
|
+
originatorName: wireString(item.originatorName),
|
|
164
|
+
participant: wireString(item.participant),
|
|
165
|
+
participantName: wireString(item.participantName),
|
|
166
|
+
bizObjectId: linked?.bizObjectId ?? null,
|
|
167
|
+
schemaCode: linked?.schemaCode ?? wireString(item.schemaCode),
|
|
168
|
+
};
|
|
169
|
+
});
|
|
170
|
+
// r6-onboarding 2026-10-21: 89 of 117 calls used this tool with only a
|
|
171
|
+
// schemaCode — mostly to ask "where did the flow go", which the todo query
|
|
172
|
+
// cannot answer (it lists pending items only). Say what this call is for
|
|
173
|
+
// at the moment it is used, and name the two substitutes.
|
|
174
|
+
const purposeHint = args.workflowInstanceId === undefined && args.workflowCode === undefined
|
|
175
|
+
? "本调用用于发现待办并取 workItemId 做审批;只想看流程走到哪,用 workflow.instanceActivity;提交/审批后优先复用 data.submit 的 readback.nextSubmit,不要重复查询。"
|
|
176
|
+
: undefined;
|
|
177
|
+
// r40a-E(2026-11-07,E2E F29):按实例查且本人口径 total:0 时,与「流程没生成」
|
|
178
|
+
// 不可区分——探针差点误判「审批没生成」。存在范围外待办时显式说明口径差。
|
|
179
|
+
const scopedToInstance = args.workflowInstanceId !== undefined && args.participant === undefined;
|
|
180
|
+
const unfiltered = page.unfilteredTotal;
|
|
181
|
+
const othersScopeNote = scopedToInstance && page.total === 0 && typeof unfiltered === "number" && unfiltered > 0
|
|
182
|
+
? `total:0 是当前登录人口径——查询范围(unfilteredTotal=${unfiltered})内存在他人的待办。若该实例应有待办:待办按持有人过滤,用 participant:<持有人id> 复查(持有人见 data.submit 回执 flowWarning);不要据此判定「流程未生成」。`
|
|
183
|
+
: undefined;
|
|
184
|
+
// r65 a-F8(探针复现):不带过滤时 total=11 与 itemsCount=0 并存且无任何口径说明
|
|
185
|
+
// ——清理验收差点把他人待办当自己残留。total 与 items 恒为「当前登录人可见」
|
|
186
|
+
// 口径,unfiltered(若平台回)才是范围全量;无过滤时同样要说清。
|
|
187
|
+
const unscopedScopeNote = !scopedToInstance
|
|
188
|
+
? `total/items 是**当前登录人可见**口径${typeof unfiltered === "number" ? `(unfilteredTotal=${unfiltered} 为查询范围全量,含他人)` : "(他人待办不在其中)"};清点残留请按此口径解读,勿把范围全量当自己的。`
|
|
189
|
+
: undefined;
|
|
190
|
+
return {
|
|
191
|
+
total: page.total,
|
|
192
|
+
// The JPA-spec path reports no page count; only emit it when known.
|
|
193
|
+
...("totalPages" in page && page.totalPages !== undefined ? { totalPages: page.totalPages } : {}),
|
|
194
|
+
itemsCount: items.length,
|
|
195
|
+
...(purposeHint ? { purposeHint } : {}),
|
|
196
|
+
...(othersScopeNote ? { scopeNote: othersScopeNote } : {}),
|
|
197
|
+
...(othersScopeNote === undefined && unscopedScopeNote !== undefined ? { scopeNote: unscopedScopeNote } : {}),
|
|
198
|
+
...(args.participant !== undefined || (args.state !== undefined && stateFilter?.applied === true)
|
|
199
|
+
? { participant: args.participant ?? selfParticipantId, state: args.state ?? "PENDING", source: "list_workitems" }
|
|
200
|
+
: {}),
|
|
201
|
+
...(stateFilter !== undefined
|
|
202
|
+
? {
|
|
203
|
+
stateFilter,
|
|
204
|
+
stateFilterNote: stateFilter.applied
|
|
205
|
+
? `state=${stateFilter.requested} 经 list_workitems 端点原生过滤(search_workitems 会静默丢弃 state 参数,DRAFT 态此前因此查不到)`
|
|
206
|
+
: stateFilter.note,
|
|
207
|
+
}
|
|
208
|
+
: {}),
|
|
209
|
+
...("unfilteredTotal" in page && page.unfilteredTotal !== undefined ? { unfilteredTotal: page.unfilteredTotal } : {}),
|
|
210
|
+
items,
|
|
211
|
+
};
|
|
212
|
+
}, { compact: workItemListCompactProjection }),
|
|
213
|
+
}));
|
|
214
|
+
tools.push(defineTool({
|
|
215
|
+
name: "workflow.instanceActivity",
|
|
216
|
+
search: { intents: ["流程实例状态", "实例节点状态", "节点状态", "流程走到哪", "实例每个节点"] },
|
|
217
|
+
layer: "low",
|
|
218
|
+
kind: "read",
|
|
219
|
+
lane: WORKFLOW_LANE,
|
|
220
|
+
scope: WORKFLOW_TOOLS["workflow.instanceActivity"].scope,
|
|
221
|
+
description: WORKFLOW_TOOLS["workflow.instanceActivity"].description,
|
|
222
|
+
inputSchema: {
|
|
223
|
+
environment: environmentArg,
|
|
224
|
+
workflowInstanceId: z.string().min(1).describe("流程实例 id(data.submit / data.load 读回的 workflowInstanceId)"),
|
|
225
|
+
capability: capabilityArg,
|
|
226
|
+
},
|
|
227
|
+
handler: async (ctx, args, self) => governedRead(ctx, self, args, async (session) => {
|
|
228
|
+
const rows = await listInstanceActivities(session, args.workflowInstanceId);
|
|
229
|
+
const header = await getInstanceBaseInfo(session, args.workflowInstanceId);
|
|
230
|
+
const instanceStatus = header ? wireString(header.status) : null;
|
|
231
|
+
const activities = rows.map((row) => {
|
|
232
|
+
const participants = Array.isArray(row.participantors) ? row.participantors : [];
|
|
233
|
+
return {
|
|
234
|
+
activityCode: wireString(row.activityCode),
|
|
235
|
+
activityName: wireString(row.activityName),
|
|
236
|
+
activityType: row.activityType === undefined ? null : row.activityType,
|
|
237
|
+
status: row.status === undefined ? null : row.status,
|
|
238
|
+
participantCount: participants.length,
|
|
239
|
+
participants: participants.slice(0, 10).map((person) => ({
|
|
240
|
+
name: wireString(person.name) ?? wireString(person.userName) ?? null,
|
|
241
|
+
id: wireString(person.id) ?? wireString(person.userId) ?? null,
|
|
242
|
+
})),
|
|
243
|
+
...(row.sheetTrigger !== undefined ? { sheetTrigger: row.sheetTrigger } : {}),
|
|
244
|
+
};
|
|
245
|
+
});
|
|
246
|
+
const active = activities.filter((activity) => activity.status === 1);
|
|
247
|
+
const reached = activities.filter((activity) => activity.status === 1 || activity.participantCount > 0);
|
|
248
|
+
// Diagnosis, not inference: the platform's own signal is status 1 = an
|
|
249
|
+
// activity that currently holds tasks. No active activity while the
|
|
250
|
+
// instance is still PROCESSING is exactly the silent-stall shape.
|
|
251
|
+
const diagnosis = diagnoseInstanceActivity({ instanceStatus, endStatus: header ? wireString(header.endStatus) : null, originator: header ? wireString(header.originator) : null, activities });
|
|
252
|
+
// The instance face gives the resolved participant, while the
|
|
253
|
+
// published template gives the configured role. Compare both faces
|
|
254
|
+
// here (and only here): data.submit wiring intentionally remains in
|
|
255
|
+
// runtime-data.ts's owning batch. If the template cannot be read,
|
|
256
|
+
// participantFallbackWarnings degrades to a participant==originator
|
|
257
|
+
// hint rather than claiming a role mismatch.
|
|
258
|
+
let publishedTemplate = null;
|
|
259
|
+
const workflowCode = header ? wireString(header.workflowCode) ?? wireString(header.workflowCode_) : null;
|
|
260
|
+
if (workflowCode) {
|
|
261
|
+
try {
|
|
262
|
+
const published = await wireCall(session, { path: ENDPOINTS.workflowGetPublished, query: { workflowCode } });
|
|
263
|
+
publishedTemplate = published.data && typeof published.data === "object" && !Array.isArray(published.data) ? published.data : null;
|
|
264
|
+
}
|
|
265
|
+
catch {
|
|
266
|
+
publishedTemplate = null;
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
const participantFallback = participantFallbackWarnings({ activities, template: publishedTemplate, originator: header ? wireString(header.originator) : null });
|
|
270
|
+
return {
|
|
271
|
+
workflowInstanceId: args.workflowInstanceId,
|
|
272
|
+
...(instanceStatus ? { instanceStatus } : {}),
|
|
273
|
+
...(header && wireString(header.endStatus) ? { endStatus: wireString(header.endStatus) } : {}),
|
|
274
|
+
activityCount: activities.length,
|
|
275
|
+
activeCount: active.length,
|
|
276
|
+
reachedCount: reached.length,
|
|
277
|
+
activities,
|
|
278
|
+
...(participantFallback.length ? { participantFallback } : {}),
|
|
279
|
+
diagnosis,
|
|
280
|
+
};
|
|
281
|
+
}),
|
|
282
|
+
}));
|
|
283
|
+
}
|
|
284
|
+
//# sourceMappingURL=instance-read.js.map
|