@devries-cameron20 / composio Mirror · read-only / commits / 86760caf4
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 readme.md

haxzie committed May 15, 2025 at 16:57 UTC 86760caf47734ca8e0bfea2b8fd1469f2c8e7d59
1 file changed +146 -60
packages/core/README.md
+146 -60
@@ -1,26 +1,15 @@
1 # @composio/core
2
3 -The core package of Composio SDK, providing essential functionality for building and managing AI-powered tools and toolsets.
3 +The core Composio SDK which allows users to interact with the Composio Platform. It provides a powerful and flexible way to manage and execute tools, handle authentication, and integrate with various platforms and frameworks.
4
5 -## Features
5 +## Core 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
7 +- **Tools**: Manage and execute tools within the Composio ecosystem. Includes functionality to list, retrieve, and execute tools.
8 +- **Toolkits**: Organize and manage collections of tools for specific use cases.
9 +- **Triggers**: Create and manage event triggers that can execute tools based on specific conditions.
10 +- **AuthConfigs**: Configure authentication providers and settings.
11 +- **ConnectedAccounts**: Manage third-party service connections.
12 +- **ActionExecution**: Track and manage the execution of actions within the platform.
13
14 ## Installation
15
@@ -32,23 +21,27 @@ yarn add @composio/core
21 pnpm add @composio/core
22 ```
23
35 -## Quick Start
24 +## Getting Started
25 +
26 +### Basic Usage with OpenAI Toolset
27
28 ```typescript
29 import { Composio } from '@composio/core';
30 +import { OpenAIToolset } from '@composio/openai-toolset';
31
40 -// Initialize Composio with default OpenAI toolset
32 const composio = new Composio({
42 - apiKey: 'your-api-key',
43 - baseURL: 'https://api.composio.dev', // optional
33 + apiKey: process.env.COMPOSIO_API_KEY,
34 + // OpenAIToolset is the default, so this is optional
35 + toolset: new OpenAIToolset(),
36 });
37
46 -// Get available tools
47 -const tools = await composio.getTools();
38 +// Fetch a single tool
39 +const searchTool = await composio.tools.get('user123', 'HACKERNEWS_SEARCH_POSTS');
40
49 -// Execute a specific tool
50 -const result = await composio.tools.execute('tool-slug', {
51 - // tool parameters
41 +// Fetch multiple tools
42 +const tools = await composio.tools.get('user123', {
43 + category: 'search',
44 + limit: 10,
45 });
46 ```
47
@@ -58,53 +51,146 @@ The Composio constructor accepts the following configuration options:
51
52 ```typescript
53 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
54 + apiKey?: string; // Your Composio API key
55 + baseURL?: string; // Custom API base URL (optional)
56 + allowTracking?: boolean; // Enable/disable telemetry (default: true)
57 + allowTracing?: boolean; // Enable/disable tracing (default: true)
58 + toolset?: TToolset; // Custom toolset (default: OpenAIToolset)
59 telemetryTransport?: BaseTelemetryTransport; // Custom telemetry transport
60 }
61 ```
62
72 -## Toolsets
63 +## Modifiers
64 +
65 +Composio SDK supports powerful modifiers to transform tool schemas and execution behavior.
66 +
67 +### Schema Modifiers
68 +
69 +Schema modifiers allow you to transform tool schemas before they are used:
70 +
71 +```typescript
72 +const tool = await composio.tools.get('user123', 'HACKERNEWS_SEARCH_POSTS', {
73 + modifyToolSchema: (toolSlug: string, tool: Tool) => ({
74 + ...tool,
75 + description: 'Enhanced HackerNews search with additional features',
76 + inputParameters: {
77 + ...tool.inputParameters,
78 + limit: {
79 + type: 'number',
80 + description: 'Maximum number of posts to return',
81 + default: 10,
82 + },
83 + },
84 + }),
85 +});
86 +```
87 +
88 +### Execution Modifiers
89
74 -### Default OpenAI Toolset
90 +For agentic toolsets (like Vercel AI and Langchain), you can also modify tool execution behavior:
91
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).
92 +```typescript
93 +const tool = await composio.tools.get('user123', 'HACKERNEWS_SEARCH_POSTS', {
94 + // Transform input before execution
95 + beforeToolExecute: (toolSlug: string, params: ToolExecuteParams) => ({
96 + ...params,
97 + arguments: {
98 + ...params.arguments,
99 + limit: Math.min((params.arguments?.limit as number) || 10, 100),
100 + },
101 + }),
102 +
103 + // Transform output after execution
104 + afterToolExecute: (toolSlug: string, response: ToolExecuteResponse) => ({
105 + ...response,
106 + data: {
107 + ...response.data,
108 + posts: (response.data?.posts as any[]).map(post => ({
109 + ...post,
110 + url: post.url || `https://news.ycombinator.com/item?id=${post.id}`,
111 + })),
112 + },
113 + }),
114 +});
115 +```
116
78 -### Creating Custom Toolsets
117 +## Connected Accounts
118
80 -You can create custom toolsets by extending the `BaseComposioToolset`:
119 +Composio SDK provides a powerful way to manage third-party service connections through Connected Accounts. This feature allows you to authenticate with various services and maintain those connections.
120 +
121 +### Creating a Connected Account
122
123 ```typescript
83 -import { BaseComposioToolset, Tool } from '@composio/core';
124 +import { Composio } from '@composio/core';
125
85 -interface CustomTool {
86 - name: string;
87 - // ... custom tool properties
88 -}
126 +const composio = new Composio({
127 + apiKey: process.env.COMPOSIO_API_KEY,
128 +});
129
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)) ?? [];
130 +// Create a connected account
131 +const connectionRequest = await composio.createConnectedAccount(
132 + 'user123', // userId
133 + 'HACKERNEWS', // authConfigId
134 + {
135 + redirectUrl: 'https://your-app.com/callback',
136 + data: {
137 + // Additional data for the connection
138 + scope: ['read', 'write'],
139 + },
140 }
105 -}
141 +);
142 +
143 +// Wait for the connection to be established
144 +// Default timeout is 60 seconds
145 +const connectedAccount = await connectionRequest.waitForConnection();
146 +```
147 +
148 +### Managing Connected Accounts
149 +
150 +```typescript
151 +// List all connected accounts
152 +const accounts = await composio.connectedAccounts.list({
153 + userId: 'user123',
154 +});
155 +
156 +// Get a specific connected account
157 +const account = await composio.connectedAccounts.get('account_id');
158 +
159 +// Enable/Disable a connected account
160 +await composio.connectedAccounts.enable('account_id');
161 +await composio.connectedAccounts.disable('account_id');
162 +
163 +// Refresh credentials
164 +await composio.connectedAccounts.refresh('account_id');
165 +
166 +// Delete a connected account
167 +await composio.connectedAccounts.delete('account_id');
168 ```
169
170 +### Connection Statuses
171 +
172 +Connected accounts can have the following statuses:
173 +
174 +- `ACTIVE`: Connection is established and working
175 +- `INACTIVE`: Connection is temporarily disabled
176 +- `PENDING`: Connection is being processed
177 +- `INITIATED`: Connection request has started
178 +- `EXPIRED`: Connection credentials have expired
179 +- `FAILED`: Connection attempt failed
180 +
181 +### Authentication Schemes
182 +
183 +Composio supports various authentication schemes:
184 +
185 +- OAuth2
186 +- OAuth1
187 +- OAuth1a
188 +- API Key
189 +- Basic Auth
190 +- Bearer Token
191 +- Google Service Account
192 +- And more...
193 +
194 ## Environment Variables
195
196 - `COMPOSIO_API_KEY`: Your Composio API key