@stalfh233/omc-cli 0.6.97 → 0.6.99

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.
@@ -2195,6 +2195,40 @@ export async function resolveWorkflowArg(session, args) {
2195
2195
  const workflowCode = code && typeof code.workflowCode === "string" && code.workflowCode ? code.workflowCode : null;
2196
2196
  return workflowCode;
2197
2197
  }
2198
+ /**
2199
+ * BUG-05-F8: `isworkflow` can lag behind the real workflow binding. Keep the
2200
+ * ordinary probe hot path unchanged, and only use the bounded model index when
2201
+ * that probe says nothing. The index is intentionally not the high-level
2202
+ * workflow.list tool (which would add summaries/details to this point lookup).
2203
+ */
2204
+ async function resolveWorkflowArgWithFallback(session, args) {
2205
+ if (args.workflowCode)
2206
+ return { workflowCode: args.workflowCode };
2207
+ if (!args.schemaCode)
2208
+ throw new ToolInputError({ status: "error", blocker: "tool-input-invalid", tool: "workflow.*", message: "需要 workflowCode,或 schemaCode(工具内部解析该模型的流程)" });
2209
+ const direct = await resolveWorkflowArg(session, args);
2210
+ if (direct)
2211
+ return { workflowCode: direct, resolution: "schemaCode-bind" };
2212
+ // 直接探针的唯一门槛是 `workflow/isworkflow`——真机里它会滞后于真实绑定。
2213
+ // 因此缺席时**绕过该门**直接问 getWorkflow(不问应用树:单点解析不需要
2214
+ // 模型清单,省一次 wire),拿到平台真实 workflowCode 才继续。
2215
+ const base = {
2216
+ workflowCode: null,
2217
+ resolution: "schemaCode-probe-plus-fallback",
2218
+ scannedModels: 1,
2219
+ nextCommand: `omc call workflow.list --args '{"applicationCode":"<应用code>"}'(按模型索引复核;不要据此断言流程不存在)`,
2220
+ };
2221
+ try {
2222
+ const linked = (await wireCall(session, { path: ENDPOINTS.workflowGetBySchema, query: { schemaCode: args.schemaCode } })).data;
2223
+ const workflowCode = linked && typeof linked.workflowCode === "string" && linked.workflowCode ? linked.workflowCode : null;
2224
+ if (workflowCode)
2225
+ return { ...base, workflowCode, resolution: "workflow-list-fallback" };
2226
+ }
2227
+ catch {
2228
+ return { ...base, readFailed: true, nextCommand: `omc call workflow.list --args '{"applicationCode":"<应用code>"}'(getWorkflow 读取失败;不要断言流程不存在)` };
2229
+ }
2230
+ return base;
2231
+ }
2198
2232
  export async function scanModelWorkflowBindings(session, schemaCode) {
2199
2233
  const workflowCode = await resolveWorkflowArg(session, { schemaCode });
2200
2234
  if (!workflowCode)
@@ -2815,9 +2849,16 @@ export function registerWorkflowLane(tools) {
2815
2849
  }
2816
2850
  return { keyword: participantSearch, scannedModels, withWorkflow, hits, hitsCount: hits.length };
2817
2851
  }
2818
- const workflowCode = await resolveWorkflowArg(session, args);
2852
+ const resolved = await resolveWorkflowArgWithFallback(session, args);
2853
+ const workflowCode = resolved.workflowCode;
2819
2854
  if (!workflowCode)
2820
- return { schemaCode: args.schemaCode, exists: false, published: false, note: "该模型没有已发布流程(workflow/isworkflow=false);先 workflow.create 再 publish" };
2855
+ return {
2856
+ schemaCode: args.schemaCode,
2857
+ exists: false,
2858
+ published: false,
2859
+ ...resolved,
2860
+ note: "流程解析未命中;可能是平台索引不同步或扫描不完整,不据此断言流程不存在。先 workflow.list 确认;确认无绑定后再 workflow.create",
2861
+ };
2821
2862
  let pub;
2822
2863
  try {
2823
2864
  pub = await wireCall(session, { path: ENDPOINTS.workflowGetPublished, query: { workflowCode } });
@@ -2840,6 +2881,9 @@ export function registerWorkflowLane(tools) {
2840
2881
  workflowCode,
2841
2882
  exists: true,
2842
2883
  published,
2884
+ ...(resolved.resolution ? { resolution: resolved.resolution } : {}),
2885
+ ...(resolved.scannedModels !== undefined ? { scannedModels: resolved.scannedModels } : {}),
2886
+ ...(resolved.partial ? { partial: true } : {}),
2843
2887
  ...(data && !published ? { note: "平台对未发布流程仍返回草稿形态——此读回不能当作已发布证据;以 published:true / templateType:PUBLISH 为准(先 workflow.publish)" } : {}),
2844
2888
  data: pub.data,
2845
2889
  };
@@ -3114,7 +3158,7 @@ export function registerWorkflowLane(tools) {
3114
3158
  lane: WORKFLOW_LANE,
3115
3159
  scope: WORKFLOW_TOOLS["workflow.publish"].scope,
3116
3160
  description: WORKFLOW_TOOLS["workflow.publish"].description,
3117
- inputSchema: { schemaCode: z.string().min(1), code: z.string().min(1).describe("流程编码——本参数名是 code,传 workflowCode 会被 schema 拒绝"), template: workflowTemplateArg.optional() },
3161
+ inputSchema: { schemaCode: z.string().min(1), code: z.string().min(1).describe("流程编码——本参数名是 code,传 workflowCode 会被 schema 拒绝"), template: workflowTemplateArg.describe("可省略——省略即把已存草稿原样发布(平台原生路径,先 workflow.update 写草稿)。要带模板时形状/连线/参与人/体积铁律与 workflow.update 的 template 完全同源,见 `omc describe workflow.update --param template`(此处不复制第二份,防漂移)").optional() },
3118
3162
  execute: async (session, args) => {
3119
3163
  // An absent template publishes the stored draft as-is — the platform's own
3120
3164
  // path. The schema is optional so the contract no longer contradicts it.
@@ -3562,6 +3606,14 @@ export function registerWorkflowLane(tools) {
3562
3606
  containerCode: existing.containerCode ?? args.schemaCode,
3563
3607
  customBtns: merged,
3564
3608
  childTableBtns: existing.childTableBtns ?? [],
3609
+ // 2.1.5(AI-Platform v2.1.5,客户口径 8.8)把节点按钮拆成审批态/查看态:
3610
+ // 非审批态只读 viewCustomBtns/viewChildTableBtns,缺失即空数组
3611
+ // (ActionPermissionHandler:91-105)。旧模板没有这三个字段,2.1.5 上
3612
+ // 「已办/查看页按钮会全部消失」。只写审批态时,若节点没有任何查看态
3613
+ // 配置,就显式声明「查看态等同审批态」(8.6 语义),不动已有独立配置。
3614
+ ...(existing.viewCustomBtns === undefined && existing.viewChildTableBtns === undefined && existing.viewBtnPermissionEqualApproval === undefined
3615
+ ? { viewBtnPermissionEqualApproval: true }
3616
+ : {}),
3565
3617
  },
3566
3618
  });
3567
3619
  }
@@ -3570,38 +3622,60 @@ export function registerWorkflowLane(tools) {
3570
3622
  const performed = await wireCall(session, { path: ENDPOINTS.workflowUpdate, method: "POST", body });
3571
3623
  const shouldPublish = args.publish !== false;
3572
3624
  let publishMarked = false;
3625
+ // issue 2026-11 F1:发布后必须读**发布面**。此前只读草稿,草稿里空
3626
+ // customBtns 容器还在、发布面却被平台归一化成 buttonPermission:null——
3627
+ // 回执说「容器内按钮 enabled:false」而真实效果是「容器没了」,调用方据此
3628
+ // 判断「仍命中节点权限分支」,把方案引向错误结论。
3629
+ let authoritative = null;
3573
3630
  if (shouldPublish) {
3574
3631
  const publishPerformed = await wireCall(session, { path: ENDPOINTS.workflowPublish, method: "POST", body });
3575
3632
  assertWorkflowWriteAccepted(publishPerformed, "workflow.setButtons", args.workflowCode);
3576
3633
  const pub = await wireCall(session, { path: ENDPOINTS.workflowGetPublished, query: { workflowCode: args.workflowCode } });
3577
- const published = (pub.data ?? null);
3578
- publishMarked = published !== null && (published.templateType === "PUBLISH" || published.published === true);
3634
+ authoritative = (pub.data ?? null);
3635
+ publishMarked = authoritative !== null && (authoritative.templateType === "PUBLISH" || authoritative.published === true);
3579
3636
  }
3580
- const readback = (await wireCall(session, { path: ENDPOINTS.workflowGetDraft, query: { workflowCode: args.workflowCode } })).data;
3637
+ const readback = shouldPublish
3638
+ ? authoritative
3639
+ : (await wireCall(session, { path: ENDPOINTS.workflowGetDraft, query: { workflowCode: args.workflowCode } })).data;
3581
3640
  const nodeButtons = (readback ? readback.activities : draft.activities);
3582
3641
  const rows = Array.isArray(nodeButtons)
3583
3642
  ? nodeButtons
3584
3643
  : nodeButtons && typeof nodeButtons === "object"
3585
3644
  ? Object.values(nodeButtons)
3586
3645
  : [];
3646
+ // 以权威面为准区分三种真实状态:容器不存在 / 容器在但按钮全禁用 / 有启用按钮。
3587
3647
  const state = args.nodes.map((node) => {
3588
3648
  const row = rows.find((entry) => String(entry.activityCode ?? "") === node.activityCode) ?? {};
3589
- const bp = (row.buttonPermission ?? {});
3649
+ const rawPerm = row.buttonPermission;
3650
+ const buttonPermissionIsNull = rawPerm === null || rawPerm === undefined;
3651
+ const bp = (rawPerm ?? {});
3590
3652
  const btns = Array.isArray(bp.customBtns) ? bp.customBtns : [];
3653
+ const enabled = btns.filter((button) => button.enabled === true).map((button) => String(button.code ?? ""));
3654
+ const disabled = btns.filter((button) => button.enabled !== true).map((button) => String(button.code ?? ""));
3655
+ const containers = Array.isArray(bp.childTableBtns) ? bp.childTableBtns.length : 0;
3591
3656
  return {
3592
3657
  activityCode: node.activityCode,
3593
- enabled: btns.filter((button) => button.enabled === true).map((button) => String(button.code ?? "")),
3594
- disabled: btns.filter((button) => button.enabled !== true).map((button) => String(button.code ?? "")),
3658
+ enabled,
3659
+ disabled,
3660
+ buttonPermissionIsNull,
3661
+ mode: buttonPermissionIsNull ? "absent" : enabled.length > 0 ? "enabled-in-container" : "disabled-in-container",
3662
+ childTableButtonContainerCount: containers,
3595
3663
  };
3596
3664
  });
3665
+ const cleared = state.filter((entry) => entry.buttonPermissionIsNull);
3597
3666
  return {
3598
3667
  performed: { errcode: performed.errcode, publishRequested: shouldPublish, nodes: args.nodes.map((node) => node.activityCode) },
3599
3668
  readback: {
3600
3669
  workflowCode: args.workflowCode,
3601
3670
  nodes: state,
3602
3671
  published: publishMarked,
3672
+ readbackFace: shouldPublish ? "published" : "draft",
3603
3673
  buttonNames: names,
3604
- note: "节点未列出的按钮被置为 enabled:false(不删除子表按钮配置);表单页只在 enabled:true 的节点显示该按钮",
3674
+ buttonPermissionIsNull: cleared.length > 0,
3675
+ ...(cleared.length > 0 ? { clearedNodes: cleared.map((entry) => entry.activityCode) } : {}),
3676
+ note: cleared.length > 0
3677
+ ? "权威读回显示这些节点的 buttonPermission 为 null(容器被平台清空/归一化,不是容器仍在但按钮均被禁用):节点不再命中节点权限分支,表单按钮会回落到权限组。子表按钮配置也未保留——需要保留时请只传有内容的 buttonCodes,不要传空数组。"
3678
+ : "权威读回显示 buttonPermission 容器仍在;未列出的表单按钮为 enabled:false,子表按钮配置保留。表单页只在 enabled:true 的节点显示该按钮。",
3605
3679
  },
3606
3680
  };
3607
3681
  },
@@ -967,7 +967,7 @@ export function projectResultExtract(result, paths, keysOnly, retry) {
967
967
  }
968
968
  return out;
969
969
  }
970
- const SINGLE_PATH_META_KEYS = ["from", "artifactId", "sha256", "truncated", "truncatedKeys", "itemsCount", "total", "projectionHint"];
970
+ const SINGLE_PATH_META_KEYS = ["from", "artifactId", "sha256", "truncated", "truncatedKeys", "itemsCount", "total", "projectionHint", "projectionMiss"];
971
971
  const SINGLE_PATH_ENTRY_META_KEYS = ["mapped", "nullEntries", "nonNullEntries", "missedEntries", "from", "autoStripped", "hint"];
972
972
  export function unwrapSinglePathProjection(projected) {
973
973
  const extracts = projected.extract;
@@ -160,11 +160,11 @@ const READ_SHAPES = {
160
160
  // A2 locator:模板摘要 activities[].code ↔ 实例/待办 activityCode(Activity.java:26-30
161
161
  // 存储面原生键就是 activityCode/activityType/activityName;code/name/type 是摘要投影)。
162
162
  locator: { templateActivityKey: "code", instanceKey: "activityCode", workitemKey: "activityCode" },
163
- keys: ["status", "workflowCode", "exists", "published", "workflowSummary:{workflowCode,templateType,activities:array<{index,code,type,name,bizActions?:{<nodeEvent>:[ruleCode]},systemBizActions?:{bizActionType,ruleCodes:[code]}}>,edges:array<{from,to}>,ruleBindings:array<{...}>,nodeRuleBindings?,systemRuleBindings?,ruleBindingCount,originateActivity:{code,type,name,participant}}", "activities:array<{code,name,type,bizActions?,systemBizActions?}>(投影)", "propertyPermissionsCount", "version", "summaryHint", "truncatedKeys?", "omittedKeys?", "truncated?", "data?(外置时 null,完整模板在 detailArtifactId)", "omittedShape?", "omittedNote?", "environmentFingerprint", "detailArtifactId?", "detailSha256?", "fetch?"],
164
- notes: ["规则绑定三个面:流程级 ruleBindings、节点事件 activities[].bizActions、SYSTEM_ACTIVITY 顶层 activities[].systemBizActions(规则绑在系统活动节点本身、激活时执行)——三个面看完再下「没绑」结论;完整模板在 data(外置 detailArtifactId),要深层字段时投影写到叶子(如 --jq 'data.activities[].bizActions')——写整棵父节点会因总量超限再次被外置;activities[] 键=code/name/type,实例/待办面(workflow.instanceActivity、workitem.list)同一概念叫 activityCode/activityName(workitem 行没有 activityType)——跨面对照别拿错键"],
163
+ keys: ["status", "workflowCode", "exists", "published", "workflowSummary:{workflowCode,templateType,activities:array<{index,code,type,name,bizActions?:{<nodeEvent>:[ruleCode]},systemBizActions?:{bizActionType,ruleCodes:[code]}}>,edges:array<{from,to,ruleConditionGroup?:[[{currentDataItem,bizPropertyType,conditionType,value}]],utilizeElse?,popupType?,childMatchType?}>,ruleBindings:array<{...}>,nodeRuleBindings?,systemRuleBindings?,ruleBindingCount,originateActivity:{code,type,name,participant}}", "activities:array<{code,name,type,bizActions?,systemBizActions?}>(投影)", "propertyPermissionsCount", "version", "summaryHint", "truncatedKeys?", "omittedKeys?", "truncated?", "data?(外置时 null,完整模板在 detailArtifactId)", "omittedShape?", "omittedNote?", "environmentFingerprint", "detailArtifactId?", "detailSha256?", "fetch?"],
164
+ notes: ["规则绑定三个面:流程级 ruleBindings、节点事件 activities[].bizActions、SYSTEM_ACTIVITY 顶层 activities[].systemBizActions(规则绑在系统活动节点本身、激活时执行)——三个面看完再下「没绑」结论;完整模板在 data(外置 detailArtifactId),要深层字段时投影写到叶子(如 --jq 'data.activities[].bizActions')——写整棵父节点会因总量超限再次被外置;activities[] 键=code/name/type,实例/待办面(workflow.instanceActivity、workitem.list)同一概念叫 activityCode/activityName(workitem 行没有 activityType)——跨面对照别拿错键", "条件分支在 edges[]:带 ruleConditionGroup 的边就是条件边(条件行含 currentDataItem/bizPropertyType/conditionType/value),utilizeElse:true 是该节点的 else 出口;摘要已含这些字段——确认「金额>1000→主管」这类分支不必再取 data 全量模板"],
165
165
  },
166
166
  "workflow.get_draft": {
167
- keys: ["status", "workflowCode", "exists", "workflowSummary:{workflowCode,templateType,activities:array<{index,code,type,name,bizActions?:{<nodeEvent>:[ruleCode]},systemBizActions?:{bizActionType,ruleCodes:[code]}}>,edges:array<{from,to}>,ruleBindings:array<{...}>,nodeRuleBindings?,systemRuleBindings?,ruleBindingCount,originateActivity:{code,type,name,participant}}", "activities:array<{code,name,type,bizActions?,systemBizActions?}>(投影)", "propertyPermissionsCount", "version", "summaryHint", "truncatedKeys?", "omittedKeys?", "truncated?", "data?(外置时 null,完整模板在 detailArtifactId)", "omittedShape?", "omittedNote?", "environmentFingerprint", "detailArtifactId?", "detailSha256?", "fetch?"],
167
+ keys: ["status", "workflowCode", "exists", "workflowSummary:{workflowCode,templateType,activities:array<{index,code,type,name,bizActions?:{<nodeEvent>:[ruleCode]},systemBizActions?:{bizActionType,ruleCodes:[code]}}>,edges:array<{from,to,ruleConditionGroup?:[[{currentDataItem,bizPropertyType,conditionType,value}]],utilizeElse?,popupType?,childMatchType?}>,ruleBindings:array<{...}>,nodeRuleBindings?,systemRuleBindings?,ruleBindingCount,originateActivity:{code,type,name,participant}}", "activities:array<{code,name,type,bizActions?,systemBizActions?}>(投影)", "propertyPermissionsCount", "version", "summaryHint", "truncatedKeys?", "omittedKeys?", "truncated?", "data?(外置时 null,完整模板在 detailArtifactId)", "omittedShape?", "omittedNote?", "environmentFingerprint", "detailArtifactId?", "detailSha256?", "fetch?"],
168
168
  notes: ["与 workflow.get_published 同形(少了 published 键);节点绑定看 activities[].bizActions、系统活动顶层看 systemBizActions;templateType=DRAFT;深层字段投影写到叶子,完整模板在 data/detailArtifactId"],
169
169
  },
170
170
  // R88 #1:双面排查面。returnsFace 只显 notes 首条——教学并进首条。
package/dist/read.js CHANGED
@@ -44,8 +44,11 @@ export async function governedRead(ctx, tool, args, execute, options = {}) {
44
44
  return refusalFromCoverage(error);
45
45
  }
46
46
  }
47
+ // issue 2026-11 F5:catch 里也要说清「打的是哪台」,所以把 session 提到 try 外。
48
+ let sessionRef;
47
49
  try {
48
50
  const session = await ctx.sessions.session(args.environment);
51
+ sessionRef = session;
49
52
  const environmentFingerprint = safeFingerprint(session);
50
53
  const result = await execute(session);
51
54
  if (result.status === "refused" || result.status === "uncertain")
@@ -111,7 +114,17 @@ export async function governedRead(ctx, tool, args, execute, options = {}) {
111
114
  }
112
115
  catch (error) {
113
116
  if (isUncertainWireError(error))
114
- return { status: "uncertain", frozen: true, reason: `wire-transport:${wireErrorKind(error)}`, detail: error.message };
117
+ return {
118
+ status: "uncertain",
119
+ frozen: true,
120
+ reason: `wire-transport:${wireErrorKind(error)}`,
121
+ detail: error.message,
122
+ // issue 2026-11 F5:传输失败时把「到底打的是哪台」一起回出来——真机会话里
123
+ // env list 是 cwd 作用域,agent 静默落到全局 default 的另一台主机,只看
124
+ // detail 无从判断。configRoot/项目根用 `omc env list` 复核。
125
+ ...(sessionRef !== undefined ? { environment: sessionRef.environmentName, baseUrl: sessionRef.profile.baseUrl } : {}),
126
+ environmentHint: "env 清单随 cwd 变(项目根 .omc-env/.omc-envs + 配置根);`omc env list` 首行回显 configRoot/projectRoot",
127
+ };
115
128
  if (error instanceof WireError)
116
129
  return { status: "refused", blocker: `wire-${error.kind}`, errcode: error.errcode, message: error.message, ...(error.diagnostic ? { diagnostic: error.diagnostic } : {}), ...(error.hint ? { hint: error.hint } : {}) };
117
130
  throw error;
package/dist/rollback.js CHANGED
@@ -353,8 +353,30 @@ export async function applyRollback(ref, options, context) {
353
353
  // explicitification tolerance can never hide a real mismatch past limit.
354
354
  verify = residual.nonAdditionCount === 0 ? "restored" : "mismatch";
355
355
  }
356
+ const mismatch = verify === "mismatch";
357
+ // issue 2026-11 F2:mismatch 的下一步必须能真的把目标改回去。优先给**可粘贴的
358
+ // 单条补偿命令**(取 inverse 的第一条;参数过大时退回 rollback plan/apply,
359
+ // 避免把 1MB 模板塞进回执)。
360
+ const inverseCall = plan.inverse.kind === "calls" ? plan.inverse.calls[0] : undefined;
361
+ const inverseArgs = inverseCall === undefined ? undefined : { ...inverseCall.args, environment: entry.environment };
362
+ const inverseJson = inverseArgs === undefined ? undefined : JSON.stringify(inverseArgs);
363
+ const pasteable = inverseCall !== undefined && inverseJson !== undefined && inverseJson.length <= 1_200;
364
+ const nextCommand = !mismatch
365
+ ? undefined
366
+ : pasteable
367
+ ? `omc call ${inverseCall.tool} --env ${entry.environment} --args '${inverseJson}'`
368
+ : `omc rollback plan ${entry.seq} --env ${entry.environment}`;
369
+ const compensation = !mismatch
370
+ ? undefined
371
+ : pasteable
372
+ ? { tool: inverseCall.tool, args: inverseArgs, why: "权威读回与 before 不一致;这条是本次恢复原本要执行的写,可直接重放" }
373
+ : {
374
+ tool: "rollback.plan",
375
+ args: { seq: entry.seq, environment: entry.environment },
376
+ why: `权威读回与 before 不一致;恢复参数较大(${inverseJson?.length ?? 0}B)不回内联——先看 plan 的 diff,再 omc rollback apply ${entry.seq} 重试`,
377
+ };
356
378
  return {
357
- status: "ok",
379
+ status: mismatch ? "refused" : "ok",
358
380
  rollbackOf: { seq: entry.seq, tool: entry.tool, target: entry.target },
359
381
  calls: results,
360
382
  // B1: the shared step-identity projection (same shape as apply_changes /
@@ -370,7 +392,16 @@ export async function applyRollback(ref, options, context) {
370
392
  matchesBefore: verify === "restored",
371
393
  recoveredTo: { seq: entry.seq, ts: entry.ts },
372
394
  ...(progressFile !== undefined ? { progressFile } : {}),
373
- ...(verify === "mismatch" ? { beforeSha, restoredSha, message: "恢复调用已完成但读回与 before 存在值冲突(非默认显式化):立即人工核对目标现态(omc rollback plan <seq> 的 diff 可复看差异)" } : {}),
395
+ ...(mismatch
396
+ ? {
397
+ beforeSha,
398
+ restoredSha,
399
+ blocker: "rollback-readback-mismatch",
400
+ message: "恢复调用已完成但权威读回与 before 不一致,不得标记成功;按 nextCommand 补偿后重跑 rollback plan 复核",
401
+ nextCommand,
402
+ compensation,
403
+ }
404
+ : {}),
374
405
  hint: "本次恢复的每次调用都走了完整写闸门并已记 journal;恢复本身可再回滚(rollback plan <新 seq>)",
375
406
  };
376
407
  }
package/dist/session.js CHANGED
@@ -23,6 +23,9 @@ export class CloudPivotSession {
23
23
  version;
24
24
  /** r86(retro issue 17):原始版本串("AI-Platform-v1.1.25" 这类含产品线前缀的完整值)。 */
25
25
  rawVersion;
26
+ versionSource;
27
+ /** F7:license 载荷留作读面复用(buildTime/licenseType 只在 license/info 有)。 */
28
+ licenseInfoValue;
26
29
  /**
27
30
  * Non-fatal login caveats (e.g. the `client` blob in system/config was
28
31
  * absent or unreadable, so the token request carried no client_secret).
@@ -67,32 +70,13 @@ export class CloudPivotSession {
67
70
  administrator: cached.administrator,
68
71
  ...(cached.accountIdentity !== undefined ? { accountIdentity: cached.accountIdentity } : {}),
69
72
  };
70
- if (cached.version !== undefined) {
71
- this.version = cached.version;
72
- if (cached.rawVersion !== undefined)
73
- this.rawVersion = cached.rawVersion;
74
- }
75
- else {
76
- // Legacy cache written while version evidence was unavailable: probe the
77
- // public system config once and backfill the cache, otherwise every
78
- // later write stays fail-closed even after the probe itself is fixed
79
- // (live 2026-10-17: AI-Platform deployment, pcServerUrl null).
80
- const systemConfig = await core
81
- .fetchCloudPivotSystemConfig(this.profile.baseUrl, undefined, fetch, core.cloudPivotTenantHeaders(this.profile.engineCode))
82
- .catch(() => undefined);
83
- this.version = detectVersion(systemConfig);
84
- this.rawVersion = detectRawVersion(systemConfig);
85
- if (this.version !== undefined) {
86
- this.tokenCache?.save({
87
- token: cached.token,
88
- enterpriseId: cached.enterpriseId,
89
- administrator: cached.administrator,
90
- ...(cached.accountIdentity !== undefined ? { accountIdentity: cached.accountIdentity } : {}),
91
- version: this.version,
92
- ...(this.rawVersion !== undefined ? { rawVersion: this.rawVersion } : {}),
93
- });
94
- }
95
- }
73
+ const evidence = await this.probeVersionEvidence(cached.version, cached.rawVersion);
74
+ this.version = evidence.version;
75
+ this.rawVersion = evidence.rawVersion;
76
+ this.versionSource = evidence.source;
77
+ // 缓存命中路径只在**拿到证据**时回写(探测失败不得凭空改写缓存)。
78
+ if (evidence.version !== undefined)
79
+ this.saveCachedLogin(this.loginResult, evidence);
96
80
  return this.loginResult;
97
81
  }
98
82
  const core = await omcCore();
@@ -115,16 +99,11 @@ export class CloudPivotSession {
115
99
  ...(systemConfig ? { systemConfig } : {}),
116
100
  });
117
101
  this.loginNotesValue = authenticator.loginNotes();
118
- this.version = detectVersion(systemConfig);
119
- this.rawVersion = detectRawVersion(systemConfig);
120
- this.tokenCache?.save({
121
- token: this.loginResult.token,
122
- enterpriseId: this.loginResult.enterpriseId,
123
- administrator: this.loginResult.administrator,
124
- ...(this.loginResult.accountIdentity !== undefined ? { accountIdentity: this.loginResult.accountIdentity } : {}),
125
- ...(this.version !== undefined ? { version: this.version } : {}),
126
- ...(this.rawVersion !== undefined ? { rawVersion: this.rawVersion } : {}),
127
- });
102
+ const evidence = await this.probeVersionEvidence(undefined, undefined, systemConfig);
103
+ this.version = evidence.version;
104
+ this.rawVersion = evidence.rawVersion;
105
+ this.versionSource = evidence.source;
106
+ this.saveCachedLogin(this.loginResult, evidence);
128
107
  return this.loginResult;
129
108
  }
130
109
  /** Version-family evidence; absent evidence returns undefined (fail closed upstream). */
@@ -135,6 +114,66 @@ export class CloudPivotSession {
135
114
  rawSystemVersion() {
136
115
  return this.rawVersion;
137
116
  }
117
+ versionEvidenceSource() {
118
+ return this.versionSource;
119
+ }
120
+ /** F7:登录期已探测过的 license/info 载荷;读面据此免去第二次 wire。 */
121
+ licenseInfo() {
122
+ return this.licenseInfoValue;
123
+ }
124
+ async probeVersionEvidence(cachedVersion, cachedRawVersion, knownSystemConfig) {
125
+ // F7(issue 05):缓存命中**不意味着**要重新探测。已有版本且属于锚定族
126
+ // (或本来就是 license 证据)就零 wire 直接用;只有「没有版本」或「缓存说
127
+ // 自己不是 8.6 族」时才重探——后者正是真机 1.1.25 误报的场景。
128
+ if (cachedVersion !== undefined && (this.versionSource === "license/info" || cachedVersion.startsWith("8.6.")))
129
+ return { version: cachedVersion, rawVersion: cachedRawVersion, source: this.versionSource ?? "system-config" };
130
+ let license;
131
+ try {
132
+ // license/info 是管理员端点:401/403/404 都属「该产品线没这面」,直接回退。
133
+ // 用裸 http(不走 this.request):后者对 401 会清 token cache 重登,而非管理员
134
+ // 会话读 license 恰好是 401,会把缓存打掉。
135
+ const response = await (await this.http()).request({ path: "/api/license/info", method: "GET", headers: this.headers() });
136
+ if (response.status >= 200 && response.status < 300) {
137
+ const body = response.body;
138
+ const data = body && typeof body === "object" && body.data && typeof body.data === "object"
139
+ ? body.data
140
+ : response.body;
141
+ if (data && typeof data === "object")
142
+ license = data;
143
+ }
144
+ }
145
+ catch {
146
+ // license 面不可达:回退 system/config。
147
+ }
148
+ this.licenseInfoValue = license;
149
+ const licenseVersion = detectVersion(license);
150
+ if (licenseVersion !== undefined)
151
+ return { version: licenseVersion, rawVersion: detectRawVersion(license), source: "license/info" };
152
+ let systemConfig = knownSystemConfig;
153
+ if (!systemConfig) {
154
+ const core = await omcCore();
155
+ systemConfig = await core
156
+ .fetchCloudPivotSystemConfig(this.profile.baseUrl, undefined, fetch, core.cloudPivotTenantHeaders(this.profile.engineCode))
157
+ .catch(() => undefined);
158
+ }
159
+ const publicVersion = detectVersion(systemConfig);
160
+ if (publicVersion !== undefined)
161
+ return { version: publicVersion, rawVersion: detectRawVersion(systemConfig), source: "system-config" };
162
+ if (cachedVersion !== undefined)
163
+ return { version: cachedVersion, rawVersion: cachedRawVersion, source: "token-cache" };
164
+ return {};
165
+ }
166
+ saveCachedLogin(login, evidence) {
167
+ this.tokenCache?.save({
168
+ token: login.token,
169
+ enterpriseId: login.enterpriseId,
170
+ administrator: login.administrator,
171
+ ...(login.accountIdentity !== undefined ? { accountIdentity: login.accountIdentity } : {}),
172
+ ...(evidence.version !== undefined ? { version: evidence.version } : {}),
173
+ ...(evidence.rawVersion !== undefined ? { rawVersion: evidence.rawVersion } : {}),
174
+ ...(evidence.source !== undefined ? { versionSource: evidence.source } : {}),
175
+ });
176
+ }
138
177
  /** Non-fatal login caveats; empty when the login was fully nominal. */
139
178
  loginNotes() {
140
179
  return this.loginNotesValue;
@@ -227,7 +266,9 @@ export class CloudPivotSession {
227
266
  function detectVersion(systemConfig) {
228
267
  if (!systemConfig)
229
268
  return undefined;
230
- for (const key of ["version", "sysVersion", "systemVersion", "productVersion", "serverVersion"]) {
269
+ // 真机 8.6 用 systemVersion;1.1.x 的公共配置与旧缓存用 version——都来自
270
+ // system/config 响应,不是 bundle 版本(bundle 猜版本是 F7 的原始误报来源)。
271
+ for (const key of ["systemVersion", "version", "sysVersion", "productVersion", "serverVersion"]) {
231
272
  const value = systemConfig[key];
232
273
  if (typeof value !== "string")
233
274
  continue;
@@ -246,7 +287,7 @@ function detectVersion(systemConfig) {
246
287
  function detectRawVersion(systemConfig) {
247
288
  if (!systemConfig)
248
289
  return undefined;
249
- for (const key of ["version", "sysVersion", "systemVersion", "productVersion", "serverVersion"]) {
290
+ for (const key of ["systemVersion", "version", "sysVersion", "productVersion", "serverVersion"]) {
250
291
  const value = systemConfig[key];
251
292
  if (typeof value === "string" && value.trim().length > 0)
252
293
  return value.trim();
package/dist/write.js CHANGED
@@ -116,7 +116,22 @@ lintDeclaration = { lintScope: "partial", lintUnchecked: [] }) {
116
116
  frozen: true,
117
117
  reason: `wire-transport:${wireErrorKind(error)}`,
118
118
  detail: error.message,
119
- message: "write outcome cannot be established; frozen — re-discover before retrying; never assume success",
119
+ // issue 2026-11 F5:同读面——把环境名与 baseUrl 一起回出来,避免
120
+ // 「cwd 落到全局 default 的另一台主机」被误判成参数问题。
121
+ environment: session.environmentName,
122
+ baseUrl: session.profile.baseUrl,
123
+ environmentHint: "env 清单随 cwd 变(项目根 .omc-env/.omc-envs + 配置根);`omc env list` 首行回显 configRoot/projectRoot",
124
+ // 2.1.5 起管理端点统一 @AdminOnly(8.6 是 @RequireAdmin):401/403 往往
125
+ // 不是 token 坏了,而是该端点在新版要求管理员。不要笼统说「传输失败」。
126
+ ...(error instanceof WireError && error.kind === "http-status" && (error.diagnostic?.httpStatus === 401 || error.diagnostic?.httpStatus === 403)
127
+ ? {
128
+ message: `HTTP ${error.diagnostic?.httpStatus}:写请求被拒(结果未知,先别重放)。2.1.5 起管理端点(programming.*、workflow.publish/update、license/info)统一为 @AdminOnly,普通应用管理员可能不再放行;先确认账号,再区分「端点要求管理员」与「平台未开该功能」。`,
129
+ nextAction: "换管理员账号复验;仍 403 就查平台侧功能开关(如 cloudpivot.programming.enable),不要把 403 当 token 过期反复重登",
130
+ }
131
+ : {}),
132
+ message: error instanceof WireError && error.kind === "http-status" && (error.diagnostic?.httpStatus === 401 || error.diagnostic?.httpStatus === 403)
133
+ ? `HTTP ${error.diagnostic?.httpStatus}:写请求被拒(结果未知,先别重放)。2.1.5 起管理端点(programming.*、workflow.publish/update、license/info)统一为 @AdminOnly;先确认账号与功能开关。`
134
+ : "write outcome cannot be established; frozen — re-discover before retrying; never assume success",
120
135
  // r46 实证:data.submit 传输中断但平台已落行,按回执盲重试产生重复数据
121
136
  // 再连锁清理。uncertain ≠ 失败——先按业务键查重再决定。
122
137
  hint: "uncertain 不是失败:写可能已生效。data.submit/data.save 先 data.list 按业务键(单号/编码)查重,命中即成功勿重发;未命中再重试。",
@@ -166,6 +181,39 @@ lintDeclaration = { lintScope: "partial", lintUnchecked: [] }) {
166
181
  nextAction: "先分叉:本次是照示例新建/改配置吗?是→按成因②对照一条已成功配置(rule.get/form.get 读回)补齐非空列字段再重试;否→按成因①稍后重试同一请求,持续复现查平台 DB/ORM 日志",
167
182
  ...(error.diagnostic ? { diagnostic: error.diagnostic } : {}),
168
183
  };
184
+ // 2.1.5(AI-Platform v2.1.5)提交新增「隐藏字段」校验:规则引用的隐藏字段
185
+ // 也必须出现在 payload 里,否则 409200。8.6/8.7 没有这一道,旧调用方按
186
+ // 「只传可见字段」构造会被拒。
187
+ if (error.errcode === 409200)
188
+ return {
189
+ status: "refused",
190
+ blocker: `wire-${error.kind}`,
191
+ errcode: 409200,
192
+ "platform-version": "2.1.5+",
193
+ message: `${error.message}——2.1.5 起提交会校验**隐藏字段**(409200 HIDDEN_PROPERTY_SUBMIT_FAIL):数据规则引用的字段即使表单不可见,也必须出现在 formData/bizObject.data 里;8.6/8.7 不做这道校验。`,
194
+ nextAction: "先 data.load/form.get 读回该记录(隐藏字段有真值),把缺失字段补进 payload 再提交;不要靠删字段绕过——规则仍会命中",
195
+ nextCommand: "omc call data.load --args '{\"schemaCode\":\"<model>\",\"bizObjectId\":\"<id>\"}'",
196
+ };
197
+ // 子表超限:8.6 = 36102,8.7/2.1.5 = 36104(同义)。
198
+ if (error.errcode === 36102 || error.errcode === 36104)
199
+ return {
200
+ status: "refused",
201
+ blocker: "child-table-data-over-limit",
202
+ errcode: error.errcode,
203
+ message: `${error.message}——子表查询结果超限(8.6 回 36102,8.7/2.1.5 回 36104,同一语义)。收窄 filters/时间窗,或分页读 list_child;不要靠调大 size 硬拉。`,
204
+ nextCommand: "omc call data.list --args '{\"schemaCode\":\"<child>\",\"size\":20,\"page\":0}'",
205
+ };
206
+ // 2.1.5 起管理面统一 @AdminOnly(8.6 是 @RequireAdmin):401/403 往往不是
207
+ // 「token 坏了」,而是该端点在新版要求管理员。
208
+ if (error.kind === "http-status" && (error.diagnostic?.httpStatus === 401 || error.diagnostic?.httpStatus === 403))
209
+ return {
210
+ status: "refused",
211
+ blocker: `wire-${error.kind}`,
212
+ errcode: error.errcode,
213
+ message: `${error.message}——HTTP ${error.diagnostic?.httpStatus}:先确认账号;2.1.5 起管理端点(programming.*、workflow.publish/update、license/info 等)统一为 @AdminOnly(8.6 是 @RequireAdmin),普通应用管理员可能不再放行。`,
214
+ nextAction: "换管理员账号复验;仍 403 就区分「端点要求管理员」与「平台未开该功能」",
215
+ ...(error.diagnostic ? { diagnostic: error.diagnostic } : {}),
216
+ };
169
217
  return { status: "refused", blocker: `wire-${error.kind}`, errcode: error.errcode, message: error.message, ...(error.diagnostic ? { diagnostic: error.diagnostic } : {}) };
170
218
  }
171
219
  throw error;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stalfh233/omc-cli",
3
- "version": "0.6.97",
3
+ "version": "0.6.99",
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.97",
59
+ "omc-core": "0.6.99",
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.97"
77
+ "@stalfh233/omc-fake-platform": "0.6.99"
78
78
  }
79
79
  }
@@ -189,6 +189,23 @@ omc call field.publish --env local --args '{"schemaCode":"expense"}'
189
189
  **只传主表字段**;确需追加行时显式 `allowChildRowAppend:true`(0.4.63 起默认拒绝,blocker `submit-approval-child-rows`)。
190
190
  收尾时前后各读一次子表行数确认未变。
191
191
 
192
+ ## Excel 导入会全量替换子表(8.6 起;2.1.5 同)
193
+
194
+ `importType=UPDATE|ADD_UPDATE` 命中**已有主记录**时:旧子行全标 `Deleted`、导入行标 `Added`。
195
+ Excel **缺子表列/sheet 为空** → 既有子行被清空(主记录还在)。要追加/局部改子表用
196
+ `data.save`/`data.update` 逐条带子行 `id + rowStatus`,不要用 Excel 导入。
197
+
198
+ ## 8.7 / 2.1.5 写面差异(同一操作行为不同)
199
+
200
+ - 权限档位:8.6 只有 1..6;8.7/2.1.5 多 `7=同机构`。
201
+ - 子表行状态:8.6 只认 `Added/Modified/Deleted`;8.7/2.1.5 新增 `Sorted`(排序落库,须带行 id)。
202
+ - 按钮权限:2.1.5 拆审批态/查看态(`viewCustomBtns`/`viewChildBtns`/`viewBtnPermissionEqualApproval`),
203
+ 非审批态只读查看态、缺失即空——OMC 只改审批态时会自动写 `viewBtnPermissionEqualApproval:true`。
204
+ - 提交校验:2.1.5 新增隐藏字段校验 `409200`(规则引用的隐藏字段也必须在 payload 里)。
205
+ - 子表超限:8.6 `36102`,8.7/2.1.5 `36104`(同义)。
206
+ - 批量提交:8.7/2.1.5 的 `batch_submit` 不校验 replayToken;单条流程发起仍要 `getReplayToken`。
207
+ - 管理端点:8.6 `@RequireAdmin`,8.7/2.1.5 `@AdminOnly`——401/403 先确认账号,别当 token 过期。
208
+
192
209
  ## 收尾核对(无 `omc baseline` 命令)
193
210
 
194
211
  对照开场 `count` 读 `model.list` → `rule.list {onlyCustom:true}` → `datarule.list`(后两者期望 `modelPresent:false`)。**勿**对已删/从未存在的 schemaCode 再 `rule.list`——会补建 7 条不可删预置规则。