@chat-js/registry 0.2.0-beta.4 → 0.2.0-beta.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/r/attach-workspace-file.json +1 -1
- package/dist/r/base/attach-workspace-file.json +1 -1
- package/dist/r/base/default-sandbox.json +1 -1
- package/dist/r/base/docker-sandbox.json +1 -1
- package/dist/r/base/generate-image.json +1 -1
- package/dist/r/base/generate-video.json +1 -1
- package/dist/r/base/guest-chat.json +1 -1
- package/dist/r/base/just-bash-sandbox.json +1 -1
- package/dist/r/base/litellm-gateway.json +2 -2
- package/dist/r/base/mcp.json +2 -2
- package/dist/r/base/openai-compatible-gateway.json +2 -2
- package/dist/r/base/openai-gateway.json +2 -2
- package/dist/r/base/openrouter-gateway.json +1 -1
- package/dist/r/base/registry.json +18 -18
- package/dist/r/base/vercel-gateway.json +2 -2
- package/dist/r/base/vercel-sandbox.json +1 -1
- package/dist/r/default-sandbox.json +1 -1
- package/dist/r/docker-sandbox.json +1 -1
- package/dist/r/eve/deep-research.json +1 -1
- package/dist/r/eve/registry.json +1 -1
- package/dist/r/generate-image.json +1 -1
- package/dist/r/generate-video.json +1 -1
- package/dist/r/guest-chat.json +1 -1
- package/dist/r/just-bash-sandbox.json +1 -1
- package/dist/r/litellm-gateway.json +2 -2
- package/dist/r/mcp.json +2 -2
- package/dist/r/openai-compatible-gateway.json +2 -2
- package/dist/r/openai-gateway.json +2 -2
- package/dist/r/openrouter-gateway.json +1 -1
- package/dist/r/radix/attach-workspace-file.json +1 -1
- package/dist/r/radix/default-sandbox.json +1 -1
- package/dist/r/radix/docker-sandbox.json +1 -1
- package/dist/r/radix/generate-image.json +1 -1
- package/dist/r/radix/generate-video.json +1 -1
- package/dist/r/radix/guest-chat.json +1 -1
- package/dist/r/radix/just-bash-sandbox.json +1 -1
- package/dist/r/radix/litellm-gateway.json +2 -2
- package/dist/r/radix/mcp.json +2 -2
- package/dist/r/radix/openai-compatible-gateway.json +2 -2
- package/dist/r/radix/openai-gateway.json +2 -2
- package/dist/r/radix/openrouter-gateway.json +1 -1
- package/dist/r/radix/registry.json +18 -18
- package/dist/r/radix/vercel-gateway.json +2 -2
- package/dist/r/radix/vercel-sandbox.json +1 -1
- package/dist/r/registry.json +18 -18
- package/dist/r/vercel-gateway.json +2 -2
- package/dist/r/vercel-sandbox.json +1 -1
- package/package.json +10 -10
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"name": "attach-workspace-file",
|
|
4
4
|
"description": "Attach workspace files to the conversation as downloads, or import earlier files into the workspace for revision.",
|
|
5
5
|
"dependencies": [
|
|
6
|
-
"eve@npm:@chat-js/eve@1.
|
|
6
|
+
"eve@npm:@chat-js/eve@1.1.1-chatjs.0",
|
|
7
7
|
"zod@4.5.4",
|
|
8
8
|
"lucide-react@0.553.0"
|
|
9
9
|
],
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"name": "attach-workspace-file",
|
|
4
4
|
"description": "Attach workspace files to the conversation as downloads, or import earlier files into the workspace for revision.",
|
|
5
5
|
"dependencies": [
|
|
6
|
-
"eve@npm:@chat-js/eve@1.
|
|
6
|
+
"eve@npm:@chat-js/eve@1.1.1-chatjs.0",
|
|
7
7
|
"zod@4.5.4",
|
|
8
8
|
"lucide-react@0.553.0"
|
|
9
9
|
],
|
package/dist/r/base/mcp.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"name": "mcp",
|
|
4
4
|
"description": "MCP connectors, management pages, OAuth and composer control",
|
|
5
5
|
"dependencies": [
|
|
6
|
-
"@ai-sdk/mcp@2.0.
|
|
6
|
+
"@ai-sdk/mcp@2.0.99",
|
|
7
7
|
"@hookform/resolvers@^5.2.1",
|
|
8
8
|
"@modelcontextprotocol/sdk@^1.24.3",
|
|
9
9
|
"@tanstack/react-query@^5.104.1",
|
|
@@ -175,7 +175,7 @@
|
|
|
175
175
|
},
|
|
176
176
|
{
|
|
177
177
|
"path": "src/plugins/mcp/src/oauth/mcp-client.ts",
|
|
178
|
-
"content": "import type {\n ListPromptsResult,\n ListResourcesResult,\n} from \"@modelcontextprotocol/sdk/types.js\";\nimport {\n auth,\n experimental_createMCPClient as createMCPClient,\n} from \"@ai-sdk/mcp\";\nimport { McpOAuthClientProvider } from \"@/chatjs/plugins/mcp/oauth/mcp-oauth-provider\";\nimport { OAuthAuthorizationRequiredError } from \"@/chatjs/plugins/mcp/oauth/oauth-authorization-required-error\";\nimport type { ReadonlyNativeSurface } from \"@/lib/readonly-native-surface\";\nimport type { Tool } from \"ai\";\nimport { config } from \"@/lib/config\";\nimport { createModuleLogger } from \"@/lib/logger\";\nimport { getBaseUrl } from \"@/lib/url\";\n\nconst log = createModuleLogger(\"mcp-client\");\n\nconst INITIAL_CONNECTION_GENERATION = 0;\nconst MCP_CONNECTION_TIMEOUT_MS = 30_000;\n\nconst getMcpErrorMessage = (error: unknown): string => {\n if (error instanceof Error) {\n return error.message;\n }\n return String(error);\n};\n\ntype McpPreconnect = (\n url: string | URL,\n options?: {\n readonly dns?: boolean;\n readonly http?: boolean;\n readonly https?: boolean;\n readonly tcp?: boolean;\n }\n) => void;\n\nconst isMcpPreconnect = (value: unknown): value is McpPreconnect =>\n typeof value === \"function\";\n\n// Bun's fetch type requires preconnect. Node's does not. Delegate when the\n// runtime provides it so one fetch value satisfies both FetchFunction types.\nconst mcpPreconnect: McpPreconnect = (url, options): void => {\n const candidate: object = globalThis.fetch;\n if (!(\"preconnect\" in candidate)) {\n return;\n }\n const method: unknown = candidate.preconnect;\n if (!isMcpPreconnect(method)) {\n return;\n }\n method(url, options);\n};\n\nconst toMcpSdkFetch = (\n fetchImpl: (\n ...args: Parameters<typeof globalThis.fetch>\n ) => ReturnType<typeof globalThis.fetch>\n): typeof globalThis.fetch =>\n Object.assign(fetchImpl, { preconnect: mcpPreconnect });\n\ntype McpClientInstance = Awaited<ReturnType<typeof createMCPClient>>;\n\ntype McpClientStatus =\n | \"disconnected\"\n | \"connecting\"\n | \"connected\"\n | \"authorizing\"\n | \"incompatible\";\n\n/**\n * MCP Client wrapper with OAuth support.\n * Uses @ai-sdk/mcp's createMCPClient with authProvider for OAuth flow.\n */\nexport class MCPClient {\n private client?: McpClientInstance;\n private generation = INITIAL_CONNECTION_GENERATION;\n private connectionAbort?: AbortController;\n private connectPromise?: Promise<void>;\n private readonly invalidateCache?: () => void;\n private oauthProvider: McpOAuthClientProvider;\n private authorizationUrl?: URL;\n private connectionStatus: McpClientStatus = \"disconnected\";\n\n private readonly id: string;\n private readonly name: string;\n private readonly serverConfig: {\n url: string;\n type: \"http\" | \"sse\";\n headers?: Record<string, string>;\n oauthClientId?: string | null;\n oauthClientSecret?: string | null;\n };\n\n public constructor(\n id: string,\n name: string,\n serverConfig: {\n readonly url: string;\n readonly type: \"http\" | \"sse\";\n readonly headers?: Readonly<Record<string, string>>;\n readonly oauthClientId?: string | null;\n readonly oauthClientSecret?: string | null;\n },\n invalidateCache?: () => void\n ) {\n this.invalidateCache = invalidateCache;\n this.id = id;\n this.name = name;\n this.serverConfig = serverConfig;\n this.oauthProvider = this.createOAuthProvider();\n }\n\n private createOAuthProvider(): McpOAuthClientProvider {\n const { generation } = this;\n const baseUrl = getBaseUrl();\n\n return new McpOAuthClientProvider({\n clientMetadata: {\n client_name: `${config.appPrefix}-${this.name}`,\n grant_types: [\"authorization_code\", \"refresh_token\"],\n redirect_uris: [`${baseUrl}/api/mcp/oauth/callback`],\n response_types: [\"code\"],\n scope: \"mcp:tools\",\n software_id: config.appPrefix,\n software_version: \"1.0.0\",\n token_endpoint_auth_method:\n typeof this.serverConfig.oauthClientId === \"string\" &&\n this.serverConfig.oauthClientId !== \"\" &&\n typeof this.serverConfig.oauthClientSecret === \"string\" &&\n this.serverConfig.oauthClientSecret !== \"\"\n ? \"client_secret_basic\"\n : \"none\",\n },\n mcpConnectorId: this.id,\n oauthClientId: this.serverConfig.oauthClientId,\n oauthClientSecret: this.serverConfig.oauthClientSecret,\n onRedirectToAuthorization: (\n authorizationUrl: ReadonlyNativeSurface<URL>\n ): never => {\n if (generation !== this.generation) {\n throw new Error(\"MCP connection was closed\");\n }\n this.authorizationUrl = authorizationUrl;\n throw new OAuthAuthorizationRequiredError(authorizationUrl);\n },\n serverUrl: this.serverConfig.url,\n });\n }\n\n public get status(): McpClientStatus {\n if (this.authorizationUrl) {\n return \"authorizing\";\n }\n if (this.client) {\n return \"connected\";\n }\n return this.connectionStatus;\n }\n\n public getAuthorizationUrl(): URL | undefined {\n return this.authorizationUrl;\n }\n\n public get serverInfo(): McpClientInstance[\"serverInfo\"] | undefined {\n const { client } = this;\n return client && client.serverInfo;\n }\n\n public async connect({\n oauthState,\n abortSignal,\n }: {\n readonly oauthState?: string;\n readonly abortSignal?: Readonly<\n Pick<\n AbortSignal,\n | \"throwIfAborted\"\n | \"reason\"\n | \"addEventListener\"\n | \"removeEventListener\"\n | \"aborted\"\n >\n >;\n } = {}): Promise<void> {\n if (abortSignal) {\n abortSignal.throwIfAborted();\n }\n if (!this.connectPromise) {\n const { generation } = this;\n this.connectPromise = (async (): Promise<void> => {\n try {\n await this.connectOnce(oauthState);\n } finally {\n // Only close() can retire a pending attempt and allow a replacement.\n if (this.generation === generation) {\n this.connectPromise = undefined;\n }\n }\n })();\n }\n if (!abortSignal) {\n await this.connectPromise;\n return;\n }\n const aborted = Promise.withResolvers<never>();\n const cancel = (): void => {\n aborted.reject(abortSignal.reason);\n };\n abortSignal.addEventListener(\"abort\", cancel, { once: true });\n if (abortSignal.aborted) {\n cancel();\n }\n try {\n await Promise.race([this.connectPromise, aborted.promise]);\n } finally {\n abortSignal.removeEventListener(\"abort\", cancel);\n }\n }\n private async connectOnce(oauthState?: string): Promise<void> {\n if (this.status === \"connected\" && this.client) {\n return;\n }\n\n const { generation, oauthProvider } = this;\n this.connectionAbort = new AbortController();\n const signal = AbortSignal.any([\n this.connectionAbort.signal,\n AbortSignal.timeout(MCP_CONNECTION_TIMEOUT_MS),\n ]);\n this.connectionStatus = \"connecting\";\n\n try {\n // Adopt state if provided (for callback reconciliation).\n if (typeof oauthState === \"string\" && oauthState !== \"\") {\n await oauthProvider.adoptState(oauthState);\n }\n signal.throwIfAborted();\n // AI SDK handles 401 internally and calls auth() with the provider\n const client = await createMCPClient({\n initializationOptions: { signal },\n transport: {\n authProvider: oauthProvider,\n fetch: toMcpSdkFetch(oauthProvider.fetch),\n headers: this.serverConfig.headers,\n type: this.serverConfig.type,\n url: this.serverConfig.url,\n },\n });\n\n if (generation !== this.generation || signal.aborted) {\n await client.close();\n signal.throwIfAborted();\n throw new Error(\"MCP connection was closed\");\n }\n this.client = client;\n this.authorizationUrl = undefined;\n this.connectionStatus = \"connected\";\n } catch (error) {\n if (generation !== this.generation || signal.aborted) {\n if (generation === this.generation) {\n this.authorizationUrl = undefined;\n this.connectionStatus = \"disconnected\";\n }\n throw error;\n }\n // If OAuth required error, status becomes \"authorizing\"\n if (error instanceof OAuthAuthorizationRequiredError) {\n this.connectionStatus = \"authorizing\";\n log.info(\n { authUrl: error.authorizationUrl.toString(), connectorId: this.id },\n \"OAuth authorization required\"\n );\n return;\n }\n\n this.connectionStatus = \"disconnected\";\n throw error;\n }\n }\n /**\n * Lightweight connection test - just checks if we can connect without full discovery.\n * Returns connection status without fetching tools/resources/prompts.\n * @param {Readonly<Pick<AbortSignal, \"throwIfAborted\" | \"reason\" | \"addEventListener\" | \"removeEventListener\" | \"aborted\">> | undefined} abortSignal - Cancels this caller while shared initialization continues.\n * @returns {Promise<{ status: McpClientStatus; needsAuth: boolean; error?: string; }>} The connection or authorization status.\n */\n public async attemptConnection(\n abortSignal?: Readonly<\n Pick<\n AbortSignal,\n | \"throwIfAborted\"\n | \"reason\"\n | \"addEventListener\"\n | \"removeEventListener\"\n | \"aborted\"\n >\n >\n ): Promise<{\n status: McpClientStatus;\n needsAuth: boolean;\n error?: string;\n }> {\n // If already connected, return current status\n if (this.status === \"connected\" && this.client) {\n return { needsAuth: false, status: \"connected\" };\n }\n\n // If already in authorizing state, return that\n if (this.authorizationUrl) {\n return { needsAuth: true, status: \"authorizing\" };\n }\n\n try {\n await this.connect({ abortSignal });\n // Check if OAuth is required (authorizationUrl gets set during connect)\n if (this.authorizationUrl !== undefined) {\n return { needsAuth: true, status: \"authorizing\" };\n }\n return {\n needsAuth: false,\n status: this.client ? \"connected\" : \"disconnected\",\n };\n } catch (error) {\n const errorMessage = getMcpErrorMessage(error);\n log.error(\n {\n connectorId: this.id,\n errorMessage,\n errorStack: error instanceof Error ? error.stack : undefined,\n },\n \"attemptConnection failed\"\n );\n\n // Detect incompatible server errors\n if (\n errorMessage.includes(\"does not support dynamic client registration\")\n ) {\n this.connectionStatus = \"incompatible\";\n return {\n error:\n \"Server requires pre-configured OAuth credentials (does not support dynamic client registration)\",\n needsAuth: false,\n status: \"incompatible\",\n };\n }\n\n return { error: errorMessage, needsAuth: false, status: \"disconnected\" };\n }\n }\n /**\n * Called after callback receives code to complete the OAuth flow.\n * @param {string} code - Authorization code received by the callback.\n * @param {string} state - State used to restore the verifier session.\n */\n public async finishAuth(code: string, state: string): Promise<void> {\n const { generation, oauthProvider } = this;\n // Always adopt the state from the callback to load the session with code verifier\n await oauthProvider.adoptState(state);\n\n // Use the auth function from @ai-sdk/mcp to complete the OAuth flow\n await auth(oauthProvider, {\n authorizationCode: code,\n fetchFn: toMcpSdkFetch(oauthProvider.fetch),\n serverUrl: this.serverConfig.url,\n });\n\n if (generation !== this.generation) {\n throw new Error(\"MCP connection was closed\");\n }\n this.authorizationUrl = undefined;\n // Don't set to connected - tokens are saved, next connect() will use them\n }\n /**\n * Get tools from the MCP server, already in AI SDK format.\n * @param {Parameters<McpClientInstance[\"tools\"]>} args - Native SDK schema options.\n * @returns {Promise<Record<string, Tool>>} The discovered SDK tools.\n */\n public async tools(\n ...args: Parameters<NonNullable<McpClientInstance>[\"tools\"]>\n ): Promise<Record<string, Tool>> {\n const { client } = this;\n if (!client) {\n throw new Error(\"Client not connected\");\n }\n try {\n return await client.tools(...args);\n } catch (error) {\n await this.handlePotentialAuthError(error, client);\n throw error;\n }\n }\n /**\n * List resources from the MCP server.\n * @returns {Promise<ListResourcesResult>} The native MCP resource result.\n */\n public async listResources(): Promise<ListResourcesResult> {\n const { client } = this;\n if (!client) {\n throw new Error(\"Client not connected\");\n }\n try {\n return await client.listResources();\n } catch (error) {\n await this.handlePotentialAuthError(error, client);\n throw error;\n }\n }\n /**\n * List prompts from the MCP server.\n * @returns {Promise<ListPromptsResult>} The native MCP prompt result.\n */\n public async listPrompts(): Promise<ListPromptsResult> {\n const { client } = this;\n if (!client) {\n throw new Error(\"Client not connected\");\n }\n try {\n return await client.experimental_listPrompts();\n } catch (error) {\n await this.handlePotentialAuthError(error, client);\n throw error;\n }\n }\n /**\n * Close the connection to the MCP server.\n */\n public async close(): Promise<void> {\n this.generation += 1;\n const { connectionAbort } = this;\n if (connectionAbort) {\n connectionAbort.abort(new Error(\"MCP connection was closed\"));\n }\n this.connectPromise = undefined;\n this.oauthProvider = this.createOAuthProvider();\n const { client } = this;\n this.client = undefined;\n this.authorizationUrl = undefined;\n this.connectionStatus = \"disconnected\";\n try {\n // Await even without a client to preserve cache-invalidation timing.\n await (client && client.close());\n } catch (error) {\n log.error({ connectorId: this.id, error }, \"Error closing MCP client\");\n }\n if (this.invalidateCache) {\n this.invalidateCache();\n }\n }\n /**\n * Check if an error is an auth error (401/403) and invalidate caches if so.\n * @param {unknown} error - Failure from a connected SDK operation.\n * @param {unknown} origin - Client whose failure is being handled.\n */\n private async handlePotentialAuthError(\n error: unknown,\n origin: unknown\n ): Promise<void> {\n if (this.client !== origin) {\n return;\n }\n const errorMessage = getMcpErrorMessage(error);\n const isAuthError =\n errorMessage.includes(\"401\") ||\n errorMessage.includes(\"403\") ||\n errorMessage.includes(\"Unauthorized\") ||\n errorMessage.includes(\"Forbidden\");\n\n if (isAuthError) {\n log.warn(\n { connectorId: this.id, errorMessage },\n \"Auth error detected, invalidating caches\"\n );\n await this.close();\n }\n }\n}\n",
|
|
178
|
+
"content": "import type {\n ListPromptsResult,\n ListResourcesResult,\n} from \"@modelcontextprotocol/sdk/types.js\";\nimport {\n auth,\n experimental_createMCPClient as createMCPClient,\n} from \"@ai-sdk/mcp\";\nimport { McpOAuthClientProvider } from \"@/chatjs/plugins/mcp/oauth/mcp-oauth-provider\";\nimport { OAuthAuthorizationRequiredError } from \"@/chatjs/plugins/mcp/oauth/oauth-authorization-required-error\";\nimport type { ReadonlyNativeSurface } from \"@/lib/readonly-native-surface\";\nimport type { Tool } from \"ai\";\nimport { config } from \"@/lib/config\";\nimport { createModuleLogger } from \"@/lib/logger\";\nimport { getBaseUrl } from \"@/lib/url\";\n\nconst log = createModuleLogger(\"mcp-client\");\n\nconst INITIAL_CONNECTION_GENERATION = 0;\nconst MCP_CONNECTION_TIMEOUT_MS = 30_000;\n\nconst getMcpErrorMessage = (error: unknown): string => {\n if (error instanceof Error) {\n return error.message;\n }\n return String(error);\n};\n\ntype McpPreconnect = (\n url: string | URL,\n options?: {\n readonly dns?: boolean;\n readonly http?: boolean;\n readonly https?: boolean;\n readonly tcp?: boolean;\n }\n) => void;\n\nconst isMcpPreconnect = (value: unknown): value is McpPreconnect =>\n typeof value === \"function\";\n\n// Bun's fetch type requires preconnect. Node's does not. Delegate when the\n// runtime provides it so one fetch value satisfies both FetchFunction types.\nconst mcpPreconnect: McpPreconnect = (url, options): void => {\n const candidate: object = globalThis.fetch;\n if (!(\"preconnect\" in candidate)) {\n return;\n }\n const method: unknown = candidate.preconnect;\n if (!isMcpPreconnect(method)) {\n return;\n }\n method(url, options);\n};\n\nconst toMcpSdkFetch = (\n fetchImpl: (\n ...args: Parameters<typeof globalThis.fetch>\n ) => ReturnType<typeof globalThis.fetch>\n): typeof globalThis.fetch =>\n Object.assign(fetchImpl, { preconnect: mcpPreconnect });\n\ntype McpClientInstance = Awaited<ReturnType<typeof createMCPClient>>;\n\ntype McpClientStatus =\n | \"disconnected\"\n | \"connecting\"\n | \"connected\"\n | \"authorizing\"\n | \"incompatible\";\n\n/**\n * MCP Client wrapper with OAuth support.\n * Uses @ai-sdk/mcp's createMCPClient with authProvider for OAuth flow.\n */\nexport class MCPClient {\n private client?: McpClientInstance;\n private generation = INITIAL_CONNECTION_GENERATION;\n private connectionAbort?: AbortController;\n private connectPromise?: Promise<void>;\n private readonly invalidateCache?: () => void;\n private oauthProvider: McpOAuthClientProvider;\n private authorizationUrl?: URL;\n private connectionStatus: McpClientStatus = \"disconnected\";\n\n private readonly id: string;\n private readonly name: string;\n private readonly serverConfig: {\n url: string;\n type: \"http\" | \"sse\";\n headers?: Record<string, string>;\n oauthClientId?: string | null;\n oauthClientSecret?: string | null;\n };\n\n public constructor(\n id: string,\n name: string,\n serverConfig: {\n readonly url: string;\n readonly type: \"http\" | \"sse\";\n readonly headers?: Readonly<Record<string, string>>;\n readonly oauthClientId?: string | null;\n readonly oauthClientSecret?: string | null;\n },\n invalidateCache?: () => void\n ) {\n this.invalidateCache = invalidateCache;\n this.id = id;\n this.name = name;\n this.serverConfig = serverConfig;\n this.oauthProvider = this.createOAuthProvider();\n }\n\n private createOAuthProvider(): McpOAuthClientProvider {\n const { generation } = this;\n const baseUrl = getBaseUrl();\n\n return new McpOAuthClientProvider({\n clientMetadata: {\n client_name: `${config.appPrefix}-${this.name}`,\n grant_types: [\"authorization_code\", \"refresh_token\"],\n redirect_uris: [`${baseUrl}/api/mcp/oauth/callback`],\n response_types: [\"code\"],\n scope: \"mcp:tools\",\n software_id: config.appPrefix,\n software_version: \"1.0.0\",\n token_endpoint_auth_method:\n typeof this.serverConfig.oauthClientId === \"string\" &&\n this.serverConfig.oauthClientId !== \"\" &&\n typeof this.serverConfig.oauthClientSecret === \"string\" &&\n this.serverConfig.oauthClientSecret !== \"\"\n ? \"client_secret_basic\"\n : \"none\",\n },\n mcpConnectorId: this.id,\n oauthClientId: this.serverConfig.oauthClientId,\n oauthClientSecret: this.serverConfig.oauthClientSecret,\n onRedirectToAuthorization: (\n authorizationUrl: ReadonlyNativeSurface<URL>\n ): never => {\n if (generation !== this.generation) {\n throw new Error(\"MCP connection was closed\");\n }\n this.authorizationUrl = authorizationUrl;\n throw new OAuthAuthorizationRequiredError(authorizationUrl);\n },\n serverUrl: this.serverConfig.url,\n });\n }\n\n public get status(): McpClientStatus {\n if (this.authorizationUrl) {\n return \"authorizing\";\n }\n if (this.client) {\n return \"connected\";\n }\n return this.connectionStatus;\n }\n\n public getAuthorizationUrl(): URL | undefined {\n return this.authorizationUrl;\n }\n\n public get serverInfo(): McpClientInstance[\"serverInfo\"] | undefined {\n const { client } = this;\n return client && client.serverInfo;\n }\n\n public async connect({\n oauthState,\n abortSignal,\n }: {\n readonly oauthState?: string;\n readonly abortSignal?: Readonly<\n Pick<\n AbortSignal,\n | \"throwIfAborted\"\n | \"reason\"\n | \"addEventListener\"\n | \"removeEventListener\"\n | \"aborted\"\n >\n >;\n } = {}): Promise<void> {\n if (abortSignal) {\n abortSignal.throwIfAborted();\n }\n if (!this.connectPromise) {\n const { generation } = this;\n this.connectPromise = (async (): Promise<void> => {\n try {\n await this.connectOnce(oauthState);\n } finally {\n // Only close() can retire a pending attempt and allow a replacement.\n if (this.generation === generation) {\n this.connectPromise = undefined;\n }\n }\n })();\n }\n if (!abortSignal) {\n await this.connectPromise;\n return;\n }\n const aborted = Promise.withResolvers<never>();\n const cancel = (): void => {\n aborted.reject(abortSignal.reason);\n };\n abortSignal.addEventListener(\"abort\", cancel, { once: true });\n if (abortSignal.aborted) {\n cancel();\n }\n try {\n await Promise.race([this.connectPromise, aborted.promise]);\n } finally {\n abortSignal.removeEventListener(\"abort\", cancel);\n }\n }\n private async connectOnce(oauthState?: string): Promise<void> {\n if (this.status === \"connected\" && this.client) {\n return;\n }\n\n const { generation, oauthProvider } = this;\n this.connectionAbort = new AbortController();\n const signal = AbortSignal.any([\n this.connectionAbort.signal,\n AbortSignal.timeout(MCP_CONNECTION_TIMEOUT_MS),\n ]);\n this.connectionStatus = \"connecting\";\n\n try {\n // Adopt state if provided (for callback reconciliation).\n if (typeof oauthState === \"string\" && oauthState !== \"\") {\n await oauthProvider.adoptState(oauthState);\n }\n signal.throwIfAborted();\n // AI SDK handles 401 internally and calls auth() with the provider\n const client = await createMCPClient({\n initializationOptions: { signal },\n transport: {\n authProvider: oauthProvider,\n fetch: toMcpSdkFetch(oauthProvider.fetch),\n headers: this.serverConfig.headers,\n type: this.serverConfig.type,\n url: this.serverConfig.url,\n },\n });\n\n if (generation !== this.generation || signal.aborted) {\n await client.close();\n signal.throwIfAborted();\n throw new Error(\"MCP connection was closed\");\n }\n this.client = client;\n this.authorizationUrl = undefined;\n this.connectionStatus = \"connected\";\n } catch (error) {\n if (generation !== this.generation || signal.aborted) {\n if (generation === this.generation) {\n this.authorizationUrl = undefined;\n this.connectionStatus = \"disconnected\";\n }\n throw error;\n }\n // If OAuth required error, status becomes \"authorizing\"\n if (error instanceof OAuthAuthorizationRequiredError) {\n this.connectionStatus = \"authorizing\";\n log.info(\n { authUrl: error.authorizationUrl.toString(), connectorId: this.id },\n \"OAuth authorization required\"\n );\n return;\n }\n\n this.connectionStatus = \"disconnected\";\n throw error;\n }\n }\n /**\n * Lightweight connection test - just checks if we can connect without full discovery.\n * Returns connection status without fetching tools/resources/prompts.\n * @param {Readonly<Pick<AbortSignal, \"throwIfAborted\" | \"reason\" | \"addEventListener\" | \"removeEventListener\" | \"aborted\">> | undefined} abortSignal - Cancels this caller while shared initialization continues.\n * @returns {Promise<{ status: McpClientStatus; needsAuth: boolean; error?: string; }>} The connection or authorization status.\n */\n public async attemptConnection(\n abortSignal?: Readonly<\n Pick<\n AbortSignal,\n | \"throwIfAborted\"\n | \"reason\"\n | \"addEventListener\"\n | \"removeEventListener\"\n | \"aborted\"\n >\n >\n ): Promise<{\n status: McpClientStatus;\n needsAuth: boolean;\n error?: string;\n }> {\n // If already connected, return current status\n if (this.status === \"connected\" && this.client) {\n return { needsAuth: false, status: \"connected\" };\n }\n\n // If already in authorizing state, return that\n if (this.authorizationUrl) {\n return { needsAuth: true, status: \"authorizing\" };\n }\n\n try {\n await this.connect({ abortSignal });\n // Check if OAuth is required (authorizationUrl gets set during connect)\n if (this.authorizationUrl !== undefined) {\n return { needsAuth: true, status: \"authorizing\" };\n }\n return {\n needsAuth: false,\n status: this.client ? \"connected\" : \"disconnected\",\n };\n } catch (error) {\n const errorMessage = getMcpErrorMessage(error);\n log.error(\n {\n connectorId: this.id,\n errorMessage,\n errorStack: error instanceof Error ? error.stack : undefined,\n },\n \"attemptConnection failed\"\n );\n\n // Detect incompatible server errors\n if (\n errorMessage.includes(\"does not support dynamic client registration\")\n ) {\n this.connectionStatus = \"incompatible\";\n return {\n error:\n \"Server requires pre-configured OAuth credentials (does not support dynamic client registration)\",\n needsAuth: false,\n status: \"incompatible\",\n };\n }\n\n return { error: errorMessage, needsAuth: false, status: \"disconnected\" };\n }\n }\n /**\n * Called after callback receives code to complete the OAuth flow.\n * @param {string} code - Authorization code received by the callback.\n * @param {string} state - State used to restore the verifier session.\n */\n public async finishAuth(code: string, state: string): Promise<void> {\n const { generation, oauthProvider } = this;\n // Always adopt the state from the callback to load the session with code verifier\n await oauthProvider.adoptState(state);\n\n // Use the auth function from @ai-sdk/mcp to complete the OAuth flow\n await auth(oauthProvider, {\n authorizationCode: code,\n fetchFn: toMcpSdkFetch(oauthProvider.fetch),\n serverUrl: this.serverConfig.url,\n });\n\n if (generation !== this.generation) {\n throw new Error(\"MCP connection was closed\");\n }\n this.authorizationUrl = undefined;\n // Don't set to connected - tokens are saved, next connect() will use them\n }\n /**\n * Get tools from the MCP server, already in AI SDK format.\n * @param {Parameters<McpClientInstance[\"tools\"]>} args - Native SDK schema options.\n * @returns {Promise<Record<string, Tool>>} The discovered SDK tools.\n */\n public async tools(\n ...args: Parameters<NonNullable<McpClientInstance>[\"tools\"]>\n ): Promise<Record<string, Tool>> {\n const { client } = this;\n if (!client) {\n throw new Error(\"Client not connected\");\n }\n try {\n return await client.tools(...args);\n } catch (error) {\n await this.handlePotentialAuthError(error, client);\n throw error;\n }\n }\n /**\n * List resources from the MCP server.\n * @returns {Promise<ListResourcesResult>} The native MCP resource result.\n */\n public async listResources(): Promise<ListResourcesResult> {\n const { client } = this;\n if (!client) {\n throw new Error(\"Client not connected\");\n }\n try {\n return await client.listResources();\n } catch (error) {\n await this.handlePotentialAuthError(error, client);\n throw error;\n }\n }\n /**\n * List prompts from the MCP server.\n * @returns {Promise<ListPromptsResult>} The native MCP prompt result.\n */\n public async listPrompts(): Promise<ListPromptsResult> {\n const { client } = this;\n if (!client) {\n throw new Error(\"Client not connected\");\n }\n try {\n return await client.listPrompts();\n } catch (error) {\n await this.handlePotentialAuthError(error, client);\n throw error;\n }\n }\n /**\n * Close the connection to the MCP server.\n */\n public async close(): Promise<void> {\n this.generation += 1;\n const { connectionAbort } = this;\n if (connectionAbort) {\n connectionAbort.abort(new Error(\"MCP connection was closed\"));\n }\n this.connectPromise = undefined;\n this.oauthProvider = this.createOAuthProvider();\n const { client } = this;\n this.client = undefined;\n this.authorizationUrl = undefined;\n this.connectionStatus = \"disconnected\";\n try {\n // Await even without a client to preserve cache-invalidation timing.\n await (client && client.close());\n } catch (error) {\n log.error({ connectorId: this.id, error }, \"Error closing MCP client\");\n }\n if (this.invalidateCache) {\n this.invalidateCache();\n }\n }\n /**\n * Check if an error is an auth error (401/403) and invalidate caches if so.\n * @param {unknown} error - Failure from a connected SDK operation.\n * @param {unknown} origin - Client whose failure is being handled.\n */\n private async handlePotentialAuthError(\n error: unknown,\n origin: unknown\n ): Promise<void> {\n if (this.client !== origin) {\n return;\n }\n const errorMessage = getMcpErrorMessage(error);\n const isAuthError =\n errorMessage.includes(\"401\") ||\n errorMessage.includes(\"403\") ||\n errorMessage.includes(\"Unauthorized\") ||\n errorMessage.includes(\"Forbidden\");\n\n if (isAuthError) {\n log.warn(\n { connectorId: this.id, errorMessage },\n \"Auth error detected, invalidating caches\"\n );\n await this.close();\n }\n }\n}\n",
|
|
179
179
|
"type": "registry:file",
|
|
180
180
|
"target": "~/chatjs/plugins/mcp/oauth/mcp-client.ts"
|
|
181
181
|
},
|
|
@@ -1037,7 +1037,7 @@
|
|
|
1037
1037
|
"name": "guest-chat",
|
|
1038
1038
|
"description": "Disposable text chat for visitors with isolated sessions and bounded cleanup",
|
|
1039
1039
|
"dependencies": [
|
|
1040
|
-
"ai@7.0.
|
|
1040
|
+
"ai@7.0.172",
|
|
1041
1041
|
"drizzle-orm@^0.45.1",
|
|
1042
1042
|
"zod@4.5.4"
|
|
1043
1043
|
],
|
|
@@ -1508,7 +1508,7 @@
|
|
|
1508
1508
|
"name": "mcp",
|
|
1509
1509
|
"description": "MCP connectors, management pages, OAuth and composer control",
|
|
1510
1510
|
"dependencies": [
|
|
1511
|
-
"@ai-sdk/mcp@2.0.
|
|
1511
|
+
"@ai-sdk/mcp@2.0.99",
|
|
1512
1512
|
"@hookform/resolvers@^5.2.1",
|
|
1513
1513
|
"@modelcontextprotocol/sdk@^1.24.3",
|
|
1514
1514
|
"@tanstack/react-query@^5.104.1",
|
|
@@ -1898,8 +1898,8 @@
|
|
|
1898
1898
|
"name": "vercel-gateway",
|
|
1899
1899
|
"title": "Vercel AI Gateway",
|
|
1900
1900
|
"dependencies": [
|
|
1901
|
-
"@chat-js/gateways@0.2.
|
|
1902
|
-
"@ai-sdk/gateway@4.0.
|
|
1901
|
+
"@chat-js/gateways@0.2.2",
|
|
1902
|
+
"@ai-sdk/gateway@4.0.145"
|
|
1903
1903
|
],
|
|
1904
1904
|
"files": [
|
|
1905
1905
|
{
|
|
@@ -1970,8 +1970,8 @@
|
|
|
1970
1970
|
"name": "openai-gateway",
|
|
1971
1971
|
"title": "OpenAI",
|
|
1972
1972
|
"dependencies": [
|
|
1973
|
-
"@chat-js/gateways@0.2.
|
|
1974
|
-
"@ai-sdk/openai@4.0.
|
|
1973
|
+
"@chat-js/gateways@0.2.2",
|
|
1974
|
+
"@ai-sdk/openai@4.0.117",
|
|
1975
1975
|
"zod@4.5.4"
|
|
1976
1976
|
],
|
|
1977
1977
|
"files": [
|
|
@@ -2033,8 +2033,8 @@
|
|
|
2033
2033
|
"name": "openai-compatible-gateway",
|
|
2034
2034
|
"title": "OpenAI Compatible",
|
|
2035
2035
|
"dependencies": [
|
|
2036
|
-
"@chat-js/gateways@0.2.
|
|
2037
|
-
"@ai-sdk/openai-compatible@3.0.
|
|
2036
|
+
"@chat-js/gateways@0.2.2",
|
|
2037
|
+
"@ai-sdk/openai-compatible@3.0.92",
|
|
2038
2038
|
"zod@4.5.4"
|
|
2039
2039
|
],
|
|
2040
2040
|
"files": [
|
|
@@ -2098,7 +2098,7 @@
|
|
|
2098
2098
|
"name": "openrouter-gateway",
|
|
2099
2099
|
"title": "OpenRouter",
|
|
2100
2100
|
"dependencies": [
|
|
2101
|
-
"@chat-js/gateways@0.2.
|
|
2101
|
+
"@chat-js/gateways@0.2.2",
|
|
2102
2102
|
"@openrouter/ai-sdk-provider@3.0.0",
|
|
2103
2103
|
"zod@4.5.4"
|
|
2104
2104
|
],
|
|
@@ -2168,8 +2168,8 @@
|
|
|
2168
2168
|
"name": "litellm-gateway",
|
|
2169
2169
|
"title": "LiteLLM",
|
|
2170
2170
|
"dependencies": [
|
|
2171
|
-
"@chat-js/gateways@0.2.
|
|
2172
|
-
"@ai-sdk/openai-compatible@3.0.
|
|
2171
|
+
"@chat-js/gateways@0.2.2",
|
|
2172
|
+
"@ai-sdk/openai-compatible@3.0.92"
|
|
2173
2173
|
],
|
|
2174
2174
|
"files": [
|
|
2175
2175
|
{
|
|
@@ -2231,7 +2231,7 @@
|
|
|
2231
2231
|
"title": "Automatic",
|
|
2232
2232
|
"description": "EVE selects Vercel on Vercel, Docker when available, or a simulated shell in development.",
|
|
2233
2233
|
"dependencies": [
|
|
2234
|
-
"eve@npm:@chat-js/eve@1.
|
|
2234
|
+
"eve@npm:@chat-js/eve@1.1.1-chatjs.0"
|
|
2235
2235
|
],
|
|
2236
2236
|
"files": [
|
|
2237
2237
|
{
|
|
@@ -2264,7 +2264,7 @@
|
|
|
2264
2264
|
"title": "Vercel Sandbox",
|
|
2265
2265
|
"description": "Hosted sandbox with native Python and Node processes.",
|
|
2266
2266
|
"dependencies": [
|
|
2267
|
-
"eve@npm:@chat-js/eve@1.
|
|
2267
|
+
"eve@npm:@chat-js/eve@1.1.1-chatjs.0"
|
|
2268
2268
|
],
|
|
2269
2269
|
"files": [
|
|
2270
2270
|
{
|
|
@@ -2311,7 +2311,7 @@
|
|
|
2311
2311
|
"title": "Docker",
|
|
2312
2312
|
"description": "Containers on a reachable Docker host, with native Python and Node processes.",
|
|
2313
2313
|
"dependencies": [
|
|
2314
|
-
"eve@npm:@chat-js/eve@1.
|
|
2314
|
+
"eve@npm:@chat-js/eve@1.1.1-chatjs.0"
|
|
2315
2315
|
],
|
|
2316
2316
|
"files": [
|
|
2317
2317
|
{
|
|
@@ -2344,7 +2344,7 @@
|
|
|
2344
2344
|
"title": "just-bash",
|
|
2345
2345
|
"description": "Simulated shell and filesystem. Cannot run native Python or Node processes.",
|
|
2346
2346
|
"dependencies": [
|
|
2347
|
-
"eve@npm:@chat-js/eve@1.
|
|
2347
|
+
"eve@npm:@chat-js/eve@1.1.1-chatjs.0"
|
|
2348
2348
|
],
|
|
2349
2349
|
"files": [
|
|
2350
2350
|
{
|
|
@@ -2373,7 +2373,7 @@
|
|
|
2373
2373
|
"name": "generate-video",
|
|
2374
2374
|
"description": "Generate videos using the selected gateway and storage",
|
|
2375
2375
|
"dependencies": [
|
|
2376
|
-
"ai@7.0.
|
|
2376
|
+
"ai@7.0.172",
|
|
2377
2377
|
"zod@4.5.4"
|
|
2378
2378
|
],
|
|
2379
2379
|
"files": [
|
|
@@ -2443,7 +2443,7 @@
|
|
|
2443
2443
|
"name": "generate-image",
|
|
2444
2444
|
"description": "Generate and edit images using the selected gateway and storage",
|
|
2445
2445
|
"dependencies": [
|
|
2446
|
-
"ai@7.0.
|
|
2446
|
+
"ai@7.0.172",
|
|
2447
2447
|
"zod@4.5.4",
|
|
2448
2448
|
"lucide-react@0.553.0"
|
|
2449
2449
|
],
|
|
@@ -2539,7 +2539,7 @@
|
|
|
2539
2539
|
"name": "attach-workspace-file",
|
|
2540
2540
|
"description": "Attach workspace files to the conversation as downloads, or import earlier files into the workspace for revision.",
|
|
2541
2541
|
"dependencies": [
|
|
2542
|
-
"eve@npm:@chat-js/eve@1.
|
|
2542
|
+
"eve@npm:@chat-js/eve@1.1.1-chatjs.0",
|
|
2543
2543
|
"zod@4.5.4",
|
|
2544
2544
|
"lucide-react@0.553.0"
|
|
2545
2545
|
],
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "deep-research",
|
|
3
3
|
"description": "Research with installed EVE capabilities; produces a sandbox report. ChatJS adds optional progress UI.",
|
|
4
4
|
"dependencies": [
|
|
5
|
-
"eve@npm:@chat-js/eve@1.
|
|
5
|
+
"eve@npm:@chat-js/eve@1.1.1-chatjs.0",
|
|
6
6
|
"zod@4.5.4"
|
|
7
7
|
],
|
|
8
8
|
"files": [
|
package/dist/r/eve/registry.json
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
"name": "deep-research",
|
|
7
7
|
"description": "Research with installed EVE capabilities; produces a sandbox report. ChatJS adds optional progress UI.",
|
|
8
8
|
"dependencies": [
|
|
9
|
-
"eve@npm:@chat-js/eve@1.
|
|
9
|
+
"eve@npm:@chat-js/eve@1.1.1-chatjs.0",
|
|
10
10
|
"zod@4.5.4"
|
|
11
11
|
],
|
|
12
12
|
"files": [
|
package/dist/r/guest-chat.json
CHANGED
package/dist/r/mcp.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"name": "mcp",
|
|
4
4
|
"description": "MCP connectors, management pages, OAuth and composer control",
|
|
5
5
|
"dependencies": [
|
|
6
|
-
"@ai-sdk/mcp@2.0.
|
|
6
|
+
"@ai-sdk/mcp@2.0.99",
|
|
7
7
|
"@hookform/resolvers@^5.2.1",
|
|
8
8
|
"@modelcontextprotocol/sdk@^1.24.3",
|
|
9
9
|
"@tanstack/react-query@^5.104.1",
|
|
@@ -175,7 +175,7 @@
|
|
|
175
175
|
},
|
|
176
176
|
{
|
|
177
177
|
"path": "src/plugins/mcp/src/oauth/mcp-client.ts",
|
|
178
|
-
"content": "import type {\n ListPromptsResult,\n ListResourcesResult,\n} from \"@modelcontextprotocol/sdk/types.js\";\nimport {\n auth,\n experimental_createMCPClient as createMCPClient,\n} from \"@ai-sdk/mcp\";\nimport { McpOAuthClientProvider } from \"@/chatjs/plugins/mcp/oauth/mcp-oauth-provider\";\nimport { OAuthAuthorizationRequiredError } from \"@/chatjs/plugins/mcp/oauth/oauth-authorization-required-error\";\nimport type { ReadonlyNativeSurface } from \"@/lib/readonly-native-surface\";\nimport type { Tool } from \"ai\";\nimport { config } from \"@/lib/config\";\nimport { createModuleLogger } from \"@/lib/logger\";\nimport { getBaseUrl } from \"@/lib/url\";\n\nconst log = createModuleLogger(\"mcp-client\");\n\nconst INITIAL_CONNECTION_GENERATION = 0;\nconst MCP_CONNECTION_TIMEOUT_MS = 30_000;\n\nconst getMcpErrorMessage = (error: unknown): string => {\n if (error instanceof Error) {\n return error.message;\n }\n return String(error);\n};\n\ntype McpPreconnect = (\n url: string | URL,\n options?: {\n readonly dns?: boolean;\n readonly http?: boolean;\n readonly https?: boolean;\n readonly tcp?: boolean;\n }\n) => void;\n\nconst isMcpPreconnect = (value: unknown): value is McpPreconnect =>\n typeof value === \"function\";\n\n// Bun's fetch type requires preconnect. Node's does not. Delegate when the\n// runtime provides it so one fetch value satisfies both FetchFunction types.\nconst mcpPreconnect: McpPreconnect = (url, options): void => {\n const candidate: object = globalThis.fetch;\n if (!(\"preconnect\" in candidate)) {\n return;\n }\n const method: unknown = candidate.preconnect;\n if (!isMcpPreconnect(method)) {\n return;\n }\n method(url, options);\n};\n\nconst toMcpSdkFetch = (\n fetchImpl: (\n ...args: Parameters<typeof globalThis.fetch>\n ) => ReturnType<typeof globalThis.fetch>\n): typeof globalThis.fetch =>\n Object.assign(fetchImpl, { preconnect: mcpPreconnect });\n\ntype McpClientInstance = Awaited<ReturnType<typeof createMCPClient>>;\n\ntype McpClientStatus =\n | \"disconnected\"\n | \"connecting\"\n | \"connected\"\n | \"authorizing\"\n | \"incompatible\";\n\n/**\n * MCP Client wrapper with OAuth support.\n * Uses @ai-sdk/mcp's createMCPClient with authProvider for OAuth flow.\n */\nexport class MCPClient {\n private client?: McpClientInstance;\n private generation = INITIAL_CONNECTION_GENERATION;\n private connectionAbort?: AbortController;\n private connectPromise?: Promise<void>;\n private readonly invalidateCache?: () => void;\n private oauthProvider: McpOAuthClientProvider;\n private authorizationUrl?: URL;\n private connectionStatus: McpClientStatus = \"disconnected\";\n\n private readonly id: string;\n private readonly name: string;\n private readonly serverConfig: {\n url: string;\n type: \"http\" | \"sse\";\n headers?: Record<string, string>;\n oauthClientId?: string | null;\n oauthClientSecret?: string | null;\n };\n\n public constructor(\n id: string,\n name: string,\n serverConfig: {\n readonly url: string;\n readonly type: \"http\" | \"sse\";\n readonly headers?: Readonly<Record<string, string>>;\n readonly oauthClientId?: string | null;\n readonly oauthClientSecret?: string | null;\n },\n invalidateCache?: () => void\n ) {\n this.invalidateCache = invalidateCache;\n this.id = id;\n this.name = name;\n this.serverConfig = serverConfig;\n this.oauthProvider = this.createOAuthProvider();\n }\n\n private createOAuthProvider(): McpOAuthClientProvider {\n const { generation } = this;\n const baseUrl = getBaseUrl();\n\n return new McpOAuthClientProvider({\n clientMetadata: {\n client_name: `${config.appPrefix}-${this.name}`,\n grant_types: [\"authorization_code\", \"refresh_token\"],\n redirect_uris: [`${baseUrl}/api/mcp/oauth/callback`],\n response_types: [\"code\"],\n scope: \"mcp:tools\",\n software_id: config.appPrefix,\n software_version: \"1.0.0\",\n token_endpoint_auth_method:\n typeof this.serverConfig.oauthClientId === \"string\" &&\n this.serverConfig.oauthClientId !== \"\" &&\n typeof this.serverConfig.oauthClientSecret === \"string\" &&\n this.serverConfig.oauthClientSecret !== \"\"\n ? \"client_secret_basic\"\n : \"none\",\n },\n mcpConnectorId: this.id,\n oauthClientId: this.serverConfig.oauthClientId,\n oauthClientSecret: this.serverConfig.oauthClientSecret,\n onRedirectToAuthorization: (\n authorizationUrl: ReadonlyNativeSurface<URL>\n ): never => {\n if (generation !== this.generation) {\n throw new Error(\"MCP connection was closed\");\n }\n this.authorizationUrl = authorizationUrl;\n throw new OAuthAuthorizationRequiredError(authorizationUrl);\n },\n serverUrl: this.serverConfig.url,\n });\n }\n\n public get status(): McpClientStatus {\n if (this.authorizationUrl) {\n return \"authorizing\";\n }\n if (this.client) {\n return \"connected\";\n }\n return this.connectionStatus;\n }\n\n public getAuthorizationUrl(): URL | undefined {\n return this.authorizationUrl;\n }\n\n public get serverInfo(): McpClientInstance[\"serverInfo\"] | undefined {\n const { client } = this;\n return client && client.serverInfo;\n }\n\n public async connect({\n oauthState,\n abortSignal,\n }: {\n readonly oauthState?: string;\n readonly abortSignal?: Readonly<\n Pick<\n AbortSignal,\n | \"throwIfAborted\"\n | \"reason\"\n | \"addEventListener\"\n | \"removeEventListener\"\n | \"aborted\"\n >\n >;\n } = {}): Promise<void> {\n if (abortSignal) {\n abortSignal.throwIfAborted();\n }\n if (!this.connectPromise) {\n const { generation } = this;\n this.connectPromise = (async (): Promise<void> => {\n try {\n await this.connectOnce(oauthState);\n } finally {\n // Only close() can retire a pending attempt and allow a replacement.\n if (this.generation === generation) {\n this.connectPromise = undefined;\n }\n }\n })();\n }\n if (!abortSignal) {\n await this.connectPromise;\n return;\n }\n const aborted = Promise.withResolvers<never>();\n const cancel = (): void => {\n aborted.reject(abortSignal.reason);\n };\n abortSignal.addEventListener(\"abort\", cancel, { once: true });\n if (abortSignal.aborted) {\n cancel();\n }\n try {\n await Promise.race([this.connectPromise, aborted.promise]);\n } finally {\n abortSignal.removeEventListener(\"abort\", cancel);\n }\n }\n private async connectOnce(oauthState?: string): Promise<void> {\n if (this.status === \"connected\" && this.client) {\n return;\n }\n\n const { generation, oauthProvider } = this;\n this.connectionAbort = new AbortController();\n const signal = AbortSignal.any([\n this.connectionAbort.signal,\n AbortSignal.timeout(MCP_CONNECTION_TIMEOUT_MS),\n ]);\n this.connectionStatus = \"connecting\";\n\n try {\n // Adopt state if provided (for callback reconciliation).\n if (typeof oauthState === \"string\" && oauthState !== \"\") {\n await oauthProvider.adoptState(oauthState);\n }\n signal.throwIfAborted();\n // AI SDK handles 401 internally and calls auth() with the provider\n const client = await createMCPClient({\n initializationOptions: { signal },\n transport: {\n authProvider: oauthProvider,\n fetch: toMcpSdkFetch(oauthProvider.fetch),\n headers: this.serverConfig.headers,\n type: this.serverConfig.type,\n url: this.serverConfig.url,\n },\n });\n\n if (generation !== this.generation || signal.aborted) {\n await client.close();\n signal.throwIfAborted();\n throw new Error(\"MCP connection was closed\");\n }\n this.client = client;\n this.authorizationUrl = undefined;\n this.connectionStatus = \"connected\";\n } catch (error) {\n if (generation !== this.generation || signal.aborted) {\n if (generation === this.generation) {\n this.authorizationUrl = undefined;\n this.connectionStatus = \"disconnected\";\n }\n throw error;\n }\n // If OAuth required error, status becomes \"authorizing\"\n if (error instanceof OAuthAuthorizationRequiredError) {\n this.connectionStatus = \"authorizing\";\n log.info(\n { authUrl: error.authorizationUrl.toString(), connectorId: this.id },\n \"OAuth authorization required\"\n );\n return;\n }\n\n this.connectionStatus = \"disconnected\";\n throw error;\n }\n }\n /**\n * Lightweight connection test - just checks if we can connect without full discovery.\n * Returns connection status without fetching tools/resources/prompts.\n * @param {Readonly<Pick<AbortSignal, \"throwIfAborted\" | \"reason\" | \"addEventListener\" | \"removeEventListener\" | \"aborted\">> | undefined} abortSignal - Cancels this caller while shared initialization continues.\n * @returns {Promise<{ status: McpClientStatus; needsAuth: boolean; error?: string; }>} The connection or authorization status.\n */\n public async attemptConnection(\n abortSignal?: Readonly<\n Pick<\n AbortSignal,\n | \"throwIfAborted\"\n | \"reason\"\n | \"addEventListener\"\n | \"removeEventListener\"\n | \"aborted\"\n >\n >\n ): Promise<{\n status: McpClientStatus;\n needsAuth: boolean;\n error?: string;\n }> {\n // If already connected, return current status\n if (this.status === \"connected\" && this.client) {\n return { needsAuth: false, status: \"connected\" };\n }\n\n // If already in authorizing state, return that\n if (this.authorizationUrl) {\n return { needsAuth: true, status: \"authorizing\" };\n }\n\n try {\n await this.connect({ abortSignal });\n // Check if OAuth is required (authorizationUrl gets set during connect)\n if (this.authorizationUrl !== undefined) {\n return { needsAuth: true, status: \"authorizing\" };\n }\n return {\n needsAuth: false,\n status: this.client ? \"connected\" : \"disconnected\",\n };\n } catch (error) {\n const errorMessage = getMcpErrorMessage(error);\n log.error(\n {\n connectorId: this.id,\n errorMessage,\n errorStack: error instanceof Error ? error.stack : undefined,\n },\n \"attemptConnection failed\"\n );\n\n // Detect incompatible server errors\n if (\n errorMessage.includes(\"does not support dynamic client registration\")\n ) {\n this.connectionStatus = \"incompatible\";\n return {\n error:\n \"Server requires pre-configured OAuth credentials (does not support dynamic client registration)\",\n needsAuth: false,\n status: \"incompatible\",\n };\n }\n\n return { error: errorMessage, needsAuth: false, status: \"disconnected\" };\n }\n }\n /**\n * Called after callback receives code to complete the OAuth flow.\n * @param {string} code - Authorization code received by the callback.\n * @param {string} state - State used to restore the verifier session.\n */\n public async finishAuth(code: string, state: string): Promise<void> {\n const { generation, oauthProvider } = this;\n // Always adopt the state from the callback to load the session with code verifier\n await oauthProvider.adoptState(state);\n\n // Use the auth function from @ai-sdk/mcp to complete the OAuth flow\n await auth(oauthProvider, {\n authorizationCode: code,\n fetchFn: toMcpSdkFetch(oauthProvider.fetch),\n serverUrl: this.serverConfig.url,\n });\n\n if (generation !== this.generation) {\n throw new Error(\"MCP connection was closed\");\n }\n this.authorizationUrl = undefined;\n // Don't set to connected - tokens are saved, next connect() will use them\n }\n /**\n * Get tools from the MCP server, already in AI SDK format.\n * @param {Parameters<McpClientInstance[\"tools\"]>} args - Native SDK schema options.\n * @returns {Promise<Record<string, Tool>>} The discovered SDK tools.\n */\n public async tools(\n ...args: Parameters<NonNullable<McpClientInstance>[\"tools\"]>\n ): Promise<Record<string, Tool>> {\n const { client } = this;\n if (!client) {\n throw new Error(\"Client not connected\");\n }\n try {\n return await client.tools(...args);\n } catch (error) {\n await this.handlePotentialAuthError(error, client);\n throw error;\n }\n }\n /**\n * List resources from the MCP server.\n * @returns {Promise<ListResourcesResult>} The native MCP resource result.\n */\n public async listResources(): Promise<ListResourcesResult> {\n const { client } = this;\n if (!client) {\n throw new Error(\"Client not connected\");\n }\n try {\n return await client.listResources();\n } catch (error) {\n await this.handlePotentialAuthError(error, client);\n throw error;\n }\n }\n /**\n * List prompts from the MCP server.\n * @returns {Promise<ListPromptsResult>} The native MCP prompt result.\n */\n public async listPrompts(): Promise<ListPromptsResult> {\n const { client } = this;\n if (!client) {\n throw new Error(\"Client not connected\");\n }\n try {\n return await client.experimental_listPrompts();\n } catch (error) {\n await this.handlePotentialAuthError(error, client);\n throw error;\n }\n }\n /**\n * Close the connection to the MCP server.\n */\n public async close(): Promise<void> {\n this.generation += 1;\n const { connectionAbort } = this;\n if (connectionAbort) {\n connectionAbort.abort(new Error(\"MCP connection was closed\"));\n }\n this.connectPromise = undefined;\n this.oauthProvider = this.createOAuthProvider();\n const { client } = this;\n this.client = undefined;\n this.authorizationUrl = undefined;\n this.connectionStatus = \"disconnected\";\n try {\n // Await even without a client to preserve cache-invalidation timing.\n await (client && client.close());\n } catch (error) {\n log.error({ connectorId: this.id, error }, \"Error closing MCP client\");\n }\n if (this.invalidateCache) {\n this.invalidateCache();\n }\n }\n /**\n * Check if an error is an auth error (401/403) and invalidate caches if so.\n * @param {unknown} error - Failure from a connected SDK operation.\n * @param {unknown} origin - Client whose failure is being handled.\n */\n private async handlePotentialAuthError(\n error: unknown,\n origin: unknown\n ): Promise<void> {\n if (this.client !== origin) {\n return;\n }\n const errorMessage = getMcpErrorMessage(error);\n const isAuthError =\n errorMessage.includes(\"401\") ||\n errorMessage.includes(\"403\") ||\n errorMessage.includes(\"Unauthorized\") ||\n errorMessage.includes(\"Forbidden\");\n\n if (isAuthError) {\n log.warn(\n { connectorId: this.id, errorMessage },\n \"Auth error detected, invalidating caches\"\n );\n await this.close();\n }\n }\n}\n",
|
|
178
|
+
"content": "import type {\n ListPromptsResult,\n ListResourcesResult,\n} from \"@modelcontextprotocol/sdk/types.js\";\nimport {\n auth,\n experimental_createMCPClient as createMCPClient,\n} from \"@ai-sdk/mcp\";\nimport { McpOAuthClientProvider } from \"@/chatjs/plugins/mcp/oauth/mcp-oauth-provider\";\nimport { OAuthAuthorizationRequiredError } from \"@/chatjs/plugins/mcp/oauth/oauth-authorization-required-error\";\nimport type { ReadonlyNativeSurface } from \"@/lib/readonly-native-surface\";\nimport type { Tool } from \"ai\";\nimport { config } from \"@/lib/config\";\nimport { createModuleLogger } from \"@/lib/logger\";\nimport { getBaseUrl } from \"@/lib/url\";\n\nconst log = createModuleLogger(\"mcp-client\");\n\nconst INITIAL_CONNECTION_GENERATION = 0;\nconst MCP_CONNECTION_TIMEOUT_MS = 30_000;\n\nconst getMcpErrorMessage = (error: unknown): string => {\n if (error instanceof Error) {\n return error.message;\n }\n return String(error);\n};\n\ntype McpPreconnect = (\n url: string | URL,\n options?: {\n readonly dns?: boolean;\n readonly http?: boolean;\n readonly https?: boolean;\n readonly tcp?: boolean;\n }\n) => void;\n\nconst isMcpPreconnect = (value: unknown): value is McpPreconnect =>\n typeof value === \"function\";\n\n// Bun's fetch type requires preconnect. Node's does not. Delegate when the\n// runtime provides it so one fetch value satisfies both FetchFunction types.\nconst mcpPreconnect: McpPreconnect = (url, options): void => {\n const candidate: object = globalThis.fetch;\n if (!(\"preconnect\" in candidate)) {\n return;\n }\n const method: unknown = candidate.preconnect;\n if (!isMcpPreconnect(method)) {\n return;\n }\n method(url, options);\n};\n\nconst toMcpSdkFetch = (\n fetchImpl: (\n ...args: Parameters<typeof globalThis.fetch>\n ) => ReturnType<typeof globalThis.fetch>\n): typeof globalThis.fetch =>\n Object.assign(fetchImpl, { preconnect: mcpPreconnect });\n\ntype McpClientInstance = Awaited<ReturnType<typeof createMCPClient>>;\n\ntype McpClientStatus =\n | \"disconnected\"\n | \"connecting\"\n | \"connected\"\n | \"authorizing\"\n | \"incompatible\";\n\n/**\n * MCP Client wrapper with OAuth support.\n * Uses @ai-sdk/mcp's createMCPClient with authProvider for OAuth flow.\n */\nexport class MCPClient {\n private client?: McpClientInstance;\n private generation = INITIAL_CONNECTION_GENERATION;\n private connectionAbort?: AbortController;\n private connectPromise?: Promise<void>;\n private readonly invalidateCache?: () => void;\n private oauthProvider: McpOAuthClientProvider;\n private authorizationUrl?: URL;\n private connectionStatus: McpClientStatus = \"disconnected\";\n\n private readonly id: string;\n private readonly name: string;\n private readonly serverConfig: {\n url: string;\n type: \"http\" | \"sse\";\n headers?: Record<string, string>;\n oauthClientId?: string | null;\n oauthClientSecret?: string | null;\n };\n\n public constructor(\n id: string,\n name: string,\n serverConfig: {\n readonly url: string;\n readonly type: \"http\" | \"sse\";\n readonly headers?: Readonly<Record<string, string>>;\n readonly oauthClientId?: string | null;\n readonly oauthClientSecret?: string | null;\n },\n invalidateCache?: () => void\n ) {\n this.invalidateCache = invalidateCache;\n this.id = id;\n this.name = name;\n this.serverConfig = serverConfig;\n this.oauthProvider = this.createOAuthProvider();\n }\n\n private createOAuthProvider(): McpOAuthClientProvider {\n const { generation } = this;\n const baseUrl = getBaseUrl();\n\n return new McpOAuthClientProvider({\n clientMetadata: {\n client_name: `${config.appPrefix}-${this.name}`,\n grant_types: [\"authorization_code\", \"refresh_token\"],\n redirect_uris: [`${baseUrl}/api/mcp/oauth/callback`],\n response_types: [\"code\"],\n scope: \"mcp:tools\",\n software_id: config.appPrefix,\n software_version: \"1.0.0\",\n token_endpoint_auth_method:\n typeof this.serverConfig.oauthClientId === \"string\" &&\n this.serverConfig.oauthClientId !== \"\" &&\n typeof this.serverConfig.oauthClientSecret === \"string\" &&\n this.serverConfig.oauthClientSecret !== \"\"\n ? \"client_secret_basic\"\n : \"none\",\n },\n mcpConnectorId: this.id,\n oauthClientId: this.serverConfig.oauthClientId,\n oauthClientSecret: this.serverConfig.oauthClientSecret,\n onRedirectToAuthorization: (\n authorizationUrl: ReadonlyNativeSurface<URL>\n ): never => {\n if (generation !== this.generation) {\n throw new Error(\"MCP connection was closed\");\n }\n this.authorizationUrl = authorizationUrl;\n throw new OAuthAuthorizationRequiredError(authorizationUrl);\n },\n serverUrl: this.serverConfig.url,\n });\n }\n\n public get status(): McpClientStatus {\n if (this.authorizationUrl) {\n return \"authorizing\";\n }\n if (this.client) {\n return \"connected\";\n }\n return this.connectionStatus;\n }\n\n public getAuthorizationUrl(): URL | undefined {\n return this.authorizationUrl;\n }\n\n public get serverInfo(): McpClientInstance[\"serverInfo\"] | undefined {\n const { client } = this;\n return client && client.serverInfo;\n }\n\n public async connect({\n oauthState,\n abortSignal,\n }: {\n readonly oauthState?: string;\n readonly abortSignal?: Readonly<\n Pick<\n AbortSignal,\n | \"throwIfAborted\"\n | \"reason\"\n | \"addEventListener\"\n | \"removeEventListener\"\n | \"aborted\"\n >\n >;\n } = {}): Promise<void> {\n if (abortSignal) {\n abortSignal.throwIfAborted();\n }\n if (!this.connectPromise) {\n const { generation } = this;\n this.connectPromise = (async (): Promise<void> => {\n try {\n await this.connectOnce(oauthState);\n } finally {\n // Only close() can retire a pending attempt and allow a replacement.\n if (this.generation === generation) {\n this.connectPromise = undefined;\n }\n }\n })();\n }\n if (!abortSignal) {\n await this.connectPromise;\n return;\n }\n const aborted = Promise.withResolvers<never>();\n const cancel = (): void => {\n aborted.reject(abortSignal.reason);\n };\n abortSignal.addEventListener(\"abort\", cancel, { once: true });\n if (abortSignal.aborted) {\n cancel();\n }\n try {\n await Promise.race([this.connectPromise, aborted.promise]);\n } finally {\n abortSignal.removeEventListener(\"abort\", cancel);\n }\n }\n private async connectOnce(oauthState?: string): Promise<void> {\n if (this.status === \"connected\" && this.client) {\n return;\n }\n\n const { generation, oauthProvider } = this;\n this.connectionAbort = new AbortController();\n const signal = AbortSignal.any([\n this.connectionAbort.signal,\n AbortSignal.timeout(MCP_CONNECTION_TIMEOUT_MS),\n ]);\n this.connectionStatus = \"connecting\";\n\n try {\n // Adopt state if provided (for callback reconciliation).\n if (typeof oauthState === \"string\" && oauthState !== \"\") {\n await oauthProvider.adoptState(oauthState);\n }\n signal.throwIfAborted();\n // AI SDK handles 401 internally and calls auth() with the provider\n const client = await createMCPClient({\n initializationOptions: { signal },\n transport: {\n authProvider: oauthProvider,\n fetch: toMcpSdkFetch(oauthProvider.fetch),\n headers: this.serverConfig.headers,\n type: this.serverConfig.type,\n url: this.serverConfig.url,\n },\n });\n\n if (generation !== this.generation || signal.aborted) {\n await client.close();\n signal.throwIfAborted();\n throw new Error(\"MCP connection was closed\");\n }\n this.client = client;\n this.authorizationUrl = undefined;\n this.connectionStatus = \"connected\";\n } catch (error) {\n if (generation !== this.generation || signal.aborted) {\n if (generation === this.generation) {\n this.authorizationUrl = undefined;\n this.connectionStatus = \"disconnected\";\n }\n throw error;\n }\n // If OAuth required error, status becomes \"authorizing\"\n if (error instanceof OAuthAuthorizationRequiredError) {\n this.connectionStatus = \"authorizing\";\n log.info(\n { authUrl: error.authorizationUrl.toString(), connectorId: this.id },\n \"OAuth authorization required\"\n );\n return;\n }\n\n this.connectionStatus = \"disconnected\";\n throw error;\n }\n }\n /**\n * Lightweight connection test - just checks if we can connect without full discovery.\n * Returns connection status without fetching tools/resources/prompts.\n * @param {Readonly<Pick<AbortSignal, \"throwIfAborted\" | \"reason\" | \"addEventListener\" | \"removeEventListener\" | \"aborted\">> | undefined} abortSignal - Cancels this caller while shared initialization continues.\n * @returns {Promise<{ status: McpClientStatus; needsAuth: boolean; error?: string; }>} The connection or authorization status.\n */\n public async attemptConnection(\n abortSignal?: Readonly<\n Pick<\n AbortSignal,\n | \"throwIfAborted\"\n | \"reason\"\n | \"addEventListener\"\n | \"removeEventListener\"\n | \"aborted\"\n >\n >\n ): Promise<{\n status: McpClientStatus;\n needsAuth: boolean;\n error?: string;\n }> {\n // If already connected, return current status\n if (this.status === \"connected\" && this.client) {\n return { needsAuth: false, status: \"connected\" };\n }\n\n // If already in authorizing state, return that\n if (this.authorizationUrl) {\n return { needsAuth: true, status: \"authorizing\" };\n }\n\n try {\n await this.connect({ abortSignal });\n // Check if OAuth is required (authorizationUrl gets set during connect)\n if (this.authorizationUrl !== undefined) {\n return { needsAuth: true, status: \"authorizing\" };\n }\n return {\n needsAuth: false,\n status: this.client ? \"connected\" : \"disconnected\",\n };\n } catch (error) {\n const errorMessage = getMcpErrorMessage(error);\n log.error(\n {\n connectorId: this.id,\n errorMessage,\n errorStack: error instanceof Error ? error.stack : undefined,\n },\n \"attemptConnection failed\"\n );\n\n // Detect incompatible server errors\n if (\n errorMessage.includes(\"does not support dynamic client registration\")\n ) {\n this.connectionStatus = \"incompatible\";\n return {\n error:\n \"Server requires pre-configured OAuth credentials (does not support dynamic client registration)\",\n needsAuth: false,\n status: \"incompatible\",\n };\n }\n\n return { error: errorMessage, needsAuth: false, status: \"disconnected\" };\n }\n }\n /**\n * Called after callback receives code to complete the OAuth flow.\n * @param {string} code - Authorization code received by the callback.\n * @param {string} state - State used to restore the verifier session.\n */\n public async finishAuth(code: string, state: string): Promise<void> {\n const { generation, oauthProvider } = this;\n // Always adopt the state from the callback to load the session with code verifier\n await oauthProvider.adoptState(state);\n\n // Use the auth function from @ai-sdk/mcp to complete the OAuth flow\n await auth(oauthProvider, {\n authorizationCode: code,\n fetchFn: toMcpSdkFetch(oauthProvider.fetch),\n serverUrl: this.serverConfig.url,\n });\n\n if (generation !== this.generation) {\n throw new Error(\"MCP connection was closed\");\n }\n this.authorizationUrl = undefined;\n // Don't set to connected - tokens are saved, next connect() will use them\n }\n /**\n * Get tools from the MCP server, already in AI SDK format.\n * @param {Parameters<McpClientInstance[\"tools\"]>} args - Native SDK schema options.\n * @returns {Promise<Record<string, Tool>>} The discovered SDK tools.\n */\n public async tools(\n ...args: Parameters<NonNullable<McpClientInstance>[\"tools\"]>\n ): Promise<Record<string, Tool>> {\n const { client } = this;\n if (!client) {\n throw new Error(\"Client not connected\");\n }\n try {\n return await client.tools(...args);\n } catch (error) {\n await this.handlePotentialAuthError(error, client);\n throw error;\n }\n }\n /**\n * List resources from the MCP server.\n * @returns {Promise<ListResourcesResult>} The native MCP resource result.\n */\n public async listResources(): Promise<ListResourcesResult> {\n const { client } = this;\n if (!client) {\n throw new Error(\"Client not connected\");\n }\n try {\n return await client.listResources();\n } catch (error) {\n await this.handlePotentialAuthError(error, client);\n throw error;\n }\n }\n /**\n * List prompts from the MCP server.\n * @returns {Promise<ListPromptsResult>} The native MCP prompt result.\n */\n public async listPrompts(): Promise<ListPromptsResult> {\n const { client } = this;\n if (!client) {\n throw new Error(\"Client not connected\");\n }\n try {\n return await client.listPrompts();\n } catch (error) {\n await this.handlePotentialAuthError(error, client);\n throw error;\n }\n }\n /**\n * Close the connection to the MCP server.\n */\n public async close(): Promise<void> {\n this.generation += 1;\n const { connectionAbort } = this;\n if (connectionAbort) {\n connectionAbort.abort(new Error(\"MCP connection was closed\"));\n }\n this.connectPromise = undefined;\n this.oauthProvider = this.createOAuthProvider();\n const { client } = this;\n this.client = undefined;\n this.authorizationUrl = undefined;\n this.connectionStatus = \"disconnected\";\n try {\n // Await even without a client to preserve cache-invalidation timing.\n await (client && client.close());\n } catch (error) {\n log.error({ connectorId: this.id, error }, \"Error closing MCP client\");\n }\n if (this.invalidateCache) {\n this.invalidateCache();\n }\n }\n /**\n * Check if an error is an auth error (401/403) and invalidate caches if so.\n * @param {unknown} error - Failure from a connected SDK operation.\n * @param {unknown} origin - Client whose failure is being handled.\n */\n private async handlePotentialAuthError(\n error: unknown,\n origin: unknown\n ): Promise<void> {\n if (this.client !== origin) {\n return;\n }\n const errorMessage = getMcpErrorMessage(error);\n const isAuthError =\n errorMessage.includes(\"401\") ||\n errorMessage.includes(\"403\") ||\n errorMessage.includes(\"Unauthorized\") ||\n errorMessage.includes(\"Forbidden\");\n\n if (isAuthError) {\n log.warn(\n { connectorId: this.id, errorMessage },\n \"Auth error detected, invalidating caches\"\n );\n await this.close();\n }\n }\n}\n",
|
|
179
179
|
"type": "registry:file",
|
|
180
180
|
"target": "~/chatjs/plugins/mcp/oauth/mcp-client.ts"
|
|
181
181
|
},
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"name": "attach-workspace-file",
|
|
4
4
|
"description": "Attach workspace files to the conversation as downloads, or import earlier files into the workspace for revision.",
|
|
5
5
|
"dependencies": [
|
|
6
|
-
"eve@npm:@chat-js/eve@1.
|
|
6
|
+
"eve@npm:@chat-js/eve@1.1.1-chatjs.0",
|
|
7
7
|
"zod@4.5.4",
|
|
8
8
|
"lucide-react@0.553.0"
|
|
9
9
|
],
|
package/dist/r/radix/mcp.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"name": "mcp",
|
|
4
4
|
"description": "MCP connectors, management pages, OAuth and composer control",
|
|
5
5
|
"dependencies": [
|
|
6
|
-
"@ai-sdk/mcp@2.0.
|
|
6
|
+
"@ai-sdk/mcp@2.0.99",
|
|
7
7
|
"@hookform/resolvers@^5.2.1",
|
|
8
8
|
"@modelcontextprotocol/sdk@^1.24.3",
|
|
9
9
|
"@tanstack/react-query@^5.104.1",
|
|
@@ -175,7 +175,7 @@
|
|
|
175
175
|
},
|
|
176
176
|
{
|
|
177
177
|
"path": "src/plugins/mcp/src/oauth/mcp-client.ts",
|
|
178
|
-
"content": "import type {\n ListPromptsResult,\n ListResourcesResult,\n} from \"@modelcontextprotocol/sdk/types.js\";\nimport {\n auth,\n experimental_createMCPClient as createMCPClient,\n} from \"@ai-sdk/mcp\";\nimport { McpOAuthClientProvider } from \"@/chatjs/plugins/mcp/oauth/mcp-oauth-provider\";\nimport { OAuthAuthorizationRequiredError } from \"@/chatjs/plugins/mcp/oauth/oauth-authorization-required-error\";\nimport type { ReadonlyNativeSurface } from \"@/lib/readonly-native-surface\";\nimport type { Tool } from \"ai\";\nimport { config } from \"@/lib/config\";\nimport { createModuleLogger } from \"@/lib/logger\";\nimport { getBaseUrl } from \"@/lib/url\";\n\nconst log = createModuleLogger(\"mcp-client\");\n\nconst INITIAL_CONNECTION_GENERATION = 0;\nconst MCP_CONNECTION_TIMEOUT_MS = 30_000;\n\nconst getMcpErrorMessage = (error: unknown): string => {\n if (error instanceof Error) {\n return error.message;\n }\n return String(error);\n};\n\ntype McpPreconnect = (\n url: string | URL,\n options?: {\n readonly dns?: boolean;\n readonly http?: boolean;\n readonly https?: boolean;\n readonly tcp?: boolean;\n }\n) => void;\n\nconst isMcpPreconnect = (value: unknown): value is McpPreconnect =>\n typeof value === \"function\";\n\n// Bun's fetch type requires preconnect. Node's does not. Delegate when the\n// runtime provides it so one fetch value satisfies both FetchFunction types.\nconst mcpPreconnect: McpPreconnect = (url, options): void => {\n const candidate: object = globalThis.fetch;\n if (!(\"preconnect\" in candidate)) {\n return;\n }\n const method: unknown = candidate.preconnect;\n if (!isMcpPreconnect(method)) {\n return;\n }\n method(url, options);\n};\n\nconst toMcpSdkFetch = (\n fetchImpl: (\n ...args: Parameters<typeof globalThis.fetch>\n ) => ReturnType<typeof globalThis.fetch>\n): typeof globalThis.fetch =>\n Object.assign(fetchImpl, { preconnect: mcpPreconnect });\n\ntype McpClientInstance = Awaited<ReturnType<typeof createMCPClient>>;\n\ntype McpClientStatus =\n | \"disconnected\"\n | \"connecting\"\n | \"connected\"\n | \"authorizing\"\n | \"incompatible\";\n\n/**\n * MCP Client wrapper with OAuth support.\n * Uses @ai-sdk/mcp's createMCPClient with authProvider for OAuth flow.\n */\nexport class MCPClient {\n private client?: McpClientInstance;\n private generation = INITIAL_CONNECTION_GENERATION;\n private connectionAbort?: AbortController;\n private connectPromise?: Promise<void>;\n private readonly invalidateCache?: () => void;\n private oauthProvider: McpOAuthClientProvider;\n private authorizationUrl?: URL;\n private connectionStatus: McpClientStatus = \"disconnected\";\n\n private readonly id: string;\n private readonly name: string;\n private readonly serverConfig: {\n url: string;\n type: \"http\" | \"sse\";\n headers?: Record<string, string>;\n oauthClientId?: string | null;\n oauthClientSecret?: string | null;\n };\n\n public constructor(\n id: string,\n name: string,\n serverConfig: {\n readonly url: string;\n readonly type: \"http\" | \"sse\";\n readonly headers?: Readonly<Record<string, string>>;\n readonly oauthClientId?: string | null;\n readonly oauthClientSecret?: string | null;\n },\n invalidateCache?: () => void\n ) {\n this.invalidateCache = invalidateCache;\n this.id = id;\n this.name = name;\n this.serverConfig = serverConfig;\n this.oauthProvider = this.createOAuthProvider();\n }\n\n private createOAuthProvider(): McpOAuthClientProvider {\n const { generation } = this;\n const baseUrl = getBaseUrl();\n\n return new McpOAuthClientProvider({\n clientMetadata: {\n client_name: `${config.appPrefix}-${this.name}`,\n grant_types: [\"authorization_code\", \"refresh_token\"],\n redirect_uris: [`${baseUrl}/api/mcp/oauth/callback`],\n response_types: [\"code\"],\n scope: \"mcp:tools\",\n software_id: config.appPrefix,\n software_version: \"1.0.0\",\n token_endpoint_auth_method:\n typeof this.serverConfig.oauthClientId === \"string\" &&\n this.serverConfig.oauthClientId !== \"\" &&\n typeof this.serverConfig.oauthClientSecret === \"string\" &&\n this.serverConfig.oauthClientSecret !== \"\"\n ? \"client_secret_basic\"\n : \"none\",\n },\n mcpConnectorId: this.id,\n oauthClientId: this.serverConfig.oauthClientId,\n oauthClientSecret: this.serverConfig.oauthClientSecret,\n onRedirectToAuthorization: (\n authorizationUrl: ReadonlyNativeSurface<URL>\n ): never => {\n if (generation !== this.generation) {\n throw new Error(\"MCP connection was closed\");\n }\n this.authorizationUrl = authorizationUrl;\n throw new OAuthAuthorizationRequiredError(authorizationUrl);\n },\n serverUrl: this.serverConfig.url,\n });\n }\n\n public get status(): McpClientStatus {\n if (this.authorizationUrl) {\n return \"authorizing\";\n }\n if (this.client) {\n return \"connected\";\n }\n return this.connectionStatus;\n }\n\n public getAuthorizationUrl(): URL | undefined {\n return this.authorizationUrl;\n }\n\n public get serverInfo(): McpClientInstance[\"serverInfo\"] | undefined {\n const { client } = this;\n return client && client.serverInfo;\n }\n\n public async connect({\n oauthState,\n abortSignal,\n }: {\n readonly oauthState?: string;\n readonly abortSignal?: Readonly<\n Pick<\n AbortSignal,\n | \"throwIfAborted\"\n | \"reason\"\n | \"addEventListener\"\n | \"removeEventListener\"\n | \"aborted\"\n >\n >;\n } = {}): Promise<void> {\n if (abortSignal) {\n abortSignal.throwIfAborted();\n }\n if (!this.connectPromise) {\n const { generation } = this;\n this.connectPromise = (async (): Promise<void> => {\n try {\n await this.connectOnce(oauthState);\n } finally {\n // Only close() can retire a pending attempt and allow a replacement.\n if (this.generation === generation) {\n this.connectPromise = undefined;\n }\n }\n })();\n }\n if (!abortSignal) {\n await this.connectPromise;\n return;\n }\n const aborted = Promise.withResolvers<never>();\n const cancel = (): void => {\n aborted.reject(abortSignal.reason);\n };\n abortSignal.addEventListener(\"abort\", cancel, { once: true });\n if (abortSignal.aborted) {\n cancel();\n }\n try {\n await Promise.race([this.connectPromise, aborted.promise]);\n } finally {\n abortSignal.removeEventListener(\"abort\", cancel);\n }\n }\n private async connectOnce(oauthState?: string): Promise<void> {\n if (this.status === \"connected\" && this.client) {\n return;\n }\n\n const { generation, oauthProvider } = this;\n this.connectionAbort = new AbortController();\n const signal = AbortSignal.any([\n this.connectionAbort.signal,\n AbortSignal.timeout(MCP_CONNECTION_TIMEOUT_MS),\n ]);\n this.connectionStatus = \"connecting\";\n\n try {\n // Adopt state if provided (for callback reconciliation).\n if (typeof oauthState === \"string\" && oauthState !== \"\") {\n await oauthProvider.adoptState(oauthState);\n }\n signal.throwIfAborted();\n // AI SDK handles 401 internally and calls auth() with the provider\n const client = await createMCPClient({\n initializationOptions: { signal },\n transport: {\n authProvider: oauthProvider,\n fetch: toMcpSdkFetch(oauthProvider.fetch),\n headers: this.serverConfig.headers,\n type: this.serverConfig.type,\n url: this.serverConfig.url,\n },\n });\n\n if (generation !== this.generation || signal.aborted) {\n await client.close();\n signal.throwIfAborted();\n throw new Error(\"MCP connection was closed\");\n }\n this.client = client;\n this.authorizationUrl = undefined;\n this.connectionStatus = \"connected\";\n } catch (error) {\n if (generation !== this.generation || signal.aborted) {\n if (generation === this.generation) {\n this.authorizationUrl = undefined;\n this.connectionStatus = \"disconnected\";\n }\n throw error;\n }\n // If OAuth required error, status becomes \"authorizing\"\n if (error instanceof OAuthAuthorizationRequiredError) {\n this.connectionStatus = \"authorizing\";\n log.info(\n { authUrl: error.authorizationUrl.toString(), connectorId: this.id },\n \"OAuth authorization required\"\n );\n return;\n }\n\n this.connectionStatus = \"disconnected\";\n throw error;\n }\n }\n /**\n * Lightweight connection test - just checks if we can connect without full discovery.\n * Returns connection status without fetching tools/resources/prompts.\n * @param {Readonly<Pick<AbortSignal, \"throwIfAborted\" | \"reason\" | \"addEventListener\" | \"removeEventListener\" | \"aborted\">> | undefined} abortSignal - Cancels this caller while shared initialization continues.\n * @returns {Promise<{ status: McpClientStatus; needsAuth: boolean; error?: string; }>} The connection or authorization status.\n */\n public async attemptConnection(\n abortSignal?: Readonly<\n Pick<\n AbortSignal,\n | \"throwIfAborted\"\n | \"reason\"\n | \"addEventListener\"\n | \"removeEventListener\"\n | \"aborted\"\n >\n >\n ): Promise<{\n status: McpClientStatus;\n needsAuth: boolean;\n error?: string;\n }> {\n // If already connected, return current status\n if (this.status === \"connected\" && this.client) {\n return { needsAuth: false, status: \"connected\" };\n }\n\n // If already in authorizing state, return that\n if (this.authorizationUrl) {\n return { needsAuth: true, status: \"authorizing\" };\n }\n\n try {\n await this.connect({ abortSignal });\n // Check if OAuth is required (authorizationUrl gets set during connect)\n if (this.authorizationUrl !== undefined) {\n return { needsAuth: true, status: \"authorizing\" };\n }\n return {\n needsAuth: false,\n status: this.client ? \"connected\" : \"disconnected\",\n };\n } catch (error) {\n const errorMessage = getMcpErrorMessage(error);\n log.error(\n {\n connectorId: this.id,\n errorMessage,\n errorStack: error instanceof Error ? error.stack : undefined,\n },\n \"attemptConnection failed\"\n );\n\n // Detect incompatible server errors\n if (\n errorMessage.includes(\"does not support dynamic client registration\")\n ) {\n this.connectionStatus = \"incompatible\";\n return {\n error:\n \"Server requires pre-configured OAuth credentials (does not support dynamic client registration)\",\n needsAuth: false,\n status: \"incompatible\",\n };\n }\n\n return { error: errorMessage, needsAuth: false, status: \"disconnected\" };\n }\n }\n /**\n * Called after callback receives code to complete the OAuth flow.\n * @param {string} code - Authorization code received by the callback.\n * @param {string} state - State used to restore the verifier session.\n */\n public async finishAuth(code: string, state: string): Promise<void> {\n const { generation, oauthProvider } = this;\n // Always adopt the state from the callback to load the session with code verifier\n await oauthProvider.adoptState(state);\n\n // Use the auth function from @ai-sdk/mcp to complete the OAuth flow\n await auth(oauthProvider, {\n authorizationCode: code,\n fetchFn: toMcpSdkFetch(oauthProvider.fetch),\n serverUrl: this.serverConfig.url,\n });\n\n if (generation !== this.generation) {\n throw new Error(\"MCP connection was closed\");\n }\n this.authorizationUrl = undefined;\n // Don't set to connected - tokens are saved, next connect() will use them\n }\n /**\n * Get tools from the MCP server, already in AI SDK format.\n * @param {Parameters<McpClientInstance[\"tools\"]>} args - Native SDK schema options.\n * @returns {Promise<Record<string, Tool>>} The discovered SDK tools.\n */\n public async tools(\n ...args: Parameters<NonNullable<McpClientInstance>[\"tools\"]>\n ): Promise<Record<string, Tool>> {\n const { client } = this;\n if (!client) {\n throw new Error(\"Client not connected\");\n }\n try {\n return await client.tools(...args);\n } catch (error) {\n await this.handlePotentialAuthError(error, client);\n throw error;\n }\n }\n /**\n * List resources from the MCP server.\n * @returns {Promise<ListResourcesResult>} The native MCP resource result.\n */\n public async listResources(): Promise<ListResourcesResult> {\n const { client } = this;\n if (!client) {\n throw new Error(\"Client not connected\");\n }\n try {\n return await client.listResources();\n } catch (error) {\n await this.handlePotentialAuthError(error, client);\n throw error;\n }\n }\n /**\n * List prompts from the MCP server.\n * @returns {Promise<ListPromptsResult>} The native MCP prompt result.\n */\n public async listPrompts(): Promise<ListPromptsResult> {\n const { client } = this;\n if (!client) {\n throw new Error(\"Client not connected\");\n }\n try {\n return await client.experimental_listPrompts();\n } catch (error) {\n await this.handlePotentialAuthError(error, client);\n throw error;\n }\n }\n /**\n * Close the connection to the MCP server.\n */\n public async close(): Promise<void> {\n this.generation += 1;\n const { connectionAbort } = this;\n if (connectionAbort) {\n connectionAbort.abort(new Error(\"MCP connection was closed\"));\n }\n this.connectPromise = undefined;\n this.oauthProvider = this.createOAuthProvider();\n const { client } = this;\n this.client = undefined;\n this.authorizationUrl = undefined;\n this.connectionStatus = \"disconnected\";\n try {\n // Await even without a client to preserve cache-invalidation timing.\n await (client && client.close());\n } catch (error) {\n log.error({ connectorId: this.id, error }, \"Error closing MCP client\");\n }\n if (this.invalidateCache) {\n this.invalidateCache();\n }\n }\n /**\n * Check if an error is an auth error (401/403) and invalidate caches if so.\n * @param {unknown} error - Failure from a connected SDK operation.\n * @param {unknown} origin - Client whose failure is being handled.\n */\n private async handlePotentialAuthError(\n error: unknown,\n origin: unknown\n ): Promise<void> {\n if (this.client !== origin) {\n return;\n }\n const errorMessage = getMcpErrorMessage(error);\n const isAuthError =\n errorMessage.includes(\"401\") ||\n errorMessage.includes(\"403\") ||\n errorMessage.includes(\"Unauthorized\") ||\n errorMessage.includes(\"Forbidden\");\n\n if (isAuthError) {\n log.warn(\n { connectorId: this.id, errorMessage },\n \"Auth error detected, invalidating caches\"\n );\n await this.close();\n }\n }\n}\n",
|
|
178
|
+
"content": "import type {\n ListPromptsResult,\n ListResourcesResult,\n} from \"@modelcontextprotocol/sdk/types.js\";\nimport {\n auth,\n experimental_createMCPClient as createMCPClient,\n} from \"@ai-sdk/mcp\";\nimport { McpOAuthClientProvider } from \"@/chatjs/plugins/mcp/oauth/mcp-oauth-provider\";\nimport { OAuthAuthorizationRequiredError } from \"@/chatjs/plugins/mcp/oauth/oauth-authorization-required-error\";\nimport type { ReadonlyNativeSurface } from \"@/lib/readonly-native-surface\";\nimport type { Tool } from \"ai\";\nimport { config } from \"@/lib/config\";\nimport { createModuleLogger } from \"@/lib/logger\";\nimport { getBaseUrl } from \"@/lib/url\";\n\nconst log = createModuleLogger(\"mcp-client\");\n\nconst INITIAL_CONNECTION_GENERATION = 0;\nconst MCP_CONNECTION_TIMEOUT_MS = 30_000;\n\nconst getMcpErrorMessage = (error: unknown): string => {\n if (error instanceof Error) {\n return error.message;\n }\n return String(error);\n};\n\ntype McpPreconnect = (\n url: string | URL,\n options?: {\n readonly dns?: boolean;\n readonly http?: boolean;\n readonly https?: boolean;\n readonly tcp?: boolean;\n }\n) => void;\n\nconst isMcpPreconnect = (value: unknown): value is McpPreconnect =>\n typeof value === \"function\";\n\n// Bun's fetch type requires preconnect. Node's does not. Delegate when the\n// runtime provides it so one fetch value satisfies both FetchFunction types.\nconst mcpPreconnect: McpPreconnect = (url, options): void => {\n const candidate: object = globalThis.fetch;\n if (!(\"preconnect\" in candidate)) {\n return;\n }\n const method: unknown = candidate.preconnect;\n if (!isMcpPreconnect(method)) {\n return;\n }\n method(url, options);\n};\n\nconst toMcpSdkFetch = (\n fetchImpl: (\n ...args: Parameters<typeof globalThis.fetch>\n ) => ReturnType<typeof globalThis.fetch>\n): typeof globalThis.fetch =>\n Object.assign(fetchImpl, { preconnect: mcpPreconnect });\n\ntype McpClientInstance = Awaited<ReturnType<typeof createMCPClient>>;\n\ntype McpClientStatus =\n | \"disconnected\"\n | \"connecting\"\n | \"connected\"\n | \"authorizing\"\n | \"incompatible\";\n\n/**\n * MCP Client wrapper with OAuth support.\n * Uses @ai-sdk/mcp's createMCPClient with authProvider for OAuth flow.\n */\nexport class MCPClient {\n private client?: McpClientInstance;\n private generation = INITIAL_CONNECTION_GENERATION;\n private connectionAbort?: AbortController;\n private connectPromise?: Promise<void>;\n private readonly invalidateCache?: () => void;\n private oauthProvider: McpOAuthClientProvider;\n private authorizationUrl?: URL;\n private connectionStatus: McpClientStatus = \"disconnected\";\n\n private readonly id: string;\n private readonly name: string;\n private readonly serverConfig: {\n url: string;\n type: \"http\" | \"sse\";\n headers?: Record<string, string>;\n oauthClientId?: string | null;\n oauthClientSecret?: string | null;\n };\n\n public constructor(\n id: string,\n name: string,\n serverConfig: {\n readonly url: string;\n readonly type: \"http\" | \"sse\";\n readonly headers?: Readonly<Record<string, string>>;\n readonly oauthClientId?: string | null;\n readonly oauthClientSecret?: string | null;\n },\n invalidateCache?: () => void\n ) {\n this.invalidateCache = invalidateCache;\n this.id = id;\n this.name = name;\n this.serverConfig = serverConfig;\n this.oauthProvider = this.createOAuthProvider();\n }\n\n private createOAuthProvider(): McpOAuthClientProvider {\n const { generation } = this;\n const baseUrl = getBaseUrl();\n\n return new McpOAuthClientProvider({\n clientMetadata: {\n client_name: `${config.appPrefix}-${this.name}`,\n grant_types: [\"authorization_code\", \"refresh_token\"],\n redirect_uris: [`${baseUrl}/api/mcp/oauth/callback`],\n response_types: [\"code\"],\n scope: \"mcp:tools\",\n software_id: config.appPrefix,\n software_version: \"1.0.0\",\n token_endpoint_auth_method:\n typeof this.serverConfig.oauthClientId === \"string\" &&\n this.serverConfig.oauthClientId !== \"\" &&\n typeof this.serverConfig.oauthClientSecret === \"string\" &&\n this.serverConfig.oauthClientSecret !== \"\"\n ? \"client_secret_basic\"\n : \"none\",\n },\n mcpConnectorId: this.id,\n oauthClientId: this.serverConfig.oauthClientId,\n oauthClientSecret: this.serverConfig.oauthClientSecret,\n onRedirectToAuthorization: (\n authorizationUrl: ReadonlyNativeSurface<URL>\n ): never => {\n if (generation !== this.generation) {\n throw new Error(\"MCP connection was closed\");\n }\n this.authorizationUrl = authorizationUrl;\n throw new OAuthAuthorizationRequiredError(authorizationUrl);\n },\n serverUrl: this.serverConfig.url,\n });\n }\n\n public get status(): McpClientStatus {\n if (this.authorizationUrl) {\n return \"authorizing\";\n }\n if (this.client) {\n return \"connected\";\n }\n return this.connectionStatus;\n }\n\n public getAuthorizationUrl(): URL | undefined {\n return this.authorizationUrl;\n }\n\n public get serverInfo(): McpClientInstance[\"serverInfo\"] | undefined {\n const { client } = this;\n return client && client.serverInfo;\n }\n\n public async connect({\n oauthState,\n abortSignal,\n }: {\n readonly oauthState?: string;\n readonly abortSignal?: Readonly<\n Pick<\n AbortSignal,\n | \"throwIfAborted\"\n | \"reason\"\n | \"addEventListener\"\n | \"removeEventListener\"\n | \"aborted\"\n >\n >;\n } = {}): Promise<void> {\n if (abortSignal) {\n abortSignal.throwIfAborted();\n }\n if (!this.connectPromise) {\n const { generation } = this;\n this.connectPromise = (async (): Promise<void> => {\n try {\n await this.connectOnce(oauthState);\n } finally {\n // Only close() can retire a pending attempt and allow a replacement.\n if (this.generation === generation) {\n this.connectPromise = undefined;\n }\n }\n })();\n }\n if (!abortSignal) {\n await this.connectPromise;\n return;\n }\n const aborted = Promise.withResolvers<never>();\n const cancel = (): void => {\n aborted.reject(abortSignal.reason);\n };\n abortSignal.addEventListener(\"abort\", cancel, { once: true });\n if (abortSignal.aborted) {\n cancel();\n }\n try {\n await Promise.race([this.connectPromise, aborted.promise]);\n } finally {\n abortSignal.removeEventListener(\"abort\", cancel);\n }\n }\n private async connectOnce(oauthState?: string): Promise<void> {\n if (this.status === \"connected\" && this.client) {\n return;\n }\n\n const { generation, oauthProvider } = this;\n this.connectionAbort = new AbortController();\n const signal = AbortSignal.any([\n this.connectionAbort.signal,\n AbortSignal.timeout(MCP_CONNECTION_TIMEOUT_MS),\n ]);\n this.connectionStatus = \"connecting\";\n\n try {\n // Adopt state if provided (for callback reconciliation).\n if (typeof oauthState === \"string\" && oauthState !== \"\") {\n await oauthProvider.adoptState(oauthState);\n }\n signal.throwIfAborted();\n // AI SDK handles 401 internally and calls auth() with the provider\n const client = await createMCPClient({\n initializationOptions: { signal },\n transport: {\n authProvider: oauthProvider,\n fetch: toMcpSdkFetch(oauthProvider.fetch),\n headers: this.serverConfig.headers,\n type: this.serverConfig.type,\n url: this.serverConfig.url,\n },\n });\n\n if (generation !== this.generation || signal.aborted) {\n await client.close();\n signal.throwIfAborted();\n throw new Error(\"MCP connection was closed\");\n }\n this.client = client;\n this.authorizationUrl = undefined;\n this.connectionStatus = \"connected\";\n } catch (error) {\n if (generation !== this.generation || signal.aborted) {\n if (generation === this.generation) {\n this.authorizationUrl = undefined;\n this.connectionStatus = \"disconnected\";\n }\n throw error;\n }\n // If OAuth required error, status becomes \"authorizing\"\n if (error instanceof OAuthAuthorizationRequiredError) {\n this.connectionStatus = \"authorizing\";\n log.info(\n { authUrl: error.authorizationUrl.toString(), connectorId: this.id },\n \"OAuth authorization required\"\n );\n return;\n }\n\n this.connectionStatus = \"disconnected\";\n throw error;\n }\n }\n /**\n * Lightweight connection test - just checks if we can connect without full discovery.\n * Returns connection status without fetching tools/resources/prompts.\n * @param {Readonly<Pick<AbortSignal, \"throwIfAborted\" | \"reason\" | \"addEventListener\" | \"removeEventListener\" | \"aborted\">> | undefined} abortSignal - Cancels this caller while shared initialization continues.\n * @returns {Promise<{ status: McpClientStatus; needsAuth: boolean; error?: string; }>} The connection or authorization status.\n */\n public async attemptConnection(\n abortSignal?: Readonly<\n Pick<\n AbortSignal,\n | \"throwIfAborted\"\n | \"reason\"\n | \"addEventListener\"\n | \"removeEventListener\"\n | \"aborted\"\n >\n >\n ): Promise<{\n status: McpClientStatus;\n needsAuth: boolean;\n error?: string;\n }> {\n // If already connected, return current status\n if (this.status === \"connected\" && this.client) {\n return { needsAuth: false, status: \"connected\" };\n }\n\n // If already in authorizing state, return that\n if (this.authorizationUrl) {\n return { needsAuth: true, status: \"authorizing\" };\n }\n\n try {\n await this.connect({ abortSignal });\n // Check if OAuth is required (authorizationUrl gets set during connect)\n if (this.authorizationUrl !== undefined) {\n return { needsAuth: true, status: \"authorizing\" };\n }\n return {\n needsAuth: false,\n status: this.client ? \"connected\" : \"disconnected\",\n };\n } catch (error) {\n const errorMessage = getMcpErrorMessage(error);\n log.error(\n {\n connectorId: this.id,\n errorMessage,\n errorStack: error instanceof Error ? error.stack : undefined,\n },\n \"attemptConnection failed\"\n );\n\n // Detect incompatible server errors\n if (\n errorMessage.includes(\"does not support dynamic client registration\")\n ) {\n this.connectionStatus = \"incompatible\";\n return {\n error:\n \"Server requires pre-configured OAuth credentials (does not support dynamic client registration)\",\n needsAuth: false,\n status: \"incompatible\",\n };\n }\n\n return { error: errorMessage, needsAuth: false, status: \"disconnected\" };\n }\n }\n /**\n * Called after callback receives code to complete the OAuth flow.\n * @param {string} code - Authorization code received by the callback.\n * @param {string} state - State used to restore the verifier session.\n */\n public async finishAuth(code: string, state: string): Promise<void> {\n const { generation, oauthProvider } = this;\n // Always adopt the state from the callback to load the session with code verifier\n await oauthProvider.adoptState(state);\n\n // Use the auth function from @ai-sdk/mcp to complete the OAuth flow\n await auth(oauthProvider, {\n authorizationCode: code,\n fetchFn: toMcpSdkFetch(oauthProvider.fetch),\n serverUrl: this.serverConfig.url,\n });\n\n if (generation !== this.generation) {\n throw new Error(\"MCP connection was closed\");\n }\n this.authorizationUrl = undefined;\n // Don't set to connected - tokens are saved, next connect() will use them\n }\n /**\n * Get tools from the MCP server, already in AI SDK format.\n * @param {Parameters<McpClientInstance[\"tools\"]>} args - Native SDK schema options.\n * @returns {Promise<Record<string, Tool>>} The discovered SDK tools.\n */\n public async tools(\n ...args: Parameters<NonNullable<McpClientInstance>[\"tools\"]>\n ): Promise<Record<string, Tool>> {\n const { client } = this;\n if (!client) {\n throw new Error(\"Client not connected\");\n }\n try {\n return await client.tools(...args);\n } catch (error) {\n await this.handlePotentialAuthError(error, client);\n throw error;\n }\n }\n /**\n * List resources from the MCP server.\n * @returns {Promise<ListResourcesResult>} The native MCP resource result.\n */\n public async listResources(): Promise<ListResourcesResult> {\n const { client } = this;\n if (!client) {\n throw new Error(\"Client not connected\");\n }\n try {\n return await client.listResources();\n } catch (error) {\n await this.handlePotentialAuthError(error, client);\n throw error;\n }\n }\n /**\n * List prompts from the MCP server.\n * @returns {Promise<ListPromptsResult>} The native MCP prompt result.\n */\n public async listPrompts(): Promise<ListPromptsResult> {\n const { client } = this;\n if (!client) {\n throw new Error(\"Client not connected\");\n }\n try {\n return await client.listPrompts();\n } catch (error) {\n await this.handlePotentialAuthError(error, client);\n throw error;\n }\n }\n /**\n * Close the connection to the MCP server.\n */\n public async close(): Promise<void> {\n this.generation += 1;\n const { connectionAbort } = this;\n if (connectionAbort) {\n connectionAbort.abort(new Error(\"MCP connection was closed\"));\n }\n this.connectPromise = undefined;\n this.oauthProvider = this.createOAuthProvider();\n const { client } = this;\n this.client = undefined;\n this.authorizationUrl = undefined;\n this.connectionStatus = \"disconnected\";\n try {\n // Await even without a client to preserve cache-invalidation timing.\n await (client && client.close());\n } catch (error) {\n log.error({ connectorId: this.id, error }, \"Error closing MCP client\");\n }\n if (this.invalidateCache) {\n this.invalidateCache();\n }\n }\n /**\n * Check if an error is an auth error (401/403) and invalidate caches if so.\n * @param {unknown} error - Failure from a connected SDK operation.\n * @param {unknown} origin - Client whose failure is being handled.\n */\n private async handlePotentialAuthError(\n error: unknown,\n origin: unknown\n ): Promise<void> {\n if (this.client !== origin) {\n return;\n }\n const errorMessage = getMcpErrorMessage(error);\n const isAuthError =\n errorMessage.includes(\"401\") ||\n errorMessage.includes(\"403\") ||\n errorMessage.includes(\"Unauthorized\") ||\n errorMessage.includes(\"Forbidden\");\n\n if (isAuthError) {\n log.warn(\n { connectorId: this.id, errorMessage },\n \"Auth error detected, invalidating caches\"\n );\n await this.close();\n }\n }\n}\n",
|
|
179
179
|
"type": "registry:file",
|
|
180
180
|
"target": "~/chatjs/plugins/mcp/oauth/mcp-client.ts"
|
|
181
181
|
},
|
|
@@ -1037,7 +1037,7 @@
|
|
|
1037
1037
|
"name": "guest-chat",
|
|
1038
1038
|
"description": "Disposable text chat for visitors with isolated sessions and bounded cleanup",
|
|
1039
1039
|
"dependencies": [
|
|
1040
|
-
"ai@7.0.
|
|
1040
|
+
"ai@7.0.172",
|
|
1041
1041
|
"drizzle-orm@^0.45.1",
|
|
1042
1042
|
"zod@4.5.4"
|
|
1043
1043
|
],
|
|
@@ -1508,7 +1508,7 @@
|
|
|
1508
1508
|
"name": "mcp",
|
|
1509
1509
|
"description": "MCP connectors, management pages, OAuth and composer control",
|
|
1510
1510
|
"dependencies": [
|
|
1511
|
-
"@ai-sdk/mcp@2.0.
|
|
1511
|
+
"@ai-sdk/mcp@2.0.99",
|
|
1512
1512
|
"@hookform/resolvers@^5.2.1",
|
|
1513
1513
|
"@modelcontextprotocol/sdk@^1.24.3",
|
|
1514
1514
|
"@tanstack/react-query@^5.104.1",
|
|
@@ -1898,8 +1898,8 @@
|
|
|
1898
1898
|
"name": "vercel-gateway",
|
|
1899
1899
|
"title": "Vercel AI Gateway",
|
|
1900
1900
|
"dependencies": [
|
|
1901
|
-
"@chat-js/gateways@0.2.
|
|
1902
|
-
"@ai-sdk/gateway@4.0.
|
|
1901
|
+
"@chat-js/gateways@0.2.2",
|
|
1902
|
+
"@ai-sdk/gateway@4.0.145"
|
|
1903
1903
|
],
|
|
1904
1904
|
"files": [
|
|
1905
1905
|
{
|
|
@@ -1970,8 +1970,8 @@
|
|
|
1970
1970
|
"name": "openai-gateway",
|
|
1971
1971
|
"title": "OpenAI",
|
|
1972
1972
|
"dependencies": [
|
|
1973
|
-
"@chat-js/gateways@0.2.
|
|
1974
|
-
"@ai-sdk/openai@4.0.
|
|
1973
|
+
"@chat-js/gateways@0.2.2",
|
|
1974
|
+
"@ai-sdk/openai@4.0.117",
|
|
1975
1975
|
"zod@4.5.4"
|
|
1976
1976
|
],
|
|
1977
1977
|
"files": [
|
|
@@ -2033,8 +2033,8 @@
|
|
|
2033
2033
|
"name": "openai-compatible-gateway",
|
|
2034
2034
|
"title": "OpenAI Compatible",
|
|
2035
2035
|
"dependencies": [
|
|
2036
|
-
"@chat-js/gateways@0.2.
|
|
2037
|
-
"@ai-sdk/openai-compatible@3.0.
|
|
2036
|
+
"@chat-js/gateways@0.2.2",
|
|
2037
|
+
"@ai-sdk/openai-compatible@3.0.92",
|
|
2038
2038
|
"zod@4.5.4"
|
|
2039
2039
|
],
|
|
2040
2040
|
"files": [
|
|
@@ -2098,7 +2098,7 @@
|
|
|
2098
2098
|
"name": "openrouter-gateway",
|
|
2099
2099
|
"title": "OpenRouter",
|
|
2100
2100
|
"dependencies": [
|
|
2101
|
-
"@chat-js/gateways@0.2.
|
|
2101
|
+
"@chat-js/gateways@0.2.2",
|
|
2102
2102
|
"@openrouter/ai-sdk-provider@3.0.0",
|
|
2103
2103
|
"zod@4.5.4"
|
|
2104
2104
|
],
|
|
@@ -2168,8 +2168,8 @@
|
|
|
2168
2168
|
"name": "litellm-gateway",
|
|
2169
2169
|
"title": "LiteLLM",
|
|
2170
2170
|
"dependencies": [
|
|
2171
|
-
"@chat-js/gateways@0.2.
|
|
2172
|
-
"@ai-sdk/openai-compatible@3.0.
|
|
2171
|
+
"@chat-js/gateways@0.2.2",
|
|
2172
|
+
"@ai-sdk/openai-compatible@3.0.92"
|
|
2173
2173
|
],
|
|
2174
2174
|
"files": [
|
|
2175
2175
|
{
|
|
@@ -2231,7 +2231,7 @@
|
|
|
2231
2231
|
"title": "Automatic",
|
|
2232
2232
|
"description": "EVE selects Vercel on Vercel, Docker when available, or a simulated shell in development.",
|
|
2233
2233
|
"dependencies": [
|
|
2234
|
-
"eve@npm:@chat-js/eve@1.
|
|
2234
|
+
"eve@npm:@chat-js/eve@1.1.1-chatjs.0"
|
|
2235
2235
|
],
|
|
2236
2236
|
"files": [
|
|
2237
2237
|
{
|
|
@@ -2264,7 +2264,7 @@
|
|
|
2264
2264
|
"title": "Vercel Sandbox",
|
|
2265
2265
|
"description": "Hosted sandbox with native Python and Node processes.",
|
|
2266
2266
|
"dependencies": [
|
|
2267
|
-
"eve@npm:@chat-js/eve@1.
|
|
2267
|
+
"eve@npm:@chat-js/eve@1.1.1-chatjs.0"
|
|
2268
2268
|
],
|
|
2269
2269
|
"files": [
|
|
2270
2270
|
{
|
|
@@ -2311,7 +2311,7 @@
|
|
|
2311
2311
|
"title": "Docker",
|
|
2312
2312
|
"description": "Containers on a reachable Docker host, with native Python and Node processes.",
|
|
2313
2313
|
"dependencies": [
|
|
2314
|
-
"eve@npm:@chat-js/eve@1.
|
|
2314
|
+
"eve@npm:@chat-js/eve@1.1.1-chatjs.0"
|
|
2315
2315
|
],
|
|
2316
2316
|
"files": [
|
|
2317
2317
|
{
|
|
@@ -2344,7 +2344,7 @@
|
|
|
2344
2344
|
"title": "just-bash",
|
|
2345
2345
|
"description": "Simulated shell and filesystem. Cannot run native Python or Node processes.",
|
|
2346
2346
|
"dependencies": [
|
|
2347
|
-
"eve@npm:@chat-js/eve@1.
|
|
2347
|
+
"eve@npm:@chat-js/eve@1.1.1-chatjs.0"
|
|
2348
2348
|
],
|
|
2349
2349
|
"files": [
|
|
2350
2350
|
{
|
|
@@ -2373,7 +2373,7 @@
|
|
|
2373
2373
|
"name": "generate-video",
|
|
2374
2374
|
"description": "Generate videos using the selected gateway and storage",
|
|
2375
2375
|
"dependencies": [
|
|
2376
|
-
"ai@7.0.
|
|
2376
|
+
"ai@7.0.172",
|
|
2377
2377
|
"zod@4.5.4"
|
|
2378
2378
|
],
|
|
2379
2379
|
"files": [
|
|
@@ -2443,7 +2443,7 @@
|
|
|
2443
2443
|
"name": "generate-image",
|
|
2444
2444
|
"description": "Generate and edit images using the selected gateway and storage",
|
|
2445
2445
|
"dependencies": [
|
|
2446
|
-
"ai@7.0.
|
|
2446
|
+
"ai@7.0.172",
|
|
2447
2447
|
"zod@4.5.4",
|
|
2448
2448
|
"lucide-react@0.553.0"
|
|
2449
2449
|
],
|
|
@@ -2539,7 +2539,7 @@
|
|
|
2539
2539
|
"name": "attach-workspace-file",
|
|
2540
2540
|
"description": "Attach workspace files to the conversation as downloads, or import earlier files into the workspace for revision.",
|
|
2541
2541
|
"dependencies": [
|
|
2542
|
-
"eve@npm:@chat-js/eve@1.
|
|
2542
|
+
"eve@npm:@chat-js/eve@1.1.1-chatjs.0",
|
|
2543
2543
|
"zod@4.5.4",
|
|
2544
2544
|
"lucide-react@0.553.0"
|
|
2545
2545
|
],
|
package/dist/r/registry.json
CHANGED
|
@@ -1037,7 +1037,7 @@
|
|
|
1037
1037
|
"name": "guest-chat",
|
|
1038
1038
|
"description": "Disposable text chat for visitors with isolated sessions and bounded cleanup",
|
|
1039
1039
|
"dependencies": [
|
|
1040
|
-
"ai@7.0.
|
|
1040
|
+
"ai@7.0.172",
|
|
1041
1041
|
"drizzle-orm@^0.45.1",
|
|
1042
1042
|
"zod@4.5.4"
|
|
1043
1043
|
],
|
|
@@ -1508,7 +1508,7 @@
|
|
|
1508
1508
|
"name": "mcp",
|
|
1509
1509
|
"description": "MCP connectors, management pages, OAuth and composer control",
|
|
1510
1510
|
"dependencies": [
|
|
1511
|
-
"@ai-sdk/mcp@2.0.
|
|
1511
|
+
"@ai-sdk/mcp@2.0.99",
|
|
1512
1512
|
"@hookform/resolvers@^5.2.1",
|
|
1513
1513
|
"@modelcontextprotocol/sdk@^1.24.3",
|
|
1514
1514
|
"@tanstack/react-query@^5.104.1",
|
|
@@ -1898,8 +1898,8 @@
|
|
|
1898
1898
|
"name": "vercel-gateway",
|
|
1899
1899
|
"title": "Vercel AI Gateway",
|
|
1900
1900
|
"dependencies": [
|
|
1901
|
-
"@chat-js/gateways@0.2.
|
|
1902
|
-
"@ai-sdk/gateway@4.0.
|
|
1901
|
+
"@chat-js/gateways@0.2.2",
|
|
1902
|
+
"@ai-sdk/gateway@4.0.145"
|
|
1903
1903
|
],
|
|
1904
1904
|
"files": [
|
|
1905
1905
|
{
|
|
@@ -1970,8 +1970,8 @@
|
|
|
1970
1970
|
"name": "openai-gateway",
|
|
1971
1971
|
"title": "OpenAI",
|
|
1972
1972
|
"dependencies": [
|
|
1973
|
-
"@chat-js/gateways@0.2.
|
|
1974
|
-
"@ai-sdk/openai@4.0.
|
|
1973
|
+
"@chat-js/gateways@0.2.2",
|
|
1974
|
+
"@ai-sdk/openai@4.0.117",
|
|
1975
1975
|
"zod@4.5.4"
|
|
1976
1976
|
],
|
|
1977
1977
|
"files": [
|
|
@@ -2033,8 +2033,8 @@
|
|
|
2033
2033
|
"name": "openai-compatible-gateway",
|
|
2034
2034
|
"title": "OpenAI Compatible",
|
|
2035
2035
|
"dependencies": [
|
|
2036
|
-
"@chat-js/gateways@0.2.
|
|
2037
|
-
"@ai-sdk/openai-compatible@3.0.
|
|
2036
|
+
"@chat-js/gateways@0.2.2",
|
|
2037
|
+
"@ai-sdk/openai-compatible@3.0.92",
|
|
2038
2038
|
"zod@4.5.4"
|
|
2039
2039
|
],
|
|
2040
2040
|
"files": [
|
|
@@ -2098,7 +2098,7 @@
|
|
|
2098
2098
|
"name": "openrouter-gateway",
|
|
2099
2099
|
"title": "OpenRouter",
|
|
2100
2100
|
"dependencies": [
|
|
2101
|
-
"@chat-js/gateways@0.2.
|
|
2101
|
+
"@chat-js/gateways@0.2.2",
|
|
2102
2102
|
"@openrouter/ai-sdk-provider@3.0.0",
|
|
2103
2103
|
"zod@4.5.4"
|
|
2104
2104
|
],
|
|
@@ -2168,8 +2168,8 @@
|
|
|
2168
2168
|
"name": "litellm-gateway",
|
|
2169
2169
|
"title": "LiteLLM",
|
|
2170
2170
|
"dependencies": [
|
|
2171
|
-
"@chat-js/gateways@0.2.
|
|
2172
|
-
"@ai-sdk/openai-compatible@3.0.
|
|
2171
|
+
"@chat-js/gateways@0.2.2",
|
|
2172
|
+
"@ai-sdk/openai-compatible@3.0.92"
|
|
2173
2173
|
],
|
|
2174
2174
|
"files": [
|
|
2175
2175
|
{
|
|
@@ -2231,7 +2231,7 @@
|
|
|
2231
2231
|
"title": "Automatic",
|
|
2232
2232
|
"description": "EVE selects Vercel on Vercel, Docker when available, or a simulated shell in development.",
|
|
2233
2233
|
"dependencies": [
|
|
2234
|
-
"eve@npm:@chat-js/eve@1.
|
|
2234
|
+
"eve@npm:@chat-js/eve@1.1.1-chatjs.0"
|
|
2235
2235
|
],
|
|
2236
2236
|
"files": [
|
|
2237
2237
|
{
|
|
@@ -2264,7 +2264,7 @@
|
|
|
2264
2264
|
"title": "Vercel Sandbox",
|
|
2265
2265
|
"description": "Hosted sandbox with native Python and Node processes.",
|
|
2266
2266
|
"dependencies": [
|
|
2267
|
-
"eve@npm:@chat-js/eve@1.
|
|
2267
|
+
"eve@npm:@chat-js/eve@1.1.1-chatjs.0"
|
|
2268
2268
|
],
|
|
2269
2269
|
"files": [
|
|
2270
2270
|
{
|
|
@@ -2311,7 +2311,7 @@
|
|
|
2311
2311
|
"title": "Docker",
|
|
2312
2312
|
"description": "Containers on a reachable Docker host, with native Python and Node processes.",
|
|
2313
2313
|
"dependencies": [
|
|
2314
|
-
"eve@npm:@chat-js/eve@1.
|
|
2314
|
+
"eve@npm:@chat-js/eve@1.1.1-chatjs.0"
|
|
2315
2315
|
],
|
|
2316
2316
|
"files": [
|
|
2317
2317
|
{
|
|
@@ -2344,7 +2344,7 @@
|
|
|
2344
2344
|
"title": "just-bash",
|
|
2345
2345
|
"description": "Simulated shell and filesystem. Cannot run native Python or Node processes.",
|
|
2346
2346
|
"dependencies": [
|
|
2347
|
-
"eve@npm:@chat-js/eve@1.
|
|
2347
|
+
"eve@npm:@chat-js/eve@1.1.1-chatjs.0"
|
|
2348
2348
|
],
|
|
2349
2349
|
"files": [
|
|
2350
2350
|
{
|
|
@@ -2373,7 +2373,7 @@
|
|
|
2373
2373
|
"name": "generate-video",
|
|
2374
2374
|
"description": "Generate videos using the selected gateway and storage",
|
|
2375
2375
|
"dependencies": [
|
|
2376
|
-
"ai@7.0.
|
|
2376
|
+
"ai@7.0.172",
|
|
2377
2377
|
"zod@4.5.4"
|
|
2378
2378
|
],
|
|
2379
2379
|
"files": [
|
|
@@ -2443,7 +2443,7 @@
|
|
|
2443
2443
|
"name": "generate-image",
|
|
2444
2444
|
"description": "Generate and edit images using the selected gateway and storage",
|
|
2445
2445
|
"dependencies": [
|
|
2446
|
-
"ai@7.0.
|
|
2446
|
+
"ai@7.0.172",
|
|
2447
2447
|
"zod@4.5.4",
|
|
2448
2448
|
"lucide-react@0.553.0"
|
|
2449
2449
|
],
|
|
@@ -2539,7 +2539,7 @@
|
|
|
2539
2539
|
"name": "attach-workspace-file",
|
|
2540
2540
|
"description": "Attach workspace files to the conversation as downloads, or import earlier files into the workspace for revision.",
|
|
2541
2541
|
"dependencies": [
|
|
2542
|
-
"eve@npm:@chat-js/eve@1.
|
|
2542
|
+
"eve@npm:@chat-js/eve@1.1.1-chatjs.0",
|
|
2543
2543
|
"zod@4.5.4",
|
|
2544
2544
|
"lucide-react@0.553.0"
|
|
2545
2545
|
],
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chat-js/registry",
|
|
3
|
-
"version": "0.2.0-beta.
|
|
3
|
+
"version": "0.2.0-beta.6",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "ChatJS tool and gateway registry items",
|
|
6
6
|
"keywords": [
|
|
@@ -46,13 +46,13 @@
|
|
|
46
46
|
"demo:sync": "bun scripts/demo-sync.ts"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
|
-
"@ai-sdk/anthropic": "4.0.
|
|
50
|
-
"@ai-sdk/gateway": "4.0.
|
|
51
|
-
"@ai-sdk/google": "4.0.
|
|
52
|
-
"@ai-sdk/mcp": "2.0.
|
|
53
|
-
"@ai-sdk/openai": "4.0.
|
|
54
|
-
"@ai-sdk/openai-compatible": "3.0.
|
|
55
|
-
"@ai-sdk/provider": "4.0.
|
|
49
|
+
"@ai-sdk/anthropic": "4.0.104",
|
|
50
|
+
"@ai-sdk/gateway": "4.0.145",
|
|
51
|
+
"@ai-sdk/google": "4.0.120",
|
|
52
|
+
"@ai-sdk/mcp": "2.0.99",
|
|
53
|
+
"@ai-sdk/openai": "4.0.117",
|
|
54
|
+
"@ai-sdk/openai-compatible": "3.0.92",
|
|
55
|
+
"@ai-sdk/provider": "4.0.38",
|
|
56
56
|
"@better-auth/electron": "1.6.2",
|
|
57
57
|
"@chat-js/gateways": "workspace:*",
|
|
58
58
|
"@chat-js/registry-validation": "workspace:*",
|
|
@@ -72,14 +72,14 @@
|
|
|
72
72
|
"@types/react-dom": "19.2.3",
|
|
73
73
|
"@vercel/blob": "2.4.0",
|
|
74
74
|
"@vercel/oidc": "3.2.0",
|
|
75
|
-
"ai": "7.0.
|
|
75
|
+
"ai": "7.0.172",
|
|
76
76
|
"ajv": "8.18.0",
|
|
77
77
|
"basic-ftp": "^5.0.5",
|
|
78
78
|
"better-auth": "1.6.2",
|
|
79
79
|
"browser-image-compression": "^2.0.2",
|
|
80
80
|
"date-fns": "^4.1.0",
|
|
81
81
|
"drizzle-orm": "^0.45.1",
|
|
82
|
-
"eve": "npm:@chat-js/eve@1.
|
|
82
|
+
"eve": "npm:@chat-js/eve@1.1.1-chatjs.0",
|
|
83
83
|
"files-sdk": "2.5.0",
|
|
84
84
|
"geist": "^1.7.2",
|
|
85
85
|
"guarded-fetch": "^0.1.4",
|