(rawJson, opts = {})
| 55 | * @returns {{ json: string, modelCount: number }} |
| 56 | */ |
| 57 | export 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 | |
| 73 | export async function runSetupOpencodeCommand(opts = {}) { |
| 74 | const { baseUrl, apiKey } = resolveOpencodeTarget(opts); |
no outgoing calls
no test coverage detected