fix: skip API key validation for free opencode models
free models (big-pickle, gpt-5-nano, etc.) define envVars: [] and isFree: true but validateAgentApiKey always required at least one provider key. now the validation is model-aware: free models bypass the check, keyed models validate their specific vars, and auto-select still requires at least one known key. closes #483 Made-with: Cursor
This commit is contained in:
committed by
pullfrog[bot]
parent
8a734c32f4
commit
30d68e53a7
@@ -132065,6 +132065,25 @@ var providers = {
|
||||
}
|
||||
})
|
||||
};
|
||||
function parseModel(slug) {
|
||||
const slashIdx = slug.indexOf("/");
|
||||
if (slashIdx === -1) {
|
||||
throw new Error(`invalid model slug "${slug}" \u2014 expected "provider/model"`);
|
||||
}
|
||||
return { provider: slug.slice(0, slashIdx), model: slug.slice(slashIdx + 1) };
|
||||
}
|
||||
function getModelEnvVars(slug) {
|
||||
const parsed2 = parseModel(slug);
|
||||
const providerConfig = providers[parsed2.provider];
|
||||
if (!providerConfig) {
|
||||
return [];
|
||||
}
|
||||
const modelConfig = providerConfig.models[parsed2.model];
|
||||
if (modelConfig?.envVars) {
|
||||
return modelConfig.envVars.slice();
|
||||
}
|
||||
return providerConfig.envVars.slice();
|
||||
}
|
||||
var modelAliases = Object.entries(providers).flatMap(
|
||||
([providerKey, config3]) => Object.entries(config3.models).map(([modelId, def]) => ({
|
||||
slug: `${providerKey}/${modelId}`,
|
||||
@@ -149212,10 +149231,18 @@ to fix this, add the required secret to your GitHub repository:
|
||||
|
||||
configure your model at ${settingsUrl}`;
|
||||
}
|
||||
function hasEnvVar(name) {
|
||||
const value2 = process.env[name];
|
||||
return typeof value2 === "string" && value2.length > 0;
|
||||
}
|
||||
function validateAgentApiKey(params) {
|
||||
const hasAnyKey = Object.entries(process.env).some(
|
||||
([key, value2]) => value2 && typeof value2 === "string" && knownApiKeys.has(key)
|
||||
);
|
||||
if (params.model) {
|
||||
const requiredVars = getModelEnvVars(params.model);
|
||||
if (requiredVars.length === 0) return;
|
||||
if (requiredVars.some((v) => hasEnvVar(v))) return;
|
||||
throw new Error(buildMissingApiKeyError({ owner: params.owner, name: params.name }));
|
||||
}
|
||||
const hasAnyKey = [...knownApiKeys].some((k) => hasEnvVar(k));
|
||||
if (!hasAnyKey) {
|
||||
throw new Error(buildMissingApiKeyError({ owner: params.owner, name: params.name }));
|
||||
}
|
||||
@@ -149805,7 +149832,7 @@ import { isAbsolute, resolve } from "node:path";
|
||||
// package.json
|
||||
var package_default = {
|
||||
name: "@pullfrog/pullfrog",
|
||||
version: "0.0.180",
|
||||
version: "0.0.181",
|
||||
type: "module",
|
||||
files: [
|
||||
"index.js",
|
||||
@@ -150374,6 +150401,7 @@ async function main() {
|
||||
const agent2 = resolveAgent();
|
||||
validateAgentApiKey({
|
||||
agent: agent2,
|
||||
model: payload.model,
|
||||
owner: runContext.repo.owner,
|
||||
name: runContext.repo.name
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user