integrate-sdk 0.4.12 → 0.5.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/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
- parameters: any;
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,CA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,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,84 @@
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
+ /**
27
+ * React hook to access integrate-sdk provider tokens and headers
28
+ *
29
+ * Automatically listens for authentication events and updates when tokens change.
30
+ * Returns tokens and formatted headers ready to pass to API requests.
31
+ *
32
+ * @param client - MCP client instance created with createMCPClient()
33
+ * @returns Object with tokens, headers, and loading state
34
+ *
35
+ * @example
36
+ * ```tsx
37
+ * import { createMCPClient, githubPlugin } from 'integrate-sdk';
38
+ * import { useIntegrateTokens } from 'integrate-sdk/react';
39
+ * import { useChat } from 'ai/react';
40
+ *
41
+ * const client = createMCPClient({
42
+ * plugins: [githubPlugin({ clientId: '...' })],
43
+ * });
44
+ *
45
+ * function ChatComponent() {
46
+ * const { tokens, headers, isLoading } = useIntegrateTokens(client);
47
+ *
48
+ * const chat = useChat({
49
+ * api: '/api/chat',
50
+ * headers, // Automatically includes x-integrate-tokens
51
+ * });
52
+ *
53
+ * return <div>Chat UI here</div>;
54
+ * }
55
+ * ```
56
+ *
57
+ * @example
58
+ * ```tsx
59
+ * // Manual fetch with tokens
60
+ * import { createMCPClient } from 'integrate-sdk';
61
+ *
62
+ * const client = createMCPClient({ plugins: [...] });
63
+ *
64
+ * function MyComponent() {
65
+ * const { headers } = useIntegrateTokens(client);
66
+ *
67
+ * const fetchData = async () => {
68
+ * const response = await fetch('/api/data', {
69
+ * method: 'POST',
70
+ * headers: {
71
+ * 'Content-Type': 'application/json',
72
+ * ...headers, // Includes x-integrate-tokens
73
+ * },
74
+ * body: JSON.stringify({ query: 'example' }),
75
+ * });
76
+ * return response.json();
77
+ * };
78
+ *
79
+ * return <button onClick={fetchData}>Fetch</button>;
80
+ * }
81
+ * ```
82
+ */
83
+ export declare function useIntegrateTokens(client: MCPClient<any>): UseIntegrateTokensResult;
84
+ //# 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;CACpB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwDG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,SAAS,CAAC,GAAG,CAAC,GACrB,wBAAwB,CA4E1B"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "integrate-sdk",
3
- "version": "0.4.12",
3
+ "version": "0.5.0",
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"
package/react.ts ADDED
@@ -0,0 +1,9 @@
1
+ /**
2
+ * React integration for integrate-sdk
3
+ *
4
+ * @packageDocumentation
5
+ */
6
+
7
+ export { useIntegrateTokens } from "./src/react/hooks.js";
8
+ export type { UseIntegrateTokensResult } from "./src/react/hooks.js";
9
+