@stalfh233/omc-cli 0.6.51 → 0.6.53

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.
@@ -1342,7 +1342,7 @@
1342
1342
  },
1343
1343
  {
1344
1344
  "capability": "R1 report page and BI chart lifecycle",
1345
- "status": "partial",
1345
+ "status": "executable",
1346
1346
  "scope": "Report page create/update/delete on the platform channel; BI dashboard config reads, chart data queries, datasource list/link, and chart/global/attributes writes on the /dashboard/v1 channel.",
1347
1347
  "excluded_or_unsupported_reason": "Custom SQL dataset authoring, report export (blob+polling), i18n packs, and exact BI mobile-option semantics were not exercised; BI corpId is deployment-specific (default \"a\", override per call).",
1348
1348
  "version_family": "8.6",
@@ -1379,7 +1379,8 @@
1379
1379
  ],
1380
1380
  "scopes": [
1381
1381
  "report tree read page metadata BI config chart data create update delete configure"
1382
- ]
1382
+ ],
1383
+ "revision_note": "r63(2026-11-14):partial→executable——reporter 服务启动后设计链真机端到端全通(create/tree/get/datasource.link/configure,沙盒 r63_report1 回执);chartdata 取数一跳是版本族边界(reporter 6.2↔主应用 8.6),教学信封已分叉说明。"
1383
1384
  },
1384
1385
  {
1385
1386
  "capability": "App-tree folders (目录/分组): read flattened tree, create, rename/move, non-recursive delete",
@@ -1509,4 +1510,4 @@
1509
1510
  ]
1510
1511
  }
1511
1512
  ]
1512
- }
1513
+ }
package/dist/bi-wire.js CHANGED
@@ -36,6 +36,31 @@ export async function biCall(session, call) {
36
36
  throw new WireError("malformed-envelope", `BI ${call.path} returned no data field`);
37
37
  return record.data;
38
38
  }
39
+ /**
40
+ * r63-F5(真机钉死):BI 端点存在版本族——reporter 6.2.0.45 的 datalogic 只有
41
+ * `/chartdata` 与 `/v2/chartdata`,`/v3/chartdata` 是新版 reporter 的路径
42
+ * (旧 CLI 单路径 404 直接 uncertain 冻结)。仅 HTTP 404(端点缺席)下探
43
+ * 下一个候选;其它错误原样抛(不吞真错误)。全部 404 重抛最后一个。
44
+ */
45
+ export async function biCallWith404Fallback(session, calls, onFallback) {
46
+ let lastError;
47
+ for (let index = 0; index < calls.length; index++) {
48
+ const call = calls[index];
49
+ try {
50
+ return await biCall(session, call);
51
+ }
52
+ catch (error) {
53
+ const endpointAbsent = error instanceof WireError && error.kind === "http-status" && error.diagnostic?.httpStatus === 404;
54
+ if (!endpointAbsent)
55
+ throw error;
56
+ lastError = error;
57
+ const next = calls[index + 1];
58
+ if (next && onFallback)
59
+ onFallback(call, next);
60
+ }
61
+ }
62
+ throw lastError;
63
+ }
39
64
  /** Default BI corp id observed on the aozhe tenant; overridable per call. */
40
65
  export const DEFAULT_BI_CORP_ID = "a";
41
66
  //# sourceMappingURL=bi-wire.js.map
@@ -181,7 +181,7 @@ const SURFACES = [
181
181
  description: "报表页 + BI 图表:报表树/元数据读取、报表页建改删、BI dashboard 配置、图表增改删、图表数据查询、数据集读取/关联。",
182
182
  operations: ["tree", "get", "chartdata", "datasource", "create", "update", "delete", "configure"],
183
183
  intent: { level: "partial", note: "顶层 reports[] 声明式 create/update + dashboard configure(global/attributes/charts diff,removeUnlistedCharts 删未声明图表);delete 走 omc call report.delete,datasource.link/chartdata 走 omc call。" },
184
- notes: "coverage=partial:tree/get/create/update/configure/delete 与 datasource.link/chartdata 可用;BI(/dashboard/v1/*) 缺 config 会静默 no-op,跨版本请实跑。报表页走 /api/api/report/*;BI body 必带 config:{token,reportCode,appCode}。BI 外层 corpId 是真实查询键(错值→dashboard.not.exist,空→corpid.empty),默认 \"a\",可用 corpId 覆盖。",
184
+ notes: "coverage=verified(r63 真机端到端:create/tree/get/datasource.link/configure 全通,沙盒 r63_report1 回执)。已知边界:chartdata 取数一跳在 reporter↔主应用版本族不匹配时断(conn.string.empty,教学信封会说清)。link 的真键是模型行(nodeType:1)的 objectId——datasource.list 带 parentObjectId 下钻取;应用/分组级 id 会静默绑 0 个。BI body 必带 config:{token,reportCode,appCode};外层 corpId 默认 \"a\"。chartdata 的 data/position 是 JSON 字符串字段(工具层已自动序列化)。",
185
185
  },
186
186
  {
187
187
  id: "data",
@@ -360,16 +360,16 @@ export const BOUNDARY_CUES = Object.freeze({
360
360
  * honestly instead of routing to workflow.permissions (who may originate).
361
361
  */
362
362
  /**
363
- * r19 p14(2026-10-26 用户裁决:报表**暂不优先支持、先隐藏**,不是「平台
364
- * 不支持」):报表分两层——平台层 `/api/api/report/*`(树/改名/存在性)在
365
- * 报表服务未启动时仍可用;BI 层 `/dashboard/v1/*`(详情/数据源/图表/配置)
366
- * 需要独立报表服务(本机有、当前未启动,网关统一 502,p9 实证)。边界首答
367
- * 让 agent 一轮转向;确需报表时先启动报表服务,不在 502 上重试。
363
+ * r63(2026-11-14 更新,推翻 r19 p14 的「暂不优先支持」):报表服务已启动
364
+ * (cloud8_reporter,6061),**设计链真机验证全通**——create/tree/get/
365
+ * datasource.link/configure(探针 r63_report1 端到端,TRIAGE 回执)。唯一
366
+ * 断点:chartdata 的取数一跳(reporter 6.2.0.45 ↔ 主应用 8.6 connstring
367
+ * 握手版本族断裂)。boundary 收窄到取数类目标;一般报表目标正常路由。
368
368
  */
369
369
  "report-bi": {
370
370
  status: "blocked",
371
- cues: ["报表", "仪表盘", "dashboard", "图表数据", "数据源绑定"],
372
- note: "报表能力暂不优先支持(2026-10-26 维护者裁决,先隐藏):BI 层(/dashboard/v1/*:详情/数据源/图表/配置)需要报表服务(本机有、当前未启动,网关统一 502)——不要重试这些子面。平台层仍可用:report.tree / report.update / report.get 存在性判定;report.create 在服务未启动时半成功(平台层建行、BI 初始化失败)。确需报表:先启动报表服务再深进",
371
+ cues: ["图表数据", "取数", "图表查询", "chartdata"],
372
+ note: "取数一跳是环境边界(r63 实证:reporter 6.2.0.45 ↔ 主应用 8.6 版本族不匹配,connstring 握手拿不到连接串)——换参数/重试无用。报表设计链全部可用(report.create/tree/get/datasource.link/configure 均真机验证);图表配置核对用 report.get 的 bi.charts",
373
373
  },
374
374
  });
375
375
  /** The first boundary category whose cue appears in the goal, if any. */
package/dist/cli.js CHANGED
@@ -1775,13 +1775,15 @@ async function cmdIntentPlan(file, environment, planOut, transport, summary = fa
1775
1775
  if (summary) {
1776
1776
  const plan = result.plan;
1777
1777
  if (plan !== undefined && Array.isArray(plan.changes)) {
1778
+ // r62c-F3(P0-4):resource 用编译器的资源标识(`field:model.code`),不从
1779
+ // args 猜——猜会降级成模型 code,3 个 field.create 无法区分(探针真机撞上)。
1778
1780
  return emitResult({
1779
1781
  ...result,
1780
1782
  plan: undefined,
1781
1783
  changesBrief: plan.changes.map((change) => ({
1782
1784
  tool: change.tool,
1783
1785
  ...(change.reason !== undefined ? { reason: change.reason } : {}),
1784
- resource: change.args?.schemaCode ?? change.args?.code ?? null,
1786
+ ...(change.resource !== undefined ? { resource: change.resource } : {}),
1785
1787
  })),
1786
1788
  summaryNote: "--summary 只回变更清单(去 args/基线);apply 用完整 plan(不带 --summary 或 --plan-out <file>)",
1787
1789
  }, transport);
@@ -2865,7 +2867,7 @@ async function main() {
2865
2867
  command.command("capability <id>").option("--executable").option("--max-output-bytes <bytes>").addOption(jqOption()).action(async (id, options) => {
2866
2868
  commandExitCode = await withTransport(options, request, (transport) => cmdCapability(id, transport, options.executable === true, options.jq));
2867
2869
  });
2868
- const intentCommand = command.command("intent");
2870
+ const intentCommand = command.command("intent").description("声明式意图面(Spec 107):intent.yaml → validate → plan → apply → readback。**intent/plan 文件必须位于配置根内**(与 --args-file 同规则:配置根外的文件一律拒绝,防携带凭据被收进会话产物;根外内容请先拷入或经 stdin)").addHelpText("after", "\n意图文件(validate/plan/readback 的 <file>)与 plan 产物(--plan-out)都解析到配置根内——配置根外一律 invalid-input(与 call --args-file 同规则)。\n");
2869
2871
  intentCommand.command("schema").option("--example [id]").action((options) => { commandExitCode = cmdIntentSchema({ request, maxOutputBytes: CLI_DEFAULT_OUTPUT_BYTES }, typeof options.example === "string" ? options.example : undefined, options.example !== undefined); });
2870
2872
  intentCommand.command("validate <file>").option("--show-intent").action((file, options) => { commandExitCode = cmdIntentValidate(file, { request, maxOutputBytes: CLI_DEFAULT_OUTPUT_BYTES }, options.showIntent === true); });
2871
2873
  intentCommand.command("plan <file>").option("--env <environment>").option("--plan-out <file>").option("--summary", "只回变更清单(tool+reason+资源键,去 args/基线)——复核用;apply 仍需完整 plan").option("--max-output-bytes <bytes>").action(async (file, options) => {
@@ -94,6 +94,13 @@ function encodeValue(op, value) {
94
94
  * without it the query fails with errcode 10009 类型转换异常. The value must
95
95
  * come from field metadata — never guessed (cpdocs filter-condition contract).
96
96
  */
97
+ /**
98
+ * r63(b-F12):系统字段的 propertyType 是**平台固定知识**(不是猜测)——
99
+ * sequenceStatus 是 0(string 枚举 DRAFT/PROCESSING/COMPLETED)。发布元数据
100
+ * 面不总包含它(fake 无字段模型/某些版本族),includeDrafts 的注入要跨环境
101
+ * 稳定,就在元数据 resolve 之前先查这张表。
102
+ */
103
+ const SYSTEM_FIELD_PROPERTY_TYPES = Object.freeze({ sequenceStatus: 0 });
97
104
  export function injectPropertyTypes(condition, resolve) {
98
105
  const missing = new Set();
99
106
  const walk = (node) => {
@@ -101,7 +108,7 @@ export function injectPropertyTypes(condition, resolve) {
101
108
  return node.map(walk);
102
109
  const leaf = node;
103
110
  const code = String(leaf?.propertyCode ?? "");
104
- const type = resolve(code);
111
+ const type = SYSTEM_FIELD_PROPERTY_TYPES[code] ?? resolve(code);
105
112
  if (type === undefined) {
106
113
  missing.add(code);
107
114
  return leaf;
package/dist/goal-plan.js CHANGED
@@ -1062,7 +1062,11 @@ export async function planGoal(registry, goal, options = {}) {
1062
1062
  const scaffoldCode = scaffoldCodeFrom(goal);
1063
1063
  scaffold = { code: scaffoldCode };
1064
1064
  args[key] = scaffoldCode;
1065
- warnings.push(`schemaCode: 目标模型 ${scaffoldCode} 尚不存在——已排 s0 建模脚手架(model.create + field.publish 模型级一次发布);业务字段清单按需求补 field.create(本计划不猜字段)`);
1065
+ // r62a-F1(P0-3):s0→s0p 中间没有字段步骤——发布的是**空模型**。
1066
+ // 计划看起来完整、实际中间是空的(探针真机:得自己插 CREATE 才能跑通)。
1067
+ // 字段清单是需求本体(needs-authoring),计划不猜;但必须明说空心,
1068
+ // 并指路 intent(一次编译全链,含字段)。
1069
+ warnings.push(`schemaCode: 目标模型 ${scaffoldCode} 尚不存在——已排 s0 建模脚手架,但 s0p 此刻发布的是**空模型**(本计划不替你猜字段清单):要么先补 field.create 再发布,要么整包需求改走声明式面(omc intent schema → validate → plan --env),字段/规则/流程一次编译`);
1066
1070
  continue;
1067
1071
  }
1068
1072
  else {
@@ -1164,7 +1168,7 @@ export async function planGoal(registry, goal, options = {}) {
1164
1168
  id: "s0p",
1165
1169
  tool: "field.publish",
1166
1170
  kind: "write",
1167
- purpose: "b-F1 前置链:模型级发布(发布全部草稿字段;流程/视图/规则面依赖已发布字段)",
1171
+ purpose: "b-F1 前置链:模型级发布——注意此刻模型是空的(r62a-F1):字段清单是需求本体,先补 field.create 再发布,或改走 intent 声明式面一次编译全链",
1168
1172
  args: { ...(environment !== null ? { environment } : {}), schemaCode: scaffold.code },
1169
1173
  dependsOn: ["s0"],
1170
1174
  validated: { ok: true, issues: [] },
@@ -12,7 +12,7 @@ import { listSkills, readSkillSection } from "./skills.js";
12
12
  */
13
13
  const SCOUT_CUES = ["能不能", "能不能够", "能否", "是否支持", "支持吗", "支持不支持", "可不可以", "有没有办法", "有没有可能", "怎么实现", "如何实现", "怎么写", "怎么配置"];
14
14
  const MODIFY_CUES = ["修改", "调整", "更新", "重命名", "改名", "编辑", "删除", "去掉", "移除", "改为", "改成"];
15
- const READ_CUES = ["查看", "读回", "盘点", "现状", "列出", "有哪些", "有没有", "检查", "审计", "导出", "只读", "看看", "看下", "查一下", "查询一下", "查一查", "梳理", "清点", "给我一份", "哪些", "是什么", "是否", "是否正确", "现有", "已有", "条数", "多少条", "数一下"];
15
+ const READ_CUES = ["查看", "读回", "盘点", "现状", "列出", "有哪些", "有没有", "检查", "审计", "导出", "只读", "看看", "看下", "查一下", "查询一下", "查一查", "梳理", "清点", "给我一份", "哪些", "是什么", "是否", "是否正确", "现有", "已有", "条数", "多少条", "数一下", "有几条", "几条", "有几个", "几个", "几笔", "多少个", "名单", "分布"];
16
16
  const BUILD_CUES = ["新建", "创建", "搭建", "从零", "从无到有", "做", "建", "加", "实现", "生成", "新增", "保存", "启用", "录入", "添加", "造", "填报", "打卡", "录"];
17
17
  /** Whole-application asks — a single-model atom is the wrong shape for these. */
18
18
  const WHOLE_APP_CUES = ["应用", "系统", "整套", "从零", "从无到有", "端到端", "一条龙", "一整套", "业务应用", "平台"];
@@ -749,7 +749,7 @@ function goalRouteInner(registry, goal) {
749
749
  // 聚合/计数问句的正确答案:data 能力**没有 group-by 工具**,诚实指路
750
750
  // data.list 拉全量 + `--jq` 投影自行计数;跨模型/大结果集才涉及报表章节。
751
751
  // 放在能力打分前,聚合词不再落进任何写阶梯(cue「分组」已从 app 移除)。
752
- if (readish && /(统计|分组|汇总|聚合|计数|条数|多少条|数一下)/.test(goal) && !WRITE_DESTINATION.test(goal)) {
752
+ if (readish && /(统计|分组|汇总|聚合|计数|条数|多少条|有几条|数一下)/.test(goal) && !WRITE_DESTINATION.test(goal)) {
753
753
  const dataRoute = routeById.get("data");
754
754
  if (dataRoute !== undefined) {
755
755
  const readTools = readToolsInLane(registry, dataRoute.lane);
@@ -951,7 +951,18 @@ function goalRouteInner(registry, goal) {
951
951
  // 会把真别名路由也拦掉(bizservice-recipes 别名测试实证)。
952
952
  if (!readish && !WHOLE_APP_CUES.some((cue) => goal.includes(cue))) {
953
953
  const aliasHit = bestAliasRecipe(registry, goal);
954
- if (aliasHit) {
954
+ // r62b-F1(真机复现,P0-1 第三层防御):「合同里金额大于50万的单据有几条」
955
+ // 被配方别名「金额大于」抢到 workflow 写配方——纯读问句拿到写工具,照做
956
+ // 会改生产流程。cue 词表(detectMode)是第一层,但问法无穷(「有几条/
957
+ // 名单/分布/给我拉一份」都可能是漏网的新词)。别名分支自身再判一次:
958
+ // 命中的配方是写工具、而问句带读尾缀时,别名不抢——落回正常能力阶梯
959
+ // (readish 路径会给读工具 + 聚合护栏的诚实指路)。
960
+ const READ_TAIL = /(几条|几个|几笔|多少|哪些|名单|分布|给我|拉一份|导出|统计|汇总|计数|条数)/;
961
+ const aliasToolKind = aliasHit === undefined ? undefined : registry.find((tool) => tool.name === aliasHit.tool)?.kind;
962
+ if (aliasHit && aliasToolKind === "write" && READ_TAIL.test(goal)) {
963
+ // fall through:读意图问句不带写别名路由
964
+ }
965
+ else if (aliasHit) {
955
966
  const action = `omc describe ${aliasHit.tool} --example ${aliasHit.recipe}`;
956
967
  return {
957
968
  status: "ok",
@@ -4,7 +4,7 @@ import { capabilityArg, environmentArg } from "../args.js";
4
4
  import { governedRead } from "../read.js";
5
5
  import { writeTool } from "../write.js";
6
6
  import { decodeJsonColumn, JSON_COLUMN_NULL_COALESCE } from "../json-column.js";
7
- import { applicationResolutionOf, applicationScopeHint, flattenTreeRows, resolveApplicationScope } from "../support.js";
7
+ import { applicationResolutionOf, applicationScopeHint, flattenTreeRows, resolveApplicationScope, suggestModelNames } from "../support.js";
8
8
  import { executeRuleSaveWrite, ruleNodeGraphArg } from "../rule-support.js";
9
9
  import { defineTool, ToolInputError, ToolRefusalError } from "../tool-types.js";
10
10
  import { resolveRuleRowId } from "../identity.js";
@@ -117,11 +117,20 @@ export function registerBusinessRuleLane(tools) {
117
117
  // 直接回 modelPresent:false + rules:[],**不发 list 请求**。
118
118
  const modelRecord = await readModelRecord(session, args.schemaCode);
119
119
  if (modelRecord === null) {
120
+ // r62b-F2(P1-5):带近名候选 + 可转发问句(plan 面 needs-decision 的
121
+ // call 面同款)——探针此前得自己翻 model.list 编问句。
122
+ const suggested = await suggestModelNames(session, args.schemaCode);
120
123
  return {
121
124
  schemaCode: args.schemaCode,
122
125
  modelPresent: false,
123
126
  rules: [],
124
127
  rulesCount: 0,
128
+ ...(suggested !== null
129
+ ? {
130
+ suggestedModels: suggested,
131
+ needsDecision: `未找到「${args.schemaCode}」,是否指 ${suggested.map((model) => `${model.code}(${model.name ?? model.code})`).join(" / ")}?`,
132
+ }
133
+ : {}),
125
134
  hint: "模型不存在(bizmodels/get_all 空)——未发 rule.list 请求(避免补建 7 条不可删预置);判定模型面用 model.inspect",
126
135
  };
127
136
  }
@@ -10,6 +10,7 @@ import { defineTool } from "../tool-types.js";
10
10
  import { resolveDataRuleRow } from "../identity.js";
11
11
  import { wireCall, wireRows, WireError } from "../wire.js";
12
12
  import { runtimeWriteWithAppMapping } from "../runtime-support.js";
13
+ import { suggestModelNames } from "../support.js";
13
14
  import { DATARULE_LANE_CONTRACT, DATARULE_TYPE_OPTION_KEYS } from "./datarule-contract.js";
14
15
  import { normalizeAggregationFormula } from "../field-families.js";
15
16
  import { CONDITION_PROTOCOL_EXAMPLES, dataRuleOptionsShapeError } from "./datarule-protocol.js";
@@ -809,12 +810,20 @@ export function registerDataRuleLane(tools) {
809
810
  // 不把平台 601003 原样 refused(三种读面反应不一致)。
810
811
  const modelRecord = await readModelRecord(session, args.schemaCode);
811
812
  if (modelRecord === null) {
813
+ // r62b-F2(P1-5):与 rule.list 同款近名候选 + 可转发问句。
814
+ const suggested = await suggestModelNames(session, args.schemaCode);
812
815
  return {
813
816
  schemaCode: args.schemaCode,
814
817
  dataRuleType: args.dataRuleType ?? null,
815
818
  modelPresent: false,
816
819
  rules: [],
817
820
  rulesCount: 0,
821
+ ...(suggested !== null
822
+ ? {
823
+ suggestedModels: suggested,
824
+ needsDecision: `未找到「${args.schemaCode}」,是否指 ${suggested.map((model) => `${model.code}(${model.name ?? model.code})`).join(" / ")}?`,
825
+ }
826
+ : {}),
818
827
  hint: "模型不存在(bizmodels/get_all 空)——空规则不是「已清干净的证据」也不是错误;判定模型面用 model.inspect",
819
828
  };
820
829
  }
@@ -865,7 +874,7 @@ export function registerDataRuleLane(tools) {
865
874
  writeTool({
866
875
  tools,
867
876
  name: "datarule.create",
868
- search: { intents: ["字段级校验", "给字段加校验", "给金额字段加校验", "校验规则", "提交校验", "字段校验", "金额校验"] },
877
+ search: { intents: ["字段级校验", "给字段加校验", "给金额字段加校验", "校验规则", "提交校验", "字段校验", "金额校验", "必填才能提交", "必须填", "不填不让提交"] },
869
878
  lane: DATARULE_LANE,
870
879
  scope: DATARULE_TOOLS["datarule.create"].scope,
871
880
  description: DATARULE_TOOLS["datarule.create"].description,
@@ -455,6 +455,10 @@ export function registerFormLane(tools) {
455
455
  return {
456
456
  steps: results,
457
457
  readback: {
458
+ // r63(a-F6):表单名此前恒 `?`(回执不带,探针只能从别处猜)——sheetGet
459
+ // 的 name 就是表单名,直接回读。
460
+ formName: typeof pub.name === "string" ? pub.name : null,
461
+ sheetCode,
458
462
  formPublished: pub.published === true,
459
463
  publishedHtmlJsonPresent: typeof pub.publishedHtmlJson === "string",
460
464
  publishedControlCodes,
@@ -17,6 +17,26 @@ import { assertListViewConfigureShape, decodeActionRow, decodeButtonRow, decodeC
17
17
  export { assertListViewConfigureShape } from "./list-view-shapes.js";
18
18
  const LIST_VIEW_LANE = LIST_VIEW_LANE_CONTRACT.lane;
19
19
  const LIST_VIEW_TOOLS = LIST_VIEW_LANE_CONTRACT.tools;
20
+ /**
21
+ * r62a-F5 / r61 a-F14:列汇总(sumType)真值在呈现层 queryPresentation.columnsJson
22
+ * ——queryColumns 列树不回它。listview.get 与 listview.configure 的读回共用这个
23
+ * 合并映射,任何读面对同一配置给同一个答案(双面一致)。
24
+ */
25
+ function sumTypeByCodeFromPresentation(model) {
26
+ const out = new Map();
27
+ const rawPresentation = model.queryPresentation;
28
+ if (!rawPresentation || typeof rawPresentation !== "object")
29
+ return out;
30
+ const decodedColumns = decodePresentation(rawPresentation).columnsJson;
31
+ if (!Array.isArray(decodedColumns))
32
+ return out;
33
+ for (const column of decodedColumns) {
34
+ if (column && typeof column === "object" && typeof column.propertyCode === "string" && typeof column.sumType === "number") {
35
+ out.set(String(column.propertyCode), column.sumType);
36
+ }
37
+ }
38
+ return out;
39
+ }
20
40
  function fieldOptions(options) {
21
41
  if (typeof options === "string") {
22
42
  try {
@@ -284,11 +304,16 @@ export function registerListViewLane(tools) {
284
304
  return { schemaCode: args.schemaCode, code, present: false, note: "视图不存在(query/get 空或 302025);先 listview.create 或 listview.configure" };
285
305
  if (args.full === true)
286
306
  return { schemaCode: args.schemaCode, code, present: true, data: model };
307
+ // r62a-F5(P0-2):queryColumns 列树不含 sumType(恒 null/缺键),列汇总
308
+ // 真值在呈现层 queryPresentation.columnsJson——与 listview.configure 的
309
+ // 读回同规则合并,get 面不再逼探针翻 full 原始报文。
310
+ const sumTypeByCode = sumTypeByCodeFromPresentation(model);
287
311
  const columns = readArray(model, "queryColumns").map((column) => ({
288
312
  propertyCode: column.propertyCode,
289
313
  propertyType: column.propertyType,
290
314
  displayFormat: column.displayFormat,
291
315
  visible: column.visible,
316
+ sumType: sumTypeByCode.get(String(column.propertyCode)) ?? column.sumType ?? null,
292
317
  }));
293
318
  // Direction is decoded to the enum NAME (ASC/DESC) — the same shape
294
319
  // `listview.configure` reads back, so a get→configure round-trip does not
@@ -545,7 +570,7 @@ export function registerListViewLane(tools) {
545
570
  writeTool({
546
571
  tools,
547
572
  name: "listview.configure",
548
- search: { intents: ["配置列表列", "配列表", "列表列"] },
573
+ search: { intents: ["配置列表列", "配列表", "列表列", "只显示", "不显示哪些列"] },
549
574
  lane: LIST_VIEW_LANE,
550
575
  scope: LIST_VIEW_TOOLS["listview.configure"].scope,
551
576
  description: LIST_VIEW_TOOLS["listview.configure"].description,
@@ -814,23 +839,11 @@ export function registerListViewLane(tools) {
814
839
  }
815
840
  const after = await wireCall(session, { path: ENDPOINTS.listQueryGet, query: { schemaCode: args.schemaCode, code, clientType: "PC" } });
816
841
  const afterModel = (after.data ?? {});
817
- // r61 a-F14(r60a-F14 真机定性):`queryColumns` 列树**不回 sumType**(投影恒
818
- // null),列汇总真值在呈现层 `queryPresentation.columnsJson`——写入面也是它。
819
- // 两面各说各话曾让探针为对账「合计配上了吗」拉全量 presentation(26KB
820
- // artifact 的根因)。这里把真值按 propertyCode 合并进列投影,单面即可对账;
821
- // 仅当呈现层该列无 sumType 时才回退列树值(保持 null=不统计的可读性)。
822
- const sumTypeByCode = new Map();
823
- const rawPresentation = afterModel.queryPresentation;
824
- if (rawPresentation && typeof rawPresentation === "object") {
825
- const decodedColumns = decodePresentation(rawPresentation).columnsJson;
826
- if (Array.isArray(decodedColumns)) {
827
- for (const column of decodedColumns) {
828
- if (column && typeof column === "object" && typeof column.propertyCode === "string" && typeof column.sumType === "number") {
829
- sumTypeByCode.set(String(column.propertyCode), column.sumType);
830
- }
831
- }
832
- }
833
- }
842
+ // r61 a-F14(r60a-F14 真机定性)+ r62a-F5(P0-2):`queryColumns` 列树**不回
843
+ // sumType**(投影恒 null),列汇总真值在呈现层 `queryPresentation.columnsJson`
844
+ // ——写入面也是它。两面各说各话曾让探针为对账「合计配上了吗」拉全量
845
+ // presentation(26KB artifact 的根因)。get 与 configure 共用合并映射。
846
+ const sumTypeByCode = sumTypeByCodeFromPresentation(afterModel);
834
847
  const afterCols = readArray(afterModel, "queryColumns").map((c) => ({
835
848
  propertyCode: c.propertyCode,
836
849
  propertyType: c.propertyType,
@@ -892,11 +892,19 @@ export function registerModelLane(tools) {
892
892
  absent = (await readRecord()) === null;
893
893
  }
894
894
  const treeNodePending = (await treeRows()).some((row) => row.type === "BizModel" && row.code === args.schemaCode);
895
+ // r63(a-F9):absent:true 与 treeNodePending:true 曾并排出现——「记录没了但
896
+ // 树上还在」是不是没删干净?给一句显式清零判据,别让探针自己猜组合语义。
897
+ const cleanVerdict = absent && !treeNodePending
898
+ ? "已删干净(判据:bizmodels 记录 absent=true 且应用树无该 BizModel 节点)"
899
+ : absent && treeNodePending
900
+ ? "记录已删、树节点残留——级联仍在拆或残留需 model-purge;等 60s 复核 model.delete(幂等)"
901
+ : "尚未删净:记录还在(级联进行中),等 60s 后重跑 model.delete 复核";
895
902
  return {
896
903
  performed: { errcode: performed.errcode, deletedId: targetId, applicationCode },
897
904
  readback: {
898
905
  absent,
899
906
  treeNodePending,
907
+ cleanVerdict,
900
908
  ...(liveWorkflows.length > 0
901
909
  ? {
902
910
  workflowWarning: {
@@ -670,7 +670,7 @@ export function registerOrganizationLane(tools) {
670
670
  writeTool({
671
671
  tools,
672
672
  name: "org.department.update",
673
- search: { intents: ["改部门", "重命名部门", "调整部门信息", "换部门主管"] },
673
+ search: { intents: ["改部门", "重命名部门", "调整部门信息", "换部门主管", "部门停用", "停用部门"] },
674
674
  lane: LANE,
675
675
  scope: SCOPES.deptUpdate,
676
676
  description: "改部门(`POST organization/department/modefied`)。先 get_dept_info 读现状再合并提交,只传要改的字段(名称/上级/主管/排序/备注/启用)。",
@@ -289,7 +289,7 @@ export function registerPermLane(tools) {
289
289
  return { userId: args.userId, appCode: args.appCode, adminBypass, ...(adminBypass ? { adminNotice: "管理员会话恒通过,不代表普通用户;本回执是管理员旁路标记。" } : {}), app: { visible: bool(first(data, "visible", "appVisible")), administrator: bool(first(data, "administrator", "isAdministrator")), allVisible: bool(first(data, "allVisible")) }, models: authSummary(data).models, fields: args.schemaCode ? authSummary(data).fields : [], rowLevel: authSummary(data).rowLevel, layers: { configResolvable: true, runtimeSessionRequired: "真实 load/write 判定受对象权限/业务调用/临时流程授权影响——本工具拒绝单值 allow/deny;验证走目标用户会话或 data.load 双读" } };
290
290
  }) }));
291
291
  writeTool({ tools, name: "perm.assign", lane: PERM_LANE, scope: PERM_TOOLS["perm.assign"].scope, description: PERM_TOOLS["perm.assign"].description, search: { intents: ["把部门加到权限组", "授权权限组", "给权限组加成员"] }, inputSchema: { appCode: z.string().min(1), groupId: z.string().min(1), units: z.array(z.object({ type: z.enum(["DEPT", "ROLE", "USER"]), id: z.string().min(1), name: z.string().optional() })).min(1), mode: z.enum(["assign", "revoke"]) }, execute: async (session, args) => { const unitType = { DEPT: 1, ROLE: 2, USER: 3 }[args.units[0].type]; const units = args.units.map((u) => ({ unitId: u.id, unitType: { DEPT: 1, ROLE: 2, USER: 3 }[u.type], name: u.name ?? "", corpId: session.enterpriseId(), appCode: args.appCode, groupId: args.groupId })); const body = args.mode === "assign" ? { permissionGroupUnits: units, permGroupInfos: [{ appCode: args.appCode, permGroupId: args.groupId }] } : { permGroupIds: [args.groupId], unitIds: args.units.map((u) => u.id), permissionGroupUnits: units, permGroupInfos: [{ appCode: args.appCode, permGroupId: args.groupId }] }; const before = (await wireCall(session, { path: ENDPOINTS.permissionGroup, method: "GET", query: { id: args.groupId, appCode: args.appCode } })).data; const performed = await wireCall(session, { path: args.mode === "assign" ? ENDPOINTS.permissionAssign : ENDPOINTS.permissionRevoke, method: "POST", body }); const after = (await wireCall(session, { path: ENDPOINTS.permissionGroup, method: "GET", query: { id: args.groupId, appCode: args.appCode } })).data; const listAfter = (await wireCall(session, { path: ENDPOINTS.permissionGroupUnits, method: "POST", body: { ...units[0], unitType, appCode: args.appCode, corpId: session.enterpriseId() } })).data; return { performed: { errcode: performed.errcode, mode: args.mode }, readback: { groups: permissionGroupRows(listAfter).map(groupView), source: "post-write listPermissionGroups readback (not write echo)", diff: { before: projectMembers(before), after: projectMembers(after) } } }; } });
292
- writeTool({ tools, name: "perm.auth", lane: PERM_LANE, scope: PERM_TOOLS["perm.auth"].scope, description: PERM_TOOLS["perm.auth"].description, search: { intents: ["配模型权限", "设行级权限", "配数据权限"] }, inputSchema: { appCode: z.string().min(1), groupId: z.string().min(1), grants: z.array(z.object({ schemaCode: z.string().min(1), visible: z.object({ pc: z.boolean(), mobile: z.boolean() }).optional(), rowLevel: z.object({ type: z.number().int().min(1).max(6).describe("1=全部可见,2=本部门,3=仅自己,4=自定义(须 conditions),5=角色管理范围,6=均不可见"), conditions: z.array(z.array(z.unknown())).optional() }).optional(), properties: z.array(z.object({ propertyCode: z.string().optional(), schemaCode: z.string().optional().describe("可省略,继承 grants.schemaCode"), visible: z.boolean().optional(), writeAble: z.boolean().optional(), decryptAble: z.boolean().optional() })).optional(), actions: z.object({ view: z.array(z.string()).optional(), form: z.array(z.string()).optional() }).optional() })).min(1), mode: z.enum(["merge"]).default("merge") }, preflight: (args) => validateGrants(args.grants), execute: async (session, args) => { const group = (await wireCall(session, { path: ENDPOINTS.permissionGroup, method: "GET", query: { id: args.groupId, appCode: args.appCode } })).data; const existing = permissionRecords(group); const mergedRecords = []; const beforeRecords = []; for (const grant of args.grants) {
292
+ writeTool({ tools, name: "perm.auth", lane: PERM_LANE, scope: PERM_TOOLS["perm.auth"].scope, description: PERM_TOOLS["perm.auth"].description, search: { intents: ["配模型权限", "设行级权限", "配数据权限", "只能看自己的", "别让他看到", "只能看到自己提的", "只能查看自己", "不能看别人的"] }, inputSchema: { appCode: z.string().min(1), groupId: z.string().min(1), grants: z.array(z.object({ schemaCode: z.string().min(1), visible: z.object({ pc: z.boolean(), mobile: z.boolean() }).optional(), rowLevel: z.object({ type: z.number().int().min(1).max(6).describe("1=全部可见,2=本部门,3=仅自己,4=自定义(须 conditions),5=角色管理范围,6=均不可见"), conditions: z.array(z.array(z.unknown())).optional() }).optional(), properties: z.array(z.object({ propertyCode: z.string().optional(), schemaCode: z.string().optional().describe("可省略,继承 grants.schemaCode"), visible: z.boolean().optional(), writeAble: z.boolean().optional(), decryptAble: z.boolean().optional() })).optional(), actions: z.object({ view: z.array(z.string()).optional(), form: z.array(z.string()).optional() }).optional() })).min(1), mode: z.enum(["merge"]).default("merge") }, preflight: (args) => validateGrants(args.grants), execute: async (session, args) => { const group = (await wireCall(session, { path: ENDPOINTS.permissionGroup, method: "GET", query: { id: args.groupId, appCode: args.appCode } })).data; const existing = permissionRecords(group); const mergedRecords = []; const beforeRecords = []; for (const grant of args.grants) {
293
293
  const prior = existing.find((record) => String(first(record, "schemaCode", "functionCode") ?? "") === grant.schemaCode);
294
294
  if (!prior)
295
295
  throw new ToolRefusalError({ status: "refused", blocker: "permission-target-model-unknown", message: `权限组中不存在模型 ${grant.schemaCode};候选:${existing.map((record) => String(first(record, "schemaCode", "functionCode") ?? "")).filter(Boolean).join(", ")}` });
@@ -4,8 +4,9 @@ import { capabilityArg, environmentArg } from "../args.js";
4
4
  import { governedRead } from "../read.js";
5
5
  import { writeTool } from "../write.js";
6
6
  import { defineTool, ToolRefusalError } from "../tool-types.js";
7
- import { wireCall, WireError } from "../wire.js";
8
- import { biCall, DEFAULT_BI_CORP_ID } from "../bi-wire.js";
7
+ import { wireCall, wireRows, WireError } from "../wire.js";
8
+ import { mapBounded } from "../support.js";
9
+ import { biCall, biCallWith404Fallback, DEFAULT_BI_CORP_ID } from "../bi-wire.js";
9
10
  import { REPORT_LANE_CONTRACT } from "./report-contract.js";
10
11
  import { readAppTree } from "./folder.js";
11
12
  const LANE = REPORT_LANE_CONTRACT.lane;
@@ -80,6 +81,32 @@ function parseJsonText(value) {
80
81
  function isMissingDashboard(error) {
81
82
  return error instanceof WireError && /dashboard\.not\.exist|The dashboard does not exist/i.test(error.message);
82
83
  }
84
+ /**
85
+ * r63-F1(真机钉死):`queryReportChartTree` 只回**已配图表**的报表——本环境
86
+ * 无图报表/孤儿节点都不在(两参数变体恒 `[]`,而应用树里有 3+1 个 Report 节点)。
87
+ * 应用报表清单的权威源 = 应用树(apppackage/trees)的 `type=Report` 节点;
88
+ * chartTree 降级为补充维度(配了图的报表数)。孤儿报表(parentId 非法被平台
89
+ * 原样存储)在两棵树都不可见——create/update 的 parentId 门才是防线。
90
+ */
91
+ function assertParentIsFolder(session, appCode, parentId) {
92
+ return (async () => {
93
+ const rows = await readAppTree(session, appCode);
94
+ const folders = rows.filter((row) => String(row.type ?? "") === "Folder");
95
+ if (folders.some((row) => String(row.id ?? "") === parentId))
96
+ return;
97
+ const candidates = folders.slice(0, 8).map((row) => ({ id: row.id, name: row.name, path: row.path }));
98
+ throw new ToolRefusalError({
99
+ status: "refused",
100
+ blocker: "report-parent-not-folder",
101
+ appCode,
102
+ parentId,
103
+ folderCandidates: candidates,
104
+ nextCommand: `omc call folder.tree --args '{"applicationCode":"${appCode}","foldersOnly":true}'`,
105
+ message: `parentId="${parentId}" 不是应用 ${appCode} 树里 type=Folder 的目录 id——平台会把非法值**原样存储**(h_app_function.parentId="test" 实证),` +
106
+ "报表变孤儿:应用树/报表树/门户都看不到,report.get 仍能按 code 命中(更具迷惑性)。用 folderCandidates 或 folder.tree 拿真实目录 id。",
107
+ });
108
+ })();
109
+ }
83
110
  /** Recursively collect report functions from a report tree (queryReportChartTree[*]). */
84
111
  function collectReports(node, out) {
85
112
  if (Array.isArray(node)) {
@@ -271,14 +298,57 @@ export function registerReportLane(tools) {
271
298
  lane: LANE,
272
299
  scope: TOOLS["report.tree"].scope,
273
300
  description: TOOLS["report.tree"].description,
274
- inputSchema: { environment: environmentArg, capability: capabilityArg, appCode: z.string().optional() },
301
+ inputSchema: { environment: environmentArg, capability: capabilityArg, appCode: z.string().optional().describe("应用 code;省略遍历全部应用") },
275
302
  handler: async (ctx, args, self) => governedRead(ctx, self, args, async (session) => {
276
- const data = args.appCode
277
- ? (await wireCall(session, { path: ENDPOINTS.reportTreeByApp, query: { appCode: args.appCode } })).data
278
- : (await wireCall(session, { path: ENDPOINTS.reportTreeAll, method: "POST", body: {} })).data;
279
- const reports = [];
280
- collectReports(data, reports);
281
- return { appCode: args.appCode ?? null, reportCount: reports.length, reports };
303
+ // r63-F1:主源 = 应用树 type=Report 节点(无图也可见);chartTree 只回
304
+ // 配了图的报表,降级为补充计数。孤儿节点(parentId 非法)两边都不可见。
305
+ const appCodes = args.appCode
306
+ ? [args.appCode]
307
+ : wireRows((await wireCall(session, { path: ENDPOINTS.applicationList, query: {} })).data)
308
+ .map((row) => String(row.appCode ?? row.code ?? ""))
309
+ .filter((code) => code !== "");
310
+ const perApp = await mapBounded(appCodes, 4, async (appCode) => {
311
+ const rows = await readAppTree(session, appCode);
312
+ return rows
313
+ .filter((row) => String(row.type ?? "") === "Report")
314
+ .map((row) => ({
315
+ appCode,
316
+ code: row.code,
317
+ name: row.name,
318
+ treeNodeId: row.id,
319
+ parentId: row.parentId,
320
+ path: row.path,
321
+ }));
322
+ });
323
+ const reports = perApp.flat();
324
+ const chartsByCode = new Map();
325
+ try {
326
+ const data = args.appCode
327
+ ? (await wireCall(session, { path: ENDPOINTS.reportTreeByApp, query: { appCode: args.appCode } })).data
328
+ : (await wireCall(session, { path: ENDPOINTS.reportTreeAll, method: "POST", body: {} })).data;
329
+ const charted = [];
330
+ collectReports(data, charted);
331
+ for (const entry of charted) {
332
+ const code = String(entry.code ?? "");
333
+ if (code)
334
+ chartsByCode.set(code, entry.charts ?? []);
335
+ }
336
+ }
337
+ catch {
338
+ // chartTree 是补充维度:BI 服务不可用时树面仍要可用。
339
+ }
340
+ for (const report of reports) {
341
+ const charts = chartsByCode.get(String(report.code ?? ""));
342
+ if (charts)
343
+ report.charts = charts;
344
+ }
345
+ return {
346
+ appCode: args.appCode ?? null,
347
+ reportCount: reports.length,
348
+ reports,
349
+ chartTreeCount: chartsByCode.size,
350
+ note: "权威源 = 应用树 type=Report 节点(无图报表也列出);chartTreeCount 是 queryReportChartTree 口径(只回已配图表的报表)。树里看不到但 report.get 命中的报表是孤儿(parentId 非法被平台原样存储)——create/update 已按 folder id 门禁。",
351
+ };
282
352
  }),
283
353
  }));
284
354
  tools.push(defineTool({
@@ -289,11 +359,40 @@ export function registerReportLane(tools) {
289
359
  lane: LANE,
290
360
  scope: TOOLS["report.get"].scope,
291
361
  description: TOOLS["report.get"].description,
292
- inputSchema: { environment: environmentArg, capability: capabilityArg, code: z.string().min(1), corpId: z.string().optional(), full: z.boolean().default(false) },
362
+ inputSchema: { environment: environmentArg, capability: capabilityArg, code: z.string().min(1), appCode: z.string().optional().describe("校验归属应用;不符则拒"), corpId: z.string().optional(), full: z.boolean().default(false) },
293
363
  handler: async (ctx, args, self) => governedRead(ctx, self, args, async (session) => {
294
364
  const page = (await wireCall(session, { path: ENDPOINTS.reportGet, query: { code: args.code } })).data;
365
+ // r63-F2:族内口径对齐——datasource.*/chartdata 要求 reportCode+appCode,
366
+ // get 此前把 appCode 拒之门外(tool-has-no-app-scope)。改为接受并**校验**:
367
+ // 不符即拒,同名 code 跨应用的混淆在 get 面就暴露。
368
+ if (args.appCode !== undefined && page.appCode !== undefined && String(page.appCode) !== args.appCode) {
369
+ throw new ToolRefusalError({
370
+ status: "refused",
371
+ blocker: "report-app-code-mismatch",
372
+ code: args.code,
373
+ appCode: args.appCode,
374
+ pageAppCode: String(page.appCode),
375
+ message: `报表 ${args.code} 属于应用 ${String(page.appCode)},不是 ${args.appCode}——code 跨应用可能同名,请核对后用页行的 appCode 调 BI 族工具`,
376
+ });
377
+ }
295
378
  const objectId = String(page.id ?? page.reportObjectId ?? "");
296
- const auth = authOf(args.corpId, String(page.code ?? args.code), String(page.appCode ?? ""));
379
+ // r63-F1:parent 权威源 = 应用树节点。report/get 不回 parentId,其
380
+ // folderList 末项在孤儿场景指向无关目录(真机实证:孤儿报表的 folderList
381
+ // 末端是「固定资产管理」,而 DB 里 parentId="test")——不再用那个回退。
382
+ const treeNode = objectId && page.appCode ? await resolveReportTreeNode(session, String(page.appCode), String(page.code ?? args.code)) : null;
383
+ const view = reportPageView(page, treeNode?.parentId ?? undefined);
384
+ if (treeNode === null) {
385
+ view.parentId = null;
386
+ view.parentIdSource = "unresolved";
387
+ view.treeVisibility = "not-listed";
388
+ view.orphanNote = "应用树里找不到该报表节点(type=Report)——大概率是孤儿:parentId 非法被平台原样存储(h_app_function.parentId 指向不存在的目录)。report.update 传合法目录 id 可救回。";
389
+ }
390
+ else {
391
+ view.parentIdSource = "app-tree";
392
+ if (treeNode.path)
393
+ view.path = treeNode.path;
394
+ }
395
+ const auth = authOf(args.corpId, String(page.code ?? args.code), String(args.appCode ?? page.appCode ?? ""));
297
396
  const bi = objectId ? await readBiConfig(session, auth, objectId) : { present: false, charts: [], title: undefined, global: undefined, attributes: undefined };
298
397
  const biView = {
299
398
  present: bi.present,
@@ -305,7 +404,7 @@ export function registerReportLane(tools) {
305
404
  attributesPresent: bi.attributes !== undefined && JSON.stringify(bi.attributes) !== "{}",
306
405
  };
307
406
  return {
308
- report: reportPageView(page),
407
+ report: view,
309
408
  bi: biView,
310
409
  global: bi.global,
311
410
  attributes: bi.attributes,
@@ -335,12 +434,17 @@ export function registerReportLane(tools) {
335
434
  handler: async (ctx, args, self) => governedRead(ctx, self, args, async (session) => {
336
435
  const raw = args.chart;
337
436
  const chart = chartParamModel(raw);
338
- const data = await biCall(session, {
339
- path: ENDPOINTS.biChartData,
437
+ // r63-F5:datalogic/chartdata 有版本族(v3 → v2 → v1),404 下探。
438
+ const base = {
340
439
  query: { lang: args.lang },
341
440
  body: { chart, dataSourceId: args.dataSourceId ?? raw.dataSourceId, corpId: args.corpId ?? DEFAULT_BI_CORP_ID },
342
441
  auth: authOf(args.corpId, args.reportCode, args.appCode),
343
- });
442
+ };
443
+ const data = await biCallWith404Fallback(session, [
444
+ { path: ENDPOINTS.biChartData, ...base },
445
+ { path: "/dashboard/v1/datalogic/v2/chartdata", ...base },
446
+ { path: "/dashboard/v1/datalogic/chartdata", ...base },
447
+ ]);
344
448
  return { data };
345
449
  }),
346
450
  }));
@@ -358,11 +462,17 @@ export function registerReportLane(tools) {
358
462
  kind: z.enum(["model", "advanced", "all"]).default("all"),
359
463
  reportCode: z.string().min(1),
360
464
  appCode: z.string().min(1),
465
+ parentObjectId: z.string().optional().describe("父节点 objectId;传则回其下模型级(nodeType:1)"),
361
466
  corpId: z.string().optional(),
362
467
  },
363
468
  handler: async (ctx, args, self) => governedRead(ctx, self, args, async (session) => {
364
469
  const auth = authOf(args.corpId, args.reportCode, args.appCode);
365
- const fetchOne = (path) => biCall(session, { path, body: {}, query: { lang: "cn" }, auth }).then((data) => (Array.isArray(data) ? data : []));
470
+ // r63-F3(真机钉死):datasourcelist 是层级树——顶层只回应用包
471
+ // (nodeType:0)+系统数据源(nodeType:200);模型级(nodeType:1)要用
472
+ // parentObjectIds 下钻取。link 的真键是模型行的 **objectId**(其
473
+ // dataSourceId 恒 null);应用/分组行不能直接 link(平台静默绑 0 个)。
474
+ const drillBody = args.parentObjectId !== undefined ? { parentObjectIds: [args.parentObjectId] } : {};
475
+ const fetchOne = (path) => biCall(session, { path, body: drillBody, query: { lang: "cn" }, auth }).then((data) => (Array.isArray(data) ? data : []));
366
476
  const model = args.kind === "advanced" ? [] : await fetchOne(ENDPOINTS.biDatasourceModelList);
367
477
  const advanced = args.kind === "model" ? [] : await fetchOne(ENDPOINTS.biDatasourceAdvancedList);
368
478
  const seen = new Set();
@@ -373,7 +483,18 @@ export function registerReportLane(tools) {
373
483
  seen.add(id);
374
484
  return true;
375
485
  });
376
- return { kind: args.kind, count: merged.length, datasources: merged };
486
+ const modelCount = merged.filter((row) => Number(row.nodeType) === 1).length;
487
+ return {
488
+ kind: args.kind,
489
+ parentObjectId: args.parentObjectId ?? null,
490
+ count: merged.length,
491
+ modelCount,
492
+ datasources: merged,
493
+ note: "link 只认**模型行**(nodeType:1)的 objectId(当 dataSourceId 用;模型行的 dataSourceId 字段恒 null)。顶层(不传 parentObjectId)没有模型行——先下钻:应用 id 从 folder.tree 取(应用包节点 id),或用本面 nodeType:0 行的 objectId。nodeType:0=应用/分组容器,200=系统数据源。",
494
+ ...(modelCount === 0 && args.parentObjectId === undefined
495
+ ? { nextCommand: `omc call report.datasource.list --args '{"reportCode":"${args.reportCode}","appCode":"${args.appCode}","parentObjectId":"<分组或应用 id>"}'` }
496
+ : {}),
497
+ };
377
498
  }),
378
499
  }));
379
500
  writeTool({
@@ -403,8 +524,10 @@ export function registerReportLane(tools) {
403
524
  throw new ToolRefusalError({
404
525
  status: "refused",
405
526
  blocker: "report-datasource-link-not-synced",
406
- message: "平台返回成功但未绑定任何数据集(linkedCount:0):模型尚未同步进 BI。先在设计器打开一次报表/触发同步,再重试;不要以 DELIVERED 判定成功。",
527
+ message: `平台返回成功但未绑定任何数据集(linkedCount:0)。r63 真机钉死两种根因:①传的是应用/分组级 id(nodeType:0)——它只能当 parentObjectId 下钻,不能 link;②该模型确实未同步进 BI。` +
528
+ `先 report.datasource.list 带 parentObjectId 下钻拿**模型行(nodeType:1)的 objectId** 当 dataSourceId 重试;模型行也绑不上才是真未同步。`,
407
529
  dataSourceIds: infos.map((info) => info.dataSourceId),
530
+ nextCommand: `omc call report.datasource.list --args '{"reportCode":"${args.reportCode}","appCode":"${args.appCode}","parentObjectId":"<应用/分组 id>"}'`,
408
531
  });
409
532
  return {
410
533
  performed: { errcode: 0, linked: infos.map((info) => info.dataSourceId) },
@@ -437,6 +560,9 @@ export function registerReportLane(tools) {
437
560
  },
438
561
  execute: async (session, args) => {
439
562
  const code = requireCode(args.code);
563
+ // r63-F1:parentId 门在写前(平台原样存储非法值 → 孤儿报表,两棵树都
564
+ // 不可见)。dry-run 走 dryRunPayload 同门。
565
+ await assertParentIsFolder(session, args.appCode, args.parentId);
440
566
  const created = (await wireCall(session, {
441
567
  path: ENDPOINTS.reportCreate,
442
568
  method: "POST",
@@ -514,6 +640,11 @@ export function registerReportLane(tools) {
514
640
  };
515
641
  },
516
642
  preflight: (args) => requireCode(args.code),
643
+ // r63-F1:dry-run 与真写同门(r29c F1b 原则)——parentId 非法在预览就拒。
644
+ dryRunPayload: async (session, args) => {
645
+ await assertParentIsFolder(session, args.appCode, args.parentId);
646
+ return { summary: `即将创建报表页 ${args.code}(appCode=${args.appCode},parentId=${args.parentId})并初始化 BI 配置` };
647
+ },
517
648
  rollback: reportRollbackSpec("report.create"),
518
649
  });
519
650
  writeTool({
@@ -536,6 +667,9 @@ export function registerReportLane(tools) {
536
667
  const page = (await wireCall(session, { path: ENDPOINTS.reportGet, query: { code: args.code } })).data;
537
668
  if (!page || !page.id)
538
669
  throw new ToolRefusalError({ status: "refused", blocker: "report-not-found", message: `报表页 ${args.code} 不存在` });
670
+ // r63-F1:显式改挂时 parentId 必须是 Folder 目录 id(与 create 同门)。
671
+ if (args.parentId !== undefined)
672
+ await assertParentIsFolder(session, String(page.appCode ?? ""), args.parentId);
539
673
  const name = args.name ?? String(page.name ?? "");
540
674
  const performed = await wireCall(session, {
541
675
  path: ENDPOINTS.reportUpdate,
@@ -553,7 +687,18 @@ export function registerReportLane(tools) {
553
687
  },
554
688
  });
555
689
  const after = (await wireCall(session, { path: ENDPOINTS.reportGet, query: { code: args.code } })).data;
556
- return { performed: { errcode: performed.errcode }, readback: { present: Boolean(after && after.code), report: reportPageView(after) } };
690
+ // r63-F1:读回 parent 走应用树权威源(folderList 回退在孤儿场景误导)。
691
+ const afterNode = after.appCode ? await resolveReportTreeNode(session, String(after.appCode), String(after.code ?? args.code)) : null;
692
+ const afterView = reportPageView(after, afterNode?.parentId ?? undefined);
693
+ if (afterNode === null) {
694
+ afterView.parentId = null;
695
+ afterView.treeVisibility = "not-listed";
696
+ afterView.orphanNote = "应用树仍看不到该报表节点——parentId 可能依旧非法(以 folder.tree 为准重挂)。";
697
+ }
698
+ else if (afterNode.path) {
699
+ afterView.path = afterNode.path;
700
+ }
701
+ return { performed: { errcode: performed.errcode }, readback: { present: Boolean(after && after.code), report: afterView } };
557
702
  },
558
703
  rollback: reportRollbackSpec("report.update"),
559
704
  });
@@ -658,6 +803,21 @@ export function registerReportLane(tools) {
658
803
  const toAdd = [];
659
804
  const toUpdate = [];
660
805
  const kept = new Set();
806
+ // r63-F4(真机钉死):addChart 的 data/position/relations 是 **JSON 字符串**
807
+ // 字段(Java String 反序列化),传对象直接 JSON parse error。工具层统一
808
+ // 序列化——调用方两种写法(对象或字符串)都收。
809
+ const wireChart = (chart) => {
810
+ const out = { ...chart };
811
+ for (const key of ["data", "position", "relations", "styles", "mobileOptions", "customSort", "jumpingRules", "formulas", "conditionFormats"]) {
812
+ const value = out[key];
813
+ if (value !== undefined && value !== null && typeof value !== "string")
814
+ out[key] = JSON.stringify(value);
815
+ }
816
+ // r63-F4 续:i_chart.corpId NOT NULL——漏盖章直接 SQL 异常(真机钉死)。
817
+ if (out.corpId === undefined)
818
+ out.corpId = auth.corpId;
819
+ return out;
820
+ };
661
821
  for (const chart of declared) {
662
822
  const uuid = chart.uuid;
663
823
  if (typeof uuid !== "string" || !uuid)
@@ -665,7 +825,7 @@ export function registerReportLane(tools) {
665
825
  kept.add(uuid);
666
826
  // The BI write face scopes charts by their parent report objectId; stamp
667
827
  // it so callers (and the intent compiler) need not know it.
668
- const stamped = { ...chart, objectId };
828
+ const stamped = { ...wireChart(chart), objectId };
669
829
  (existing.has(uuid) ? toUpdate : toAdd).push(stamped);
670
830
  }
671
831
  const toRemove = args.removeUnlistedCharts ? [...existing.keys()].filter((uuid) => !kept.has(uuid)) : [];
@@ -44,6 +44,7 @@ export function dataSubmitDescription() {
44
44
  `仅无 workflowCode/workItemId/workflowInstanceId 且无 bizObjectId 时保留 save→submit 便捷链(新建记录);只要存在 workItemId 或 workflowInstanceId 就 fail-closed 拒绝(blocker submit-biz-object-id-required),零 runtime/form/submit wire。`,
45
45
  `formType 自动判定:无任何 workflowCode/workItemId/workflowInstanceId 时**先按模型自动判定**——GET workflow/isworkflow?schemaCode=true 则用 workflow/getWorkflow 解析已发布流程码并**发起流程**(formType="${wire.formTypeWorkflow}",自动先 GET getReplayToken 注入 replayToken,否则 ${wire.replayTokenErrcode} 频繁重复提交);模型无流程 → "${wire.formTypeNoWorkflow}"(无流程提交,走 live 已证链 ${wire.submitChain};单发新建对象会 ${wire.typeCastErrcode},bizObject 勿带字符串 status)或 workItemId+workflowInstanceId(审批待办,agree **顶层**通过/驳回(approval 对象里放 agree 会被静默忽略并按通过处理),**必须带 bizObjectId 指向在途单据**,否则引擎 NPE ${wire.approvalNpeErrcode})→ "${wire.formTypeWorkflow}"。即「无流程直接提交、有流程发起流程」,不再把有流程模型的新建数据落成游离 sheet 行。`,
46
46
  "根因提示(环境相关,ticket 78 观测):**某些环境**里模型所在应用未发布时运行时提交稳定 50000,工具会反推并拒 app-not-published。该根因非普遍规律(见 data.save 的同条提示与 docs/issues/omc-cli-findings-2026-09-19.md B17)——遇 50000 先只读核对再判断。",
47
+ "readback.requiredFace:published=已发布表单(权威)/draft=仅草稿/unavailable=读不到(requiredFields:[]≠无必填;真值 form.get --controls)。",
47
48
  "Pass `sheetCode` explicitly when the model has multiple sheets; otherwise the default-form sheetCode is resolved from bizsheet/get.",
48
49
  `计算字段:${wire.formulaFieldNote}`,
49
50
  ]);
@@ -1065,7 +1065,7 @@ async function diagnoseDbException(session, schemaCode, error) {
1065
1065
  export function registerRuntimeDataLane(tools) {
1066
1066
  tools.push(defineTool({
1067
1067
  name: "data.list",
1068
- search: { intents: ["查业务数据", "查询数据", "查数据", "查记录", "查单据"] },
1068
+ search: { intents: ["查业务数据", "查询数据", "查数据", "查记录", "查单据", "统计数据", "汇总数据", "分组统计", "数条数", "总条数", "导出数据", "多少条", "有几条", "统计", "导出", "查合同列表", "查单据列表"] },
1069
1069
  layer: "low",
1070
1070
  kind: "read",
1071
1071
  lane: RUNTIME_LANE,
@@ -1093,6 +1093,11 @@ export function registerRuntimeDataLane(tools) {
1093
1093
  fields: z.array(z.string().min(1)).optional().describe("列投影别名(=displayFields;与 data.load/data.save/data.update 的 fields 同语义)"),
1094
1094
  orders: z.array(z.object({ field: z.string().min(1), dir: z.enum(["ASC", "DESC"]) })).optional().describe("运行面 query/list 不支持服务端排序;排序请用 listview.configure 的 sorts(视图级)或在本地对 items 排序"),
1095
1095
  mobile: z.boolean().optional(),
1096
+ // r63(b-F12):draftPolicy 此前只能从结果反推——探针无法控制也无法预知
1097
+ // 草稿口径。显式开关:false 注入 sequenceStatus≠DRAFT(真机验证可过滤,
1098
+ // 17→11);true/省略不注入(带条件时平台自己排除草稿,无法强制包含,
1099
+ // 回执 draftPolicy 如实标注)。
1100
+ includeDrafts: z.boolean().optional().describe("false=注入 sequenceStatus≠DRAFT 排除草稿;省略=平台默认(带条件时平台自己排除,无法强制包含);口径看回执 filter.draftPolicy"),
1096
1101
  showTotal: z.boolean().default(true),
1097
1102
  page: z.number().int().min(0).default(0).describe("页码,从 0 开始(不是每页条数);每页条数用 size"),
1098
1103
  size: z.number().int().min(1).max(200).default(10).describe("每页条数,默认 10、上限 200;页码用 page(从 0 开始)"),
@@ -1127,10 +1132,14 @@ export function registerRuntimeDataLane(tools) {
1127
1132
  // An array `filter` is the caller's AND-list; fold it into `filters`.
1128
1133
  const asFilters = args.filters ?? (Array.isArray(args.filter) ? args.filter : undefined);
1129
1134
  const asFilter = Array.isArray(args.filter) ? undefined : args.filter;
1135
+ // r63(b-F12):includeDrafts:false 显式排除草稿——注入 sequenceStatus≠DRAFT
1136
+ // 并入既有条件(AND)。真机验证 sequenceStatus 可作过滤字段(17→11)。
1137
+ const draftExclusion = args.includeDrafts === false ? [{ op: "neq", field: "sequenceStatus", value: "DRAFT" }] : [];
1138
+ const mergedFilters = [...(asFilters ?? []), ...draftExclusion];
1130
1139
  condition = toQueryCondition({
1131
1140
  rawCondition: args.rawCondition,
1132
- ...(asFilter !== undefined ? { filter: asFilter } : {}),
1133
- ...(asFilters !== undefined ? { filters: asFilters } : {}),
1141
+ ...(asFilter !== undefined || (asFilters !== undefined && asFilters.length > 0) || draftExclusion.length > 0 ? { filter: asFilter } : {}),
1142
+ ...(mergedFilters.length > 0 ? { filters: mergedFilters } : {}),
1134
1143
  ...(args.filterGroup !== undefined ? { filterGroup: args.filterGroup } : {}),
1135
1144
  });
1136
1145
  fromDsl = condition !== undefined && args.rawCondition === undefined;
@@ -1523,15 +1532,17 @@ export function registerRuntimeDataLane(tools) {
1523
1532
  // 统一一个枚举键 `draftPolicy`(included | excluded | unspecified),
1524
1533
  // 不再用两个不同键名表达同一件事(那要调用方写两套分支)。
1525
1534
  ...(() => {
1526
- const policy = draftRows > 0
1527
- ? {
1528
- draftPolicy: "included",
1529
- draftRows,
1530
- hint: `本次结果含 ${draftRows} 条 DRAFT 行(total 也计入)——**不要**把 total 当"已提交数据量",判定状态读 data.load 的 sequenceStatus`,
1531
- }
1532
- : condition !== undefined
1533
- ? { draftPolicy: "excluded", hint: "本次结果无 DRAFT 行;判定状态仍以 data.load 的 sequenceStatus 为准" }
1534
- : { draftPolicy: "unspecified", hint: "本次结果无 DRAFT 行,但本面是否过滤草稿不能据此断定;判定状态读 data.load 的 sequenceStatus" };
1535
+ const policy = args.includeDrafts === false
1536
+ ? { draftPolicy: "excluded-by-request", hint: "includeDrafts:false——已注入 sequenceStatus≠DRAFT,total/items 只计非草稿行" }
1537
+ : draftRows > 0
1538
+ ? {
1539
+ draftPolicy: "included",
1540
+ draftRows,
1541
+ hint: `本次结果含 ${draftRows} 条 DRAFT 行(total 也计入)——**不要**把 total 当"已提交数据量",判定状态读 data.load 的 sequenceStatus`,
1542
+ }
1543
+ : condition !== undefined
1544
+ ? { draftPolicy: "excluded", hint: "本次结果无 DRAFT 行;判定状态仍以 data.load 的 sequenceStatus 为准" }
1545
+ : { draftPolicy: "unspecified", hint: "本次结果无 DRAFT 行,但本面是否过滤草稿不能据此断定;判定状态读 data.load 的 sequenceStatus" };
1535
1546
  return { filter: policy };
1536
1547
  })(),
1537
1548
  ...(choiceFilterFields.length > 0 && Number(total ?? 0) === 0 ? { filterValueHint: choiceFilterValueHint(choiceFilterFields) } : {}),
@@ -1860,7 +1871,7 @@ export function registerRuntimeDataLane(tools) {
1860
1871
  writeTool({
1861
1872
  tools,
1862
1873
  name: "data.update",
1863
- search: { intents: ["改一条记录", "编辑单据", "更新业务数据"] },
1874
+ search: { intents: ["改一条记录", "编辑单据", "更新业务数据", "改数据", "录错了改回来", "修正数据", "改成", "改为"] },
1864
1875
  lane: RUNTIME_LANE,
1865
1876
  scope: RUNTIME_TOOLS["data.update"].scope,
1866
1877
  description: RUNTIME_TOOLS["data.update"].description,
@@ -2425,6 +2436,8 @@ export function registerRuntimeDataLane(tools) {
2425
2436
  schemaCode: typeof performedData.schemaCode === "string" ? performedData.schemaCode : args.schemaCode,
2426
2437
  formCode: typeof performedData.formCode === "string" ? performedData.formCode : sheetCode,
2427
2438
  sequenceStatus,
2439
+ // r62a-F7:无流程模型不存在待办——显式说明,null 不再歧义。
2440
+ workItemState: "none-no-workflow",
2428
2441
  ...(sequenceStatus === null ? { missingSequenceStatus: true } : {}),
2429
2442
  // r28b F2(真机 2026-11-05 复现):模型没配业务流水号时,平台把
2430
2443
  // `sequenceNo` 直接回填成 objectId 本身——32 位 hex 长得像单号,
@@ -2434,6 +2447,21 @@ export function registerRuntimeDataLane(tools) {
2434
2447
  ? { sequenceNoSource: "object-id", sequenceNoNote: "本模型未配置业务流水号:sequenceNo 回填的是 objectId 本身(不是生成的单号)。要单号请在模型上配序列号字段。" }
2435
2448
  : {}),
2436
2449
  submittedData: projectReadbackRecord(record, args),
2450
+ // r62a-F10(P1-9):无流程分支的 name 覆盖检测(与 approval 分支同款)——
2451
+ // 真机实证无流程模型也会把传入 name 换成「发起人+模型名+时间」标题。
2452
+ ...(() => {
2453
+ const wanted = (formData ?? {});
2454
+ const wantedName = typeof wanted.name === "string" && wanted.name.trim() !== "" ? wanted.name : null;
2455
+ const landedNameRaw = typeof record.name === "string"
2456
+ ? record.name
2457
+ : typeof (record.fields ?? {}).name === "string"
2458
+ ? String(record.fields.name)
2459
+ : null;
2460
+ const landedName = landedNameRaw !== null && landedNameRaw.trim() !== "" ? landedNameRaw : null;
2461
+ if (wantedName === null || landedName === null || landedName === wantedName)
2462
+ return {};
2463
+ return { nameOverridden: { wanted: wantedName, landed: landedName, note: "name 是平台数据标题(自动生成优先):传入值被覆盖,业务字段请用自有 code(如 title/subject)" } };
2464
+ })(),
2437
2465
  ...(serialGenerationFailed.length > 0
2438
2466
  ? { serialGenerationFailed, serialGenerationWarning: SERIAL_GENERATION_FAILURE_NOTE }
2439
2467
  : {}),
@@ -2484,8 +2512,32 @@ export function registerRuntimeDataLane(tools) {
2484
2512
  // The submit response often has no workItemId; when the engine created
2485
2513
  // the next todo, its first item is the authoritative continuation id.
2486
2514
  workItemId: typeof performedData.workItemId === "string" ? performedData.workItemId : null,
2515
+ // r62a-F7(P1-8):workItemId 裸 null 有三态歧义——「没有待办」「待办
2516
+ // 不在我名下(真答案曾只藏在 flowWarning 文案里)」「流程已走完」。
2517
+ // workItemState 显式判别,null 时读这个键。
2518
+ workItemState: sequenceStatus === "COMPLETED" ? "none-flow-completed"
2519
+ : hasWorkItem ? "consumed-by-this-submit"
2520
+ : "pending-or-none",
2487
2521
  sequenceStatus,
2488
2522
  submittedData: approvalDelta ? projectApprovalReadback(loadedRecord, Object.keys(formData ?? {})) : projectReadbackRecord(loadedRecord, args),
2523
+ // r62a-F10(P1-9):formData.name 是平台数据标题的**建议值**——引擎按
2524
+ // 「发起人+模型名+时间」生成标题时,传的 name 被静默替换且无告警(探针
2525
+ // 传「r62a_差旅-短程」得到「付文彬的差旅申请 2026-11-13 …」)。检测
2526
+ // 覆盖并点名,别让调用方以为标题没生效是 bug。
2527
+ ...(() => {
2528
+ const wanted = (formData ?? {});
2529
+ const landed = (loadedRecord ?? {});
2530
+ // data.load 的行形状 name 可能平铺或在 fields.name——两形都认。
2531
+ const landedFields = (landed.fields ?? {});
2532
+ const wantedName = typeof wanted.name === "string" && wanted.name.trim() !== "" ? wanted.name : null;
2533
+ const landedNameRaw = typeof landed.name === "string" ? landed.name : typeof landedFields.name === "string" ? landedFields.name : null;
2534
+ const landedName = landedNameRaw !== null && landedNameRaw.trim() !== "" ? landedNameRaw : null;
2535
+ if (wantedName === null || landedName === null || landedName === wantedName)
2536
+ return {};
2537
+ return {
2538
+ nameOverridden: { wanted: wantedName, landed: landedName, note: "name 是平台数据标题(自动生成优先):传入值被覆盖,业务字段请用自有 code(如 title/subject),不要用 name 承载业务语义" },
2539
+ };
2540
+ })(),
2489
2541
  ...(approvalDelta
2490
2542
  ? { readbackShape: "approval-delta", readbackHint: "审批提交默认只回 sequenceStatus + 本次提交的字段;要整条记录(含子表/系统字段)加 full:true,要指定字段加 fields:[...]" }
2491
2543
  : {}),
@@ -2570,6 +2622,8 @@ export function registerRuntimeDataLane(tools) {
2570
2622
  .map((person) => person.name ?? person.id)
2571
2623
  .filter((value) => typeof value === "string" && value.length > 0);
2572
2624
  const holders = holderNames.length > 0 ? holderNames.join("、") : "(参与人未回显)";
2625
+ // r62a-F7:主键同步——「待办在别处」从 flowWarning 文案提升为主键判别值。
2626
+ readback.workItemState = "pending-elsewhere";
2573
2627
  if (rejected) {
2574
2628
  readback.returnedTo = { activityCode: first.activityCode, activityName: first.activityName };
2575
2629
  readback.nextSubmit = {
@@ -2585,6 +2639,9 @@ export function registerRuntimeDataLane(tools) {
2585
2639
  activityCode: first.activityCode,
2586
2640
  activityName: first.activityName,
2587
2641
  participants: first.participants,
2642
+ // r62a-F7:主键 workItemState 同步改写——探针读主键就能判「在别处」,
2643
+ // 不必解析 warning 文案。
2644
+ workItemState: "pending-elsewhere",
2588
2645
  checks: [
2589
2646
  `omc call workflow.instanceActivity --args '{"workflowInstanceId":"${effectiveInstanceId}"}'`,
2590
2647
  `omc call workitem.list --args '{"workflowInstanceId":"${effectiveInstanceId}","participant":"<持有人 id>"}'`,
@@ -2617,7 +2617,7 @@ export function registerWorkflowLane(tools) {
2617
2617
  writeTool({
2618
2618
  tools,
2619
2619
  name: "workflow.update",
2620
- search: { intents: ["更新流程", "修改流程", "改流程", "加审批节点"] },
2620
+ search: { intents: ["更新流程", "修改流程", "改流程", "加审批节点", "退回给", "退回到"] },
2621
2621
  lane: WORKFLOW_LANE,
2622
2622
  scope: WORKFLOW_TOOLS["workflow.update"].scope,
2623
2623
  description: WORKFLOW_TOOLS["workflow.update"].description,
@@ -2695,6 +2695,9 @@ export function registerWorkflowLane(tools) {
2695
2695
  });
2696
2696
  const body = await mergedTemplateBody(session, args.schemaCode, args.code, template, merge);
2697
2697
  validateWorkflowRender(body, "workflow.update");
2698
+ // r62a-F2(P1-6):条件枚举校验必须在 dry-run 同门跑——GE/GT= 这类直觉
2699
+ // 缩写此前只有真写才拒,dry-run 假绿(wouldChange:true 无 issues)。
2700
+ validateWorkflowRouteConditions(body, "workflow.update");
2698
2701
  const edgeKeys = (rules) => (Array.isArray(rules) ? rules : []).map((rule) => `${String(rule.preActivityCode ?? "")}->${String(rule.postActivityCode ?? "")}`);
2699
2702
  const beforeEdges = edgeKeys(draft.rules);
2700
2703
  const afterEdges = edgeKeys(body.rules);
@@ -3216,6 +3219,11 @@ export function registerWorkflowLane(tools) {
3216
3219
  .optional()
3217
3220
  .describe("可选:发布后绑定业务规则;每项 {handler?,ruleCodes[]},handler 取 start|cancel|activate|end(缺省 end)"),
3218
3221
  },
3222
+ // r62a-F2(P1-6):条件枚举校验进 preflight——semanticGate 在 dry-run 与真写
3223
+ // 都跑(r29c F1b 同门原则),GE/GT= 这类直觉缩写此前 dry-run 假绿、真写才拒。
3224
+ preflight: (args) => {
3225
+ validateWorkflowRouteConditions((args.template ?? {}), "configure_workflow");
3226
+ },
3219
3227
  plan: (args) => {
3220
3228
  const actions = [
3221
3229
  { tool: "workflow.create", args: { schemaCode: args.schemaCode, name: args.name, code: args.code } },
package/dist/plan.js CHANGED
@@ -27,8 +27,11 @@ export function planFingerprint(plan) {
27
27
  /**
28
28
  * r28g F8(真机 2026-11-05):dry-run 的 `*Summary` 只给键名 + sha256,把**最该
29
29
  * 自查的那段**(三层转义后的条件串)整个遮住——校验通过的结论看得见,被校验的
30
- * 内容看不见。这里补一个 `*Preview`:把**小**的字符串叶子原样列出(总长 ≤400B),
30
+ * 内容看不见。这里补一个 `*Preview`:把**小**的标量叶子原样列出(总长 ≤400B),
31
31
  * 超了就不给(还是回到摘要)。目的是"可自查形状",不是把正文搬回来。
32
+ * r62a-F10(P1-9):只收 string 会把数值/布尔叶子吞掉——探针 dry-run 提交
33
+ * {days:2, amount:1200.5} 时 formDataPreview 只见字符串字段,提交前无法核对
34
+ * 数值解析。扩展为全部标量(string/number/boolean)。
32
35
  */
33
36
  function smallStringPreview(value) {
34
37
  if (value === null || typeof value !== "object" || Array.isArray(value))
@@ -36,9 +39,9 @@ function smallStringPreview(value) {
36
39
  const out = {};
37
40
  let budget = 400;
38
41
  for (const [key, entry] of Object.entries(value)) {
39
- if (typeof entry !== "string")
42
+ if (typeof entry !== "string" && typeof entry !== "number" && typeof entry !== "boolean")
40
43
  continue;
41
- const bytes = Buffer.byteLength(entry, "utf8");
44
+ const bytes = Buffer.byteLength(String(entry), "utf8");
42
45
  if (bytes > budget)
43
46
  continue;
44
47
  budget -= bytes;
package/dist/read.js CHANGED
@@ -169,6 +169,23 @@ function compactReadback(result) {
169
169
  compact[key] = value.map(activityOfEntry).filter((entry) => entry !== undefined);
170
170
  compact[`${key}Count`] = value.length;
171
171
  }
172
+ else if (key === "rules" && Array.isArray(value)) {
173
+ // r62b-F3(P1-10):rules 折叠成 `rules:[]`+artifact 曾逼探针二次取回——
174
+ // 9 条规则连名字都看不到。瘦身版 [{code,name,enabled,defaultRule}] ~40B/条,
175
+ // **≤12 条**内联(~500B,回答「配了哪些规则/几条自建几条预置」);更大的
176
+ // 清单保持外置语义(readback-diet 的 token 经济不变),正文仍在 artifact。
177
+ if (value.length <= 12) {
178
+ const slim = value
179
+ .map((rule) => ({
180
+ code: typeof rule.code === "string" ? rule.code : null,
181
+ name: typeof rule.name === "string" ? rule.name : null,
182
+ ...(rule.enabled !== undefined ? { enabled: rule.enabled } : {}),
183
+ ...(rule.defaultRule !== undefined ? { defaultRule: rule.defaultRule } : {}),
184
+ }));
185
+ compact[key] = slim;
186
+ }
187
+ compact[`${key}Count`] = value.length;
188
+ }
172
189
  else if (BULKY_READ_KEYS.has(key)) {
173
190
  compact[`${key}Count`] = Array.isArray(value) ? value.length : value && typeof value === "object" ? Object.keys(value).length : 0;
174
191
  }
@@ -170,6 +170,20 @@ function dashboardBoundaryGuidance() {
170
170
  fixFirst: "报表能力暂不优先支持(维护者裁决,先隐藏):不要重试同一子面。平台层仍可用:report.tree / report.update / report.get 存在性判定;确需 BI 详情/数据源/图表/配置时,先启动本机报表服务再深进",
171
171
  };
172
172
  }
173
+ /**
174
+ * r63(真机钉死):报表服务**已启动**时 BI 仍可能业务性失败——reporter 与主应用
175
+ * 版本族不匹配(本环境 reporter 6.2.0.45 ↔ 主应用 8.6):数据查询的连接串握手
176
+ * (executebefore/connstring,SM4 解密链)拿不到,回 conn.string.empty /
177
+ * server.error。这与「服务未启动」是两个边界:设计链(建页/挂树/数据源 link/
178
+ * 配图/读回)全部可用,只有 chartdata 的取数一跳断。教清楚,别让探针误判成
179
+ * 自己的参数错或无限重试。
180
+ */
181
+ function dashboardVersionFamilyGuidance() {
182
+ return {
183
+ whatWentWrong: "报表服务已连通,但取数一跳失败——reporter 与主应用版本族不匹配(r63 实证:reporter 6.2.0.45 ↔ 主应用 8.6,connstring 握手 SM4 解密链断裂,conn.string.empty)",
184
+ fixFirst: "这是环境边界,不是参数错:换参数/重试无用。设计链全部可用(report.create/tree/get/datasource.link/configure 均真机验证过)——配置已落库,取数要等 reporter 版本对齐主应用(升级 reporter 镜像)。核对配置用 report.get 的 bi.charts",
185
+ };
186
+ }
173
187
  function mentionsDashboardChannel(payload) {
174
188
  return JSON.stringify({ m: payload.message, d: payload.detail, r: payload.reason }).includes("/dashboard/v1/");
175
189
  }
@@ -197,8 +211,12 @@ export function refusalRecovery(blocker, payload, options = {}) {
197
211
  return payload.recovery;
198
212
  // r19 p14: the report BI boundary is matched from the wire path in the
199
213
  // message/detail, so both refused and frozen (uncertain) envelopes teach it.
200
- if (mentionsDashboardChannel(payload))
201
- return dashboardBoundaryGuidance();
214
+ if (mentionsDashboardChannel(payload)) {
215
+ // r63:业务性失败(服务已连通)与 transport 失败(服务未启动)分叉教学。
216
+ const text = JSON.stringify({ m: payload.message, d: payload.detail });
217
+ const businessFailure = /conn\.string\.empty|server\.error|illegal\.field|rejected:/.test(text);
218
+ return businessFailure ? dashboardVersionFamilyGuidance() : dashboardBoundaryGuidance();
219
+ }
202
220
  // r29b F7: blockerAliases 让旧名也能命中新引导。
203
221
  const aliasBlockers = Array.isArray(payload.blockerAliases)
204
222
  ? payload.blockerAliases.filter((entry) => typeof entry === "string")
package/dist/support.js CHANGED
@@ -165,4 +165,55 @@ export async function mapBounded(items, limit, worker) {
165
165
  await Promise.all(runners);
166
166
  return results;
167
167
  }
168
+ /**
169
+ * r62b-F2(P1-5):call 面判定「模型不存在」时的近名候选(top3)。
170
+ * plan 面已有 needs-decision blocker(c-F12),call 面(rule.list / datarule.list
171
+ * 的 modelPresent:false)此前只回一句判定——探针为编一个可转发的问句得自己翻
172
+ * model.list 清单。计分用双向子串 + 共享 2-gram(不引编辑距离库,call 面只需
173
+ * 「最接近的几个」)。候选是加分项:树拉不到就回 null,绝不阻塞主判定。
174
+ */
175
+ export async function suggestModelNames(session, asked) {
176
+ try {
177
+ const scope = await resolveApplicationScope(session);
178
+ const tree = flattenTreeRows(wireRows((await wireCall(session, { path: ENDPOINTS.applicationTree, query: { appCode: scope.code } })).data));
179
+ const models = tree
180
+ .filter((row) => row.type === "BizModel" && typeof row.code === "string" && row.code)
181
+ .map((row) => ({ code: String(row.code), name: typeof row.name === "string" ? row.name : typeof row.text === "string" ? row.text : null }));
182
+ const needle = asked.trim().toLowerCase();
183
+ if (needle === "" || models.length === 0)
184
+ return null;
185
+ const bigrams = (text) => {
186
+ const normalized = text.toLowerCase();
187
+ const out = new Set();
188
+ for (let i = 0; i + 2 <= normalized.length; i++)
189
+ out.add(normalized.slice(i, i + 2));
190
+ return out;
191
+ };
192
+ const askedBigrams = bigrams(asked);
193
+ const scored = models
194
+ .map((model) => {
195
+ const haystack = `${model.code} ${model.name ?? ""}`.toLowerCase();
196
+ let score = 0;
197
+ if (haystack.includes(needle))
198
+ score += 10;
199
+ if (model.name !== null && needle.includes(model.name.toLowerCase()) && model.name.length >= 2)
200
+ score += 8;
201
+ const modelBigrams = bigrams(`${model.code}${model.name ?? ""}`);
202
+ let shared = 0;
203
+ for (const gram of askedBigrams)
204
+ if (modelBigrams.has(gram))
205
+ shared++;
206
+ score += shared;
207
+ return { model, score };
208
+ })
209
+ .filter((entry) => entry.score >= 2)
210
+ .sort((left, right) => right.score - left.score)
211
+ .slice(0, 3)
212
+ .map((entry) => entry.model);
213
+ return scored.length > 0 ? scored : null;
214
+ }
215
+ catch {
216
+ return null;
217
+ }
218
+ }
168
219
  //# sourceMappingURL=support.js.map
@@ -140,7 +140,7 @@ const READ_LEADING_VERBS = Object.freeze(["读", "看", "查", "列出", "列",
140
140
  * service.dbconnpool.*。刻意**不收**裸「数据」(太宽,靠能力标题/摘要兜底)。
141
141
  */
142
142
  const OBJECT_LEXICON = Object.freeze({
143
- model: ["模型", "业务模型"],
143
+ model: ["模型", "业务模型", "登记表", "申请单", "申请表", "台账", "单表"],
144
144
  field: ["字段"],
145
145
  form: ["表单"],
146
146
  listview: ["列表视图", "列表", "视图", "查询列"],
@@ -91,6 +91,13 @@ const TOOL_INPUT_ALIASES = Object.freeze({
91
91
  // 没有自己的 `code` 参数,无歧义)。
92
92
  "workflow.get_draft": Object.freeze({ workflowCode: ["code"] }),
93
93
  "workflow.get_published": Object.freeze({ workflowCode: ["code"] }),
94
+ // r62a-F4(P1-7):workflow.validate 是同族读面——写面(update/publish)用
95
+ // `code`、读面用 `workflowCode`,从 update 抄参数过来就被 unknown-keys 拒。
96
+ "workflow.validate": Object.freeze({ workflowCode: ["code"] }),
97
+ // r62c-F6(P1-7):模型 code 的键名分裂——model-purge 收 `--code`、
98
+ // model.delete/model.list 收 `schemaCode`、model.inspect 也收 `schemaCode`。
99
+ // 同一个概念(模型的 code)在读写面间换了名字,读面归一。
100
+ "model.inspect": Object.freeze({ schemaCode: ["code"] }),
94
101
  // field family: the platform's own column key is `propertyCode`; the tool's is
95
102
  // `code`. Same field, so the alias is safe either direction.
96
103
  "field.create": Object.freeze({ code: ["propertyCode"] }),
package/dist/wire.js CHANGED
@@ -175,6 +175,12 @@ function invalidateReadCache(session, call) {
175
175
  else if (nonCachingDesignWrites.has(path)) {
176
176
  // Rule/query writes never mutate the cached faces — nothing to drop.
177
177
  }
178
+ else if (path === ENDPOINTS.reportCreate || path === ENDPOINTS.reportUpdate || path === ENDPOINTS.reportDelete) {
179
+ // r63-F1:报表页镜像进应用树(h_app_function 的 Report 节点)——
180
+ // create/update/delete 改树,但路径在 /api/api/report/ 下不落上面的
181
+ // fail-safe 分支。不失效的话 create 后 60s 内 folder/report 树全是旧的。
182
+ dropAll([ENDPOINTS.applicationTree]);
183
+ }
178
184
  else if (path.startsWith("/api/api/app/")) {
179
185
  // Unknown design-surface write — fail safe, drop everything cached.
180
186
  state.entries.clear();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stalfh233/omc-cli",
3
- "version": "0.6.51",
3
+ "version": "0.6.53",
4
4
  "description": "CloudPivot 8.6 configuration capability CLI — governed, fail-closed, coverage-manifest bounded.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -56,7 +56,7 @@
56
56
  },
57
57
  "dependencies": {
58
58
  "commander": "14.0.3",
59
- "omc-core": "0.6.51",
59
+ "omc-core": "0.6.53",
60
60
  "proper-lockfile": "4.1.2",
61
61
  "write-file-atomic": "6.0.0",
62
62
  "zod": "^3.23.8",
@@ -74,6 +74,6 @@
74
74
  "directory": "packages/omc-cli"
75
75
  },
76
76
  "optionalDependencies": {
77
- "@stalfh233/omc-fake-platform": "0.6.51"
77
+ "@stalfh233/omc-fake-platform": "0.6.53"
78
78
  }
79
79
  }
@@ -1,27 +0,0 @@
1
- import { claim, declareLaneCoverage } from "./coverage-declaration.js";
2
- import { LANES } from "./lane-ids.js";
3
- /**
4
- * Organization writes (role group / role / members / management scope) sit on
5
- * the same live-proven template lane; the scopes below are claimed here so the
6
- * runtime gate can resolve them without a second manifest item.
7
- */
8
- export const ORGANIZATION_COVERAGE = declareLaneCoverage(LANES.workflow, [
9
- {
10
- capability: "W7 S29 greenfield workflow authoring",
11
- evidence: [
12
- "packages/omc-cli/src/lanes/organization.ts",
13
- "OpenAPI /api/v3/api-docs (1.1.25): organization/role/add_role, add_role_user, update_ouscope",
14
- ],
15
- tools: [
16
- claim("org.role.users", "organization role member read (role/users)"),
17
- claim("org.role.userScope", "organization role member management scope read (role/get_ouscope)"),
18
- claim("org.roleGroup.create", "organization role group create (role/add_role_group)"),
19
- claim("org.role.create", "organization role create (role/add_role)"),
20
- claim("org.role.update", "organization role update (role/modify_role)"),
21
- claim("org.role.addUsers", "organization role member add (role/add_role_user)"),
22
- claim("org.role.removeUsers", "organization role member remove (role/strike_out_role_user)"),
23
- claim("org.role.setUserScope", "organization role member scope update (role/update_ouscope)"),
24
- ],
25
- },
26
- ]);
27
- //# sourceMappingURL=organization-coverage.js.map