@composio/core 0.1.3-alpha.0 → 0.1.4-alpha.0

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,26 +1,15 @@
1
1
  # @composio/core
2
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
4
 
5
- ## Features
5
+ ## Core Features
6
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.
24
13
 
25
14
  ## Installation
26
15
 
@@ -32,23 +21,27 @@ yarn add @composio/core
32
21
  pnpm add @composio/core
33
22
  ```
34
23
 
35
- ## Quick Start
24
+ ## Getting Started
25
+
26
+ ### Basic Usage with OpenAI Toolset
36
27
 
37
28
  ```typescript
38
29
  import { Composio } from '@composio/core';
30
+ import { OpenAIToolset } from '@composio/openai-toolset';
39
31
 
40
- // Initialize Composio with default OpenAI toolset
41
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(),
44
36
  });
45
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');
48
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,
52
45
  });
53
46
  ```
54
47
 
@@ -58,53 +51,146 @@ The Composio constructor accepts the following configuration options:
58
51
 
59
52
  ```typescript
60
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)
68
59
  telemetryTransport?: BaseTelemetryTransport; // Custom telemetry transport
69
60
  }
70
61
  ```
71
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
73
89
 
74
- ### Default OpenAI Toolset
90
+ For agentic toolsets (like Vercel AI and Langchain), you can also modify tool execution behavior:
75
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
+ ```
77
116
 
78
- ### Creating Custom Toolsets
117
+ ## Connected Accounts
79
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
81
122
 
82
123
  ```typescript
83
- import { BaseComposioToolset, Tool } from '@composio/core';
124
+ import { Composio } from '@composio/core';
84
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
+ });
89
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
+ },
104
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');
106
168
  ```
107
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
+
108
194
  ## Environment Variables
109
195
 
110
196
  - `COMPOSIO_API_KEY`: Your Composio API key
package/dist/index.cjs CHANGED
@@ -1850,7 +1850,7 @@ var OpenAIToolset = class extends BaseNonAgenticToolset {
1850
1850
  };
1851
1851
 
1852
1852
  // package.json
1853
- var version = "0.1.1-alpha.0";
1853
+ var version = "0.1.3-alpha.0";
1854
1854
 
1855
1855
  // src/utils/uuid.ts
1856
1856
  var import_uuid = require("uuid");
package/dist/index.js CHANGED
@@ -1814,7 +1814,7 @@ var OpenAIToolset = class extends BaseNonAgenticToolset {
1814
1814
  };
1815
1815
 
1816
1816
  // package.json
1817
- var version = "0.1.1-alpha.0";
1817
+ var version = "0.1.3-alpha.0";
1818
1818
 
1819
1819
  // src/utils/uuid.ts
1820
1820
  import { v4 as uuidv4 } from "uuid";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@composio/core",
3
- "version": "0.1.3-alpha.0",
3
+ "version": "0.1.4-alpha.0",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",
@@ -43,5 +43,5 @@
43
43
  "zod": "^3.24.2",
44
44
  "zod-to-json-schema": "^3.24.5"
45
45
  },
46
- "gitHead": "84ce22190d205c3846bc29fd63b88462e0eaa3bb"
46
+ "gitHead": "7f90a422e9451b6147a3bc77ca7fe381905d6a57"
47
47
  }