| 179 | } |
| 180 | |
| 181 | listAvailableModels(): Array<{ provider: string; model: string; info: ModelInfo; local: boolean }> { |
| 182 | // Use the stored provider + model id directly instead of parsing index keys. |
| 183 | // The index holds each model under both `${provider}/${id}` and `${id}`, and an |
| 184 | // id can itself contain a '/' (e.g. LM Studio's `qwen/qwen3-coder-next`), so |
| 185 | // splitting the key produced bogus/truncated rows like `openai/qwen`. |
| 186 | const seen = new Set<string>(); |
| 187 | const out: Array<{ provider: string; model: string; info: ModelInfo; local: boolean }> = []; |
| 188 | for (const val of this.modelIndex.values()) { |
| 189 | const provider = val.provider.name; |
| 190 | const model = val.info.id; |
| 191 | const tag = `${provider}/${model}`; |
| 192 | if (seen.has(tag)) continue; |
| 193 | seen.add(tag); |
| 194 | out.push({ provider, model, info: val.info, local: val.provider.isLocal }); |
| 195 | } |
| 196 | return out; |
| 197 | } |
| 198 | |
| 199 | resolveModel(modelId: string): { provider: Provider; modelInfo: ModelInfo; resolvedId: string } | null { |
| 200 | // Try exact match first |