mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-08-27 04:07:05 +00:00
fix: restore provider typing against the Agents SDK declarations (#15161)
@librechat/agents publishes its declaration files with its internal @/* path aliases unrewritten, across 112 files. types/llm.d.ts imports Providers that way, so a consumer cannot resolve it, ProviderOptionsMap's computed keys go unresolved, and keyof ProviderOptionsMap collapses to number. Through v3.6.15 that only degraded LLMConfig silently: provider was typed as the unresolved Providers, so everything assigned. v3.6.16 made SharedLLMConfig generic over that key union, turning provider into number | RuntimeProviderName, which nothing real is assignable to. That is the whole of the "Type check @librechat/api" failure on dev. Declaring the one alias llm.d.ts needs restores the enum and the provider key union, taking the package from 20 errors to 4. The remaining 4 were genuine: custom-endpoint specs pass provider: 'custom', which widens to string, and the SDK models a provider outside ProviderOptionsMap as RuntimeProviderName. Mapping every @/* alias instead was tried and rejected here: it unmasks a backlog of roughly 114 latent errors elsewhere in the package, which is a separate cleanup. The real fix belongs upstream, in what the SDK ships.
This commit is contained in:
parent
8773b36eec
commit
c52ba4efdb
2 changed files with 21 additions and 4 deletions
|
|
@ -3,6 +3,7 @@ import { Run, Providers, GraphEvents } from '@librechat/agents';
|
|||
import { AIMessage, HumanMessage } from '@librechat/agents/langchain/messages';
|
||||
import { Tools, MemoryScope, EModelEndpoint, AgentCapabilities } from 'librechat-data-provider';
|
||||
import type { FiltersConfig } from 'librechat-data-provider';
|
||||
import type { RuntimeProviderName } from '@librechat/agents';
|
||||
import type { IUser } from '@librechat/data-schemas';
|
||||
import type { Response } from 'express';
|
||||
import type { ServerRequest } from '~/types';
|
||||
|
|
@ -223,7 +224,7 @@ describe('Memory Agent Header Resolution', () => {
|
|||
|
||||
it('should resolve environment variables in custom endpoint headers', async () => {
|
||||
const llmConfig = {
|
||||
provider: 'custom',
|
||||
provider: 'custom' as RuntimeProviderName,
|
||||
model: 'gpt-4o-mini',
|
||||
configuration: {
|
||||
defaultHeaders: {
|
||||
|
|
@ -258,7 +259,7 @@ describe('Memory Agent Header Resolution', () => {
|
|||
|
||||
it('should resolve user placeholders in custom endpoint headers', async () => {
|
||||
const llmConfig = {
|
||||
provider: 'custom',
|
||||
provider: 'custom' as RuntimeProviderName,
|
||||
model: 'gpt-4o-mini',
|
||||
configuration: {
|
||||
defaultHeaders: {
|
||||
|
|
@ -293,7 +294,7 @@ describe('Memory Agent Header Resolution', () => {
|
|||
|
||||
it('should handle mixed environment variables and user placeholders', async () => {
|
||||
const llmConfig = {
|
||||
provider: 'custom',
|
||||
provider: 'custom' as RuntimeProviderName,
|
||||
model: 'gpt-4o-mini',
|
||||
configuration: {
|
||||
defaultHeaders: {
|
||||
|
|
@ -330,7 +331,7 @@ describe('Memory Agent Header Resolution', () => {
|
|||
|
||||
it('should resolve env vars when user is undefined', async () => {
|
||||
const llmConfig = {
|
||||
provider: 'custom',
|
||||
provider: 'custom' as RuntimeProviderName,
|
||||
model: 'gpt-4o-mini',
|
||||
configuration: {
|
||||
defaultHeaders: {
|
||||
|
|
|
|||
16
packages/api/src/types/agents.d.ts
vendored
Normal file
16
packages/api/src/types/agents.d.ts
vendored
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
/**
|
||||
* `@librechat/agents` publishes its declaration files with its internal `@/*` path aliases
|
||||
* unrewritten, so a consumer cannot resolve them. `types/llm.d.ts` imports `Providers` that
|
||||
* way, which leaves `ProviderOptionsMap`'s computed keys unresolved and collapses
|
||||
* `keyof ProviderOptionsMap` to `number`. Until v3.6.16 that only degraded `LLMConfig`
|
||||
* silently; v3.6.16 made `SharedLLMConfig` generic over that key union, so `provider` became
|
||||
* `number | RuntimeProviderName` and no real provider was assignable to it.
|
||||
*
|
||||
* Declaring the one alias `llm.d.ts` needs restores the enum, and with it the provider key
|
||||
* union. Remove this once the SDK ships declarations with its aliases resolved — note that
|
||||
* mapping every `@/*` alias instead unmasks a large backlog of latent errors elsewhere in
|
||||
* this package, so widening it is a separate cleanup rather than a drop-in improvement.
|
||||
*/
|
||||
declare module '@/common' {
|
||||
export { Providers } from '@librechat/agents';
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue