@devries-cameron20 / composio Mirror · read-only / commits / 9a45854f9
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, 00:30 UTC

Update custom tools

haxzie committed Jun 12, 2025 at 12:29 UTC 9a45854f96c10fd789784483d97b3b9a48bd924b
7 files changed +33 -70
examples/custom-tools/README.md
+1 -1
@@ -85,7 +85,7 @@ const tool = await composio.tools.createCustomTool({
85 {
86 method: 'PUT',
87 headers: {
88 - Authorization: `Bearer ${authCredentials?.access_token}`,
88 + Authorization: `Bearer ${authCredentials.val?.access_token}`,
89 },
90 }
91 );
packages/core/src/models/CustomTools.ts
+4 -6
@@ -28,12 +28,10 @@ import {
28 import { ComposioConnectedAccountNotFoundError } from '../errors/ConnectedAccountsErrors';
29 import { ComposioError } from '../errors/ComposioError';
30 import { telemetry } from '../telemetry/Telemetry';
31 -import {
32 - ConnectedAccountRetrieveResponse,
33 - ConnectedAccountRetrieveResponseSchema,
34 -} from '../types/connectedAccounts.types';
31 +import { ConnectedAccountRetrieveResponse } from '../types/connectedAccounts.types';
32 import { ValidationError } from '../errors';
33 import { transformConnectedAccountResponse } from '../utils/transformers/connectedAccounts';
34 +import { ConnectionData } from '../types/connectedAccountAuthStates.types';
35
36 export class CustomTools {
37 private readonly client: ComposioClient;
@@ -241,7 +239,7 @@ export class CustomTools {
239 throw new ComposioToolNotFoundError(`Tool with slug ${slug} not found`);
240 }
241
244 - let authCredentials: Record<string, unknown> = {};
242 + let authCredentials: ConnectionData | null = null;
243 const { toolkitSlug, execute, inputParams } = tool.options;
244 // if a toolkit is used, get the connected account, and auth credentials
245 let connectedAccountId: string | undefined = body.connectedAccountId;
@@ -267,7 +265,7 @@ export class CustomTools {
265 }
266 );
267 }
270 - authCredentials = connectedAccount.data as Record<string, unknown>;
268 + authCredentials = connectedAccount.state ?? null;
269 connectedAccountId = connectedAccount.id;
270 }
271
packages/core/src/types/customTool.types.ts
+2 -1
@@ -1,6 +1,7 @@
1 import { z } from 'zod';
2 import { Tool, ToolProxyParams } from './tool.types';
3 import { ToolExecuteResponse } from '@composio/client/resources/tools';
4 +import { ConnectionData } from './connectedAccountAuthStates.types';
5
6 type BaseCustomToolOptions<T extends z.ZodType> = {
7 name: string;
@@ -12,7 +13,7 @@ type BaseCustomToolOptions<T extends z.ZodType> = {
13 type ToolkitBasedExecute<T extends z.ZodType> = {
14 execute: (
15 input: z.infer<T>,
15 - authCredentials: Record<string, unknown>,
16 + authCredentials: ConnectionData | null,
17 executeToolRequest: (data: ToolProxyParams) => Promise<ToolExecuteResponse>
18 ) => Promise<ToolExecuteResponse>;
19 toolkitSlug: string;
packages/json-schema-to-zod/package.json
+1
@@ -35,6 +35,7 @@
35 "vitest": "^3.1.4"
36 },
37 "dependencies": {
38 + "@types/json-schema": "^7.0.15",
39 "zod": "^3.24.2"
40 }
41 }
packages/json-schema-to-zod/src/types.ts
+2 -58
@@ -1,4 +1,5 @@
1 import type { ZodTypeAny } from 'zod';
2 +import type { JSONSchema7 } from 'json-schema';
3
4 export type Serializable =
5 | { [key: string]: Serializable }
@@ -9,64 +10,7 @@ export type Serializable =
10 | null;
11
12 export type JsonSchema = JsonSchemaObject | boolean;
12 -export type JsonSchemaObject = {
13 - // left permissive by design
14 - type?: string | string[];
15 -
16 - // object
17 - properties?: { [key: string]: JsonSchema };
18 - additionalProperties?: JsonSchema;
19 - unevaluatedProperties?: JsonSchema;
20 - patternProperties?: { [key: string]: JsonSchema };
21 - minProperties?: number;
22 - maxProperties?: number;
23 - required?: string[] | boolean;
24 - propertyNames?: JsonSchema;
25 -
26 - // array
27 - items?: JsonSchema | JsonSchema[];
28 - additionalItems?: JsonSchema;
29 - minItems?: number;
30 - maxItems?: number;
31 - uniqueItems?: boolean;
32 -
33 - // string
34 - minLength?: number;
35 - maxLength?: number;
36 - pattern?: string;
37 - format?: string;
38 -
39 - // number
40 - minimum?: number;
41 - maximum?: number;
42 - exclusiveMinimum?: number | boolean;
43 - exclusiveMaximum?: number | boolean;
44 - multipleOf?: number;
45 -
46 - // unions
47 - anyOf?: JsonSchema[];
48 - allOf?: JsonSchema[];
49 - oneOf?: JsonSchema[];
50 -
51 - if?: JsonSchema;
52 - then?: JsonSchema;
53 - else?: JsonSchema;
54 -
55 - // shared
56 - const?: Serializable;
57 - enum?: Serializable[];
58 -
59 - errorMessage?: { [key: string]: string | undefined };
60 -
61 - description?: string;
62 - title?: string;
63 - default?: Serializable;
64 - readOnly?: boolean;
65 - not?: JsonSchema;
66 - contentEncoding?: string;
67 - nullable?: boolean;
68 -};
69 -
13 +export type JsonSchemaObject = JSONSchema7;
14 export type ParserSelector = (schema: JsonSchemaObject, refs: Refs) => ZodTypeAny;
15 export type ParserOverride = (schema: JsonSchemaObject, refs: Refs) => ZodTypeAny | undefined;
16
pnpm-lock.yaml
+22 -3
@@ -452,6 +452,9 @@ importers:
452
453 packages/json-schema-to-zod:
454 dependencies:
455 + '@types/json-schema':
456 + specifier: ^7.0.15
457 + version: 7.0.15
458 zod:
459 specifier: ^3.24.2
460 version: 3.25.62
@@ -9748,6 +9751,14 @@ snapshots:
9751 chai: 5.2.0
9752 tinyrainbow: 2.0.0
9753
9754 + '@vitest/mocker@3.2.3(vite@6.3.5(@types/node@20.19.0)(jiti@1.21.7)(tsx@4.20.1)(yaml@2.8.0))':
9755 + dependencies:
9756 + '@vitest/spy': 3.2.3
9757 + estree-walker: 3.0.3
9758 + magic-string: 0.30.17
9759 + optionalDependencies:
9760 + vite: 6.3.5(@types/node@20.19.0)(jiti@1.21.7)(tsx@4.20.1)(yaml@2.8.0)
9761 +
9762 '@vitest/mocker@3.2.3(vite@6.3.5(@types/node@22.15.31)(jiti@1.21.7)(tsx@4.20.1)(yaml@2.8.0))':
9763 dependencies:
9764 '@vitest/spy': 3.2.3
@@ -9756,6 +9767,14 @@ snapshots:
9767 optionalDependencies:
9768 vite: 6.3.5(@types/node@22.15.31)(jiti@1.21.7)(tsx@4.20.1)(yaml@2.8.0)
9769
9770 + '@vitest/mocker@3.2.3(vite@6.3.5(@types/node@24.0.1)(jiti@1.21.7)(tsx@4.20.1)(yaml@2.8.0))':
9771 + dependencies:
9772 + '@vitest/spy': 3.2.3
9773 + estree-walker: 3.0.3
9774 + magic-string: 0.30.17
9775 + optionalDependencies:
9776 + vite: 6.3.5(@types/node@24.0.1)(jiti@1.21.7)(tsx@4.20.1)(yaml@2.8.0)
9777 +
9778 '@vitest/pretty-format@3.2.3':
9779 dependencies:
9780 tinyrainbow: 2.0.0
@@ -9785,7 +9804,7 @@ snapshots:
9804 sirv: 3.0.1
9805 tinyglobby: 0.2.14
9806 tinyrainbow: 2.0.0
9788 - vitest: 3.2.3(@types/node@22.15.31)(@vitest/ui@3.2.3)(jiti@1.21.7)(tsx@4.20.1)(yaml@2.8.0)
9807 + vitest: 3.2.3(@types/node@24.0.1)(@vitest/ui@3.2.3)(jiti@1.21.7)(tsx@4.20.1)(yaml@2.8.0)
9808
9809 '@vitest/utils@3.2.3':
9810 dependencies:
@@ -12141,7 +12160,7 @@ snapshots:
12160 dependencies:
12161 '@types/chai': 5.2.2
12162 '@vitest/expect': 3.2.3
12144 - '@vitest/mocker': 3.2.3(vite@6.3.5(@types/node@22.15.31)(jiti@1.21.7)(tsx@4.20.1)(yaml@2.8.0))
12163 + '@vitest/mocker': 3.2.3(vite@6.3.5(@types/node@20.19.0)(jiti@1.21.7)(tsx@4.20.1)(yaml@2.8.0))
12164 '@vitest/pretty-format': 3.2.3
12165 '@vitest/runner': 3.2.3
12166 '@vitest/snapshot': 3.2.3
@@ -12225,7 +12244,7 @@ snapshots:
12244 dependencies:
12245 '@types/chai': 5.2.2
12246 '@vitest/expect': 3.2.3
12228 - '@vitest/mocker': 3.2.3(vite@6.3.5(@types/node@22.15.31)(jiti@1.21.7)(tsx@4.20.1)(yaml@2.8.0))
12247 + '@vitest/mocker': 3.2.3(vite@6.3.5(@types/node@24.0.1)(jiti@1.21.7)(tsx@4.20.1)(yaml@2.8.0))
12248 '@vitest/pretty-format': 3.2.3
12249 '@vitest/runner': 3.2.3
12250 '@vitest/snapshot': 3.2.3
ts/docs/api/custom-tools.md
+1 -1
@@ -90,7 +90,7 @@ const tool = await composio.tools.createCustomTool({
90 // Use authCredentials for direct API calls
91 const result = await fetch(`https://api.github.com/repos/${input.repo}`, {
92 headers: {
93 - Authorization: `Bearer ${authCredentials.access_token}`,
93 + Authorization: `Bearer ${authCredentials.val?.access_token}`,
94 },
95 });
96