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 { commandInputError } from 'src/commands/errors'; |
| 3 | import { resolveDeveloperResourceProject } from 'src/commands/surface'; |
| 4 | import { handleClientApiError } from 'src/effects/handle-http-error'; |
| 5 | import { ComposioToolkitsRepository } from 'src/services/composio-clients'; |
| 6 | import { CLIENT_API_ERROR_TAGS } from 'src/services/composio-errors'; |
| 7 | import { TerminalUI } from 'src/services/terminal-ui'; |
| 8 | import { formatAuthConfigInfo } from './auth-configs.info.format'; |
| 9 | |
| 10 | export type AuthConfigsInfoParams = { |
| 11 | readonly id: Option.Option<string>; |
| 12 | }; |
| 13 | |
| 14 | const invalidInput = commandInputError('dev auth-configs info'); |
| 15 | |
| 16 | /** |
| 17 | * Show one auth config of the developer project: the details on stderr, the JSON on stdout. A |
| 18 | * missing `<id>` fails with a `CommandInputError` before any request, and a developer project that cannot be found with `ProjectResolutionError`; an API failure is reported with a hint and exits 1. |
| 19 | */ |
| 20 | export const runAuthConfigsInfo = ({ id }: AuthConfigsInfoParams) => |
| 21 | Effect.gen(function* () { |
| 22 | const ui = yield* TerminalUI; |
| 23 | const repo = yield* ComposioToolkitsRepository; |
| 24 | |
| 25 | if (Option.isNone(id)) { |
| 26 | return yield* invalidInput( |
| 27 | 'Missing required argument: <id>\nTry specifying an auth config ID, e.g.:\n> composio dev auth-configs info "ac_1232323"\n\nTo find auth config IDs:\n> composio dev auth-configs list', |
| 28 | '<id>' |
| 29 | ); |
| 30 | } |
| 31 | |
| 32 | const idValue = id.value; |
| 33 | const project = yield* resolveDeveloperResourceProject; |
| 34 | |
| 35 | // Auth config IDs are opaque nanoids — "Did you mean?" suggestions would not be useful |
| 36 | const item = yield* ui |
| 37 | .withSpinner(`Fetching auth config "${idValue}"...`, repo.getAuthConfig(project, idValue)) |
| 38 | .pipe( |
| 39 | Effect.catchTag( |
| 40 | CLIENT_API_ERROR_TAGS, |
| 41 | handleClientApiError(ui, { |
| 42 | fallbackMessage: `Failed to fetch auth config "${idValue}".`, |
| 43 | hint: 'Browse available auth configs:\n> composio dev auth-configs list', |
| 44 | }) |
| 45 | ) |
| 46 | ); |
| 47 | |
| 48 | yield* ui.note(formatAuthConfigInfo(item), `Auth Config: ${item.name}`); |
| 49 | |
| 50 | yield* ui.output(JSON.stringify(item, null, 2)); |
| 51 | }); |