fix: use generic type on resolveModelId to preserve Model<Api> through resolution

resolveModelId narrowed the return type to { id, provider } which lost
the full Model<Api> shape needed by pi.setModel(). Using a generic <T>
preserves the actual type from the registry's getAvailable() call.
This commit is contained in:
Jeremy McSpadden 2026-03-17 11:37:59 -05:00
parent 5a5cbff64e
commit f77ce13944

View file

@ -143,11 +143,11 @@ export async function selectAndApplyModel(
* Resolve a model ID string to a model object from the available models list.
* Handles formats: "provider/model", "bare-id", "org/model-name" (OpenRouter).
*/
function resolveModelId(
function resolveModelId<T extends { id: string; provider: string }>(
modelId: string,
availableModels: Array<{ id: string; provider: string }>,
availableModels: T[],
currentProvider: string | undefined,
): { id: string; provider: string } | undefined {
): T | undefined {
const slashIdx = modelId.indexOf("/");
if (slashIdx !== -1) {