@devries-cameron20 / composio Mirror · read-only / commits / c43bf494e
Fork 0

Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.

Mirrored from https://github.com/Camo67/composio.git

Synced Nov 23, 03:00 UTC

Update scripts and readme

haxzie committed May 13, 2025 at 14:39 UTC c43bf494eda985991cf41f6c1331aabe5d0dfd96
3 files changed +281 -91
README.md
+56 -20
@@ -11,62 +11,98 @@ The core Composio SDK which allows users to interact with the Composio Platform.
11 - **ConnectedAccounts**: Manage third-party service connections. Includes functionality to create, list, refresh, and manage the status of connected accounts.
12 - **ActionExecution**: Track and manage the execution of actions within the platform.
13
14 +## Toolsets
15 +
16 +Composio SDK supports two types of toolsets:
17 +
18 +1. **Non-Agentic Toolsets**: These toolsets only support schema modifiers for transforming tool schemas. They are suitable for simple integrations like OpenAI, Anthropic, etc.
19 +2. **Agentic Toolsets**: These toolsets support full modifier capabilities including tool execution modifiers, schema modifiers, and custom modifiers. They are suitable for more complex integrations like Vercel, Langchain, etc.
20
21 ## Usage
16 -@composio/core ships with openai toolset by default. You can directly use the tools from composio in `openai` methods.
17 -```
18 -import { Composio } from "@composio/core";
22
20 -// By default composio ships with OpenAI toolset
23 +@composio/core ships with OpenAI toolset by default. You can directly use the tools from composio in `openai` methods.
24 +
25 +```typescript
26 +import { Composio } from '@composio/core';
27 +
28 +// By default composio ships with OpenAI toolset (non-agentic)
29 const composio = new Composio({
30 apiKey: process.env.COMPOSIO_API_KEY,
31 });
32
25 -const tool = await composio.getTool("HACKERNEWS_SEARCH_POSTS");
33 +const tool = await composio.getToolBySlug('HACKERNEWS_SEARCH_POSTS');
34 console.log(tool);
35 ```
36
37 For more examples, please check the `/examples` directory.
38
39 ## Using with a different toolset
40 +
41 To use a different toolset, please install the recommended toolset packages.
42
34 -```
35 -import { Composio } from "@composio/core";
36 -import { VercelToolset } from "@composio/vercel"
43 +```typescript
44 +import { Composio } from '@composio/core';
45 +import { VercelToolset } from '@composio/vercel-toolset'; // Agentic toolset
46 +// or
47 +import { OpenAIToolset } from '@composio/openai-toolset'; // Non-agentic toolset
48
49 const composio = new Composio({
50 apiKey: process.env.COMPOSIO_API_KEY,
40 - toolset: new VercelToolset();
51 + toolset: new VercelToolset(), // or new OpenAIToolset()
52 });
53
43 -const tool = await composio.getTool("HACKERNEWS_SEARCH_POSTS");
54 +const tool = await composio.getToolBySlug('HACKERNEWS_SEARCH_POSTS');
55 console.log(tool);
56 ```
57
47 -
58 ## Creating a new toolset
49 -To create a new Toolset, you need to extend the `BaseComposioToolset<YourToolType>` and implement the `_wrapTool` method to return the tool type of your choice.
59
51 -To Quickly create a toolset project, execute the following command from the root of the project
60 +To create a new Toolset, you need to extend either `BaseNonAgenticToolset` or `BaseAgenticToolset` from `@composio/core` and implement the required methods.
61 +
62 +To quickly create a toolset project, execute the following command from the root of the project:
63 +
64 +```bash
65 +# Create a non-agentic toolset (default)
66 +pnpm run create-toolset <your-toolset-name>
67 +
68 +# Create an agentic toolset
69 +pnpm run create-toolset <your-toolset-name> --agentic
70 ```
53 -pnpm run create-toolset <your toolset name>
71 +
72 +For example:
73 +
74 +```bash
75 +# Create a non-agentic toolset for Anthropic
76 +pnpm run create-toolset anthropic
77 +
78 +# Create an agentic toolset for Langchain
79 +pnpm run create-toolset langchain --agentic
80 ```
55 -eg:
81 +
82 +The script will create a new toolset with the following structure:
83 +
84 ```
57 -pnpm run create-toolset langchain
85 +<toolset-name>/
86 +├── src/
87 +│ └── index.ts # Toolset implementation
88 +├── package.json # Package configuration
89 +├── tsconfig.json # TypeScript configuration
90 +├── tsup.config.ts # Build configuration
91 +└── README.md # Toolset documentation
92 ```
93
94 ## Internal
95 +
96 What's not included from @composio/client
62 -- [X] Org/Project Mangement with API Keys
63 -- [X] Trigger Subscriptions
97 +
98 +- [x] Org/Project Mangement with API Keys
99 +- [x] Trigger Subscriptions
100 - [ ] Zod Schemas for type checking `Ideally strike a minimal balance, since backend has most`
101 - [ ] Action Execution
102 - [ ] CLI `Do we need this in the core SDK?`
103 - [ ] MCP `Not required as this is not necessary`
68 -- [ ] Team Members
104 +- [ ] Team Members
105 - [ ] File uploads/user files
106 - [ ] Tests
107
72 -These models can be still be accessed via the SDK explicitly by using the `@composio/client`.
\ No newline at end of file
108 +These models can be still be accessed via the SDK explicitly by using the `@composio/client`.
packages/toolsets/README.md
+130 -60
@@ -2,61 +2,119 @@
2
3 This package contains various toolsets that integrate with Composio's core functionality. Each toolset provides a collection of tools that can be used to interact with different services and APIs.
4
5 -## Creating a New Toolset
5 +## Types of Toolsets
6
7 -To create a new toolset, you can use the provided script:
7 +Composio SDK supports two types of toolsets:
8
9 -```bash
10 -npm run create-toolset <toolset-name>
11 -```
9 +### 1. Non-Agentic Toolsets
10
13 -This will create a new toolset with the following structure:
14 -```
15 -<toolset-name>/
16 -├── src/
17 -│ └── index.ts
18 -├── package.json
19 -├── tsconfig.json
20 -└── tsup.config.ts
11 +These toolsets only support schema modifiers for transforming tool schemas. They are suitable for simple integrations like OpenAI, Anthropic, etc.
12 +
13 +```typescript
14 +import { BaseNonAgenticToolset } from '@composio/core';
15 +import type { Tool, ToolListParams, SchemaModifiersParams } from '@composio/core';
16 +
17 +interface ToolType {
18 + // Define your tool type here
19 +}
20 +
21 +interface ToolCollection {
22 + // Define your tool collection here
23 +}
24 +
25 +export class NonAgenticToolset extends BaseNonAgenticToolset<ToolCollection, ToolType> {
26 + static FRAMEWORK_NAME = 'non-agentic-toolset';
27 + readonly FILE_NAME: string = 'toolsets/non-agentic-toolset/src/index.ts';
28 +
29 + wrapTool = (tool: Tool): ToolType => {
30 + // Implement tool wrapping logic
31 + return tool as ToolType;
32 + };
33 +
34 + getTools = async (
35 + params?: ToolListParams,
36 + modifiers?: SchemaModifiersParams
37 + ): Promise<ToolCollection> => {
38 + // Implement tool collection logic
39 + return [];
40 + };
41 +
42 + getToolBySlug = async (slug: string, modifiers?: SchemaModifiersParams): Promise<ToolType> => {
43 + const tool = await this.getComposio().tools.getToolBySlug(slug, modifiers?.schema);
44 + return this.wrapTool(tool);
45 + };
46 +}
47 ```
48
23 -## Toolset Implementation
49 +### 2. Agentic Toolsets
50
25 -Each toolset extends the `BaseComposioToolset` class from `@composio/core`. Here's a basic structure of a toolset:
51 +These toolsets support full modifier capabilities including tool execution modifiers, schema modifiers, and custom modifiers. They are suitable for more complex integrations like Vercel, Langchain, etc.
52
53 ```typescript
28 -import { BaseComposioToolset } from "@composio/core";
29 -import type { Tool, ToolListParams } from "@composio/core";
54 +import { BaseAgenticToolset } from '@composio/core';
55 +import type { Tool, ToolListParams, ModifiersParams } from '@composio/core';
56
57 interface ToolType {
32 - // Define your tool type here
58 + // Define your tool type here
59 }
60
61 interface ToolCollection {
36 - // Define your tool collection here
62 + // Define your tool collection here
63 +}
64 +
65 +export class AgenticToolset extends BaseAgenticToolset<ToolCollection, ToolType> {
66 + static FRAMEWORK_NAME = 'agentic-toolset';
67 + readonly FILE_NAME: string = 'toolsets/agentic-toolset/src/index.ts';
68 +
69 + wrapTool = (tool: Tool): ToolType => {
70 + // Implement tool wrapping logic
71 + return tool as ToolType;
72 + };
73 +
74 + getTools = async (
75 + params?: ToolListParams,
76 + modifiers?: ModifiersParams
77 + ): Promise<ToolCollection> => {
78 + // Implement tool collection logic with full modifier support
79 + return [];
80 + };
81 +
82 + getToolBySlug = async (slug: string, modifiers?: ModifiersParams): Promise<ToolType> => {
83 + const tool = await this.getComposio().tools.getToolBySlug(slug, modifiers?.schema);
84 + return this.wrapTool(tool);
85 + };
86 }
87 +```
88
39 -export class YourToolset extends BaseComposioToolset<ToolCollection, ToolType> {
40 - static FRAMEWORK_NAME = "your-toolset";
41 - private DEFAULT_ENTITY_ID = "default";
42 - readonly FILE_NAME: string = "toolsets/your-toolset/src/index.ts";
89 +## Creating a New Toolset
90
44 - _wrapTool = (tool: Tool): ToolType => {
45 - // Implement tool wrapping logic
46 - return tool as ToolType;
47 - }
91 +To create a new toolset, you can use the provided script:
92
49 - getTools = async (query?: ToolListParams): Promise<ToolCollection> => {
50 - // Implement tool collection logic
51 - return [];
52 - }
53 -}
93 +```bash
94 +# Create a non-agentic toolset (default)
95 +pnpm run create-toolset <toolset-name>
96 +
97 +# Create an agentic toolset
98 +pnpm run create-toolset <toolset-name> --agentic
99 +```
100 +
101 +This will create a new toolset with the following structure:
102 +
103 +```
104 +<toolset-name>/
105 +├── src/
106 +│ └── index.ts # Toolset implementation
107 +├── package.json # Package configuration
108 +├── tsconfig.json # TypeScript configuration
109 +├── tsup.config.ts # Build configuration
110 +└── README.md # Toolset documentation
111 ```
112
113 ### Required Methods
114
58 -1. `_wrapTool`: This method is responsible for wrapping a tool in the toolset's specific format.
115 +1. `wrapTool`: This method is responsible for wrapping a tool in the toolset's specific format.
116 2. `getTools`: This method retrieves all available tools from the Composio API.
117 +3. `getToolBySlug`: This method retrieves a specific tool by its slug.
118
119 ### Configuration
120
@@ -81,44 +139,55 @@ pnpm build
139 2. **Error Handling**: Implement proper error handling in your tool methods
140 3. **Documentation**: Document your tools and their parameters clearly
141 4. **Testing**: Write unit tests for your toolset functionality
142 +5. **Modifier Support**:
143 + - For non-agentic toolsets, implement schema modifiers to transform tool schemas
144 + - For agentic toolsets, implement full modifier support including execution and custom modifiers
145
146 ## Example Implementation
147
87 -Here's a simple example of implementing a toolset:
148 +Here's a simple example of implementing a non-agentic toolset:
149
150 ```typescript
151 interface MyToolType {
91 - name: string;
92 - description: string;
93 - execute: (params: any) => Promise<any>;
152 + name: string;
153 + description: string;
154 + execute: (params: any) => Promise<any>;
155 }
156
157 interface MyToolCollection {
97 - [key: string]: MyToolType;
158 + [key: string]: MyToolType;
159 }
160
100 -export class MyToolset extends BaseComposioToolset<MyToolCollection, MyToolType> {
101 - static FRAMEWORK_NAME = "my-toolset";
102 - readonly FILE_NAME:string = "toolsets/MyToolset/src/index.ts"
103 -
104 - _wrapTool = (tool: Tool): MyToolType => {
105 - return {
106 - name: tool.name,
107 - description: tool.description,
108 - execute: async (params) => {
109 - // Implement tool execution logic
110 - return await this.executeTool(tool, params);
111 - }
112 - };
113 - }
114 -
115 - getTools = async (query?: ToolListParams): Promise<MyToolCollection> => {
116 - const tools = await this.listTools(query);
117 - return tools.reduce((acc, tool) => {
118 - acc[tool.name] = this._wrapTool(tool);
119 - return acc;
120 - }, {} as MyToolCollection);
121 - }
161 +export class MyNonAgenticToolset extends BaseNonAgenticToolset<MyToolCollection, MyToolType> {
162 + static FRAMEWORK_NAME = 'my-toolset';
163 + readonly FILE_NAME: string = 'toolsets/my-toolset/src/index.ts';
164 +
165 + wrapTool = (tool: Tool): MyToolType => {
166 + return {
167 + name: tool.name,
168 + description: tool.description,
169 + execute: async params => {
170 + // Implement tool execution logic
171 + return await this.getComposio().tools.execute(tool.slug, params);
172 + },
173 + };
174 + };
175 +
176 + getTools = async (
177 + params?: ToolListParams,
178 + modifiers?: SchemaModifiersParams
179 + ): Promise<MyToolCollection> => {
180 + const tools = await this.getComposio().tools.getTools(params, modifiers?.schema);
181 + return tools.reduce((acc, tool) => {
182 + acc[tool.slug] = this.wrapTool(tool);
183 + return acc;
184 + }, {} as MyToolCollection);
185 + };
186 +
187 + getToolBySlug = async (slug: string, modifiers?: SchemaModifiersParams): Promise<MyToolType> => {
188 + const tool = await this.getComposio().tools.getToolBySlug(slug, modifiers?.schema);
189 + return this.wrapTool(tool);
190 + };
191 }
192 ```
193
@@ -130,3 +199,4 @@ When contributing a new toolset:
199 2. Include proper documentation
200 3. Add tests for your implementation
201 4. Update this README if necessary
202 +5. Choose the appropriate base class (agentic or non-agentic) based on your toolset's needs
scripts/create-toolset.sh
+95 -11
@@ -3,7 +3,7 @@
3 # Check if toolset name is provided
4 if [ -z "$1" ]; then
5 echo "Please provide a toolset name"
6 - echo "Usage: npm run create-toolset <toolset-name>"
6 + echo "Usage: npm run create-toolset <toolset-name> [--agentic]"
7 exit 1
8 fi
9
@@ -11,6 +11,12 @@ TOOLSET_NAME=$1
11 TOOLSET_PATH="packages/toolsets/$TOOLSET_NAME"
12 CAPITAL_TOOLSET_NAME="$(tr '[:lower:]' '[:upper:]' <<< ${TOOLSET_NAME:0:1})${TOOLSET_NAME:1}"
13
14 +# Check if toolset should be agentic
15 +IS_AGENTIC=false
16 +if [ "$2" = "--agentic" ]; then
17 + IS_AGENTIC=true
18 +fi
19 +
20 # Create directory structure
21 mkdir -p "$TOOLSET_PATH/src"
22
@@ -19,7 +25,7 @@ cat > "$TOOLSET_PATH/package.json" << EOL
25 {
26 "name": "@composio/${TOOLSET_NAME}-toolset",
27 "version": "1.0.0",
22 - "description": "",
28 + "description": "${IS_AGENTIC:+Agentic }Toolset for ${TOOLSET_NAME}",
29 "main": "src/index.ts",
30 "type": "module",
31 "publishConfig": {
@@ -38,7 +44,7 @@ cat > "$TOOLSET_PATH/package.json" << EOL
44 "build": "tsup",
45 "test": "echo \\"Error: no test specified\\" && exit 1"
46 },
41 - "keywords": [],
47 + "keywords": ["composio", "toolset", "${TOOLSET_NAME}"],
48 "author": "",
49 "license": "ISC",
50 "packageManager": "pnpm@10.8.0",
@@ -87,8 +93,9 @@ EOL
93
94 # Create src/index.ts
95 cat > "$TOOLSET_PATH/src/index.ts" << EOL
90 -import { BaseComposioToolset } from "@composio/core";
96 +import { ${IS_AGENTIC:+BaseAgenticToolset}${!IS_AGENTIC:+BaseNonAgenticToolset} } from "@composio/core";
97 import type { Tool, ToolListParams } from "@composio/core";
98 +import type { ${IS_AGENTIC:+ModifiersParams}${!IS_AGENTIC:+SchemaModifiersParams} } from "@composio/core";
99
100 interface ToolType {
101 // Add your tool type here
@@ -98,37 +105,114 @@ interface ToolCollection {
105 // Add your tool collection here
106 }
107
101 -export class ${CAPITAL_TOOLSET_NAME}Toolset extends BaseComposioToolset<ToolCollection, ToolType> {
108 +/**
109 + * ${CAPITAL_TOOLSET_NAME} Toolset
110 + * ${IS_AGENTIC:+This is an agentic toolset that supports full modifier capabilities.}
111 +${!IS_AGENTIC:+This is a non-agentic toolset that only supports schema modifiers.}
112 + *
113 + * @example
114 + * \`\`\`typescript
115 + * import { Composio } from "@composio/core";
116 + * import { ${CAPITAL_TOOLSET_NAME}Toolset } from "@composio/${TOOLSET_NAME}-toolset";
117 + *
118 + * const composio = new Composio({
119 + * apiKey: "your-api-key",
120 + * toolset: new ${CAPITAL_TOOLSET_NAME}Toolset()
121 + * });
122 + * \`\`\`
123 + */
124 +export class ${CAPITAL_TOOLSET_NAME}Toolset extends ${IS_AGENTIC:+BaseAgenticToolset}${!IS_AGENTIC:+BaseNonAgenticToolset}<ToolCollection, ToolType> {
125 static FRAMEWORK_NAME = "${TOOLSET_NAME}";
103 - private DEFAULT_ENTITY_ID = "default";
126 readonly FILE_NAME: string = "toolsets/${TOOLSET_NAME}/src/index.ts";
127
128 /**
107 - * Abstract method to wrap a tool in the toolset.
129 + * Wraps a tool in the toolset format.
130 * This method is implemented by the toolset.
131 * @param tool - The tool to wrap.
132 * @returns The wrapped tool.
133 */
112 - _wrapTool = (tool: Tool): ToolType => {
134 + wrapTool = (tool: Tool): ToolType => {
135 return tool as ToolType;
136 }
137
138 /**
139 * Get all the tools from the Composio API
118 - * @param query - The query to get the tools
140 + * @param params - The query parameters to get the tools
141 + * @param modifiers - ${IS_AGENTIC:+Full modifiers to apply to the tools}${!IS_AGENTIC:+Schema modifiers to apply to the tools}
142 * @returns The tools
143 */
121 - getTools = async (query?: ToolListParams): Promise<ToolCollection> => {
144 + getTools = async (
145 + params?: ToolListParams,
146 + modifiers?: ${IS_AGENTIC:+ModifiersParams}${!IS_AGENTIC:+SchemaModifiersParams}
147 + ): Promise<ToolCollection> => {
148 return [];
149 }
150 +
151 + /**
152 + * Get a tool from the Composio API by its slug
153 + * @param slug - The slug of the tool to get
154 + * @param modifiers - ${IS_AGENTIC:+Full modifiers to apply to the tool}${!IS_AGENTIC:+Schema modifiers to apply to the tool}
155 + * @returns The tool
156 + */
157 + getToolBySlug = async (
158 + slug: string,
159 + modifiers?: ${IS_AGENTIC:+ModifiersParams}${!IS_AGENTIC:+SchemaModifiersParams}
160 + ): Promise<ToolType> => {
161 + const tool = await this.getComposio().tools.getToolBySlug(slug, modifiers?.schema);
162 + return this.wrapTool(tool);
163 + }
164 }
165 EOL
166
167 +# Create README.md
168 +cat > "$TOOLSET_PATH/README.md" << EOL
169 +# @composio/${TOOLSET_NAME}-toolset
170 +
171 +${IS_AGENTIC:+Agentic }Toolset for ${TOOLSET_NAME} in Composio SDK.
172 +
173 +## Installation
174 +
175 +\`\`\`bash
176 +pnpm add @composio/${TOOLSET_NAME}-toolset
177 +\`\`\`
178 +
179 +## Usage
180 +
181 +\`\`\`typescript
182 +import { Composio } from "@composio/core";
183 +import { ${CAPITAL_TOOLSET_NAME}Toolset } from "@composio/${TOOLSET_NAME}-toolset";
184 +
185 +const composio = new Composio({
186 + apiKey: "your-api-key",
187 + toolset: new ${CAPITAL_TOOLSET_NAME}Toolset()
188 +});
189 +
190 +// Get all tools
191 +const tools = await composio.getTools();
192 +
193 +// Get a specific tool by slug
194 +const tool = await composio.getToolBySlug("tool-slug");
195 +\`\`\`
196 +
197 +## Features
198 +
199 +${IS_AGENTIC:+This is an agentic toolset that supports full modifier capabilities, including:
200 +- Tool execution modifiers
201 +- Schema modifiers
202 +- Custom modifiers
203 +
204 +}${!IS_AGENTIC:+This is a non-agentic toolset that supports schema modifiers for transforming tool schemas.}
205 +
206 +## License
207 +
208 +ISC
209 +EOL
210 +
211 # Make the script executable
212 chmod +x "$TOOLSET_PATH"
213
214 # Install dependencies using pnpm
215 cd "$TOOLSET_PATH" && pnpm install
216
133 -echo "✨ Created new toolset at $TOOLSET_PATH"
217 +echo "✨ Created new ${IS_AGENTIC:+agentic }toolset at $TOOLSET_PATH"
218 echo "✨ Dependencies installed successfully"
\ No newline at end of file