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): use nano IDs in login and simplify org project list headers (#2773)

Musthaq Ahamad7b47f355c0d7
diff --git a/.changeset/flat-islands-cry.md b/.changeset/flat-islands-cry.md
new file mode 100644
index 000000000..a416ec5e4
--- /dev/null
+++ b/.changeset/flat-islands-cry.md
@@ -0,0 +1,5 @@
+---
+'@composio/cli': patch
+---
+
+Fix cli login command
diff --git a/ts/packages/cli/src/commands/init.cmd.ts b/ts/packages/cli/src/commands/init.cmd.ts
index 9528f7c28..d398190a8 100644
--- a/ts/packages/cli/src/commands/init.cmd.ts
+++ b/ts/packages/cli/src/commands/init.cmd.ts
@@ -201,7 +201,7 @@ const logEnvCreationDecodingError = (ui: TerminalUI) => (e: { cause?: unknown })
const selectDefaultProject = (params: {
projects: ReadonlyArray<OrgProject>;
defaultOrgId: string;
- defaultProjectId: string;
+ defaultProjectId?: string;
}): OrgProject | undefined => {
const { projects, defaultOrgId, defaultProjectId } = params;
const exactMatch = projects.find(p => p.org_id === defaultOrgId && p.id === defaultProjectId);
@@ -308,10 +308,8 @@ const initInteractiveFlow = (params: { composioDir: string; noBrowser: boolean;
// 2. Fetch projects
const orgIdValue = Option.getOrUndefined(ctx.data.orgId);
const projectIdValue = Option.getOrUndefined(ctx.data.projectId);
- if (!globalApiKey || !orgIdValue || !projectIdValue) {
- yield* ui.log.warn(
- 'No global API key, org ID, or project ID found. Please try `composio login` first.'
- );
+ if (!globalApiKey || !orgIdValue) {
+ yield* ui.log.warn('No global API key or org ID found. Please try `composio login` first.');
yield* ui.outro('');
return;
}
@@ -320,7 +318,6 @@ const initInteractiveFlow = (params: { composioDir: string; noBrowser: boolean;
baseURL: ctx.data.baseURL,
apiKey: globalApiKey,
orgId: orgIdValue,
- projectId: projectIdValue,
}).pipe(
Effect.catchTag('services/HttpServerError', e =>
Effect.gen(function* () {
diff --git a/ts/packages/cli/src/commands/login.cmd.ts b/ts/packages/cli/src/commands/login.cmd.ts
index aecd66e41..af91264df 100644
--- a/ts/packages/cli/src/commands/login.cmd.ts
+++ b/ts/packages/cli/src/commands/login.cmd.ts
@@ -93,8 +93,8 @@ const storeCredentials = (params: {
// Use session/info as the canonical source of org/project IDs when available.
// The initial IDs come from the linked session response (which may use session-level
// identifiers rather than the actual org/project IDs).
- const orgId = sessionInfo?.org_member.id ?? initialOrgId;
- const projectId = sessionInfo?.project.id ?? initialProjectId;
+ const orgId = sessionInfo?.project.org.id ?? initialOrgId;
+ const projectId = sessionInfo?.project.nano_id ?? initialProjectId;
if (sessionInfo) {
if (initialOrgId !== orgId) {
diff --git a/ts/packages/cli/src/services/composio-clients.ts b/ts/packages/cli/src/services/composio-clients.ts
index 5e42f6704..bbcc95774 100644
--- a/ts/packages/cli/src/services/composio-clients.ts
+++ b/ts/packages/cli/src/services/composio-clients.ts
@@ -719,14 +719,12 @@ export type OrgProjectListResponse = Schema.Schema.Type<typeof OrgProjectListRes
* @param params.baseURL - API base URL
* @param params.apiKey - UAK (sent as `x-user-api-key`)
* @param params.orgId - Organization ID (sent as `x-org-id`)
- * @param params.projectId - Project ID (sent as `x-project-id`)
* @param params.limit - Max projects to return (default 100)
*/
export const listOrgProjects = (params: {
baseURL: string;
apiKey: string;
orgId: string;
- projectId: string;
limit?: number;
}): Effect.Effect<OrgProjectListResponse, HttpServerError | HttpDecodingError> =>
Effect.gen(function* () {
@@ -741,7 +739,6 @@ export const listOrgProjects = (params: {
headers: {
'x-user-api-key': params.apiKey,
'x-org-id': params.orgId,
- 'x-project-id': params.projectId,
'User-Agent': '@composio/cli',
Accept: 'application/json',
'Content-Type': 'application/json',
@@ -1102,7 +1099,9 @@ export class ComposioClientSingleton extends Effect.Service<ComposioClientSingle
}
// Note: `api_key` is not required in every API request.
- const apiKey = ctx.data.apiKey.pipe(Option.getOrUndefined);
+ const rawApiKey = ctx.data.apiKey.pipe(Option.getOrUndefined);
+ const apiKey =
+ typeof rawApiKey === 'string' && rawApiKey.trim().length > 0 ? rawApiKey : undefined;
const baseURL = ctx.data.baseURL;
const resolvedProjectContext = yield* Option.match(projectContextOpt, {
onNone: () => Effect.succeed(Option.none()),
diff --git a/ts/packages/cli/test/src/commands/login.cmd.test.ts b/ts/packages/cli/test/src/commands/login.cmd.test.ts
index 38d34f3c4..17e61b9cf 100644
--- a/ts/packages/cli/test/src/commands/login.cmd.test.ts
+++ b/ts/packages/cli/test/src/commands/login.cmd.test.ts
@@ -12,6 +12,8 @@ import { cli, TestLive, MockConsole } from 'test/__utils__';
*/
const makeSessionInfoBody = (overrides?: {
orgId?: string;
+ orgNanoId?: string;
+ orgMemberId?: string;
orgName?: string;
projectId?: string;
projectNanoId?: string;
@@ -29,12 +31,12 @@ const makeSessionInfoBody = (overrides?: {
updated_at: '2026-01-01T00:00:00.000Z',
org: {
name: overrides?.orgName ?? 'Test Org',
- id: overrides?.orgId ?? 'org_test_456',
+ id: overrides?.orgNanoId ?? 'org_nano_456',
plan: 'free',
},
},
org_member: {
- id: overrides?.orgId ?? 'org_test_456',
+ id: overrides?.orgMemberId ?? 'org_member_uuid_456',
email: overrides?.email ?? '[email protected]',
name: overrides?.memberName ?? 'Test User',
role: 'admin',
@@ -77,8 +79,11 @@ describe('CLI: composio login', () => {
const fetchSpy = vi.spyOn(globalThis, 'fetch').mockResolvedValue(
mockFetchResponse(
makeSessionInfoBody({
- orgId: 'org_verified',
- projectId: 'proj_verified',
+ orgId: 'org_verified_uuid',
+ orgNanoId: 'org_verified_nano',
+ orgMemberId: 'org_member_verified_uuid',
+ projectId: 'proj_verified_uuid',
+ projectNanoId: 'proj_verified_nano',
projectName: 'Verified Project',
orgName: 'Verified Org',
@@ -113,6 +118,8 @@ describe('CLI: composio login', () => {
const lines = yield* MockConsole.getLines();
const output = lines.join('\n');
expect(output).toContain('[email protected]');
+ expect(output).toContain('"org_id":"org_verified_nano"');
+ expect(output).toContain('"project_id":"proj_verified_nano"');
expect(output).toContain("You're all set!");
})
);