omp-config-crypt 0.9.2 → 0.9.4
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 +5 -0
- package/package.json +1 -1
- package/src/provider-menu.js +14 -2
- package/src/provider-models.js +13 -4
- package/src/provider-store.js +15 -4
package/README.md
CHANGED
|
@@ -123,6 +123,11 @@ checked subset, Esc returns to source actions. Other/manual IDs also require gen
|
|
|
123
123
|
Progress and model rows show full short-generation latency in milliseconds, including the final
|
|
124
124
|
stream event. Esc during discovery or testing cancels acquisition. A supported native askDialog
|
|
125
125
|
host is required. The local registry is read without refreshing it or accessing other credentials.
|
|
126
|
+
Managing an existing provider no longer re-tests configured models by default: the edit "模型"
|
|
127
|
+
entry first offers "保留已配置模型", which keeps every configured model checked and verified
|
|
128
|
+
without generation requests. "重新选择并测试模型" reopens the full acquisition flow, where
|
|
129
|
+
configured models are marked "已配置(默认保留)", skip candidate testing, and only new
|
|
130
|
+
candidates require generation checks.
|
|
126
131
|
Manage existing providers to view details, edit a draft, verify a selected model, or confirm deletion.
|
|
127
132
|
Role-bound providers must be rebound through `/role` before deletion (both in interactive UI and non-UI
|
|
128
133
|
slash command `/provider rm <name>`, preventing dangling role references in `config.yml`; `omp-sync provider rm`
|
package/package.json
CHANGED
package/src/provider-menu.js
CHANGED
|
@@ -71,7 +71,8 @@ async function verifyDraft(ctx, draft) {
|
|
|
71
71
|
}
|
|
72
72
|
const checkIdentity = config => JSON.stringify([config.api, config.baseUrl, config.apiKey || ""]);
|
|
73
73
|
async function acquireDraftModels(ctx, draft, agentDir, seedIds = draft.config.models.map(model => model.id)) {
|
|
74
|
-
const acquired = await acquireProviderModels(ctx, { name: draft.name, config: draft.config, agentDir, seedIds
|
|
74
|
+
const acquired = await acquireProviderModels(ctx, { name: draft.name, config: draft.config, agentDir, seedIds,
|
|
75
|
+
preservedIds: draft.config.models.map(model => model.id) });
|
|
75
76
|
if (!acquired) return false;
|
|
76
77
|
draft.config.models = acquired.models;
|
|
77
78
|
draft.config.baseUrl = acquired.baseUrl;
|
|
@@ -173,7 +174,18 @@ async function editDraft(ctx, name, agentDir, supplied) {
|
|
|
173
174
|
} else if (field === "存储范围") {
|
|
174
175
|
const scope = await chooseScope(ctx);
|
|
175
176
|
if (scope !== undefined) draft.isPrivate = scope;
|
|
176
|
-
} else if (field === "模型")
|
|
177
|
+
} else if (field === "模型") {
|
|
178
|
+
if (!draft.config.models.length) { await acquireDraftModels(ctx, draft, agentDir); continue; }
|
|
179
|
+
const operation = await select(ctx, `MODELS // ${name} · ${draft.config.models.length} 个已配置模型`,
|
|
180
|
+
["保留已配置模型", "重新选择并测试模型", "返回"]);
|
|
181
|
+
if (operation === "保留已配置模型") {
|
|
182
|
+
// Default for edit: keep every configured model verified without re-testing.
|
|
183
|
+
draft.checks = new Map(draft.config.models.map(model => [model.id, { ok: true }]));
|
|
184
|
+
draft.checkIdentity = checkIdentity(draft.config);
|
|
185
|
+
draft.requireVerifiedModels = true;
|
|
186
|
+
ctx.ui.notify("已保留全部已配置模型,未重新测试", "info");
|
|
187
|
+
} else if (operation === "重新选择并测试模型") await acquireDraftModels(ctx, draft, agentDir);
|
|
188
|
+
}
|
|
177
189
|
else if (field === "保存" && await saveSummary(ctx, draft, agentDir, false)) return;
|
|
178
190
|
}
|
|
179
191
|
}
|
package/src/provider-models.js
CHANGED
|
@@ -116,12 +116,18 @@ async function showFailures(ctx, cache) {
|
|
|
116
116
|
}
|
|
117
117
|
|
|
118
118
|
/** Acquire a verified subset without mutating config, the registry, or either store. */
|
|
119
|
-
export async function acquireProviderModels(ctx, { name, config, agentDir, seedIds = [] }) {
|
|
119
|
+
export async function acquireProviderModels(ctx, { name, config, agentDir, seedIds = [], preservedIds = [] }) {
|
|
120
120
|
if (typeof ctx.ui.askDialog !== "function") {
|
|
121
121
|
ctx.ui.notify("当前宿主不支持空格多选,请升级 OMP", "error");
|
|
122
122
|
return;
|
|
123
123
|
}
|
|
124
124
|
const working = { ...config }, existing = new Map((config.models || []).map(model => [model.id, model]));
|
|
125
|
+
const cache = new Map(), sources = new Map();
|
|
126
|
+
// Already-configured models keep verified status without any generation test (edit flow).
|
|
127
|
+
for (const id of unique(preservedIds)) {
|
|
128
|
+
if (!cache.has(id)) cache.set(id, { ok: true, latencyMs: null, preserved: true });
|
|
129
|
+
if (!sources.has(id)) sources.set(id, "已配置");
|
|
130
|
+
}
|
|
125
131
|
if (working.api === "anthropic-messages") working.baseUrl = working.baseUrl.trim().replace(/\/+$/, "").replace(/\/v1$/i, "");
|
|
126
132
|
let configuredProviders;
|
|
127
133
|
try { configuredProviders = listProviders({ agentDir }); }
|
|
@@ -132,7 +138,7 @@ export async function acquireProviderModels(ctx, { name, config, agentDir, seedI
|
|
|
132
138
|
catalog = ctx.modelRegistry.getAll("chat");
|
|
133
139
|
if (!Array.isArray(catalog)) throw new Error("Invalid registry");
|
|
134
140
|
} catch { catalog = []; ctx.ui.notify("本机模型目录不可用", "warning"); }
|
|
135
|
-
const
|
|
141
|
+
const stageIds = [[], [], [], []];
|
|
136
142
|
let stage = 0, mode = "stage", retry = false;
|
|
137
143
|
const available = () => [...sources.keys()].filter(id => cache.get(id)?.ok);
|
|
138
144
|
const check = async (ids, source) => {
|
|
@@ -186,8 +192,11 @@ export async function acquireProviderModels(ctx, { name, config, agentDir, seedI
|
|
|
186
192
|
const labels = new Map(available().map(id => [id, id]));
|
|
187
193
|
const result = await ctx.ui.askDialog([{
|
|
188
194
|
id: "provider-models", header: "MODELS", question: "选择已验证模型 · 空格勾选 · Enter 确认 · Esc 返回", multi: true,
|
|
189
|
-
options: [...labels.keys()].map(id =>
|
|
190
|
-
|
|
195
|
+
options: [...labels.keys()].map(id => {
|
|
196
|
+
const entry = cache.get(id);
|
|
197
|
+
return { label: id,
|
|
198
|
+
description: entry.preserved ? "已配置(默认保留)" : `可用 · ${entry.latencyMs} ms · 来源: ${sources.get(id)}` };
|
|
199
|
+
}),
|
|
191
200
|
}]);
|
|
192
201
|
if (!result || result.kind !== "submit") { mode = "menu"; continue; }
|
|
193
202
|
const answer = result.results?.find(item => item.id === "provider-models");
|
package/src/provider-store.js
CHANGED
|
@@ -231,10 +231,20 @@ export function ensureLocalExtension(ompDir) {
|
|
|
231
231
|
*/
|
|
232
232
|
export function parseYamlModels(str) {
|
|
233
233
|
if (!str || typeof str !== "string") return {};
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
234
|
+
// Prefer the yaml package: handles flow-style (braces) and block-list values
|
|
235
|
+
// (e.g. `input:` followed by `- text` lines) the line parser cannot.
|
|
236
|
+
const parsed = normalizeProviderInputs(parseFlowYamlModels(str));
|
|
237
|
+
if (Object.keys(parsed).length) return parsed;
|
|
238
|
+
return normalizeProviderInputs(parseBlockYamlModels(str));
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
function normalizeProviderInputs(providers) {
|
|
242
|
+
for (const cfg of Object.values(providers || {})) {
|
|
243
|
+
for (const model of cfg?.models || []) {
|
|
244
|
+
if (typeof model.input === "string" && model.input) model.input = [model.input];
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
return providers;
|
|
238
248
|
}
|
|
239
249
|
|
|
240
250
|
function parseFlowYamlModels(str) {
|
|
@@ -608,6 +618,7 @@ function scanBlockSource(text) {
|
|
|
608
618
|
if (section === "models" || section === "model" || section === "compat") {
|
|
609
619
|
if (indent === 6 && trimmed.startsWith("- ") && field === "id") { section = "model"; continue; }
|
|
610
620
|
if (indent === 8 && MODEL_FIELDS.has(field)) { section = field === "compat" ? "compat" : "model"; continue; }
|
|
621
|
+
if (section === "model" && indent === 10 && trimmed.startsWith("- ")) continue;
|
|
611
622
|
if (indent === 10 && section === "compat" && /^[A-Za-z0-9_-]+:\s*\S/.test(trimmed)) continue;
|
|
612
623
|
}
|
|
613
624
|
unsupported(`${provider || "root"}.${field}`);
|