@stalfh233/omc-cli 0.8.1 → 0.8.3
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/bench/call-face-eval.js +1 -1
- package/dist/bench/scenario.js +3 -3
- package/dist/cli-contract.js +55 -2
- package/dist/cli-output.js +59 -8
- package/dist/cli.js +338 -59
- package/dist/field-families.js +19 -9
- package/dist/form-layout.js +19 -4
- package/dist/form-support.js +78 -9
- package/dist/graph.js +151 -29
- package/dist/lanes/app.js +34 -6
- package/dist/lanes/field.js +136 -10
- package/dist/lanes/form.js +18 -4
- package/dist/lanes/runtime-data.js +308 -46
- package/dist/lanes/workflow-contract.js +1 -1
- package/dist/lanes/workflow.js +187 -39
- package/dist/path-projection.js +25 -14
- package/dist/read.js +132 -3
- package/dist/refusal-guidance.js +14 -0
- package/dist/session.js +30 -2
- package/dist/support.js +3 -1
- package/dist/wire-failure.js +120 -0
- package/dist/wire.js +109 -5
- package/dist/workflow-support.js +41 -0
- package/package.json +3 -3
package/dist/lanes/workflow.js
CHANGED
|
@@ -10,7 +10,7 @@ import { writeSummary } from "../human-summary.js";
|
|
|
10
10
|
import { defineTool, ToolInputError } from "../tool-types.js";
|
|
11
11
|
import { DEFAULT_SCAN_CONCURRENCY, mapWithConcurrency } from "../concurrency.js";
|
|
12
12
|
import { wireCall, wireRows, WireError } from "../wire.js";
|
|
13
|
-
import { diagnoseInstanceActivity, getInstanceBaseInfo, listInstanceActivities, listWorkItemsByParticipant, resolveBizObjectIdByInstance, searchWorkItems, wireString } from "../workflow-support.js";
|
|
13
|
+
import { diagnoseInstanceActivity, getInstanceBaseInfo, isCanceledInstanceStatus, isFinishedInstanceStatus, listInstanceActivities, listWorkItemsByParticipant, resolveBizObjectIdByInstance, searchWorkItems, wireString } from "../workflow-support.js";
|
|
14
14
|
import { readSchemaFormButtons } from "../form-support.js";
|
|
15
15
|
import { WORKFLOW_EVENT_HANDLER_FIELDS, WORKFLOW_NODE_EVENT_HANDLER_FIELDS, WORKFLOW_LANE_CONTRACT, workflowTemplateArg } from "./workflow-contract.js";
|
|
16
16
|
import { PLATFORM_TRIGGER_RULE_CODES } from "./rule-graph.js";
|
|
@@ -405,6 +405,20 @@ function assertTemplateNotMinimal(template, tool) {
|
|
|
405
405
|
if (template === undefined || template === null)
|
|
406
406
|
return;
|
|
407
407
|
const activities = callerActivities(template);
|
|
408
|
+
// W1: a TYPE-LESS edit row (participant/propertyPermissions/btnConfigList/
|
|
409
|
+
// rename) still names an existing draft node — the merge path backfills its
|
|
410
|
+
// type from that node. Counting only the literal type strings made a full
|
|
411
|
+
// replace like [START, {activityCode,participant}, END] look boundary-only
|
|
412
|
+
// and refused it as `workflow-template-minimal`.
|
|
413
|
+
const hasTypelessEditRow = (activities ?? []).some((activity) => {
|
|
414
|
+
if (activity === null || typeof activity !== "object")
|
|
415
|
+
return false;
|
|
416
|
+
const record = activity;
|
|
417
|
+
const type = record.type ?? record.activityType;
|
|
418
|
+
return (type === undefined || type === null || String(type).trim() === "") && editsExistingNodeShape(record);
|
|
419
|
+
});
|
|
420
|
+
if (hasTypelessEditRow)
|
|
421
|
+
return;
|
|
408
422
|
const types = activities
|
|
409
423
|
? activities
|
|
410
424
|
.map((activity) => (activity && typeof activity === "object" ? String(activity.type ?? activity.activityType ?? "") : ""))
|
|
@@ -418,6 +432,71 @@ function assertTemplateNotMinimal(template, tool) {
|
|
|
418
432
|
});
|
|
419
433
|
}
|
|
420
434
|
}
|
|
435
|
+
/**
|
|
436
|
+
* W1(2.1.5 真机 2026-11-25 契约不一致):既有节点的编辑行可以只给 activityCode
|
|
437
|
+
* ——类型在合并时从草稿同 code 节点补齐,调用方不必重复声明。
|
|
438
|
+
*
|
|
439
|
+
* 证据(前后端双侧):
|
|
440
|
+
* - 平台上送的**整行**必须有 activityType:`WorkflowTemplateUtil.convertActivity`
|
|
441
|
+
* 对每个活动做 `ActivityType.valueOf(activity.get("activityType"))`
|
|
442
|
+
* (2.1.5 launcher: :216-256 / 8.6.26: :249),缺类型抛异常被
|
|
443
|
+
* `convertWorkflowTemplateJsonToModel` 的 catch 吞成残缺模型(2.1.5 :135-140)
|
|
444
|
+
* → 保存链 50000。平台看到的是 OMC 合并后的草稿整行,不是调用方 delta。
|
|
445
|
+
* - 前端模板模型 `ActivitySchema.activityType: string` 是必填
|
|
446
|
+
* (frontend-src/frontend/packages/admin/src/typings/workflow.ts:26-28),
|
|
447
|
+
* 设计器从不发无类型节点 —— 「省 type」是 OMC 的合并能力,不是平台接受的形状,
|
|
448
|
+
* 所以只在草稿里**唯一**命中同 code 节点时成立(见
|
|
449
|
+
* uniqueDraftRowForTypelessEdit)。
|
|
450
|
+
*
|
|
451
|
+
* 编辑行判据是**形状**:这些键只可能是既有节点的子面(权限/改名/参与人/按钮),
|
|
452
|
+
* 新节点不会带。原先漏了 participant(0.8.1 真机:只给
|
|
453
|
+
* `{activityCode, participant}` 被本地拒),这里补齐。
|
|
454
|
+
*/
|
|
455
|
+
const EXISTING_NODE_EDIT_KEYS = [
|
|
456
|
+
"propertyPermissions",
|
|
457
|
+
"subPropertyPermissions",
|
|
458
|
+
"activityName",
|
|
459
|
+
"name",
|
|
460
|
+
"i18nMessage",
|
|
461
|
+
"permittedAction",
|
|
462
|
+
"buttonPermission",
|
|
463
|
+
"btnConfigList",
|
|
464
|
+
"participant",
|
|
465
|
+
];
|
|
466
|
+
function editsExistingNodeShape(record) {
|
|
467
|
+
return EXISTING_NODE_EDIT_KEYS.some((key) => record[key] !== undefined);
|
|
468
|
+
}
|
|
469
|
+
/**
|
|
470
|
+
* Resolve the draft row a type-less caller edit inherits its activityType from.
|
|
471
|
+
* Only a UNIQUE same-code draft node qualifies: a miss means the caller is
|
|
472
|
+
* creating a new node (type is its identity — must be explicit), and duplicate
|
|
473
|
+
* codes cannot be resolved to one type. Both refuse BEFORE the wire with the
|
|
474
|
+
* draft's node list, because the platform swallows a typeless element into a
|
|
475
|
+
* partial model (50000).
|
|
476
|
+
*/
|
|
477
|
+
function draftNodeCandidateList(draftActivities) {
|
|
478
|
+
return draftActivities
|
|
479
|
+
.map((activity) => ({ activityCode: String(activity.activityCode ?? ""), activityType: String(activity.activityType ?? "") }))
|
|
480
|
+
.filter((row) => row.activityCode !== "")
|
|
481
|
+
.slice(0, 40);
|
|
482
|
+
}
|
|
483
|
+
function uniqueDraftRowForTypelessEdit(tool, code, draftActivities) {
|
|
484
|
+
const matches = draftActivities.filter((activity) => String(activity.activityCode ?? "") === code);
|
|
485
|
+
if (matches.length === 1)
|
|
486
|
+
return matches[0];
|
|
487
|
+
const candidates = draftNodeCandidateList(draftActivities);
|
|
488
|
+
const listed = candidates.map((row) => `${row.activityCode}(${row.activityType})`).join("、");
|
|
489
|
+
throw new ToolRefusalError({
|
|
490
|
+
status: "refused",
|
|
491
|
+
blocker: "workflow-activity-type-missing",
|
|
492
|
+
activityCode: code,
|
|
493
|
+
...(matches.length > 1 ? { ambiguousMatches: matches.length } : {}),
|
|
494
|
+
candidates,
|
|
495
|
+
message: matches.length > 1
|
|
496
|
+
? `${tool}: 节点 ${code} 在草稿里命中 ${matches.length} 个同 code 节点,无法唯一继承类型——显式给 type/activityType。`
|
|
497
|
+
: `${tool}: 节点 ${code} 缺 type/activityType,且草稿里没有同 code 的既有节点可继承(新节点必须显式给 type;既有节点编辑行——participant/propertyPermissions/btnConfigList/改名——可省 type 仅当 activityCode 唯一命中草稿)。草稿现有节点:${listed || "(空)"}`,
|
|
498
|
+
});
|
|
499
|
+
}
|
|
421
500
|
/**
|
|
422
501
|
* Ticket 112 — dry-lint the caller template against the platform's update
|
|
423
502
|
* contract (8.6.26 decompiled source), zero wire:
|
|
@@ -425,8 +504,10 @@ function assertTemplateNotMinimal(template, tool) {
|
|
|
425
504
|
* (WorkflowTemplateUtil.java:136 valueOf; the converter swallows the
|
|
426
505
|
* exception into a partial model and the save chain then fails with errcode
|
|
427
506
|
* 50000) — omit it and the draft's value rides along.
|
|
428
|
-
* - every activities element needs a type (platform keys on
|
|
429
|
-
* ActivityType.valueOf("null") throws the same swallowed way).
|
|
507
|
+
* - every activities element on the WIRE needs a type (platform keys on
|
|
508
|
+
* activityType; ActivityType.valueOf("null") throws the same swallowed way).
|
|
509
|
+
* An edit row of an EXISTING draft node may omit it — the merge path backfills
|
|
510
|
+
* the draft node's own type (uniqueDraftRowForTypelessEdit).
|
|
430
511
|
*/
|
|
431
512
|
function lintWorkflowTemplate(template, tool) {
|
|
432
513
|
if (template === undefined || template === null)
|
|
@@ -442,15 +523,16 @@ function lintWorkflowTemplate(template, tool) {
|
|
|
442
523
|
for (const activity of activities) {
|
|
443
524
|
const record = activity;
|
|
444
525
|
const type = record != null && typeof record === "object" ? (record.type ?? record.activityType) : undefined;
|
|
445
|
-
//
|
|
446
|
-
// type at merge time
|
|
447
|
-
//
|
|
448
|
-
|
|
526
|
+
// Edit rows (permissions/rename/participant/buttons) target an existing
|
|
527
|
+
// draft node and inherit its type at merge time — only a bare new node
|
|
528
|
+
// must carry its own type here. The code→draft uniqueness check belongs
|
|
529
|
+
// to the merge paths (they hold the draft); this lint is shape-only.
|
|
530
|
+
const targetsExistingNode = record != null && typeof record === "object" && editsExistingNodeShape(record);
|
|
449
531
|
if ((type === undefined || type === null || String(type).trim() === "") && !targetsExistingNode)
|
|
450
532
|
throw new ToolRefusalError({
|
|
451
533
|
status: "refused",
|
|
452
534
|
blocker: "workflow-activity-type-missing",
|
|
453
|
-
message: `${tool}: activities 元素缺少 type/activityType(平台 ActivityType.valueOf 对 "null" 抛异常被吞成残缺模型 → 50000
|
|
535
|
+
message: `${tool}: activities 元素缺少 type/activityType(平台 ActivityType.valueOf 对 "null" 抛异常被吞成残缺模型 → 50000);新节点必须带类型(既有节点编辑行如 participant/propertyPermissions/btnConfigList/改名可省,类型继承自草稿同 code 节点)`,
|
|
454
536
|
});
|
|
455
537
|
}
|
|
456
538
|
}
|
|
@@ -500,9 +582,16 @@ function mapCallerActivities(callerActivities, draftActivities) {
|
|
|
500
582
|
const record = (entry ?? {});
|
|
501
583
|
const code = activityCodeOf(record);
|
|
502
584
|
const type = activityTypeOf(record);
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
585
|
+
// W1: a type-less edit row inherits the draft node's own activityType. Only
|
|
586
|
+
// a unique same-code draft row qualifies — the platform requires a type on
|
|
587
|
+
// every activity element of the body it receives (WorkflowTemplateUtil
|
|
588
|
+
// .convertActivity → ActivityType.valueOf), and a miss means this is a new
|
|
589
|
+
// node whose type must be explicit.
|
|
590
|
+
const base = type
|
|
591
|
+
? (draftByCode.get(code) ??
|
|
592
|
+
(type === "START" ? draftByType("START") : type === "END" ? draftByType("END") : type === "PARTICIPANT" ? draftByType("PARTICIPANT") : undefined) ??
|
|
593
|
+
{})
|
|
594
|
+
: uniqueDraftRowForTypelessEdit("workflow", code, draftActivities);
|
|
506
595
|
// Drop the input aliases AND the readback-only keys (`code`/`index` come
|
|
507
596
|
// from workflowSummary). Stray keys on an Activity/Rule make the platform
|
|
508
597
|
// answer a misleading 401001; only canonical keys may ride the wire. The
|
|
@@ -524,12 +613,13 @@ function mapCallerActivities(callerActivities, draftActivities) {
|
|
|
524
613
|
};
|
|
525
614
|
// Replace path: a caller-only code with no type has no draft row to
|
|
526
615
|
// inherit from — refuse before the wire (same rule the merge path
|
|
527
|
-
// enforces for its appended nodes).
|
|
616
|
+
// enforces for its appended nodes). uniqueDraftRowForTypelessEdit already
|
|
617
|
+
// refused the common case; this catches a draft row whose own type is empty.
|
|
528
618
|
if (String(mapped.activityType ?? "") === "")
|
|
529
619
|
throw new ToolRefusalError({
|
|
530
620
|
status: "refused",
|
|
531
621
|
blocker: "workflow-activity-type-missing",
|
|
532
|
-
message: `workflow:
|
|
622
|
+
message: `workflow: 节点 ${code} 在草稿里没有可继承的 type/activityType——新节点必须显式给 type;只有 activityCode 唯一命中既有草稿节点时才能省`,
|
|
533
623
|
});
|
|
534
624
|
return mapped;
|
|
535
625
|
});
|
|
@@ -549,13 +639,15 @@ function validateCallerActivities(template, tool) {
|
|
|
549
639
|
if (codes.has(code))
|
|
550
640
|
throw new ToolRefusalError({ status: "refused", blocker: "workflow-render-activity-code-duplicate", message: `${tool}: duplicate activityCode ${code}` });
|
|
551
641
|
if (!rawType) {
|
|
552
|
-
//
|
|
642
|
+
// An edit row (permissions/rename/participant/buttons) targets an
|
|
553
643
|
// EXISTING draft node and inherits its type at merge time — demanding a
|
|
554
644
|
// type here forced agents to re-send identity fields, and any spelling
|
|
555
|
-
// drift then minted `_2` codes. Bare new nodes still need a type
|
|
556
|
-
|
|
645
|
+
// drift then minted `_2` codes. Bare new nodes still need a type; the
|
|
646
|
+
// merge paths refuse a type-less row whose code is not a unique draft hit
|
|
647
|
+
// (uniqueDraftRowForTypelessEdit).
|
|
648
|
+
const targetsExistingNode = activity != null && typeof activity === "object" && editsExistingNodeShape(activity);
|
|
557
649
|
if (!targetsExistingNode)
|
|
558
|
-
throw new ToolRefusalError({ status: "refused", blocker: "workflow-activity-type-missing", message: `${tool}: activities[${index}] requires type/activityType
|
|
650
|
+
throw new ToolRefusalError({ status: "refused", blocker: "workflow-activity-type-missing", message: `${tool}: activities[${index}] requires type/activityType(既有节点编辑行——participant/propertyPermissions/btnConfigList/改名——可省,类型继承自草稿同 code 节点)` });
|
|
559
651
|
}
|
|
560
652
|
if (rawType !== "" && !WORKFLOW_ACTIVITY_TYPES.has(type))
|
|
561
653
|
throw new ToolRefusalError({ status: "refused", blocker: "workflow-render-activity-type-invalid", message: `${tool}: activities[${index}] has an illegal ActivityType` });
|
|
@@ -1867,16 +1959,24 @@ function mergeCallerDelta(template, draft, options = {}) {
|
|
|
1867
1959
|
const newActivities = [...callerByOriginal.values()];
|
|
1868
1960
|
refusePartialBtnConfigList([...mergedActivities, ...newActivities]);
|
|
1869
1961
|
// A caller-only code that arrived WITHOUT a type has no draft row to inherit
|
|
1870
|
-
// from — refuse it here (the lint allows type-less
|
|
1871
|
-
//
|
|
1962
|
+
// from — refuse it here (the lint allows type-less edit-shape rows precisely
|
|
1963
|
+
// because they are expected to match an existing node; this list is what is
|
|
1964
|
+
// left after matching). W1: participant/btnConfigList rows get the same
|
|
1965
|
+
// exemption as permission rows, so a mistyped activityCode lands on THIS
|
|
1966
|
+
// message (not the old "must carry type" one) and gets the draft's node list.
|
|
1872
1967
|
for (const activity of newActivities) {
|
|
1873
1968
|
const type = activityTypeOf(activity);
|
|
1874
|
-
if (type === "")
|
|
1969
|
+
if (type === "") {
|
|
1970
|
+
const code = String(activity.activityCode ?? "");
|
|
1971
|
+
const candidates = draftNodeCandidateList(draftActivities);
|
|
1875
1972
|
throw new ToolRefusalError({
|
|
1876
1973
|
status: "refused",
|
|
1877
1974
|
blocker: "workflow-activity-type-missing",
|
|
1878
|
-
|
|
1975
|
+
activityCode: code,
|
|
1976
|
+
candidates,
|
|
1977
|
+
message: `workflow.update: 节点 ${code} 缺 type/activityType,且草稿里没有同 code 的既有节点可继承(省略类型仅当 activityCode 唯一命中草稿既有节点——participant/propertyPermissions/btnConfigList/改名等编辑行;新节点必须显式给 type)。草稿现有节点:${candidates.map((row) => `${row.activityCode}(${row.activityType})`).join("、") || "(空)"}`,
|
|
1879
1978
|
});
|
|
1979
|
+
}
|
|
1880
1980
|
}
|
|
1881
1981
|
// Insert added nodes BEFORE the terminal END, so the auto-chain reads
|
|
1882
1982
|
// START → …existing… → new → END (appending after END produced a chain that
|
|
@@ -3026,7 +3126,7 @@ export function registerWorkflowLane(tools) {
|
|
|
3026
3126
|
lane: WORKFLOW_LANE,
|
|
3027
3127
|
scope: WORKFLOW_TOOLS["workflow.update"].scope,
|
|
3028
3128
|
description: WORKFLOW_TOOLS["workflow.update"].description,
|
|
3029
|
-
inputSchema: { schemaCode: z.string().min(1), code: z.string().min(1).describe("流程编码——本参数名是 code,传 workflowCode 会被 schema 拒绝"), template: workflowTemplateArg, merge: z.boolean().optional().describe("增量 merge:只发改动/新增节点与路由,按 activityCode 并入草稿;模板缺 START/END 自动增量、给全 START..END 才整模板替换。并集绝不删边,少边拒 workflow-merge-would-drop-routes;--dry-run 回 routesBefore/routesAfter/routesAdded/routesDropped") },
|
|
3129
|
+
inputSchema: { schemaCode: z.string().min(1), code: z.string().min(1).describe("流程编码——本参数名是 code,传 workflowCode 会被 schema 拒绝"), template: workflowTemplateArg.describe(`${workflowTemplateArg.description ?? ""}**省 type 的边界**:既有节点编辑行只给 activityCode 即可(participant / propertyPermissions / btnConfigList / 改名),工具按草稿同 code 节点的现有 type 补齐后上送——因为平台对收到的每个 activities 元素都跑 ActivityType.valueOf,缺类型会被吞成残缺模型(50000);activityCode 不在草稿(新节点)仍必须显式给 type,同 code 多候选直接拒并给候选清单。`), merge: z.boolean().optional().describe("增量 merge:只发改动/新增节点与路由,按 activityCode 并入草稿;模板缺 START/END 自动增量、给全 START..END 才整模板替换。并集绝不删边,少边拒 workflow-merge-would-drop-routes;--dry-run 回 routesBefore/routesAfter/routesAdded/routesDropped") },
|
|
3030
3130
|
execute: async (session, args) => {
|
|
3031
3131
|
const template = args.template ?? {};
|
|
3032
3132
|
validateCallerActivities(template, "workflow.update");
|
|
@@ -4798,8 +4898,11 @@ export function registerWorkflowLane(tools) {
|
|
|
4798
4898
|
if (base === null)
|
|
4799
4899
|
throw new ToolRefusalError({ status: "refused", blocker: "workflow-instance-not-found", workflowInstanceId: args.workflowInstanceId, message: `流程实例 ${args.workflowInstanceId} 不存在(get_instance_baseinfo 空)——实例 id 来自 data.submit 读回的 workflowInstanceId` });
|
|
4800
4900
|
const status = wireString(base.status);
|
|
4801
|
-
|
|
4802
|
-
|
|
4901
|
+
// 读面终态含 APPROVED(末级审批通过)/TOPPING_OFF(手动结束/超时)——
|
|
4902
|
+
// 只比 COMPLETED 会漏掉全部正常终结的实例(见 workflow-support.ts
|
|
4903
|
+
// FINISHED_INSTANCE_STATES 的平台投影依据)。
|
|
4904
|
+
if (isFinishedInstanceStatus(status))
|
|
4905
|
+
throw new ToolRefusalError({ status: "refused", blocker: "workflow-instance-completed", workflowInstanceId: args.workflowInstanceId, instanceStatus: status, message: `实例已结束(读面状态 ${status}),没有可换的审批人` });
|
|
4803
4906
|
const active = await activeActivitiesOf(session, args.workflowInstanceId);
|
|
4804
4907
|
if (active.length === 0)
|
|
4805
4908
|
throw new ToolRefusalError({ status: "refused", blocker: "workflow-no-active-activity", workflowInstanceId: args.workflowInstanceId, message: "实例没有任何激活节点(参与者解析失败/引擎异常),无审批人可换——先 workflow.instanceActivity 诊断" });
|
|
@@ -4890,8 +4993,8 @@ export function registerWorkflowLane(tools) {
|
|
|
4890
4993
|
if (base === null)
|
|
4891
4994
|
throw new ToolRefusalError({ status: "refused", blocker: "workflow-instance-not-found", workflowInstanceId: args.workflowInstanceId, message: `流程实例 ${args.workflowInstanceId} 不存在` });
|
|
4892
4995
|
const status = wireString(base.status);
|
|
4893
|
-
if (status
|
|
4894
|
-
throw new ToolRefusalError({ status: "refused", blocker: "workflow-instance-completed", workflowInstanceId: args.workflowInstanceId, message:
|
|
4996
|
+
if (isFinishedInstanceStatus(status))
|
|
4997
|
+
throw new ToolRefusalError({ status: "refused", blocker: "workflow-instance-completed", workflowInstanceId: args.workflowInstanceId, instanceStatus: status, message: `实例已结束(读面状态 ${status}),不能跳转节点` });
|
|
4895
4998
|
const rows = await listInstanceActivities(session, args.workflowInstanceId);
|
|
4896
4999
|
const known = rows.map((row) => wireString(row.activityCode));
|
|
4897
5000
|
if (!known.includes(args.activityCode))
|
|
@@ -4940,7 +5043,7 @@ export function registerWorkflowLane(tools) {
|
|
|
4940
5043
|
search: { intents: ["结束流程", "手动结束", "流程结束", "直接完结"] },
|
|
4941
5044
|
lane: WORKFLOW_LANE,
|
|
4942
5045
|
scope: "runtime workflow admin finish instance",
|
|
4943
|
-
description: "流程运维·手动结束流程(`POST /api/api/runtime/workflow/finish_instance_by_post
|
|
5046
|
+
description: "流程运维·手动结束流程(`POST /api/api/runtime/workflow/finish_instance_by_post`,发起人「结束流程」语义):实例完结(存储 COMPLETED + endStatus=ABORT_END ⇒ 读面 **TOPPING_OFF**,不是 APPROVED),**workflow.bindRules 的 end handler 规则照常触发**(这是 finish 与 abort_instance 终止的本质区别——终止不保证跑规则;验证规则跑了没有用 rule.log 查)。已结束实例(读面 COMPLETED/APPROVED/TOPPING_OFF)幂等拒。**测试提速工具**:手动结束的实例不能用于真实流程推进/权限验证;正常审批走 data.submit。",
|
|
4944
5047
|
inputSchema: {
|
|
4945
5048
|
workflowInstanceId: z.string().min(1).describe("流程实例 id"),
|
|
4946
5049
|
comment: z.string().optional().describe("结束意见(进审批记录)"),
|
|
@@ -4950,8 +5053,16 @@ export function registerWorkflowLane(tools) {
|
|
|
4950
5053
|
if (base === null)
|
|
4951
5054
|
throw new ToolRefusalError({ status: "refused", blocker: "workflow-instance-not-found", workflowInstanceId: args.workflowInstanceId, message: `流程实例 ${args.workflowInstanceId} 不存在` });
|
|
4952
5055
|
const status = wireString(base.status);
|
|
4953
|
-
|
|
4954
|
-
|
|
5056
|
+
// 幂等门(0.8.3 修复):读面终态是 APPROVED / TOPPING_OFF 时存储列也已是
|
|
5057
|
+
// COMPLETED,只比 COMPLETED 会让第二次 finish 穿门、回伪成功 ok。
|
|
5058
|
+
if (isFinishedInstanceStatus(status))
|
|
5059
|
+
throw new ToolRefusalError({
|
|
5060
|
+
status: "refused",
|
|
5061
|
+
blocker: "workflow-instance-completed",
|
|
5062
|
+
workflowInstanceId: args.workflowInstanceId,
|
|
5063
|
+
instanceStatus: status,
|
|
5064
|
+
message: `实例已结束(读面状态 ${status}),无需结束(幂等拒绝;已结束实例不再接受 finish/activate 运维动作——要再走一遍流程请新发起一笔)`,
|
|
5065
|
+
});
|
|
4955
5066
|
const activeBefore = await activeActivitiesOf(session, args.workflowInstanceId);
|
|
4956
5067
|
const performed = await wireCall(session, {
|
|
4957
5068
|
path: ENDPOINTS.workflowFinishInstance,
|
|
@@ -4960,16 +5071,19 @@ export function registerWorkflowLane(tools) {
|
|
|
4960
5071
|
});
|
|
4961
5072
|
const afterBase = await getInstanceBaseInfo(session, args.workflowInstanceId);
|
|
4962
5073
|
const afterStatus = wireString(afterBase?.status);
|
|
5074
|
+
const afterEndStatus = wireString(afterBase?.endStatus);
|
|
4963
5075
|
const afterActive = await activeActivitiesOf(session, args.workflowInstanceId);
|
|
4964
|
-
//
|
|
4965
|
-
//
|
|
4966
|
-
|
|
5076
|
+
// finish 走 finishWorkflowInstance:1066-1072,固定写 endStatus=ABORT_END →
|
|
5077
|
+
// 读面投影 COMPLETED+ABORT_END = TOPPING_OFF(不是「滞后」)。并发下若末级
|
|
5078
|
+
// 审批同时走完则读到 APPROVED——两者都是「已结束」,都算受理。
|
|
5079
|
+
const finished = isFinishedInstanceStatus(afterStatus);
|
|
4967
5080
|
return {
|
|
4968
5081
|
performed: { errcode: performed.errcode, finishedActivities: activeBefore.map((row) => row.activityCode) },
|
|
4969
5082
|
readback: {
|
|
4970
5083
|
instanceStatus: afterStatus,
|
|
5084
|
+
...(afterEndStatus !== null ? { endStatus: afterEndStatus } : {}),
|
|
4971
5085
|
finished,
|
|
4972
|
-
...(afterStatus === "TOPPING_OFF" ? { toppingOffNote: "TOPPING_OFF
|
|
5086
|
+
...(afterStatus === "TOPPING_OFF" ? { toppingOffNote: "TOPPING_OFF=收尾态:存储态 COMPLETED + endStatus=ABORT_END(finish 固定写 ABORT_END),读面按 parseStatusByInstance:459-474 投影成 TOPPING_OFF——这是正常完结,不是失败,勿重试" } : {}),
|
|
4973
5087
|
activeActivities: afterActive,
|
|
4974
5088
|
endRulesNote: "finish=正常完结语义:workflow.bindRules 绑在 end handler 的业务规则照常触发(查 rule.log / rulelog 面);abort 终止不保证跑规则——本工具不走 abort。",
|
|
4975
5089
|
boundaryNote: "测试提速工具:手动结束的实例不能用于真实流程推进/权限验证。",
|
|
@@ -5119,6 +5233,27 @@ export function registerWorkflowLane(tools) {
|
|
|
5119
5233
|
: {}),
|
|
5120
5234
|
};
|
|
5121
5235
|
};
|
|
5236
|
+
/**
|
|
5237
|
+
* W5(真机普查 2026-11-25,`.scratch/omc-cli-2.1-compat/APPROVAL-SIDEEFFECT-SURVEY.md`):
|
|
5238
|
+
* `errcode 0 + data:false` 的**拒绝文案必须按动作分支**——只有 `reject` 会「失败前
|
|
5239
|
+
* 先取消待办、失败后不复建」(RejectWorkItemCommand:41-51 先 onReject 再解析目标
|
|
5240
|
+
* 节点,NPE 被 CommandExecutorImpl:130-158 吞掉但 finally 仍 flush)。其余动作真机
|
|
5241
|
+
* 未观察到该副作用:forward/adjust/assist/circulate 四种形状全打不出 data:false
|
|
5242
|
+
* (全是非 0 业务错、原待办原样 PENDING),revoke 的 data:false 伴随 402509,
|
|
5243
|
+
* abort 的 data:false 只在「实例不存在」时出现(写入之前就失败,且 OMC 有
|
|
5244
|
+
* workflow-instance-not-found 前置门)。共用一句「目标节点不可驳回 / 驳回失败还有
|
|
5245
|
+
* 副作用」会让 forward/abort 的调用方读到不成立甚至吓人的结论。
|
|
5246
|
+
*
|
|
5247
|
+
* 只改文案:判据(`data === true`)、回读(`readSideEffect` 仅 reject 传)与 wire 全不动。
|
|
5248
|
+
*/
|
|
5249
|
+
const APPROVAL_ACTION_FAILURE_HINTS = {
|
|
5250
|
+
"workflow.forward": "forward 常见业务错(**不是** data:false 的成因,走非 0 errcode):409019 转办人不存在、402511 不允许转办给自己、409018 待办已处理/已取消、405029 不是待办处理人。forward 命令体没有显式 false 分支,data:false 只能来自平台内部异常或实例锁超时。",
|
|
5251
|
+
"workflow.adjust": "adjust(加签,`adjust_workItem_participators`)常见业务错(**不是** data:false 的成因):409020 加签人不存在、402512 不允许加签给自己、409018、405029。命令体无显式 false 分支,data:false 只能来自平台内部异常或实例锁超时。",
|
|
5252
|
+
"workflow.assist": "assist(协办)常见业务错(**不是** data:false 的成因):409021 参与人不存在、402515 不能协办给当前活动处理人、409018。命令体无显式 false 分支,data:false 只能来自平台内部异常或实例锁超时。",
|
|
5253
|
+
"workflow.circulate": "circulate(传阅)常见业务错(**不是** data:false 的成因):402501 待办不存在、402523 不允许传阅给自己、202511121416 不是待办处理人。注意 2.1.5 的 circulate 不校验接收人——接收人不存在时平台回 data:true(已在 participantsUnverified 标注),不是失败;data:false 只能来自平台内部异常或实例锁超时。",
|
|
5254
|
+
"workflow.revoke": "revoke 的失败通常回**非 0** errcode 402509「当前操作不能被撤回!」(此时 data 也是 false,但走 wire-business);走到这里(errcode 0 + data:false)说明是平台内部异常或实例锁超时。",
|
|
5255
|
+
"workflow.abort": "abort 的 data:false 在 2.1.5 真机上只对应「实例不存在」(errcode 0 + errmsg「流程实例作废失败」,写入之前就失败;OMC 有 workflow-instance-not-found 前置门,只有读到后被删的竞态才会走到这里);已作废实例再作废回 402520,不是 data:false。",
|
|
5256
|
+
};
|
|
5122
5257
|
/**
|
|
5123
5258
|
* 审批动作统一回执判定。七个动作(reject/forward/adjust/assist/circulate/revoke/abort)
|
|
5124
5259
|
* 平台用 `getOkResponseResult(Boolean, ErrorCode)` 回包——失败也是 errcode 0,
|
|
@@ -5132,14 +5267,26 @@ export function registerWorkflowLane(tools) {
|
|
|
5132
5267
|
* (2.1.5 ErrorCode.java:573 / 8.6.26 :548)仍在 8.6 族存在(WorkflowAspect
|
|
5133
5268
|
* .validateWorkItemParticipant:263 在开启 workflow oauth 时用),但不是 2.1.5
|
|
5134
5269
|
* data:false 的来源。`options.readSideEffect` 只在失败路径做两次只读回读。
|
|
5270
|
+
* 文案按 tool 分支见 APPROVAL_ACTION_FAILURE_HINTS(W5)。
|
|
5135
5271
|
*/
|
|
5136
5272
|
const approvalActionReceipt = async (session, result, tool, args, options) => {
|
|
5137
5273
|
const applied = result.data === true;
|
|
5138
5274
|
if (!applied) {
|
|
5139
5275
|
const instanceId = typeof args.workflowInstanceId === "string" ? args.workflowInstanceId : undefined;
|
|
5276
|
+
// Only reject reads the side-effect face — the survey found no such
|
|
5277
|
+
// side effect on the other six actions, so they stay zero-extra-wire.
|
|
5140
5278
|
const sideEffect = options?.readSideEffect === true && instanceId !== undefined
|
|
5141
5279
|
? await approvalActionSideEffectReadback(session, instanceId)
|
|
5142
5280
|
: undefined;
|
|
5281
|
+
const notAppliedMessage = tool === "workflow.reject"
|
|
5282
|
+
? `平台回了 errcode 0 但 data:false(errmsg: ${result.errmsg ?? "(空)"})——这是平台的「动作未生效」,不是成功。` +
|
|
5283
|
+
"常见原因:目标节点不可驳回(rejectToActivityCode 不在 workflow.rejectActivities 的结果里——2.1.5 真机上这是稳定复现 data:false 的唯一形状)、操作人不是该待办持有人。" +
|
|
5284
|
+
"「待办已处理/已取消」通常不是 data:false,而是非 0 业务错:2.1.5 回 409018「当前任务已被取消或者已被处理」,8.6 族的 405022「该任务已在其他页面处理」是历史码。" +
|
|
5285
|
+
"驳回失败还有平台副作用:待办可能已在失败前被取消且没有新待办(详见 sideEffectReadback)。"
|
|
5286
|
+
: `平台回了 errcode 0 但 data:false(errmsg: ${result.errmsg ?? "(空)"})——这是平台的「动作未生效」,不是成功(errcode 0 不代表已生效,成败只看 data===true)。` +
|
|
5287
|
+
(APPROVAL_ACTION_FAILURE_HINTS[tool] ?? "该动作命令体没有显式 false 分支,data:false 只能来自平台内部异常或实例锁超时。") +
|
|
5288
|
+
"「待办已处理/已取消」通常不是 data:false,而是非 0 业务错:2.1.5 回 409018「当前任务已被取消或者已被处理」,8.6 族的 405022「该任务已在其他页面处理」是历史码。" +
|
|
5289
|
+
"本动作未观察到 reject 那种「待办已取消且不复建」的副作用(真机普查 2026-11-25);仍以 workflow.instanceActivity 回读为准。";
|
|
5143
5290
|
throw new ToolRefusalError({
|
|
5144
5291
|
status: "refused",
|
|
5145
5292
|
blocker: "workflow-approval-action-not-applied",
|
|
@@ -5148,10 +5295,9 @@ export function registerWorkflowLane(tools) {
|
|
|
5148
5295
|
platformErrmsg: result.errmsg ?? null,
|
|
5149
5296
|
args,
|
|
5150
5297
|
...(sideEffect ?? {}),
|
|
5151
|
-
message:
|
|
5152
|
-
|
|
5153
|
-
|
|
5154
|
-
"驳回失败还有平台副作用:待办可能已在失败前被取消且没有新待办(详见 sideEffectReadback)。",
|
|
5298
|
+
message: notAppliedMessage,
|
|
5299
|
+
// Per-action readback: every approval action carries workflowInstanceId,
|
|
5300
|
+
// so instanceActivity is the generic next read (not reject-specific).
|
|
5155
5301
|
nextCommand: instanceId !== undefined
|
|
5156
5302
|
? `omc call workflow.instanceActivity --args '{"workflowInstanceId":"${instanceId}"}'`
|
|
5157
5303
|
: "omc call workitem.list --args '{}'",
|
|
@@ -5588,8 +5734,10 @@ export function registerWorkflowLane(tools) {
|
|
|
5588
5734
|
// 实例终态是 CANCELED(WorkflowInstanceStatus.java:15-22 只有
|
|
5589
5735
|
// DRAFT/PROCESSING/COMPLETED/CANCELED/EXCEPTION/APPROVED/TOPPING_OFF/PAUSE
|
|
5590
5736
|
// ——没有 VOIDED 这个实例态,VOIDED_APPROVER 是 endStatus),所以只认
|
|
5591
|
-
// CANCEL 家族;绝不能把 COMPLETED
|
|
5592
|
-
|
|
5737
|
+
// CANCEL 家族;绝不能把 COMPLETED/APPROVED/TOPPING_OFF 也算作废成功——
|
|
5738
|
+
// 那是 workflow.finish 的终态(见 workflow-support.ts 的
|
|
5739
|
+
// isFinishedInstanceStatus / isCanceledInstanceStatus 分工)。
|
|
5740
|
+
voided: isCanceledInstanceStatus(statusAfter),
|
|
5593
5741
|
endRulesNote: "作废走 cancelInstance(WorkflowEndStatus.VOIDED_APPROVER):实例终态 CANCELED,end handler 规则不保证执行;要正常完结(COMPLETED)并触发 end 规则用 workflow.finish(finish_instance_by_post)。",
|
|
5594
5742
|
},
|
|
5595
5743
|
};
|
package/dist/path-projection.js
CHANGED
|
@@ -703,7 +703,7 @@ function projectPathOnSource(source, path) {
|
|
|
703
703
|
}
|
|
704
704
|
return { ...first };
|
|
705
705
|
}
|
|
706
|
-
export function projectResultExtract(result, paths, keysOnly, retry) {
|
|
706
|
+
export function projectResultExtract(result, paths, keysOnly, retry, explain = false) {
|
|
707
707
|
const artifactId = typeof result.detailArtifactId === "string" ? result.detailArtifactId : typeof result.artifactId === "string" ? result.artifactId : undefined;
|
|
708
708
|
// Tools hand an in-process artifact as `detailFile` (a local path);
|
|
709
709
|
// command-transport later swaps it for detailArtifactId. Extraction runs
|
|
@@ -854,15 +854,21 @@ export function projectResultExtract(result, paths, keysOnly, retry) {
|
|
|
854
854
|
content: null,
|
|
855
855
|
pathMiss: true,
|
|
856
856
|
missedAt: fan.at,
|
|
857
|
-
available: fan.available,
|
|
858
|
-
...(fan.availableTruncated !== undefined ? { availableTruncated: fan.availableTruncated } : {}),
|
|
859
|
-
missedEntries: fan.missedEntries,
|
|
860
857
|
...(didYouMean !== undefined ? { didYouMean } : {}),
|
|
861
|
-
...(correction !== undefined ? { correctPath: correction.correctPath } : {}),
|
|
862
858
|
helpRef: PATH_MISS_HELP_REF,
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
859
|
+
// C6(0.8.4):默认只留「在哪断 + 最接近的键 + 教程指针」(≤300B);
|
|
860
|
+
// 整层键表/可复制路径/重跑命令/成因说明是排查载荷,只在 --explain 给。
|
|
861
|
+
...(explain
|
|
862
|
+
? {
|
|
863
|
+
available: fan.available,
|
|
864
|
+
...(fan.availableTruncated !== undefined ? { availableTruncated: fan.availableTruncated } : {}),
|
|
865
|
+
missedEntries: fan.missedEntries,
|
|
866
|
+
...(correction !== undefined ? { correctPath: correction.correctPath } : {}),
|
|
867
|
+
...(nextCommand !== undefined ? { nextCommand } : {}),
|
|
868
|
+
...(readFromArtifact ? resultLayerNote(result, path, projectionSource, fan.at) ?? {} : {}),
|
|
869
|
+
hint: missHintFor(fan.at, fan.available, correction),
|
|
870
|
+
}
|
|
871
|
+
: {}),
|
|
866
872
|
};
|
|
867
873
|
}
|
|
868
874
|
return {
|
|
@@ -898,14 +904,19 @@ export function projectResultExtract(result, paths, keysOnly, retry) {
|
|
|
898
904
|
content: null,
|
|
899
905
|
pathMiss: true,
|
|
900
906
|
missedAt: single.at,
|
|
901
|
-
available: single.available,
|
|
902
|
-
...(single.availableTruncated !== undefined ? { availableTruncated: single.availableTruncated } : {}),
|
|
903
907
|
...(didYouMean !== undefined ? { didYouMean } : {}),
|
|
904
|
-
...(correction !== undefined ? { correctPath: correction.correctPath } : {}),
|
|
905
908
|
helpRef: PATH_MISS_HELP_REF,
|
|
906
|
-
|
|
907
|
-
...(
|
|
908
|
-
|
|
909
|
+
// C6(0.8.4):见 fanout 同款说明——默认只留结论,排查载荷在 --explain。
|
|
910
|
+
...(explain
|
|
911
|
+
? {
|
|
912
|
+
available: single.available,
|
|
913
|
+
...(single.availableTruncated !== undefined ? { availableTruncated: single.availableTruncated } : {}),
|
|
914
|
+
...(correction !== undefined ? { correctPath: correction.correctPath } : {}),
|
|
915
|
+
...(nextCommand !== undefined ? { nextCommand } : {}),
|
|
916
|
+
...(readFromArtifact ? resultLayerNote(result, path, projectionSource, single.at) ?? {} : {}),
|
|
917
|
+
hint: missHintFor(single.at, single.available, correction),
|
|
918
|
+
}
|
|
919
|
+
: {}),
|
|
909
920
|
};
|
|
910
921
|
}
|
|
911
922
|
return {
|