integrate-sdk 0.1.5 → 0.2.0
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/LICENSE +1 -1
- package/README.md +114 -584
- package/dist/client.d.ts +88 -2
- package/dist/client.d.ts.map +1 -1
- package/dist/config/types.d.ts +45 -0
- package/dist/config/types.d.ts.map +1 -1
- package/dist/errors.d.ts +67 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/index.d.ts +5 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +336 -7
- package/dist/integrations/vercel-ai.d.ts +1 -1
- package/dist/integrations/vercel-ai.d.ts.map +1 -1
- package/dist/plugins/generic.d.ts +17 -10
- package/dist/plugins/generic.d.ts.map +1 -1
- package/dist/plugins/github-client.d.ts +320 -0
- package/dist/plugins/github-client.d.ts.map +1 -0
- package/dist/plugins/github.d.ts +4 -1
- package/dist/plugins/github.d.ts.map +1 -1
- package/dist/plugins/gmail-client.d.ts +200 -0
- package/dist/plugins/gmail-client.d.ts.map +1 -0
- package/dist/plugins/gmail.d.ts +4 -1
- package/dist/plugins/gmail.d.ts.map +1 -1
- package/dist/plugins/server-client.d.ts +18 -0
- package/dist/plugins/server-client.d.ts.map +1 -0
- package/dist/plugins/types.d.ts +4 -4
- package/dist/plugins/types.d.ts.map +1 -1
- package/dist/transport/http-session.d.ts.map +1 -1
- package/dist/utils/naming.d.ts +37 -0
- package/dist/utils/naming.d.ts.map +1 -0
- package/package.json +8 -4
package/dist/client.d.ts
CHANGED
|
@@ -5,6 +5,10 @@
|
|
|
5
5
|
import type { MCPTool, MCPToolCallResponse } from "./protocol/messages.js";
|
|
6
6
|
import type { MCPPlugin, OAuthConfig } from "./plugins/types.js";
|
|
7
7
|
import type { MCPClientConfig } from "./config/types.js";
|
|
8
|
+
import { type AuthenticationError } from "./errors.js";
|
|
9
|
+
import type { GitHubPluginClient } from "./plugins/github-client.js";
|
|
10
|
+
import type { GmailPluginClient } from "./plugins/gmail-client.js";
|
|
11
|
+
import type { ServerPluginClient } from "./plugins/server-client.js";
|
|
8
12
|
/**
|
|
9
13
|
* Tool invocation options
|
|
10
14
|
*/
|
|
@@ -14,6 +18,25 @@ export interface ToolInvocationOptions {
|
|
|
14
18
|
/** Tool arguments */
|
|
15
19
|
arguments?: Record<string, unknown>;
|
|
16
20
|
}
|
|
21
|
+
/**
|
|
22
|
+
* Extract all plugin IDs from a plugins array as a union
|
|
23
|
+
*/
|
|
24
|
+
type ExtractPluginId<T> = T extends {
|
|
25
|
+
id: infer Id;
|
|
26
|
+
} ? Id : never;
|
|
27
|
+
type PluginIds<TPlugins extends readonly MCPPlugin[]> = ExtractPluginId<TPlugins[number]>;
|
|
28
|
+
/**
|
|
29
|
+
* Check if a specific plugin ID exists in the plugin array
|
|
30
|
+
*/
|
|
31
|
+
type HasPluginId<TPlugins extends readonly MCPPlugin[], Id extends string> = Id extends PluginIds<TPlugins> ? true : false;
|
|
32
|
+
/**
|
|
33
|
+
* Plugin namespace type mapping - only includes properties for configured plugins
|
|
34
|
+
*/
|
|
35
|
+
type PluginNamespaces<TPlugins extends readonly MCPPlugin[]> = (HasPluginId<TPlugins, "github"> extends true ? {
|
|
36
|
+
github: GitHubPluginClient;
|
|
37
|
+
} : {}) & (HasPluginId<TPlugins, "gmail"> extends true ? {
|
|
38
|
+
gmail: GmailPluginClient;
|
|
39
|
+
} : {});
|
|
17
40
|
/**
|
|
18
41
|
* MCP Client Class
|
|
19
42
|
*
|
|
@@ -26,7 +49,30 @@ export declare class MCPClient<TPlugins extends readonly MCPPlugin[] = readonly
|
|
|
26
49
|
private enabledToolNames;
|
|
27
50
|
private initialized;
|
|
28
51
|
private clientInfo;
|
|
52
|
+
private onReauthRequired?;
|
|
53
|
+
private maxReauthRetries;
|
|
54
|
+
private authState;
|
|
55
|
+
readonly github: PluginNamespaces<TPlugins> extends {
|
|
56
|
+
github: GitHubPluginClient;
|
|
57
|
+
} ? GitHubPluginClient : never;
|
|
58
|
+
readonly gmail: PluginNamespaces<TPlugins> extends {
|
|
59
|
+
gmail: GmailPluginClient;
|
|
60
|
+
} ? GmailPluginClient : never;
|
|
61
|
+
readonly server: ServerPluginClient;
|
|
29
62
|
constructor(config: MCPClientConfig<TPlugins>);
|
|
63
|
+
/**
|
|
64
|
+
* Create a proxy for a plugin namespace that intercepts method calls
|
|
65
|
+
* and routes them to the appropriate tool
|
|
66
|
+
*/
|
|
67
|
+
private createPluginProxy;
|
|
68
|
+
/**
|
|
69
|
+
* Create a proxy for the server namespace that handles server-level tools
|
|
70
|
+
*/
|
|
71
|
+
private createServerProxy;
|
|
72
|
+
/**
|
|
73
|
+
* Internal implementation for calling server tools
|
|
74
|
+
*/
|
|
75
|
+
private callServerToolInternal;
|
|
30
76
|
/**
|
|
31
77
|
* Initialize all plugins
|
|
32
78
|
*/
|
|
@@ -44,9 +90,32 @@ export declare class MCPClient<TPlugins extends readonly MCPPlugin[] = readonly
|
|
|
44
90
|
*/
|
|
45
91
|
private discoverTools;
|
|
46
92
|
/**
|
|
47
|
-
*
|
|
93
|
+
* Internal method for integrations to call tools by name
|
|
94
|
+
* Used by integrations like Vercel AI that need to map from tool names
|
|
95
|
+
* @internal
|
|
48
96
|
*/
|
|
49
|
-
|
|
97
|
+
_callToolByName(name: string, args?: Record<string, unknown>): Promise<MCPToolCallResponse>;
|
|
98
|
+
/**
|
|
99
|
+
* Call any available tool on the server by name, bypassing plugin restrictions
|
|
100
|
+
* Useful for server-level tools like 'list_tools_by_integration' that don't belong to a specific plugin
|
|
101
|
+
*
|
|
102
|
+
* @example
|
|
103
|
+
* ```typescript
|
|
104
|
+
* // Call a server-level tool
|
|
105
|
+
* const tools = await client.callServerTool('list_tools_by_integration', {
|
|
106
|
+
* integration: 'github'
|
|
107
|
+
* });
|
|
108
|
+
* ```
|
|
109
|
+
*/
|
|
110
|
+
callServerTool(name: string, args?: Record<string, unknown>): Promise<MCPToolCallResponse>;
|
|
111
|
+
/**
|
|
112
|
+
* Internal method to call a tool with retry logic
|
|
113
|
+
*/
|
|
114
|
+
private callToolWithRetry;
|
|
115
|
+
/**
|
|
116
|
+
* Get the OAuth provider for a given tool
|
|
117
|
+
*/
|
|
118
|
+
private getProviderForTool;
|
|
50
119
|
/**
|
|
51
120
|
* Get a tool by name
|
|
52
121
|
*/
|
|
@@ -83,6 +152,22 @@ export declare class MCPClient<TPlugins extends readonly MCPPlugin[] = readonly
|
|
|
83
152
|
* Check if client is initialized
|
|
84
153
|
*/
|
|
85
154
|
isInitialized(): boolean;
|
|
155
|
+
/**
|
|
156
|
+
* Get authentication state for a specific provider
|
|
157
|
+
*/
|
|
158
|
+
getAuthState(provider: string): {
|
|
159
|
+
authenticated: boolean;
|
|
160
|
+
lastError?: AuthenticationError;
|
|
161
|
+
} | undefined;
|
|
162
|
+
/**
|
|
163
|
+
* Check if a specific provider is authenticated
|
|
164
|
+
*/
|
|
165
|
+
isProviderAuthenticated(provider: string): boolean;
|
|
166
|
+
/**
|
|
167
|
+
* Manually trigger re-authentication for a specific provider
|
|
168
|
+
* Useful if you want to proactively refresh tokens
|
|
169
|
+
*/
|
|
170
|
+
reauthenticate(provider: string): Promise<boolean>;
|
|
86
171
|
}
|
|
87
172
|
/**
|
|
88
173
|
* Create a new MCP Client instance
|
|
@@ -106,4 +191,5 @@ export declare class MCPClient<TPlugins extends readonly MCPPlugin[] = readonly
|
|
|
106
191
|
* ```
|
|
107
192
|
*/
|
|
108
193
|
export declare function createMCPClient<TPlugins extends readonly MCPPlugin[]>(config: MCPClientConfig<TPlugins>): MCPClient<TPlugins>;
|
|
194
|
+
export {};
|
|
109
195
|
//# sourceMappingURL=client.d.ts.map
|
package/dist/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EACV,OAAO,EAEP,mBAAmB,EAIpB,MAAM,wBAAwB,CAAC;AAEh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zD;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,eAAe,CAAC,QAAQ,SAAS,SAAS,SAAS,EAAE,EACnE,MAAM,EAAE,eAAe,CAAC,QAAQ,CAAC,GAChC,SAAS,CAAC,QAAQ,CAAC,CAErB"}
|
package/dist/config/types.d.ts
CHANGED
|
@@ -3,6 +3,24 @@
|
|
|
3
3
|
* Type-safe configuration with inference
|
|
4
4
|
*/
|
|
5
5
|
import type { MCPPlugin } from "../plugins/types.js";
|
|
6
|
+
import type { AuthenticationError } from "../errors.js";
|
|
7
|
+
/**
|
|
8
|
+
* Re-authentication context provided to the callback
|
|
9
|
+
*/
|
|
10
|
+
export interface ReauthContext {
|
|
11
|
+
/** The plugin/provider that needs re-authentication */
|
|
12
|
+
provider: string;
|
|
13
|
+
/** The error that triggered re-authentication */
|
|
14
|
+
error: AuthenticationError;
|
|
15
|
+
/** The tool name that was being called (if applicable) */
|
|
16
|
+
toolName?: string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Re-authentication handler function
|
|
20
|
+
* Called when authentication fails and user needs to re-authenticate
|
|
21
|
+
* Should return true if re-authentication was successful, false otherwise
|
|
22
|
+
*/
|
|
23
|
+
export type ReauthHandler = (context: ReauthContext) => Promise<boolean> | boolean;
|
|
6
24
|
/**
|
|
7
25
|
* Main client configuration
|
|
8
26
|
*/
|
|
@@ -18,6 +36,33 @@ export interface MCPClientConfig<TPlugins extends readonly MCPPlugin[]> {
|
|
|
18
36
|
name: string;
|
|
19
37
|
version: string;
|
|
20
38
|
};
|
|
39
|
+
/**
|
|
40
|
+
* Handler called when authentication fails and re-authentication is needed
|
|
41
|
+
* This is typically called when OAuth tokens expire or become invalid
|
|
42
|
+
*
|
|
43
|
+
* @param context - Information about the authentication failure
|
|
44
|
+
* @returns Promise<boolean> - true if re-authentication was successful, false otherwise
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* ```typescript
|
|
48
|
+
* const client = createMCPClient({
|
|
49
|
+
* plugins: [githubPlugin(...)],
|
|
50
|
+
* onReauthRequired: async (context) => {
|
|
51
|
+
* console.log(`Re-auth needed for ${context.provider}`);
|
|
52
|
+
* // Trigger your OAuth flow here
|
|
53
|
+
* // Return true if successful, false otherwise
|
|
54
|
+
* return await triggerOAuthFlow(context.provider);
|
|
55
|
+
* }
|
|
56
|
+
* });
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
59
|
+
onReauthRequired?: ReauthHandler;
|
|
60
|
+
/**
|
|
61
|
+
* Maximum number of automatic retry attempts when authentication fails
|
|
62
|
+
* Default: 1 (one retry after re-authentication)
|
|
63
|
+
* Set to 0 to disable automatic retries
|
|
64
|
+
*/
|
|
65
|
+
maxReauthRetries?: number;
|
|
21
66
|
}
|
|
22
67
|
/**
|
|
23
68
|
* Helper type to infer enabled tools from plugins
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/config/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/config/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAExD;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,uDAAuD;IACvD,QAAQ,EAAE,MAAM,CAAC;IACjB,iDAAiD;IACjD,KAAK,EAAE,mBAAmB,CAAC;IAC3B,0DAA0D;IAC1D,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;;;GAIG;AACH,MAAM,MAAM,aAAa,GAAG,CAAC,OAAO,EAAE,aAAa,KAAK,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;AAEnF;;GAEG;AACH,MAAM,WAAW,eAAe,CAAC,QAAQ,SAAS,SAAS,SAAS,EAAE;IACpE,iCAAiC;IACjC,OAAO,EAAE,QAAQ,CAAC;IAElB,mDAAmD;IACnD,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAEjC,uDAAuD;IACvD,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB,yBAAyB;IACzB,UAAU,CAAC,EAAE;QACX,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,MAAM,CAAC;KACjB,CAAC;IAEF;;;;;;;;;;;;;;;;;;;OAmBG;IACH,gBAAgB,CAAC,EAAE,aAAa,CAAC;IAEjC;;;;OAIG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED;;GAEG;AACH,MAAM,MAAM,iBAAiB,CAAC,QAAQ,SAAS,SAAS,SAAS,EAAE,IACjE,QAAQ,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC;AAEpC;;GAEG;AACH,MAAM,MAAM,gBAAgB,CAAC,QAAQ,SAAS,SAAS,SAAS,EAAE,IAAI;KACnE,CAAC,IAAI,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC;CAC/C,CAAC"}
|
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Custom error types for the Integrate SDK
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Base error class for all SDK errors
|
|
6
|
+
*/
|
|
7
|
+
export declare class IntegrateSDKError extends Error {
|
|
8
|
+
constructor(message: string);
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Error thrown when authentication fails or tokens are invalid
|
|
12
|
+
*/
|
|
13
|
+
export declare class AuthenticationError extends IntegrateSDKError {
|
|
14
|
+
readonly statusCode?: number;
|
|
15
|
+
readonly provider?: string;
|
|
16
|
+
constructor(message: string, statusCode?: number, provider?: string);
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Error thrown when access is forbidden (insufficient permissions)
|
|
20
|
+
*/
|
|
21
|
+
export declare class AuthorizationError extends IntegrateSDKError {
|
|
22
|
+
readonly statusCode?: number;
|
|
23
|
+
readonly requiredScopes?: string[];
|
|
24
|
+
constructor(message: string, statusCode?: number, requiredScopes?: string[]);
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Error thrown when OAuth tokens have expired and need to be refreshed
|
|
28
|
+
*/
|
|
29
|
+
export declare class TokenExpiredError extends AuthenticationError {
|
|
30
|
+
constructor(message: string, provider?: string);
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Error thrown when a connection to the server fails
|
|
34
|
+
*/
|
|
35
|
+
export declare class ConnectionError extends IntegrateSDKError {
|
|
36
|
+
readonly statusCode?: number;
|
|
37
|
+
constructor(message: string, statusCode?: number);
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Error thrown when a tool call fails
|
|
41
|
+
*/
|
|
42
|
+
export declare class ToolCallError extends IntegrateSDKError {
|
|
43
|
+
readonly toolName: string;
|
|
44
|
+
readonly originalError?: unknown;
|
|
45
|
+
constructor(message: string, toolName: string, originalError?: unknown);
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Helper function to determine if an error is an authentication error
|
|
49
|
+
*/
|
|
50
|
+
export declare function isAuthError(error: unknown): error is AuthenticationError;
|
|
51
|
+
/**
|
|
52
|
+
* Helper function to determine if an error is a token expired error
|
|
53
|
+
*/
|
|
54
|
+
export declare function isTokenExpiredError(error: unknown): error is TokenExpiredError;
|
|
55
|
+
/**
|
|
56
|
+
* Helper function to determine if an error is an authorization error
|
|
57
|
+
*/
|
|
58
|
+
export declare function isAuthorizationError(error: unknown): error is AuthorizationError;
|
|
59
|
+
/**
|
|
60
|
+
* Helper function to parse error responses from the MCP server
|
|
61
|
+
* and convert them to appropriate error types
|
|
62
|
+
*/
|
|
63
|
+
export declare function parseServerError(error: any, context?: {
|
|
64
|
+
toolName?: string;
|
|
65
|
+
provider?: string;
|
|
66
|
+
}): IntegrateSDKError;
|
|
67
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;GAEG;AACH,qBAAa,iBAAkB,SAAQ,KAAK;gBAC9B,OAAO,EAAE,MAAM;CAI5B;AAED;;GAEG;AACH,qBAAa,mBAAoB,SAAQ,iBAAiB;IACxD,SAAgB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpC,SAAgB,QAAQ,CAAC,EAAE,MAAM,CAAC;gBAEtB,OAAO,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM;CAMpE;AAED;;GAEG;AACH,qBAAa,kBAAmB,SAAQ,iBAAiB;IACvD,SAAgB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpC,SAAgB,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;gBAE9B,OAAO,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,EAAE,cAAc,CAAC,EAAE,MAAM,EAAE;CAM5E;AAED;;GAEG;AACH,qBAAa,iBAAkB,SAAQ,mBAAmB;gBAC5C,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM;CAI/C;AAED;;GAEG;AACH,qBAAa,eAAgB,SAAQ,iBAAiB;IACpD,SAAgB,UAAU,CAAC,EAAE,MAAM,CAAC;gBAExB,OAAO,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM;CAKjD;AAED;;GAEG;AACH,qBAAa,aAAc,SAAQ,iBAAiB;IAClD,SAAgB,QAAQ,EAAE,MAAM,CAAC;IACjC,SAAgB,aAAa,CAAC,EAAE,OAAO,CAAC;gBAE5B,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,aAAa,CAAC,EAAE,OAAO;CAMvE;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,mBAAmB,CAExE;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,iBAAiB,CAE9E;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,kBAAkB,CAEhF;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,GAAG,EACV,OAAO,CAAC,EAAE;IAAE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,GACjD,iBAAiB,CA+FnB"}
|
package/dist/index.d.ts
CHANGED
|
@@ -4,12 +4,14 @@
|
|
|
4
4
|
*/
|
|
5
5
|
export { MCPClient, createMCPClient } from "./client.js";
|
|
6
6
|
export type { ToolInvocationOptions } from "./client.js";
|
|
7
|
-
export type { MCPClientConfig } from "./config/types.js";
|
|
7
|
+
export type { MCPClientConfig, ReauthContext, ReauthHandler } from "./config/types.js";
|
|
8
|
+
export { IntegrateSDKError, AuthenticationError, AuthorizationError, TokenExpiredError, ConnectionError, ToolCallError, isAuthError, isTokenExpiredError, isAuthorizationError, parseServerError, } from "./errors.js";
|
|
8
9
|
export type { MCPPlugin, OAuthConfig, ExtractPluginIds, ExtractPluginTools, } from "./plugins/types.js";
|
|
9
10
|
export { githubPlugin } from "./plugins/github.js";
|
|
10
|
-
export type { GitHubPluginConfig, GitHubTools } from "./plugins/github.js";
|
|
11
|
+
export type { GitHubPluginConfig, GitHubTools, GitHubPluginClient } from "./plugins/github.js";
|
|
11
12
|
export { gmailPlugin } from "./plugins/gmail.js";
|
|
12
|
-
export type { GmailPluginConfig, GmailTools } from "./plugins/gmail.js";
|
|
13
|
+
export type { GmailPluginConfig, GmailTools, GmailPluginClient } from "./plugins/gmail.js";
|
|
14
|
+
export type { ServerPluginClient } from "./plugins/server-client.js";
|
|
13
15
|
export { genericOAuthPlugin, createSimplePlugin, } from "./plugins/generic.js";
|
|
14
16
|
export type { GenericOAuthPluginConfig } from "./plugins/generic.js";
|
|
15
17
|
export { convertMCPToolToVercelAI, convertMCPToolsToVercelAI, getVercelAITools, } from "./integrations/vercel-ai.js";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACzD,YAAY,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAGzD,YAAY,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACzD,YAAY,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAGzD,YAAY,EAAE,eAAe,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAGvF,OAAO,EACL,iBAAiB,EACjB,mBAAmB,EACnB,kBAAkB,EAClB,iBAAiB,EACjB,eAAe,EACf,aAAa,EACb,WAAW,EACX,mBAAmB,EACnB,oBAAoB,EACpB,gBAAgB,GACjB,MAAM,aAAa,CAAC;AAGrB,YAAY,EACV,SAAS,EACT,WAAW,EACX,gBAAgB,EAChB,kBAAkB,GACnB,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,YAAY,EAAE,kBAAkB,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAE/F,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