Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.

next
ts 26 lines 994 Bytes
Raw
1 import { Effect } from 'effect';
2 import { handleAgentAuthError } from 'src/effects/handle-agent-auth-error';
3 import { claimAgent, resolveStoredAgentKey } from 'src/services/agents';
4 import { TerminalUI } from 'src/services/terminal-ui';
5 import { claimInviteSentMessage, formatAgentClaimJson } from './agent.claim.format';
6
7 /** The argument of `composio agent claim`. */
8 export type AgentClaimParams = {
9 readonly email: string;
10 };
11
12 /**
13 * Invites `email` as an admin of the stored agent's org. A missing or human login is reported
14 * by `handleAgentAuthError` and exits 1.
15 */
16 export const runAgentClaim = ({ email }: AgentClaimParams) =>
17 handleAgentAuthError(
18 Effect.gen(function* () {
19 const ui = yield* TerminalUI;
20 const agentKey = yield* resolveStoredAgentKey;
21 const result = yield* claimAgent({ agentKey, email });
22
23 yield* ui.log.success(claimInviteSentMessage(result.email ?? email));
24 yield* ui.output(formatAgentClaimJson(result, email));
25 })
26 );