@devries-cameron20 / composio Mirror · read-only / commits / bc1a06a35
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, 04:15 UTC

Stable version

haxzie committed Apr 16, 2025 at 14:04 UTC bc1a06a354c419391fa162cfc18d6ebc30ddfed2
6 files changed +10 -27
packages/core/src/composio.ts
+8 -9
@@ -3,14 +3,14 @@ import { Tools } from "./models/Tools";
3 import { Toolkits } from "./models/Toolkits";
4 import { Triggers } from "./models/Triggers";
5 import { ComposioToolset } from "./toolset/ComposioToolset";
6 -import { OpenAIToolset} from "@composio/openai-toolset";
7 -import { Toolset, WrappedTool } from "./types/toolset.types.";
8 -import { BaseTool, Tool } from "./types/tool.types";
6 +import { WrappedTool } from "./types/toolset.types.";
7 +import { Tool } from "./types/tool.types";
8 import { AuthConfigs } from "./models/AuthConfigs";
9 import { ConnectedAccounts } from "./models/ConnectedAccounts";
10 import { ToolListParams } from "@composio/client/resources/tools";
11 +import { BaseComposioToolset } from "./toolset/BaseToolset";
12
13 -export type ComposioConfig<T extends Toolset<any>> = {
13 +export type ComposioConfig<TTool, T extends BaseComposioToolset<TTool>> = {
14 apiKey?: string;
15 baseURL?: string;
16 runtime?: string;
@@ -23,14 +23,14 @@ export type ComposioConfig<T extends Toolset<any>> = {
23 * This is the core class for Composio.
24 * It is used to initialize the Composio SDK and provide a global configuration.
25 */
26 -export class Composio<T extends Toolset<any>> {
26 +export class Composio<TTool, T extends BaseComposioToolset<TTool>> {
27 /**
28 * The Composio API client.
29 * @type {ComposioClient}
30 */
31 private client: ComposioClient;
32
33 - private config: ComposioConfig<T>;
33 + private config: ComposioConfig<TTool, T>;
34
35 /**
36 * Core models for Composio.
@@ -51,7 +51,7 @@ export class Composio<T extends Toolset<any>> {
51 * @param {boolean} config.allowTracing Whether to allow tracing. Defaults to true.
52 * @param {TS} config.toolset The toolset to use for this Composio instance.
53 */
54 - constructor(config: ComposioConfig<T>) {
54 + constructor(config: ComposioConfig<TTool,T>) {
55 /**
56 * Initialize the Composio SDK client.
57 * The client is used to make API calls to the Composio API.
@@ -70,8 +70,7 @@ export class Composio<T extends Toolset<any>> {
70 /**
71 * Set the default toolset, if not provided by the user.
72 */
73 - const defaultToolset = new OpenAIToolset();
74 - this.toolset = config.toolset ?? (defaultToolset as unknown as T);
73 + this.toolset = config.toolset ?? new ComposioToolset() as unknown as T;
74 this.toolset.setClient(this);
75
76 /**
packages/core/src/toolset/BaseToolset.ts
+2 -2
@@ -23,13 +23,13 @@ import { Composio } from "../composio";
23 * ```
24 */
25 export abstract class BaseComposioToolset<TTool = BaseTool> implements Toolset<TTool> {
26 - protected client: Composio<Toolset<TTool>> | undefined;
26 + protected client: Composio<TTool, this> | undefined;
27
28 /**
29 * Set the client for the toolset. This is automatically done by the Composio class.
30 * @param client - The Composio client.
31 */
32 - setClient(client: Composio<Toolset<TTool>>): void {
32 + setClient(client: Composio<TTool, this>): void {
33 this.client = client;
34 }
35
packages/core/src/types/Toolset.types..ts
-1
@@ -7,7 +7,6 @@ import { Tool, BaseTool } from "./tool.types";
7 */
8 export interface Toolset<TTool = BaseTool> {
9 _wrapTool: (tool: Tool) => TTool;
10 - setClient<T extends Toolset<TTool>>(client: Composio<T>): void;
10 }
11
12
packages/core/src/types/toolset.types.ts deleted
-9
@@ -1,9 +0,0 @@
1 -import { Tool } from "./tool.types";
2 -import { Composio } from "../composio";
3 -
4 -export interface Toolset<TTool = Tool> {
5 - _wrapTool(tool: Tool): TTool;
6 - setClient(client: Composio<Toolset<TTool>>): void;
7 -}
8 -
9 -export type WrappedTool<T> = T extends Toolset<infer U> ? U : never;
\ No newline at end of file
packages/core/tsconfig.json
-1
@@ -3,7 +3,6 @@
3 "target": "ESNext",
4 "module": "ESNext",
5 "declaration": true,
6 - "declarationDir": "./dist",
6 "outDir": "./dist",
7 "rootDir": "./src",
8 "strict": true,
packages/toolsets/openai/src/index.ts
-5
@@ -6,11 +6,6 @@ export class OpenAIToolset extends BaseComposioToolset<OpenAI.ChatCompletionTool
6 static readonly FRAMEWORK_NAME = "openai";
7 static readonly DEFAULT_USER_ID = "default";
8 private static readonly FILE_NAME = "toolsets/openai/src/index.ts";
9 - private client: Composio<OpenAI.ChatCompletionTool, Toolset<OpenAI.ChatCompletionTool>> | undefined;
10 -
11 - setClient(client: Composio<OpenAI.ChatCompletionTool, Toolset<OpenAI.ChatCompletionTool>>) {
12 - this.client = client;
13 - }
9
10 _wrapTool = (tool: Tool): OpenAI.ChatCompletionTool => {
11 const formattedSchema: OpenAI.FunctionDefinition = {