omp-config-crypt 0.9.4 → 0.9.5

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 CHANGED
@@ -148,7 +148,7 @@ Pika, Vidu, Wanx, SDXL, Imagen, Ideogram, Kolors, `*-image`, `*-video`) while st
148
148
  The summary supports rechecking all selected models; failed, cancelled or unstarted rechecks cannot inherit
149
149
  previous successes. Check results, source labels and latency remain in memory and are not saved. `/provider test`
150
150
  checks one model and reports its latency; it does not claim the entire provider is verified.
151
- Draft cancellation does not write; saved changes load after restarting OMP.
151
+ Draft cancellation does not write. In-session interactive and non-UI `/provider` add, edit, and deletion synchronize immediately into the active OMP session's model catalog (`/models`). If the current session model belongs to a provider whose configuration is deleted or edited without that model ID, an alternative model must be selected before writing; if no replacement model is available, or if the current model is actively generating, the operation is blocked with zero configuration writes. If model catalog synchronization fails, configuration writes remain preserved on disk and a warning notification is displayed. Standalone `omp-sync` and other external OMP processes operate strictly at the file level and load changes upon their next startup.
152
152
  PRIVATE is the default and is excluded by encrypted-sync filtering; PUBLIC includes credentials
153
153
  in encrypted synchronization. Private providers remain mirrored in both existing stores.
154
154
  Background maintenance preserves the active `models.local.json` store; only obsolete root-level
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "omp-config-crypt",
3
- "version": "0.9.4",
3
+ "version": "0.9.5",
4
4
  "description": "Universal cross-platform encrypted portability for omp config, extensions, and instructions",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -11,7 +11,9 @@
11
11
  "omp-sync": "./bin/omp-sync.js"
12
12
  },
13
13
  "scripts": {
14
- "test": "node test/sync-portable.test.mjs"
14
+ "test": "node test/sync-portable.test.mjs",
15
+ "eval": "node eval/change-eval.mjs",
16
+ "eval:gate": "omp-agent-eval"
15
17
  },
16
18
  "keywords": [
17
19
  "omp",
@@ -8,6 +8,214 @@ const DIALOG = { outline: true, helpText: "↑↓ 选择 · Enter 确认 · Esc
8
8
  const select = (ctx, title, options) => ctx.ui.select(title, options, DIALOG);
9
9
  const rolesFor = (name, agentDir) => Object.entries(getRoles(agentDir))
10
10
  .filter(([, ref]) => ref.startsWith(`${name}/`)).map(([role]) => role);
11
+ const DEFAULT_CONTEXT_WINDOW = 256000;
12
+ const DEFAULT_MAX_TOKENS = 65536;
13
+
14
+ function inferModelSpec(modelId) {
15
+ const id = (modelId || "").toLowerCase();
16
+ if (/gemini.*pro/.test(id)) {
17
+ return { contextWindow: 2000000, maxTokens: 65536, hasImage: true };
18
+ }
19
+ if (/gemini.*(flash|lite)/.test(id)) {
20
+ return { contextWindow: 1000000, maxTokens: 65536, hasImage: true };
21
+ }
22
+ if (/deepseek.*(v4|pro|flash)/.test(id)) {
23
+ return { contextWindow: 1048576, maxTokens: 65536, hasImage: /flash|vl/.test(id) };
24
+ }
25
+ if (/deepseek/.test(id)) {
26
+ return { contextWindow: 1048576, maxTokens: 32000, hasImage: /vl/.test(id) };
27
+ }
28
+ if (/kimi|moonshot/.test(id)) {
29
+ return { contextWindow: 512000, maxTokens: 32000, hasImage: false };
30
+ }
31
+ if (/claude/.test(id)) {
32
+ return { contextWindow: 200000, maxTokens: 64000, hasImage: true };
33
+ }
34
+ if (/(gpt-6|gpt-5\.[0-9]).*(sol|terra)/.test(id)) {
35
+ return { contextWindow: 256000, maxTokens: 384000, reasoning: true, hasImage: false };
36
+ }
37
+ if (/gpt-6|astra/.test(id)) {
38
+ return { contextWindow: 256000, maxTokens: 32000, hasImage: false };
39
+ }
40
+ if (/qwen.*(max|plus|turbo|2\.5)/.test(id)) {
41
+ return { contextWindow: 131072, maxTokens: 32000, hasImage: /vl/.test(id) };
42
+ }
43
+ return { contextWindow: DEFAULT_CONTEXT_WINDOW, maxTokens: DEFAULT_MAX_TOKENS, hasImage: false };
44
+ }
45
+
46
+ function optimizeRuntimeModel(model) {
47
+ const id = model.id || "";
48
+ const inferred = inferModelSpec(id);
49
+ let cw = model.contextWindow;
50
+ let mt = model.maxTokens;
51
+ let input = Array.isArray(model.input) ? [...model.input] : ["text"];
52
+ let reasoning = model.reasoning;
53
+
54
+ if (!cw || cw <= 128000) {
55
+ cw = inferred.contextWindow || DEFAULT_CONTEXT_WINDOW;
56
+ }
57
+ if (cw < DEFAULT_CONTEXT_WINDOW) {
58
+ cw = DEFAULT_CONTEXT_WINDOW;
59
+ }
60
+ if (!mt || mt === 32000) {
61
+ mt = inferred.maxTokens || DEFAULT_MAX_TOKENS;
62
+ }
63
+ if (inferred.hasImage && !input.includes("image")) {
64
+ input.push("image");
65
+ }
66
+ if (inferred.reasoning && reasoning === undefined) {
67
+ reasoning = true;
68
+ }
69
+ return {
70
+ ...model,
71
+ contextWindow: cw,
72
+ maxTokens: mt,
73
+ input,
74
+ ...(reasoning !== undefined ? { reasoning } : {})
75
+ };
76
+ }
77
+
78
+ export function runtimeConfig(provider) {
79
+ const isPrivate = Boolean(provider.isPrivate || provider.private);
80
+ let models = Array.isArray(provider.models) ? provider.models : [];
81
+ if (isPrivate) {
82
+ models = models.map(m => optimizeRuntimeModel(m));
83
+ } else {
84
+ models = models.map(m => ({ ...m }));
85
+ }
86
+ const cfg = {
87
+ api: provider.api,
88
+ baseUrl: provider.baseUrl,
89
+ apiKey: provider.apiKey,
90
+ models,
91
+ };
92
+ if (provider.authHeader !== undefined) {
93
+ cfg.authHeader = provider.authHeader;
94
+ }
95
+ return cfg;
96
+ }
97
+
98
+ export function currentModel(ctx) {
99
+ try {
100
+ if (typeof ctx?.models?.current === "function") {
101
+ const cur = ctx.models.current();
102
+ if (cur) return cur;
103
+ }
104
+ } catch {}
105
+ try {
106
+ if (ctx?.model) return ctx.model;
107
+ } catch {}
108
+ return null;
109
+ }
110
+
111
+ export async function refreshRegistry(ctx) {
112
+ if (typeof ctx?.modelRegistry?.refresh === "function") {
113
+ await ctx.modelRegistry.refresh();
114
+ }
115
+ }
116
+
117
+ export async function registerRuntimeProvider(pi, ctx, provider) {
118
+ const name = provider.name || provider.id;
119
+ const isPrivate = Boolean(provider.isPrivate || provider.private);
120
+ if (isPrivate) {
121
+ if (typeof pi?.registerProvider !== "function") {
122
+ throw new Error("模型目录同步不可用");
123
+ }
124
+ pi.registerProvider(name, runtimeConfig(provider));
125
+ }
126
+ if (!isPrivate && typeof ctx?.modelRegistry?.refresh !== "function") {
127
+ throw new Error("模型目录同步不可用");
128
+ }
129
+ await refreshRegistry(ctx);
130
+ }
131
+
132
+ export async function syncRemovedProvider(pi, ctx, name, wasPrivate) {
133
+ if (wasPrivate) {
134
+ if (typeof pi?.unregisterProvider !== "function") {
135
+ throw new Error("模型目录同步不可用");
136
+ }
137
+ await pi.unregisterProvider(name);
138
+ }
139
+ if (!wasPrivate && typeof ctx?.modelRegistry?.refresh !== "function") {
140
+ throw new Error("模型目录同步不可用");
141
+ }
142
+ await refreshRegistry(ctx);
143
+ }
144
+
145
+ export function availableModels(ctx) {
146
+ try {
147
+ if (typeof ctx?.modelRegistry?.getAvailable === "function") {
148
+ const list = ctx.modelRegistry.getAvailable();
149
+ if (Array.isArray(list)) return list;
150
+ }
151
+ } catch {}
152
+ return [];
153
+ }
154
+
155
+ export async function ensureCurrentModel(pi, ctx, { provider, modelId, modelIds, action }) {
156
+ const cur = currentModel(ctx);
157
+ if (!cur || cur.provider !== provider) return true;
158
+
159
+ if (typeof ctx?.waitForIdle === "function") {
160
+ await ctx.waitForIdle();
161
+ }
162
+ if (typeof ctx?.isIdle === "function" && !ctx.isIdle()) {
163
+ ctx.ui?.notify?.(`当前模型正在响应,完成后再${action}`, "warning");
164
+ return false;
165
+ }
166
+
167
+ if (action === "保存") {
168
+ const ids = Array.isArray(modelIds)
169
+ ? modelIds
170
+ : (Array.isArray(modelId) ? modelId : (modelId ? [modelId] : []));
171
+ if (ids.includes(cur.id)) {
172
+ return true;
173
+ }
174
+ }
175
+
176
+ const candidateMap = new Map();
177
+ for (const m of availableModels(ctx)) {
178
+ if (m?.provider && m?.id && m.provider !== provider) {
179
+ const key = `${m.provider}/${m.id}`;
180
+ if (!candidateMap.has(key)) candidateMap.set(key, m);
181
+ }
182
+ }
183
+
184
+ const options = Array.from(candidateMap.keys());
185
+ if (!options.length) {
186
+ ctx.ui?.notify?.(`没有可切换的其它模型,未${action}`, "warning");
187
+ return false;
188
+ }
189
+
190
+ if (!ctx?.hasUI) {
191
+ ctx.ui?.notify?.(`当前模型属于 ${provider},请先使用 /model 切换后再${action}`, "warning");
192
+ return false;
193
+ }
194
+
195
+ const chosenKey = await select(ctx, "当前模型将被移除,请选择替代模型", options);
196
+ if (!chosenKey) return false;
197
+
198
+ const chosenModel = candidateMap.get(chosenKey);
199
+ try {
200
+ if (typeof pi?.setModel !== "function") {
201
+ throw new Error("宿主不支持 setModel");
202
+ }
203
+ await pi.setModel(chosenModel);
204
+ } catch (err) {
205
+ ctx.ui?.notify?.(`切换模型失败: ${err.message}`, "error");
206
+ return false;
207
+ }
208
+
209
+ const newCur = currentModel(ctx);
210
+ if (!newCur || newCur.provider !== chosenModel.provider || newCur.id !== chosenModel.id) {
211
+ ctx.ui?.notify?.(`切换模型失败: 无法激活 ${chosenKey}`, "error");
212
+ return false;
213
+ }
214
+
215
+ ctx.ui?.notify?.(`当前模型已切换到 ${chosenKey}`, "info");
216
+ return true;
217
+ }
218
+
11
219
 
12
220
  function validName(name) {
13
221
  if (!/^[A-Za-z0-9][A-Za-z0-9_-]*$/.test(name)) throw new Error("名称须以字母或数字开头,仅含字母、数字、_、-");
@@ -90,7 +298,7 @@ async function recheckDraftModels(ctx, draft) {
90
298
  for (const result of batch.results) if (result.ok) draft.checks.set(result.id, { ok: true, latencyMs: result.latencyMs });
91
299
  draft.checkIdentity = identity;
92
300
  }
93
- async function saveSummary(ctx, draft, agentDir, isNew) {
301
+ export async function saveSummary(pi, ctx, draft, agentDir, isNew) {
94
302
  if (!draft.requireVerifiedModels && draft.config.api === "anthropic-messages") draft.config.baseUrl = draft.config.baseUrl.replace(/\/v1$/i, "");
95
303
  for (;;) {
96
304
  if (draft.requireVerifiedModels && draft.checkIdentity !== checkIdentity(draft.config)) draft.checks = new Map();
@@ -109,13 +317,53 @@ async function saveSummary(ctx, draft, agentDir, isNew) {
109
317
  try {
110
318
  if (isNew && getProvider(draft.name, { agentDir })) throw new Error("名称已存在,请进入已有项编辑");
111
319
  if (!draft.config.models.length) throw new Error("请先配置实际模型 ID");
320
+
321
+ const cur = currentModel(ctx);
322
+ const curBelongsToThis = Boolean(cur && cur.provider === draft.name);
323
+ const newModelIds = draft.config.models.map(model => model.id);
324
+ const retainsCurrentId = curBelongsToThis && newModelIds.includes(cur.id);
325
+
326
+ if (curBelongsToThis) {
327
+ const ok = await ensureCurrentModel(pi, ctx, { provider: draft.name, modelId: newModelIds, action: "保存" });
328
+ if (!ok) return false;
329
+ }
330
+
112
331
  saveProvider({ name: draft.name, providerConfig: draft.config, isPrivate: draft.isPrivate, agentDir });
113
- ctx.ui.notify("已保存,重启 OMP 后加载配置", "info");
332
+ const savedProvider = getProvider(draft.name, { agentDir }) || {
333
+ name: draft.name,
334
+ isPrivate: draft.isPrivate,
335
+ ...draft.config,
336
+ };
337
+
338
+ let syncFailed = false;
339
+ try {
340
+ await registerRuntimeProvider(pi, ctx, savedProvider);
341
+ } catch (syncErr) {
342
+ syncFailed = true;
343
+ ctx.ui.notify(`配置已保存,但模型目录同步失败: ${syncErr.message}`, "error");
344
+ }
345
+
346
+ if (!syncFailed) {
347
+ if (retainsCurrentId) {
348
+ const available = availableModels(ctx);
349
+ const resolved = available.find(m => m.provider === draft.name && m.id === cur.id);
350
+ if (resolved && typeof pi?.setModel === "function") {
351
+ try {
352
+ await pi.setModel(resolved);
353
+ } catch {
354
+ ctx.ui.notify("配置已保存,但当前模型未能重新绑定", "warning");
355
+ }
356
+ } else {
357
+ ctx.ui.notify("配置已保存,但当前模型未能重新绑定", "warning");
358
+ }
359
+ }
360
+ ctx.ui.notify("已保存,模型目录已同步", "info");
361
+ }
114
362
  return true;
115
363
  } catch (error) { ctx.ui.notify(`保存失败,未完成保存: ${error.message}`, "error"); }
116
364
  }
117
365
  }
118
- async function addDraft(ctx, agentDir, seed = {}) {
366
+ async function addDraft(pi, ctx, agentDir, seed = {}) {
119
367
  const name = await inputField(ctx, "Provider 名称", seed.name || "例如 my-provider", value => {
120
368
  validName(value);
121
369
  if (getProvider(value, { agentDir })) throw new Error("名称已存在,请进入已有项编辑");
@@ -132,9 +380,9 @@ async function addDraft(ctx, agentDir, seed = {}) {
132
380
  if (isPrivate === undefined) return;
133
381
  const draft = { name, isPrivate, config: { baseUrl, api, apiKey, models: [] }, verified: false };
134
382
  if (!await acquireDraftModels(ctx, draft, agentDir, seed.model ? [seed.model] : [])) return;
135
- await saveSummary(ctx, draft, agentDir, true);
383
+ await saveSummary(pi, ctx, draft, agentDir, true);
136
384
  }
137
- async function editDraft(ctx, name, agentDir, supplied) {
385
+ async function editDraft(pi, ctx, name, agentDir, supplied) {
138
386
  const provider = getProvider(name, { agentDir });
139
387
  if (!provider) return ctx.ui.notify(`Provider '${name}' not found`, "warning");
140
388
  const draft = supplied || fromProvider(provider);
@@ -186,31 +434,43 @@ async function editDraft(ctx, name, agentDir, supplied) {
186
434
  ctx.ui.notify("已保留全部已配置模型,未重新测试", "info");
187
435
  } else if (operation === "重新选择并测试模型") await acquireDraftModels(ctx, draft, agentDir);
188
436
  }
189
- else if (field === "保存" && await saveSummary(ctx, draft, agentDir, false)) return;
437
+ else if (field === "保存" && await saveSummary(pi, ctx, draft, agentDir, false)) return;
190
438
  }
191
439
  }
192
- async function deleteProvider(ctx, name, agentDir) {
440
+ export async function deleteProvider(pi, ctx, name, agentDir) {
193
441
  const provider = getProvider(name, { agentDir });
194
442
  if (!provider) return ctx.ui.notify(`Provider '${name}' not found`, "warning");
443
+ const wasPrivate = Boolean(provider.isPrivate || provider.private);
195
444
  const roles = rolesFor(name, agentDir);
196
445
  if (roles.length) {
197
446
  ctx.ui.notify(`${name} 绑定角色: ${roles.join(", ")};请先通过 /role 改绑`, "warning"); return;
198
447
  }
199
- if (await ctx.ui.confirm(`删除 ${name}`, `名称: ${name}\n绑定角色: 无\n确认从两处配置删除?`)) {
200
- removeProvider({ name, agentDir });
201
- ctx.ui.notify(`已删除 ${name},重启 OMP 后加载配置`, "info");
448
+ if (!await ctx.ui.confirm(`删除 ${name}`, `名称: ${name}\n绑定角色: 无\n确认从两处配置删除?`)) {
449
+ return;
450
+ }
451
+ const modelOk = await ensureCurrentModel(pi, ctx, { provider: name, action: "删除" });
452
+ if (!modelOk) return;
453
+
454
+ const removed = removeProvider({ name, agentDir });
455
+ if (!removed) return;
456
+
457
+ try {
458
+ await syncRemovedProvider(pi, ctx, name, wasPrivate);
459
+ ctx.ui.notify(`已删除 ${name},模型目录已同步`, "info");
460
+ } catch (err) {
461
+ ctx.ui.notify(`配置已删除,但模型目录同步失败: ${err.message}`, "error");
202
462
  }
203
463
  }
204
464
 
205
465
  export async function runProviderMenu(pi, ctx, { agentDir, action, name, draft } = {}) {
206
466
  if (!ctx.hasUI) return;
207
- if (action === "add" || action === "wizard") return addDraft(ctx, agentDir, draft);
208
- if (action === "edit") return editDraft(ctx, name, agentDir, draft);
467
+ if (action === "add" || action === "wizard") return addDraft(pi, ctx, agentDir, draft);
468
+ if (action === "edit") return editDraft(pi, ctx, name, agentDir, draft);
209
469
  if (action === "test") {
210
470
  const provider = getProvider(name, { agentDir });
211
471
  return provider ? verifyDraft(ctx, fromProvider(provider)) : ctx.ui.notify(`Provider '${name}' not found`, "warning");
212
472
  }
213
- if (action === "rm" || action === "remove") return deleteProvider(ctx, name, agentDir);
473
+ if (action === "rm" || action === "remove") return deleteProvider(pi, ctx, name, agentDir);
214
474
  for (;;) {
215
475
  const providers = listProviders({ agentDir });
216
476
  const choice = await select(ctx, "PROVIDER // CONTROL", [
@@ -218,7 +478,7 @@ export async function runProviderMenu(pi, ctx, { agentDir, action, name, draft }
218
478
  { label: "≡ 管理已有 Provider", description: `${providers.length} 个 Provider` }, "× 退出",
219
479
  ]);
220
480
  if (!choice || choice === "× 退出") return;
221
- if (choice === "+ 添加 Provider") { await addDraft(ctx, agentDir); continue; }
481
+ if (choice === "+ 添加 Provider") { await addDraft(pi, ctx, agentDir); continue; }
222
482
  for (;;) {
223
483
  const current = listProviders({ agentDir });
224
484
  if (!current.length) { ctx.ui.notify("尚未配置 Provider", "info"); break; }
@@ -231,9 +491,9 @@ export async function runProviderMenu(pi, ctx, { agentDir, action, name, draft }
231
491
  const operation = await select(ctx, `PROVIDER // ${chosen}`, ["查看详情", "编辑配置", "验证连接", "删除", "返回"]);
232
492
  if (!operation || operation === "返回") break;
233
493
  if (operation === "查看详情") ctx.ui.notify(summary(fromProvider(provider), agentDir), "info");
234
- if (operation === "编辑配置") await editDraft(ctx, chosen, agentDir);
494
+ if (operation === "编辑配置") await editDraft(pi, ctx, chosen, agentDir);
235
495
  if (operation === "验证连接") await verifyDraft(ctx, fromProvider(provider));
236
- if (operation === "删除") { await deleteProvider(ctx, chosen, agentDir); if (!getProvider(chosen, { agentDir })) break; }
496
+ if (operation === "删除") { await deleteProvider(pi, ctx, chosen, agentDir); if (!getProvider(chosen, { agentDir })) break; }
237
497
  }
238
498
  }
239
499
  }
@@ -285,12 +545,28 @@ export async function handleProviderCommand(pi, ctx, args, agentDir) {
285
545
  if (!name || tokens.length !== 2) throw new Error(`Usage: /provider ${sub} <name>`);
286
546
  if (ctx.hasUI) return await runProviderMenu(pi, ctx, { agentDir, action: sub, name });
287
547
  if (sub === "edit" || sub === "test") throw new Error(`Usage: /provider ${sub} <name> (requires interactive UI)`);
548
+ const provider = getProvider(name, { agentDir });
549
+ if (!provider) {
550
+ ctx.ui.notify(`Provider '${name}' not found`, "info");
551
+ return;
552
+ }
553
+ const wasPrivate = Boolean(provider.isPrivate || provider.private);
288
554
  const roles = rolesFor(name, agentDir);
289
555
  if (roles.length) {
290
556
  ctx.ui.notify(`Provider '${name}' 绑定角色: ${roles.join(", ")};请先通过 /role 改绑`, "warning");
291
557
  return;
292
558
  }
293
- ctx.ui.notify(removeProvider({ name, agentDir }) ? `Removed provider '${name}'` : `Provider '${name}' not found`, "info"); return;
559
+ const modelOk = await ensureCurrentModel(pi, ctx, { provider: name, action: "删除" });
560
+ if (!modelOk) return;
561
+
562
+ removeProvider({ name, agentDir });
563
+ try {
564
+ await syncRemovedProvider(pi, ctx, name, wasPrivate);
565
+ ctx.ui.notify(`Removed provider '${name}' and synchronized the model catalog`, "info");
566
+ } catch (err) {
567
+ ctx.ui.notify(`配置已删除,但模型目录同步失败: ${err.message}`, "error");
568
+ }
569
+ return;
294
570
  }
295
571
  if (sub === "add" || sub === "wizard") {
296
572
  const options = parseAdd(tokens.slice(1));
@@ -304,16 +580,32 @@ export async function handleProviderCommand(pi, ctx, args, agentDir) {
304
580
  const draft = { name: options.name, isPrivate: options.isPrivate, verified: false,
305
581
  config: { api: options.api, baseUrl: options.baseUrl, apiKey: options.apiKey, models: [] } };
306
582
  if (!await acquireDraftModels(ctx, draft, agentDir, options.model ? [options.model] : [])) return;
307
- await saveSummary(ctx, draft, agentDir, true);
583
+ await saveSummary(pi, ctx, draft, agentDir, true);
308
584
  return;
309
585
  }
310
586
  const result = await probeProvider({ ...options, testModelId: options.model, providerName: options.name });
311
587
  if (!result.ok && !options.model) throw new Error(result.error);
312
588
  const models = result.ok ? result.models : [inferModelCapabilities(options.model, options.name)];
313
589
  if (options.model && !models.some(model => model.id === options.model)) models.push(inferModelCapabilities(options.model, options.name));
314
- saveProvider({ name: options.name, providerConfig: { baseUrl: result.ok ? result.normalizedBaseUrl : options.baseUrl,
315
- api: options.api, apiKey: options.apiKey, models }, isPrivate: options.isPrivate, agentDir });
316
- ctx.ui.notify("已保存(未验证),重启 OMP 后加载配置", "info"); return;
590
+ const providerConfig = {
591
+ baseUrl: result.ok ? result.normalizedBaseUrl : options.baseUrl,
592
+ api: options.api,
593
+ apiKey: options.apiKey,
594
+ models,
595
+ };
596
+ saveProvider({ name: options.name, providerConfig, isPrivate: options.isPrivate, agentDir });
597
+ const savedProvider = getProvider(options.name, { agentDir }) || {
598
+ name: options.name,
599
+ isPrivate: options.isPrivate,
600
+ ...providerConfig,
601
+ };
602
+ try {
603
+ await registerRuntimeProvider(pi, ctx, savedProvider);
604
+ ctx.ui.notify("已保存(未验证),模型目录已同步", "info");
605
+ } catch (syncErr) {
606
+ ctx.ui.notify(`配置已保存,但模型目录同步失败: ${syncErr.message}`, "error");
607
+ }
608
+ return;
317
609
  }
318
610
  throw new Error("Usage: /provider [ls|add|edit <name>|test <name>|rm <name>]");
319
611
  } catch (error) { ctx.ui.notify(`Provider command error: ${error.message}`, "error"); }