From 1814c81888ae8adb5a2f02b30d4219840d068e53 Mon Sep 17 00:00:00 2001 From: Danny Avila Date: Fri, 21 Nov 2025 14:25:05 -0500 Subject: [PATCH] =?UTF-8?q?=F0=9F=95=B8=EF=B8=8F=20fix:=20Minor=20Type=20I?= =?UTF-8?q?ssues=20&=20Anthropic=20Web=20Search=20(#10618)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: update @librechat/agents dependency to version 3.0.29 * chore: fix typing by replacing TUser with IUser * chore: import order * fix: replace TUser with IUser in run and OAuthReconnectionManager modules * fix: update @librechat/agents dependency to version 3.0.30 --- api/package.json | 2 +- package-lock.json | 10 +++++----- packages/api/package.json | 2 +- packages/api/src/agents/run.ts | 3 ++- packages/api/src/mcp/MCPManager.ts | 7 +++---- .../src/mcp/oauth/OAuthReconnectionManager.ts | 5 ++--- packages/api/src/mcp/types/index.ts | 8 ++++---- packages/api/src/utils/env.ts | 16 ++++++++-------- packages/api/src/utils/oidc.ts | 5 +---- 9 files changed, 27 insertions(+), 31 deletions(-) diff --git a/api/package.json b/api/package.json index 1e57967e6a..4a011b33b5 100644 --- a/api/package.json +++ b/api/package.json @@ -47,7 +47,7 @@ "@langchain/google-genai": "^0.2.13", "@langchain/google-vertexai": "^0.2.13", "@langchain/textsplitters": "^0.1.0", - "@librechat/agents": "^3.0.27", + "@librechat/agents": "^3.0.30", "@librechat/api": "*", "@librechat/data-schemas": "*", "@microsoft/microsoft-graph-client": "^3.0.7", diff --git a/package-lock.json b/package-lock.json index 4da9b4e26c..da281442fb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -63,7 +63,7 @@ "@langchain/google-genai": "^0.2.13", "@langchain/google-vertexai": "^0.2.13", "@langchain/textsplitters": "^0.1.0", - "@librechat/agents": "^3.0.27", + "@librechat/agents": "^3.0.30", "@librechat/api": "*", "@librechat/data-schemas": "*", "@microsoft/microsoft-graph-client": "^3.0.7", @@ -16426,9 +16426,9 @@ } }, "node_modules/@librechat/agents": { - "version": "3.0.27", - "resolved": "https://registry.npmjs.org/@librechat/agents/-/agents-3.0.27.tgz", - "integrity": "sha512-4xMzWdPgzYhEkbgGgwYx9/fIpYa9CDEupyTvYllR1sZQ8inBeByA8sMW3aTnaC+euAHZP0oVYs4Uw3J1SB0Mag==", + "version": "3.0.30", + "resolved": "https://registry.npmjs.org/@librechat/agents/-/agents-3.0.30.tgz", + "integrity": "sha512-EJLo6GqXH0tefpdrhMnoiVwhFupS3K9I0xXAKCn+6greIhdZV1IlsYRxu+NXoK+xaFJBJeMkAb0E9Oih61NxoA==", "license": "MIT", "dependencies": { "@langchain/anthropic": "^0.3.26", @@ -47440,7 +47440,7 @@ "@azure/storage-blob": "^12.27.0", "@keyv/redis": "^4.3.3", "@langchain/core": "^0.3.79", - "@librechat/agents": "^3.0.27", + "@librechat/agents": "^3.0.30", "@librechat/data-schemas": "*", "@modelcontextprotocol/sdk": "^1.21.0", "axios": "^1.12.1", diff --git a/packages/api/package.json b/packages/api/package.json index 82107c38fc..e67e47ac6a 100644 --- a/packages/api/package.json +++ b/packages/api/package.json @@ -84,7 +84,7 @@ "@azure/storage-blob": "^12.27.0", "@keyv/redis": "^4.3.3", "@langchain/core": "^0.3.79", - "@librechat/agents": "^3.0.27", + "@librechat/agents": "^3.0.30", "@librechat/data-schemas": "*", "@modelcontextprotocol/sdk": "^1.21.0", "axios": "^1.12.1", diff --git a/packages/api/src/agents/run.ts b/packages/api/src/agents/run.ts index 5df80c5f39..8124b26d61 100644 --- a/packages/api/src/agents/run.ts +++ b/packages/api/src/agents/run.ts @@ -9,6 +9,7 @@ import type { RunConfig, IState, } from '@librechat/agents'; +import type { IUser } from '@librechat/data-schemas'; import type { Agent } from 'librechat-data-provider'; import type * as t from '~/types'; import { resolveHeaders, createSafeUser } from '~/utils/env'; @@ -79,7 +80,7 @@ export async function createRun({ streaming?: boolean; streamUsage?: boolean; requestBody?: t.RequestBody; - user?: t.TUser; + user?: IUser; } & Pick): Promise< Run > { diff --git a/packages/api/src/mcp/MCPManager.ts b/packages/api/src/mcp/MCPManager.ts index 1e0d483f17..c1442bdeba 100644 --- a/packages/api/src/mcp/MCPManager.ts +++ b/packages/api/src/mcp/MCPManager.ts @@ -2,9 +2,8 @@ import pick from 'lodash/pick'; import { logger } from '@librechat/data-schemas'; import { CallToolResultSchema, ErrorCode, McpError } from '@modelcontextprotocol/sdk/types.js'; import type { RequestOptions } from '@modelcontextprotocol/sdk/shared/protocol.js'; -import type { TokenMethods } from '@librechat/data-schemas'; +import type { TokenMethods, IUser } from '@librechat/data-schemas'; import type { FlowStateManager } from '~/flow/manager'; -import type { TUser } from 'librechat-data-provider'; import type { MCPOAuthTokens } from './oauth'; import type { RequestBody } from '~/types'; import type * as t from './types'; @@ -49,7 +48,7 @@ export class MCPManager extends UserConnectionManager { public async getConnection( args: { serverName: string; - user?: TUser; + user?: IUser; forceNew?: boolean; flowManager?: FlowStateManager; } & Omit, @@ -176,7 +175,7 @@ Please follow these instructions when using tools from the respective MCP server oauthEnd, customUserVars, }: { - user?: TUser; + user?: IUser; serverName: string; toolName: string; provider: t.Provider; diff --git a/packages/api/src/mcp/oauth/OAuthReconnectionManager.ts b/packages/api/src/mcp/oauth/OAuthReconnectionManager.ts index 25edec7f3a..db81a2ffae 100644 --- a/packages/api/src/mcp/oauth/OAuthReconnectionManager.ts +++ b/packages/api/src/mcp/oauth/OAuthReconnectionManager.ts @@ -1,6 +1,5 @@ import { logger } from '@librechat/data-schemas'; -import type { TokenMethods } from '@librechat/data-schemas'; -import type { TUser } from 'librechat-data-provider'; +import type { TokenMethods, IUser } from '@librechat/data-schemas'; import type { MCPOAuthTokens } from './types'; import { OAuthReconnectionTracker } from './OAuthReconnectionTracker'; import { FlowStateManager } from '~/flow/manager'; @@ -117,7 +116,7 @@ export class OAuthReconnectionManager { // attempt to get connection (this will use existing tokens and refresh if needed) const connection = await this.mcpManager.getUserConnection({ serverName, - user: { id: userId } as TUser, + user: { id: userId } as IUser, flowManager: this.flowManager, tokenMethods: this.tokenMethods, // don't force new connection, let it reuse existing or create new as needed diff --git a/packages/api/src/mcp/types/index.ts b/packages/api/src/mcp/types/index.ts index 6e445e26ad..cc78ef720a 100644 --- a/packages/api/src/mcp/types/index.ts +++ b/packages/api/src/mcp/types/index.ts @@ -1,16 +1,16 @@ import { z } from 'zod'; import { + Tools, SSEOptionsSchema, MCPOptionsSchema, MCPServersSchema, StdioOptionsSchema, WebSocketOptionsSchema, StreamableHTTPOptionsSchema, - Tools, } from 'librechat-data-provider'; -import type { SearchResultData, UIResource, TPlugin, TUser } from 'librechat-data-provider'; +import type { SearchResultData, UIResource, TPlugin } from 'librechat-data-provider'; +import type { TokenMethods, JsonSchemaType, IUser } from '@librechat/data-schemas'; import type * as t from '@modelcontextprotocol/sdk/types.js'; -import type { TokenMethods, JsonSchemaType } from '@librechat/data-schemas'; import type { FlowStateManager } from '~/flow/manager'; import type { RequestBody } from '~/types/http'; import type * as o from '~/mcp/oauth/types'; @@ -161,7 +161,7 @@ export interface BasicConnectionOptions { } export interface OAuthConnectionOptions { - user: TUser; + user: IUser; useOAuth: true; requestBody?: RequestBody; customUserVars?: Record; diff --git a/packages/api/src/utils/env.ts b/packages/api/src/utils/env.ts index 81c7f3923b..86e60cfce9 100644 --- a/packages/api/src/utils/env.ts +++ b/packages/api/src/utils/env.ts @@ -1,5 +1,5 @@ import { extractEnvVariable } from 'librechat-data-provider'; -import type { TUser, MCPOptions } from 'librechat-data-provider'; +import type { MCPOptions } from 'librechat-data-provider'; import type { IUser } from '@librechat/data-schemas'; import type { RequestBody } from '~/types'; import { extractOpenIDTokenInfo, processOpenIDPlaceholders, isOpenIDTokenValid } from './oidc'; @@ -71,7 +71,7 @@ const ALLOWED_BODY_FIELDS = ['conversationId', 'parentMessageId', 'messageId'] a * @param user - The user object * @returns The processed string with placeholders replaced */ -function processUserPlaceholders(value: string, user?: TUser): string { +function processUserPlaceholders(value: string, user?: IUser): string { if (!user || typeof value !== 'string') { return value; } @@ -82,7 +82,7 @@ function processUserPlaceholders(value: string, user?: TUser): string { continue; } - const fieldValue = user[field as keyof TUser]; + const fieldValue = user[field as keyof IUser]; // Skip replacement if field doesn't exist in user object if (!(field in user)) { @@ -141,7 +141,7 @@ function processSingleValue({ }: { originalValue: string; customUserVars?: Record; - user?: TUser; + user?: IUser; body?: RequestBody; }): string { let value = originalValue; @@ -182,7 +182,7 @@ function processSingleValue({ */ export function processMCPEnv(params: { options: Readonly; - user?: TUser; + user?: IUser; customUserVars?: Record; body?: RequestBody; }): MCPOptions { @@ -227,7 +227,7 @@ export function processMCPEnv(params: { // Process OAuth configuration if it exists (for all transport types) if ('oauth' in newObj && newObj.oauth) { - const processedOAuth: Record = {}; + const processedOAuth: Record = {}; for (const [key, originalValue] of Object.entries(newObj.oauth)) { // Only process string values for environment variables // token_exchange_method is an enum and shouldn't be processed @@ -255,7 +255,7 @@ export function processMCPEnv(params: { */ export function resolveHeaders(options?: { headers: Record | undefined; - user?: Partial | { id: string }; + user?: Partial | { id: string }; body?: RequestBody; customUserVars?: Record; }) { @@ -269,7 +269,7 @@ export function resolveHeaders(options?: { resolvedHeaders[key] = processSingleValue({ originalValue: inputHeaders[key], customUserVars, - user: user as TUser, + user: user as IUser, body, }); }); diff --git a/packages/api/src/utils/oidc.ts b/packages/api/src/utils/oidc.ts index fb16cdf16f..9c0ac478fd 100644 --- a/packages/api/src/utils/oidc.ts +++ b/packages/api/src/utils/oidc.ts @@ -1,5 +1,4 @@ import { logger } from '@librechat/data-schemas'; -import type { TUser } from 'librechat-data-provider'; import type { IUser } from '@librechat/data-schemas'; export interface OpenIDTokenInfo { @@ -35,9 +34,7 @@ const OPENID_TOKEN_FIELDS = [ 'EXPIRES_AT', ] as const; -export function extractOpenIDTokenInfo( - user: IUser | TUser | null | undefined, -): OpenIDTokenInfo | null { +export function extractOpenIDTokenInfo(user: IUser | null | undefined): OpenIDTokenInfo | null { if (!user) { logger.debug('[extractOpenIDTokenInfo] No user provided'); return null;