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 title of the note `formatConnectedAccountInfo` fills. */ |
| 9 | export const connectedAccountInfoTitle = (item: ConnectedAccountItem) => |
| 10 | `Connected Account: ${item.toolkit.slug}`; |
| 11 | |
| 12 | /** |
| 13 | * Format a single connected account for interactive display. |
| 14 | */ |
| 15 | export function formatConnectedAccountInfo(item: ConnectedAccountItem): string { |
| 16 | const lines: string[] = []; |
| 17 | |
| 18 | lines.push(`${bold('Id:')} ${redact({ value: item.id, prefix: 'con_' })}`); |
| 19 | lines.push(`${bold('Alias:')} ${item.alias || '-'}`); |
| 20 | lines.push(`${bold('Word Id:')} ${item.word_id || '-'}`); |
| 21 | lines.push(`${bold('Status:')} ${formatStatus(item.status)}`); |
| 22 | |
| 23 | if (item.status_reason) { |
| 24 | lines.push(`${bold('Status Reason:')} ${item.status_reason}`); |
| 25 | } |
| 26 | |
| 27 | lines.push(`${bold('Toolkit:')} ${item.toolkit.slug}`); |
| 28 | lines.push(`${bold('User Id:')} ${item.user_id}`); |
| 29 | lines.push( |
| 30 | `${bold('Auth Config:')} ${redact({ value: item.auth_config.id, prefix: 'ac_' })} (${item.auth_config.auth_scheme})` |
| 31 | ); |
| 32 | lines.push(`${bold('Composio Managed:')} ${item.auth_config.is_composio_managed ? 'Yes' : 'No'}`); |
| 33 | lines.push(`${bold('Disabled:')} ${item.is_disabled ? 'Yes' : 'No'}`); |
| 34 | lines.push(`${bold('Created:')} ${item.created_at}`); |
| 35 | lines.push(`${bold('Updated:')} ${item.updated_at}`); |
| 36 | |
| 37 | if (item.test_request_endpoint) { |
| 38 | lines.push(`${bold('Test Endpoint:')} ${item.test_request_endpoint}`); |
| 39 | } |
| 40 | |
| 41 | return lines.join('\n'); |
| 42 | } |
| 43 | |
| 44 | // --- stdout ----------------------------------------------------------------------------------- |
| 45 | |
| 46 | /** The whole decoded account, as JSON. */ |
| 47 | export const formatConnectedAccountInfoJson = (item: ConnectedAccountItem) => |
| 48 | JSON.stringify(item, null, 2); |