@composio/google 0.10.0 → 0.10.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/README.md CHANGED
@@ -1,124 +1,72 @@
1
1
  # @composio/google
2
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
3
+ Adapts Composio tools to Gemini function declarations for the Google GenAI SDK (`@google/genai`) and executes the function calls the model returns.
13
4
 
14
5
  ## Installation
15
6
 
16
7
  ```bash
17
8
  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
9
  ```
23
10
 
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:
11
+ Set `COMPOSIO_API_KEY` (create one at https://dashboard.composio.dev/settings) and `GOOGLE_API_KEY` (from https://aistudio.google.com/apikey) in your environment.
32
12
 
33
- - `GOOGLE_PROJECT_ID`: Your Google Cloud project ID (for custom deployments)
34
- - `GOOGLE_LOCATION`: Your Google Cloud location (for custom deployments)
13
+ ## Quickstart
35
14
 
36
- ## Quick Start
15
+ Create a session for your user, pass its tools to Gemini as function declarations, and run the loop: execute each function call with `composio.provider.executeToolCall`, feed the result back, and repeat until the model replies with text.
37
16
 
38
17
  ```typescript
39
18
  import { Composio } from '@composio/core';
40
19
  import { GoogleProvider } from '@composio/google';
41
- import { GoogleGenerativeAI } from '@google/genai';
20
+ import { GoogleGenAI, type Part } from '@google/genai';
42
21
 
43
- // Initialize Google GenAI
44
- const genAI = new GoogleGenerativeAI(process.env.GEMINI_API_KEY);
45
-
46
- // Initialize Composio with Google provider
47
22
  const composio = new Composio({
48
- apiKey: process.env.COMPOSIO_API_KEY,
49
23
  provider: new GoogleProvider(),
50
24
  });
25
+ const ai = new GoogleGenAI({ apiKey: process.env.GOOGLE_API_KEY! });
51
26
 
52
- // Get available tools
53
- const tools = await composio.tools.get('user123', {
54
- toolkits: ['gmail', 'calendar'],
55
- limit: 10,
56
- });
57
- ```
58
-
59
- ## Examples
27
+ // Create a session for your user
28
+ const session = await composio.create('user_123');
29
+ const tools = await session.tools();
60
30
 
61
- Check out our complete example implementations:
62
-
63
- - [Basic Google Integration](../../examples/google/src/index.ts)
64
-
65
- ## API Reference
66
-
67
- ### GoogleProvider Class
68
-
69
- The `GoogleProvider` class extends `BaseNonAgenticProvider` and provides Google GenAI-specific functionality.
70
-
71
- #### Methods
72
-
73
- ##### `wrapTool(tool: Tool): GoogleTool`
74
-
75
- Wraps a Composio tool in the Google GenAI function declaration format.
76
-
77
- ```typescript
78
- const wrappedTool = provider.wrapTool(composioTool);
79
- ```
80
-
81
- ##### `wrapTools(tools: Tool[]): GoogleGenAIToolCollection`
82
-
83
- Wraps multiple Composio tools in the Google GenAI function declaration format.
84
-
85
- ```typescript
86
- const wrappedTools = provider.wrapTools(composioTools);
87
- ```
88
-
89
- ##### `executeToolCall(userId: string, tool: GoogleGenAIFunctionCall, options?: ExecuteToolFnOptions, modifiers?: ExecuteToolModifiers): Promise<string>`
90
-
91
- Executes a tool call from Google GenAI and returns the result as a JSON string.
92
-
93
- ```typescript
94
- const result = await provider.executeToolCall('user123', functionCall, options, modifiers);
95
- ```
31
+ const chat = ai.chats.create({
32
+ model: 'gemini-3-pro-preview',
33
+ config: {
34
+ tools: [{ functionDeclarations: tools }],
35
+ },
36
+ });
96
37
 
97
- #### Types
38
+ let response = await chat.sendMessage({
39
+ message:
40
+ "Send an email to john@example.com with the subject 'Hello' and body 'Hello from Composio!'",
41
+ });
98
42
 
99
- ```typescript
100
- interface GoogleGenAIFunctionCall {
101
- name: string;
102
- args: Record<string, unknown>;
43
+ // Agentic loop: keep executing tool calls until the model responds with text
44
+ while (response.functionCalls && response.functionCalls.length > 0) {
45
+ const parts: Part[] = [];
46
+ for (const fc of response.functionCalls) {
47
+ const result = await composio.provider.executeToolCall('user_123', {
48
+ name: fc.name || '',
49
+ args: (fc.args || {}) as Record<string, unknown>,
50
+ });
51
+ parts.push({
52
+ functionResponse: {
53
+ id: fc.id,
54
+ name: fc.name,
55
+ response: JSON.parse(result),
56
+ },
57
+ });
58
+ }
59
+ response = await chat.sendMessage({ message: parts });
103
60
  }
104
61
 
105
- type GoogleTool = {
106
- name: string;
107
- description: string;
108
- parameters: Schema;
109
- };
110
-
111
- type GoogleGenAIToolCollection = GoogleTool[];
62
+ console.log(response.text);
112
63
  ```
113
64
 
114
- ## Contributing
115
-
116
- We welcome contributions! Please see our [Contributing Guide](../../CONTRIBUTING.md) for more details.
117
-
118
- ## License
65
+ ## Tool execution
119
66
 
120
- ISC License
67
+ Gemini function calling is non-agentic; the model returns function calls and you execute them. `GoogleProvider` exposes `executeToolCall(userId, functionCall, options?, modifiers?)`, which takes a `{ name, args }` pair and returns the tool result as a JSON string. The constructor takes no options.
121
68
 
122
- ## Support
69
+ ## Links
123
70
 
124
- For support, please visit our [Documentation](https://docs.composio.dev) or join our [Discord Community](https://discord.gg/composio).
71
+ - [Google provider docs](https://docs.composio.dev/docs/providers/google)
72
+ - [Composio documentation](https://docs.composio.dev)
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { BaseNonAgenticProvider, normalizeToolArguments } from "@composio/core";
1
+ import { BaseNonAgenticProvider, deduplicateJsonSchemaRequiredArrays, normalizeToolArguments } from "@composio/core";
2
2
 
3
3
  //#region src/index.ts
4
4
  /**
@@ -90,14 +90,15 @@ var GoogleProvider = class extends BaseNonAgenticProvider {
90
90
  * ```
91
91
  */
92
92
  wrapTool(tool) {
93
+ const inputParameters = deduplicateJsonSchemaRequiredArrays(tool.inputParameters);
93
94
  return {
94
95
  name: tool.slug,
95
96
  description: tool.description || "",
96
97
  parameters: {
97
98
  type: "object",
98
99
  description: tool.description || "",
99
- properties: tool.inputParameters?.properties || {},
100
- required: tool.inputParameters?.required || []
100
+ properties: inputParameters?.properties || {},
101
+ required: inputParameters?.required || []
101
102
  }
102
103
  };
103
104
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@composio/google",
3
- "version": "0.10.0",
3
+ "version": "0.10.1",
4
4
  "description": "Google GenAI Provider for Composio SDK",
5
5
  "main": "dist/index.mjs",
6
6
  "type": "module",
@@ -12,7 +12,7 @@
12
12
  "bugs": {
13
13
  "url": "https://github.com/ComposioHQ/composio/issues"
14
14
  },
15
- "homepage": "https://github.com/ComposioHQ/composio/tree/main/ts/packages/providers/google#readme",
15
+ "homepage": "https://github.com/ComposioHQ/composio/tree/next/ts/packages/providers/google#readme",
16
16
  "publishConfig": {
17
17
  "access": "public"
18
18
  },
@@ -42,7 +42,7 @@
42
42
  "devDependencies": {
43
43
  "tsdown": "^0.22.3",
44
44
  "typescript": "^6.0.3",
45
- "@composio/core": "0.12.0"
45
+ "@composio/core": "0.14.0"
46
46
  },
47
47
  "scripts": {
48
48
  "clean": "git clean -xdf node_modules",