@devries-cameron20 / composio Mirror · read-only / commits / f65d9c4b9
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 22, 20:45 UTC

Chore: Update TS Docs (#1847)

Musthaq Ahamad committed Aug 14, 2025 at 20:20 UTC f65d9c4b92581886676866ed5e84342f8e38670a
7 files changed +108 -124
CLAUDE.md
+14 -2
@@ -201,11 +201,23 @@ const wrappedTools = provider.wrapTools(tools);
201
202 ### Custom Tool Creation
203 ```typescript
204 +import { z } from 'zod';
205 +
206 const customTool = await composio.tools.createCustomTool({
207 name: 'My Tool',
208 description: 'Tool description',
207 - inputParameters: { /* JSON schema */ },
208 - handler: async (params) => { /* implementation */ }
209 + slug: 'MY_TOOL',
210 + inputParams: z.object({
211 + param: z.string().describe('Parameter description')
212 + }),
213 + execute: async (input) => {
214 + // Implementation
215 + return {
216 + data: { result: input.param },
217 + error: null,
218 + successful: true
219 + };
220 + }
221 });
222 ```
223
ts/README.md
+8 -33
@@ -138,45 +138,20 @@ if (completion.choices[0].message.tool_calls) {
138 ## Creating Custom Tools
139
140 ```typescript
141 +import { z } from 'zod';
142 +
143 // Create a custom tool
144 const customTool = await composio.tools.createCustomTool({
145 name: 'Weather Forecast',
146 description: 'Get the weather forecast for a location',
147 slug: 'WEATHER_FORECAST',
146 - inputParameters: {
147 - type: 'object',
148 - properties: {
149 - location: {
150 - type: 'string',
151 - description: 'The location to get the forecast for',
152 - },
153 - days: {
154 - type: 'integer',
155 - description: 'Number of days for the forecast',
156 - default: 3,
157 - },
158 - },
159 - required: ['location'],
160 - },
161 - outputParameters: {
162 - type: 'object',
163 - properties: {
164 - forecast: {
165 - type: 'array',
166 - items: {
167 - type: 'object',
168 - properties: {
169 - date: { type: 'string' },
170 - temperature: { type: 'number' },
171 - conditions: { type: 'string' },
172 - },
173 - },
174 - },
175 - },
176 - },
177 - handler: async (params, context) => {
148 + inputParams: z.object({
149 + location: z.string().describe('The location to get the forecast for'),
150 + days: z.number().optional().default(3).describe('Number of days for the forecast')
151 + }),
152 + execute: async (input) => {
153 try {
179 - const { location, days = 3 } = params.arguments;
154 + const { location, days = 3 } = input;
155
156 // Your implementation here
157 const forecast = [
ts/docs/advanced/error-handling.md
+8 -16
@@ -177,27 +177,19 @@ try {
177 When creating custom tools, implement proper error handling in your handler function:
178
179 ```typescript
180 +import { z } from 'zod';
181 +
182 const customTool = await composio.tools.createCustomTool({
183 name: 'My Custom Tool',
184 description: 'A custom tool with error handling',
185 slug: 'MY_CUSTOM_TOOL',
184 - inputParameters: {
185 - type: 'object',
186 - properties: {
187 - param1: { type: 'string' },
188 - },
189 - required: ['param1'],
190 - },
191 - outputParameters: {
192 - type: 'object',
193 - properties: {
194 - result: { type: 'string' },
195 - },
196 - },
197 - handler: async (params, context) => {
186 + inputParams: z.object({
187 + param1: z.string().describe('Required parameter')
188 + }),
189 + execute: async (input) => {
190 try {
199 - // Validate input
200 - const { param1 } = params.arguments;
191 + // Input is already validated by zod
192 + const { param1 } = input;
193 if (!param1 || param1.trim() === '') {
194 return {
195 data: {},
ts/docs/api/auth-configs.md
+43 -9
@@ -73,24 +73,40 @@ const authConfig = await composio.authConfigs.create('github', {
73 Updates an existing auth config.
74
75 ```typescript
76 -// Update an auth config
76 +// Update a custom auth config with new credentials
77 const updatedAuthConfig = await composio.authConfigs.update('auth_config_123', {
78 - name: 'Updated GitHub Auth Config',
79 - fields: {
78 + type: 'custom',
79 + credentials: {
80 client_id: 'new_client_id',
81 client_secret: 'new_client_secret',
82 },
83 + toolAccessConfig: {
84 + toolsAvailableForExecution: ['GITHUB_STAR_A_REPOSITORY_FOR_THE_AUTHENTICATED_USER']
85 + }
86 +});
87 +
88 +// Update a default auth config with new scopes
89 +const updatedDefaultAuth = await composio.authConfigs.update('auth_config_456', {
90 + type: 'default',
91 + scopes: 'read:user,repo',
92 + toolAccessConfig: {
93 + toolsAvailableForExecution: ['GITHUB_GET_A_REPOSITORY', 'GITHUB_LIST_REPOSITORIES_FOR_A_USER']
94 + }
95 });
96 ```
97
98 **Parameters:**
99
100 - `id` (string): The unique identifier of the auth config to update
89 -- `data` (AuthConfigUpdateParams): The parameters for updating the auth config
101 +- `data` (AuthConfigUpdateParams): The parameters for updating the auth config. Must be a discriminated union with either:
102 + - `{ type: 'custom', credentials: Record<string, unknown>, toolAccessConfig?: {...} }`
103 + - `{ type: 'default', scopes: string, toolAccessConfig?: {...} }`
104
105 **Returns:** Promise<AuthConfigUpdateResponse> - The updated auth config
106
93 -**Throws:** ComposioAuthConfigNotFoundError if the auth config cannot be found
107 +**Throws:**
108 +- ValidationError if the update parameters are invalid
109 +- ComposioAuthConfigNotFoundError if the auth config cannot be found
110
111 ### delete(id)
112
@@ -167,10 +183,28 @@ interface AuthConfigCreateParams {
183 ### AuthConfigUpdateParams
184
185 ```typescript
170 -interface AuthConfigUpdateParams {
171 - name?: string; // Name of the auth config
172 - fields?: Record<string, unknown>; // Configuration fields
173 -}
186 +// Discriminated union type for updating auth configs
187 +type AuthConfigUpdateParams =
188 + | {
189 + type: 'custom';
190 + credentials: Record<string, string | number | boolean | unknown>;
191 + toolAccessConfig?: {
192 + toolsAvailableForExecution?: string[];
193 + toolsForConnectedAccountCreation?: string[];
194 + };
195 + /** @deprecated Use toolAccessConfig instead */
196 + restrictToFollowingTools?: string[];
197 + }
198 + | {
199 + type: 'default';
200 + scopes: string;
201 + toolAccessConfig?: {
202 + toolsAvailableForExecution?: string[];
203 + toolsForConnectedAccountCreation?: string[];
204 + };
205 + /** @deprecated Use toolAccessConfig instead */
206 + restrictToFollowingTools?: string[];
207 + };
208 ```
209
210 ### AuthConfigType
ts/docs/api/tools.md
+13 -15
@@ -90,26 +90,24 @@ const result = await composio.tools.execute(
90 Creates a custom tool that can be used within the Composio SDK.
91
92 ```typescript
93 +import { z } from 'zod';
94 +
95 const customTool = await composio.tools.createCustomTool({
96 name: 'My Custom Tool',
97 description: 'A custom tool that does something specific',
98 slug: 'MY_CUSTOM_TOOL',
97 - inputParameters: {
98 - param1: {
99 - type: 'string',
100 - description: 'First parameter',
101 - required: true,
102 - },
103 - },
104 - outputParameters: {
105 - result: {
106 - type: 'string',
107 - description: 'The result of the operation',
108 - },
109 - },
110 - handler: async (params, context) => {
99 + inputParams: z.object({
100 + param1: z.string().describe('Description of param1'),
101 + param2: z.number().optional().describe('Optional numeric parameter')
102 + }),
103 + execute: async (input) => {
104 // Custom logic here
112 - return { data: { result: 'Success!' } };
105 + console.log('Input:', input.param1, input.param2);
106 + return {
107 + data: { result: 'Success!' },
108 + error: null,
109 + successful: true
110 + };
111 },
112 });
113 ```
ts/docs/core-concepts.md
+13 -15
@@ -399,27 +399,25 @@ Use direct execution when:
399 Custom Tools allow you to extend Composio's functionality by creating your own tools. You define the input and output parameters and provide a handler function that implements the tool's behavior.
400
401 ```typescript
402 +import { z } from 'zod';
403 +
404 // Example: Create a custom tool
405 const customTool = await composio.tools.createCustomTool({
406 name: 'My Custom Tool',
407 description: 'A custom tool that does something specific',
408 slug: 'MY_CUSTOM_TOOL',
407 - inputParameters: {
408 - param1: {
409 - type: 'string',
410 - description: 'First parameter',
411 - required: true,
412 - },
413 - },
414 - outputParameters: {
415 - result: {
416 - type: 'string',
417 - description: 'The result of the operation',
418 - },
419 - },
420 - handler: async (params, context) => {
409 + inputParams: z.object({
410 + param1: z.string().describe('First parameter'),
411 + param2: z.number().optional().describe('Optional parameter')
412 + }),
413 + execute: async (input) => {
414 // Custom logic here
422 - return { data: { result: 'Success!' } };
415 + console.log('Received input:', input.param1, input.param2);
416 + return {
417 + data: { result: 'Success!' },
418 + error: null,
419 + successful: true
420 + };
421 },
422 });
423 ```
ts/docs/getting-started.md
+9 -34
@@ -193,53 +193,28 @@ For a more complete integration, check out the [OpenAI Provider example](../exam
193 You can extend Composio by creating your own custom tools:
194
195 ```typescript
196 +import { z } from 'zod';
197 +
198 // Create a custom tool
199 const customTool = await composio.tools.createCustomTool({
200 name: 'Weather Forecast',
201 description: 'Get the weather forecast for a location',
202 slug: 'WEATHER_FORECAST',
201 - inputParameters: {
202 - type: 'object',
203 - properties: {
204 - location: {
205 - type: 'string',
206 - description: 'The location to get the forecast for',
207 - },
208 - days: {
209 - type: 'integer',
210 - description: 'Number of days for the forecast',
211 - default: 3,
212 - },
213 - },
214 - required: ['location'],
215 - },
216 - outputParameters: {
217 - type: 'object',
218 - properties: {
219 - forecast: {
220 - type: 'array',
221 - items: {
222 - type: 'object',
223 - properties: {
224 - date: { type: 'string' },
225 - temperature: { type: 'number' },
226 - conditions: { type: 'string' },
227 - },
228 - },
229 - },
230 - },
231 - },
232 - handler: async (params, context) => {
203 + inputParams: z.object({
204 + location: z.string().describe('The location to get the forecast for'),
205 + days: z.number().optional().default(3).describe('Number of days for the forecast')
206 + }),
207 + execute: async (input) => {
208 try {
234 - const { location, days = 3 } = params.arguments;
209 + const { location, days = 3 } = input;
210
211 // Here you would call your weather API
212 const forecast = await getWeatherForecast(location, days);
213
214 return {
215 data: { forecast },
241 - successful: true,
216 error: null,
217 + successful: true,
218 };
219 } catch (error) {
220 return {