integrate-sdk 0.8.42-dev.0 → 0.8.42
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/adapters/auto-routes.js +1 -1
- package/dist/adapters/base-handler.js +561 -0
- package/dist/adapters/index.js +1 -1
- package/dist/adapters/nextjs.js +1 -1
- package/dist/adapters/node.js +1 -1
- package/dist/adapters/svelte-kit.js +1 -1
- package/dist/adapters/tanstack-start.js +1 -1
- package/dist/ai/cloudflare.d.ts +158 -0
- package/dist/ai/cloudflare.d.ts.map +1 -0
- package/dist/ai/cloudflare.js +4249 -0
- package/dist/ai/langchain.d.ts +139 -0
- package/dist/ai/langchain.d.ts.map +1 -0
- package/dist/ai/langchain.js +4237 -0
- package/dist/ai/llamaindex.d.ts +125 -0
- package/dist/ai/llamaindex.d.ts.map +1 -0
- package/dist/ai/llamaindex.js +4236 -0
- package/dist/ai/mastra.d.ts +138 -0
- package/dist/ai/mastra.d.ts.map +1 -0
- package/dist/ai/mastra.js +4240 -0
- package/dist/index.js +1 -1
- package/dist/oauth.js +1 -1
- package/dist/server.js +1 -1
- package/dist/src/ai/cloudflare.d.ts +158 -0
- package/dist/src/ai/cloudflare.d.ts.map +1 -0
- package/dist/src/ai/langchain.d.ts +139 -0
- package/dist/src/ai/langchain.d.ts.map +1 -0
- package/dist/src/ai/llamaindex.d.ts +125 -0
- package/dist/src/ai/llamaindex.d.ts.map +1 -0
- package/dist/src/ai/mastra.d.ts +138 -0
- package/dist/src/ai/mastra.d.ts.map +1 -0
- package/dist/src/integrations/vercel-ai.d.ts +127 -0
- package/dist/src/integrations/vercel-ai.d.ts.map +1 -0
- package/dist/src/plugins/generic.d.ts +99 -0
- package/dist/src/plugins/generic.d.ts.map +1 -0
- package/dist/src/plugins/github-client.d.ts +320 -0
- package/dist/src/plugins/github-client.d.ts.map +1 -0
- package/dist/src/plugins/github.d.ts +89 -0
- package/dist/src/plugins/github.d.ts.map +1 -0
- package/dist/src/plugins/gmail-client.d.ts +106 -0
- package/dist/src/plugins/gmail-client.d.ts.map +1 -0
- package/dist/src/plugins/gmail.d.ts +87 -0
- package/dist/src/plugins/gmail.d.ts.map +1 -0
- package/dist/src/plugins/server-client.d.ts +18 -0
- package/dist/src/plugins/server-client.d.ts.map +1 -0
- package/dist/src/plugins/types.d.ts +70 -0
- package/dist/src/plugins/types.d.ts.map +1 -0
- package/package.json +2 -2
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LangChain Integration
|
|
3
|
+
*
|
|
4
|
+
* Helper functions to convert MCP tools to LangChain DynamicStructuredTool format
|
|
5
|
+
*/
|
|
6
|
+
import { z } from "zod";
|
|
7
|
+
import type { MCPClient } from "../client.js";
|
|
8
|
+
import type { MCPTool } from "../protocol/messages.js";
|
|
9
|
+
import { type AIToolsOptions } from "./utils.js";
|
|
10
|
+
/**
|
|
11
|
+
* LangChain DynamicStructuredTool definition
|
|
12
|
+
* Compatible with @langchain/core/tools
|
|
13
|
+
*/
|
|
14
|
+
export interface LangChainTool {
|
|
15
|
+
name: string;
|
|
16
|
+
description: string;
|
|
17
|
+
schema: z.ZodType<any>;
|
|
18
|
+
func: (...args: any[]) => Promise<string>;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Options for converting MCP tools to LangChain format
|
|
22
|
+
*/
|
|
23
|
+
export interface LangChainToolsOptions extends AIToolsOptions {
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Convert a single MCP tool to LangChain DynamicStructuredTool format
|
|
27
|
+
*
|
|
28
|
+
* @param mcpTool - The MCP tool definition
|
|
29
|
+
* @param client - The MCP client instance (used for executing the tool)
|
|
30
|
+
* @param options - Optional configuration including provider tokens
|
|
31
|
+
* @returns LangChain compatible tool definition
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```typescript
|
|
35
|
+
* const langchainTool = convertMCPToolToLangChain(mcpTool, client);
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
export declare function convertMCPToolToLangChain(mcpTool: MCPTool, client: MCPClient<any>, options?: LangChainToolsOptions): LangChainTool;
|
|
39
|
+
/**
|
|
40
|
+
* Convert all enabled MCP tools to LangChain DynamicStructuredTool format
|
|
41
|
+
*
|
|
42
|
+
* @param client - The MCP client instance (must be connected)
|
|
43
|
+
* @param options - Optional configuration including provider tokens
|
|
44
|
+
* @returns Array of LangChain compatible tool definitions
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* ```typescript
|
|
48
|
+
* // Client-side usage
|
|
49
|
+
* const tools = convertMCPToolsToLangChain(mcpClient);
|
|
50
|
+
*
|
|
51
|
+
* // Server-side with provider tokens
|
|
52
|
+
* const tools = convertMCPToolsToLangChain(serverClient, {
|
|
53
|
+
* providerTokens: { github: 'ghp_...', gmail: 'ya29...' }
|
|
54
|
+
* });
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
export declare function convertMCPToolsToLangChain(client: MCPClient<any>, options?: LangChainToolsOptions): LangChainTool[];
|
|
58
|
+
/**
|
|
59
|
+
* Get tools in a format compatible with LangChain
|
|
60
|
+
*
|
|
61
|
+
* Automatically connects the client if not already connected.
|
|
62
|
+
* Returns tool definitions that can be used with DynamicStructuredTool.
|
|
63
|
+
*
|
|
64
|
+
* @param client - The MCP client instance
|
|
65
|
+
* @param options - Optional configuration including provider tokens for server-side usage
|
|
66
|
+
* @returns Array of tools ready to use with LangChain
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* ```typescript
|
|
70
|
+
* // Client-side usage
|
|
71
|
+
* import { createMCPClient, githubIntegration } from 'integrate-sdk';
|
|
72
|
+
* import { getLangChainTools } from 'integrate-sdk/ai/langchain';
|
|
73
|
+
* import { DynamicStructuredTool } from '@langchain/core/tools';
|
|
74
|
+
* import { ChatOpenAI } from '@langchain/openai';
|
|
75
|
+
* import { AgentExecutor, createOpenAIFunctionsAgent } from 'langchain/agents';
|
|
76
|
+
*
|
|
77
|
+
* const client = createMCPClient({
|
|
78
|
+
* integrations: [githubIntegration({ clientId: '...' })],
|
|
79
|
+
* });
|
|
80
|
+
*
|
|
81
|
+
* const toolConfigs = await getLangChainTools(client);
|
|
82
|
+
*
|
|
83
|
+
* // Create DynamicStructuredTools from configs
|
|
84
|
+
* const tools = toolConfigs.map(config =>
|
|
85
|
+
* new DynamicStructuredTool(config)
|
|
86
|
+
* );
|
|
87
|
+
*
|
|
88
|
+
* const model = new ChatOpenAI({ temperature: 0 });
|
|
89
|
+
* const agent = await createOpenAIFunctionsAgent({
|
|
90
|
+
* llm: model,
|
|
91
|
+
* tools
|
|
92
|
+
* });
|
|
93
|
+
*
|
|
94
|
+
* const executor = new AgentExecutor({ agent, tools });
|
|
95
|
+
* const result = await executor.invoke({
|
|
96
|
+
* input: "Create a GitHub issue"
|
|
97
|
+
* });
|
|
98
|
+
* ```
|
|
99
|
+
*
|
|
100
|
+
* @example
|
|
101
|
+
* ```typescript
|
|
102
|
+
* // Server-side usage with tokens from client
|
|
103
|
+
* import { createMCPServer, githubIntegration } from 'integrate-sdk/server';
|
|
104
|
+
* import { getLangChainTools } from 'integrate-sdk/ai/langchain';
|
|
105
|
+
*
|
|
106
|
+
* const { client: serverClient } = createMCPServer({
|
|
107
|
+
* integrations: [githubIntegration({
|
|
108
|
+
* clientId: '...',
|
|
109
|
+
* clientSecret: '...'
|
|
110
|
+
* })],
|
|
111
|
+
* });
|
|
112
|
+
*
|
|
113
|
+
* // In your API route
|
|
114
|
+
* export async function POST(req: Request) {
|
|
115
|
+
* const providerTokens = JSON.parse(req.headers.get('x-integrate-tokens') || '{}');
|
|
116
|
+
* const toolConfigs = await getLangChainTools(serverClient, { providerTokens });
|
|
117
|
+
*
|
|
118
|
+
* // Create DynamicStructuredTools
|
|
119
|
+
* const tools = toolConfigs.map(config =>
|
|
120
|
+
* new DynamicStructuredTool(config)
|
|
121
|
+
* );
|
|
122
|
+
*
|
|
123
|
+
* const model = new ChatOpenAI({ temperature: 0 });
|
|
124
|
+
* const agent = await createOpenAIFunctionsAgent({
|
|
125
|
+
* llm: model,
|
|
126
|
+
* tools
|
|
127
|
+
* });
|
|
128
|
+
*
|
|
129
|
+
* const executor = new AgentExecutor({ agent, tools });
|
|
130
|
+
* const result = await executor.invoke({
|
|
131
|
+
* input: "Create a GitHub issue"
|
|
132
|
+
* });
|
|
133
|
+
*
|
|
134
|
+
* return Response.json(result);
|
|
135
|
+
* }
|
|
136
|
+
* ```
|
|
137
|
+
*/
|
|
138
|
+
export declare function getLangChainTools(client: MCPClient<any>, options?: LangChainToolsOptions): Promise<LangChainTool[]>;
|
|
139
|
+
//# sourceMappingURL=langchain.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"langchain.d.ts","sourceRoot":"","sources":["../../../src/ai/langchain.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAKL,KAAK,cAAc,EACpB,MAAM,YAAY,CAAC;AAEpB;;;GAGG;AACH,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IACvB,IAAI,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;CAC3C;AAED;;GAEG;AACH,MAAM,WAAW,qBAAsB,SAAQ,cAAc;CAAI;AAEjE;;;;;;;;;;;;GAYG;AACH,wBAAgB,yBAAyB,CACvC,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,SAAS,CAAC,GAAG,CAAC,EACtB,OAAO,CAAC,EAAE,qBAAqB,GAC9B,aAAa,CAYf;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,0BAA0B,CACxC,MAAM,EAAE,SAAS,CAAC,GAAG,CAAC,EACtB,OAAO,CAAC,EAAE,qBAAqB,GAC9B,aAAa,EAAE,CAGjB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+EG;AACH,wBAAsB,iBAAiB,CACrC,MAAM,EAAE,SAAS,CAAC,GAAG,CAAC,EACtB,OAAO,CAAC,EAAE,qBAAqB,GAC9B,OAAO,CAAC,aAAa,EAAE,CAAC,CAe1B"}
|