@stalfh233/omc-cli 0.7.0 → 0.8.1
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/coverage/m1-coverage-manifest-v1.json +88 -2
- package/dist/bootstrap.js +49 -0
- package/dist/call.js +23 -8
- package/dist/capability-overview.js +16 -4
- package/dist/cli.js +36 -16
- package/dist/contract-resources.js +2 -0
- package/dist/coverage-registry.js +4 -0
- package/dist/coverage.js +16 -2
- package/dist/endpoints.js +65 -0
- package/dist/environment-policy.js +15 -1
- package/dist/field-change.js +9 -2
- package/dist/field-families.js +27 -6
- package/dist/governed-execution.js +18 -12
- package/dist/human-summary.js +8 -0
- package/dist/intent/capabilities/field.js +6 -0
- package/dist/lanes/environment.js +3 -0
- package/dist/lanes/field-contract.js +117 -6
- package/dist/lanes/file-contract.js +69 -0
- package/dist/lanes/file-coverage.js +16 -0
- package/dist/lanes/file.js +257 -0
- package/dist/lanes/lane-ids.js +1 -0
- package/dist/lanes/list-view-contract.js +3 -3
- package/dist/lanes/list-view-shapes.js +56 -0
- package/dist/lanes/list-view.js +40 -5
- package/dist/lanes/meta.js +5 -4
- package/dist/lanes/model.js +8 -4
- package/dist/lanes/org-query-contract.js +62 -0
- package/dist/lanes/org-query-coverage.js +27 -0
- package/dist/lanes/org-query.js +610 -0
- package/dist/lanes/organization.js +44 -11
- package/dist/lanes/runtime-data.js +228 -59
- package/dist/lanes/workflow-contract.js +110 -1
- package/dist/lanes/workflow-coverage.js +13 -0
- package/dist/lanes/workflow.js +710 -13
- package/dist/omc-core-lazy.js +37 -1
- package/dist/package.js +3 -1
- package/dist/read-shapes.js +3 -3
- package/dist/recipes/runtime-data.js +8 -6
- package/dist/refusal-guidance.js +2 -1
- package/dist/rule-support.js +15 -17
- package/dist/session-manager.js +9 -3
- package/dist/session.js +70 -11
- package/dist/token-cache.js +5 -0
- package/dist/tool-types.js +15 -1
- package/dist/tools.js +18 -0
- package/dist/version-family-gaps.js +8 -1
- package/dist/version-partition.js +633 -0
- package/dist/wire.js +8 -2
- package/dist/write.js +11 -2
- package/package.json +3 -3
- package/skills/omc-capabilities.md +9 -2
- package/skills/omc-refusals.md +18 -0
- package/skills/omc-write-hazards.md +8 -0
package/dist/omc-core-lazy.js
CHANGED
|
@@ -1,6 +1,42 @@
|
|
|
1
1
|
let pending;
|
|
2
|
+
/** Kept non-literal so TypeScript does not try to resolve an export that the
|
|
3
|
+
* installed omc-core version may not declare yet. */
|
|
4
|
+
async function importLoose(specifier) {
|
|
5
|
+
return (await import(specifier));
|
|
6
|
+
}
|
|
7
|
+
function merge(parts) {
|
|
8
|
+
return Object.assign({}, ...parts);
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Narrow first (O5), full package last (compatibility). Every failure mode
|
|
12
|
+
* degrades to the same full index the CLI used before, so an older omc-core
|
|
13
|
+
* install never breaks.
|
|
14
|
+
*/
|
|
15
|
+
async function loadCore() {
|
|
16
|
+
// 1. Declared subpath exports (omc-core/package.json `./auth`, `./fingerprints`).
|
|
17
|
+
try {
|
|
18
|
+
return merge(await Promise.all([importLoose("omc-core/auth"), importLoose("omc-core/fingerprints")]));
|
|
19
|
+
}
|
|
20
|
+
catch {
|
|
21
|
+
// not published / installed core predates the exports — fall through.
|
|
22
|
+
}
|
|
23
|
+
// 2. The same leaf modules by file URL, bypassing the `exports` map. The
|
|
24
|
+
// package ships `dist/` in `files`, and these two leaf modules have been
|
|
25
|
+
// present since the CLI's pinned core version.
|
|
26
|
+
try {
|
|
27
|
+
const entry = import.meta.resolve("omc-core");
|
|
28
|
+
return merge(await Promise.all([
|
|
29
|
+
importLoose(new URL("cloudpivot-auth.js", entry).href),
|
|
30
|
+
importLoose(new URL("cloudpivot-fingerprints.js", entry).href),
|
|
31
|
+
]));
|
|
32
|
+
}
|
|
33
|
+
catch {
|
|
34
|
+
// 3. last resort: the full index (old behaviour).
|
|
35
|
+
}
|
|
36
|
+
return import("omc-core");
|
|
37
|
+
}
|
|
2
38
|
export function omcCore() {
|
|
3
|
-
pending ??=
|
|
39
|
+
pending ??= loadCore();
|
|
4
40
|
return pending;
|
|
5
41
|
}
|
|
6
42
|
//# sourceMappingURL=omc-core-lazy.js.map
|
package/dist/package.js
CHANGED
|
@@ -29,6 +29,8 @@ export async function executePackage(ctx, plan, coverage, args, execute) {
|
|
|
29
29
|
wouldChange: true,
|
|
30
30
|
plan: boundPlan,
|
|
31
31
|
planFingerprint: planFingerprint(boundPlan),
|
|
32
|
+
...(boundPlan.versionEvidence !== undefined ? { versionEvidence: boundPlan.versionEvidence } : {}),
|
|
33
|
+
...(boundPlan.versionNotice !== undefined ? { versionNotice: boundPlan.versionNotice } : {}),
|
|
32
34
|
...(typeof args.requestId === "string" ? { requestId: args.requestId } : {}),
|
|
33
35
|
}),
|
|
34
36
|
});
|
|
@@ -76,7 +78,7 @@ export async function executePackage(ctx, plan, coverage, args, execute) {
|
|
|
76
78
|
writeArtifact(ctx, `package-${randomUUID().slice(0, 8)}.json`, artifact);
|
|
77
79
|
// A4(r89 契约层):ruleStatus 透传(configure_rule 等套餐面)——与原子工具
|
|
78
80
|
// (write.ts)同一键、同一构造(rule-support.ts ruleStatusSegment)。
|
|
79
|
-
return { status: "ok", deliveryState: "DELIVERED", steps, readback, ...(ruleStatus !== undefined ? { ruleStatus } : {}), ...(productionConfirmed ? { productionConfirmed: true } : {}), ...(reason !== undefined ? { reason } : {}), ...(summary !== undefined ? { summary } : {}), artifactFingerprint: sha256(artifact) };
|
|
81
|
+
return { status: "ok", deliveryState: "DELIVERED", steps, readback, ...(ruleStatus !== undefined ? { ruleStatus } : {}), ...(productionConfirmed ? { productionConfirmed: true } : {}), ...(reason !== undefined ? { reason } : {}), ...(boundPlan.versionEvidence !== undefined ? { versionEvidence: boundPlan.versionEvidence } : {}), ...(boundPlan.versionNotice !== undefined ? { versionNotice: boundPlan.versionNotice } : {}), ...(summary !== undefined ? { summary } : {}), artifactFingerprint: sha256(artifact) };
|
|
80
82
|
});
|
|
81
83
|
}
|
|
82
84
|
//# sourceMappingURL=package.js.map
|
package/dist/read-shapes.js
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
const READ_SHAPES = {
|
|
13
13
|
// r28k 治理面形状钉:截断≠空表;指纹有用途;doctor/get_status 分流。
|
|
14
14
|
"discover_environment": {
|
|
15
|
-
keys: ["applications:array<{code,name,groupId?,portalHidden?}>", "applicationsCount", "groups", "groupsCount", "foldersAndModels?", "foldersAndModelsCount?", "foldersAndModelsOmitted?", "models?", "modelsCount?", "modelsOmitted?", "tablesHint?", "applicationCode", "applicationResolution", "readiness", "detectedVersion", "inAnchorFamily", "versionSource", "versionFamily", "anchorVersion", "versionNotice?", "environmentFingerprint", "fingerprintHint?", "platform:{productVersion,buildTime?,licenseType?,licenseExpiration?,source,licenseFaceUnavailable?,extensionBuildShaUnavailable?}|{versionUnavailable}", "detailArtifactId?"],
|
|
15
|
+
keys: ["applications:array<{code,name,groupId?,portalHidden?}>", "applicationsCount", "groups", "groupsCount", "foldersAndModels?", "foldersAndModelsCount?", "foldersAndModelsOmitted?", "models?", "modelsCount?", "modelsOmitted?", "tablesHint?", "applicationCode", "applicationResolution", "readiness", "detectedVersion", "inAnchorFamily", "versionSource", "versionFamily", "anchorVersion", "partition:{family,confidence,matched}", "versionNotice?", "environmentFingerprint", "fingerprintHint?", "platform:{productVersion,buildTime?,licenseType?,licenseExpiration?,source,licenseFaceUnavailable?,extensionBuildShaUnavailable?}|{versionUnavailable}", "detailArtifactId?"],
|
|
16
16
|
notes: [
|
|
17
17
|
"applications/groups 内联;foldersAndModels/models 外置时是 null + *Omitted:true(不是 [])",
|
|
18
18
|
"environmentFingerprint 用途见 fingerprintHint(写前漂移/计划绑定/读缓存键,非审批令牌)",
|
|
@@ -21,8 +21,8 @@ const READ_SHAPES = {
|
|
|
21
21
|
],
|
|
22
22
|
},
|
|
23
23
|
"environment.fingerprint": {
|
|
24
|
-
keys: ["environment", "fingerprint", "fingerprintHint", "detectedVersion", "inAnchorFamily", "versionSource", "versionFamily", "anchorVersion", "versionNotice?"],
|
|
25
|
-
notes: ["fingerprint 随 env/origin/application/enterprise 变;写前漂移/计划绑定", "版本证据与 discover/doctor
|
|
24
|
+
keys: ["environment", "fingerprint", "fingerprintHint", "detectedVersion", "inAnchorFamily", "versionSource", "versionFamily", "anchorVersion", "partition:{family,confidence,matched}", "versionNotice?"],
|
|
25
|
+
notes: ["fingerprint 随 env/origin/application/enterprise 变;写前漂移/计划绑定", "版本证据与 discover/doctor 同源;partition 是三态分区的单一真相源"],
|
|
26
26
|
},
|
|
27
27
|
"get_status": {
|
|
28
28
|
keys: ["environment", "session", "coverage", "environmentScope", "unsupportedCapabilities?", "writeLease"],
|
|
@@ -131,16 +131,18 @@ const dataDeleteSweep = Object.freeze({
|
|
|
131
131
|
title: "清空模型数据并权威验证(list 取 ids → 逐条 delete → 逐条 load 确认 absent)",
|
|
132
132
|
status: "offline-valid",
|
|
133
133
|
tool: "data.delete",
|
|
134
|
-
// 1.1.
|
|
135
|
-
//
|
|
134
|
+
// 批量删除不按版本拒绝(多版本兼容优先):1.1.25 有已知假成功(r30),
|
|
135
|
+
// 2.1.5 实测真实生效;所有版本都放行,主防线是删后逐条回读——仍能读到的 id
|
|
136
|
+
// 进 readback.batchDeleteIneffective / undeletedIds,提示改单条重试。
|
|
137
|
+
// recipe.args 给单条形状;批量可用 bizObjectIds,失败 id 用 dryRun.command 的 --args-list 重跑。
|
|
136
138
|
args: { environment, schemaCode: model, bizObjectId: "<data.list 一条 id>" },
|
|
137
139
|
preconditions: [
|
|
138
140
|
"先 data.list 取全量 ids(`all:true` 才含 DRAFT;翻页取全),清理对象按 data.list 全量",
|
|
139
141
|
"**行数以 data.list total 为准,别按「N 提交=2N 行」外推**:带流程的 submit 原地推进同一行(r28b 实测 3→3);双行只在平台另起草稿行时出现(r30 的 5→10)",
|
|
140
142
|
],
|
|
141
143
|
conditionalRequirements: [
|
|
142
|
-
"
|
|
143
|
-
"删完逐条 `data.load` 确认 `exists:false`(`absent:true` / `modelResidue.total` 递减都不是删除成功的证明);最后再 `data.list` 复验 total:0",
|
|
144
|
+
"批量 `bizObjectIds` 所有版本都放行(单次上限 200,超限分块串行),但必须看删后回读:成功判据是 `undeletedIds` 为空(`deletionVerified:true`),**不是** `remainingRows`/`clean`(整表状态,删一部分时 clean:false 正常)。出现 `undeletedIds`/`batchDeleteIneffective`(1.1.25 已知批量假成功:回执成功但行仍在)→ 对这些 id 改用单条 `bizObjectId` 重试(可 `--args-list` 一次跑多条单删)",
|
|
145
|
+
"删完逐条 `data.load` 确认 `exists:false`(`absent:true` / `modelResidue.total` 递减都不是删除成功的证明);最后再 `data.list` 复验 total:0。批量回执的 deletedCount/已删条数与 alreadyAbsentCount/本来不存在条数要能对上",
|
|
144
146
|
"id 已被删时幂等 no-op,重复清理安全",
|
|
145
147
|
],
|
|
146
148
|
priorToolReferences: [
|
|
@@ -149,7 +151,7 @@ const dataDeleteSweep = Object.freeze({
|
|
|
149
151
|
dryRun: {
|
|
150
152
|
supported: true,
|
|
151
153
|
command: `omc call data.delete --env ${environment} --args-list '[{"schemaCode":"${model}","bizObjectId":"<id1>"},{"schemaCode":"${model}","bizObjectId":"<id2>"}]'`,
|
|
152
|
-
notes: "多条用 --args-list
|
|
154
|
+
notes: "多条用 bizObjectIds(所有版本放行,单次上限 200;删后逐条回读,dry-run 回执给 estimatedWireCalls≈3N+1);若回执报 batch-delete-ineffective/undeletedIds,用 --args-list 对未删 id 逐条单删。成功判据是 undeletedIds 为空,不是 remainingRows/clean",
|
|
153
155
|
},
|
|
154
156
|
expectedReadback: {
|
|
155
157
|
readback: { deleted: true, exists: false },
|
|
@@ -159,7 +161,7 @@ const dataDeleteSweep = Object.freeze({
|
|
|
159
161
|
],
|
|
160
162
|
},
|
|
161
163
|
refusalRecovery: [
|
|
162
|
-
{ code: "
|
|
164
|
+
{ code: "batch-delete-ineffective", action: "列出 undeletedIds 改用单条 bizObjectId 重试(可 --args-list 一次跑多条单删),每条删完 data.load 确认 exists:false" },
|
|
163
165
|
{ code: "wire-business", action: "模型须已创建且有已发布字段;运行面 50000 时先 model.inspect modelPresent 判存在" },
|
|
164
166
|
],
|
|
165
167
|
requiresEnvironmentDerivedIds: false,
|
package/dist/refusal-guidance.js
CHANGED
|
@@ -119,8 +119,9 @@ const FIX_FIRST_GATES = Object.freeze({
|
|
|
119
119
|
"production-confirmation-required": "生产环境的写需要显式 confirmProduction:true——确认这次写入真的要落生产再加该参数,不要靠重试",
|
|
120
120
|
"app-not-published": "目标应用未发布:先 workflow/form/field 各面发布(或 app 级发布),再重试运行面操作",
|
|
121
121
|
"submit-workitem-not-mine": "该 workItem 不在当前登录人的待办里:用 omc call workitem.list --args '{\"status\":\"PENDING\"}' 拿**自己的** workItemId,不要用别人的 id 提交",
|
|
122
|
+
"workflow-approval-action-not-applied": "平台回了 errcode 0 + data:false——动作没生效,别当成功,也别先怀疑 workItemId。2.1.5 真机上稳定复现 data:false 的形状是「有效待办 + 非法目标节点」(rejectToActivityCode 不在 workflow.rejectActivities 的结果里),而且平台在返回 false 之前**已经取消了原待办**:先看回执 sideEffectReadback(instanceStatus / activeActivityCount)。若 instanceStatus=PROCESSING 且 activeActivityCount=0,流程已卡死(原待办没了、也没生成新待办),重试同一 action 不会恢复——按 recovery.nextCommand 先 workflow.abort 再重新发起,或 workflow.activate 激活目标节点。反过来,「已处理/已取消的 workItemId」通常不是 data:false:2.1.5 回 409018 业务错(405022 是 8.6 族历史码),先用 workflow.instanceActivity + workitem.list 核对当前状态再决定。",
|
|
122
123
|
"capability-out-of-coverage": "需求不在覆盖面内:这份拒绝就是答案——用 omc capabilities 核对运行时清单,不要换相近工具伪造实现",
|
|
123
|
-
"version-family-evidence-missing": "
|
|
124
|
+
"version-family-evidence-missing": "**已放宽为兼容模式**(2026-11-24):这个 blocker 不再产生 refuse——版本串探测不到时写入照常放行,回执带 `versionEvidence:\"absent\"` + 兼容提示,平台是最终门。见到它只说明是旧版回执:按兼容模式继续,无需为「取版本」阻塞;要拿版本证据跑 omc doctor / discover_environment(必要时 refresh 刷登录缓存)",
|
|
124
125
|
});
|
|
125
126
|
/**
|
|
126
127
|
* `tool-input-invalid` and friends: point at the refused **parameter**, not the
|
package/dist/rule-support.js
CHANGED
|
@@ -13,6 +13,7 @@ import { closestMatches } from "./closest-match.js";
|
|
|
13
13
|
import { RESERVED_CODES } from "./code-rules.js";
|
|
14
14
|
import { SYSTEM_FIELD_CODES } from "./field-families.js";
|
|
15
15
|
import { FIELD_PROPERTY_TYPES } from "./field-families.js";
|
|
16
|
+
import { CAPABILITIES, partitionVersion } from "./version-partition.js";
|
|
16
17
|
/** Business-rule node graph. Platform trigger rules are addressed by ruleCode: Create / Update / Delete / Available / Cancel / GetList / Load. */
|
|
17
18
|
export const ruleNodeGraphArg = z
|
|
18
19
|
.object({
|
|
@@ -577,24 +578,16 @@ async function assertRuleMappingFieldsPublished(session, schemaCode, nodes, opti
|
|
|
577
578
|
* 8.6, and AI-Platform 1.x uses the same modern shape (DataAssignNode in
|
|
578
579
|
* 1.1.25). OMC only writes the modern shape, so on a pre-8.6 environment it must
|
|
579
580
|
* refuse rather than send keys the target will silently misread.
|
|
581
|
+
*
|
|
582
|
+
* The gate itself lives in `CAPABILITIES[partitionVersion(version).family]
|
|
583
|
+
* .assignNodeModernShape` (version-partition.ts): preflight refusal is a matrix
|
|
584
|
+
* decision, not a bare version comparison.
|
|
580
585
|
*/
|
|
581
586
|
export function assignNodes(nodes) {
|
|
582
587
|
return nodes
|
|
583
588
|
.filter((node) => String(node.nodeType ?? "") === "ASSIGN")
|
|
584
589
|
.map((node) => String(node.nodeCode ?? "ASSIGN"));
|
|
585
590
|
}
|
|
586
|
-
export function isModernAssignVersion(version) {
|
|
587
|
-
if (version === undefined || version.trim() === "")
|
|
588
|
-
return true;
|
|
589
|
-
const match = /^(\d+)\.(\d+)/u.exec(version.trim());
|
|
590
|
-
if (!match)
|
|
591
|
-
return true;
|
|
592
|
-
const major = Number(match[1]);
|
|
593
|
-
const minor = Number(match[2]);
|
|
594
|
-
if (major >= 1 && major < 8)
|
|
595
|
-
return true;
|
|
596
|
-
return major > 8 || (major === 8 && minor >= 6);
|
|
597
|
-
}
|
|
598
591
|
/**
|
|
599
592
|
* 1.2 (r8 2026-10-22, 1.1.25): a `dataCondition` that compares a text-CHOICE field
|
|
600
593
|
* (RADIO/CHECKBOX/DROPDOWN) with a FIXED value never evaluates — the launcher
|
|
@@ -1299,21 +1292,26 @@ export async function lintRuleSaveWrite(session, args) {
|
|
|
1299
1292
|
// rule model plus two target/query models) and refuse before rule.save.
|
|
1300
1293
|
blockers.push(...(await assertRuleGraphFieldOwnership(session, args.schemaCode, Array.isArray(nodes) ? nodes : [], args.allowAdvisory === true)));
|
|
1301
1294
|
// Ticket 96: phantom-schema gate — r85 起已提前到函数首(一切规则面 wire 之前)。
|
|
1302
|
-
// ASSIGN shape is version-dependent
|
|
1295
|
+
// ASSIGN shape is version-dependent; the decision lives in the partition matrix
|
|
1296
|
+
// (version-partition.ts), not in a bare version comparison.
|
|
1303
1297
|
const assignCodes = assignNodes(nodes);
|
|
1304
1298
|
if (assignCodes.length > 0) {
|
|
1305
1299
|
const version = session.detectedVersion();
|
|
1306
|
-
|
|
1300
|
+
const partition = partitionVersion(version);
|
|
1301
|
+
const capability = CAPABILITIES[partition.family].assignNodeModernShape;
|
|
1302
|
+
if (capability.guard === "preflight-refuse") {
|
|
1307
1303
|
throw new ToolRefusalError({
|
|
1308
1304
|
status: "refused",
|
|
1309
1305
|
blocker: "rule-graph-assign-version-unsupported",
|
|
1310
1306
|
schemaCode: args.schemaCode,
|
|
1311
1307
|
ruleCode: args.ruleCode,
|
|
1312
1308
|
version: version ?? "unknown",
|
|
1309
|
+
partition: { family: partition.family, confidence: partition.confidence, matched: partition.matched },
|
|
1313
1310
|
nodes: assignCodes,
|
|
1314
|
-
message: `检测到 CloudPivot ${version ?? "未知版本"}
|
|
1315
|
-
`8.6.26 自带 BusinessRuleUpgradeServiceImpl + UpgradeRuleHandler.upgradeAssignNode 正是用来把旧图升级成 inputParam+targetObjectCode+nonMatchingAdded
|
|
1316
|
-
|
|
1311
|
+
message: `检测到 CloudPivot ${version ?? "未知版本"}(分区 ${partition.family}/${partition.confidence}):「数据赋值」在 8.6 之前是旧形状(triggerObjectCode/currentDataModel/targetSchemaModel/tableConditionGroups),` +
|
|
1312
|
+
`8.6.26 自带 BusinessRuleUpgradeServiceImpl + UpgradeRuleHandler.upgradeAssignNode 正是用来把旧图升级成 inputParam+targetObjectCode+nonMatchingAdded 的;升级器只做旧→新,没有反向降级。` +
|
|
1313
|
+
`现代形状从 8.6 起(AI-Platform 1.x 同形),OMC 只写现代形状;在旧形状环境会被静默误读。` +
|
|
1314
|
+
`${capability.diagnostic ?? ""} ` +
|
|
1317
1315
|
`请改用 UPDATE/CREATE 表达同一逻辑,或在该版本的设计器里配置 ASSIGN。`,
|
|
1318
1316
|
});
|
|
1319
1317
|
}
|
package/dist/session-manager.js
CHANGED
|
@@ -14,11 +14,13 @@ export class SessionManager {
|
|
|
14
14
|
config() {
|
|
15
15
|
return this.store;
|
|
16
16
|
}
|
|
17
|
-
async session(environment) {
|
|
17
|
+
async session(environment, options = {}) {
|
|
18
18
|
const resolved = this.store.resolveEnvironment(environment);
|
|
19
19
|
const profileKey = JSON.stringify(resolved.profile);
|
|
20
20
|
const cached = this.sessions.get(resolved.name);
|
|
21
|
-
|
|
21
|
+
// `freshLogin` must not reuse an in-memory session: its token came from the
|
|
22
|
+
// cache, so reusing it would silently skip the handshake the flag promises.
|
|
23
|
+
let session = options.freshLogin === true ? undefined : cached?.profileKey === profileKey ? cached.session : undefined;
|
|
22
24
|
if (!session) {
|
|
23
25
|
const credential = this.store.readCredential(resolved.name);
|
|
24
26
|
// F1: cross-process token cache — lives beside the credentials, keyed
|
|
@@ -29,12 +31,16 @@ export class SessionManager {
|
|
|
29
31
|
const environmentName = resolved.name;
|
|
30
32
|
const fingerprint = loginFingerprint(resolved.profile, credential);
|
|
31
33
|
session = new CloudPivotSession(resolved.name, resolved.profile, credential, this.httpFactory?.(resolved.profile), this.systemConfigFactory?.(resolved.profile), defaultRequestTimeoutMs(), {
|
|
32
|
-
|
|
34
|
+
// O7: `freshLogin` only disables the READ side; the fresh handshake
|
|
35
|
+
// still refreshes the on-disk cache for future processes.
|
|
36
|
+
load: () => (options.freshLogin === true ? undefined : cache.load(environmentName, fingerprint)),
|
|
33
37
|
save: (login) => cache.save(environmentName, fingerprint, login),
|
|
34
38
|
clear: () => cache.clear(environmentName),
|
|
35
39
|
});
|
|
36
40
|
this.sessions.set(resolved.name, { profileKey, session });
|
|
37
41
|
}
|
|
42
|
+
// O4(0.8.1 决策变更):写路径不再强制重探版本——`login()` 自己按缓存窗口
|
|
43
|
+
// 决定探不探(`OMC_VERSION_RECHECK_MS` 可调,见 session.ts)。
|
|
38
44
|
await session.login();
|
|
39
45
|
return session;
|
|
40
46
|
}
|
package/dist/session.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { omcCore } from "./omc-core-lazy.js";
|
|
2
|
+
import { partitionVersion } from "./version-partition.js";
|
|
2
3
|
/**
|
|
3
4
|
* An authenticated CloudPivot session for one named environment. Wraps the
|
|
4
5
|
* core authenticator; exposes a version-family probe used by the 8.6-only
|
|
@@ -24,6 +25,10 @@ export class CloudPivotSession {
|
|
|
24
25
|
/** r86(retro issue 17):原始版本串("AI-Platform-v1.1.25" 这类含产品线前缀的完整值)。 */
|
|
25
26
|
rawVersion;
|
|
26
27
|
versionSource;
|
|
28
|
+
/** O4:版本证据最后一次真实探测的时刻(缓存命中时从 token-cache 回读)。 */
|
|
29
|
+
versionProbedAt;
|
|
30
|
+
/** O7:本次登录是否吃到了跨进程 token 缓存(doctor 回执用)。 */
|
|
31
|
+
loginSourceValue = "fresh-login";
|
|
27
32
|
/** F7:license 载荷留作读面复用(buildTime/licenseType 只在 license/info 有)。 */
|
|
28
33
|
licenseInfoValue;
|
|
29
34
|
/**
|
|
@@ -53,6 +58,11 @@ export class CloudPivotSession {
|
|
|
53
58
|
this.fingerprintOf = core.canonicalCloudPivotEnvironmentFingerprint;
|
|
54
59
|
return this.httpAdapter;
|
|
55
60
|
}
|
|
61
|
+
/**
|
|
62
|
+
* O4(0.8.1 决策变更):版本证据按缓存窗口复用——`probeVersionEvidence` 只在
|
|
63
|
+
* 「没有版本」「非锚定族且过了复检窗口」时走 wire。写路径不再强制重探(见
|
|
64
|
+
* call.ts 的说明);要每进程必探,运维设 `OMC_VERSION_RECHECK_MS=0`。
|
|
65
|
+
*/
|
|
56
66
|
async login() {
|
|
57
67
|
if (this.loginResult)
|
|
58
68
|
return this.loginResult;
|
|
@@ -61,6 +71,7 @@ export class CloudPivotSession {
|
|
|
61
71
|
// mid-call clears the cache and re-logins (request() below).
|
|
62
72
|
const cached = this.tokenCache?.load();
|
|
63
73
|
if (cached) {
|
|
74
|
+
this.loginSourceValue = "token-cache";
|
|
64
75
|
const core = await omcCore();
|
|
65
76
|
if (!this.fingerprintOf)
|
|
66
77
|
this.fingerprintOf = core.canonicalCloudPivotEnvironmentFingerprint;
|
|
@@ -70,15 +81,17 @@ export class CloudPivotSession {
|
|
|
70
81
|
administrator: cached.administrator,
|
|
71
82
|
...(cached.accountIdentity !== undefined ? { accountIdentity: cached.accountIdentity } : {}),
|
|
72
83
|
};
|
|
73
|
-
const evidence = await this.probeVersionEvidence(cached.version, cached.rawVersion);
|
|
84
|
+
const evidence = await this.probeVersionEvidence(cached.version, cached.rawVersion, undefined, cached.versionSource, cached.probedAt);
|
|
74
85
|
this.version = evidence.version;
|
|
75
86
|
this.rawVersion = evidence.rawVersion;
|
|
76
87
|
this.versionSource = evidence.source;
|
|
88
|
+
this.versionProbedAt = evidence.probedAt;
|
|
77
89
|
// 缓存命中路径只在**拿到证据**时回写(探测失败不得凭空改写缓存)。
|
|
78
90
|
if (evidence.version !== undefined)
|
|
79
91
|
this.saveCachedLogin(this.loginResult, evidence);
|
|
80
92
|
return this.loginResult;
|
|
81
93
|
}
|
|
94
|
+
this.loginSourceValue = "fresh-login";
|
|
82
95
|
const core = await omcCore();
|
|
83
96
|
if (!this.fingerprintOf)
|
|
84
97
|
this.fingerprintOf = core.canonicalCloudPivotEnvironmentFingerprint;
|
|
@@ -99,13 +112,18 @@ export class CloudPivotSession {
|
|
|
99
112
|
...(systemConfig ? { systemConfig } : {}),
|
|
100
113
|
});
|
|
101
114
|
this.loginNotesValue = authenticator.loginNotes();
|
|
102
|
-
const evidence = await this.probeVersionEvidence(undefined, undefined, systemConfig);
|
|
115
|
+
const evidence = await this.probeVersionEvidence(undefined, undefined, systemConfig, undefined, undefined);
|
|
103
116
|
this.version = evidence.version;
|
|
104
117
|
this.rawVersion = evidence.rawVersion;
|
|
105
118
|
this.versionSource = evidence.source;
|
|
119
|
+
this.versionProbedAt = evidence.probedAt;
|
|
106
120
|
this.saveCachedLogin(this.loginResult, evidence);
|
|
107
121
|
return this.loginResult;
|
|
108
122
|
}
|
|
123
|
+
/** O7: where the token came from (`fresh-login` when the handshake ran). */
|
|
124
|
+
loginSource() {
|
|
125
|
+
return this.loginSourceValue;
|
|
126
|
+
}
|
|
109
127
|
/** Version-family evidence; absent evidence returns undefined (fail closed upstream). */
|
|
110
128
|
detectedVersion() {
|
|
111
129
|
return this.version;
|
|
@@ -121,12 +139,16 @@ export class CloudPivotSession {
|
|
|
121
139
|
licenseInfo() {
|
|
122
140
|
return this.licenseInfoValue;
|
|
123
141
|
}
|
|
124
|
-
async probeVersionEvidence(cachedVersion, cachedRawVersion, knownSystemConfig) {
|
|
125
|
-
// F7(issue 05
|
|
126
|
-
// (或本来就是 license
|
|
127
|
-
//
|
|
128
|
-
|
|
129
|
-
|
|
142
|
+
async probeVersionEvidence(cachedVersion, cachedRawVersion, knownSystemConfig, cachedSource, cachedProbedAt) {
|
|
143
|
+
// F7(issue 05)+ O4:缓存命中**不意味着**要重新探测。已有版本且属于锚定族
|
|
144
|
+
// (或本来就是 license 证据,或复检窗口内刚探过)就零 wire 直接用;只有
|
|
145
|
+
// 「没有版本」「缓存说自己不是 8.6 族且已过复检窗口」时才重探。0.8.1 起
|
|
146
|
+
// 写路径不再强制重探(版本不是写门);窗口长度由 `OMC_VERSION_RECHECK_MS`
|
|
147
|
+
// 控制——设 0 即每进程必探。族判定走 partitionVersion,不再裸比字符串。
|
|
148
|
+
// 注意这里的 source 必须来自**缓存**(旧代码读 `this.versionSource`,在
|
|
149
|
+
// 缓存命中路径上恒为 undefined,断环就断在这)。
|
|
150
|
+
if (cacheVersionSkipsReprobe(cachedVersion, cachedSource, cachedProbedAt))
|
|
151
|
+
return { version: cachedVersion, rawVersion: cachedRawVersion, source: cachedSource ?? "system-config", probedAt: cachedProbedAt };
|
|
130
152
|
let license;
|
|
131
153
|
try {
|
|
132
154
|
// license/info 是管理员端点:401/403/404 都属「该产品线没这面」,直接回退。
|
|
@@ -146,9 +168,10 @@ export class CloudPivotSession {
|
|
|
146
168
|
// license 面不可达:回退 system/config。
|
|
147
169
|
}
|
|
148
170
|
this.licenseInfoValue = license;
|
|
171
|
+
const probedAt = Date.now();
|
|
149
172
|
const licenseVersion = detectVersion(license);
|
|
150
173
|
if (licenseVersion !== undefined)
|
|
151
|
-
return { version: licenseVersion, rawVersion: detectRawVersion(license), source: "license/info" };
|
|
174
|
+
return { version: licenseVersion, rawVersion: detectRawVersion(license), source: "license/info", probedAt };
|
|
152
175
|
let systemConfig = knownSystemConfig;
|
|
153
176
|
if (!systemConfig) {
|
|
154
177
|
const core = await omcCore();
|
|
@@ -158,9 +181,9 @@ export class CloudPivotSession {
|
|
|
158
181
|
}
|
|
159
182
|
const publicVersion = detectVersion(systemConfig);
|
|
160
183
|
if (publicVersion !== undefined)
|
|
161
|
-
return { version: publicVersion, rawVersion: detectRawVersion(systemConfig), source: "system-config" };
|
|
184
|
+
return { version: publicVersion, rawVersion: detectRawVersion(systemConfig), source: "system-config", probedAt };
|
|
162
185
|
if (cachedVersion !== undefined)
|
|
163
|
-
return { version: cachedVersion, rawVersion: cachedRawVersion, source: "token-cache" };
|
|
186
|
+
return { version: cachedVersion, rawVersion: cachedRawVersion, source: "token-cache", probedAt };
|
|
164
187
|
return {};
|
|
165
188
|
}
|
|
166
189
|
saveCachedLogin(login, evidence) {
|
|
@@ -172,6 +195,7 @@ export class CloudPivotSession {
|
|
|
172
195
|
...(evidence.version !== undefined ? { version: evidence.version } : {}),
|
|
173
196
|
...(evidence.rawVersion !== undefined ? { rawVersion: evidence.rawVersion } : {}),
|
|
174
197
|
...(evidence.source !== undefined ? { versionSource: evidence.source } : {}),
|
|
198
|
+
...(evidence.probedAt !== undefined ? { probedAt: evidence.probedAt } : {}),
|
|
175
199
|
});
|
|
176
200
|
}
|
|
177
201
|
/** Non-fatal login caveats; empty when the login was fully nominal. */
|
|
@@ -263,6 +287,41 @@ export class CloudPivotSession {
|
|
|
263
287
|
return this.httpAdapter;
|
|
264
288
|
}
|
|
265
289
|
}
|
|
290
|
+
/**
|
|
291
|
+
* O4: how long a non-anchor version probe stays authoritative. 15 minutes by
|
|
292
|
+
* default; `OMC_VERSION_RECHECK_MS` overrides (tests / operators that need a
|
|
293
|
+
* different window). Setting it to `0` makes the window empty, so every
|
|
294
|
+
* process re-probes — the only way to force a probe now that the write path
|
|
295
|
+
* no longer does (0.8.1: version evidence is diagnostic, not a write gate).
|
|
296
|
+
*/
|
|
297
|
+
const DEFAULT_VERSION_RECHECK_MS = 15 * 60 * 1000;
|
|
298
|
+
export function versionRecheckMs(env = process.env) {
|
|
299
|
+
const raw = env.OMC_VERSION_RECHECK_MS;
|
|
300
|
+
const parsed = raw === undefined || raw.trim() === "" ? NaN : Number(raw);
|
|
301
|
+
return Number.isFinite(parsed) && parsed >= 0 ? parsed : DEFAULT_VERSION_RECHECK_MS;
|
|
302
|
+
}
|
|
303
|
+
/**
|
|
304
|
+
* F7 + O4: does cached evidence prove enough to skip the version re-probe?
|
|
305
|
+
*
|
|
306
|
+
* - `license/info` is authoritative forever;
|
|
307
|
+
* - the anchor family (8.6.x) is what the CLI is built against;
|
|
308
|
+
* - any other family is authoritative for one recheck interval (`probedAt`),
|
|
309
|
+
* so 8.7 / 8.8 / 2.1.x / 1.1.x no longer cost two HTTP requests per process.
|
|
310
|
+
*
|
|
311
|
+
* Without evidence (`cachedVersion === undefined`) the caller must probe. A
|
|
312
|
+
* legacy cache entry (version but no probedAt / no source) gets exactly one
|
|
313
|
+
* re-probe and then becomes windowed. Family classification lives in
|
|
314
|
+
* version-partition.ts.
|
|
315
|
+
*/
|
|
316
|
+
export function cacheVersionSkipsReprobe(cachedVersion, source, probedAt, recheckMs = versionRecheckMs(), now = Date.now()) {
|
|
317
|
+
if (cachedVersion === undefined)
|
|
318
|
+
return false;
|
|
319
|
+
if (source === "license/info")
|
|
320
|
+
return true;
|
|
321
|
+
if (partitionVersion(cachedVersion).family === "anchor-8.6")
|
|
322
|
+
return true;
|
|
323
|
+
return typeof probedAt === "number" && Number.isFinite(probedAt) && now - probedAt < recheckMs;
|
|
324
|
+
}
|
|
266
325
|
function detectVersion(systemConfig) {
|
|
267
326
|
if (!systemConfig)
|
|
268
327
|
return undefined;
|
package/dist/token-cache.js
CHANGED
|
@@ -40,6 +40,11 @@ export class TokenCache {
|
|
|
40
40
|
// r86(retro issue 17):白名单漏读会让 productVersion 面在产品线前缀上
|
|
41
41
|
// 永久降级(写进缓存却读不回 → 每次命中都走 detectedVersion 兜底)。
|
|
42
42
|
...(typeof parsed.rawVersion === "string" && parsed.rawVersion.trim().length > 0 ? { rawVersion: parsed.rawVersion } : {}),
|
|
43
|
+
// O4:save() 早就写了 versionSource,load() 却漏读——缓存命中的
|
|
44
|
+
// `this.versionSource` 因此恒为 undefined,非 8.6 环境每进程重探 2 个
|
|
45
|
+
// HTTP。probedAt 同理:只在窗口内才允许跳过复检。
|
|
46
|
+
...(parsed.versionSource === "license/info" || parsed.versionSource === "system-config" || parsed.versionSource === "token-cache" ? { versionSource: parsed.versionSource } : {}),
|
|
47
|
+
...(typeof parsed.probedAt === "number" && Number.isFinite(parsed.probedAt) ? { probedAt: parsed.probedAt } : {}),
|
|
43
48
|
};
|
|
44
49
|
}
|
|
45
50
|
save(environmentName, fingerprint, login) {
|
package/dist/tool-types.js
CHANGED
|
@@ -544,8 +544,22 @@ export function parseToolInput(tool, input) {
|
|
|
544
544
|
}
|
|
545
545
|
}
|
|
546
546
|
const result = z.object(tool.inputSchema).safeParse(normalized);
|
|
547
|
-
if (result.success)
|
|
547
|
+
if (result.success) {
|
|
548
|
+
// 跨字段约束(zod raw shape 表达不了):在 schema 通过后、handler 之前
|
|
549
|
+
// 拒绝,零 wire。错误信封与 zod 拒绝同形,调用方只认 blocker/issues。
|
|
550
|
+
const violation = tool.inputRefine?.(result.data);
|
|
551
|
+
if (violation !== undefined) {
|
|
552
|
+
throw new ToolInputError({
|
|
553
|
+
status: "error",
|
|
554
|
+
blocker: "tool-input-invalid",
|
|
555
|
+
tool: tool.name,
|
|
556
|
+
message: violation.message,
|
|
557
|
+
issues: [{ path: violation.path === undefined ? [] : violation.path.split("."), code: "custom", message: violation.message }],
|
|
558
|
+
...(violation.path === undefined ? {} : { nextCommand: `omc describe ${tool.name} --param ${violation.path.split(".")[0]}` }),
|
|
559
|
+
});
|
|
560
|
+
}
|
|
548
561
|
return result.data;
|
|
562
|
+
}
|
|
549
563
|
// T3(GitLab #17,2026-11-04):封闭取值此前只能靠报错试出来(`dir:"desc"`
|
|
550
564
|
// → zod 原生 "Expected 'ASC' | 'DESC'",而 filter op 的枚举又只在拒绝文案里)。
|
|
551
565
|
// 把「这个参数到底收哪些值」直接放进错误信封:zod 的 invalid_enum_value 自带
|
package/dist/tools.js
CHANGED
|
@@ -19,6 +19,7 @@ import { registerRuntimeDataLane } from "./lanes/runtime-data.js";
|
|
|
19
19
|
import { registerWorkflowLane } from "./lanes/workflow.js";
|
|
20
20
|
import { registerConfigDiffTool } from "./lanes/config-diff.js";
|
|
21
21
|
import { registerOrganizationLane } from "./lanes/organization.js";
|
|
22
|
+
import { registerOrgQueryLane } from "./lanes/org-query.js";
|
|
22
23
|
import { registerOnlineJsLane } from "./lanes/online-js.js";
|
|
23
24
|
import { registerProgrammingLane } from "./lanes/programming.js";
|
|
24
25
|
import { registerB2Lane } from "./lanes/b2-registration.js";
|
|
@@ -27,6 +28,7 @@ import { registerListViewLane } from "./lanes/list-view.js";
|
|
|
27
28
|
import { registerReportLane } from "./lanes/report.js";
|
|
28
29
|
import { registerApplyChangesLane } from "./lanes/apply-changes.js";
|
|
29
30
|
import { registerPermLane } from "./lanes/perm.js";
|
|
31
|
+
import { registerFileLane } from "./lanes/file.js";
|
|
30
32
|
import { executionMetadataFor } from "./execution-metadata.js";
|
|
31
33
|
import { attachRefusalRecovery } from "./refusal-guidance.js";
|
|
32
34
|
import { defineTool, ToolRefusalError } from "./tool-types.js";
|
|
@@ -49,7 +51,17 @@ const COMPOUND_IRREVERSIBLE = Object.freeze({
|
|
|
49
51
|
* declarations; the shared governance pipelines live in ./read.ts / ./write.ts
|
|
50
52
|
* / ./package.ts (planning in ./plan.ts, wiring in ./context.ts).
|
|
51
53
|
*/
|
|
54
|
+
/**
|
|
55
|
+
* O2: one registry per process. Building it twice cost a second ~20 ms of CPU
|
|
56
|
+
* on every `omc call` (cli.ts's argument gate + call.ts's dispatch), and the
|
|
57
|
+
* definitions are immutable after construction. The singleton keeps the exact
|
|
58
|
+
* registration order below (apply_changes still captures the fully-populated
|
|
59
|
+
* array because it is registered last).
|
|
60
|
+
*/
|
|
61
|
+
let registryCache;
|
|
52
62
|
export function buildToolRegistry() {
|
|
63
|
+
if (registryCache !== undefined)
|
|
64
|
+
return registryCache;
|
|
53
65
|
const tools = [];
|
|
54
66
|
registerMetaLane(tools);
|
|
55
67
|
registerEnvironmentLane(tools);
|
|
@@ -72,6 +84,10 @@ export function buildToolRegistry() {
|
|
|
72
84
|
// workflow.ts instead would create a module cycle.
|
|
73
85
|
registerConfigDiffTool(tools);
|
|
74
86
|
registerOrganizationLane(tools);
|
|
87
|
+
// Organization light-query read faces (searchUnits / department.search /
|
|
88
|
+
// visibleDepartments / departmentTree / users). Declared in their own coverage
|
|
89
|
+
// module so the workflow lane files (owned by a parallel change) stay untouched.
|
|
90
|
+
registerOrgQueryLane(tools);
|
|
75
91
|
registerOnlineJsLane(tools);
|
|
76
92
|
registerProgrammingLane(tools);
|
|
77
93
|
registerB2Lane(tools);
|
|
@@ -79,6 +95,7 @@ export function buildToolRegistry() {
|
|
|
79
95
|
registerListViewLane(tools);
|
|
80
96
|
registerReportLane(tools);
|
|
81
97
|
registerPermLane(tools);
|
|
98
|
+
registerFileLane(tools);
|
|
82
99
|
// LAST: apply_changes looks up sibling write tools at call time, so it must
|
|
83
100
|
// capture the fully-populated registry array.
|
|
84
101
|
registerApplyChangesLane(tools);
|
|
@@ -172,6 +189,7 @@ export function buildToolRegistry() {
|
|
|
172
189
|
}
|
|
173
190
|
};
|
|
174
191
|
}
|
|
192
|
+
registryCache = tools;
|
|
175
193
|
return tools;
|
|
176
194
|
}
|
|
177
195
|
/** Local-only requestId readback (r30a F4) — exposes findCompleted's store. */
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { partitionVersion } from "./version-partition.js";
|
|
1
2
|
/** 与版本无关的平台永久缺席面(与 `capability-absences.ts` 同源的事实,此处只投影)。 */
|
|
2
3
|
const PLATFORM_ABSENCES = [
|
|
3
4
|
{
|
|
@@ -58,8 +59,13 @@ function familyOf(version) {
|
|
|
58
59
|
* 给定检测到的版本,返回**当前环境适用**的已知缺口。
|
|
59
60
|
* `version` 为 undefined(无版本证据)时返回全部家族条目——保守方向:
|
|
60
61
|
* 调用方宁可多看到一条,也不要漏掉一个会 404 的端点。
|
|
62
|
+
*
|
|
63
|
+
* 族判定用 `partitionVersion`(version-partition.ts);FAMILY_GAPS 里的
|
|
64
|
+
* `families` 仍是 **X.Y 端点族**(8.0/8.1、1.0/1.1),因为缺口是端点级而不是
|
|
65
|
+
* 整个分区级的——分区级能力差异看 `CAPABILITIES`。
|
|
61
66
|
*/
|
|
62
67
|
export function unsupportedCapabilities(manifest, version) {
|
|
68
|
+
const partition = partitionVersion(version);
|
|
63
69
|
const family = version === undefined ? undefined : familyOf(version);
|
|
64
70
|
const applicable = FAMILY_GAPS.filter((gap) => family === undefined || gap.families === undefined || gap.families.includes(family));
|
|
65
71
|
return {
|
|
@@ -67,7 +73,8 @@ export function unsupportedCapabilities(manifest, version) {
|
|
|
67
73
|
coverageClaim: "known-gaps-only",
|
|
68
74
|
coverageClaimMeaning: KNOWN_GAPS_CLAIM_MEANING,
|
|
69
75
|
detectedVersion: version ?? null,
|
|
70
|
-
inAnchorFamily: version === undefined ? null : version.startsWith(`${manifest.version_family}.`),
|
|
76
|
+
inAnchorFamily: version === undefined ? null : partition.family === "anchor-8.6" || version.startsWith(`${manifest.version_family}.`),
|
|
77
|
+
partition: { family: partition.family, confidence: partition.confidence, matched: partition.matched },
|
|
71
78
|
// 锚点族内部无缺口时也别回空数组造成"没有限制"的错觉——platform-absent 永远在。
|
|
72
79
|
capabilities: [...applicable, ...PLATFORM_ABSENCES],
|
|
73
80
|
};
|