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(cli): resolve custom schemas through tool router
shams haroon7ed76f97fcfe
diff --git a/ts/packages/cli/src/commands/tools/commands/tools.search.cmd.ts b/ts/packages/cli/src/commands/tools/commands/tools.search.cmd.tsindex 44bd3e47b..8958a4b19 100644--- a/ts/packages/cli/src/commands/tools/commands/tools.search.cmd.ts+++ b/ts/packages/cli/src/commands/tools/commands/tools.search.cmd.ts@@ -388,8 +388,46 @@ const runToolsSearch = (params: {cause,}),});+ const customToolSlugsMissingSchemas = Object.entries(searchResponse.tool_schemas)+ .filter(+ ([slug, schema]) =>+ isRemoteCustomToolSlug(slug) && !schema.input_schema+ )+ .map(([slug]) => slug);+ const hydratedSearchResponse =+ customToolSlugsMissingSchemas.length === 0+ ? searchResponse+ : yield* Effect.tryPromise({+ try: async () => {+ const schemaResponse = await client.toolRouter.session.executeMeta(sessionId, {+ slug: 'COMPOSIO_GET_TOOL_SCHEMAS',+ arguments: { tool_slugs: customToolSlugsMissingSchemas },+ });+ if (schemaResponse.error) {+ throw new Error(schemaResponse.error);+ }++ const resolvedSchemas = schemaResponse.data.tool_schemas;+ if (!resolvedSchemas || typeof resolvedSchemas !== 'object') {+ throw new Error('Tool Router returned no tool schemas.');+ }++ return {+ ...searchResponse,+ tool_schemas: {+ ...searchResponse.tool_schemas,+ ...(resolvedSchemas as Record<string, SearchToolSchema>),+ },+ };+ },+ catch: cause =>+ new ToolsSearchRequestError({+ message: 'Failed to fetch custom tool schemas.',+ cause,+ }),+ });return {- searchResponse,+ searchResponse: hydratedSearchResponse,projectScope: {orgId: resolvedProject.orgId,projectId: resolvedProject.projectId,diff --git a/ts/packages/cli/test/src/commands/tools/tools.search.cmd.test.ts b/ts/packages/cli/test/src/commands/tools/tools.search.cmd.test.tsindex 5a776ee8c..221cbf238 100644--- a/ts/packages/cli/test/src/commands/tools/tools.search.cmd.test.ts+++ b/ts/packages/cli/test/src/commands/tools/tools.search.cmd.test.ts@@ -199,6 +199,91 @@ describe('CLI: composio search', () => {});+ layer(TestLive(testLiveOptions))(+ '[Given] a remote custom tool schema reference [Then] search resolves it with the Tool Router meta-tool',+ it => {+ it.scoped('does not use the legacy tools endpoint for schema references', () =>+ Effect.gen(function* () {+ const customSlug = 'CUSTOM_DEEPWIKI_READ_WIKI_CONTENTS';+ let schemaRequestSlugs: unknown;+ const live = TestLive({+ ...testLiveOptions,+ toolRouter: {+ search: async (_sessionId, params) => ({+ success: true,+ error: null,+ results: [+ {+ index: 1,+ use_case: params.queries[0]?.use_case ?? '',+ primary_tool_slugs: [customSlug],+ related_tool_slugs: [],+ toolkits: ['CUSTOM_DEEPWIKI'],+ },+ ],+ tool_schemas: {+ [customSlug]: {+ tool_slug: customSlug,+ toolkit: 'CUSTOM_DEEPWIKI',+ description: 'Read wiki contents',+ hasFullSchema: false,+ schemaRef: {+ tool: 'COMPOSIO_GET_TOOL_SCHEMAS',+ args: { tool_slugs: [customSlug] },+ },+ },+ },+ toolkit_connection_statuses: [],+ next_steps_guidance: [],+ session: {+ id: 'trs_test_session',+ generate_id: false,+ instructions: 'Reuse this session id for follow-up calls.',+ },+ time_info: {+ current_time_utc: '2026-01-01T00:00:00.000Z',+ current_time_utc_epoch_seconds: 1767225600,+ message: 'UTC time',+ },+ }),+ executeMeta: async (_sessionId, params) => {+ schemaRequestSlugs = params.arguments?.tool_slugs;+ return {+ data: {+ success: true,+ tool_schemas: {+ [customSlug]: {+ tool_slug: customSlug,+ toolkit: 'CUSTOM_DEEPWIKI',+ description: 'Read wiki contents',+ input_schema: {+ type: 'object',+ properties: { repo: { type: 'string' } },+ required: ['repo'],+ },+ },+ },+ },+ error: null,+ log_id: 'log_test',+ };+ },+ },+ });++ yield* cli(['search', 'read wiki contents']).pipe(Effect.provide(live));+ const output = (yield* MockConsole.getLines({ stripAnsi: true })).join('\n');++ expect(output).toContain(customSlug);+ expect(schemaRequestSlugs).toEqual([customSlug]);+ expect(output).toContain(+ `~/.composio/tool_definitions/${customSlug}.json`+ );+ })+ );+ }+ );+layer(TestLive(testLiveOptions))('[Given] multiple queries [Then] the CLI returns a batched JSON response',it => {