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 21, 06:00 UTC
| 1 | import type { ConnectedAccountItem } from 'src/models/connected-accounts'; |
| 2 | import { bold } from 'src/ui/colors'; |
| 3 | import { redact } from 'src/ui/redact'; |
| 4 | import { formatStatus } from '../format'; |
| 5 | |
| 6 | // --- stderr ----------------------------------------------------------------------------------- |
| 7 | |
| 8 | /** The warning for an account that is not ACTIVE. */ |
| 9 | export const inactiveStatusMessage = (status: string) => |
| 10 | `This connected account has status ${status}.`; |
| 11 | |
| 12 | /** The title of the note `formatConnectedAccountWhoami` fills. */ |
| 13 | export const connectedAccountWhoamiTitle = (item: ConnectedAccountItem) => |
| 14 | `whoami: ${item.toolkit.slug}`; |
| 15 | |
| 16 | /** |
| 17 | * Format a connected account for the whoami display (compact 6-field subset). |
| 18 | */ |
| 19 | export function formatConnectedAccountWhoami(item: ConnectedAccountItem): string { |
| 20 | const lines: string[] = []; |
| 21 | lines.push(`${bold('Id:')} ${redact({ value: item.id, prefix: 'con_' })}`); |
| 22 | lines.push(`${bold('Alias:')} ${item.alias || '-'}`); |
| 23 | lines.push(`${bold('Word Id:')} ${item.word_id || '-'}`); |
| 24 | lines.push(`${bold('Status:')} ${formatStatus(item.status)}`); |
| 25 | lines.push(`${bold('Toolkit:')} ${item.toolkit.slug}`); |
| 26 | lines.push(`${bold('User Id:')} ${item.user_id}`); |
| 27 | lines.push(`${bold('Auth Config:')} ${redact({ value: item.auth_config.id, prefix: 'ac_' })}`); |
| 28 | lines.push(`${bold('Auth Scheme:')} ${item.auth_config.auth_scheme}`); |
| 29 | return lines.join('\n'); |
| 30 | } |
| 31 | |
| 32 | // --- stdout ----------------------------------------------------------------------------------- |
| 33 | |
| 34 | /** Who the account is connected as, as JSON. */ |
| 35 | export const formatConnectedAccountWhoamiJson = (item: ConnectedAccountItem) => |
| 36 | JSON.stringify( |
| 37 | { |
| 38 | id: item.id, |
| 39 | alias: item.alias, |
| 40 | word_id: item.word_id, |
| 41 | toolkit: item.toolkit.slug, |
| 42 | user_id: item.user_id, |
| 43 | status: item.status, |
| 44 | auth_config_id: item.auth_config.id, |
| 45 | auth_scheme: item.auth_config.auth_scheme, |
| 46 | }, |
| 47 | null, |
| 48 | 2 |
| 49 | ); |