refactor: remove type re-exports from @librechat/api tokens

Update all imports of TokenConfig and EndpointTokenConfig to import
directly from librechat-data-provider instead of re-exporting through
packages/api/src/types/tokens.ts. Remove the now-unnecessary re-export
file and its barrel export.
This commit is contained in:
Marco Beretta 2026-02-08 17:36:44 +01:00
parent c7165d7ca1
commit 023696c5d9
No known key found for this signature in database
GPG key ID: D918033D8E74CC11
11 changed files with 583 additions and 38 deletions

View file

@ -8,6 +8,7 @@ import {
isAgentsEndpoint,
replaceSpecialVars,
providerEndpointMap,
getModelMaxTokens,
} from 'librechat-data-provider';
import type {
AgentToolResources,
@ -21,12 +22,7 @@ import type { GenericTool, LCToolRegistry, ToolMap, LCTool } from '@librechat/ag
import type { Response as ServerResponse } from 'express';
import type { IMongoFile } from '@librechat/data-schemas';
import type { InitializeResultBase, ServerRequest, EndpointDbMethods } from '~/types';
import {
optionalChainWithEmptyCheck,
extractLibreChatParams,
getModelMaxTokens,
getThreadData,
} from '~/utils';
import { optionalChainWithEmptyCheck, extractLibreChatParams, getThreadData } from '~/utils';
import { filterFilesByEndpointConfig } from '~/files';
import { generateArtifactsPrompt } from '~/prompts';
import { getProviderConfig } from '~/endpoints';

View file

@ -1,7 +1,7 @@
import { logger } from '@librechat/data-schemas';
import type { TCustomConfig, TTransactionsConfig } from 'librechat-data-provider';
import type { UsageMetadata } from '../stream/interfaces/IJobStore';
import type { EndpointTokenConfig } from '../types/tokens';
import type { EndpointTokenConfig } from 'librechat-data-provider';
interface TokenUsage {
promptTokens?: number;

View file

@ -6,8 +6,8 @@ import {
anthropicSettings,
supportsContext1m,
supportsAdaptiveThinking,
matchModelName,
} from 'librechat-data-provider';
import { matchModelName } from '~/utils/tokens';
/**
* @param {string} modelName

View file

@ -5,9 +5,9 @@ import {
FetchTokenConfig,
extractEnvVariable,
} from 'librechat-data-provider';
import type { TEndpoint } from 'librechat-data-provider';
import type { TEndpoint, EndpointTokenConfig } from 'librechat-data-provider';
import type { AppConfig } from '@librechat/data-schemas';
import type { BaseInitializeParams, InitializeResultBase, EndpointTokenConfig } from '~/types';
import type { BaseInitializeParams, InitializeResultBase } from '~/types';
import { getOpenAIConfig } from '~/endpoints/openai/config';
import { getCustomEndpointConfig } from '~/app/config';
import { fetchModels } from '~/endpoints/models';

View file

@ -1,6 +1,7 @@
import type { ClientOptions, OpenAIClientOptions } from '@librechat/agents';
import type { TConfig } from 'librechat-data-provider';
import type { EndpointTokenConfig, ServerRequest } from '~/types';
import type { EndpointTokenConfig } from 'librechat-data-provider';
import type { ServerRequest } from '~/types';
export type TCustomEndpointsConfig = Partial<{ [key: string]: Omit<TConfig, 'order'> }>;

View file

@ -12,5 +12,4 @@ export * from './mistral';
export type * from './openai';
export * from './prompts';
export * from './run';
export * from './tokens';
export * from './stream';

View file

@ -1,17 +0,0 @@
/** Configuration object mapping model keys to their respective prompt, completion rates, and context limit
*
* Note: the [key: string]: unknown is not in the original JSDoc typedef in /api/typedefs.js, but I've included it since
* getModelMaxOutputTokens calls getModelTokenValue with a key of 'output', which was not in the original JSDoc typedef,
* but would be referenced in a TokenConfig in the if(matchedPattern) portion of getModelTokenValue.
* So in order to preserve functionality for that case and any others which might reference an additional key I'm unaware of,
* I've included it here until the interface can be typed more tightly.
*/
export interface TokenConfig {
prompt: number;
completion: number;
context: number;
[key: string]: unknown;
}
/** An endpoint's config object mapping model keys to their respective prompt, completion rates, and context limit */
export type EndpointTokenConfig = Record<string, TokenConfig>;