Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
TypeScript agentic-aiagentsaiai-agentsaiagentsdeveloper-toolsfunction-callinggpt-4javascriptjsllmllmopsmcppythonremote-mcp-serverssetypescript
Add docs
haxzie6220b16d5db9
diff --git a/README.md b/README.mdindex 62e2ffeef..37996a181 100644--- a/README.md+++ b/README.md@@ -13,16 +13,13 @@ The core Composio SDK which allows users to interact with the Composio Platform.## Usage-To use the composio tools with your Provider, please install the recommended packages along with `@composio/core`.-+@composio/core ships with openai toolset by default. You can directly use the tools from composio in `openai` methods.```import { Composio } from "@composio/core";-import { OpenAIToolset } from "@composio/openai-toolset";-+// By default composio ships with OpenAI toolsetconst composio = new Composio({apiKey: process.env.COMPOSIO_API_KEY,- toolset: new OpenAIToolset(),});const tool = await composio.getTool("HACKERNEWS_SEARCH_POSTS");@@ -31,6 +28,23 @@ console.log(tool);For more examples, please check the `/examples` directory.+## Using with a different toolset+To use a different toolset, please install the recommended toolset packages.++```+import { Composio } from "@composio/core";+import { VercelToolset } from "@composio/vercel"++const composio = new Composio({+ apiKey: process.env.COMPOSIO_API_KEY,+ toolset: new VercelToolset();+});++const tool = await composio.getTool("HACKERNEWS_SEARCH_POSTS");+console.log(tool);+```++## Creating a new toolsetTo create a new Toolset, you need to extend the `BaseComposioToolset<YourToolType>` and implement the `_wrapTool` method to return the tool type of your choice.diff --git a/packages/core/README.md b/packages/core/README.mdnew file mode 100644index 000000000..4a36c893c--- /dev/null+++ b/packages/core/README.md@@ -0,0 +1,126 @@+# @composio/core++The core package of Composio SDK, providing essential functionality for building and managing AI-powered tools and toolsets.++## Features++### 1. Core Functionality+- **Composio Client Integration**: Seamless integration with Composio API+- **Tool Management**: Create, manage, and execute tools+- **Toolkit Support**: Organize tools into toolsets+- **Authentication & Authorization**: Built-in auth configuration and management+- **Connected Accounts**: Manage multiple account connections++### 2. Toolsets+- **Default OpenAI Toolset**: Ships with built-in OpenAI integration+- **Extensible Base Toolset**: Create custom toolsets by extending `BaseComposioToolset`+- **Tool Wrapping**: Standardized tool wrapping and execution++### 3. Advanced Features+- **Telemetry**: Built-in telemetry for monitoring and debugging+- **Logging**: Configurable logging system with multiple levels+- **Environment Management**: Flexible configuration through environment variables+- **Version Management**: Automatic version checking and updates++## Installation++```bash+npm install @composio/core+# or+yarn add @composio/core+# or+pnpm add @composio/core+```++## Quick Start++```typescript+import { Composio } from '@composio/core';++// Initialize Composio with default OpenAI toolset+const composio = new Composio({+ apiKey: 'your-api-key',+ baseURL: 'https://api.composio.dev', // optional+});++// Get available tools+const tools = await composio.getTools();++// Execute a specific tool+const result = await composio.tools.execute('tool-slug', {+ // tool parameters+});+```++## Configuration++The Composio constructor accepts the following configuration options:++```typescript+interface ComposioConfig {+ apiKey?: string; // Your Composio API key+ baseURL?: string; // Custom API base URL (optional)+ allowTracking?: boolean; // Enable/disable telemetry (default: true)+ allowTracing?: boolean; // Enable/disable tracing (default: true)+ toolset?: TToolset; // Custom toolset (default: OpenAIToolset)+ userId?: string; // Custom user ID+ connectedAccountIds?: Record<string, string>; // Connected account mappings+ telemetryTransport?: BaseTelemetryTransport; // Custom telemetry transport+}+```++## Toolsets++### Default OpenAI Toolset++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).++### Creating Custom Toolsets++You can create custom toolsets by extending the `BaseComposioToolset`:++```typescript+import { BaseComposioToolset, Tool } from '@composio/core';++interface CustomTool {+ name: string;+ // ... custom tool properties+}++class CustomToolset extends BaseComposioToolset<CustomTool[], CustomTool> {+ readonly FILE_NAME = 'custom/toolset.ts';++ _wrapTool = (tool: Tool): CustomTool => {+ // Implement tool wrapping logic+ return {+ name: tool.name,+ // ... map other properties+ };+ };++ async getTools() {+ const tools = await this.client?.tools.list();+ return tools?.items.map(tool => this._wrapTool(tool)) ?? [];+ }+}+```++## Environment Variables++- `COMPOSIO_API_KEY`: Your Composio API key+- `COMPOSIO_BASE_URL`: Custom API base URL+- `COMPOSIO_LOGGING_LEVEL`: Logging level (silent, error, warn, info, debug)+- `DEVELOPMENT`: Development mode flag+- `CI`: CI environment flag++## Contributing++We welcome contributions! Please see our [Contributing Guide](../../CONTRIBUTING.md) for more details.++## License++ISC License++## Support++For support, please visit our [Documentation](https://docs.composio.dev) or join our [Discord Community](https://discord.gg/composio).diff --git a/packages/toolsets/README.md b/packages/toolsets/README.mdnew file mode 100644index 000000000..a03286829--- /dev/null+++ b/packages/toolsets/README.md@@ -0,0 +1,132 @@+# Composio Toolsets++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.++## Creating a New Toolset++To create a new toolset, you can use the provided script:++```bash+npm run create-toolset <toolset-name>+```++This will create a new toolset with the following structure:+```+<toolset-name>/+├── src/+│ └── index.ts+├── package.json+├── tsconfig.json+└── tsup.config.ts+```++## Toolset Implementation++Each toolset extends the `BaseComposioToolset` class from `@composio/core`. Here's a basic structure of a toolset:++```typescript+import { BaseComposioToolset } from "@composio/core";+import type { Tool, ToolListParams } from "@composio/core";++interface ToolType {+ // Define your tool type here+}++interface ToolCollection {+ // Define your tool collection here+}++export class YourToolset extends BaseComposioToolset<ToolCollection, ToolType> {+ static FRAMEWORK_NAME = "your-toolset";+ private DEFAULT_ENTITY_ID = "default";+ readonly FILE_NAME: string = "toolsets/your-toolset/src/index.ts";++ _wrapTool = (tool: Tool): ToolType => {+ // Implement tool wrapping logic+ return tool as ToolType;+ }++ getTools = async (query?: ToolListParams): Promise<ToolCollection> => {+ // Implement tool collection logic+ return [];+ }+}+```++### Required Methods++1. `_wrapTool`: This method is responsible for wrapping a tool in the toolset's specific format.+2. `getTools`: This method retrieves all available tools from the Composio API.++### Configuration++Each toolset comes with the following configuration files:++- `package.json`: Contains dependencies and build scripts+- `tsconfig.json`: TypeScript configuration+- `tsup.config.ts`: Build configuration for the toolset++## Building and Testing++To build your toolset:++```bash+cd packages/toolsets/<toolset-name>+pnpm build+```++## Best Practices++1. **Type Safety**: Always define proper TypeScript interfaces for your tools and collections+2. **Error Handling**: Implement proper error handling in your tool methods+3. **Documentation**: Document your tools and their parameters clearly+4. **Testing**: Write unit tests for your toolset functionality++## Example Implementation++Here's a simple example of implementing a toolset:++```typescript+interface MyToolType {+ name: string;+ description: string;+ execute: (params: any) => Promise<any>;+}++interface MyToolCollection {+ [key: string]: MyToolType;+}++export class MyToolset extends BaseComposioToolset<MyToolCollection, MyToolType> {+ static FRAMEWORK_NAME = "my-toolset";+ readonly FILE_NAME:string = "toolsets/MyToolset/src/index.ts"++ _wrapTool = (tool: Tool): MyToolType => {+ return {+ name: tool.name,+ description: tool.description,+ execute: async (params) => {+ // Implement tool execution logic+ return await this.executeTool(tool, params);+ }+ };+ }++ getTools = async (query?: ToolListParams): Promise<MyToolCollection> => {+ const tools = await this.listTools(query);+ return tools.reduce((acc, tool) => {+ acc[tool.name] = this._wrapTool(tool);+ return acc;+ }, {} as MyToolCollection);+ }+}+```++## Contributing++When contributing a new toolset:++1. Follow the existing code style and patterns+2. Include proper documentation+3. Add tests for your implementation+4. Update this README if necessary