fix: infer synthetic provider auth in implicit tests

This commit is contained in:
Peter Steinberger
2026-04-05 12:45:08 +01:00
parent 21ef63d9f2
commit 76da484bed
2 changed files with 43 additions and 0 deletions

View File

@@ -287,6 +287,24 @@ async function inferImplicitProviderTestPluginIds(params: {
for (const providerId of await inferAuthProfileProviderIds(params.agentDir)) {
providerIds.add(providerId);
}
for (const [pluginId, entry] of Object.entries(params.config?.plugins?.entries ?? {})) {
if (!pluginId.trim() || entry?.enabled === false) {
continue;
}
const pluginConfig =
entry.config && typeof entry.config === "object"
? (entry.config as { webSearch?: { apiKey?: unknown } })
: undefined;
if (pluginConfig?.webSearch?.apiKey !== undefined) {
providerIds.add(pluginId);
}
}
const legacyGrokApiKey = (
params.config?.tools?.web?.search as { grok?: { apiKey?: unknown } } | undefined
)?.grok?.apiKey;
if (legacyGrokApiKey !== undefined && params.config?.plugins?.entries?.xai?.enabled !== false) {
providerIds.add("xai");
}
if (providerIds.size === 0) {
// No config/env/auth hints: keep ambient local auto-discovery focused on the

View File

@@ -511,5 +511,30 @@ function resolveXaiConfigFallbackAuth(params: { provider: string; config?: OpenC
mode: "api-key",
};
}
const legacyGrokApiKey = normalizeOptionalSecretInput(
(params.config?.tools?.web?.search as { grok?: { apiKey?: unknown } } | undefined | null)?.grok
?.apiKey,
);
if (legacyGrokApiKey) {
return {
apiKey: legacyGrokApiKey,
source: "tools.web.search.grok.apiKey",
mode: "api-key",
};
}
const legacyGrokApiKeyRef = coerceSecretRef(
(params.config?.tools?.web?.search as { grok?: { apiKey?: unknown } } | undefined | null)?.grok
?.apiKey,
);
if (legacyGrokApiKeyRef) {
return {
apiKey:
legacyGrokApiKeyRef.source === "env"
? legacyGrokApiKeyRef.id.trim()
: resolveNonEnvSecretRefApiKeyMarker(legacyGrokApiKeyRef.source),
source: "tools.web.search.grok.apiKey",
mode: "api-key",
};
}
return undefined;
}