@composio/google 0.1.12-alpha.12

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/README.md ADDED
@@ -0,0 +1,147 @@
1
+ # @composio/google
2
+
3
+ Google GenAI Provider for Composio SDK.
4
+
5
+ ## Features
6
+
7
+ - **Google GenAI Integration**: Seamless integration with Google's Generative AI models (Gemini)
8
+ - **Function Calling Support**: Convert Composio tools to Google GenAI function declarations
9
+ - **Type Safety**: Full TypeScript support with proper type definitions
10
+ - **Execution Modifiers**: Support for transforming tool inputs and outputs
11
+ - **Flexible Authentication**: Support for custom authentication parameters
12
+ - **Streaming Support**: First-class support for streaming responses
13
+
14
+ ## Installation
15
+
16
+ ```bash
17
+ npm install @composio/core @composio/google @google/genai
18
+ # or
19
+ yarn add @composio/core @composio/google @google/genai
20
+ # or
21
+ pnpm add @composio/core @composio/google @google/genai
22
+ ```
23
+
24
+ ## Environment Variables
25
+
26
+ Required environment variables:
27
+
28
+ - `COMPOSIO_API_KEY`: Your Composio API key
29
+ - `GEMINI_API_KEY`: Your Google AI API key
30
+
31
+ Optional environment variables:
32
+
33
+ - `GOOGLE_PROJECT_ID`: Your Google Cloud project ID (for custom deployments)
34
+ - `GOOGLE_LOCATION`: Your Google Cloud location (for custom deployments)
35
+
36
+ ## Quick Start
37
+
38
+ ```typescript
39
+ import { Composio } from '@composio/core';
40
+ import { GoogleProvider } from '@composio/google';
41
+ import { GoogleGenerativeAI } from '@google/genai';
42
+
43
+ // Initialize Google GenAI
44
+ const genAI = new GoogleGenerativeAI(process.env.GEMINI_API_KEY);
45
+
46
+ // Initialize Composio with Google provider
47
+ const composio = new Composio({
48
+ apiKey: process.env.COMPOSIO_API_KEY,
49
+ provider: new GoogleProvider(),
50
+ });
51
+
52
+ // Get available tools
53
+ const tools = await composio.tools.get('user123', {
54
+ toolkits: ['gmail', 'calendar'],
55
+ limit: 10,
56
+ });
57
+ ```
58
+
59
+ ## Examples
60
+
61
+ Check out our complete example implementations:
62
+
63
+ - [Basic Google Integration](../../examples/google/src/index.ts)
64
+
65
+ ## Provider Configuration
66
+
67
+ The Google provider can be configured with various options:
68
+
69
+ ```typescript
70
+ const provider = new GoogleProvider({
71
+ // Custom project configuration
72
+ projectId: 'your-project-id',
73
+ location: 'your-location',
74
+ // Custom execution modifiers
75
+ modifiers: {
76
+ beforeExecute: params => {
77
+ // Transform parameters before execution
78
+ return params;
79
+ },
80
+ afterExecute: response => {
81
+ // Transform response after execution
82
+ return response;
83
+ },
84
+ },
85
+ });
86
+ ```
87
+
88
+ ## API Reference
89
+
90
+ ### GoogleProvider Class
91
+
92
+ The `GoogleProvider` class extends `BaseNonAgenticProvider` and provides Google GenAI-specific functionality.
93
+
94
+ #### Methods
95
+
96
+ ##### `wrapTool(tool: Tool): GoogleTool`
97
+
98
+ Wraps a Composio tool in the Google GenAI function declaration format.
99
+
100
+ ```typescript
101
+ const wrappedTool = provider.wrapTool(composioTool);
102
+ ```
103
+
104
+ ##### `wrapTools(tools: Tool[]): GoogleGenAIToolCollection`
105
+
106
+ Wraps multiple Composio tools in the Google GenAI function declaration format.
107
+
108
+ ```typescript
109
+ const wrappedTools = provider.wrapTools(composioTools);
110
+ ```
111
+
112
+ ##### `executeToolCall(userId: string, tool: GoogleGenAIFunctionCall, options?: ExecuteToolFnOptions, modifiers?: ExecuteToolModifiers): Promise<string>`
113
+
114
+ Executes a tool call from Google GenAI and returns the result as a JSON string.
115
+
116
+ ```typescript
117
+ const result = await provider.executeToolCall('user123', functionCall, options, modifiers);
118
+ ```
119
+
120
+ #### Types
121
+
122
+ ```typescript
123
+ interface GoogleGenAIFunctionCall {
124
+ name: string;
125
+ args: Record<string, unknown>;
126
+ }
127
+
128
+ type GoogleTool = {
129
+ name: string;
130
+ description: string;
131
+ parameters: Schema;
132
+ };
133
+
134
+ type GoogleGenAIToolCollection = GoogleTool[];
135
+ ```
136
+
137
+ ## Contributing
138
+
139
+ We welcome contributions! Please see our [Contributing Guide](../../CONTRIBUTING.md) for more details.
140
+
141
+ ## License
142
+
143
+ ISC License
144
+
145
+ ## Support
146
+
147
+ For support, please visit our [Documentation](https://docs.composio.dev) or join our [Discord Community](https://discord.gg/composio).
package/dist/index.cjs ADDED
@@ -0,0 +1,76 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
+ GoogleProvider: () => GoogleProvider
24
+ });
25
+ module.exports = __toCommonJS(index_exports);
26
+ var import_core = require("@composio/core");
27
+ var GoogleProvider = class extends import_core.BaseNonAgenticProvider {
28
+ name = "google";
29
+ /**
30
+ * Wrap a Composio tool in the Google GenAI function declaration format.
31
+ * @param tool - The Composio tool to wrap.
32
+ * @returns The wrapped tool in Google GenAI format.
33
+ */
34
+ wrapTool(tool) {
35
+ return {
36
+ name: tool.slug,
37
+ description: tool.description || "",
38
+ parameters: {
39
+ type: "object",
40
+ description: tool.description || "",
41
+ properties: tool.inputParameters?.properties || {},
42
+ required: tool.inputParameters?.required || []
43
+ }
44
+ };
45
+ }
46
+ /**
47
+ * Wrap a list of Composio tools in the Google GenAI function declaration format.
48
+ * @param tools - The Composio tools to wrap.
49
+ * @returns The wrapped tools in Google GenAI format.
50
+ */
51
+ wrapTools(tools) {
52
+ return tools.map((tool) => this.wrapTool(tool));
53
+ }
54
+ /**
55
+ * Execute a tool call from Google GenAI.
56
+ * @param userId - The user id.
57
+ * @param tool - The Google GenAI function call to execute.
58
+ * @param options - Optional execution options.
59
+ * @param modifiers - Optional execution modifiers.
60
+ * @returns The result of the tool call as a JSON string.
61
+ */
62
+ async executeToolCall(userId, tool, options, modifiers) {
63
+ const payload = {
64
+ arguments: tool.args,
65
+ connectedAccountId: options?.connectedAccountId,
66
+ customAuthParams: options?.customAuthParams,
67
+ userId
68
+ };
69
+ const result = await this.executeTool(tool.name, payload, modifiers);
70
+ return JSON.stringify(result);
71
+ }
72
+ };
73
+ // Annotate the CommonJS export names for ESM import in node:
74
+ 0 && (module.exports = {
75
+ GoogleProvider
76
+ });
@@ -0,0 +1,60 @@
1
+ import { BaseNonAgenticProvider, Tool, ExecuteToolFnOptions, ExecuteToolModifiers } from '@composio/core';
2
+ import { FunctionDeclaration } from '@google/genai';
3
+
4
+ /**
5
+ * Google GenAI Provider
6
+ *
7
+ * This provider provides a set of tools for interacting with Google's GenAI API.
8
+ * It supports both the Gemini Developer API and Vertex AI implementations.
9
+ *
10
+ * @packageDocumentation
11
+ * @module providers/google
12
+ */
13
+
14
+ /**
15
+ * Interface for Google GenAI function declaration
16
+ * Based on the FunctionDeclaration type from @google/genai
17
+ */
18
+ type GoogleTool = FunctionDeclaration;
19
+ /**
20
+ * Interface for Google GenAI function call
21
+ * Based on the FunctionCall type from @google/genai
22
+ */
23
+ interface GoogleGenAIFunctionCall {
24
+ name: string;
25
+ args: Record<string, unknown>;
26
+ }
27
+ /**
28
+ * Type for a collection of Google GenAI function declarations
29
+ */
30
+ type GoogleGenAIToolCollection = GoogleTool[];
31
+ /**
32
+ * Google GenAI Provider for Composio SDK
33
+ * Implements the BaseNonAgenticProvider to wrap Composio tools for use with Google's GenAI API
34
+ */
35
+ declare class GoogleProvider extends BaseNonAgenticProvider<GoogleGenAIToolCollection, GoogleTool> {
36
+ readonly name = "google";
37
+ /**
38
+ * Wrap a Composio tool in the Google GenAI function declaration format.
39
+ * @param tool - The Composio tool to wrap.
40
+ * @returns The wrapped tool in Google GenAI format.
41
+ */
42
+ wrapTool(tool: Tool): GoogleTool;
43
+ /**
44
+ * Wrap a list of Composio tools in the Google GenAI function declaration format.
45
+ * @param tools - The Composio tools to wrap.
46
+ * @returns The wrapped tools in Google GenAI format.
47
+ */
48
+ wrapTools(tools: Tool[]): GoogleGenAIToolCollection;
49
+ /**
50
+ * Execute a tool call from Google GenAI.
51
+ * @param userId - The user id.
52
+ * @param tool - The Google GenAI function call to execute.
53
+ * @param options - Optional execution options.
54
+ * @param modifiers - Optional execution modifiers.
55
+ * @returns The result of the tool call as a JSON string.
56
+ */
57
+ executeToolCall(userId: string, tool: GoogleGenAIFunctionCall, options?: ExecuteToolFnOptions, modifiers?: ExecuteToolModifiers): Promise<string>;
58
+ }
59
+
60
+ export { type GoogleGenAIFunctionCall, type GoogleGenAIToolCollection, GoogleProvider, type GoogleTool };
@@ -0,0 +1,60 @@
1
+ import { BaseNonAgenticProvider, Tool, ExecuteToolFnOptions, ExecuteToolModifiers } from '@composio/core';
2
+ import { FunctionDeclaration } from '@google/genai';
3
+
4
+ /**
5
+ * Google GenAI Provider
6
+ *
7
+ * This provider provides a set of tools for interacting with Google's GenAI API.
8
+ * It supports both the Gemini Developer API and Vertex AI implementations.
9
+ *
10
+ * @packageDocumentation
11
+ * @module providers/google
12
+ */
13
+
14
+ /**
15
+ * Interface for Google GenAI function declaration
16
+ * Based on the FunctionDeclaration type from @google/genai
17
+ */
18
+ type GoogleTool = FunctionDeclaration;
19
+ /**
20
+ * Interface for Google GenAI function call
21
+ * Based on the FunctionCall type from @google/genai
22
+ */
23
+ interface GoogleGenAIFunctionCall {
24
+ name: string;
25
+ args: Record<string, unknown>;
26
+ }
27
+ /**
28
+ * Type for a collection of Google GenAI function declarations
29
+ */
30
+ type GoogleGenAIToolCollection = GoogleTool[];
31
+ /**
32
+ * Google GenAI Provider for Composio SDK
33
+ * Implements the BaseNonAgenticProvider to wrap Composio tools for use with Google's GenAI API
34
+ */
35
+ declare class GoogleProvider extends BaseNonAgenticProvider<GoogleGenAIToolCollection, GoogleTool> {
36
+ readonly name = "google";
37
+ /**
38
+ * Wrap a Composio tool in the Google GenAI function declaration format.
39
+ * @param tool - The Composio tool to wrap.
40
+ * @returns The wrapped tool in Google GenAI format.
41
+ */
42
+ wrapTool(tool: Tool): GoogleTool;
43
+ /**
44
+ * Wrap a list of Composio tools in the Google GenAI function declaration format.
45
+ * @param tools - The Composio tools to wrap.
46
+ * @returns The wrapped tools in Google GenAI format.
47
+ */
48
+ wrapTools(tools: Tool[]): GoogleGenAIToolCollection;
49
+ /**
50
+ * Execute a tool call from Google GenAI.
51
+ * @param userId - The user id.
52
+ * @param tool - The Google GenAI function call to execute.
53
+ * @param options - Optional execution options.
54
+ * @param modifiers - Optional execution modifiers.
55
+ * @returns The result of the tool call as a JSON string.
56
+ */
57
+ executeToolCall(userId: string, tool: GoogleGenAIFunctionCall, options?: ExecuteToolFnOptions, modifiers?: ExecuteToolModifiers): Promise<string>;
58
+ }
59
+
60
+ export { type GoogleGenAIFunctionCall, type GoogleGenAIToolCollection, GoogleProvider, type GoogleTool };
package/dist/index.js ADDED
@@ -0,0 +1,53 @@
1
+ // src/index.ts
2
+ import {
3
+ BaseNonAgenticProvider
4
+ } from "@composio/core";
5
+ var GoogleProvider = class extends BaseNonAgenticProvider {
6
+ name = "google";
7
+ /**
8
+ * Wrap a Composio tool in the Google GenAI function declaration format.
9
+ * @param tool - The Composio tool to wrap.
10
+ * @returns The wrapped tool in Google GenAI format.
11
+ */
12
+ wrapTool(tool) {
13
+ return {
14
+ name: tool.slug,
15
+ description: tool.description || "",
16
+ parameters: {
17
+ type: "object",
18
+ description: tool.description || "",
19
+ properties: tool.inputParameters?.properties || {},
20
+ required: tool.inputParameters?.required || []
21
+ }
22
+ };
23
+ }
24
+ /**
25
+ * Wrap a list of Composio tools in the Google GenAI function declaration format.
26
+ * @param tools - The Composio tools to wrap.
27
+ * @returns The wrapped tools in Google GenAI format.
28
+ */
29
+ wrapTools(tools) {
30
+ return tools.map((tool) => this.wrapTool(tool));
31
+ }
32
+ /**
33
+ * Execute a tool call from Google GenAI.
34
+ * @param userId - The user id.
35
+ * @param tool - The Google GenAI function call to execute.
36
+ * @param options - Optional execution options.
37
+ * @param modifiers - Optional execution modifiers.
38
+ * @returns The result of the tool call as a JSON string.
39
+ */
40
+ async executeToolCall(userId, tool, options, modifiers) {
41
+ const payload = {
42
+ arguments: tool.args,
43
+ connectedAccountId: options?.connectedAccountId,
44
+ customAuthParams: options?.customAuthParams,
45
+ userId
46
+ };
47
+ const result = await this.executeTool(tool.name, payload, modifiers);
48
+ return JSON.stringify(result);
49
+ }
50
+ };
51
+ export {
52
+ GoogleProvider
53
+ };
package/package.json ADDED
@@ -0,0 +1,44 @@
1
+ {
2
+ "name": "@composio/google",
3
+ "version": "0.1.12-alpha.12",
4
+ "description": "Google GenAI Provider for Composio SDK",
5
+ "main": "dist/index.js",
6
+ "type": "module",
7
+ "publishConfig": {
8
+ "access": "public"
9
+ },
10
+ "exports": {
11
+ ".": {
12
+ "import": "./dist/index.js",
13
+ "types": "./dist/index.d.ts",
14
+ "require": "./dist/index.cjs"
15
+ }
16
+ },
17
+ "files": [
18
+ "README.md",
19
+ "dist"
20
+ ],
21
+ "keywords": [
22
+ "composio",
23
+ "provider",
24
+ "google",
25
+ "genai",
26
+ "gemini"
27
+ ],
28
+ "author": "",
29
+ "license": "ISC",
30
+ "peerDependencies": {
31
+ "@composio/core": "0.1.12-alpha.12",
32
+ "@google/genai": "^1.1.0"
33
+ },
34
+ "devDependencies": {
35
+ "tsup": "^8.4.0",
36
+ "typescript": "^5.8.3",
37
+ "@composio/core": "0.1.12-alpha.12"
38
+ },
39
+ "scripts": {
40
+ "build": "tsup",
41
+ "test": "vitest run"
42
+ },
43
+ "types": "dist/index.d.ts"
44
+ }