@devries-cameron20 / composio-1 / commits / 6220b16d5
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.

Add docs

haxzie committed Apr 18, 2025 at 12:58 UTC 6220b16d5db9c19a07d2caa9e001b3ca45015afe
3 files changed +277 -5
README.md
+19 -5
@@ -13,16 +13,13 @@ The core Composio SDK which allows users to interact with the Composio Platform.
13
14
15 ## Usage
16 -To use the composio tools with your Provider, please install the recommended packages along with `@composio/core`.
17 -
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";
20 -import { OpenAIToolset } from "@composio/openai-toolset";
21 -
19
20 +// By default composio ships with OpenAI toolset
21 const composio = new Composio({
22 apiKey: process.env.COMPOSIO_API_KEY,
25 - toolset: new OpenAIToolset(),
23 });
24
25 const tool = await composio.getTool("HACKERNEWS_SEARCH_POSTS");
@@ -31,6 +28,23 @@ console.log(tool);
28
29 For more examples, please check the `/examples` directory.
30
31 +## Using with a different toolset
32 +To use a different toolset, please install the recommended toolset packages.
33 +
34 +```
35 +import { Composio } from "@composio/core";
36 +import { VercelToolset } from "@composio/vercel"
37 +
38 +const composio = new Composio({
39 + apiKey: process.env.COMPOSIO_API_KEY,
40 + toolset: new VercelToolset();
41 +});
42 +
43 +const tool = await composio.getTool("HACKERNEWS_SEARCH_POSTS");
44 +console.log(tool);
45 +```
46 +
47 +
48 ## 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.
50
packages/core/README.md new
+126
@@ -0,0 +1,126 @@
1 +# @composio/core
2 +
3 +The core package of Composio SDK, providing essential functionality for building and managing AI-powered tools and toolsets.
4 +
5 +## Features
6 +
7 +### 1. Core Functionality
8 +- **Composio Client Integration**: Seamless integration with Composio API
9 +- **Tool Management**: Create, manage, and execute tools
10 +- **Toolkit Support**: Organize tools into toolsets
11 +- **Authentication & Authorization**: Built-in auth configuration and management
12 +- **Connected Accounts**: Manage multiple account connections
13 +
14 +### 2. Toolsets
15 +- **Default OpenAI Toolset**: Ships with built-in OpenAI integration
16 +- **Extensible Base Toolset**: Create custom toolsets by extending `BaseComposioToolset`
17 +- **Tool Wrapping**: Standardized tool wrapping and execution
18 +
19 +### 3. Advanced Features
20 +- **Telemetry**: Built-in telemetry for monitoring and debugging
21 +- **Logging**: Configurable logging system with multiple levels
22 +- **Environment Management**: Flexible configuration through environment variables
23 +- **Version Management**: Automatic version checking and updates
24 +
25 +## Installation
26 +
27 +```bash
28 +npm install @composio/core
29 +# or
30 +yarn add @composio/core
31 +# or
32 +pnpm add @composio/core
33 +```
34 +
35 +## Quick Start
36 +
37 +```typescript
38 +import { Composio } from '@composio/core';
39 +
40 +// Initialize Composio with default OpenAI toolset
41 +const composio = new Composio({
42 + apiKey: 'your-api-key',
43 + baseURL: 'https://api.composio.dev', // optional
44 +});
45 +
46 +// Get available tools
47 +const tools = await composio.getTools();
48 +
49 +// Execute a specific tool
50 +const result = await composio.tools.execute('tool-slug', {
51 + // tool parameters
52 +});
53 +```
54 +
55 +## Configuration
56 +
57 +The Composio constructor accepts the following configuration options:
58 +
59 +```typescript
60 +interface ComposioConfig {
61 + apiKey?: string; // Your Composio API key
62 + baseURL?: string; // Custom API base URL (optional)
63 + allowTracking?: boolean; // Enable/disable telemetry (default: true)
64 + allowTracing?: boolean; // Enable/disable tracing (default: true)
65 + toolset?: TToolset; // Custom toolset (default: OpenAIToolset)
66 + userId?: string; // Custom user ID
67 + connectedAccountIds?: Record<string, string>; // Connected account mappings
68 + telemetryTransport?: BaseTelemetryTransport; // Custom telemetry transport
69 +}
70 +```
71 +
72 +## Toolsets
73 +
74 +### Default OpenAI Toolset
75 +
76 +The core package ships with OpenAI toolset by default. For more information about the OpenAI toolset and its capabilities, check out the [OpenAI Toolset Documentation](./toolset/OpenAIToolset.md).
77 +
78 +### Creating Custom Toolsets
79 +
80 +You can create custom toolsets by extending the `BaseComposioToolset`:
81 +
82 +```typescript
83 +import { BaseComposioToolset, Tool } from '@composio/core';
84 +
85 +interface CustomTool {
86 + name: string;
87 + // ... custom tool properties
88 +}
89 +
90 +class CustomToolset extends BaseComposioToolset<CustomTool[], CustomTool> {
91 + readonly FILE_NAME = 'custom/toolset.ts';
92 +
93 + _wrapTool = (tool: Tool): CustomTool => {
94 + // Implement tool wrapping logic
95 + return {
96 + name: tool.name,
97 + // ... map other properties
98 + };
99 + };
100 +
101 + async getTools() {
102 + const tools = await this.client?.tools.list();
103 + return tools?.items.map(tool => this._wrapTool(tool)) ?? [];
104 + }
105 +}
106 +```
107 +
108 +## Environment Variables
109 +
110 +- `COMPOSIO_API_KEY`: Your Composio API key
111 +- `COMPOSIO_BASE_URL`: Custom API base URL
112 +- `COMPOSIO_LOGGING_LEVEL`: Logging level (silent, error, warn, info, debug)
113 +- `DEVELOPMENT`: Development mode flag
114 +- `CI`: CI environment flag
115 +
116 +## Contributing
117 +
118 +We welcome contributions! Please see our [Contributing Guide](../../CONTRIBUTING.md) for more details.
119 +
120 +## License
121 +
122 +ISC License
123 +
124 +## Support
125 +
126 +For support, please visit our [Documentation](https://docs.composio.dev) or join our [Discord Community](https://discord.gg/composio).
packages/toolsets/README.md new
+132
@@ -0,0 +1,132 @@
1 +# Composio Toolsets
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
6 +
7 +To create a new toolset, you can use the provided script:
8 +
9 +```bash
10 +npm run create-toolset <toolset-name>
11 +```
12 +
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
21 +```
22 +
23 +## Toolset Implementation
24 +
25 +Each toolset extends the `BaseComposioToolset` class from `@composio/core`. Here's a basic structure of a toolset:
26 +
27 +```typescript
28 +import { BaseComposioToolset } from "@composio/core";
29 +import type { Tool, ToolListParams } from "@composio/core";
30 +
31 +interface ToolType {
32 + // Define your tool type here
33 +}
34 +
35 +interface ToolCollection {
36 + // Define your tool collection here
37 +}
38 +
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";
43 +
44 + _wrapTool = (tool: Tool): ToolType => {
45 + // Implement tool wrapping logic
46 + return tool as ToolType;
47 + }
48 +
49 + getTools = async (query?: ToolListParams): Promise<ToolCollection> => {
50 + // Implement tool collection logic
51 + return [];
52 + }
53 +}
54 +```
55 +
56 +### Required Methods
57 +
58 +1. `_wrapTool`: This method is responsible for wrapping a tool in the toolset's specific format.
59 +2. `getTools`: This method retrieves all available tools from the Composio API.
60 +
61 +### Configuration
62 +
63 +Each toolset comes with the following configuration files:
64 +
65 +- `package.json`: Contains dependencies and build scripts
66 +- `tsconfig.json`: TypeScript configuration
67 +- `tsup.config.ts`: Build configuration for the toolset
68 +
69 +## Building and Testing
70 +
71 +To build your toolset:
72 +
73 +```bash
74 +cd packages/toolsets/<toolset-name>
75 +pnpm build
76 +```
77 +
78 +## Best Practices
79 +
80 +1. **Type Safety**: Always define proper TypeScript interfaces for your tools and collections
81 +2. **Error Handling**: Implement proper error handling in your tool methods
82 +3. **Documentation**: Document your tools and their parameters clearly
83 +4. **Testing**: Write unit tests for your toolset functionality
84 +
85 +## Example Implementation
86 +
87 +Here's a simple example of implementing a toolset:
88 +
89 +```typescript
90 +interface MyToolType {
91 + name: string;
92 + description: string;
93 + execute: (params: any) => Promise<any>;
94 +}
95 +
96 +interface MyToolCollection {
97 + [key: string]: MyToolType;
98 +}
99 +
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 + }
122 +}
123 +```
124 +
125 +## Contributing
126 +
127 +When contributing a new toolset:
128 +
129 +1. Follow the existing code style and patterns
130 +2. Include proper documentation
131 +3. Add tests for your implementation
132 +4. Update this README if necessary