integrate-sdk 0.7.22 → 0.7.24
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/ai/anthropic.d.ts +182 -0
- package/dist/ai/anthropic.d.ts.map +1 -0
- package/dist/ai/anthropic.js +4265 -0
- 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/google.d.ts +159 -0
- package/dist/ai/google.d.ts.map +1 -0
- package/dist/ai/google.js +4242 -0
- package/dist/ai/index.d.ts +79 -0
- package/dist/ai/index.d.ts.map +1 -0
- package/dist/ai/index.js +4580 -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/ai/openai-agents.d.ts +99 -0
- package/dist/ai/openai-agents.d.ts.map +1 -0
- package/dist/ai/openai-agents.js +4235 -0
- package/dist/ai/openai.d.ts +130 -0
- package/dist/ai/openai.d.ts.map +1 -0
- package/dist/ai/openai.js +4245 -0
- package/dist/ai/utils.d.ts +75 -0
- package/dist/ai/utils.d.ts.map +1 -0
- package/dist/ai/utils.js +4212 -0
- package/dist/ai/vercel-ai.d.ts +141 -0
- package/dist/ai/vercel-ai.d.ts.map +1 -0
- package/dist/ai/vercel-ai.js +4238 -0
- package/package.json +12 -6
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Google GenAI Integration
|
|
3
|
+
*
|
|
4
|
+
* Helper functions to convert MCP tools to Google GenAI 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
|
+
* Google GenAI function declaration
|
|
11
|
+
* Compatible with @google/genai SDK
|
|
12
|
+
*/
|
|
13
|
+
export interface GoogleTool {
|
|
14
|
+
name: string;
|
|
15
|
+
description: string;
|
|
16
|
+
parameters: {
|
|
17
|
+
type: 'object';
|
|
18
|
+
description?: string;
|
|
19
|
+
properties?: Record<string, unknown>;
|
|
20
|
+
required?: string[];
|
|
21
|
+
[key: string]: unknown;
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Google GenAI function call
|
|
26
|
+
*/
|
|
27
|
+
export interface GoogleFunctionCall {
|
|
28
|
+
name: string;
|
|
29
|
+
args: Record<string, unknown>;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Options for converting MCP tools to Google GenAI format
|
|
33
|
+
*/
|
|
34
|
+
export interface GoogleToolsOptions extends AIToolsOptions {
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Convert a single MCP tool to Google GenAI format
|
|
38
|
+
*
|
|
39
|
+
* @param mcpTool - The MCP tool definition
|
|
40
|
+
* @param client - The MCP client instance (used for executing the tool)
|
|
41
|
+
* @param options - Optional configuration including provider tokens
|
|
42
|
+
* @returns Google GenAI compatible tool definition
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```typescript
|
|
46
|
+
* const googleTool = convertMCPToolToGoogle(mcpTool, client);
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
export declare function convertMCPToolToGoogle(mcpTool: MCPTool, _client: MCPClient<any>, _options?: GoogleToolsOptions): GoogleTool;
|
|
50
|
+
/**
|
|
51
|
+
* Convert all enabled MCP tools to Google GenAI format
|
|
52
|
+
*
|
|
53
|
+
* @param client - The MCP client instance (must be connected)
|
|
54
|
+
* @param options - Optional configuration including provider tokens
|
|
55
|
+
* @returns Array of Google GenAI compatible tool definitions
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* ```typescript
|
|
59
|
+
* // Client-side usage
|
|
60
|
+
* const tools = convertMCPToolsToGoogle(mcpClient);
|
|
61
|
+
*
|
|
62
|
+
* // Server-side with provider tokens
|
|
63
|
+
* const tools = convertMCPToolsToGoogle(serverClient, {
|
|
64
|
+
* providerTokens: { github: 'ghp_...', gmail: 'ya29...' }
|
|
65
|
+
* });
|
|
66
|
+
* ```
|
|
67
|
+
*/
|
|
68
|
+
export declare function convertMCPToolsToGoogle(client: MCPClient<any>, options?: GoogleToolsOptions): GoogleTool[];
|
|
69
|
+
/**
|
|
70
|
+
* Execute a function call from Google GenAI
|
|
71
|
+
*
|
|
72
|
+
* @param client - The MCP client instance
|
|
73
|
+
* @param functionCall - The function call from Google GenAI response
|
|
74
|
+
* @param options - Optional configuration including provider tokens
|
|
75
|
+
* @returns Tool execution result as JSON string
|
|
76
|
+
*
|
|
77
|
+
* @example
|
|
78
|
+
* ```typescript
|
|
79
|
+
* const result = await executeGoogleFunctionCall(client, {
|
|
80
|
+
* name: 'github_create_issue',
|
|
81
|
+
* args: { owner: 'user', repo: 'repo', title: 'Bug' }
|
|
82
|
+
* }, { providerTokens });
|
|
83
|
+
* ```
|
|
84
|
+
*/
|
|
85
|
+
export declare function executeGoogleFunctionCall(client: MCPClient<any>, functionCall: GoogleFunctionCall, options?: GoogleToolsOptions): Promise<string>;
|
|
86
|
+
/**
|
|
87
|
+
* Get tools in a format compatible with Google GenAI
|
|
88
|
+
*
|
|
89
|
+
* Automatically connects the client if not already connected.
|
|
90
|
+
*
|
|
91
|
+
* @param client - The MCP client instance
|
|
92
|
+
* @param options - Optional configuration including provider tokens for server-side usage
|
|
93
|
+
* @returns Array of tools ready to use with Google GenAI
|
|
94
|
+
*
|
|
95
|
+
* @example
|
|
96
|
+
* ```typescript
|
|
97
|
+
* // Client-side usage
|
|
98
|
+
* import { createMCPClient, githubIntegration } from 'integrate-sdk';
|
|
99
|
+
* import { getGoogleTools } from 'integrate-sdk/ai/google';
|
|
100
|
+
* import { GoogleGenerativeAI } from '@google/generative-ai';
|
|
101
|
+
*
|
|
102
|
+
* const client = createMCPClient({
|
|
103
|
+
* integrations: [githubIntegration({ clientId: '...' })],
|
|
104
|
+
* });
|
|
105
|
+
*
|
|
106
|
+
* const tools = await getGoogleTools(client);
|
|
107
|
+
* const genAI = new GoogleGenerativeAI('YOUR_API_KEY');
|
|
108
|
+
* const model = genAI.getGenerativeModel({
|
|
109
|
+
* model: 'gemini-pro',
|
|
110
|
+
* tools: [{ functionDeclarations: tools }]
|
|
111
|
+
* });
|
|
112
|
+
*
|
|
113
|
+
* const result = await model.generateContent({
|
|
114
|
+
* contents: [{ role: 'user', parts: [{ text: 'Create a GitHub issue' }] }]
|
|
115
|
+
* });
|
|
116
|
+
* ```
|
|
117
|
+
*
|
|
118
|
+
* @example
|
|
119
|
+
* ```typescript
|
|
120
|
+
* // Server-side usage with tokens from client
|
|
121
|
+
* import { createMCPServer, githubIntegration } from 'integrate-sdk/server';
|
|
122
|
+
* import { getGoogleTools, executeGoogleFunctionCall } from 'integrate-sdk/ai/google';
|
|
123
|
+
*
|
|
124
|
+
* const { client: serverClient } = createMCPServer({
|
|
125
|
+
* integrations: [githubIntegration({
|
|
126
|
+
* clientId: '...',
|
|
127
|
+
* clientSecret: '...'
|
|
128
|
+
* })],
|
|
129
|
+
* });
|
|
130
|
+
*
|
|
131
|
+
* // In your API route
|
|
132
|
+
* export async function POST(req: Request) {
|
|
133
|
+
* const providerTokens = JSON.parse(req.headers.get('x-integrate-tokens') || '{}');
|
|
134
|
+
* const tools = await getGoogleTools(serverClient, { providerTokens });
|
|
135
|
+
*
|
|
136
|
+
* const genAI = new GoogleGenerativeAI(process.env.GOOGLE_API_KEY);
|
|
137
|
+
* const model = genAI.getGenerativeModel({
|
|
138
|
+
* model: 'gemini-pro',
|
|
139
|
+
* tools: [{ functionDeclarations: tools }]
|
|
140
|
+
* });
|
|
141
|
+
*
|
|
142
|
+
* const result = await model.generateContent({
|
|
143
|
+
* contents: [{ role: 'user', parts: [{ text: 'Create a GitHub issue' }] }]
|
|
144
|
+
* });
|
|
145
|
+
*
|
|
146
|
+
* // Handle function calls if any
|
|
147
|
+
* const functionCalls = result.response.functionCalls();
|
|
148
|
+
* if (functionCalls) {
|
|
149
|
+
* for (const call of functionCalls) {
|
|
150
|
+
* await executeGoogleFunctionCall(serverClient, call, { providerTokens });
|
|
151
|
+
* }
|
|
152
|
+
* }
|
|
153
|
+
*
|
|
154
|
+
* return Response.json(result.response);
|
|
155
|
+
* }
|
|
156
|
+
* ```
|
|
157
|
+
*/
|
|
158
|
+
export declare function getGoogleTools(client: MCPClient<any>, options?: GoogleToolsOptions): Promise<GoogleTool[]>;
|
|
159
|
+
//# sourceMappingURL=google.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"google.d.ts","sourceRoot":"","sources":["../../../src/ai/google.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,EAAkE,KAAK,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjH;;;GAGG;AACH,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE;QACV,IAAI,EAAE,QAAQ,CAAC;QACf,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,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;CACH;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb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