omp-config-crypt 0.9.7 → 0.9.8
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/README.md +8 -6
- package/bin/omp-sync.js +1 -0
- package/index.js +7 -1
- package/package.json +1 -1
- package/src/role-healer.js +33 -21
package/README.md
CHANGED
|
@@ -114,12 +114,14 @@ same checks standalone; exit code 1 when any check fails.
|
|
|
114
114
|
|
|
115
115
|
After a successful (non-dry-run) pull, every chat-model reference in the restored
|
|
116
116
|
`config.yml` (top-level `modelRoles` and `modelPresets.*.modelRoles`) is probed with one
|
|
117
|
-
short verified generation. Unavailable references
|
|
118
|
-
verified replacement candidates from the configured
|
|
119
|
-
failed model itself excluded
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
117
|
+
short verified generation. Unavailable references are grouped by model: ONE dialog per
|
|
118
|
+
distinct unavailable model offers verified replacement candidates from the configured
|
|
119
|
+
providers (same provider first, the failed model itself excluded), and the chosen
|
|
120
|
+
replacement is applied to EVERY reference of that model in one pass (`:thinking`
|
|
121
|
+
suffixes preserved per reference). Selecting a candidate re-verifies it once, then
|
|
122
|
+
rewrites all affected roles; `保留不改`/Esc keeps the original and the refs are reported
|
|
123
|
+
as skipped. `web/*` roles are never probed. Headless hosts skip the flow with a summary
|
|
124
|
+
notification.
|
|
123
125
|
|
|
124
126
|
### Provider control menu
|
|
125
127
|
|
package/bin/omp-sync.js
CHANGED
package/index.js
CHANGED
|
@@ -1266,8 +1266,14 @@ export default function (pi) {
|
|
|
1266
1266
|
try {
|
|
1267
1267
|
const heal = await runPullModelHeal(ctx, { root: configRoot(), notify: (msg, type) => ctx.ui.notify(msg, type) });
|
|
1268
1268
|
if (heal && heal.applied.length > 0) {
|
|
1269
|
+
const byFrom = new Map();
|
|
1270
|
+
for (const a of heal.applied) {
|
|
1271
|
+
const groupKey = a.from.replace(/:[a-z]+$/, "");
|
|
1272
|
+
if (!byFrom.has(groupKey)) byFrom.set(groupKey, { to: a.to.replace(/:[a-z]+$/, ""), count: 0 });
|
|
1273
|
+
byFrom.get(groupKey).count++;
|
|
1274
|
+
}
|
|
1269
1275
|
ctx.ui.notify(
|
|
1270
|
-
"[pull] 模型替换:\n" +
|
|
1276
|
+
"[pull] 模型替换:\n" + [...byFrom.entries()].map(([from, g]) => ` ${from} -> ${g.to} (${g.count} 处)`).join("\n") +
|
|
1271
1277
|
"\nrestart omp 生效",
|
|
1272
1278
|
"info",
|
|
1273
1279
|
);
|
package/package.json
CHANGED
package/src/role-healer.js
CHANGED
|
@@ -172,10 +172,12 @@ export async function findWorkingReplacement({ candidates, signal }) {
|
|
|
172
172
|
}
|
|
173
173
|
|
|
174
174
|
/**
|
|
175
|
-
*
|
|
176
|
-
*
|
|
177
|
-
*
|
|
178
|
-
* (
|
|
175
|
+
* Unified interactive repair flow over the checked refs. Groups failures by
|
|
176
|
+
* provider/model: ONE dialog per distinct unavailable model, and the chosen
|
|
177
|
+
* replacement is applied to EVERY reference of that model in one pass
|
|
178
|
+
* (identical thinking suffixes share the decision).
|
|
179
|
+
* Returns applied rewrites [{ pointer, role, from, to }] and skipped refs;
|
|
180
|
+
* never throws on user abort.
|
|
179
181
|
*/
|
|
180
182
|
export async function healModelRefs({ ctx, checked, providers, configPath }) {
|
|
181
183
|
const applied = [];
|
|
@@ -183,56 +185,66 @@ export async function healModelRefs({ ctx, checked, providers, configPath }) {
|
|
|
183
185
|
const failures = checked.filter((r) => !r.ok);
|
|
184
186
|
if (failures.length === 0) return { applied, skipped };
|
|
185
187
|
|
|
188
|
+
// Group by distinct unavailable provider/model (thinking suffix is preserved
|
|
189
|
+
// per-ref at rewrite time, so grouping key is bare provider/model).
|
|
190
|
+
const groups = new Map();
|
|
191
|
+
for (const failed of failures) {
|
|
192
|
+
const key = `${failed.provider}/${failed.model}`;
|
|
193
|
+
if (!groups.has(key)) groups.set(key, { key, failed, refs: [] });
|
|
194
|
+
groups.get(key).refs.push(failed);
|
|
195
|
+
}
|
|
196
|
+
|
|
186
197
|
ctx.ui.notify(
|
|
187
|
-
`[pull] 发现 ${failures.length}
|
|
198
|
+
`[pull] 发现 ${groups.size} 个不可用模型(${failures.length} 处引用),每个模型统一选择一次替代(每个候选 1 次短生成请求,可能产生费用;Esc 可跳过)`,
|
|
188
199
|
"info",
|
|
189
200
|
);
|
|
190
201
|
|
|
191
202
|
const text = fs.readFileSync(configPath, "utf8");
|
|
192
203
|
let updated = text;
|
|
193
204
|
|
|
194
|
-
for (const failed of
|
|
205
|
+
for (const { key, failed, refs } of groups.values()) {
|
|
195
206
|
const candidates = replacementCandidates({ failedRef: failed, providers });
|
|
196
207
|
if (candidates.length === 0) {
|
|
197
|
-
skipped.push({ ...
|
|
208
|
+
for (const ref of refs) skipped.push({ ...ref, reason: "no replacement candidates configured" });
|
|
198
209
|
continue;
|
|
199
210
|
}
|
|
200
211
|
|
|
212
|
+
const locations = [...new Set(refs.map((r) => r.pointer))].join(", ");
|
|
201
213
|
const choice = await ctx.ui.select(
|
|
202
|
-
`模型不可用: ${
|
|
214
|
+
`模型不可用: ${key} (${failed.error}) · ${refs.length} 处引用 [${locations}]`,
|
|
203
215
|
["保留不改", ...candidates.map((c) => c.key)],
|
|
204
|
-
{ outline: true, helpText: "↑↓ 选择 · Enter 确认 · Esc 保留原值" },
|
|
216
|
+
{ outline: true, helpText: "↑↓ 选择 · Enter 确认 · Esc 保留原值 · 所选替代应用到全部引用" },
|
|
205
217
|
);
|
|
206
218
|
|
|
207
219
|
if (!choice || choice === "保留不改") {
|
|
208
|
-
skipped.push({ ...
|
|
220
|
+
for (const ref of refs) skipped.push({ ...ref, reason: "user kept original" });
|
|
209
221
|
continue;
|
|
210
222
|
}
|
|
211
223
|
|
|
212
224
|
const chosen = candidates.find((c) => c.key === choice);
|
|
213
225
|
if (!chosen) {
|
|
214
|
-
skipped.push({ ...
|
|
226
|
+
for (const ref of refs) skipped.push({ ...ref, reason: `unknown selection: ${choice}` });
|
|
215
227
|
continue;
|
|
216
228
|
}
|
|
217
229
|
|
|
218
|
-
// Verify the chosen candidate before rewriting (1 short generation).
|
|
230
|
+
// Verify the chosen candidate once before rewriting (1 short generation).
|
|
219
231
|
const { results } = await testModelCandidates({
|
|
220
232
|
name: chosen.provider,
|
|
221
|
-
config: {
|
|
222
|
-
baseUrl: chosen.baseUrl,
|
|
223
|
-
api: chosen.api,
|
|
224
|
-
apiKey: chosen.apiKey,
|
|
225
|
-
},
|
|
233
|
+
config: { baseUrl: chosen.baseUrl, api: chosen.api, apiKey: chosen.apiKey },
|
|
226
234
|
ids: [chosen.model],
|
|
227
235
|
});
|
|
228
236
|
if (!results.some((r) => r.ok)) {
|
|
229
|
-
|
|
237
|
+
const detail = `selected ${chosen.key} failed verification: ${results[0]?.error || "unknown"}`;
|
|
238
|
+
for (const ref of refs) skipped.push({ ...ref, reason: detail });
|
|
230
239
|
continue;
|
|
231
240
|
}
|
|
232
241
|
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
242
|
+
// Apply to every reference of this model; group applied by target for summary.
|
|
243
|
+
for (const ref of refs) {
|
|
244
|
+
const nextRef = chosen.key + (ref.thinking ? `:${ref.thinking}` : "");
|
|
245
|
+
updated = applyPointerRef(updated, ref.pointer, nextRef);
|
|
246
|
+
applied.push({ pointer: ref.pointer, role: ref.role, from: ref.ref, to: nextRef });
|
|
247
|
+
}
|
|
236
248
|
}
|
|
237
249
|
|
|
238
250
|
if (applied.length > 0) {
|