
/**
* Selects a specific model programmatically, independent of whatever the
* user currently has picked in the Copilot Chat model picker. This is the
* mechanism that lets different pipeline stages run on different models
* in the same run.
*/
async function pickModel(ref) {
	const models = ref.id ? await vscode.lm.selectChatModels({
		vendor: ref.vendor,
		id: ref.id
	}) : await vscode.lm.selectChatModels({
		vendor: ref.vendor,
		family: ref.family
	});
	if (models.length === 0) throw new Error(`No model found for vendor="${ref.vendor}" family="${ref.family}"${ref.id ? ` id="${ref.id}"` : ""}. Check glm-copilot.modelIdOverrides for the exact id string this model registers under.`);
	return models[0];
}
/** Text parts of a tool result — everything else (tsx, data) is dropped. */
function resultToTextParts(result) {
	return result.content.filter((part) => part instanceof vscode.LanguageModelTextPart);
}
/** Flat text of a tool result. */
function resultToText(result) {
	return resultToTextParts(result).map((part) => part.value).join("\n");
}
