@devries-cameron20 / composio Mirror · read-only
Fork 0

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

Mirrored from https://github.com/Camo67/composio.git

Synced Nov 21, 04:45 UTC

next
ts 29 lines 1.06 KB
Raw
1 import { Effect } from 'effect';
2 import { handleAgentAuthError } from 'src/effects/handle-agent-auth-error';
3 import {
4 AGENT_SUMMARY_NOTE_TITLE,
5 fetchAgentWhoami,
6 resolveStoredAgentKey,
7 safeAgentSummary,
8 writeStoredAgentIdentity,
9 } from 'src/services/agents';
10 import { TerminalUI } from 'src/services/terminal-ui';
11 import { formatAgentWhoamiJson, formatAgentWhoamiNote } from './agent.whoami.format';
12
13 /**
14 * Refreshes the stored agent identity from the agents API, saves it, and prints its summary.
15 * A missing or human login is reported by `handleAgentAuthError` and exits 1.
16 */
17 export const runAgentWhoami = () =>
18 handleAgentAuthError(
19 Effect.gen(function* () {
20 const ui = yield* TerminalUI;
21 const agentKey = yield* resolveStoredAgentKey;
22 const identity = yield* fetchAgentWhoami(agentKey);
23 const saved = yield* writeStoredAgentIdentity(identity);
24 const summary = safeAgentSummary(saved);
25
26 yield* ui.note(formatAgentWhoamiNote(summary), AGENT_SUMMARY_NOTE_TITLE);
27 yield* ui.output(formatAgentWhoamiJson(summary));
28 })
29 );