@stalfh233/omc-cli 0.8.32 → 0.8.33

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.
Files changed (49) hide show
  1. package/dist/arg-vocabulary.js +223 -0
  2. package/dist/artifact-cmd.js +443 -0
  3. package/dist/batch-call.js +56 -3
  4. package/dist/call-command.js +70 -0
  5. package/dist/call-execute.js +228 -0
  6. package/dist/call-input.js +557 -0
  7. package/dist/call-output.js +240 -0
  8. package/dist/cli.js +13 -1359
  9. package/dist/command-transport.js +4 -1
  10. package/dist/form-support.js +14 -3
  11. package/dist/intent/plan-apply.js +14 -24
  12. package/dist/lanes/datarule.js +21 -0
  13. package/dist/lanes/field.js +31 -0
  14. package/dist/lanes/list-view-shapes.js +8 -1
  15. package/dist/lanes/list-view.js +64 -2
  16. package/dist/lanes/runtime-data/aggregate-support.js +209 -0
  17. package/dist/lanes/runtime-data/aggregate.js +679 -0
  18. package/dist/lanes/runtime-data/field-options.js +52 -0
  19. package/dist/lanes/runtime-data/lane.js +4 -0
  20. package/dist/lanes/runtime-data/record-delete.js +419 -0
  21. package/dist/lanes/runtime-data/record-read.js +984 -0
  22. package/dist/lanes/runtime-data/record-write.js +562 -0
  23. package/dist/lanes/runtime-data/registration.js +22 -0
  24. package/dist/lanes/runtime-data/shapes.js +594 -0
  25. package/dist/lanes/runtime-data/submission.js +1293 -0
  26. package/dist/lanes/runtime-data/write-support.js +875 -0
  27. package/dist/lanes/runtime-data.js +10 -5590
  28. package/dist/lanes/workflow/approval-ops.js +983 -0
  29. package/dist/lanes/workflow/instance-read.js +284 -0
  30. package/dist/lanes/workflow/lifecycle-write.js +1499 -0
  31. package/dist/lanes/workflow/permissions.js +571 -0
  32. package/dist/lanes/workflow/recovery.js +361 -0
  33. package/dist/lanes/workflow/registration.js +14 -0
  34. package/dist/lanes/workflow/shapes.js +811 -0
  35. package/dist/lanes/workflow/template-fetch.js +197 -0
  36. package/dist/lanes/workflow/template-merge.js +1351 -0
  37. package/dist/lanes/workflow/template-read.js +327 -0
  38. package/dist/lanes/workflow.js +11 -6312
  39. package/dist/read-projection.js +442 -0
  40. package/dist/read.js +40 -335
  41. package/dist/rollback.js +17 -23
  42. package/dist/runtime-support.js +1 -1
  43. package/dist/verification.js +39 -0
  44. package/dist/write-coordinator.js +152 -0
  45. package/dist/write-outcome.js +295 -0
  46. package/dist/write.js +34 -115
  47. package/package.json +3 -3
  48. package/skills/omc-refusals.md +1 -1
  49. package/skills/omc-start-here.md +2 -2
@@ -0,0 +1,223 @@
1
+ /**
2
+ * 参数词汇表(canonical + alias 注册表)。
3
+ *
4
+ * 反复出现的探针摩擦是**同一件事有多个名字**:`operator`/`op`、`code`/`roleCode`、
5
+ * `pageSize`/`size`、`applicationCode`/`appCode`、枚举大小写(`desc`/`Desc`)。
6
+ * 每次摩擦都只值一轮重试,但这一轮在长任务里反复出现。这里把「同一个概念的
7
+ * 规范名 + 同义输入 + 值归一」收成一份可查表的数据,而不是继续把 if 分支散落在
8
+ * `call-input.ts` 与各 lane。
9
+ *
10
+ * 三条硬约束(写在这里,改注册表前先读):
11
+ *
12
+ * 1. **不跨 scope 静默转换**。别名只在该工具的 schema **同时**满足
13
+ * 「有 canonical 键」且「没有 alias 键」时换算——即调用方明显是按别的面
14
+ * 的键名写的。典型反例:`workflow.list` 的 `schemaCode` 是**客户端过滤**
15
+ * (该工具没有应用范围参数),把任何键映射成 `applicationCode` 都会改掉
16
+ * 真实查询语义,所以注册表里根本没有这等条目,解析器也不会凭相似度猜。
17
+ * 2. **规范键与别名同给且值不同 → 拒绝**(`read-arg-alias-conflict`),
18
+ * 绝不静默覆盖调用方显式给的规范键。
19
+ * 3. **只收已在用的别名**。新概念的准入条件是「真机探针里有误用证据」,
20
+ * 不是「听起来像同义词」。应用范围键那一条是**例外**:它在 schema 里
21
+ * 成对声明时由工具自己解析(folder.* 的 `app-code-conflict`),只在一边
22
+ * 声明时由写前硬门 `unknown-app-scope-arg` 拥有——所以这里登记为
23
+ * 「文档对」(`convertUndeclaredAlias: false`),只提供概念与提示,
24
+ * 不做换算(换算会推翻 r27/r29 的写错应用保护)。
25
+ */
26
+ /**
27
+ * 第一版注册表:**只收已在用**的别名(依据见每条注释)。
28
+ *
29
+ * `APPLIED` 键名沿用既有约定:顶层别名用别名本身(`pageSize`),条款内别名
30
+ * 用 `<路径>.operator`(`filter.operator` / `filters[0].operator`)。
31
+ */
32
+ export const ARG_CONCEPTS = Object.freeze([
33
+ {
34
+ // 应用范围键:folder.* 同时声明两个(lane 内解析,冲突报 app-code-conflict),
35
+ // 其余工具只有一个——此时由 call-input 的写前硬门拒绝,不在这里换算。
36
+ id: "app.scope",
37
+ canonical: "applicationCode",
38
+ aliases: Object.freeze(["appCode", "application"]),
39
+ convertUndeclaredAlias: false,
40
+ },
41
+ {
42
+ // 探针 V F2(0.8.30):`operator` 是 `op` 的同义别名,出现在 filter 条款里
43
+ // (CloudPivot 习惯键)。只对声明了 filter/filters 的工具生效。
44
+ id: "filter.operator",
45
+ canonical: "op",
46
+ aliases: Object.freeze(["operator"]),
47
+ clauseRoots: Object.freeze(["filter", "filters", "filterGroup"]),
48
+ },
49
+ {
50
+ // C1(0.8.4):`pageSize` 与分页工具的 `size`(每页条数)是同一件事。
51
+ // 平台依据:QueryRuntimeController 把 size 落到 PageableImpl(page*size, size);
52
+ // 前端列表页也是 `size:this.pageSize`。
53
+ id: "pagination.size",
54
+ canonical: "size",
55
+ aliases: Object.freeze(["pageSize"]),
56
+ valueKind: "number",
57
+ },
58
+ {
59
+ // 探针 R F2(0.8.26):org.role.list 的行把角色主键叫 `id`,org.role.users
60
+ // 只收 roleId(同一行的角色)。
61
+ id: "org.role.id",
62
+ canonical: "roleId",
63
+ aliases: Object.freeze(["id"]),
64
+ tools: Object.freeze(["org.role.users"]),
65
+ valueKind: "non-empty-string",
66
+ appliedNote: "org.role.list 的 id",
67
+ },
68
+ {
69
+ // 探针 S F1(0.8.27):同一行的角色码叫 `code`,role.users 只收 roleCode。
70
+ id: "org.role.code",
71
+ canonical: "roleCode",
72
+ aliases: Object.freeze(["code"]),
73
+ tools: Object.freeze(["org.role.users"]),
74
+ valueKind: "non-empty-string",
75
+ appliedNote: "org.role.list 的 code",
76
+ },
77
+ {
78
+ // 探针 T3 / 0.8.x:`sorts[].direction` 的合法值是 ASC|DESC,调用方按别的面
79
+ // 习惯写 `desc`/`Desc`。归一在 zod 层(list-view-shapes 的 directionArg),
80
+ // 不放宽枚举本身:错误信封仍列 ASC|DESC。
81
+ id: "listview.sort.direction",
82
+ canonical: "direction",
83
+ aliases: Object.freeze([]),
84
+ valueAliases: Object.freeze({ asc: "ASC", desc: "DESC" }),
85
+ normalizeCase: "upper",
86
+ },
87
+ ]);
88
+ const CONCEPT_BY_ID = new Map(ARG_CONCEPTS.map((concept) => [concept.id, concept]));
89
+ /** 按 id 取概念(值归一/提示用;未知 id 返回 undefined,不编造)。 */
90
+ export function findConcept(id) {
91
+ return CONCEPT_BY_ID.get(id);
92
+ }
93
+ function foldCase(value, mode) {
94
+ if (mode === "upper")
95
+ return value.toUpperCase();
96
+ if (mode === "lower")
97
+ return value.toLowerCase();
98
+ return value;
99
+ }
100
+ /**
101
+ * 值归一:精确命中 `valueAliases` → 大小写不敏感命中 → 大小写折叠。
102
+ * 非字符串原样返回(交给 schema 校验)。未知概念同样原样返回。
103
+ */
104
+ export function normalizeConceptValue(conceptId, value) {
105
+ if (typeof value !== "string")
106
+ return value;
107
+ const concept = findConcept(conceptId);
108
+ if (concept === undefined)
109
+ return value;
110
+ const exact = concept.valueAliases?.[value];
111
+ if (exact !== undefined)
112
+ return exact;
113
+ if (concept.valueAliases !== undefined) {
114
+ const lower = value.toLowerCase();
115
+ const insensitive = Object.entries(concept.valueAliases).find(([key]) => key.toLowerCase() === lower);
116
+ if (insensitive !== undefined)
117
+ return insensitive[1];
118
+ }
119
+ return foldCase(value, concept.normalizeCase);
120
+ }
121
+ function isPlainObject(value) {
122
+ return value !== null && typeof value === "object" && !Array.isArray(value);
123
+ }
124
+ /**
125
+ * 条款对象里的别名换算:`{operator:...}` → `{op:...}`,递归 `clauses[]`。
126
+ * 命中时把 `<路径>.operator` 记进 applied;同给且不同值 → conflict。
127
+ */
128
+ function fixClause(clause, path, concept, applied) {
129
+ if (!isPlainObject(clause))
130
+ return { value: clause };
131
+ const row = clause;
132
+ if (Array.isArray(row.clauses)) {
133
+ const fixed = row.clauses.map((entry, index) => fixClause(entry, `${path}.clauses[${index}]`, concept, applied));
134
+ const conflict = fixed.find((entry) => entry.conflict !== undefined)?.conflict;
135
+ return { value: { ...row, clauses: fixed.map((entry) => entry.value) }, ...(conflict !== undefined ? { conflict } : {}) };
136
+ }
137
+ const alias = concept.aliases.find((candidate) => row[candidate] !== undefined);
138
+ if (alias === undefined)
139
+ return { value: row };
140
+ const canonicalValue = row[concept.canonical];
141
+ // 别名与规范键同给:相同就删别名(幂等,沿用既有回执),不同就是冲突。
142
+ if (canonicalValue !== undefined && canonicalValue !== row[alias])
143
+ return { value: row, conflict: { alias, canonical: concept.canonical } };
144
+ if (canonicalValue !== undefined) {
145
+ const { [alias]: _dropped, ...rest } = row;
146
+ applied[`${path}.${alias}`] = `${concept.canonical}=${String(canonicalValue)}`;
147
+ return { value: rest };
148
+ }
149
+ const { [alias]: aliasValue, ...rest } = row;
150
+ applied[`${path}.${alias}`] = `${concept.canonical}=${String(aliasValue)}`;
151
+ return { value: { ...rest, [concept.canonical]: aliasValue } };
152
+ }
153
+ function acceptsValue(kind, value) {
154
+ if (kind === "number")
155
+ return typeof value === "number" && Number.isFinite(value);
156
+ if (kind === "non-empty-string")
157
+ return typeof value === "string" && value.trim().length > 0;
158
+ return true;
159
+ }
160
+ /**
161
+ * 解析一次调用的参数别名。
162
+ *
163
+ * `schemaKeys` 是**必须**的:别名换算只在「本工具真的收规范键」时发生,
164
+ * 没有 schema 就无法保证不跨 scope 转换(宁可少换算,也不猜)。
165
+ * 写面不调用它——写面参数静默改写会改掉真实载荷(`call-input.ts` 的既有门)。
166
+ */
167
+ export function resolveArgAliases(tool, args, schemaKeys) {
168
+ const keys = schemaKeys instanceof Set ? schemaKeys : new Set(schemaKeys);
169
+ let current = { ...args };
170
+ const applied = {};
171
+ for (const concept of ARG_CONCEPTS) {
172
+ if (concept.tools !== undefined && !concept.tools.includes(tool))
173
+ continue;
174
+ if (concept.clauseRoots !== undefined) {
175
+ // 与既有行为一致:只有当工具声明了条款根(filter/filters/filterGroup)
176
+ // 才处理条款面。W37C:注册表 `clauseRoots` 早已含 `filterGroup`,但这里
177
+ // 只认 filter/filters——只声明 `filterGroup` 的 schema 会静默跳过别名换算。
178
+ if (!keys.has("filter") && !keys.has("filters") && !keys.has("filterGroup"))
179
+ continue;
180
+ for (const root of concept.clauseRoots) {
181
+ const value = current[root];
182
+ if (value === undefined)
183
+ continue;
184
+ if (Array.isArray(value)) {
185
+ const fixed = value.map((entry, index) => fixClause(entry, `${root}[${index}]`, concept, applied));
186
+ const conflict = fixed.find((entry) => entry.conflict !== undefined)?.conflict;
187
+ if (conflict !== undefined)
188
+ return { args: current, applied, conflict };
189
+ current[root] = fixed.map((entry) => entry.value);
190
+ }
191
+ else {
192
+ // 既有行为:`filters` 只在数组形态下换算;对象形态原样留给校验。
193
+ if (root === "filters")
194
+ continue;
195
+ const fixed = fixClause(value, root, concept, applied);
196
+ if (fixed.conflict !== undefined)
197
+ return { args: current, applied, conflict: fixed.conflict };
198
+ current[root] = fixed.value;
199
+ }
200
+ }
201
+ continue;
202
+ }
203
+ // 顶层同义键:别名不在 schema(是别的面的键名)且规范键在 schema。
204
+ // alias 已是本工具合法键时,工具自己拥有该语义(如 folder.* 的 appCode)。
205
+ if (!keys.has(concept.canonical))
206
+ continue;
207
+ const alias = concept.aliases.find((candidate) => current[candidate] !== undefined && !keys.has(candidate));
208
+ if (alias === undefined)
209
+ continue;
210
+ if (concept.convertUndeclaredAlias === false)
211
+ continue;
212
+ if (current[concept.canonical] !== undefined)
213
+ return { args: current, applied, conflict: { alias, canonical: concept.canonical } };
214
+ const aliasValue = current[alias];
215
+ if (!acceptsValue(concept.valueKind, aliasValue))
216
+ continue; // 类型不符:交给正常参数校验
217
+ current[concept.canonical] = aliasValue;
218
+ delete current[alias];
219
+ applied[alias] = `${concept.canonical}=${String(aliasValue)}${concept.appliedNote !== undefined ? `(${concept.appliedNote})` : ""}`;
220
+ }
221
+ return { args: current, applied };
222
+ }
223
+ //# sourceMappingURL=arg-vocabulary.js.map