integrate-sdk 0.6.5 → 0.6.7
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 +268 -0
- package/dist/adapters/base-handler.js +144 -0
- package/dist/adapters/nextjs-oauth-redirect.js +152 -0
- package/dist/adapters/nextjs.js +405 -0
- package/dist/adapters/node.js +280 -0
- package/dist/adapters/solid-start.js +27 -0
- package/dist/adapters/svelte-kit.js +34 -0
- package/dist/adapters/tanstack-start.js +26 -0
- package/dist/index.js +203 -96
- package/dist/src/adapters/node.d.ts +48 -0
- package/dist/src/adapters/node.d.ts.map +1 -0
- package/dist/src/adapters/solid-start.d.ts +54 -0
- package/dist/src/adapters/solid-start.d.ts.map +1 -0
- package/dist/src/adapters/svelte-kit.d.ts +82 -0
- package/dist/src/adapters/svelte-kit.d.ts.map +1 -0
- package/dist/src/adapters/tanstack-start.d.ts +28 -144
- package/dist/src/adapters/tanstack-start.d.ts.map +1 -1
- package/dist/src/index.d.ts +4 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/integrations/anthropic.d.ts +208 -0
- package/dist/src/integrations/anthropic.d.ts.map +1 -0
- package/dist/src/integrations/cloudflare.d.ts +158 -0
- package/dist/src/integrations/cloudflare.d.ts.map +1 -0
- package/dist/src/integrations/google.d.ts +159 -0
- package/dist/src/integrations/google.d.ts.map +1 -0
- package/dist/src/integrations/index.d.ts +79 -0
- package/dist/src/integrations/index.d.ts.map +1 -0
- package/dist/src/integrations/langchain.d.ts +139 -0
- package/dist/src/integrations/langchain.d.ts.map +1 -0
- package/dist/src/integrations/llamaindex.d.ts +125 -0
- package/dist/src/integrations/llamaindex.d.ts.map +1 -0
- package/dist/src/integrations/mastra.d.ts +138 -0
- package/dist/src/integrations/mastra.d.ts.map +1 -0
- package/dist/src/integrations/openai-agents.d.ts +117 -0
- package/dist/src/integrations/openai-agents.d.ts.map +1 -0
- package/dist/src/integrations/openai.d.ts +158 -0
- package/dist/src/integrations/openai.d.ts.map +1 -0
- package/dist/src/integrations/utils.d.ts +56 -0
- package/dist/src/integrations/utils.d.ts.map +1 -0
- package/dist/src/integrations/vercel-ai.d.ts +2 -16
- package/dist/src/integrations/vercel-ai.d.ts.map +1 -1
- package/integrations.ts +9 -0
- package/package.json +104 -9
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OpenAI Agents Integration
|
|
3
|
+
*
|
|
4
|
+
* Helper functions to convert MCP tools to @openai/agents 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
|
+
* OpenAI Agents tool definition
|
|
12
|
+
* Compatible with @openai/agents package
|
|
13
|
+
*/
|
|
14
|
+
export interface OpenAIAgentsTool {
|
|
15
|
+
name: string;
|
|
16
|
+
description: string;
|
|
17
|
+
parameters: z.ZodType<any>;
|
|
18
|
+
execute: (args: any) => Promise<any>;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Options for converting MCP tools to OpenAI Agents format
|
|
22
|
+
*/
|
|
23
|
+
export interface OpenAIAgentsToolsOptions extends AIToolsOptions {
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Convert a single MCP tool to OpenAI Agents 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 OpenAI Agents compatible tool definition
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```typescript
|
|
35
|
+
* const agentTool = convertMCPToolToOpenAIAgents(mcpTool, client);
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
export declare function convertMCPToolToOpenAIAgents(mcpTool: MCPTool, client: MCPClient<any>, options?: OpenAIAgentsToolsOptions): OpenAIAgentsTool;
|
|
39
|
+
/**
|
|
40
|
+
* Convert all enabled MCP tools to OpenAI Agents format
|
|
41
|
+
*
|
|
42
|
+
* @param client - The MCP client instance (must be connected)
|
|
43
|
+
* @param options - Optional configuration including provider tokens
|
|
44
|
+
* @returns Array of OpenAI Agents compatible tool definitions
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* ```typescript
|
|
48
|
+
* // Client-side usage
|
|
49
|
+
* const tools = convertMCPToolsToOpenAIAgents(mcpClient);
|
|
50
|
+
*
|
|
51
|
+
* // Server-side with provider tokens
|
|
52
|
+
* const tools = convertMCPToolsToOpenAIAgents(serverClient, {
|
|
53
|
+
* providerTokens: { github: 'ghp_...', gmail: 'ya29...' }
|
|
54
|
+
* });
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
export declare function convertMCPToolsToOpenAIAgents(client: MCPClient<any>, options?: OpenAIAgentsToolsOptions): OpenAIAgentsTool[];
|
|
58
|
+
/**
|
|
59
|
+
* Get tools in a format compatible with @openai/agents
|
|
60
|
+
*
|
|
61
|
+
* Automatically connects the client if not already connected.
|
|
62
|
+
*
|
|
63
|
+
* @param client - The MCP client instance
|
|
64
|
+
* @param options - Optional configuration including provider tokens for server-side usage
|
|
65
|
+
* @returns Array of tools ready to use with @openai/agents
|
|
66
|
+
*
|
|
67
|
+
* @example
|
|
68
|
+
* ```typescript
|
|
69
|
+
* // Client-side usage
|
|
70
|
+
* import { createMCPClient, githubPlugin } from 'integrate-sdk';
|
|
71
|
+
* import { getOpenAIAgentsTools } from 'integrate-sdk/integrations/openai-agents';
|
|
72
|
+
* import { Agent } from '@openai/agents';
|
|
73
|
+
*
|
|
74
|
+
* const client = createMCPClient({
|
|
75
|
+
* plugins: [githubPlugin({ clientId: '...' })],
|
|
76
|
+
* });
|
|
77
|
+
*
|
|
78
|
+
* const tools = await getOpenAIAgentsTools(client);
|
|
79
|
+
*
|
|
80
|
+
* const agent = new Agent({
|
|
81
|
+
* model: 'gpt-4o',
|
|
82
|
+
* tools,
|
|
83
|
+
* });
|
|
84
|
+
*
|
|
85
|
+
* const result = await agent.run('Create a GitHub issue');
|
|
86
|
+
* ```
|
|
87
|
+
*
|
|
88
|
+
* @example
|
|
89
|
+
* ```typescript
|
|
90
|
+
* // Server-side usage with tokens from client
|
|
91
|
+
* import { createMCPServer, githubPlugin } from 'integrate-sdk/server';
|
|
92
|
+
* import { getOpenAIAgentsTools } from 'integrate-sdk/integrations/openai-agents';
|
|
93
|
+
*
|
|
94
|
+
* const { client: serverClient } = createMCPServer({
|
|
95
|
+
* plugins: [githubPlugin({
|
|
96
|
+
* clientId: '...',
|
|
97
|
+
* clientSecret: '...'
|
|
98
|
+
* })],
|
|
99
|
+
* });
|
|
100
|
+
*
|
|
101
|
+
* // In your API route
|
|
102
|
+
* export async function POST(req: Request) {
|
|
103
|
+
* const providerTokens = JSON.parse(req.headers.get('x-integrate-tokens') || '{}');
|
|
104
|
+
* const tools = await getOpenAIAgentsTools(serverClient, { providerTokens });
|
|
105
|
+
*
|
|
106
|
+
* const agent = new Agent({
|
|
107
|
+
* model: 'gpt-4o',
|
|
108
|
+
* tools,
|
|
109
|
+
* });
|
|
110
|
+
*
|
|
111
|
+
* const result = await agent.run('Create a GitHub issue');
|
|
112
|
+
* return Response.json({ result });
|
|
113
|
+
* }
|
|
114
|
+
* ```
|
|
115
|
+
*/
|
|
116
|
+
export declare function getOpenAIAgentsTools(client: MCPClient<any>, options?: OpenAIAgentsToolsOptions): Promise<OpenAIAgentsTool[]>;
|
|
117
|
+
//# sourceMappingURL=openai-agents.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openai-agents.d.ts","sourceRoot":"","sources":["../../../src/integrations/openai-agents.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,EAIL,KAAK,cAAc,EACpB,MAAM,YAAY,CAAC;AAEpB;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IAC3B,OAAO,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC;CACtC;AAED;;GAEG;AACH,MAAM,WAAW,wBAAyB,SAAQ,cAAc;CAAG;AAEnE;;;;;;;;;;;;GAYG;AACH,wBAAgB,4BAA4B,CAC1C,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,SAAS,CAAC,GAAG,CAAC,EACtB,OAAO,CAAC,EAAE,wBAAwB,GACjC,gBAAgB,CASlB;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,6BAA6B,CAC3C,MAAM,EAAE,SAAS,CAAC,GAAG,CAAC,EACtB,OAAO,CAAC,EAAE,wBAAwB,GACjC,gBAAgB,EAAE,CAGpB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyDG;AACH,wBAAsB,oBAAoB,CACxC,MAAM,EAAE,SAAS,CAAC,GAAG,CAAC,EACtB,OAAO,CAAC,EAAE,wBAAwB,GACjC,OAAO,CAAC,gBAAgB,EAAE,CAAC,CAG7B"}
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OpenAI Responses API Integration
|
|
3
|
+
*
|
|
4
|
+
* Helper functions to convert MCP tools to OpenAI Responses API format
|
|
5
|
+
*/
|
|
6
|
+
import type { MCPClient } from "../client.js";
|
|
7
|
+
import type { MCPTool } from "../protocol/messages.js";
|
|
8
|
+
import { type AIToolsOptions } from "./utils.js";
|
|
9
|
+
/**
|
|
10
|
+
* OpenAI function tool definition
|
|
11
|
+
* Compatible with OpenAI's Responses API format
|
|
12
|
+
*/
|
|
13
|
+
export interface OpenAITool {
|
|
14
|
+
type: 'function';
|
|
15
|
+
name: string;
|
|
16
|
+
description?: string;
|
|
17
|
+
parameters: {
|
|
18
|
+
type: 'object';
|
|
19
|
+
properties?: Record<string, unknown>;
|
|
20
|
+
required?: string[];
|
|
21
|
+
[key: string]: unknown;
|
|
22
|
+
};
|
|
23
|
+
strict?: boolean;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Options for converting MCP tools to OpenAI format
|
|
27
|
+
*/
|
|
28
|
+
export interface OpenAIToolsOptions extends AIToolsOptions {
|
|
29
|
+
/**
|
|
30
|
+
* Whether to use strict mode for function calls
|
|
31
|
+
* @default false
|
|
32
|
+
*/
|
|
33
|
+
strict?: boolean;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Convert a single MCP tool to OpenAI Responses API format
|
|
37
|
+
*
|
|
38
|
+
* @param mcpTool - The MCP tool definition
|
|
39
|
+
* @param client - The MCP client instance (used for executing the tool)
|
|
40
|
+
* @param options - Optional configuration including provider tokens and strict mode
|
|
41
|
+
* @returns OpenAI compatible tool definition
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* ```typescript
|
|
45
|
+
* const openaiTool = convertMCPToolToOpenAI(mcpTool, client, { strict: true });
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
export declare function convertMCPToolToOpenAI(mcpTool: MCPTool, _client: MCPClient<any>, options?: OpenAIToolsOptions): OpenAITool;
|
|
49
|
+
/**
|
|
50
|
+
* Convert all enabled MCP tools to OpenAI Responses API format
|
|
51
|
+
*
|
|
52
|
+
* @param client - The MCP client instance (must be connected)
|
|
53
|
+
* @param options - Optional configuration including provider tokens and strict mode
|
|
54
|
+
* @returns Array of OpenAI compatible tool definitions
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* ```typescript
|
|
58
|
+
* // Client-side usage
|
|
59
|
+
* const tools = convertMCPToolsToOpenAI(mcpClient);
|
|
60
|
+
*
|
|
61
|
+
* // Server-side with provider tokens
|
|
62
|
+
* const tools = convertMCPToolsToOpenAI(serverClient, {
|
|
63
|
+
* providerTokens: { github: 'ghp_...', gmail: 'ya29...' }
|
|
64
|
+
* });
|
|
65
|
+
* ```
|
|
66
|
+
*/
|
|
67
|
+
export declare function convertMCPToolsToOpenAI(client: MCPClient<any>, options?: OpenAIToolsOptions): OpenAITool[];
|
|
68
|
+
/**
|
|
69
|
+
* Execute a tool call from OpenAI's response
|
|
70
|
+
*
|
|
71
|
+
* @param client - The MCP client instance
|
|
72
|
+
* @param toolCall - The tool call from OpenAI response
|
|
73
|
+
* @param options - Optional configuration including provider tokens
|
|
74
|
+
* @returns Tool execution result as JSON string
|
|
75
|
+
*
|
|
76
|
+
* @example
|
|
77
|
+
* ```typescript
|
|
78
|
+
* const result = await executeOpenAIToolCall(client, {
|
|
79
|
+
* id: 'call_123',
|
|
80
|
+
* name: 'github_create_issue',
|
|
81
|
+
* arguments: '{"owner":"user","repo":"repo","title":"Bug"}'
|
|
82
|
+
* }, { providerTokens });
|
|
83
|
+
* ```
|
|
84
|
+
*/
|
|
85
|
+
export declare function executeOpenAIToolCall(client: MCPClient<any>, toolCall: {
|
|
86
|
+
id: string;
|
|
87
|
+
name: string;
|
|
88
|
+
arguments: string;
|
|
89
|
+
}, options?: OpenAIToolsOptions): Promise<string>;
|
|
90
|
+
/**
|
|
91
|
+
* Get tools in a format compatible with OpenAI Responses API
|
|
92
|
+
*
|
|
93
|
+
* Automatically connects the client if not already connected.
|
|
94
|
+
*
|
|
95
|
+
* @param client - The MCP client instance
|
|
96
|
+
* @param options - Optional configuration including provider tokens for server-side usage
|
|
97
|
+
* @returns Array of tools ready to pass to OpenAI's Responses API
|
|
98
|
+
*
|
|
99
|
+
* @example
|
|
100
|
+
* ```typescript
|
|
101
|
+
* // Client-side usage
|
|
102
|
+
* import { createMCPClient, githubPlugin } from 'integrate-sdk';
|
|
103
|
+
* import { getOpenAITools } from 'integrate-sdk/integrations/openai';
|
|
104
|
+
*
|
|
105
|
+
* const client = createMCPClient({
|
|
106
|
+
* plugins: [githubPlugin({ clientId: '...' })],
|
|
107
|
+
* });
|
|
108
|
+
*
|
|
109
|
+
* const tools = await getOpenAITools(client);
|
|
110
|
+
*
|
|
111
|
+
* // Use with OpenAI SDK
|
|
112
|
+
* const response = await openai.responses.create({
|
|
113
|
+
* model: 'gpt-4o-2024-11-20',
|
|
114
|
+
* input: 'Create a GitHub issue',
|
|
115
|
+
* tools,
|
|
116
|
+
* });
|
|
117
|
+
* ```
|
|
118
|
+
*
|
|
119
|
+
* @example
|
|
120
|
+
* ```typescript
|
|
121
|
+
* // Server-side usage with tokens from client
|
|
122
|
+
* import { createMCPServer, githubPlugin } from 'integrate-sdk/server';
|
|
123
|
+
* import { getOpenAITools, executeOpenAIToolCall } from 'integrate-sdk/integrations/openai';
|
|
124
|
+
*
|
|
125
|
+
* const { client: serverClient } = createMCPServer({
|
|
126
|
+
* plugins: [githubPlugin({
|
|
127
|
+
* clientId: '...',
|
|
128
|
+
* clientSecret: '...'
|
|
129
|
+
* })],
|
|
130
|
+
* });
|
|
131
|
+
*
|
|
132
|
+
* // In your API route
|
|
133
|
+
* export async function POST(req: Request) {
|
|
134
|
+
* const providerTokens = JSON.parse(req.headers.get('x-integrate-tokens') || '{}');
|
|
135
|
+
* const tools = await getOpenAITools(serverClient, { providerTokens });
|
|
136
|
+
*
|
|
137
|
+
* const response = await openai.responses.create({
|
|
138
|
+
* model: 'gpt-4o-2024-11-20',
|
|
139
|
+
* input: 'Create a GitHub issue',
|
|
140
|
+
* tools,
|
|
141
|
+
* });
|
|
142
|
+
*
|
|
143
|
+
* // Handle tool calls
|
|
144
|
+
* const toolCalls = response.output.filter(o => o.type === 'function_call');
|
|
145
|
+
* for (const toolCall of toolCalls) {
|
|
146
|
+
* const result = await executeOpenAIToolCall(serverClient, {
|
|
147
|
+
* id: toolCall.id,
|
|
148
|
+
* name: toolCall.name,
|
|
149
|
+
* arguments: toolCall.arguments,
|
|
150
|
+
* }, { providerTokens });
|
|
151
|
+
* }
|
|
152
|
+
*
|
|
153
|
+
* return Response.json(response);
|
|
154
|
+
* }
|
|
155
|
+
* ```
|
|
156
|
+
*/
|
|
157
|
+
export declare function getOpenAITools(client: MCPClient<any>, options?: OpenAIToolsOptions): Promise<OpenAITool[]>;
|
|
158
|
+
//# sourceMappingURL=openai.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openai.d.ts","sourceRoot":"","sources":["../../../src/integrations/openai.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAA+C,KAAK,cAAc,EAAE,MAAM,YAAY,CAAC;AAE9F;;;GAGG;AACH,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,UAAU,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE;QACV,IAAI,EAAE,QAAQ,CAAC;QACf,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QACrC,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;QACpB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;KACxB,CAAC;IACF,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,kBAAmB,SAAQ,cAAc;IACxD;;;OAGG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,SAAS,CAAC,GAAG,CAAC,EACvB,OAAO,CAAC,EAAE,kBAAkB,GAC3B,UAAU,CAcZ;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,SAAS,CAAC,GAAG,CAAC,EACtB,OAAO,CAAC,EAAE,kBAAkB,GAC3B,UAAU,EAAE,CAGd;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAsB,qBAAqB,CACzC,MAAM,EAAE,SAAS,CAAC,GAAG,CAAC,EACtB,QAAQ,EAAE;IACR,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;CACnB,EACD,OAAO,CAAC,EAAE,kBAAkB,GAC3B,OAAO,CAAC,MAAM,CAAC,CAIjB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkEG;AACH,wBAAsB,cAAc,CAClC,MAAM,EAAE,SAAS,CAAC,GAAG,CAAC,EACtB,OAAO,CAAC,EAAE,kBAAkB,GAC3B,OAAO,CAAC,UAAU,EAAE,CAAC,CAGvB"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared utilities for AI provider integrations
|
|
3
|
+
*
|
|
4
|
+
* Common functions used across different AI provider integrations
|
|
5
|
+
*/
|
|
6
|
+
import { z } from "zod";
|
|
7
|
+
import type { MCPClient } from "../client.js";
|
|
8
|
+
/**
|
|
9
|
+
* Options for AI provider tool conversions
|
|
10
|
+
*/
|
|
11
|
+
export interface AIToolsOptions {
|
|
12
|
+
/**
|
|
13
|
+
* Provider tokens for server-side usage
|
|
14
|
+
* Maps provider names (e.g., 'github', 'gmail') to their access tokens
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* const tools = await getAITools(client, 'openai', {
|
|
19
|
+
* providerTokens: {
|
|
20
|
+
* github: 'ghp_...',
|
|
21
|
+
* gmail: 'ya29...'
|
|
22
|
+
* }
|
|
23
|
+
* });
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
providerTokens?: Record<string, string>;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Get the provider for a tool by checking which plugin includes it
|
|
30
|
+
* @internal
|
|
31
|
+
*/
|
|
32
|
+
export declare function getProviderForTool(client: MCPClient<any>, toolName: string): string | undefined;
|
|
33
|
+
/**
|
|
34
|
+
* Convert a JSON Schema property to a Zod schema
|
|
35
|
+
* @internal
|
|
36
|
+
*/
|
|
37
|
+
export declare function jsonSchemaPropertyToZod(propSchema: any): z.ZodType<any>;
|
|
38
|
+
/**
|
|
39
|
+
* Convert JSON Schema to Zod schema for AI SDKs that use Zod
|
|
40
|
+
* Handles edge cases like missing schemas, type: "None", or invalid types
|
|
41
|
+
* Always returns a valid Zod object schema
|
|
42
|
+
* @internal
|
|
43
|
+
*/
|
|
44
|
+
export declare function jsonSchemaToZod(schema: any): z.ZodObject<any>;
|
|
45
|
+
/**
|
|
46
|
+
* Execute a tool with provider token injection
|
|
47
|
+
* Temporarily sets the Authorization header for the tool call
|
|
48
|
+
* @internal
|
|
49
|
+
*/
|
|
50
|
+
export declare function executeToolWithToken(client: MCPClient<any>, toolName: string, args: Record<string, unknown>, options?: AIToolsOptions): Promise<any>;
|
|
51
|
+
/**
|
|
52
|
+
* Auto-connect client if needed
|
|
53
|
+
* @internal
|
|
54
|
+
*/
|
|
55
|
+
export declare function ensureClientConnected(client: MCPClient<any>): Promise<void>;
|
|
56
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/integrations/utils.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAE9C;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B;;;;;;;;;;;;;OAaG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACzC;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,CAAC,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAG/F;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,UAAU,EAAE,GAAG,GAAG,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAqFvE;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,GAAG,GAAG,CAAC,CAAC,SAAS,CAAC,GAAG,CAAC,CAoD7D;AAED;;;;GAIG;AACH,wBAAsB,oBAAoB,CACxC,MAAM,EAAE,SAAS,CAAC,GAAG,CAAC,EACtB,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CAAC,GAAG,CAAC,CAgCd;AAED;;;GAGG;AACH,wBAAsB,qBAAqB,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAIjF"}
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
import { z } from "zod";
|
|
7
7
|
import type { MCPClient } from "../client.js";
|
|
8
8
|
import type { MCPTool } from "../protocol/messages.js";
|
|
9
|
+
import { type AIToolsOptions } from "./utils.js";
|
|
9
10
|
/**
|
|
10
11
|
* Tool definition compatible with Vercel AI SDK v5
|
|
11
12
|
* This matches the CoreTool interface from 'ai' package v5
|
|
@@ -18,22 +19,7 @@ export interface VercelAITool {
|
|
|
18
19
|
/**
|
|
19
20
|
* Options for converting MCP tools to Vercel AI SDK format
|
|
20
21
|
*/
|
|
21
|
-
export interface VercelAIToolsOptions {
|
|
22
|
-
/**
|
|
23
|
-
* Provider tokens for server-side usage
|
|
24
|
-
* Maps provider names (e.g., 'github', 'gmail') to their access tokens
|
|
25
|
-
*
|
|
26
|
-
* @example
|
|
27
|
-
* ```typescript
|
|
28
|
-
* const tools = getVercelAITools(serverClient, {
|
|
29
|
-
* providerTokens: {
|
|
30
|
-
* github: 'ghp_...',
|
|
31
|
-
* gmail: 'ya29...'
|
|
32
|
-
* }
|
|
33
|
-
* });
|
|
34
|
-
* ```
|
|
35
|
-
*/
|
|
36
|
-
providerTokens?: Record<string, string>;
|
|
22
|
+
export interface VercelAIToolsOptions extends AIToolsOptions {
|
|
37
23
|
}
|
|
38
24
|
/**
|
|
39
25
|
* Convert a single MCP tool to Vercel AI SDK format
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vercel-ai.d.ts","sourceRoot":"","sources":["../../../src/integrations/vercel-ai.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;
|
|
1
|
+
{"version":3,"file":"vercel-ai.d.ts","sourceRoot":"","sources":["../../../src/integrations/vercel-ai.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,EAIL,KAAK,cAAc,EACpB,MAAM,YAAY,CAAC;AAEpB;;;GAGG;AACH,MAAM,WAAW,YAAY;IAC3B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IAC5B,OAAO,EAAE,CAAC,IAAI,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,GAAG,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC;CACrD;AAED;;GAEG;AACH,MAAM,WAAW,oBAAqB,SAAQ,cAAc;CAAG;AAE/D;;;;;;;GAOG;AACH,wBAAgB,wBAAwB,CACtC,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,SAAS,CAAC,GAAG,CAAC,EACtB,OAAO,CAAC,EAAE,oBAAoB,GAC7B,YAAY,CAQd;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsDG;AACH,wBAAgB,yBAAyB,CACvC,MAAM,EAAE,SAAS,CAAC,GAAG,CAAC,EACtB,OAAO,CAAC,EAAE,oBAAoB,GAC7B,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CASrB;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAsB,gBAAgB,CACpC,MAAM,EAAE,SAAS,CAAC,GAAG,CAAC,EACtB,OAAO,CAAC,EAAE,oBAAoB,gCAM/B"}
|
package/integrations.ts
ADDED
package/package.json
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "integrate-sdk",
|
|
3
|
-
"version": "0.6.
|
|
4
|
-
"description": "Type-safe
|
|
3
|
+
"version": "0.6.7",
|
|
4
|
+
"description": "Type-safe 3rd party integration SDK for the Integrate MCP server",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
7
7
|
"module": "./dist/index.js",
|
|
8
8
|
"types": "./dist/index.d.ts",
|
|
9
9
|
"repository": {
|
|
10
10
|
"type": "git",
|
|
11
|
-
"url": "https://github.com/
|
|
11
|
+
"url": "https://github.com/integratedotdev/integrate-sdk.git"
|
|
12
12
|
},
|
|
13
13
|
"bugs": {
|
|
14
|
-
"url": "https://github.com/
|
|
14
|
+
"url": "https://github.com/integratedotdev/integrate-sdk/issues"
|
|
15
15
|
},
|
|
16
|
-
"homepage": "https://github.com/
|
|
16
|
+
"homepage": "https://github.com/integratedotdev/integrate-sdk#readme",
|
|
17
17
|
"exports": {
|
|
18
18
|
".": {
|
|
19
19
|
"types": "./dist/index.d.ts",
|
|
@@ -30,6 +30,62 @@
|
|
|
30
30
|
"./react": {
|
|
31
31
|
"types": "./dist/react.d.ts",
|
|
32
32
|
"import": "./dist/react.js"
|
|
33
|
+
},
|
|
34
|
+
"./integrations": {
|
|
35
|
+
"types": "./dist/integrations.d.ts",
|
|
36
|
+
"import": "./dist/integrations.js"
|
|
37
|
+
},
|
|
38
|
+
"./integrations/openai": {
|
|
39
|
+
"types": "./dist/integrations/openai.d.ts",
|
|
40
|
+
"import": "./dist/integrations/openai.js"
|
|
41
|
+
},
|
|
42
|
+
"./integrations/openai-agents": {
|
|
43
|
+
"types": "./dist/integrations/openai-agents.d.ts",
|
|
44
|
+
"import": "./dist/integrations/openai-agents.js"
|
|
45
|
+
},
|
|
46
|
+
"./integrations/anthropic": {
|
|
47
|
+
"types": "./dist/integrations/anthropic.d.ts",
|
|
48
|
+
"import": "./dist/integrations/anthropic.js"
|
|
49
|
+
},
|
|
50
|
+
"./integrations/google": {
|
|
51
|
+
"types": "./dist/integrations/google.d.ts",
|
|
52
|
+
"import": "./dist/integrations/google.js"
|
|
53
|
+
},
|
|
54
|
+
"./integrations/cloudflare": {
|
|
55
|
+
"types": "./dist/integrations/cloudflare.d.ts",
|
|
56
|
+
"import": "./dist/integrations/cloudflare.js"
|
|
57
|
+
},
|
|
58
|
+
"./integrations/langchain": {
|
|
59
|
+
"types": "./dist/integrations/langchain.d.ts",
|
|
60
|
+
"import": "./dist/integrations/langchain.js"
|
|
61
|
+
},
|
|
62
|
+
"./integrations/llamaindex": {
|
|
63
|
+
"types": "./dist/integrations/llamaindex.d.ts",
|
|
64
|
+
"import": "./dist/integrations/llamaindex.js"
|
|
65
|
+
},
|
|
66
|
+
"./integrations/mastra": {
|
|
67
|
+
"types": "./dist/integrations/mastra.d.ts",
|
|
68
|
+
"import": "./dist/integrations/mastra.js"
|
|
69
|
+
},
|
|
70
|
+
"./adapters/nextjs": {
|
|
71
|
+
"types": "./dist/adapters/nextjs.d.ts",
|
|
72
|
+
"import": "./dist/adapters/nextjs.js"
|
|
73
|
+
},
|
|
74
|
+
"./adapters/node": {
|
|
75
|
+
"types": "./dist/adapters/node.d.ts",
|
|
76
|
+
"import": "./dist/adapters/node.js"
|
|
77
|
+
},
|
|
78
|
+
"./adapters/solid-start": {
|
|
79
|
+
"types": "./dist/adapters/solid-start.d.ts",
|
|
80
|
+
"import": "./dist/adapters/solid-start.js"
|
|
81
|
+
},
|
|
82
|
+
"./adapters/svelte-kit": {
|
|
83
|
+
"types": "./dist/adapters/svelte-kit.d.ts",
|
|
84
|
+
"import": "./dist/adapters/svelte-kit.js"
|
|
85
|
+
},
|
|
86
|
+
"./adapters/tanstack-start": {
|
|
87
|
+
"types": "./dist/adapters/tanstack-start.d.ts",
|
|
88
|
+
"import": "./dist/adapters/tanstack-start.js"
|
|
33
89
|
}
|
|
34
90
|
},
|
|
35
91
|
"files": [
|
|
@@ -37,11 +93,14 @@
|
|
|
37
93
|
"index.ts",
|
|
38
94
|
"server.ts",
|
|
39
95
|
"oauth.ts",
|
|
40
|
-
"react.ts"
|
|
96
|
+
"react.ts",
|
|
97
|
+
"integrations.ts"
|
|
41
98
|
],
|
|
42
99
|
"scripts": {
|
|
43
100
|
"prep": "bun run type-check && bun run build",
|
|
44
|
-
"build": "bun build index.ts server.ts oauth.ts react.ts --outdir dist --target node --format esm --external react && bun run build:types",
|
|
101
|
+
"build": "bun build index.ts server.ts oauth.ts react.ts integrations.ts --outdir dist --target node --format esm --external react && bun run build:types",
|
|
102
|
+
"build": "bun build index.ts server.ts oauth.ts react.ts --outdir dist --target node --format esm --external react && bun run build:adapters && bun run build:types",
|
|
103
|
+
"build:adapters": "bun build src/adapters/*.ts --outdir dist/adapters --target node --format esm",
|
|
45
104
|
"build:types": "tsc --emitDeclarationOnly --declaration --declarationMap",
|
|
46
105
|
"dev": "bun --watch src/index.ts",
|
|
47
106
|
"type-check": "tsc --noEmit",
|
|
@@ -73,14 +132,50 @@
|
|
|
73
132
|
},
|
|
74
133
|
"peerDependencies": {
|
|
75
134
|
"typescript": ">=5.0.0",
|
|
76
|
-
"react": ">=19.0.0"
|
|
135
|
+
"react": ">=19.0.0",
|
|
136
|
+
"ai": ">=4.0.0",
|
|
137
|
+
"openai": ">=4.0.0",
|
|
138
|
+
"@openai/agents": ">=0.1.0",
|
|
139
|
+
"@anthropic-ai/sdk": ">=0.20.0",
|
|
140
|
+
"@google/generative-ai": ">=0.1.0",
|
|
141
|
+
"@cloudflare/workers-types": ">=4.0.0",
|
|
142
|
+
"@langchain/core": ">=0.1.0",
|
|
143
|
+
"llamaindex": ">=0.1.0",
|
|
144
|
+
"@mastra/core": ">=0.1.0"
|
|
77
145
|
},
|
|
78
146
|
"peerDependenciesMeta": {
|
|
79
147
|
"react": {
|
|
80
148
|
"optional": true
|
|
149
|
+
},
|
|
150
|
+
"ai": {
|
|
151
|
+
"optional": true
|
|
152
|
+
},
|
|
153
|
+
"openai": {
|
|
154
|
+
"optional": true
|
|
155
|
+
},
|
|
156
|
+
"@openai/agents": {
|
|
157
|
+
"optional": true
|
|
158
|
+
},
|
|
159
|
+
"@anthropic-ai/sdk": {
|
|
160
|
+
"optional": true
|
|
161
|
+
},
|
|
162
|
+
"@google/generative-ai": {
|
|
163
|
+
"optional": true
|
|
164
|
+
},
|
|
165
|
+
"@cloudflare/workers-types": {
|
|
166
|
+
"optional": true
|
|
167
|
+
},
|
|
168
|
+
"@langchain/core": {
|
|
169
|
+
"optional": true
|
|
170
|
+
},
|
|
171
|
+
"llamaindex": {
|
|
172
|
+
"optional": true
|
|
173
|
+
},
|
|
174
|
+
"@mastra/core": {
|
|
175
|
+
"optional": true
|
|
81
176
|
}
|
|
82
177
|
},
|
|
83
178
|
"simple-git-hooks": {
|
|
84
179
|
"pre-commit": "./scripts/check-version.sh"
|
|
85
180
|
}
|
|
86
|
-
}
|
|
181
|
+
}
|