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): curate piped JSON output for toolkits info, validate redirect URL scheme

jkomyno00ddb3012f3b
diff --git a/ts/packages/cli/src/commands/connected-accounts/commands/connected-accounts.link.cmd.ts b/ts/packages/cli/src/commands/connected-accounts/commands/connected-accounts.link.cmd.ts
index 324701d72..6bb1ae0f7 100644
--- a/ts/packages/cli/src/commands/connected-accounts/commands/connected-accounts.link.cmd.ts
+++ b/ts/packages/cli/src/commands/connected-accounts/commands/connected-accounts.link.cmd.ts
@@ -43,15 +43,29 @@ const waitForActiveConnection = (
yield* ui.output(redirectUrl);
if (!noBrowser) {
- yield* Effect.tryPromise(() => open(redirectUrl, { wait: false })).pipe(
- Effect.catchAll(error =>
- Effect.gen(function* () {
- yield* Effect.logDebug('Failed to open browser:', error);
- yield* ui.log.warn('Could not open the browser automatically.');
- yield* ui.log.info('Tip: try using `--no-browser` and open the URL manually.');
- })
- )
- );
+ // Validate URL scheme before opening — prevent non-HTTPS redirects
+ let urlSchemeValid = false;
+ try {
+ const parsed = new URL(redirectUrl);
+ urlSchemeValid = parsed.protocol === 'https:' || parsed.protocol === 'http:';
+ } catch {
+ // Malformed URL — fall through to the warning below
+ }
+
+ if (!urlSchemeValid) {
+ yield* ui.log.warn(`Redirect URL has an unexpected scheme: ${redirectUrl}`);
+ yield* ui.log.info('Open the URL manually if you trust the source.');
+ } else {
+ yield* Effect.tryPromise(() => open(redirectUrl, { wait: false })).pipe(
+ Effect.catchAll(error =>
+ Effect.gen(function* () {
+ yield* Effect.logDebug('Failed to open browser:', error);
+ yield* ui.log.warn('Could not open the browser automatically.');
+ yield* ui.log.info('Tip: try using `--no-browser` and open the URL manually.');
+ })
+ )
+ );
+ }
}
// Poll until the connected account becomes ACTIVE
diff --git a/ts/packages/cli/src/commands/toolkits/commands/toolkits.info.cmd.ts b/ts/packages/cli/src/commands/toolkits/commands/toolkits.info.cmd.ts
index 1671d50d1..bea4ba643 100644
--- a/ts/packages/cli/src/commands/toolkits/commands/toolkits.info.cmd.ts
+++ b/ts/packages/cli/src/commands/toolkits/commands/toolkits.info.cmd.ts
@@ -4,7 +4,7 @@ import { ComposioClientSingleton, ComposioToolkitsRepository } from 'src/service
import { TerminalUI } from 'src/services/terminal-ui';
import { requireAuth } from 'src/effects/require-auth';
import { createToolRouterSession } from 'src/effects/create-tool-router-session';
-import { formatToolkitInfo } from '../format';
+import { formatToolkitInfo, formatToolkitInfoJson } from '../format';
const slug = Args.text({ name: 'slug' }).pipe(
Args.withDescription('Toolkit slug (e.g. "gmail")'),
@@ -108,6 +108,6 @@ export const toolkitsCmd$Info = Command.make('info', { slug, userId }, ({ slug,
`To list tools in this toolkit:\n> composio tools list --toolkits "${toolkit.slug}"`
);
- yield* ui.output(JSON.stringify(toolkit, null, 2));
+ yield* ui.output(formatToolkitInfoJson(toolkit));
})
).pipe(Command.withDescription('View details of a specific toolkit.'));
diff --git a/ts/packages/cli/src/commands/toolkits/format.ts b/ts/packages/cli/src/commands/toolkits/format.ts
index af1e6582c..a42966bbe 100644
--- a/ts/packages/cli/src/commands/toolkits/format.ts
+++ b/ts/packages/cli/src/commands/toolkits/format.ts
@@ -105,6 +105,33 @@ export function formatToolkitInfo(toolkit: SessionToolkitItem): string {
return lines.join('\n');
}
+/**
+ * Format a single session toolkit as JSON for piped output.
+ * Produces a stable, curated schema — does not leak the raw API response.
+ */
+export function formatToolkitInfoJson(toolkit: SessionToolkitItem): string {
+ return JSON.stringify(
+ {
+ name: toolkit.name,
+ slug: toolkit.slug,
+ description: toolkit.meta.description,
+ is_no_auth: toolkit.is_no_auth,
+ enabled: toolkit.enabled,
+ connected: toolkit.connected_account
+ ? {
+ status: toolkit.connected_account.status,
+ id: toolkit.connected_account.id,
+ auth_scheme: toolkit.connected_account.auth_config?.auth_scheme ?? null,
+ is_composio_managed: toolkit.connected_account.auth_config?.is_composio_managed ?? null,
+ }
+ : null,
+ composio_managed_auth_schemes: toolkit.composio_managed_auth_schemes,
+ },
+ null,
+ 2
+ );
+}
+
// ---------- Legacy format functions (used by non-migrated commands) ----------
/**