mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-16 16:30:15 +01:00
🕸️ fix: Minor Type Issues & Anthropic Web Search (#10618)
* 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
This commit is contained in:
parent
846e34b1d7
commit
1814c81888
9 changed files with 27 additions and 31 deletions
|
|
@ -47,7 +47,7 @@
|
||||||
"@langchain/google-genai": "^0.2.13",
|
"@langchain/google-genai": "^0.2.13",
|
||||||
"@langchain/google-vertexai": "^0.2.13",
|
"@langchain/google-vertexai": "^0.2.13",
|
||||||
"@langchain/textsplitters": "^0.1.0",
|
"@langchain/textsplitters": "^0.1.0",
|
||||||
"@librechat/agents": "^3.0.27",
|
"@librechat/agents": "^3.0.30",
|
||||||
"@librechat/api": "*",
|
"@librechat/api": "*",
|
||||||
"@librechat/data-schemas": "*",
|
"@librechat/data-schemas": "*",
|
||||||
"@microsoft/microsoft-graph-client": "^3.0.7",
|
"@microsoft/microsoft-graph-client": "^3.0.7",
|
||||||
|
|
|
||||||
10
package-lock.json
generated
10
package-lock.json
generated
|
|
@ -63,7 +63,7 @@
|
||||||
"@langchain/google-genai": "^0.2.13",
|
"@langchain/google-genai": "^0.2.13",
|
||||||
"@langchain/google-vertexai": "^0.2.13",
|
"@langchain/google-vertexai": "^0.2.13",
|
||||||
"@langchain/textsplitters": "^0.1.0",
|
"@langchain/textsplitters": "^0.1.0",
|
||||||
"@librechat/agents": "^3.0.27",
|
"@librechat/agents": "^3.0.30",
|
||||||
"@librechat/api": "*",
|
"@librechat/api": "*",
|
||||||
"@librechat/data-schemas": "*",
|
"@librechat/data-schemas": "*",
|
||||||
"@microsoft/microsoft-graph-client": "^3.0.7",
|
"@microsoft/microsoft-graph-client": "^3.0.7",
|
||||||
|
|
@ -16426,9 +16426,9 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@librechat/agents": {
|
"node_modules/@librechat/agents": {
|
||||||
"version": "3.0.27",
|
"version": "3.0.30",
|
||||||
"resolved": "https://registry.npmjs.org/@librechat/agents/-/agents-3.0.27.tgz",
|
"resolved": "https://registry.npmjs.org/@librechat/agents/-/agents-3.0.30.tgz",
|
||||||
"integrity": "sha512-4xMzWdPgzYhEkbgGgwYx9/fIpYa9CDEupyTvYllR1sZQ8inBeByA8sMW3aTnaC+euAHZP0oVYs4Uw3J1SB0Mag==",
|
"integrity": "sha512-EJLo6GqXH0tefpdrhMnoiVwhFupS3K9I0xXAKCn+6greIhdZV1IlsYRxu+NXoK+xaFJBJeMkAb0E9Oih61NxoA==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@langchain/anthropic": "^0.3.26",
|
"@langchain/anthropic": "^0.3.26",
|
||||||
|
|
@ -47440,7 +47440,7 @@
|
||||||
"@azure/storage-blob": "^12.27.0",
|
"@azure/storage-blob": "^12.27.0",
|
||||||
"@keyv/redis": "^4.3.3",
|
"@keyv/redis": "^4.3.3",
|
||||||
"@langchain/core": "^0.3.79",
|
"@langchain/core": "^0.3.79",
|
||||||
"@librechat/agents": "^3.0.27",
|
"@librechat/agents": "^3.0.30",
|
||||||
"@librechat/data-schemas": "*",
|
"@librechat/data-schemas": "*",
|
||||||
"@modelcontextprotocol/sdk": "^1.21.0",
|
"@modelcontextprotocol/sdk": "^1.21.0",
|
||||||
"axios": "^1.12.1",
|
"axios": "^1.12.1",
|
||||||
|
|
|
||||||
|
|
@ -84,7 +84,7 @@
|
||||||
"@azure/storage-blob": "^12.27.0",
|
"@azure/storage-blob": "^12.27.0",
|
||||||
"@keyv/redis": "^4.3.3",
|
"@keyv/redis": "^4.3.3",
|
||||||
"@langchain/core": "^0.3.79",
|
"@langchain/core": "^0.3.79",
|
||||||
"@librechat/agents": "^3.0.27",
|
"@librechat/agents": "^3.0.30",
|
||||||
"@librechat/data-schemas": "*",
|
"@librechat/data-schemas": "*",
|
||||||
"@modelcontextprotocol/sdk": "^1.21.0",
|
"@modelcontextprotocol/sdk": "^1.21.0",
|
||||||
"axios": "^1.12.1",
|
"axios": "^1.12.1",
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ import type {
|
||||||
RunConfig,
|
RunConfig,
|
||||||
IState,
|
IState,
|
||||||
} from '@librechat/agents';
|
} from '@librechat/agents';
|
||||||
|
import type { IUser } from '@librechat/data-schemas';
|
||||||
import type { Agent } from 'librechat-data-provider';
|
import type { Agent } from 'librechat-data-provider';
|
||||||
import type * as t from '~/types';
|
import type * as t from '~/types';
|
||||||
import { resolveHeaders, createSafeUser } from '~/utils/env';
|
import { resolveHeaders, createSafeUser } from '~/utils/env';
|
||||||
|
|
@ -79,7 +80,7 @@ export async function createRun({
|
||||||
streaming?: boolean;
|
streaming?: boolean;
|
||||||
streamUsage?: boolean;
|
streamUsage?: boolean;
|
||||||
requestBody?: t.RequestBody;
|
requestBody?: t.RequestBody;
|
||||||
user?: t.TUser;
|
user?: IUser;
|
||||||
} & Pick<RunConfig, 'tokenCounter' | 'customHandlers' | 'indexTokenCountMap'>): Promise<
|
} & Pick<RunConfig, 'tokenCounter' | 'customHandlers' | 'indexTokenCountMap'>): Promise<
|
||||||
Run<IState>
|
Run<IState>
|
||||||
> {
|
> {
|
||||||
|
|
|
||||||
|
|
@ -2,9 +2,8 @@ import pick from 'lodash/pick';
|
||||||
import { logger } from '@librechat/data-schemas';
|
import { logger } from '@librechat/data-schemas';
|
||||||
import { CallToolResultSchema, ErrorCode, McpError } from '@modelcontextprotocol/sdk/types.js';
|
import { CallToolResultSchema, ErrorCode, McpError } from '@modelcontextprotocol/sdk/types.js';
|
||||||
import type { RequestOptions } from '@modelcontextprotocol/sdk/shared/protocol.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 { FlowStateManager } from '~/flow/manager';
|
||||||
import type { TUser } from 'librechat-data-provider';
|
|
||||||
import type { MCPOAuthTokens } from './oauth';
|
import type { MCPOAuthTokens } from './oauth';
|
||||||
import type { RequestBody } from '~/types';
|
import type { RequestBody } from '~/types';
|
||||||
import type * as t from './types';
|
import type * as t from './types';
|
||||||
|
|
@ -49,7 +48,7 @@ export class MCPManager extends UserConnectionManager {
|
||||||
public async getConnection(
|
public async getConnection(
|
||||||
args: {
|
args: {
|
||||||
serverName: string;
|
serverName: string;
|
||||||
user?: TUser;
|
user?: IUser;
|
||||||
forceNew?: boolean;
|
forceNew?: boolean;
|
||||||
flowManager?: FlowStateManager<MCPOAuthTokens | null>;
|
flowManager?: FlowStateManager<MCPOAuthTokens | null>;
|
||||||
} & Omit<t.OAuthConnectionOptions, 'useOAuth' | 'user' | 'flowManager'>,
|
} & Omit<t.OAuthConnectionOptions, 'useOAuth' | 'user' | 'flowManager'>,
|
||||||
|
|
@ -176,7 +175,7 @@ Please follow these instructions when using tools from the respective MCP server
|
||||||
oauthEnd,
|
oauthEnd,
|
||||||
customUserVars,
|
customUserVars,
|
||||||
}: {
|
}: {
|
||||||
user?: TUser;
|
user?: IUser;
|
||||||
serverName: string;
|
serverName: string;
|
||||||
toolName: string;
|
toolName: string;
|
||||||
provider: t.Provider;
|
provider: t.Provider;
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
import { logger } from '@librechat/data-schemas';
|
import { logger } from '@librechat/data-schemas';
|
||||||
import type { TokenMethods } from '@librechat/data-schemas';
|
import type { TokenMethods, IUser } from '@librechat/data-schemas';
|
||||||
import type { TUser } from 'librechat-data-provider';
|
|
||||||
import type { MCPOAuthTokens } from './types';
|
import type { MCPOAuthTokens } from './types';
|
||||||
import { OAuthReconnectionTracker } from './OAuthReconnectionTracker';
|
import { OAuthReconnectionTracker } from './OAuthReconnectionTracker';
|
||||||
import { FlowStateManager } from '~/flow/manager';
|
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)
|
// attempt to get connection (this will use existing tokens and refresh if needed)
|
||||||
const connection = await this.mcpManager.getUserConnection({
|
const connection = await this.mcpManager.getUserConnection({
|
||||||
serverName,
|
serverName,
|
||||||
user: { id: userId } as TUser,
|
user: { id: userId } as IUser,
|
||||||
flowManager: this.flowManager,
|
flowManager: this.flowManager,
|
||||||
tokenMethods: this.tokenMethods,
|
tokenMethods: this.tokenMethods,
|
||||||
// don't force new connection, let it reuse existing or create new as needed
|
// don't force new connection, let it reuse existing or create new as needed
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,16 @@
|
||||||
import { z } from 'zod';
|
import { z } from 'zod';
|
||||||
import {
|
import {
|
||||||
|
Tools,
|
||||||
SSEOptionsSchema,
|
SSEOptionsSchema,
|
||||||
MCPOptionsSchema,
|
MCPOptionsSchema,
|
||||||
MCPServersSchema,
|
MCPServersSchema,
|
||||||
StdioOptionsSchema,
|
StdioOptionsSchema,
|
||||||
WebSocketOptionsSchema,
|
WebSocketOptionsSchema,
|
||||||
StreamableHTTPOptionsSchema,
|
StreamableHTTPOptionsSchema,
|
||||||
Tools,
|
|
||||||
} from 'librechat-data-provider';
|
} 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 * as t from '@modelcontextprotocol/sdk/types.js';
|
||||||
import type { TokenMethods, JsonSchemaType } from '@librechat/data-schemas';
|
|
||||||
import type { FlowStateManager } from '~/flow/manager';
|
import type { FlowStateManager } from '~/flow/manager';
|
||||||
import type { RequestBody } from '~/types/http';
|
import type { RequestBody } from '~/types/http';
|
||||||
import type * as o from '~/mcp/oauth/types';
|
import type * as o from '~/mcp/oauth/types';
|
||||||
|
|
@ -161,7 +161,7 @@ export interface BasicConnectionOptions {
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface OAuthConnectionOptions {
|
export interface OAuthConnectionOptions {
|
||||||
user: TUser;
|
user: IUser;
|
||||||
useOAuth: true;
|
useOAuth: true;
|
||||||
requestBody?: RequestBody;
|
requestBody?: RequestBody;
|
||||||
customUserVars?: Record<string, string>;
|
customUserVars?: Record<string, string>;
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import { extractEnvVariable } from 'librechat-data-provider';
|
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 { IUser } from '@librechat/data-schemas';
|
||||||
import type { RequestBody } from '~/types';
|
import type { RequestBody } from '~/types';
|
||||||
import { extractOpenIDTokenInfo, processOpenIDPlaceholders, isOpenIDTokenValid } from './oidc';
|
import { extractOpenIDTokenInfo, processOpenIDPlaceholders, isOpenIDTokenValid } from './oidc';
|
||||||
|
|
@ -71,7 +71,7 @@ const ALLOWED_BODY_FIELDS = ['conversationId', 'parentMessageId', 'messageId'] a
|
||||||
* @param user - The user object
|
* @param user - The user object
|
||||||
* @returns The processed string with placeholders replaced
|
* @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') {
|
if (!user || typeof value !== 'string') {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
@ -82,7 +82,7 @@ function processUserPlaceholders(value: string, user?: TUser): string {
|
||||||
continue;
|
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
|
// Skip replacement if field doesn't exist in user object
|
||||||
if (!(field in user)) {
|
if (!(field in user)) {
|
||||||
|
|
@ -141,7 +141,7 @@ function processSingleValue({
|
||||||
}: {
|
}: {
|
||||||
originalValue: string;
|
originalValue: string;
|
||||||
customUserVars?: Record<string, string>;
|
customUserVars?: Record<string, string>;
|
||||||
user?: TUser;
|
user?: IUser;
|
||||||
body?: RequestBody;
|
body?: RequestBody;
|
||||||
}): string {
|
}): string {
|
||||||
let value = originalValue;
|
let value = originalValue;
|
||||||
|
|
@ -182,7 +182,7 @@ function processSingleValue({
|
||||||
*/
|
*/
|
||||||
export function processMCPEnv(params: {
|
export function processMCPEnv(params: {
|
||||||
options: Readonly<MCPOptions>;
|
options: Readonly<MCPOptions>;
|
||||||
user?: TUser;
|
user?: IUser;
|
||||||
customUserVars?: Record<string, string>;
|
customUserVars?: Record<string, string>;
|
||||||
body?: RequestBody;
|
body?: RequestBody;
|
||||||
}): MCPOptions {
|
}): MCPOptions {
|
||||||
|
|
@ -227,7 +227,7 @@ export function processMCPEnv(params: {
|
||||||
|
|
||||||
// Process OAuth configuration if it exists (for all transport types)
|
// Process OAuth configuration if it exists (for all transport types)
|
||||||
if ('oauth' in newObj && newObj.oauth) {
|
if ('oauth' in newObj && newObj.oauth) {
|
||||||
const processedOAuth: Record<string, string | string[] | undefined> = {};
|
const processedOAuth: Record<string, boolean | string | string[] | undefined> = {};
|
||||||
for (const [key, originalValue] of Object.entries(newObj.oauth)) {
|
for (const [key, originalValue] of Object.entries(newObj.oauth)) {
|
||||||
// Only process string values for environment variables
|
// Only process string values for environment variables
|
||||||
// token_exchange_method is an enum and shouldn't be processed
|
// token_exchange_method is an enum and shouldn't be processed
|
||||||
|
|
@ -255,7 +255,7 @@ export function processMCPEnv(params: {
|
||||||
*/
|
*/
|
||||||
export function resolveHeaders(options?: {
|
export function resolveHeaders(options?: {
|
||||||
headers: Record<string, string> | undefined;
|
headers: Record<string, string> | undefined;
|
||||||
user?: Partial<TUser> | { id: string };
|
user?: Partial<IUser> | { id: string };
|
||||||
body?: RequestBody;
|
body?: RequestBody;
|
||||||
customUserVars?: Record<string, string>;
|
customUserVars?: Record<string, string>;
|
||||||
}) {
|
}) {
|
||||||
|
|
@ -269,7 +269,7 @@ export function resolveHeaders(options?: {
|
||||||
resolvedHeaders[key] = processSingleValue({
|
resolvedHeaders[key] = processSingleValue({
|
||||||
originalValue: inputHeaders[key],
|
originalValue: inputHeaders[key],
|
||||||
customUserVars,
|
customUserVars,
|
||||||
user: user as TUser,
|
user: user as IUser,
|
||||||
body,
|
body,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
import { logger } from '@librechat/data-schemas';
|
import { logger } from '@librechat/data-schemas';
|
||||||
import type { TUser } from 'librechat-data-provider';
|
|
||||||
import type { IUser } from '@librechat/data-schemas';
|
import type { IUser } from '@librechat/data-schemas';
|
||||||
|
|
||||||
export interface OpenIDTokenInfo {
|
export interface OpenIDTokenInfo {
|
||||||
|
|
@ -35,9 +34,7 @@ const OPENID_TOKEN_FIELDS = [
|
||||||
'EXPIRES_AT',
|
'EXPIRES_AT',
|
||||||
] as const;
|
] as const;
|
||||||
|
|
||||||
export function extractOpenIDTokenInfo(
|
export function extractOpenIDTokenInfo(user: IUser | null | undefined): OpenIDTokenInfo | null {
|
||||||
user: IUser | TUser | null | undefined,
|
|
||||||
): OpenIDTokenInfo | null {
|
|
||||||
if (!user) {
|
if (!user) {
|
||||||
logger.debug('[extractOpenIDTokenInfo] No user provided');
|
logger.debug('[extractOpenIDTokenInfo] No user provided');
|
||||||
return null;
|
return null;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue