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.

fix(cli): skip misleading connection tips for meta tools, sync META_TOOL_SLUGS with API type

jkomyno920f1aca7ec4
diff --git a/ts/packages/cli/src/commands/tools/commands/tools.execute.cmd.ts b/ts/packages/cli/src/commands/tools/commands/tools.execute.cmd.ts
index fe52e5b4c..87df8622c 100644
--- a/ts/packages/cli/src/commands/tools/commands/tools.execute.cmd.ts
+++ b/ts/packages/cli/src/commands/tools/commands/tools.execute.cmd.ts
@@ -83,14 +83,24 @@ const parseArguments = (raw: string) =>
/**
* Derive the toolkit slug from a tool slug.
* e.g. "GMAIL_CREATE_EMAIL_DRAFT" → "gmail", "GITHUB_GET_REPOS" → "github"
+ *
+ * Returns `undefined` for meta tool slugs (COMPOSIO_*) since they don't map
+ * to a real toolkit and would produce misleading connection tips.
*/
-const toolkitFromToolSlug = (toolSlug: string): string => {
+const toolkitFromToolSlug = (toolSlug: string): string | undefined => {
const idx = toolSlug.indexOf('_');
- return idx > 0 ? toolSlug.slice(0, idx).toLowerCase() : toolSlug.toLowerCase();
+ if (idx <= 0) return toolSlug.toLowerCase();
+ const prefix = toolSlug.slice(0, idx).toLowerCase();
+ // Meta tools (COMPOSIO_*) are internal and don't correspond to a real toolkit.
+ if (prefix === 'composio') return undefined;
+ return prefix;
};
const connectionTips = (toolSlug: string, userId: string) => {
const toolkit = toolkitFromToolSlug(toolSlug);
+ if (!toolkit) {
+ return `Retry: ${bold(`composio tools execute ${toolSlug} ...`)}`;
+ }
return [
`Link the toolkit first: ${bold(`composio connected-accounts link ${toolkit} --user-id ${userId}`)}`,
`Then retry: ${bold(`composio tools execute ${toolSlug} ...`)}`,
diff --git a/ts/packages/cli/src/services/tools-executor.ts b/ts/packages/cli/src/services/tools-executor.ts
index 4a85a07a7..29b0938af 100644
--- a/ts/packages/cli/src/services/tools-executor.ts
+++ b/ts/packages/cli/src/services/tools-executor.ts
@@ -61,8 +61,12 @@ export const ToolsExecutor = Context.GenericTag<ToolsExecutor>('services/ToolsEx
/**
* Meta tool slugs handled by `session.executeMeta` instead of `session.execute`.
+ *
+ * The `satisfies` constraint ensures this list stays in sync with the API's
+ * `SessionExecuteMetaParams['slug']` union — a compile error will surface if
+ * a slug is misspelled or if the API adds/removes a meta tool.
*/
-const META_TOOL_SLUGS: ReadonlySet<string> = new Set([
+const META_TOOL_SLUG_LIST = [
'COMPOSIO_SEARCH_TOOLS',
'COMPOSIO_MULTI_EXECUTE_TOOL',
'COMPOSIO_MANAGE_CONNECTIONS',
@@ -72,7 +76,9 @@ const META_TOOL_SLUGS: ReadonlySet<string> = new Set([
'COMPOSIO_GET_TOOL_SCHEMAS',
'COMPOSIO_UPSERT_RECIPE',
'COMPOSIO_GET_RECIPE',
-] as const);
+] as const satisfies ReadonlyArray<SessionExecuteMetaParams['slug']>;
+
+const META_TOOL_SLUGS: ReadonlySet<string> = new Set(META_TOOL_SLUG_LIST);
const isMetaToolSlug = (slug: string): slug is SessionExecuteMetaParams['slug'] =>
META_TOOL_SLUGS.has(slug);
diff --git a/ts/packages/cli/test/__utils__/services/test-layer.ts b/ts/packages/cli/test/__utils__/services/test-layer.ts
index bdc09028e..f2f2278f9 100644
--- a/ts/packages/cli/test/__utils__/services/test-layer.ts
+++ b/ts/packages/cli/test/__utils__/services/test-layer.ts
@@ -821,6 +821,10 @@ export const TestLayer = (input?: TestLiveInput) =>
ComposioClientSingleton,
new ComposioClientSingleton({
get: Effect.fn(function* () {
+ // Partial mock: only implements `toolRouter.session.*` methods used by
+ // CLI commands under test. The full Composio client interface is too
+ // large to mock completely for unit tests.
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
return mockComposioClient as any;
}),
})
diff --git a/ts/packages/cli/test/src/commands/tools/tools.execute.cmd.test.ts b/ts/packages/cli/test/src/commands/tools/tools.execute.cmd.test.ts
index 53b8f7880..a9eb7b8a7 100644
--- a/ts/packages/cli/test/src/commands/tools/tools.execute.cmd.test.ts
+++ b/ts/packages/cli/test/src/commands/tools/tools.execute.cmd.test.ts
@@ -316,6 +316,35 @@ describe('CLI: composio tools execute', () => {
);
});
+ // --- Meta tool error tests ---
+
+ layer(
+ TestLive({
+ baseConfigProvider: testConfigProvider,
+ stdin: { isTTY: true, data: '' },
+ toolsExecutor: {
+ failWith: new ActionExecuteConnectedAccountNotFoundError({
+ slug: 'ToolRouterV2_NoActiveConnection',
+ message: 'No active connection found for toolkit(s) in this session',
+ }),
+ },
+ })
+ )('[Given] meta tool NoActiveConnection error [Then] does not suggest "link composio"', it => {
+ it.scoped('omits connection tips for meta tool slugs', () =>
+ Effect.gen(function* () {
+ yield* cli(['tools', 'execute', 'COMPOSIO_SEARCH_TOOLS', '-d', '{"query":"email"}']).pipe(
+ Effect.catchAll(() => Effect.void)
+ );
+ const lines = yield* MockConsole.getLines({ stripAnsi: true });
+ const output = lines.join('\n');
+
+ expect(output).toContain('No active connection');
+ // Should NOT produce a misleading tip like "link composio"
+ expect(output).not.toContain('link composio');
+ })
+ );
+ });
+
// --- Edge case tests ---
layer(