Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
feat(llm): add zero-slot Codex subscription descriptor
Alfredo Lopez6676d781688b
diff --git a/control-api/src/services/modelsDevClient.ts b/control-api/src/services/modelsDevClient.tsindex 91fb47c0d..5cfa54f65 100644--- a/control-api/src/services/modelsDevClient.ts+++ b/control-api/src/services/modelsDevClient.ts@@ -88,7 +88,9 @@ export type RawModelsDevCatalog = Record<string, RawModelsDevProvider>* only ever review candidates — the operator's hand-added `source='manual'`* rows (deployment names, `us.anthropic.*` profiles) are never touched (§11.2).*/-export const PROVIDER_KEY_MAP: Readonly<Record<LlmProviderId, string>> = {+export type ModelsDevMappedProviderId = Exclude<LlmProviderId, 'codex-subscription'>++export const PROVIDER_KEY_MAP: Readonly<Record<ModelsDevMappedProviderId, string>> = {openai: 'openai',claude: 'anthropic',zai: 'zai-coding-plan',@@ -397,7 +399,7 @@ export function mapCatalogToProviders(): Record<LlmProviderId, DiscoveredModel[]> {const out = Object.create(null) as Record<LlmProviderId, DiscoveredModel[]>for (const providerId of PROVIDER_IDS) {- const key = PROVIDER_KEY_MAP[providerId]+ const key = providerId === 'codex-subscription' ? undefined : PROVIDER_KEY_MAP[providerId]const entry = key ? catalog[key] : undefinedconst models: DiscoveredModel[] = []out[providerId] = modelsdiff --git a/control-api/test/helpers/modelsDevFixtures.ts b/control-api/test/helpers/modelsDevFixtures.tsindex cc302ff17..229cd53f3 100644--- a/control-api/test/helpers/modelsDevFixtures.ts+++ b/control-api/test/helpers/modelsDevFixtures.ts@@ -15,6 +15,9 @@ import {/** models.dev provider KEY for one of our provider ids (e.g. 'claude' → 'anthropic'). */export function providerKey(id: LlmProviderId): string {+ if (id === 'codex-subscription') {+ throw new Error('providerKey: codex-subscription is not a models.dev catalog source')+ }return PROVIDER_KEY_MAP[id]}diff --git a/control-api/test/llmProviders.test.ts b/control-api/test/llmProviders.test.tsindex 842006b5d..5382bf447 100644--- a/control-api/test/llmProviders.test.ts+++ b/control-api/test/llmProviders.test.ts@@ -1,11 +1,15 @@import { describe, expect, it } from 'vitest'import {+ PROVIDER_AUTH_MODE,PROVIDER_CREDENTIAL_SLOTS,PROVIDER_DISPLAY_LABELS,PROVIDER_IDS,+ PROVIDER_MODEL_CATALOG_MODE,PROVIDER_NON_SECRET_ENV,isCredentialSlotOwnedByProvider,isLlmProviderId,+ providerDescriptor,+ requireStaticCredentialSlot,} from '@clerum/llm-providers'// Unit tests for the shared @clerum/llm-providers package (spec §3-R4). Hosted@@ -13,7 +17,7 @@ import {// (same convention as @clerum/image-policy → control-api/test/imagePolicy.test.ts).describe('PROVIDER_IDS', () => {- it('is the canonical 22-provider set in auto-detect priority order', () => {+ it('is the canonical 22 static providers plus the Codex broker', () => {expect([...PROVIDER_IDS]).toEqual(['openai','claude',@@ -37,14 +41,19 @@ describe('PROVIDER_IDS', () => {'novita','minimax','azure',+ 'codex-subscription',])})- it('has a display label and a credential-slot entry for every id', () => {+ it('has a display label for every id and credential slots only for static providers', () => {for (const id of PROVIDER_IDS) {expect(PROVIDER_DISPLAY_LABELS[id]).toBeTruthy()- expect(PROVIDER_CREDENTIAL_SLOTS[id].length).toBeGreaterThan(0)expect(PROVIDER_NON_SECRET_ENV[id]).toBeInstanceOf(Array)+ if (id === 'codex-subscription') {+ expect(PROVIDER_CREDENTIAL_SLOTS[id]).toEqual([])+ } else {+ expect(PROVIDER_CREDENTIAL_SLOTS[id].length).toBeGreaterThan(0)+ }}})})@@ -161,3 +170,23 @@ describe('non-secret per-Host env', () => {}})})++describe('codex-subscription descriptor', () => {+ it('is an oauth-broker with a dynamic catalog and no static slots', () => {+ expect(providerDescriptor('codex-subscription')).toMatchObject({+ id: 'codex-subscription',+ authMode: 'oauth-broker',+ modelCatalogMode: 'dynamic',+ credentialSlots: [],+ nonSecretEnv: [],+ })+ expect(PROVIDER_AUTH_MODE['codex-subscription']).toBe('oauth-broker')+ expect(PROVIDER_MODEL_CATALOG_MODE['codex-subscription']).toBe('dynamic')+ })++ it('rejects the static credential helper for a broker', () => {+ expect(() => requireStaticCredentialSlot(providerDescriptor('codex-subscription'))).toThrow(+ /static credential helper/+ )+ })+})diff --git a/control-api/test/services.modelsDevClient.test.ts b/control-api/test/services.modelsDevClient.test.tsindex a5096f995..2617ff477 100644--- a/control-api/test/services.modelsDevClient.test.ts+++ b/control-api/test/services.modelsDevClient.test.ts@@ -37,12 +37,14 @@ const FIXTURE: RawModelsDevCatalog = {}describe('modelsDevClient — PROVIDER_KEY_MAP', () => {- it('maps every one of our 22 providers to a models.dev key', () => {- for (const id of PROVIDER_IDS) {+ it('maps every static provider to a models.dev key and excludes the Codex broker', () => {+ const staticIds = PROVIDER_IDS.filter(id => id !== 'codex-subscription')+ for (const id of staticIds) {expect(typeof PROVIDER_KEY_MAP[id]).toBe('string')expect(PROVIDER_KEY_MAP[id].length).toBeGreaterThan(0)}- expect(Object.keys(PROVIDER_KEY_MAP).sort()).toEqual([...PROVIDER_IDS].sort())+ expect(Object.keys(PROVIDER_KEY_MAP).sort()).toEqual([...staticIds].sort())+ expect('codex-subscription' in PROVIDER_KEY_MAP).toBe(false)})it('pins the non-obvious / ambiguous choices (zai coding-plan, bailian→alibaba)', () => {diff --git a/control-ui/lib/__tests__/llm.test.ts b/control-ui/lib/__tests__/llm.test.tsindex 8843afd89..d340658f5 100644--- a/control-ui/lib/__tests__/llm.test.ts+++ b/control-ui/lib/__tests__/llm.test.ts@@ -60,8 +60,10 @@ describe('resolveDefaultModel', () => {it('prefers the static provider default when it is enabled', () => {const enabled = getModelOptions(CATALOG, 'claude')// Seed the static default into the enabled list to exercise the happy path.- const withDefault = [...enabled, LLM_DEFAULT_MODEL_BY_PROVIDER.claude]- expect(resolveDefaultModel('claude', withDefault)).toBe(LLM_DEFAULT_MODEL_BY_PROVIDER.claude)+ const claudeDefault = LLM_DEFAULT_MODEL_BY_PROVIDER.claude+ expect(claudeDefault).toBeDefined()+ const withDefault = [...enabled, claudeDefault!]+ expect(resolveDefaultModel('claude', withDefault)).toBe(claudeDefault)})it('falls back to the first enabled model when the default is not allowed', () => {@@ -120,6 +122,14 @@ describe('LLM_CREDENTIAL_GROUPS (spec R4.5.1/R4.5.2)', () => {expect(vertex.slots[0].multiline).toBe(true)expect(vertex.nonSecretEnv).toEqual(expect.arrayContaining(['VERTEX_PROJECT_ID']))})++ it('models Codex as a zero-slot broker with no static default model', () => {+ const codex = LLM_CREDENTIAL_GROUPS.find(g => g.provider === 'codex-subscription')!+ expect(codex.slots).toEqual([])+ expect(codex.nonSecretEnv).toEqual([])+ expect(LLM_DEFAULT_MODEL_BY_PROVIDER['codex-subscription']).toBeUndefined()+ expect(resolveDefaultModel('codex-subscription', ['gpt-5.1'])).toBe('gpt-5.1')+ })})describe('getLlmGroupCompleteness (spec R4.5.5)', () => {diff --git a/control-ui/lib/llm.ts b/control-ui/lib/llm.tsindex d9c27a41a..464ce8c86 100644--- a/control-ui/lib/llm.ts+++ b/control-ui/lib/llm.ts@@ -63,7 +63,7 @@ export type LlmModelCatalogEntry = {// absorb it into the shared providers package. When this default is not// enabled in the allowlist, `resolveDefaultModel()` falls back to the first// enabled model of the provider.-export const LLM_DEFAULT_MODEL_BY_PROVIDER: Record<LlmProvider, string> = {+export const LLM_DEFAULT_MODEL_BY_PROVIDER: Partial<Record<LlmProvider, string>> = {openai: 'gpt-5.4-mini',claude: 'claude-sonnet-4-6',zai: 'glm-5.1',diff --git a/mcp-host/src/config.devProvider.test.ts b/mcp-host/src/config.devProvider.test.tsindex fd1a1297c..49023b20a 100644--- a/mcp-host/src/config.devProvider.test.ts+++ b/mcp-host/src/config.devProvider.test.ts@@ -31,5 +31,6 @@ describe('resolveDevModelProvider', () => {expect(() => resolveDevModelProvider('zaii')).toThrow(new RegExp(`Valid providers: ${ALL_PROVIDERS.join(', ')}`))+ expect(ALL_PROVIDERS).toContain('codex-subscription')})})diff --git a/mcp-host/src/config.ts b/mcp-host/src/config.tsindex dc58d5ed0..5852b2c11 100644--- a/mcp-host/src/config.ts+++ b/mcp-host/src/config.ts@@ -414,7 +414,11 @@ function parseDevHostConfig(): HostSpec | undefined {* model per provider comes straight from the registry descriptor.*/function getDefaultModel(provider: LlmProvider): string {- return descriptorFor(provider).defaultModel+ const model = descriptorFor(provider).defaultModel+ if (!model) {+ throw new Error(`[Config] provider '${provider}' requires an explicit model`)+ }+ return model}function buildDevHostConfig(provider?: LlmProvider, modelName?: string): HostSpec {diff --git a/mcp-host/src/config/configStore.ts b/mcp-host/src/config/configStore.tsindex 55090b328..f9001af1f 100644--- a/mcp-host/src/config/configStore.ts+++ b/mcp-host/src/config/configStore.ts@@ -53,8 +53,11 @@ export type { LlmProvider }* Exported for status/debug callers that key on the primary env name.*/export const PROVIDER_ENV_NAME = Object.fromEntries(- ALL_PROVIDERS.map(p => [p, primarySlot(descriptorFor(p)).envName])-) as Record<LlmProvider, string>+ ALL_PROVIDERS.filter(p => descriptorFor(p).authMode === 'static-credentials').map(p => [+ p,+ primarySlot(descriptorFor(p)).envName,+ ])+) as Record<Exclude<LlmProvider, 'codex-subscription'>, string>/*** Every provider credential env var name across ALL providers and ALL theirdiff --git a/mcp-host/src/llm/__tests__/makeProvider.throws.test.ts b/mcp-host/src/llm/__tests__/makeProvider.throws.test.tsindex e67f361fc..0c4bead9d 100644--- a/mcp-host/src/llm/__tests__/makeProvider.throws.test.ts+++ b/mcp-host/src/llm/__tests__/makeProvider.throws.test.ts@@ -36,3 +36,11 @@ describe('makeProvider — divergent provider without a factory', () => {)})})++describe('makeProvider — Codex broker', () => {+ it('fails closed without runtime authorizer/proxy dependencies', () => {+ expect(() => makeProvider('codex-subscription', {})).toThrow(+ /requires an explicit model and runtime authorizer/+ )+ })+})diff --git a/mcp-host/src/llm/__tests__/registry.test.ts b/mcp-host/src/llm/__tests__/registry.test.tsindex eb8b107ef..c14eab7f7 100644--- a/mcp-host/src/llm/__tests__/registry.test.ts+++ b/mcp-host/src/llm/__tests__/registry.test.ts@@ -6,8 +6,9 @@* guard in `isLlmProvider` (§1), and the factory fail-safe (§5.7).*/import { describe, expect, it } from 'vitest'-import { createLLMProvider } from '../index'-import { ALL_PROVIDERS, descriptorFor, isLlmProvider } from '../registryCore'+import { apiKeysFromEnv, createLLMProvider } from '../index'+import { makeProvider } from '../registry'+import { ALL_PROVIDERS, descriptorFor, isLlmProvider, primarySlot } from '../registryCore'describe('provider registry — auto-detection order (§5.9)', () => {it('preserves the dev priority prefix openai > claude > zai > bailian > vertex > bedrock', () => {@@ -27,8 +28,12 @@ describe('provider registry — auto-detection order (§5.9)', () => {])})- it('registers all 22 canonical providers and every R6 addition', () => {- expect(ALL_PROVIDERS).toHaveLength(22)+ it('registers all 22 static providers plus the Codex broker', () => {+ expect(+ ALL_PROVIDERS.filter(p => descriptorFor(p).authMode === 'static-credentials')+ ).toHaveLength(22)+ expect(ALL_PROVIDERS).toContain('codex-subscription')+ expect(ALL_PROVIDERS).toHaveLength(23)for (const p of ['openrouter','gemini',@@ -187,3 +192,38 @@ describe('createLLMProvider — fail-safe (§5.7)', () => {expect(internals.client.baseURL).toBe(desc.baseURL)})})++describe('codex-subscription zero-slot broker', () => {+ it('exposes oauth-broker/dynamic metadata with no slots or defaultModel', () => {+ expect(descriptorFor('codex-subscription')).toMatchObject({+ authMode: 'oauth-broker',+ modelCatalogMode: 'dynamic',+ credentialSlots: [],+ nonSecretEnv: [],+ })+ expect(descriptorFor('codex-subscription').credentialSlots).toEqual([])+ expect(descriptorFor('codex-subscription').defaultModel).toBeUndefined()+ })++ it('rejects the static credential helper for a broker', () => {+ expect(() => primarySlot(descriptorFor('codex-subscription'))).toThrow(+ /static credential helper/+ )+ })++ it('does not autodetect Codex from env API keys', () => {+ const keys = apiKeysFromEnv({+ OPENAI_API_KEY: 'sk-test',+ CODEX_SUBSCRIPTION_API_KEY: 'should-not-count',+ })+ expect(keys.openai).toBeDefined()+ expect(keys['codex-subscription']).toBeUndefined()+ })++ it('fails closed when constructing Codex without runtime dependencies', () => {+ expect(() => makeProvider('codex-subscription', {})).toThrow(+ /requires an explicit model and runtime authorizer/+ )+ expect(createLLMProvider({}, { provider: 'codex-subscription', name: 'gpt-5.1' })).toBeNull()+ })+})diff --git a/mcp-host/src/llm/index.ts b/mcp-host/src/llm/index.tsindex b6247f16c..1f93bd979 100644--- a/mcp-host/src/llm/index.ts+++ b/mcp-host/src/llm/index.ts@@ -67,6 +67,7 @@ export function createLLMProvider(export function apiKeysFromEnv(env: NodeJS.ProcessEnv = process.env): ApiKeys {const keys: ApiKeys = {}for (const p of ALL_PROVIDERS) {+ if (descriptorFor(p).authMode !== 'static-credentials') continueconst slots = descriptorFor(p).credentialSlotsconst bag: Record<string, string> = {}for (const slot of slots) {diff --git a/mcp-host/src/llm/registry.ts b/mcp-host/src/llm/registry.tsindex c31ae344f..485327ab4 100644--- a/mcp-host/src/llm/registry.ts+++ b/mcp-host/src/llm/registry.ts@@ -78,12 +78,19 @@ export function makeProvider(// it deliberately has NO static baseURL and must not hit the data arm// below. Fails closed (throws) if the operator omitted the endpoint.return new AzureOpenAIProvider(credentials[primarySlot(d).dataKey], model ?? d.defaultModel)+ case 'codex-subscription':+ throw new Error(+ '[LLM] makeProvider: codex-subscription requires an explicit model and runtime authorizer/proxy dependencies'+ )}// Data-driven arm: anything carrying a baseURL is OpenAI-compatible and is// built straight from its descriptor — no per-id branch. A new divergent// (own-SDK) provider must instead add its own case above.if (d.baseURL) {+ if (!d.defaultModel) {+ throw new Error(`[LLM] makeProvider: provider '${d.id}' requires a defaultModel`)+ }return new OpenAICompatibleProvider({ id: d.id, baseURL: d.baseURL, defaultModel: d.defaultModel },credentials[primarySlot(d).dataKey],diff --git a/mcp-host/src/llm/registryCore.ts b/mcp-host/src/llm/registryCore.tsindex 787f27bac..106f317af 100644--- a/mcp-host/src/llm/registryCore.ts+++ b/mcp-host/src/llm/registryCore.ts@@ -20,9 +20,15 @@import {type CredentialSlot,type LlmProviderId,+ PROVIDER_AUTH_MODE,PROVIDER_CREDENTIAL_SLOTS,PROVIDER_IDS,+ PROVIDER_MODEL_CATALOG_MODE,+ PROVIDER_NON_SECRET_ENV,+ type ProviderAuthMode,+ type ProviderModelCatalogMode,isLlmProviderId,+ requireStaticCredentialSlot,} from '@clerum/llm-providers'/**@@ -48,14 +54,18 @@ export type { CredentialSlot }export interface CoreProviderDescriptor {/** Canonical id, == getProviderType(). */id: string+ authMode: ProviderAuthMode+ modelCatalogMode: ProviderModelCatalogMode/*** Credentials this provider loads from the LLM Secret, in priority order- * (the first is the "primary" slot — see {@link primarySlot}). Every- * provider has at least one slot.+ * (the first is the "primary" slot — see {@link primarySlot}). Static+ * providers have at least one slot; oauth-broker providers have none.*/credentialSlots: CredentialSlot[]- /** Default model when the Host does not specify one. */- defaultModel: string+ /** Non-secret per-Host env vars. Empty for brokers and single-key providers. */+ nonSecretEnv: readonly { envName: string; required: boolean }[]+ /** Default model when the Host does not specify one. Absent for brokers. */+ defaultModel?: string/*** Base URL for OpenAI-compatible providers (zai, bailian). Absent for* providers that bring their own SDK/client (openai, claude, vertex, bedrock).@@ -80,7 +90,7 @@ export type LlmProvider = LlmProviderId* `@clerum/llm-providers`.*/interface RuntimeProviderFields {- defaultModel: string+ defaultModel?: string/** Base URL for OpenAI-compatible providers (zai, bailian). */baseURL?: stringtokenizer: CoreProviderDescriptor['tokenizer']@@ -189,6 +199,8 @@ const RUNTIME_FIELDS: Record<LlmProvider, RuntimeProviderFields> = {// data-driven baseURL arm. Tokenizer 'openai' (it serves OpenAI models) and// defaultModel is the Azure DEPLOYMENT name the operator expects by default.azure: { defaultModel: 'gpt-4.1', tokenizer: 'openai' },+ // Broker: explicit model required later; no Secret slot and no default.+ 'codex-subscription': { tokenizer: 'fallback' },}// Order = dev auto-detection priority (first present key wins), inherited from@@ -198,7 +210,14 @@ const RUNTIME_FIELDS: Record<LlmProvider, RuntimeProviderFields> = {export const PROVIDERS: Record<LlmProvider, CoreProviderDescriptor> = Object.fromEntries(PROVIDER_IDS.map(id => [id,- { id, credentialSlots: [...PROVIDER_CREDENTIAL_SLOTS[id]], ...RUNTIME_FIELDS[id] },+ {+ id,+ authMode: PROVIDER_AUTH_MODE[id],+ modelCatalogMode: PROVIDER_MODEL_CATALOG_MODE[id],+ credentialSlots: [...PROVIDER_CREDENTIAL_SLOTS[id]],+ nonSecretEnv: [...PROVIDER_NON_SECRET_ENV[id]],+ ...RUNTIME_FIELDS[id],+ },])) as Record<LlmProvider, CoreProviderDescriptor>@@ -216,7 +235,7 @@ export const ALL_PROVIDERS = [...PROVIDER_IDS] as LlmProvider[]* fallback slots (R5) are never leaked to a subprocess.*/export function primarySlot(d: CoreProviderDescriptor): CredentialSlot {- return d.credentialSlots[0]+ return requireStaticCredentialSlot(d)}/**diff --git a/mcp-host/src/main.ts b/mcp-host/src/main.tsindex c549f166d..4ecb31d3b 100644--- a/mcp-host/src/main.ts+++ b/mcp-host/src/main.ts@@ -2785,9 +2785,13 @@ async function startDevMode(): Promise<void> {// Safe `!`: the `ALL_PROVIDERS.every(p => !keys[p])` throw-guard above// already proved at least one key is present.const provider = ALL_PROVIDERS.find(p => keys[p])!+ const defaultModel = descriptorFor(provider).defaultModel+ if (!defaultModel) {+ throw new Error(`[Main] auto-detected provider '${provider}' requires an explicit model`)+ }hostSpec = {...hostSpec,- model: { provider, name: descriptorFor(provider).defaultModel },+ model: { provider, name: defaultModel },}console.log(`[Main] Auto-detected provider: ${provider} (based on available API key)`)}diff --git a/packages/llm-providers/index.cjs b/packages/llm-providers/index.cjsindex b38412052..b40537872 100644--- a/packages/llm-providers/index.cjs+++ b/packages/llm-providers/index.cjs@@ -51,6 +51,8 @@ const PROVIDER_IDS = Object.freeze(['minimax',// Light-driver (OpenAI-compatible shape, non-vanilla auth/host).'azure',+ // OAuth-broker subscription provider. Not part of env-key autodetection.+ 'codex-subscription',])// Model identifiers are transport selectors, not arbitrary user text. Keep@@ -69,7 +71,8 @@ function apiKeySlot(dataKey, envName) {/*** Credentials each provider loads from the LLM Secret, in priority order (the- * first is the "primary" slot). Every provider has at least one slot.+ * first is the "primary" slot). Static-credential providers have at least one+ * slot; oauth-broker providers have none.* @type {Record<string, ReadonlyArray<{dataKey: string, envName: string, required: boolean, multiline?: boolean}>>}*/const PROVIDER_CREDENTIAL_SLOTS = Object.freeze({@@ -116,6 +119,8 @@ const PROVIDER_CREDENTIAL_SLOTS = Object.freeze({minimax: apiKeySlot('minimax-api-key', 'MINIMAX_API_KEY'),// Azure: one API key, sent via the `api-key` header (driver concern, not here).azure: apiKeySlot('azure-openai-api-key', 'AZURE_OPENAI_API_KEY'),+ // Subscription broker: zero Secret slots. Env autodetection must never pick it.+ 'codex-subscription': Object.freeze([]),})/**@@ -145,6 +150,7 @@ const PROVIDER_DISPLAY_LABELS = Object.freeze({novita: 'Novita AI',minimax: 'MiniMax',azure: 'Azure OpenAI',+ 'codex-subscription': 'OpenAI Codex Subscription',})/**@@ -186,6 +192,7 @@ const PROVIDER_NON_SECRET_ENV = Object.freeze({Object.freeze({ envName: 'AZURE_OPENAI_ENDPOINT', required: true }),Object.freeze({ envName: 'AZURE_OPENAI_API_VERSION', required: false }),]),+ 'codex-subscription': Object.freeze([]),})// SECURITY: use an own-property check, NOT `in`. `in` walks the prototype chain@@ -214,6 +221,45 @@ function isCredentialSlotOwnedByProvider(provider, credentialSlot) {return canonical.includes(credentialSlot)}+/** @type {Record<string, 'static-credentials' | 'oauth-broker'>} */+const PROVIDER_AUTH_MODE = Object.freeze(+ Object.fromEntries(+ PROVIDER_IDS.map(id => [id, id === 'codex-subscription' ? 'oauth-broker' : 'static-credentials'])+ )+)++/** @type {Record<string, 'static' | 'dynamic'>} */+const PROVIDER_MODEL_CATALOG_MODE = Object.freeze(+ Object.fromEntries(PROVIDER_IDS.map(id => [id, id === 'codex-subscription' ? 'dynamic' : 'static']))+)++function providerDescriptor(id) {+ if (!isLlmProviderId(id)) {+ throw new Error(`[llm-providers] unknown provider '${String(id)}'`)+ }+ return Object.freeze({+ id,+ displayLabel: PROVIDER_DISPLAY_LABELS[id],+ authMode: PROVIDER_AUTH_MODE[id],+ modelCatalogMode: PROVIDER_MODEL_CATALOG_MODE[id],+ credentialSlots: PROVIDER_CREDENTIAL_SLOTS[id],+ nonSecretEnv: PROVIDER_NON_SECRET_ENV[id],+ })+}++function requireStaticCredentialSlot(descriptor) {+ if (!descriptor || descriptor.authMode !== 'static-credentials') {+ throw new Error(+ `[llm-providers] static credential helper rejects authMode '${descriptor && descriptor.authMode}'`+ )+ }+ const slot = descriptor.credentialSlots && descriptor.credentialSlots[0]+ if (!slot) {+ throw new Error('[llm-providers] static credential helper requires a primary slot')+ }+ return slot+}+module.exports = {PROVIDER_IDS,RUNNABLE_LLM_MODEL_ID_MAX_LENGTH,@@ -221,7 +267,11 @@ module.exports = {PROVIDER_CREDENTIAL_SLOTS,PROVIDER_DISPLAY_LABELS,PROVIDER_NON_SECRET_ENV,+ PROVIDER_AUTH_MODE,+ PROVIDER_MODEL_CATALOG_MODE,isCredentialSlotOwnedByProvider,isLlmProviderId,isRunnableLlmModelId,+ providerDescriptor,+ requireStaticCredentialSlot,}diff --git a/packages/llm-providers/index.d.ts b/packages/llm-providers/index.d.tsindex a5177bb88..80d53800c 100644--- a/packages/llm-providers/index.d.ts+++ b/packages/llm-providers/index.d.ts@@ -28,6 +28,7 @@ export declare const PROVIDER_IDS: readonly ['novita','minimax','azure',+ 'codex-subscription',]/** Union of the canonical provider ids. */@@ -89,3 +90,23 @@ export declare function isCredentialSlotOwnedByProvider(provider: string,credentialSlot: string,): boolean++export type ProviderAuthMode = 'static-credentials' | 'oauth-broker'+export type ProviderModelCatalogMode = 'static' | 'dynamic'++export interface ProviderDescriptor {+ id: LlmProviderId+ displayLabel: string+ authMode: ProviderAuthMode+ modelCatalogMode: ProviderModelCatalogMode+ credentialSlots: readonly CredentialSlot[]+ nonSecretEnv: readonly NonSecretEnvVar[]+ defaultModel?: string+}++export declare const PROVIDER_AUTH_MODE: Record<LlmProviderId, ProviderAuthMode>+export declare const PROVIDER_MODEL_CATALOG_MODE: Record<LlmProviderId, ProviderModelCatalogMode>+export declare function providerDescriptor(id: LlmProviderId): ProviderDescriptor+export declare function requireStaticCredentialSlot(+ descriptor: Pick<ProviderDescriptor, 'authMode' | 'credentialSlots'>,+): CredentialSlot