@devries-cameron20 / composio Mirror · read-only / commits / 4c9d69743
Fork 0

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

Mirrored from https://github.com/Camo67/composio.git

Synced Nov 22, 02:00 UTC

Allow `execute --get-schema` without user context (#3032)

## Summary - Removed the execution-user requirement from schema fetch paths so `composio execute --get-schema` works without a configured user. - Added a dedicated schema-resolution flow that resolves project context and fetches tool definitions without checking connected accounts. - Extended CLI coverage for single-tool schema fetches when no test user ID is configured. ## Testing - `pnpm test -- tools.execute.cmd.test.ts` not run here. - Added/updated a test that runs `composio execute GITHUB_CREATE_AN_ISSUE --get-schema` without user context and verifies the schema output and cached schema file. - Not run: full package test suite.

Rahul Tarak committed Mar 26, 2026 at 22:53 UTC 4c9d69743d214d060e0ef7f1bef48fef3b274b19
5 files changed +207 -17
ts/packages/cli/src/commands/connected-accounts/connected-accounts.cmd.ts
+2
@@ -3,6 +3,7 @@ import { connectedAccountsCmd$List } from './commands/connected-accounts.list.cm
3 import { connectedAccountsCmd$Info } from './commands/connected-accounts.info.cmd';
4 import { connectedAccountsCmd$Whoami } from './commands/connected-accounts.whoami.cmd';
5 import { connectedAccountsCmd$Delete } from './commands/connected-accounts.delete.cmd';
6 +import { connectedAccountsCmd$Link } from './commands/connected-accounts.link.cmd';
7
8 /**
9 * CLI entry point for connected account management commands.
@@ -15,6 +16,7 @@ import { connectedAccountsCmd$Delete } from './commands/connected-accounts.delet
16 export const connectedAccountsCmd = Command.make('connected-accounts').pipe(
17 Command.withDescription('View and manage Composio connected accounts.'),
18 Command.withSubcommands([
19 + connectedAccountsCmd$Link,
20 connectedAccountsCmd$List,
21 connectedAccountsCmd$Info,
22 connectedAccountsCmd$Whoami,
ts/packages/cli/src/commands/projects/commands/projects.switch.cmd.ts
+1 -1
@@ -8,7 +8,7 @@ export const projectsCmd$Switch = Command.make('switch', {}).pipe(
8 Effect.gen(function* () {
9 const ui = yield* TerminalUI;
10 yield* ui.log.info(
11 - 'Run `composio dev init` in a directory to bind it to a developer project.'
11 + 'Global developer project switching is no longer supported. Run `composio dev init` in a directory to bind it to a developer project.'
12 );
13 })
14 )
ts/packages/cli/src/commands/tools/commands/tools.execute.cmd.ts
+135 -16
@@ -649,6 +649,20 @@ type ParsedParallelExecuteArgs = SharedRunToolsExecuteParams & {
649 readonly specs: ReadonlyArray<ParallelExecuteSpec>;
650 };
651
652 +type ParallelExecuteResult =
653 + | {
654 + readonly slug: string;
655 + readonly successful: true;
656 + readonly version: string | null;
657 + readonly schemaPath: string;
658 + readonly inputSchema: Record<string, unknown>;
659 + }
660 + | {
661 + readonly slug: string;
662 + readonly successful: false;
663 + readonly error: string;
664 + };
665 +
666 type ResolvedExecuteContext = {
667 readonly ui: TerminalUI;
668 readonly executor: ToolsExecutor;
@@ -664,6 +678,16 @@ type ResolvedExecuteContext = {
678 readonly executeOutputDir?: string;
679 };
680
681 +type ResolvedSchemaContext = {
682 + readonly ui: TerminalUI;
683 + readonly resolvedProject: {
684 + readonly orgId: string;
685 + readonly projectId: string;
686 + readonly projectType: 'CONSUMER' | 'DEVELOPER';
687 + readonly consumerUserId?: string;
688 + };
689 +};
690 +
691 const emitCachedSchema = (
692 ui: TerminalUI,
693 slug: string,
@@ -757,6 +781,21 @@ const resolveExecuteContext = (params: RunToolsExecuteParams) =>
781 } satisfies ResolvedExecuteContext;
782 });
783
784 +const resolveSchemaContext = (params: SharedRunToolsExecuteParams) =>
785 + Effect.gen(function* () {
786 + const resolvedProject = yield* resolveCommandProject({
787 + mode: params.projectMode,
788 + projectName:
789 + params.surface === 'root' ? undefined : Option.getOrUndefined(params.projectName),
790 + }).pipe(Effect.mapError(formatResolveCommandProjectError));
791 + const ui = yield* TerminalUI;
792 +
793 + return {
794 + ui,
795 + resolvedProject,
796 + } satisfies ResolvedSchemaContext;
797 + });
798 +
799 const runConnectedToolkitFailFast = (params: {
800 readonly slug: string;
801 readonly surface: 'root' | 'dev';
@@ -1112,8 +1151,8 @@ const runToolsExecute = (params: RunToolsExecuteParams) =>
1151 Effect.gen(function* () {
1152 if (!(yield* requireAuth)) return;
1153
1115 - const context = yield* resolveExecuteContext(params);
1154 if (params.getSchema) {
1155 + const context = yield* resolveSchemaContext(params);
1156 const definition = yield* getOrFetchToolInputDefinition(params.slug, {
1157 orgId: context.resolvedProject.orgId,
1158 projectId: context.resolvedProject.projectId,
@@ -1121,7 +1160,7 @@ const runToolsExecute = (params: RunToolsExecuteParams) =>
1160 Effect.tapError(error =>
1161 emitExecuteFailureTelemetry({
1162 toolSlug: params.slug,
1124 - args: context.args,
1163 + args: {},
1164 error,
1165 surface: params.surface,
1166 projectMode: params.projectMode,
@@ -1133,6 +1172,8 @@ const runToolsExecute = (params: RunToolsExecuteParams) =>
1172 return;
1173 }
1174
1175 + const context = yield* resolveExecuteContext(params);
1176 +
1177 yield* runConnectedToolkitFailFast({
1178 slug: params.slug,
1179 surface: params.surface,
@@ -1367,10 +1408,102 @@ const checkConnectedToolkitOrFail = (params: {
1408 }
1409 });
1410
1411 +const runParallelSchemaFetchFromParsed = (params: ParsedParallelExecuteArgs) =>
1412 + Effect.gen(function* () {
1413 + const contexts = yield* Effect.forEach(
1414 + params.specs,
1415 + () =>
1416 + resolveSchemaContext({
1417 + userId: params.userId,
1418 + projectName: params.projectName,
1419 + surface: params.surface,
1420 + projectMode: params.projectMode,
1421 + getSchema: params.getSchema,
1422 + dryRun: params.dryRun,
1423 + skipConnectionCheck: params.skipConnectionCheck,
1424 + skipToolParamsCheck: params.skipToolParamsCheck,
1425 + skipChecks: params.skipChecks,
1426 + }),
1427 + { concurrency: 'unbounded' }
1428 + );
1429 + const entries = contexts.map((context, index) => ({
1430 + context,
1431 + spec: params.specs[index]!,
1432 + }));
1433 +
1434 + const ui = contexts[0]?.ui;
1435 + const results = yield* Effect.forEach(
1436 + entries,
1437 + ({ context, spec }) =>
1438 + Effect.gen(function* () {
1439 + const definition = yield* getOrFetchToolInputDefinition(spec.slug, {
1440 + orgId: context.resolvedProject.orgId,
1441 + projectId: context.resolvedProject.projectId,
1442 + });
1443 + return {
1444 + slug: spec.slug,
1445 + successful: true,
1446 + version: definition.version,
1447 + schemaPath: definition.schemaPath,
1448 + inputSchema: definition.schema,
1449 + } satisfies Extract<
1450 + ParallelExecuteResult,
1451 + { readonly inputSchema: Record<string, unknown> }
1452 + >;
1453 + }).pipe(
1454 + Effect.catchAll(error => {
1455 + const mapped = mapComposioError({ error, toolSlug: spec.slug });
1456 + return Effect.succeed({
1457 + slug: spec.slug,
1458 + successful: false,
1459 + error: mapped.message,
1460 + } satisfies Extract<ParallelExecuteResult, { readonly successful: false }>);
1461 + })
1462 + ),
1463 + { concurrency: 'unbounded' }
1464 + );
1465 +
1466 + if (ui) {
1467 + for (const result of results) {
1468 + if (!result.successful) {
1469 + yield* ui.log.error(`[${result.slug}] ${result.error}`);
1470 + continue;
1471 + }
1472 +
1473 + yield* ui.log.step(`[${result.slug}] Schema fetched: ${result.schemaPath}`);
1474 + }
1475 +
1476 + const successful = results.every(result => result.successful);
1477 + yield* ui.log.message(
1478 + `Parallel execute completed: ${results.filter(result => result.successful).length}/${results.length} successful`
1479 + );
1480 + yield* ui.output(
1481 + JSON.stringify(
1482 + {
1483 + successful,
1484 + parallel: true,
1485 + results,
1486 + },
1487 + ciRedactReplacer,
1488 + 2
1489 + )
1490 + );
1491 + if (!successful) {
1492 + return yield* Effect.fail(
1493 + new ToolExecutionError('One or more parallel tool executions failed.')
1494 + );
1495 + }
1496 + }
1497 + });
1498 +
1499 const runParallelToolsExecuteFromParsed = (params: ParsedParallelExecuteArgs) =>
1500 Effect.gen(function* () {
1501 if (!(yield* requireAuth)) return;
1502
1503 + if (params.getSchema) {
1504 + return yield* runParallelSchemaFetchFromParsed(params);
1505 + }
1506 +
1507 const contexts = yield* Effect.forEach(
1508 params.specs,
1509 spec =>
@@ -1402,20 +1535,6 @@ const runParallelToolsExecuteFromParsed = (params: ParsedParallelExecuteArgs) =>
1535 const toolSlug = spec.slug;
1536
1537 try {
1405 - if (params.getSchema) {
1406 - const definition = yield* getOrFetchToolInputDefinition(toolSlug, {
1407 - orgId: context.resolvedProject.orgId,
1408 - projectId: context.resolvedProject.projectId,
1409 - });
1410 - return {
1411 - slug: toolSlug,
1412 - successful: true,
1413 - version: definition.version,
1414 - schemaPath: definition.schemaPath,
1415 - inputSchema: definition.schema,
1416 - };
1417 - }
1418 -
1538 yield* checkConnectedToolkitOrFail({
1539 slug: toolSlug,
1540 resolvedProject: context.resolvedProject,
ts/packages/cli/src/commands/triggers/triggers.cmd.ts
+2
@@ -6,6 +6,7 @@ import { triggersCmd$Create } from './commands/triggers.create.cmd';
6 import { triggersCmd$Enable } from './commands/triggers.enable.cmd';
7 import { triggersCmd$Disable } from './commands/triggers.disable.cmd';
8 import { triggersCmd$Delete } from './commands/triggers.delete.cmd';
9 +import { triggersCmd$Listen } from './commands/triggers.listen.cmd';
10
11 /**
12 * CLI entry point for realtime trigger commands.
@@ -18,6 +19,7 @@ import { triggersCmd$Delete } from './commands/triggers.delete.cmd';
19 export const triggersCmd = Command.make('triggers').pipe(
20 Command.withDescription('Inspect and subscribe to trigger events.'),
21 Command.withSubcommands([
22 + triggersCmd$Listen,
23 triggersCmd$List,
24 triggersCmd$Info,
25 triggersCmd$Status,
ts/packages/cli/test/src/commands/tools/tools.execute.cmd.test.ts
+67
@@ -664,6 +664,73 @@ describe('CLI: composio execute', () => {
664 );
665 });
666
667 + layer(
668 + TestLive({
669 + baseConfigProvider: testConfigProvider,
670 + fixture: 'user-config-with-global-context',
671 + stdin: { isTTY: true, data: '' },
672 + toolkitsData: {
673 + tools: [
674 + {
675 + name: 'Create Issue',
676 + slug: 'GITHUB_CREATE_AN_ISSUE',
677 + description: 'Create a GitHub issue',
678 + tags: ['github'],
679 + available_versions: ['20260316_00'],
680 + input_parameters: {
681 + type: 'object',
682 + properties: {
683 + owner: { type: 'string' },
684 + repo: { type: 'string' },
685 + title: { type: 'string' },
686 + body: { type: 'string' },
687 + },
688 + },
689 + output_parameters: {
690 + type: 'object',
691 + properties: {
692 + html_url: { type: 'string' },
693 + },
694 + },
695 + },
696 + ],
697 + },
698 + })
699 + )(
700 + '[Given] composio execute --get-schema without a configured test user id [Then] it still works',
701 + it => {
702 + it.scoped('does not require execution user context for schema fetches', () =>
703 + Effect.gen(function* () {
704 + const cacheDir = yield* setupCacheDir;
705 + const schemaPath = `${cacheDir}/tool_definitions/GITHUB_CREATE_AN_ISSUE.json`;
706 +
707 + yield* cli(['execute', 'GITHUB_CREATE_AN_ISSUE', '--get-schema']);
708 + const lines = yield* MockConsole.getLines({ stripAnsi: true });
709 + const output = parseLastJson(lines) as unknown as {
710 + slug: string;
711 + version: string | null;
712 + schemaPath: string;
713 + inputSchema: Record<string, unknown>;
714 + };
715 +
716 + expect(output.slug).toBe('GITHUB_CREATE_AN_ISSUE');
717 + expect(output.version).toBe('20260316_00');
718 + expect(output.schemaPath).toBe(schemaPath);
719 + expect(output.inputSchema).toEqual({
720 + type: 'object',
721 + properties: {
722 + owner: { type: 'string' },
723 + repo: { type: 'string' },
724 + title: { type: 'string' },
725 + body: { type: 'string' },
726 + },
727 + });
728 + expect(fs.existsSync(schemaPath)).toBe(true);
729 + })
730 + );
731 + }
732 + );
733 +
734 layer(
735 TestLive({
736 baseConfigProvider: testConfigProvider,