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 } from 'effect'; |
| 2 | import { reportFailure } from 'src/effects/report-failure'; |
| 3 | import { AgentAuthError } from 'src/services/agents'; |
| 4 | import { TerminalUI } from 'src/services/terminal-ui'; |
| 5 | |
| 6 | /** Reports an `AgentAuthError` and its next steps on stderr and exits 1. */ |
| 7 | export const handleAgentAuthError = <E, R>(effect: Effect.Effect<void, E | AgentAuthError, R>) => |
| 8 | effect.pipe( |
| 9 | Effect.catchIf( |
| 10 | (error): error is AgentAuthError => error instanceof AgentAuthError, |
| 11 | error => |
| 12 | Effect.gen(function* () { |
| 13 | const ui = yield* TerminalUI; |
| 14 | return yield* reportFailure( |
| 15 | ui, |
| 16 | error.message, |
| 17 | error.nextSteps.length > 0 |
| 18 | ? ['Next steps:', ...error.nextSteps.map((step: string) => `- ${step}`)].join('\n') |
| 19 | : undefined |
| 20 | ); |
| 21 | }) |
| 22 | ) |
| 23 | ); |