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 { notLoggedIn } from 'src/commands/errors'; |
| 3 | import { ComposioUserContext } from 'src/services/user-context'; |
| 4 | |
| 5 | /** |
| 6 | * Fails with `NotLoggedInError` when `~/.composio` holds no API key. A command never calls it |
| 7 | * itself: it declares `withCommandMeta({ requiresLogin: true })`, and the registration that runs |
| 8 | * it checks the login right after the command began (`src/commands/registration.ts`). |
| 9 | */ |
| 10 | export const assertLoggedIn = Effect.gen(function* () { |
| 11 | const ctx = yield* ComposioUserContext; |
| 12 | if (!ctx.isLoggedIn()) { |
| 13 | return yield* notLoggedIn(); |
| 14 | } |
| 15 | }); |