MCPcopy Create free account
hub / github.com/QodeXcli/QodeX / mergeCustomProvider

Function mergeCustomProvider

src/setup/gateways.ts:230–247  ·  view source on GitHub ↗
(config: any, entry: CustomProviderEntry, opts?: { setDefault?: boolean; defaultModel?: string })

Source from the content-addressed store, hash-verified

228 * exists, it's replaced in place (no duplicates).
229 */
230export function mergeCustomProvider(config: any, entry: CustomProviderEntry, opts?: { setDefault?: boolean; defaultModel?: string }): any {
231 const cfg = config && typeof config === 'object' ? config : {};
232 cfg.providers = cfg.providers && typeof cfg.providers === 'object' ? cfg.providers : {};
233 const custom: CustomProviderEntry[] = Array.isArray(cfg.providers.custom) ? cfg.providers.custom : [];
234
235 const idx = custom.findIndex(c => c && c.name === entry.name);
236 if (idx >= 0) custom[idx] = entry;
237 else custom.push(entry);
238 cfg.providers.custom = custom;
239
240 if (opts?.setDefault) {
241 cfg.defaults = cfg.defaults && typeof cfg.defaults === 'object' ? cfg.defaults : {};
242 cfg.defaults.provider = entry.name;
243 const model = opts.defaultModel ?? entry.models?.[0]?.id;
244 if (model) cfg.defaults.model = model;
245 }
246 return cfg;
247}

Callers 2

gateways.test.tsFile · 0.90
addProviderToConfigFunction · 0.85

Calls 1

pushMethod · 0.45

Tested by

no test coverage detected