Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
TypeScript agentic-aiagentsaiai-agentsaiagentsdeveloper-toolsfunction-callinggpt-4javascriptjsllmllmopsmcppythonremote-mcp-serverssetypescript
Add experimental modifiers
haxzieb416a818416b
diff --git a/packages/core/src/composio.ts b/packages/core/src/composio.tsindex fe4d09f0c..97b74d173 100644--- a/packages/core/src/composio.ts+++ b/packages/core/src/composio.ts@@ -36,8 +36,6 @@ export type ComposioConfig<TToolset extends BaseComposioToolset<unknown, unknown*/export class Composio<TToolset extends BaseComposioToolset<unknown, unknown> = OpenAIToolset> {private readonly DEFAULT_USER_ID = 'default';- readonly FILE_NAME = 'core/composio.ts';-/*** The Composio API client.* @type {ComposioClient}@@ -81,7 +79,7 @@ export class Composio<TToolset extends BaseComposioToolset<unknown, unknown> = O* @param {string} config.runtime The runtime for the Composio SDK.* @param {boolean} config.allowTracking Whether to allow analytics / tracking. Defaults to true.* @param {boolean} config.allowTracing Whether to allow tracing. Defaults to true.- * @param {TS} config.toolset The toolset to use for this Composio instance.+ * @param {TToolset} config.toolset The toolset to use for this Composio instance.*/constructor(config: ComposioConfig<TToolset>) {const { baseURL: baseURLParsed, apiKey: apiKeyParsed } = getSDKConfig(diff --git a/packages/core/src/models/AuthConfigs.ts b/packages/core/src/models/AuthConfigs.tsindex 9f40980c3..ab85b0910 100644--- a/packages/core/src/models/AuthConfigs.ts+++ b/packages/core/src/models/AuthConfigs.ts@@ -1,3 +1,10 @@+/**+ * @fileoverview Auth configs class for Composio SDK, used to manage authentication configurations.+ *+ * @author Musthaq Ahamad <[email protected]>+ * @date 2025-05-05+ * @module AuthConfigs+ */import ComposioClient from '@composio/client';import { RequestOptions } from '@composio/client/internal/request-options';import {diff --git a/packages/core/src/models/ConnectedAccounts.ts b/packages/core/src/models/ConnectedAccounts.tsindex 779d9ca81..731ddd7b8 100644--- a/packages/core/src/models/ConnectedAccounts.ts+++ b/packages/core/src/models/ConnectedAccounts.ts@@ -1,3 +1,10 @@+/**+ * @fileoverview Connected accounts class for Composio SDK, used to manage connected accounts of a user.+ *+ * @author Musthaq Ahamad <[email protected]>+ * @date 2025-05-05+ * @module ConnectedAccounts+ */import ComposioClient from '@composio/client';import { RequestOptions } from '@composio/client/internal/request-options';import {diff --git a/packages/core/src/models/ConnectionRequest.ts b/packages/core/src/models/ConnectionRequest.tsindex 06bccab4a..d3460bbd1 100644--- a/packages/core/src/models/ConnectionRequest.ts+++ b/packages/core/src/models/ConnectionRequest.ts@@ -1,3 +1,10 @@+/**+ * @fileoverview Connection request class for Composio SDK, used to manage an initiated connection request.+ *+ * @author Musthaq Ahamad <[email protected]>+ * @date 2025-05-05+ * @module ConnectionRequest+ */import ComposioClient from '@composio/client';import {ConnectedAccountStatus,@@ -23,8 +30,8 @@ export class ConnectionRequest {/*** Transform the response from the Composio API to the SDK format- * @param response- * @returns+ * @param response+ * @returns*/private async transformResponse(response: OriginalConnectedAccountResponse@@ -47,10 +54,10 @@ export class ConnectionRequest {}/**- * Wait for the connection to be established.+ * Wait for the connection to be established.* The function will poll the Composio API every second until the connection is established or the timeout is reached.* @param {number} timeout - The time in milliseconds to wait for the connection to be established. Default is 30 seconds.- * @returns+ * @returns*/async waitForConnection(timeout: number = 60000): Promise<ConnectedAccountRetrieveResponse> {if (this.connectedAccountStatus === ConnectedAccountStatuses.ACTIVE) {@@ -78,5 +85,4 @@ export class ConnectionRequest {}, timeout);});}-}diff --git a/packages/core/src/models/CustomTools.ts b/packages/core/src/models/CustomTools.tsindex 642c9f102..dd554680c 100644--- a/packages/core/src/models/CustomTools.ts+++ b/packages/core/src/models/CustomTools.ts@@ -1,3 +1,10 @@+/**+ * @fileoverview Custom tools class for Composio SDK, used to manage custom tools created by users.+ *+ * @author Musthaq Ahamad <[email protected]>+ * @date 2025-05-05+ * @module CustomTools+ */import ComposioClient from '@composio/client';import {CustomToolOptions,@@ -96,10 +103,10 @@ export class CustomTools {* @param {string} slug The slug of the tool to get* @returns {Tool} The tool*/- async getCustomToolBySlug(slug: string): Promise<Tool> {+ async getCustomToolBySlug(slug: string): Promise<Tool | null> {const tool = this.customToolsRegistry.get(slug.toLowerCase());if (!tool) {- throw new Error(`Tool with slug ${slug} not found`);+ return null;}return tool.schema;}@@ -125,6 +132,13 @@ export class CustomTools {: connectedAccounts.items[0];}+ /**+ * Execute a custom tool+ * @param {slug} slug The slug of the tool to execute+ * @param {Record<string, unknown>} inputParams The input parameters for the tool+ * @param {ExecuteMetadata} metadata The metadata of the execution+ * @returns {Promise<ToolExecuteResponse>} The response from the tool+ */async executeCustomTool(slug: string,inputParams: Record<string, unknown>,@@ -137,6 +151,7 @@ export class CustomTools {let authCredentials: Record<string, unknown> = {};const { toolkitSlug, execute } = tool.options;+ // if a toolkit is used, get the connected account, and auth credentialsif (toolkitSlug) {const connectedAccount = await this.getConnectedAccount(toolkitSlug, metadata);if (!connectedAccount) {diff --git a/packages/core/src/models/Modifiers.ts b/packages/core/src/models/Modifiers.tsindex 673a0b0f0..532d76f6c 100644--- a/packages/core/src/models/Modifiers.ts+++ b/packages/core/src/models/Modifiers.ts@@ -138,7 +138,10 @@ export class Modifiers {}/**- * Function signature for modifying the tool schema.+ * Function signatures for modifying the tool schema.+ * We support two ways to register modifiers:+ * 1. useTransformToolSchema(globalModifier: GlobalTransformToolSchemaModifier): void+ * 2. useTransformToolSchema(toolSlug: string, modifier: TransformToolSchemaModifier): void*/useTransformToolSchema(globalModifier: GlobalTransformToolSchemaModifier): void;useTransformToolSchema(toolSlug: string, modifier: TransformToolSchemaModifier): void;