diff --git a/packages/core/src/config/plugin/provider.ts b/packages/core/src/config/plugin/provider.ts index ec00ddf36c..9b25b6be4b 100644 --- a/packages/core/src/config/plugin/provider.ts +++ b/packages/core/src/config/plugin/provider.ts @@ -13,17 +13,15 @@ export const Plugin = define({ const loaded = { entries: yield* config.entries() } yield* ctx.integration.transform((integrations) => { const files = loaded.entries.filter((entry): entry is Config.Document => entry.type === "document") - const configuredIntegrations = new Set( - files.flatMap((file) => - Object.entries(file.info.providers ?? {}).flatMap(([id, provider]) => - provider.env === undefined ? [] : [id], - ), - ), - ) for (const file of files) { for (const [id, item] of Object.entries(file.info.providers ?? {})) { const integrationID = id - if (!configuredIntegrations.has(id) && !integrations.get(integrationID)) continue + if (!integrations.get(integrationID)) { + integrations.method.update({ + integrationID, + method: { type: "key", label: "Manually enter API Key" }, + }) + } integrations.update(integrationID, (integration) => { integration.name = item.name ?? integration.name }) diff --git a/packages/core/test/config/provider.test.ts b/packages/core/test/config/provider.test.ts index de10dbcd36..288c1a4e1e 100644 --- a/packages/core/test/config/provider.test.ts +++ b/packages/core/test/config/provider.test.ts @@ -49,6 +49,33 @@ function withEnv(vars: Record, effect: () = const decode = Schema.decodeUnknownSync(Config.Info) describe("ConfigProviderPlugin.Plugin", () => { + it.effect("adds key auth for custom providers without env credentials", () => + Effect.gen(function* () { + const integrations = yield* Integration.Service + const entries = [ + new Config.Document({ + type: "document", + info: decode({ + providers: { + litellm: { + package: "aisdk:@ai-sdk/openai-compatible", + models: { chat: {} }, + }, + }, + }), + }), + ] + + yield* addPlugin(entries) + + expect(yield* integrations.get(Integration.ID.make("litellm"))).toMatchObject({ + id: "litellm", + name: "litellm", + methods: [{ type: "key", label: "Manually enter API Key" }], + }) + }), + ) + it.effect("defaults custom models to agent capabilities", () => Effect.gen(function* () { const catalog = yield* Catalog.Service