integrate-sdk 0.4.13 → 0.5.1
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/index.js +4093 -19
- package/dist/oauth.js +16 -0
- package/dist/react.js +1921 -0
- package/dist/server.js +16 -0
- package/dist/src/integrations/vercel-ai.d.ts +2 -1
- package/dist/src/integrations/vercel-ai.d.ts.map +1 -1
- package/dist/src/react/hooks.d.ts +94 -0
- package/dist/src/react/hooks.d.ts.map +1 -0
- package/package.json +20 -4
- package/react.ts +9 -0
package/dist/server.js
CHANGED
|
@@ -1,4 +1,20 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
1
3
|
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __toESM = (mod, isNodeMode, target) => {
|
|
7
|
+
target = mod != null ? __create(__getProtoOf(mod)) : {};
|
|
8
|
+
const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
|
|
9
|
+
for (let key of __getOwnPropNames(mod))
|
|
10
|
+
if (!__hasOwnProp.call(to, key))
|
|
11
|
+
__defProp(to, key, {
|
|
12
|
+
get: () => mod[key],
|
|
13
|
+
enumerable: true
|
|
14
|
+
});
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
2
18
|
var __export = (target, all) => {
|
|
3
19
|
for (var name in all)
|
|
4
20
|
__defProp(target, name, {
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Helper functions to convert MCP tools to Vercel AI SDK v5 format
|
|
5
5
|
*/
|
|
6
|
+
import { z } from "zod";
|
|
6
7
|
import type { MCPClient } from "../client.js";
|
|
7
8
|
import type { MCPTool } from "../protocol/messages.js";
|
|
8
9
|
/**
|
|
@@ -11,7 +12,7 @@ import type { MCPTool } from "../protocol/messages.js";
|
|
|
11
12
|
*/
|
|
12
13
|
export interface VercelAITool {
|
|
13
14
|
description?: string;
|
|
14
|
-
|
|
15
|
+
inputSchema: z.ZodType<any>;
|
|
15
16
|
execute: (args: any, options?: any) => Promise<any>;
|
|
16
17
|
}
|
|
17
18
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vercel-ai.d.ts","sourceRoot":"","sources":["../../../src/integrations/vercel-ai.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAEvD;;;GAGG;AACH,MAAM,WAAW,YAAY;IAC3B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,
|
|
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;AAEvD;;;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,oBAAoB;IACnC;;;;;;;;;;;;;OAaG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACzC;AAmKD;;;;;;;GAOG;AACH,wBAAgB,wBAAwB,CACtC,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,SAAS,CAAC,GAAG,CAAC,EACtB,OAAO,CAAC,EAAE,oBAAoB,GAC7B,YAAY,CAsCd;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,gCAQ/B"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* React hooks for integrate-sdk
|
|
3
|
+
*
|
|
4
|
+
* Provides React hooks for managing provider tokens and headers
|
|
5
|
+
* in client-side applications.
|
|
6
|
+
*/
|
|
7
|
+
import type { MCPClient } from "../client.js";
|
|
8
|
+
/**
|
|
9
|
+
* Return type for useIntegrateTokens hook
|
|
10
|
+
*/
|
|
11
|
+
export interface UseIntegrateTokensResult {
|
|
12
|
+
/**
|
|
13
|
+
* Current provider tokens (e.g., { github: 'token123', gmail: 'token456' })
|
|
14
|
+
*/
|
|
15
|
+
tokens: Record<string, string>;
|
|
16
|
+
/**
|
|
17
|
+
* Headers object ready to spread into fetch/useChat options
|
|
18
|
+
* Includes 'x-integrate-tokens' header with JSON-stringified tokens
|
|
19
|
+
*/
|
|
20
|
+
headers: Record<string, string>;
|
|
21
|
+
/**
|
|
22
|
+
* Whether tokens are currently being loaded
|
|
23
|
+
*/
|
|
24
|
+
isLoading: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Custom fetch function with integrate tokens automatically included
|
|
27
|
+
* Use this with libraries that accept a custom fetch function (like Vercel AI SDK's useChat)
|
|
28
|
+
*/
|
|
29
|
+
fetch: (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;
|
|
30
|
+
/**
|
|
31
|
+
* Helper function to merge integrate headers with existing headers
|
|
32
|
+
* Useful for manual fetch calls where you need to combine headers
|
|
33
|
+
*/
|
|
34
|
+
mergeHeaders: (existingHeaders?: HeadersInit) => Headers;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* React hook to access integrate-sdk provider tokens and headers
|
|
38
|
+
*
|
|
39
|
+
* Automatically listens for authentication events and updates when tokens change.
|
|
40
|
+
* Returns tokens and formatted headers ready to pass to API requests.
|
|
41
|
+
*
|
|
42
|
+
* @param client - MCP client instance created with createMCPClient()
|
|
43
|
+
* @returns Object with tokens, headers, and loading state
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* ```tsx
|
|
47
|
+
* import { createMCPClient, githubPlugin } from 'integrate-sdk';
|
|
48
|
+
* import { useIntegrateTokens } from 'integrate-sdk/react';
|
|
49
|
+
* import { useChat } from 'ai/react';
|
|
50
|
+
*
|
|
51
|
+
* const client = createMCPClient({
|
|
52
|
+
* plugins: [githubPlugin({ clientId: '...' })],
|
|
53
|
+
* });
|
|
54
|
+
*
|
|
55
|
+
* function ChatComponent() {
|
|
56
|
+
* const { tokens, headers, isLoading } = useIntegrateTokens(client);
|
|
57
|
+
*
|
|
58
|
+
* const chat = useChat({
|
|
59
|
+
* api: '/api/chat',
|
|
60
|
+
* headers, // Automatically includes x-integrate-tokens
|
|
61
|
+
* });
|
|
62
|
+
*
|
|
63
|
+
* return <div>Chat UI here</div>;
|
|
64
|
+
* }
|
|
65
|
+
* ```
|
|
66
|
+
*
|
|
67
|
+
* @example
|
|
68
|
+
* ```tsx
|
|
69
|
+
* // Manual fetch with tokens
|
|
70
|
+
* import { createMCPClient } from 'integrate-sdk';
|
|
71
|
+
*
|
|
72
|
+
* const client = createMCPClient({ plugins: [...] });
|
|
73
|
+
*
|
|
74
|
+
* function MyComponent() {
|
|
75
|
+
* const { headers } = useIntegrateTokens(client);
|
|
76
|
+
*
|
|
77
|
+
* const fetchData = async () => {
|
|
78
|
+
* const response = await fetch('/api/data', {
|
|
79
|
+
* method: 'POST',
|
|
80
|
+
* headers: {
|
|
81
|
+
* 'Content-Type': 'application/json',
|
|
82
|
+
* ...headers, // Includes x-integrate-tokens
|
|
83
|
+
* },
|
|
84
|
+
* body: JSON.stringify({ query: 'example' }),
|
|
85
|
+
* });
|
|
86
|
+
* return response.json();
|
|
87
|
+
* };
|
|
88
|
+
*
|
|
89
|
+
* return <button onClick={fetchData}>Fetch</button>;
|
|
90
|
+
* }
|
|
91
|
+
* ```
|
|
92
|
+
*/
|
|
93
|
+
export declare function useIntegrateTokens(client: MCPClient<any>): UseIntegrateTokensResult;
|
|
94
|
+
//# sourceMappingURL=hooks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../../../src/react/hooks.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAE9C;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAE/B;;;OAGG;IACH,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAEhC;;OAEG;IACH,SAAS,EAAE,OAAO,CAAC;IAEnB;;;OAGG;IACH,KAAK,EAAE,CAAC,KAAK,EAAE,WAAW,GAAG,GAAG,EAAE,IAAI,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC;IAE3E;;;OAGG;IACH,YAAY,EAAE,CAAC,eAAe,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC;CAC1D;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwDG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,SAAS,CAAC,GAAG,CAAC,GACrB,wBAAwB,CA+G1B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "integrate-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.1",
|
|
4
4
|
"description": "Type-safe TypeScript SDK for MCP Client with plugin-based OAuth provider configuration",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -26,17 +26,22 @@
|
|
|
26
26
|
"./oauth": {
|
|
27
27
|
"import": "./dist/oauth.js",
|
|
28
28
|
"types": "./dist/oauth.d.ts"
|
|
29
|
+
},
|
|
30
|
+
"./react": {
|
|
31
|
+
"import": "./dist/react.js",
|
|
32
|
+
"types": "./dist/react.d.ts"
|
|
29
33
|
}
|
|
30
34
|
},
|
|
31
35
|
"files": [
|
|
32
36
|
"dist",
|
|
33
37
|
"index.ts",
|
|
34
38
|
"server.ts",
|
|
35
|
-
"oauth.ts"
|
|
39
|
+
"oauth.ts",
|
|
40
|
+
"react.ts"
|
|
36
41
|
],
|
|
37
42
|
"scripts": {
|
|
38
43
|
"prep": "bun run type-check && bun run build",
|
|
39
|
-
"build": "bun build index.ts server.ts oauth.ts --outdir dist --target node --format esm && bun run build:types",
|
|
44
|
+
"build": "bun build index.ts server.ts oauth.ts react.ts --outdir dist --target node --format esm && bun run build:types",
|
|
40
45
|
"build:types": "tsc --emitDeclarationOnly --declaration --declarationMap",
|
|
41
46
|
"dev": "bun --watch src/index.ts",
|
|
42
47
|
"type-check": "tsc --noEmit",
|
|
@@ -56,13 +61,24 @@
|
|
|
56
61
|
],
|
|
57
62
|
"author": "",
|
|
58
63
|
"license": "MIT",
|
|
64
|
+
"dependencies": {
|
|
65
|
+
"zod": "^3.23.8"
|
|
66
|
+
},
|
|
59
67
|
"devDependencies": {
|
|
60
68
|
"@types/bun": "latest",
|
|
69
|
+
"@types/react": "^18.3.0",
|
|
70
|
+
"react": "^18.3.1",
|
|
61
71
|
"simple-git-hooks": "^2.13.1",
|
|
62
72
|
"typescript": "^5.3.3"
|
|
63
73
|
},
|
|
64
74
|
"peerDependencies": {
|
|
65
|
-
"typescript": ">=5.0.0"
|
|
75
|
+
"typescript": ">=5.0.0",
|
|
76
|
+
"react": ">=18.0.0"
|
|
77
|
+
},
|
|
78
|
+
"peerDependenciesMeta": {
|
|
79
|
+
"react": {
|
|
80
|
+
"optional": true
|
|
81
|
+
}
|
|
66
82
|
},
|
|
67
83
|
"simple-git-hooks": {
|
|
68
84
|
"pre-commit": "./scripts/check-version.sh"
|