Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
| 1 | import { Effect, Option } from 'effect'; |
| 2 | import { actingUser } from 'src/commands/surface'; |
| 3 | import { ComposioClientSingleton } from 'src/services/composio-clients'; |
| 4 | import { idempotent } from 'src/services/composio-request'; |
| 5 | import { TerminalUI } from 'src/services/terminal-ui'; |
| 6 | |
| 7 | export type ListParams = { readonly toolkit: Option.Option<string> }; |
| 8 | |
| 9 | /** Teaching example: lists accounts through the CLI's native Effect client. */ |
| 10 | export const listAccounts = ({ toolkit }: ListParams) => |
| 11 | Effect.gen(function* () { |
| 12 | const ui = yield* TerminalUI; |
| 13 | const factory = yield* ComposioClientSingleton; |
| 14 | const { userId, project } = yield* actingUser(); |
| 15 | const client = yield* factory.getFor({ orgId: project.orgId, projectId: project.projectId }); |
| 16 | const result = yield* client.connectedAccounts.list( |
| 17 | { |
| 18 | user_ids: [userId], |
| 19 | toolkit_slugs: Option.map(toolkit, slug => [slug]).pipe(Option.getOrUndefined), |
| 20 | }, |
| 21 | idempotent |
| 22 | ); |
| 23 | yield* ui.output(JSON.stringify(result.items), { force: true }); |
| 24 | }); |