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
Fix eslint rules
haxzied0fad6cf06d3
diff --git a/eslint.config.mjs b/eslint.config.mjsindex 4a5522060..f157a8802 100644--- a/eslint.config.mjs+++ b/eslint.config.mjs@@ -7,18 +7,18 @@ export default [{ignores: ["packages/**/dist/**", "packages/**/node_modules/**", "node_modules/**", "examples/"]},- {files: ["packages/**/*.{ts}"]},+ {files: ["packages/**/*.ts"]},{languageOptions: { globals: globals.browser }},...tseslint.configs.recommended,{rules: {- "@typescript-eslint/no-var-requires": "off",+ // "@typescript-eslint/no-var-requires": "off","@typescript-eslint/no-require-imports": "warn","@typescript-eslint/no-unsafe-function-type": "off","no-prototype-builtins": "off","max-lines-per-function": ["error", 250],"no-unused-vars": "off",- "@typescript-eslint/ban-ts-comment": "off",+ "@typescript-eslint/ban-ts-comment": "warn","no-constant-condition": "off","no-ex-assign": "off","no-constant-binary-expression": "off",diff --git a/packages/core/src/models/Triggers.ts b/packages/core/src/models/Triggers.tsindex 8154cc916..d2fb15f35 100644--- a/packages/core/src/models/Triggers.ts+++ b/packages/core/src/models/Triggers.ts@@ -1,5 +1,5 @@-import ComposioClient from "@composio/client";-import { RequestOptions } from "@composio/client/internal/request-options";+import ComposioClient from '@composio/client';+import { RequestOptions } from '@composio/client/internal/request-options';import {TriggerInstanceListActiveParams,TriggerInstanceRemoveUpsertResponse,@@ -10,15 +10,12 @@ import {TriggersTypeListResponse,TriggersTypeRetrieveEnumResponse,TriggersTypeRetrieveResponse,-} from "@composio/client/resources/index";-import { TriggerStatusEnum, TriggerSubscribeParams } from "../types/triggers.types";-import { InstrumentedInstance } from "../types/telemetry.types";-import { PusherUtils, TriggerData } from "../utils/pusher";-import logger from "../utils/logger";-import { Session } from "./Session";---+} from '@composio/client/resources/index';+import { TriggerStatusEnum, TriggerSubscribeParams } from '../types/triggers.types';+import { InstrumentedInstance } from '../types/telemetry.types';+import { PusherUtils, TriggerData } from '../utils/pusher';+import logger from '../utils/logger';+import { Session } from './Session';/*** Trigger (Instance) class@@ -26,7 +23,7 @@ import { Session } from "./Session";**/export class Triggers implements InstrumentedInstance {- readonly FILE_NAME: string = "core/models/Triggers.ts";+ readonly FILE_NAME: string = 'core/models/Triggers.ts';private client: ComposioClient;constructor(client: ComposioClient) {@@ -37,10 +34,7 @@ export class Triggers implements InstrumentedInstance {* Fetch list of all the active triggers* @returns {Promise<TriggerInstance[]>} List of trigger instances*/- async list(- query?: TriggerInstanceListActiveParams,- options?: RequestOptions- ) {+ async list(query?: TriggerInstanceListActiveParams, options?: RequestOptions) {return this.client.triggerInstances.listActive(query, options);}@@ -108,11 +102,7 @@ export class Triggers implements InstrumentedInstance {* @returns {Promise<TriggerInstanceUpsertResponse>} The updated trigger instance*/async disable(slug: string, options?: RequestOptions) {- return this.client.triggerInstances.updateStatus(- "disable",- { slug },- options- );+ return this.client.triggerInstances.updateStatus('disable', { slug }, options);}/**@@ -123,11 +113,7 @@ export class Triggers implements InstrumentedInstance {* @returns {Promise<TriggerInstanceUpsertResponse>} The updated trigger instance*/async enable(slug: string, options?: RequestOptions) {- return this.client.triggerInstances.updateStatus(- "enable",- { slug },- options- );+ return this.client.triggerInstances.updateStatus('enable', { slug }, options);}/**@@ -135,18 +121,21 @@ export class Triggers implements InstrumentedInstance {*//*** List all the trigger types- *+ ** @param {TriggersTypeListParams} query - The query parameters to filter the trigger types* @param {RequestOptions} options - Request options* @returns {Promise<TriggersTypeListResponse>} The list of trigger types*/- async listTypes(query?: TriggersTypeListParams, options?: RequestOptions): Promise<TriggersTypeListResponse> {+ async listTypes(+ query?: TriggersTypeListParams,+ options?: RequestOptions+ ): Promise<TriggersTypeListResponse> {return this.client.triggersTypes.list(query, options);}/*** Retrieve a trigger type by its slug- *+ ** @param {string} slug - The slug of the trigger type* @param {RequestOptions} options - request options* @returns {Promise<TriggersTypeRetrieveResponse>} The trigger type object@@ -157,49 +146,38 @@ export class Triggers implements InstrumentedInstance {/*** Fetches the list of all the available trigger enums- *+ ** This method is used by the CLI where filters are not required.- * @param options- * @returns+ * @param options+ * @returns*/async listEnum(options?: RequestOptions): Promise<TriggersTypeRetrieveEnumResponse> {return this.client.triggersTypes.retrieveEnum(options);}- async subscribe(- fn: (data: TriggerData) => void,- filters: TriggerSubscribeParams = {}- ) {-- if (!fn) throw new Error("Function is required for trigger subscription");+ async subscribe(fn: (_data: TriggerData) => void, filters: TriggerSubscribeParams = {}) {+ if (!fn) throw new Error('Function is required for trigger subscription');// @TODO: Get the client id from the backendconst session = new Session(this.client);const sessionInfo = await session.getInfo();const clientId = sessionInfo.project?.id;- if (!clientId) throw new Error("Client ID not found");+ if (!clientId) throw new Error('Client ID not found');- await PusherUtils.getPusherClient(- this.client.baseURL,- this.client.apiKey- );+ await PusherUtils.getPusherClient(this.client.baseURL, this.client.apiKey);const shouldSendTrigger = (data: TriggerData) => {if (Object.keys(filters).length === 0) return true;else {return (- (!filters.appName ||- data.appName.toLowerCase() === filters.appName.toLowerCase()) &&+ (!filters.appName || data.appName.toLowerCase() === filters.appName.toLowerCase()) &&(!filters.triggerId ||- data.metadata.id.toLowerCase() ===- filters.triggerId.toLowerCase()) &&+ data.metadata.id.toLowerCase() === filters.triggerId.toLowerCase()) &&(!filters.connectionId ||- data.metadata.connectionId.toLowerCase() ===- filters.connectionId.toLowerCase()) &&+ data.metadata.connectionId.toLowerCase() === filters.connectionId.toLowerCase()) &&(!filters.triggerName ||- data.metadata.triggerName.toLowerCase() ===- filters.triggerName.toLowerCase()) &&+ data.metadata.triggerName.toLowerCase() === filters.triggerName.toLowerCase()) &&(!filters.entityId ||data.metadata.connection.clientUniqueUserId.toLowerCase() ===filters.entityId.toLowerCase()) &&@@ -210,7 +188,7 @@ export class Triggers implements InstrumentedInstance {}};- logger.debug("Subscribing to triggers", filters);+ logger.debug('Subscribing to triggers', filters);PusherUtils.triggerSubscribe(clientId, (data: TriggerData) => {if (shouldSendTrigger(data)) {fn(data);@@ -223,7 +201,7 @@ export class Triggers implements InstrumentedInstance {const sessionInfo = await session.getInfo();const clientId = sessionInfo.project?.id;- if (!clientId) throw new Error("Client ID not found");+ if (!clientId) throw new Error('Client ID not found');PusherUtils.triggerUnsubscribe(clientId);}diff --git a/packages/toolsets/vercel/src/index.ts b/packages/toolsets/vercel/src/index.tsindex 206f2a3a7..d3ee5a590 100644--- a/packages/toolsets/vercel/src/index.ts+++ b/packages/toolsets/vercel/src/index.ts@@ -1,84 +1,85 @@/**- * Vercel AI Toolset+ * Vercel AI Toolset* To be used with the Vercel AI SDK- *+ ** Author: @haxzie* Legacy Reference: https://github.com/ComposioHQ/composio/blob/master/js/src/frameworks/vercel.ts- *+ ** This toolset provides a set of tools for interacting with Vercel AI SDK.- *+ ** @packageDocumentation* @module toolsets/vercel*/-import { BaseComposioToolset, Tool as ComposioTool, ToolListParams } from "@composio/core";-import type { Tool as VercelTool } from "ai";-import { jsonSchema, tool } from "ai";+import { BaseComposioToolset, Tool as ComposioTool, ToolListParams } from '@composio/core';+import type { Tool as VercelTool } from 'ai';+import { jsonSchema, tool } from 'ai';type VercelToolCollection = Record<string, VercelTool>;export class VercelToolset extends BaseComposioToolset<VercelToolCollection, VercelTool> {+ readonly FILE_NAME = 'toolsets/vercel/src/index.ts';+ static readonly FRAMEWORK_NAME = 'vercel';- readonly FILE_NAME = "toolsets/vercel/src/index.ts";- static readonly FRAMEWORK_NAME = "vercel";+ /**+ * Get all the tools from the client.+ * Override the default implementation to return a record of tools.+ *+ * @param params - The parameters for the tool list.+ * @returns The tools.+ */+ override async getTools(params?: ToolListParams): Promise<VercelToolCollection> {+ if (!this.client) {+ throw new Error('Client not initialized');+ }+ const tools = await this.client.tools.list(params);+ return tools.items.reduce(+ (tools, tool) => ({+ ...tools,+ [tool.slug]: this._wrapTool(tool as ComposioTool),+ }),+ {}+ );+ }- /**- * Get all the tools from the client.- * Override the default implementation to return a record of tools.- *- * @param params - The parameters for the tool list.- * @returns The tools.- */- override async getTools(params?: ToolListParams): Promise<VercelToolCollection> {- if (!this.client) {- throw new Error("Client not initialized");- }- const tools = await this.client.tools.list(params);- return tools.items.reduce((tools, tool) => ({- ...tools,- [tool.slug]: this._wrapTool(tool as ComposioTool)- }), {});+ /**+ * Execute a tool call.+ * @param tool - The tool to execute.+ * @param userId - The user id.+ * @returns {Promise<string>} The result of the tool call.+ */+ async executeToolCall(+ tool: { name: string; arguments: unknown },+ userId?: string+ ): Promise<string> {+ if (!this.client) {+ throw new Error('Client not initialized');}-- /**- * Execute a tool call.- * @param tool - The tool to execute.- * @param userId - The user id.- * @returns {Promise<string>} The result of the tool call.- */- async executeToolCall(- tool: { name: string; arguments: unknown },- userId?: string- ): Promise<string> {- if (!this.client) {- throw new Error("Client not initialized");- }- const toolSchema = await this.client.tools.get(tool.name);- const appName = toolSchema?.name.toLowerCase();- const args = typeof tool.arguments === "string" ? JSON.parse(tool.arguments) : tool.arguments;+ const toolSchema = await this.client.tools.get(tool.name);+ const appName = toolSchema?.name.toLowerCase();+ const args = typeof tool.arguments === 'string' ? JSON.parse(tool.arguments) : tool.arguments;- const results = await this.client.tools.execute(toolSchema.slug, {- arguments: args,- entity_id: userId ?? this.client.userId,- connected_account_id: this.client.getConnectedAccountId(appName)- });+ const results = await this.client.tools.execute(toolSchema.slug, {+ arguments: args,+ entity_id: userId ?? this.client.userId,+ connected_account_id: this.client.getConnectedAccountId(appName),+ });- return JSON.stringify(results);- }+ return JSON.stringify(results);+ }- _wrapTool(composioTool: ComposioTool): VercelTool {- return tool({- description: composioTool.description,- // @ts-ignore the type are JSONSchemV7. Internally it's resolved- parameters: jsonSchema(composioTool.input_parameters),- execute: async (params) => {- return await this.executeToolCall(- {- name: composioTool.slug,- arguments: JSON.stringify(params),- },- this.client?.userId- );- },- });- }-}\ No newline at end of file+ _wrapTool(composioTool: ComposioTool): VercelTool {+ return tool({+ description: composioTool.description,+ parameters: jsonSchema(composioTool.input_parameters),+ execute: async params => {+ return await this.executeToolCall(+ {+ name: composioTool.slug,+ arguments: JSON.stringify(params),+ },+ this.client?.userId+ );+ },+ });+ }+}