MCPcopy Create free account
hub / github.com/diegosouzapw/OmniRoute / postProcessOpencodeConfig

Function postProcessOpencodeConfig

bin/cli/commands/setup-opencode.mjs:57–71  ·  view source on GitHub ↗
(rawJson, opts = {})

Source from the content-addressed store, hash-verified

55 * @returns {{ json: string, modelCount: number }}
56 */
57export function postProcessOpencodeConfig(rawJson, opts = {}) {
58 const config = JSON.parse(rawJson);
59 const prov = config.provider?.omniroute;
60 if (prov?.options) prov.options.apiKey = ENV_KEY_REF;
61
62 if (opts.only && opts.only.length && prov?.models) {
63 const kept = {};
64 for (const [id, entry] of Object.entries(prov.models)) {
65 if (opts.only.some((f) => id.includes(f))) kept[id] = entry;
66 }
67 prov.models = kept;
68 }
69 const modelCount = prov?.models ? Object.keys(prov.models).length : 0;
70 return { json: JSON.stringify(config, null, 2) + "\n", modelCount };
71}
72
73export async function runSetupOpencodeCommand(opts = {}) {
74 const { baseUrl, apiKey } = resolveOpencodeTarget(opts);

Callers 2

runSetupOpencodeCommandFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected