From 557509c9d469efd9e913aca5f477477cdebcc87f Mon Sep 17 00:00:00 2001 From: Arjun <6592213+arkml@users.noreply.github.com> Date: Tue, 24 Mar 2026 22:57:28 +0530 Subject: [PATCH] fix agent notes not populating user email when Gmail connected via Composio ensureUserEmail() only tried direct Google OAuth, which doesn't work when Gmail is connected through Composio. Now tries Composio first. Co-Authored-By: Claude Opus 4.6 (1M context) --- .../core/src/knowledge/agent_notes.ts | 27 ++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/apps/x/packages/core/src/knowledge/agent_notes.ts b/apps/x/packages/core/src/knowledge/agent_notes.ts index 433423ac..5ec3e801 100644 --- a/apps/x/packages/core/src/knowledge/agent_notes.ts +++ b/apps/x/packages/core/src/knowledge/agent_notes.ts @@ -7,6 +7,8 @@ import { bus } from '../runs/bus.js'; import { serviceLogger } from '../services/service_logger.js'; import { loadUserConfig, updateUserEmail } from '../config/user_config.js'; import { GoogleClientFactory } from './google-client-factory.js'; +import { useComposioForGoogle, executeAction } from '../composio/client.js'; +import { composioAccountsRepo } from '../composio/repo.js'; import { loadAgentNotesState, saveAgentNotesState, @@ -209,7 +211,30 @@ async function ensureUserEmail(): Promise { return existing.email; } - // Try to get email from Gmail profile + // Try Composio (used when signed in or composio configured) + try { + if (await useComposioForGoogle()) { + const account = composioAccountsRepo.getAccount('gmail'); + if (account && account.status === 'ACTIVE') { + const result = await executeAction('GMAIL_GET_PROFILE', { + connected_account_id: account.id, + user_id: 'rowboat-user', + version: 'latest', + arguments: { user_id: 'me' }, + }); + const email = (result.data as Record)?.emailAddress as string | undefined; + if (email) { + updateUserEmail(email); + console.log(`[AgentNotes] Auto-populated user email via Composio: ${email}`); + return email; + } + } + } + } catch (error) { + console.log('[AgentNotes] Could not fetch email via Composio:', error instanceof Error ? error.message : error); + } + + // Try direct Google OAuth try { const auth = await GoogleClientFactory.getClient(); if (auth) {