@stalfh233/omc-cli 0.6.82 → 0.6.84

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.js CHANGED
@@ -25,7 +25,8 @@ import { beginUsage, completeUsage, currentUsageArgsDigest, ensureProjectIgnore,
25
25
  import { artifactFetchHint, artifactRoot, boundResult, emitInvalid, emitResult, emitThrown, emitTransportResult, outputBudget, readArtifact, withTransport, } from "./command-transport.js";
26
26
  import { CLI_DEFAULT_OUTPUT_BYTES, assertSafeOutputPath, pruneArtifacts } from "./artifacts.js";
27
27
  import { sessionAccountForEnvironment } from "./session-account.js";
28
- import { artifactPathMissHint, nullProjectionHint, partialPathMissHint, pathMissDidYouMean, projectJsonPath, projectJsonPathFanout, projectResultExtract, shapeOf, SHAPE_MAX_DEPTH, unwrapSinglePathProjection } from "./path-projection.js";
28
+ import { closeWritableWindow, openWritableWindow, parseWritableTtl, sweepWritableWindowsAtStartup, validateWritableReason, writableWindowStatus, WRITABLE_WINDOW_DEFAULT_TTL_MINUTES, WRITABLE_WINDOW_LOG, WRITABLE_WINDOW_MAX_TTL_MINUTES, WritableWindowInputError } from "./writable-window.js";
29
+ import { artifactPathMissHint, nullProjectionHint, partialPathMissHint, pathMissCopyableHint, pathMissDidYouMean, projectJsonPath, projectJsonPathFanout, projectResultExtract, shapeOf, SHAPE_MAX_DEPTH, unwrapSinglePathProjection } from "./path-projection.js";
29
30
  import { basename, join, resolve } from "node:path";
30
31
  import { existsSync, readFileSync, writeFileSync, chmodSync } from "node:fs";
31
32
  import { buildToolRegistry } from "./tools.js";
@@ -1132,7 +1133,7 @@ async function cmdArtifactGet(id, transport, options = {}) {
1132
1133
  // `--shape <path>`:在命中的子树上出骨架(同 --jq 的路径 DSL,含 [] 与 [code=X])。
1133
1134
  const projected = projectArtifactPath(artifact.content.toString("utf8") === "" ? undefined : content, options.shape);
1134
1135
  if (projected.missed) {
1135
- return emitTransportResult({ status: "ok", artifactId: id, sha256: artifact.sha256, ...artifactProjectionMetadata(content), path: options.shape, content: null, pathMiss: true, missedAt: projected.at, available: projected.available, ...artifactMissExtras(projected), unanswered: true, hint: artifactPathMissHint(projected.at) }, transport);
1136
+ return emitTransportResult({ status: "ok", artifactId: id, sha256: artifact.sha256, ...artifactProjectionMetadata(content), path: options.shape, content: null, pathMiss: true, missedAt: projected.at, available: projected.available, ...artifactMissExtras(projected), unanswered: true, hint: artifactPathMissHint(projected.at, pathMissCopyableHint(content, options.shape, projected.at)) }, transport);
1136
1137
  }
1137
1138
  return emitTransportResult({ status: "ok", artifactId: id, sha256: artifact.sha256, bytes: artifact.content.length, path: options.shape, depth, shape: shapeOf(projected.content, depth), fetch: artifactFetchHint(id) }, transport);
1138
1139
  }
@@ -1175,7 +1176,7 @@ async function cmdArtifactGet(id, transport, options = {}) {
1175
1176
  // 一层 `projection:{path,content}`——`artifact get --jq` 与 `--summary --jq`
1176
1177
  // 因此同形(顶层 path/content),换读面不用重新探根键。
1177
1178
  return emitTransportResult(projected.missed
1178
- ? { status: "ok", artifactId: id, sha256: artifact.sha256, bytes: artifact.content.length, ...artifactProjectionMetadata(content), keys, path: options.jq, content: null, projections: [{ path: options.jq, content: null, pathMiss: true, missedAt: projected.at, available: projected.available, ...artifactMissExtras(projected) }], pathMiss: true, missedAt: projected.at, available: projected.available, ...artifactMissExtras(projected), unanswered: true, hint: artifactPathMissHint(projected.at) }
1179
+ ? { status: "ok", artifactId: id, sha256: artifact.sha256, bytes: artifact.content.length, ...artifactProjectionMetadata(content), keys, path: options.jq, content: null, projections: [{ path: options.jq, content: null, pathMiss: true, missedAt: projected.at, available: projected.available, ...artifactMissExtras(projected) }], pathMiss: true, missedAt: projected.at, available: projected.available, ...artifactMissExtras(projected), unanswered: true, hint: artifactPathMissHint(projected.at, pathMissCopyableHint(content, options.jq, projected.at)) }
1179
1180
  : {
1180
1181
  status: "ok",
1181
1182
  artifactId: id,
@@ -1234,7 +1235,7 @@ async function cmdArtifactGet(id, transport, options = {}) {
1234
1235
  }
1235
1236
  const projected = projectArtifactPath(artifactContent, options.jq);
1236
1237
  return emitTransportResult(projected.missed
1237
- ? { status: "ok", artifactId: id, sha256: artifact.sha256, ...artifactProjectionMetadata(content), path: options.jq, content: null, pathMiss: true, missedAt: projected.at, available: projected.available, ...artifactMissExtras(projected), unanswered: true, hint: artifactPathMissHint(projected.at) }
1238
+ ? { status: "ok", artifactId: id, sha256: artifact.sha256, ...artifactProjectionMetadata(content), path: options.jq, content: null, pathMiss: true, missedAt: projected.at, available: projected.available, ...artifactMissExtras(projected), unanswered: true, hint: artifactPathMissHint(projected.at, pathMissCopyableHint(artifactContent, options.jq, projected.at)) }
1238
1239
  : { status: "ok", artifactId: id, sha256: artifact.sha256, ...artifactProjectionMetadata(content), path: options.jq, projections: [{ path: options.jq, content: projected.content ?? null, ...(projected.mapped !== undefined ? { mapped: projected.mapped } : {}), ...(projected.missedEntries !== undefined ? { missedEntries: projected.missedEntries } : {}), ...(projected.nullEntries !== undefined && projected.nullEntries > 0 ? { nullEntries: projected.nullEntries } : {}) }], ...(projected.mapped !== undefined ? { mapped: projected.mapped } : {}), ...(projected.missedEntries !== undefined ? { missedEntries: projected.missedEntries } : {}), ...(projected.nullEntries !== undefined && projected.nullEntries > 0 ? { nullEntries: projected.nullEntries } : {}), ...(artifactNullHint(projected.content, projected.nullEntries) !== undefined ? { hint: artifactNullHint(projected.content, projected.nullEntries) } : {}) }, transport);
1239
1240
  }
1240
1241
  // r6-onboarding 2026-10-21: 47 artifact fetches, 0 used a projection; the 10
@@ -2671,6 +2672,10 @@ async function main() {
2671
2672
  // stderr is the diagnostics stream: apply the same Windows code-page policy
2672
2673
  // as stdout before ANY message is written (banner, doctor, refusals).
2673
2674
  installCodePageSafeStderr();
2675
+ // issue 13:临时期限窗口的懒恢复——任意命令启动时检查所有环境的
2676
+ // writableWindow,过期即恢复只读(无后台进程),当次 stderr 提示一句。
2677
+ // 用与命令相同的配置根(OMC_CONFIG_HOME / homedir),失败静默交给命令自身。
2678
+ sweepWritableWindowsAtStartup(new ConfigStore(defaultPaths()));
2674
2679
  beginUsage(argv);
2675
2680
  const command = new Command();
2676
2681
  // r60b-F7:helpDisplayed 不区分「根帮助」与「子命令帮助」——两者都走同一个
@@ -2757,7 +2762,7 @@ async function main() {
2757
2762
  nextCommand: "omc setup --list",
2758
2763
  }));
2759
2764
  });
2760
- command.command("env [action] [name]").description("环境清单与联调参数包;`env export` 一键导出 token/headers,免手工从浏览器复制 token").option("--json").option("--env <environment>", "环境名;按与 call 相同的项目范围门解析").option("--format <format>", "export:输出可 source 的 bash 环境变量语句").option("--field <field>", "输出单个裸值:accessToken|baseUrl|enterpriseId|engineCode").option("--example <example>", "追加一个复制即测示例:curl|node;path 换成你的接口(示例内 token 默认占位,真值走 --field accessToken 或管道注入)").option("--reveal-token", "示例里回填真实 accessToken(默认打码;只在本地直接执行时用,别把输出贴进对话/归档)").addHelpText("after", "\n`omc env export` 用于二开联调参数包;`--example curl|node` 追加复制即测示例(把 `<your-api-path>` 换成你的接口),默认 JSON 不带示例。`--format env` 可 source,`--field accessToken` 输出裸 token;`--example` 里的 token 默认占位(`--reveal-token` 才回填真值)。\n账号口径(issue 07):`account` 是本次**导出凭据**登录的显示名;`sessionAccount` 是 token 声明的账号(id=user_id、username=user_name)。导出凭据账号 ≠ 之后 call 的会话账号——凭据轮换/token 过期重登/多环境同名账号时两者不同;每次 `omc call` 回执的 resultMeta.sessionAccount 才是当次会话账号(token 解码,解不出回 unavailableReason)。报错里的 currentUser 是平台按 username 反查的 id(同名多账号时可能与 token user_id 不同人)。\n").action(async (action, name, options) => {
2765
+ command.command("env [action] [name]").description("环境清单与联调参数包;`env export` 一键导出 token/headers,免手工从浏览器复制 token").option("--json").option("--env <environment>", "环境名;按与 call 相同的项目范围门解析").option("--format <format>", "export:输出可 source 的 bash 环境变量语句").option("--field <field>", "输出单个裸值:accessToken|baseUrl|enterpriseId|engineCode").option("--example <example>", "追加一个复制即测示例:curl|node;path 换成你的接口(示例内 token 默认占位,真值走 --field accessToken 或管道注入)").option("--reveal-token", "示例里回填真实 accessToken(默认打码;只在本地直接执行时用,别把输出贴进对话/归档)").option("--ttl <duration>", `writable:窗口时长(默认 ${WRITABLE_WINDOW_DEFAULT_TTL_MINUTES}m,上限 ${WRITABLE_WINDOW_MAX_TTL_MINUTES}m),如 10m / 30m`).option("--reason <text>", "writable:必填,写清这一次为什么要临时开写(进 writable-window.log 审计)").option("--close", "writable:立即恢复只读并清掉窗口").addHelpText("after", "\n`omc env export` 用于二开联调参数包;`--example curl|node` 追加复制即测示例(把 `<your-api-path>` 换成你的接口),默认 JSON 不带示例。`--format env` 可 source,`--field accessToken` 输出裸 token;`--example` 里的 token 默认占位(`--reveal-token` 才回填真值)。\n账号口径(issue 07):`account` 是本次**导出凭据**登录的显示名;`sessionAccount` 是 token 声明的账号(id=user_id、username=user_name)。导出凭据账号 ≠ 之后 call 的会话账号——凭据轮换/token 过期重登/多环境同名账号时两者不同;每次 `omc call` 回执的 resultMeta.sessionAccount 才是当次会话账号(token 解码,解不出回 unavailableReason)。报错里的 currentUser 是平台按 username 反查的 id(同名多账号时可能与 token user_id 不同人)。\n\n环境写窗口(治理,issue 13):`omc env writable <env> --ttl 10m --reason \"为什么开写\"` 临时把该环境置为可写,回执带开启人/到期时间/到期自动恢复说明,并写 append-only 配置根 `" + WRITABLE_WINDOW_LOG + "` 审计(open/close/expire)。`--reason` 必填,TTL 默认 " + WRITABLE_WINDOW_DEFAULT_TTL_MINUTES + "m、上限 " + WRITABLE_WINDOW_MAX_TTL_MINUTES + "m。到期后**下一次任意 omc 命令**自动恢复只读(懒检查,没有后台进程);`omc env writable <env>` 查看窗口,`omc env writable <env> --close` 立即恢复只读。窗口只解除 writable 只读门——生产环境的每笔写**仍然**要在 args 里带 confirmProduction:true(两道门并存,窗口不绕过生产确认)。\n\n输入乱码自检(issue 18):若参数或用户消息出现异常汉字(如「翿」替掉「说/门/试」),先把原文回显请用户确认再执行——输入链路可能不是 UTF-8(终端/输入法→IPC),不要按猜测的语义写配置。\n").action(async (action, name, options) => {
2761
2766
  // Read-only inventory of configured environment names. r18: the sandbox
2762
2767
  // guessed names instead of listing them; doctor's wording now points here.
2763
2768
  const store = new ConfigStore(defaultPaths());
@@ -2804,6 +2809,92 @@ async function main() {
2804
2809
  }
2805
2810
  return;
2806
2811
  }
2812
+ if (action === "writable") {
2813
+ // issue 13:生产写临时开关。stdout 恒一个信封(与 export 同面);
2814
+ // 人类可读的一句话走 stderr。窗口只解除 writable 门,生产写仍须确认。
2815
+ const target = name ?? options.env;
2816
+ const emitWritable = (result) => {
2817
+ writeEnvelope(envelope("ok", result, request));
2818
+ return CLI_EXIT_CODES.ok;
2819
+ };
2820
+ try {
2821
+ if (!target) {
2822
+ console.error(`用法:omc env writable <环境名> [--ttl ${WRITABLE_WINDOW_DEFAULT_TTL_MINUTES}m] --reason "为什么开写" | omc env writable <环境名>(查看)| omc env writable <环境名> --close(立即恢复只读)`);
2823
+ const parsed = errorEnvelope(new Error("omc env writable 需要环境名"), "invalid-input", CLI_EXIT_CODES.invalidInput, request);
2824
+ writeEnvelope(parsed.envelope);
2825
+ commandExitCode = parsed.exitCode;
2826
+ return;
2827
+ }
2828
+ if (options.close === true) {
2829
+ if (options.ttl !== undefined || options.reason !== undefined) {
2830
+ const parsed = errorEnvelope(new Error("--close 与 --ttl/--reason 互斥:关窗不需要时长和原因(关窗本身会记审计)"), "invalid-input", CLI_EXIT_CODES.invalidInput, request);
2831
+ writeEnvelope(parsed.envelope);
2832
+ commandExitCode = parsed.exitCode;
2833
+ return;
2834
+ }
2835
+ const closed = closeWritableWindow(store, target);
2836
+ console.error(`已立即恢复只读:${closed.environment}${closed.previousWindow !== undefined ? `(原窗口:到期 ${closed.previousWindow.expiresAt},原因:${closed.previousWindow.reason})` : ""}`);
2837
+ commandExitCode = emitWritable({
2838
+ status: "ok",
2839
+ action: "close",
2840
+ environment: closed.environment,
2841
+ writable: false,
2842
+ ...(closed.previousWindow !== undefined ? { previousWindow: closed.previousWindow } : {}),
2843
+ sessionAccount: closed.sessionAccount,
2844
+ audit: WRITABLE_WINDOW_LOG,
2845
+ });
2846
+ return;
2847
+ }
2848
+ if (options.ttl === undefined && options.reason === undefined) {
2849
+ const status = writableWindowStatus(store, target);
2850
+ console.error(status.window !== undefined
2851
+ ? `${status.environment} 写窗口开启中:到期 ${status.window.expiresAt}(原因:${status.window.reason};开启人:${status.window.openedBy})。到期后下一次任意 omc 命令自动恢复只读;立即关:omc env writable ${status.environment} --close`
2852
+ : `${status.environment} 没有写窗口(writable=${status.writable})。开一次:omc env writable ${status.environment} --ttl ${WRITABLE_WINDOW_DEFAULT_TTL_MINUTES}m --reason "..."`);
2853
+ commandExitCode = emitWritable({
2854
+ status: "ok",
2855
+ action: "status",
2856
+ environment: status.environment,
2857
+ writable: status.writable,
2858
+ production: status.production,
2859
+ window: status.window ?? null,
2860
+ expired: status.expired,
2861
+ now: status.now,
2862
+ audit: WRITABLE_WINDOW_LOG,
2863
+ });
2864
+ return;
2865
+ }
2866
+ const ttlMinutes = parseWritableTtl(options.ttl);
2867
+ const reason = validateWritableReason(options.reason);
2868
+ const opened = openWritableWindow(store, target, { ttlMinutes, reason });
2869
+ const production = opened.profile.production === true;
2870
+ console.error(`已开启写窗口:${opened.environment} 到期 ${opened.window.expiresAt}(TTL ${opened.window.ttlMinutes}m,开启人:${opened.window.openedBy})。到期后下一次任意 omc 命令自动恢复只读;审计:${WRITABLE_WINDOW_LOG}${production ? "。注意:生产写仍需每笔 confirmProduction:true(窗口不绕过生产确认)" : ""}`);
2871
+ commandExitCode = emitWritable({
2872
+ status: "ok",
2873
+ action: "open",
2874
+ environment: opened.environment,
2875
+ writable: true,
2876
+ production,
2877
+ window: opened.window,
2878
+ openedBy: opened.window.openedBy,
2879
+ expiresAt: opened.window.expiresAt,
2880
+ sessionAccount: opened.sessionAccount,
2881
+ autoRestore: `到期(${opened.window.expiresAt})后下一次任意 omc 命令启动时自动恢复只读并清掉窗口记录(懒检查,无后台进程)`,
2882
+ productionConfirmation: production
2883
+ ? { required: true, note: "窗口只解除 writable 只读门;生产环境每笔写仍须在 args 里带 confirmProduction:true(两道门并存)" }
2884
+ : { required: false, note: "窗口只解除 writable 只读门" },
2885
+ audit: WRITABLE_WINDOW_LOG,
2886
+ });
2887
+ return;
2888
+ }
2889
+ catch (error) {
2890
+ const message = error instanceof Error ? error.message : String(error);
2891
+ const invalid = error instanceof WritableWindowInputError || /unknown environment|跨环境访问被拒绝|writableWindow|not valid JSON|must contain an environments/.test(message);
2892
+ const parsed = errorEnvelope(error, invalid ? "invalid-input" : "environment-unreachable", invalid ? CLI_EXIT_CODES.invalidInput : CLI_EXIT_CODES.internal, request);
2893
+ writeEnvelope(parsed.envelope);
2894
+ commandExitCode = parsed.exitCode;
2895
+ return;
2896
+ }
2897
+ }
2807
2898
  if (action === "allow") {
2808
2899
  // The only sanctioned way to widen a project's environment scope. The
2809
2900
  // list stays project-scoped until the operator names the environment —
@@ -2826,7 +2917,7 @@ async function main() {
2826
2917
  return;
2827
2918
  }
2828
2919
  if (action !== undefined && action !== "list") {
2829
- console.error("用法:omc env list [--json] | omc env allow <环境名>");
2920
+ console.error("用法:omc env list [--json] | omc env allow <环境名> | omc env writable <环境名> [--ttl 10m --reason \"...\" | --close]");
2830
2921
  commandExitCode = CLI_EXIT_CODES.invalidInput;
2831
2922
  return;
2832
2923
  }
@@ -44,6 +44,20 @@ export function removedProfileKeys(profile) {
44
44
  const raw = profile;
45
45
  return REMOVED_PROFILE_KEYS.filter((key) => raw[key] !== undefined);
46
46
  }
47
+ /** Fail closed on a malformed window (hand-edited config must not fake a gate). */
48
+ function validateWritableWindow(environment, window) {
49
+ if (window === null || typeof window !== "object" || Array.isArray(window))
50
+ throw new ConfigurationError(`environment ${environment} writableWindow must be an object when present`);
51
+ const record = window;
52
+ for (const key of ["openedBy", "openedAt", "expiresAt", "reason"])
53
+ if (typeof record[key] !== "string" || record[key].length === 0)
54
+ throw new ConfigurationError(`environment ${environment} writableWindow.${key} must be a non-empty string`);
55
+ if (typeof record.ttlMinutes !== "number" || !Number.isFinite(record.ttlMinutes) || record.ttlMinutes <= 0)
56
+ throw new ConfigurationError(`environment ${environment} writableWindow.ttlMinutes must be a positive number`);
57
+ for (const key of ["openedAt", "expiresAt"])
58
+ if (Number.isNaN(Date.parse(record[key])))
59
+ throw new ConfigurationError(`environment ${environment} writableWindow.${key} must be an ISO timestamp`);
60
+ }
47
61
  export class ConfigurationError extends Error {
48
62
  policyRefused;
49
63
  constructor(message, options = {}) {
@@ -131,6 +145,8 @@ export class ConfigStore {
131
145
  for (const key of ["isDefault", "production", "writable"])
132
146
  if (profile[key] !== undefined && typeof profile[key] !== "boolean")
133
147
  throw new ConfigurationError(`environment ${name} ${key} must be boolean when present`);
148
+ if (profile.writableWindow !== undefined)
149
+ validateWritableWindow(name, profile.writableWindow);
134
150
  const removed = removedProfileKeys(profile);
135
151
  if (removed.length > 0)
136
152
  throw new ConfigurationError(`environment ${name} carries removed governance keys: ${removed.join(", ")}. Writing is decided by "writable" alone, and a production write needs a per-write confirmProduction — delete these keys.`);
@@ -162,6 +178,25 @@ export class ConfigStore {
162
178
  this.writeConfig({ environments });
163
179
  return config;
164
180
  }
181
+ /**
182
+ * Read-modify-write one profile against a **fresh** config read. Used by the
183
+ * writable-window commands: the updater runs on the just-read profile so a
184
+ * concurrent setup edit is never silently overwritten by a stale snapshot.
185
+ */
186
+ updateEnvironmentProfile(name, update) {
187
+ const config = this.readConfig();
188
+ const current = config.environments[name];
189
+ if (!current)
190
+ throw new ConfigurationError(`unknown environment "${name}"; available: ${this.availableEnvironmentNames()}`);
191
+ const next = update(current);
192
+ const environments = { ...config.environments, [name]: next };
193
+ if (next.isDefault)
194
+ for (const [other, otherProfile] of Object.entries(environments))
195
+ if (other !== name)
196
+ environments[other] = { ...otherProfile, isDefault: false };
197
+ this.writeConfig({ environments });
198
+ return next;
199
+ }
165
200
  /**
166
201
  * Environments visible to THIS project. Project isolation is the default:
167
202
  * the caller only ever sees the project's own environments, never the rest of
package/dist/endpoints.js CHANGED
@@ -43,6 +43,16 @@ export const ENDPOINTS = {
43
43
  * answers 40007 请求方法不正确. There is no per-app or per-asset filter.
44
44
  */
45
45
  environmentLifeCycleExport: "/api/api/lifeCycle/apppackage/lifeCycleExport",
46
+ /**
47
+ * r86(retro issue 17):LicenseController(@RequestMapping("/api/license"),
48
+ * @RequireAdmin)的 GET /info → LicenseInfo{systemVersion(系统版本号),
49
+ * licenseType, expiration, ...}——8.6 族版本面(管理端「关于」页数据源)。
50
+ * 声明字段 buildTime 在该控制器的 info() 里**从不赋值**(反编译
51
+ * LicenseController.java:92-119 没有 setBuildTime),所以按「平台回传才用」处理。
52
+ * **产品线差异**:1.1.x(AI-Platform,真机 1.1.25)不挂载该路径(未认证 401、
53
+ * 管理员会话 404),版本只能回落 public/system/config 的 systemVersion 原串。
54
+ */
55
+ licenseInfo: "/api/license/info",
46
56
  modelList: "/api/api/app/bizmodels/list_schema",
47
57
  modelGet: "/api/api/app/bizmodels/get_all",
48
58
  modelCreate: "/api/api/app/bizmodels/create",
@@ -66,9 +66,70 @@ const RULE_ROUND_TRIP_FIXES = Object.freeze({
66
66
  });
67
67
  const roundTripFixOf = (code) => RULE_ROUND_TRIP_FIXES[code] ?? "按 message 修正该节点后重存;或不要整图回存:用 rule.node.update 只 patch 目标节点";
68
68
  const RULE_ROUND_TRIP_HINT = "整图原样回存会被这些 hazard 拒(rule.save);备份/恢复请用 rule.node.update 单节点 patch,或先补 gaps。**平台版本差异**:部分版本的读面不回传 CREATE 节点的 originatorValue(8.6.41 实测),本工具不猜值。";
69
+ const CANONICAL_NODE_KEY_BY_LOWER = {
70
+ targetworkflowcode: "targetWorkflowCode",
71
+ };
72
+ function normalizeCasingCollisions(value, nodeCode, path, collisions) {
73
+ if (Array.isArray(value)) {
74
+ return value.map((entry, index) => normalizeCasingCollisions(entry, nodeCode, `${path}[${index}]`, collisions));
75
+ }
76
+ if (value === null || typeof value !== "object")
77
+ return value;
78
+ const source = value;
79
+ const byLower = new Map();
80
+ for (const key of Object.keys(source)) {
81
+ const lower = key.toLowerCase();
82
+ const group = byLower.get(lower);
83
+ if (group)
84
+ group.push(key);
85
+ else
86
+ byLower.set(lower, [key]);
87
+ }
88
+ const output = {};
89
+ const handled = new Set();
90
+ for (const [lower, keys] of byLower) {
91
+ if (keys.length < 2)
92
+ continue;
93
+ const canonical = CANONICAL_NODE_KEY_BY_LOWER[lower];
94
+ const kept = canonical !== undefined && keys.includes(canonical) ? canonical : keys[0];
95
+ // fastjson 文本序最后赋值生效:存活值取组内最后一个键的值。
96
+ const lastKey = keys[keys.length - 1];
97
+ const surviving = source[lastKey];
98
+ const lostValues = keys.filter((key) => JSON.stringify(source[key]) !== JSON.stringify(surviving)).map((key) => source[key]);
99
+ const differ = lostValues.length > 0;
100
+ for (const key of keys)
101
+ handled.add(key);
102
+ collisions.push({
103
+ nodeCode,
104
+ kept,
105
+ dropped: keys.filter((key) => key !== kept).join(","),
106
+ valuesDiffer: differ,
107
+ // 被并掉、不再出现在投影里的值(存活值之外的分歧值)——数据不丢。
108
+ ...(differ ? { droppedValue: lostValues } : {}),
109
+ ...(path !== "" ? { path } : {}),
110
+ });
111
+ output[kept] = normalizeCasingCollisions(surviving, nodeCode, path === "" ? kept : `${path}.${kept}`, collisions);
112
+ }
113
+ for (const key of Object.keys(source)) {
114
+ if (handled.has(key))
115
+ continue;
116
+ output[key] = normalizeCasingCollisions(source[key], nodeCode, path === "" ? key : `${path}.${key}`, collisions);
117
+ }
118
+ return output;
119
+ }
69
120
  function projectRuleGraph(nodes, routes, full) {
121
+ // r86 issue 20:默认面与 --full 深层面同样归一——绝不出「同节点仅大小写
122
+ // 不同的两个键」的 JSON(PowerShell ConvertFrom-Json 会直接拒绝)。
123
+ const collisions = [];
124
+ const normalizedNodes = Array.isArray(nodes)
125
+ ? nodes.map((entry) => {
126
+ if (entry === null || typeof entry !== "object" || Array.isArray(entry))
127
+ return entry;
128
+ return normalizeCasingCollisions(entry, String(entry.nodeCode ?? ""), "", collisions);
129
+ })
130
+ : nodes;
70
131
  if (full)
71
- return { nodes, routes };
132
+ return { nodes: normalizedNodes, routes, casingCollisions: collisions };
72
133
  const strip = (value, keys) => {
73
134
  if (!Array.isArray(value))
74
135
  return value;
@@ -81,7 +142,7 @@ function projectRuleGraph(nodes, routes, full) {
81
142
  return copy;
82
143
  });
83
144
  };
84
- return { nodes: strip(nodes, RULE_NODE_LAYOUT_KEYS), routes: strip(routes, RULE_ROUTE_LAYOUT_KEYS) };
145
+ return { nodes: strip(normalizedNodes, RULE_NODE_LAYOUT_KEYS), routes: strip(routes, RULE_ROUTE_LAYOUT_KEYS), casingCollisions: collisions };
85
146
  }
86
147
  /**
87
148
  * `rule.get` 的默认投影:保住语义图(nodes/routes),只剥确定性布局。
@@ -1271,6 +1332,16 @@ export function registerBusinessRuleLane(tools) {
1271
1332
  routes: projected.routes,
1272
1333
  schedulerSetting: parse(record.schedulerSetting),
1273
1334
  renderCompat,
1335
+ // r86(retro issue 20):大小写冲突归一点名。节点内仅大小写不同的键已
1336
+ // 归一并进 casingNormalized(kept/dropped/valuesDiffer;值不同再给
1337
+ // droppedValue)——回执绝不含「同节点仅大小写不同的两个键」的 JSON
1338
+ // (PowerShell ConvertFrom-Json 会拒),无冲突时零噪音。
1339
+ ...(projected.casingCollisions.length > 0
1340
+ ? {
1341
+ casingNormalized: projected.casingCollisions,
1342
+ casingNote: "节点里仅大小写不同的键已归一(platform 双拼写并存:后端 DTO targetWorkFlowCode vs 设计器 targetWorkflowCode,fastjson 大小写不敏感折叠进同一字段);valuesDiffer:true 时存活值取文本序最后一个键(fastjson 最后赋值生效),被并值在 droppedValue",
1343
+ }
1344
+ : {}),
1274
1345
  // r85(retro 2026-11-19 issue 09/11):codeType:7 公式口径注记(非侵入,
1275
1346
  // 不改写公式)。无表达式映射时不出现该键。
1276
1347
  ...((() => { const notes = ruleFormulaNotes(projected.nodes); return notes ? { formulaNotes: notes } : {}; })()),
@@ -1374,6 +1445,11 @@ export function registerBusinessRuleLane(tools) {
1374
1445
  ...(linted.mappingFieldChecks > 0 ? { mappingFieldChecks: linted.mappingFieldChecks } : {}),
1375
1446
  ...(linted.absentMappingFields !== undefined ? { absentMappingFieldsAllowed: linted.absentMappingFields } : {}),
1376
1447
  publish: args.publish === true,
1448
+ // r86(retro issue 14):dry-run 与真写同答案——发布验证契约先行告知,
1449
+ // 避免「以为没发布成功 → 重复 save → 造新记录」。
1450
+ ...(args.publish === true
1451
+ ? { publishVerifyContract: "真写发布后经 runtime list_by_schemacode 读回验证(+1 wire):publishedVerified/verifiedBy/ruleVersion 只报验证过的事实;latestPublished 仅列表验证成立时出现,否则 latestPublishedUnchecked——不要因它重复 save(每次保存都造新记录 ID)" }
1452
+ : {}),
1377
1453
  customTrigger: linted.customTriggerApplied,
1378
1454
  ...(linted.bizMethodChecks > 0 ? { bizMethodChecks: linted.bizMethodChecks } : {}),
1379
1455
  ...(linted.lintWarnings.length > 0 ? { lintWarnings: linted.lintWarnings } : {}),
@@ -12,6 +12,7 @@ export const ENVIRONMENT_WIRE = Object.freeze({
12
12
  portalVisibility: "group membership decides portal visibility: the portal renders NAMED groups; an app in the fallback group (code === 'all', case-insensitive) or with an unresolvable groupId is flagged portalHidden:true; move it with app.update {code, groupId}",
13
13
  fingerprint: "canonical environment fingerprint (environment, origin, application, enterprise) from the authenticated session; also returns version evidence (detectedVersion/inAnchorFamily/versionSource) shared with discover_environment and doctor",
14
14
  versionEvidence: "detectedVersion + inAnchorFamily + versionSource(=system-config) + versionFamily/anchorVersion [+ versionNotice outside the anchor family]; same face on discover_environment, environment.fingerprint, and doctor",
15
+ platformVersion: "r86(retro issue 17)platform 块:license/info(8.6 族 LicenseInfo.systemVersion;@RequireAdmin,声明字段 buildTime 从未赋值) → public/system-config systemVersion 原串(1.1.x 不挂载 license/info,真机 1.1.25 未认证 401/管理员 404)→ token-cache detectedVersion → versionUnavailable;扩展 build sha 无端点暴露(extensionBuildShaUnavailable);失败不进 readiness blockers、绝不造版本",
15
16
  });
16
17
  export const ENVIRONMENT_LANE_CONTRACT = Object.freeze({
17
18
  lane: LANES.environment,
@@ -22,6 +23,7 @@ export const ENVIRONMENT_LANE_CONTRACT = Object.freeze({
22
23
  applicationGroupList: "applicationGroupList",
23
24
  applicationTree: "applicationTree",
24
25
  modelList: "modelList",
26
+ licenseInfo: "licenseInfo",
25
27
  }),
26
28
  wire: Object.freeze({
27
29
  discoveryReads: ENVIRONMENT_WIRE.discoveryReads,
@@ -30,6 +32,7 @@ export const ENVIRONMENT_LANE_CONTRACT = Object.freeze({
30
32
  portalVisibility: ENVIRONMENT_WIRE.portalVisibility,
31
33
  fingerprint: ENVIRONMENT_WIRE.fingerprint,
32
34
  versionEvidence: ENVIRONMENT_WIRE.versionEvidence,
35
+ platformVersion: ENVIRONMENT_WIRE.platformVersion,
33
36
  }),
34
37
  wireBindings: Object.freeze({
35
38
  discoveryReads: Object.freeze([behaviorBinding("test/discovery-group-visibility.test.ts#discover_environment exposes group membership and flags fallback-group apps", assertEnvironmentContract)]),
@@ -38,6 +41,7 @@ export const ENVIRONMENT_LANE_CONTRACT = Object.freeze({
38
41
  portalVisibility: Object.freeze([behaviorBinding("test/discovery-group-visibility.test.ts#discover_environment fails closed: an unresolvable groupId is portalHidden", assertEnvironmentContract)]),
39
42
  fingerprint: Object.freeze([behaviorBinding("test/lane-contracts.test.ts#environment lane contract pins the discovery/fingerprint wire", assertEnvironmentContract)]),
40
43
  versionEvidence: Object.freeze([behaviorBinding("test/friction-r30f-version-evidence.test.ts#discover_environment and environment.fingerprint return shared version evidence", assertEnvironmentContract)]),
44
+ platformVersion: Object.freeze([behaviorBinding("test/r86-environment-platform-version.test.ts#discover_environment surfaces the platform version block (license/info → system/config → unavailable)", assertEnvironmentContract)]),
41
45
  }),
42
46
  evidence: Object.freeze([
43
47
  "src/dbsweep.ts",
@@ -76,6 +80,10 @@ export function assertEnvironmentContract() {
76
80
  throw new Error("environment contract must pin the fingerprint fields");
77
81
  if (!ENVIRONMENT_WIRE.versionEvidence.includes("detectedVersion"))
78
82
  throw new Error("environment contract must pin shared version evidence");
83
+ if (!ENVIRONMENT_WIRE.platformVersion.includes("platform"))
84
+ throw new Error("environment contract must pin the r86 platform version block face");
85
+ if (!ENVIRONMENT_WIRE.platformVersion.includes("license/info"))
86
+ throw new Error("environment contract must pin the license/info version source and its product-line absence");
79
87
  if (!ENVIRONMENT_WIRE.fingerprint.includes("detectedVersion"))
80
88
  throw new Error("environment fingerprint contract must mention version evidence");
81
89
  }
@@ -22,6 +22,69 @@ function versionEvidenceFor(ctx, session) {
22
22
  ...(notice ? { versionNotice: notice } : {}),
23
23
  });
24
24
  }
25
+ /**
26
+ * r86(retro issue 17)——环境版本面 `platform` 块。数据源优先级(真机 1.1.25 +
27
+ * 8.6.26 反编译实证):
28
+ * 1. GET /api/license/info(LicenseController.info → LicenseInfo{systemVersion,
29
+ * licenseType, expiration})——8.6 族「关于」页数据源,@RequireAdmin,+1 wire;
30
+ * 声明字段 buildTime 在该控制器里从不赋值(LicenseController.java:92-119),
31
+ * 所以只有平台真回 buildTime 时才带;
32
+ * 2. 回落 public/system/config 的 systemVersion **原串**(登录时已取,零新增 wire;
33
+ * detectVersion 只留点号数字段,这里保留 "AI-Platform-v1.1.25" 全串);
34
+ * 3. 都没有 → versionUnavailable(如实说明原因,绝不造版本)。
35
+ * 1.1.x(AI-Platform)不挂载 license/info(真机 1.1.25:未认证 401、管理员 404)——
36
+ * 产品线差异如实进 licenseFaceUnavailable,不阻塞就绪判定。
37
+ * 扩展/前端构件的 build sha 没有任何端点暴露 → extensionBuildShaUnavailable 如实
38
+ * 说明,不用端点存在性反推。
39
+ */
40
+ const EXTENSION_SHA_UNAVAILABLE = "平台没有暴露扩展/前端构件 build sha 的端点(8.6.26 与 1.1.25 反编译 + 真机均无);版本判断只能用 productVersion";
41
+ async function platformVersionBlock(session) {
42
+ try {
43
+ const license = (await wireCall(session, { path: ENDPOINTS.licenseInfo })).data;
44
+ const productVersion = license && typeof license.systemVersion === "string" && license.systemVersion.trim() ? license.systemVersion.trim() : undefined;
45
+ if (productVersion !== undefined)
46
+ return {
47
+ productVersion,
48
+ ...(typeof license.buildTime === "string" && license.buildTime ? { buildTime: license.buildTime } : {}),
49
+ ...(license.licenseType !== undefined && license.licenseType !== null ? { licenseType: license.licenseType } : {}),
50
+ ...(typeof license.expiration === "string" && license.expiration ? { licenseExpiration: license.expiration } : {}),
51
+ source: "license/info",
52
+ extensionBuildShaUnavailable: EXTENSION_SHA_UNAVAILABLE,
53
+ };
54
+ }
55
+ catch {
56
+ // fall through to the system/config face — the license face is 8.6-only
57
+ }
58
+ const raw = session.rawSystemVersion();
59
+ if (raw !== undefined)
60
+ return {
61
+ productVersion: raw,
62
+ source: "public/system-config systemVersion",
63
+ licenseFaceUnavailable: "license/info 不可达(真机 1.1.25:未认证 401、管理员会话 404——该产品线不挂载);buildTime 只在平台回传时才有",
64
+ extensionBuildShaUnavailable: EXTENSION_SHA_UNAVAILABLE,
65
+ };
66
+ // 登录缓存沿用(老缓存只存了点号版本、没有原串):用 detectedVersion 兜底——
67
+ // 它是真实版本证据,只是缺产品线前缀,不能因为缺前缀就说「无版本」。
68
+ const detected = session.detectedVersion();
69
+ if (detected !== undefined)
70
+ return {
71
+ productVersion: detected,
72
+ source: "token-cache detectedVersion(原串缺失:登录缓存早于 rawVersion 字段;refresh:true 重登可取回原串)",
73
+ licenseFaceUnavailable: "license/info 不可达(该产品线不挂载);buildTime 只在平台回传时才有",
74
+ extensionBuildShaUnavailable: EXTENSION_SHA_UNAVAILABLE,
75
+ };
76
+ return { versionUnavailable: "license/info 不可达且 public/system/config 未携带版本键——本环境无法给出 productVersion,勿据端点存在性反推版本" };
77
+ }
78
+ /** Zero-wire variant for the project-card cache hit (keeps the key set stable). */
79
+ function platformVersionBlockFromSession(session) {
80
+ const cached = session.rawSystemVersion();
81
+ if (cached !== undefined)
82
+ return { productVersion: cached, source: "public/system-config systemVersion", extensionBuildShaUnavailable: EXTENSION_SHA_UNAVAILABLE };
83
+ const detected = session.detectedVersion();
84
+ if (detected !== undefined)
85
+ return { productVersion: detected, source: "token-cache detectedVersion(缓存命中面零 wire)", extensionBuildShaUnavailable: EXTENSION_SHA_UNAVAILABLE };
86
+ return { versionUnavailable: "缓存命中面零 wire:license/info 未查,登录缓存也没有版本证据(refresh:true 重查)" };
87
+ }
25
88
  export function registerEnvironmentLane(tools) {
26
89
  tools.push(defineTool({
27
90
  name: "discover_environment",
@@ -58,11 +121,15 @@ export function registerEnvironmentLane(tools) {
58
121
  const perAppCached = cachedExtra.modelsPerApplication;
59
122
  const resolution = cached.applicationResolution;
60
123
  const versionEvidence = versionEvidenceFor(ctx, session);
124
+ // r86(retro issue 17):缓存命中零 wire——platform 块优先用卡里存的
125
+ // (冷路径写入),老卡没有时退 session 原串,键集恒定。
126
+ const platformCached = cachedExtra.platform;
61
127
  return {
62
128
  status: "ok",
63
129
  // r53 场景03 F2:缓存命中与冷路径同面给出 baseUrl(非密)。
64
130
  baseUrl: session.profile.baseUrl,
65
131
  baseUrlHint: "非密运行参数(环境配置的 baseUrl)。拼平台端点用它 + 路径;鉴权凭据不在此面。",
132
+ ...(platformCached !== undefined ? { platform: platformCached } : { platform: platformVersionBlockFromSession(session) }),
66
133
  applications: apps,
67
134
  applicationsCount: apps.length,
68
135
  groups,
@@ -237,6 +304,10 @@ export function registerEnvironmentLane(tools) {
237
304
  tenantModelsCount,
238
305
  modelsPerApplication,
239
306
  };
307
+ // r86(retro issue 17):冷路径 +1 wire 读 license/info(8.6 族版本/构建时
308
+ // 间面;1.1.x 404 回落 system/config 原串)——失败不进 readiness blockers,
309
+ // 且先于项目卡写入(卡里存一份,缓存命中零 wire 同键回放)。
310
+ const platform = await platformVersionBlock(session);
240
311
  // 项目卡写入(软失败):默认形态(无收窄参数)时缓存模型清单,下次会话一次本地读。
241
312
  if (args.applicationCode === undefined && args.modelCode === undefined && args.full !== true) {
242
313
  const envName = String(args.environment ?? session.environmentName ?? "");
@@ -256,12 +327,14 @@ export function registerEnvironmentLane(tools) {
256
327
  // ProjectCard 未声明扩展键;JSON 落盘后由上方 cache 归一读回。
257
328
  tenantModelsCount,
258
329
  modelsPerApplication,
330
+ platform,
259
331
  });
260
332
  }
261
333
  }
262
334
  const versionEvidence = versionEvidenceFor(ctx, session);
263
335
  return {
264
336
  ...discovered,
337
+ platform,
265
338
  // r53 场景03 F2:agent 要拼「端点 = baseUrl + path」(比如外部 invoke 面)时
266
339
  // 只能伸手进凭据目录附近自制过滤读取。baseUrl 是非密运行参数,在这里给掉。
267
340
  baseUrl: session.profile.baseUrl,
@@ -74,6 +74,8 @@ export const RUNTIME_DATA_LANE_CONTRACT = Object.freeze({
74
74
  queryConditionShape: RUNTIME_DATA_WIRE.queryConditionShape,
75
75
  dslShape: RUNTIME_DATA_WIRE.dslShape,
76
76
  queryBodyCanon: RUNTIME_DATA_WIRE.queryBodyCanon,
77
+ subtableFilterFace: RUNTIME_DATA_WIRE.subtableFilterFace,
78
+ queryOrdersFace: RUNTIME_DATA_WIRE.queryOrdersFace,
77
79
  typeCastErrcode: RUNTIME_DATA_WIRE.typeCastErrcode,
78
80
  emptyModelErrcode: RUNTIME_DATA_WIRE.emptyModelErrcode,
79
81
  absenceErrcode: RUNTIME_DATA_WIRE.absenceErrcode,
@@ -95,6 +97,8 @@ export const RUNTIME_DATA_LANE_CONTRACT = Object.freeze({
95
97
  queryConditionShape: Object.freeze([emitterBinding("data-list-filter.toQueryCondition", assertRuntimeDataContract)]),
96
98
  dslShape: Object.freeze([emitterBinding("data-list-filter.SIMPLE_OP_MAP", assertRuntimeDataContract)]),
97
99
  queryBodyCanon: Object.freeze([behaviorBinding("test/data-list.test.ts#data.list translates simplified filters", assertRuntimeDataContract)]),
100
+ subtableFilterFace: Object.freeze([behaviorBinding("test/r86-data-list-subtable.test.ts#data.list refuses a DSL filter on a subtable schema before the wire and maps the rawCondition 50000", assertRuntimeDataContract)]),
101
+ queryOrdersFace: Object.freeze([behaviorBinding("test/r86-data-list-order.test.ts#data.list orderBy maps to wire orders and validates the orderable face", assertRuntimeDataContract)]),
98
102
  typeCastErrcode: Object.freeze([emitterBinding("data-list-filter.injectPropertyTypes", assertRuntimeDataContract)]),
99
103
  emptyModelErrcode: Object.freeze([emitterBinding("omc-core/wire-facts.RUNTIME_DATA_WIRE", assertRuntimeDataContract)]),
100
104
  absenceErrcode: Object.freeze([emitterBinding("omc-core/wire-facts.RUNTIME_DATA_WIRE", assertRuntimeDataContract)]),
@@ -163,6 +167,10 @@ export function assertRuntimeDataContract() {
163
167
  throw new Error("runtime-data contract pins the create-only workflow start duplicate errcode to 40000");
164
168
  if (!RUNTIME_DATA_WIRE.queryConditionShape.includes("level 3 AND across leaves"))
165
169
  throw new Error("runtime-data contract must pin the three-layer queryCondition shape");
170
+ if (!RUNTIME_DATA_WIRE.subtableFilterFace.includes("unsupported-filter-on-subtable"))
171
+ throw new Error("runtime-data contract must pin the r86 subtable filter refusal face");
172
+ if (!RUNTIME_DATA_WIRE.queryOrdersFace.includes("orders") || !RUNTIME_DATA_WIRE.queryOrdersFace.includes("createdTime"))
173
+ throw new Error("runtime-data contract must pin the r86 server-side orders face");
166
174
  if (!RUNTIME_DATA_WIRE.dslShape.includes("or>and"))
167
175
  throw new Error("runtime-data contract must pin the or>and>leaf DSL shape");
168
176
  if (!RUNTIME_DATA_WIRE.queryBodyCanon.includes("queryVersion:1") || !RUNTIME_DATA_WIRE.queryBodyCanon.includes("queryCode=schemaCode"))