@devries-cameron20 / composio-1 / commits / 7b47f355c
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.

fix(cli): use nano IDs in login and simplify org project list headers (#2773)

Musthaq Ahamad committed Feb 25, 2026 at 23:08 UTC 7b47f355c0d765d10dc1b30b8c04959b3859a740
5 files changed +24 -16
.changeset/flat-islands-cry.md new
+5
@@ -0,0 +1,5 @@
1 +---
2 +'@composio/cli': patch
3 +---
4 +
5 +Fix cli login command
ts/packages/cli/src/commands/init.cmd.ts
+3 -6
@@ -201,7 +201,7 @@ const logEnvCreationDecodingError = (ui: TerminalUI) => (e: { cause?: unknown })
201 const selectDefaultProject = (params: {
202 projects: ReadonlyArray<OrgProject>;
203 defaultOrgId: string;
204 - defaultProjectId: string;
204 + defaultProjectId?: string;
205 }): OrgProject | undefined => {
206 const { projects, defaultOrgId, defaultProjectId } = params;
207 const exactMatch = projects.find(p => p.org_id === defaultOrgId && p.id === defaultProjectId);
@@ -308,10 +308,8 @@ const initInteractiveFlow = (params: { composioDir: string; noBrowser: boolean;
308 // 2. Fetch projects
309 const orgIdValue = Option.getOrUndefined(ctx.data.orgId);
310 const projectIdValue = Option.getOrUndefined(ctx.data.projectId);
311 - if (!globalApiKey || !orgIdValue || !projectIdValue) {
312 - yield* ui.log.warn(
313 - 'No global API key, org ID, or project ID found. Please try `composio login` first.'
314 - );
311 + if (!globalApiKey || !orgIdValue) {
312 + yield* ui.log.warn('No global API key or org ID found. Please try `composio login` first.');
313 yield* ui.outro('');
314 return;
315 }
@@ -320,7 +318,6 @@ const initInteractiveFlow = (params: { composioDir: string; noBrowser: boolean;
318 baseURL: ctx.data.baseURL,
319 apiKey: globalApiKey,
320 orgId: orgIdValue,
323 - projectId: projectIdValue,
321 }).pipe(
322 Effect.catchTag('services/HttpServerError', e =>
323 Effect.gen(function* () {
ts/packages/cli/src/commands/login.cmd.ts
+2 -2
@@ -93,8 +93,8 @@ const storeCredentials = (params: {
93 // Use session/info as the canonical source of org/project IDs when available.
94 // The initial IDs come from the linked session response (which may use session-level
95 // identifiers rather than the actual org/project IDs).
96 - const orgId = sessionInfo?.org_member.id ?? initialOrgId;
97 - const projectId = sessionInfo?.project.id ?? initialProjectId;
96 + const orgId = sessionInfo?.project.org.id ?? initialOrgId;
97 + const projectId = sessionInfo?.project.nano_id ?? initialProjectId;
98
99 if (sessionInfo) {
100 if (initialOrgId !== orgId) {
ts/packages/cli/src/services/composio-clients.ts
+3 -4
@@ -719,14 +719,12 @@ export type OrgProjectListResponse = Schema.Schema.Type<typeof OrgProjectListRes
719 * @param params.baseURL - API base URL
720 * @param params.apiKey - UAK (sent as `x-user-api-key`)
721 * @param params.orgId - Organization ID (sent as `x-org-id`)
722 - * @param params.projectId - Project ID (sent as `x-project-id`)
722 * @param params.limit - Max projects to return (default 100)
723 */
724 export const listOrgProjects = (params: {
725 baseURL: string;
726 apiKey: string;
727 orgId: string;
729 - projectId: string;
728 limit?: number;
729 }): Effect.Effect<OrgProjectListResponse, HttpServerError | HttpDecodingError> =>
730 Effect.gen(function* () {
@@ -741,7 +739,6 @@ export const listOrgProjects = (params: {
739 headers: {
740 'x-user-api-key': params.apiKey,
741 'x-org-id': params.orgId,
744 - 'x-project-id': params.projectId,
742 'User-Agent': '@composio/cli',
743 Accept: 'application/json',
744 'Content-Type': 'application/json',
@@ -1102,7 +1099,9 @@ export class ComposioClientSingleton extends Effect.Service<ComposioClientSingle
1099 }
1100
1101 // Note: `api_key` is not required in every API request.
1105 - const apiKey = ctx.data.apiKey.pipe(Option.getOrUndefined);
1102 + const rawApiKey = ctx.data.apiKey.pipe(Option.getOrUndefined);
1103 + const apiKey =
1104 + typeof rawApiKey === 'string' && rawApiKey.trim().length > 0 ? rawApiKey : undefined;
1105 const baseURL = ctx.data.baseURL;
1106 const resolvedProjectContext = yield* Option.match(projectContextOpt, {
1107 onNone: () => Effect.succeed(Option.none()),
ts/packages/cli/test/src/commands/login.cmd.test.ts
+11 -4
@@ -12,6 +12,8 @@ import { cli, TestLive, MockConsole } from 'test/__utils__';
12 */
13 const makeSessionInfoBody = (overrides?: {
14 orgId?: string;
15 + orgNanoId?: string;
16 + orgMemberId?: string;
17 orgName?: string;
18 projectId?: string;
19 projectNanoId?: string;
@@ -29,12 +31,12 @@ const makeSessionInfoBody = (overrides?: {
31 updated_at: '2026-01-01T00:00:00.000Z',
32 org: {
33 name: overrides?.orgName ?? 'Test Org',
32 - id: overrides?.orgId ?? 'org_test_456',
34 + id: overrides?.orgNanoId ?? 'org_nano_456',
35 plan: 'free',
36 },
37 },
38 org_member: {
37 - id: overrides?.orgId ?? 'org_test_456',
39 + id: overrides?.orgMemberId ?? 'org_member_uuid_456',
40 email: overrides?.email ?? 'test@composio.dev',
41 name: overrides?.memberName ?? 'Test User',
42 role: 'admin',
@@ -77,8 +79,11 @@ describe('CLI: composio login', () => {
79 const fetchSpy = vi.spyOn(globalThis, 'fetch').mockResolvedValue(
80 mockFetchResponse(
81 makeSessionInfoBody({
80 - orgId: 'org_verified',
81 - projectId: 'proj_verified',
82 + orgId: 'org_verified_uuid',
83 + orgNanoId: 'org_verified_nano',
84 + orgMemberId: 'org_member_verified_uuid',
85 + projectId: 'proj_verified_uuid',
86 + projectNanoId: 'proj_verified_nano',
87 email: 'verified@composio.dev',
88 projectName: 'Verified Project',
89 orgName: 'Verified Org',
@@ -113,6 +118,8 @@ describe('CLI: composio login', () => {
118 const lines = yield* MockConsole.getLines();
119 const output = lines.join('\n');
120 expect(output).toContain('verified@composio.dev');
121 + expect(output).toContain('"org_id":"org_verified_nano"');
122 + expect(output).toContain('"project_id":"proj_verified_nano"');
123 expect(output).toContain("You're all set!");
124 })
125 );