Skip to content

Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.

Base openai toolset

haxzie9461c44145fd
diff --git a/packages/core/package.json b/packages/core/package.json
index 7ecd8a42e..0dc71f9dd 100644
--- a/packages/core/package.json
+++ b/packages/core/package.json
@@ -18,6 +18,7 @@
"typescript": "^5.8.3"
},
"dependencies": {
- "@composio/client": "0.1.0-alpha.1"
+ "@composio/client": "0.1.0-alpha.1",
+ "@composio/openai-toolset": "workspace:^"
}
}
diff --git a/packages/core/src/composio.ts b/packages/core/src/composio.ts
index 25b10d8ac..3334dd105 100644
--- a/packages/core/src/composio.ts
+++ b/packages/core/src/composio.ts
@@ -3,8 +3,9 @@ import { Tools } from "./models/Tools";
import { Toolkits } from "./models/Toolkits";
import { Triggers } from "./models/Triggers";
import { ComposioToolset } from "./toolset/ComposioToolset";
+import { OpenAIToolset} from "@composio/openai-toolset";
import { Toolset, WrappedTool } from "./types/toolset.types.";
-import { Tool } from "./types/tool.types";
+import { BaseTool, Tool } from "./types/tool.types";
import { AuthConfigs } from "./models/AuthConfigs";
import { ConnectedAccounts } from "./models/ConnectedAccounts";
import { ToolListParams } from "@composio/client/resources/tools";
@@ -69,7 +70,7 @@ export class Composio<T extends Toolset<any>> {
/**
* Set the default toolset, if not provided by the user.
*/
- const defaultToolset = new ComposioToolset();
+ const defaultToolset = new OpenAIToolset();
this.toolset = config.toolset ?? (defaultToolset as unknown as T);
this.toolset.setClient(this);
diff --git a/packages/core/src/toolset/BaseToolset.ts b/packages/core/src/toolset/BaseToolset.ts
index 6a219fd84..df1d7acbb 100644
--- a/packages/core/src/toolset/BaseToolset.ts
+++ b/packages/core/src/toolset/BaseToolset.ts
@@ -1,5 +1,5 @@
import { Toolset } from "../types/toolset.types.";
-import { Tool } from "../types/tool.types";
+import { Tool, BaseTool } from "../types/tool.types";
import { Composio } from "../composio";
/**
@@ -12,20 +12,38 @@ import { Composio } from "../composio";
*
* eg:
* ```ts
- * class MyToolset extends BaseComposioToolset<MyTool> {
- * _wrapTool(tool: BaseTool): MyTool {}
- * }
+ * // Using default BaseTool type
+ * class DefaultToolset extends BaseComposioToolset {}
+ *
+ * // Using a custom tool type
+ * class MyToolset extends BaseComposioToolset<MyCustomTool> {}
+ *
+ * // Using a third-party tool type
+ * class ThirdPartyToolset extends BaseComposioToolset<ThirdPartyTool> {}
* ```
*/
-export abstract class BaseComposioToolset<TTool> implements Toolset<TTool> {
+export abstract class BaseComposioToolset<TTool = BaseTool> implements Toolset<TTool> {
protected client: Composio<Toolset<TTool>> | undefined;
+ /**
+ * Set the client for the toolset. This is automatically done by the Composio class.
+ * @param client - The Composio client.
+ */
setClient(client: Composio<Toolset<TTool>>): void {
this.client = client;
}
+ /**
+ * Wrap a tool in the toolset.
+ * @param tool - The tool to wrap.
+ * @returns The wrapped tool.
+ */
abstract _wrapTool(tool: Tool): TTool;
+ /**
+ * Ensure the client is initialized.
+ * This is automatically done by the Composio class.
+ */
protected ensureClient(): void {
if (!this.client) {
throw new Error('Client not initialized. Make sure the toolset is properly initialized with Composio.');
diff --git a/packages/core/src/toolset/ComposioToolset.ts b/packages/core/src/toolset/ComposioToolset.ts
index a4ac7e220..ddc8f787a 100644
--- a/packages/core/src/toolset/ComposioToolset.ts
+++ b/packages/core/src/toolset/ComposioToolset.ts
@@ -9,20 +9,14 @@ import { BaseComposioToolset } from "./BaseToolset";
* This class shouldn't be used directly or to be extended.
*/
-export class ComposioToolset extends BaseComposioToolset<Tool> {
+interface CustomTool {
+ name: string;
+}
+export class ComposioToolset extends BaseComposioToolset<CustomTool> {
- _wrapTool = (tool: Tool): Tool => {
- return tool as Tool;
+ _wrapTool = (tool: Tool): CustomTool => {
+ return tool as CustomTool;
};
async test() {}
-}
-
-
-const composio = new Composio({
- apiKey: process.env.COMPOSIO_API_KEY,
- toolset: new ComposioToolset(),
-});
-
-composio.toolset.test();
-composio.getTool("123");
\ No newline at end of file
+}
\ No newline at end of file
diff --git a/packages/core/src/types/Tool.types.ts b/packages/core/src/types/Tool.types.ts
index 2c1cdcb2f..05b496019 100644
--- a/packages/core/src/types/Tool.types.ts
+++ b/packages/core/src/types/Tool.types.ts
@@ -1,3 +1,12 @@
import { ToolListResponse, ToolRetrieveResponse } from "@composio/client/resources/tools";
-export type Tool = ToolRetrieveResponse;
\ No newline at end of file
+export type Tool = ToolRetrieveResponse;
+
+export interface BaseTool {
+ name: string;
+ description?: string;
+ input_parameters?: Record<string, any>;
+ output_parameters?: Record<string, any>;
+}
+
+export type ToolType<T extends BaseTool> = T;
\ No newline at end of file
diff --git a/packages/core/src/types/Toolset.types..ts b/packages/core/src/types/Toolset.types..ts
index 44d1ba636..a4dc53018 100644
--- a/packages/core/src/types/Toolset.types..ts
+++ b/packages/core/src/types/Toolset.types..ts
@@ -1,11 +1,11 @@
import { Composio } from "../composio";
-import { Tool } from "./tool.types";
+import { Tool, BaseTool } from "./tool.types";
/**
* Base toolset implementation, which needs to be implemented by the extended class.
* This class is used to create a base toolset by implementing this class.
*/
-export interface Toolset<TTool> {
+export interface Toolset<TTool = BaseTool> {
_wrapTool: (tool: Tool) => TTool;
setClient<T extends Toolset<TTool>>(client: Composio<T>): void;
}
diff --git a/packages/core/src/types/toolset.types.ts b/packages/core/src/types/toolset.types.ts
index cd58dd0be..410b80e42 100644
--- a/packages/core/src/types/toolset.types.ts
+++ b/packages/core/src/types/toolset.types.ts
@@ -1,7 +1,7 @@
import { Tool } from "./tool.types";
import { Composio } from "../composio";
-export interface Toolset<TTool> {
+export interface Toolset<TTool = Tool> {
_wrapTool(tool: Tool): TTool;
setClient(client: Composio<Toolset<TTool>>): void;
}
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 172996880..ce58978c3 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -13,6 +13,9 @@ importers:
'@composio/client':
specifier: 0.1.0-alpha.1
version: 0.1.0-alpha.1
+ '@composio/openai-toolset':
+ specifier: workspace:^
+ version: link:../toolsets/openai
devDependencies:
rolldown:
specifier: 1.0.0-beta.7