CLI: detect env-backed audio providers (#65491)

* CLI: detect env-backed audio providers

* fix(cli): trust audio provider env detection

* Secrets: keep default provider env lookups stable

* Plugins: harden env-backed auth defaults

* Plugins: tighten trusted env var lookups

---------

Co-authored-by: Vincent Koc <vincentkoc@ieee.org>
This commit is contained in:
scoootscooob
2026-04-12 14:04:44 -07:00
committed by GitHub
parent 0bca55acea
commit 94ef2f1b0d
8 changed files with 378 additions and 9 deletions

View File

@@ -105,6 +105,7 @@ const mocks = vi.hoisted(() => ({
{ id: "openai", defaultModel: "text-embedding-3-small", transport: "remote" },
]),
registerBuiltInMemoryEmbeddingProviders: vi.fn(),
buildMediaUnderstandingRegistry: vi.fn(() => new Map()),
isWebSearchProviderConfigured: vi.fn(() => false),
isWebFetchProviderConfigured: vi.fn(() => false),
modelsStatusCommand: vi.fn(
@@ -183,6 +184,11 @@ vi.mock("../media-understanding/runtime.js", () => ({
mocks.transcribeAudioFile as typeof import("../media-understanding/runtime.js").transcribeAudioFile,
}));
vi.mock("../media-understanding/provider-registry.js", () => ({
buildMediaUnderstandingRegistry:
mocks.buildMediaUnderstandingRegistry as typeof import("../media-understanding/provider-registry.js").buildMediaUnderstandingRegistry,
}));
vi.mock("../plugins/memory-embedding-providers.js", () => ({
listMemoryEmbeddingProviders:
mocks.listMemoryEmbeddingProviders as unknown as typeof import("../plugins/memory-embedding-providers.js").listMemoryEmbeddingProviders,
@@ -241,6 +247,7 @@ vi.mock("../web-fetch/runtime.js", () => ({
describe("capability cli", () => {
afterEach(() => {
vi.unstubAllGlobals();
vi.unstubAllEnvs();
});
beforeEach(() => {
@@ -288,6 +295,7 @@ describe("capability cli", () => {
mocks.textToSpeech.mockClear();
mocks.setTtsProvider.mockClear();
mocks.resolveExplicitTtsOverrides.mockClear();
mocks.buildMediaUnderstandingRegistry.mockReset().mockReturnValue(new Map());
mocks.createEmbeddingProvider.mockClear();
mocks.registerMemoryEmbeddingProvider.mockClear();
mocks.registerBuiltInMemoryEmbeddingProviders.mockClear();
@@ -920,6 +928,55 @@ describe("capability cli", () => {
);
});
it("marks env-backed audio providers as configured", async () => {
vi.stubEnv("DEEPGRAM_API_KEY", "deepgram-test-key");
vi.stubEnv("GROQ_API_KEY", "groq-test-key");
mocks.buildMediaUnderstandingRegistry.mockReturnValueOnce(
new Map([
[
"deepgram",
{
id: "deepgram",
capabilities: ["audio"],
defaultModels: { audio: "nova-3" },
},
],
[
"groq",
{
id: "groq",
capabilities: ["audio"],
defaultModels: { audio: "whisper-large-v3-turbo" },
},
],
]),
);
await runRegisteredCli({
register: registerCapabilityCli as (program: Command) => void,
argv: ["capability", "audio", "providers", "--json"],
});
expect(mocks.runtime.writeJson).toHaveBeenCalledWith([
{
available: true,
configured: true,
selected: false,
id: "deepgram",
capabilities: ["audio"],
defaultModels: { audio: "nova-3" },
},
{
available: true,
configured: true,
selected: false,
id: "groq",
capabilities: ["audio"],
defaultModels: { audio: "whisper-large-v3-turbo" },
},
]);
});
it("surfaces available, configured, and selected for web providers", async () => {
mocks.loadConfig.mockReturnValue({
tools: {