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 { APP_CONFIG } from 'src/config'; |
| 3 | |
| 4 | export const DEFAULT_CLI_INVOCATION_ORIGIN = 'cli'; |
| 5 | |
| 6 | export type CliInvocationContext = { |
| 7 | readonly invocationOrigin: string; |
| 8 | readonly parentRunId: string | undefined; |
| 9 | }; |
| 10 | |
| 11 | /** |
| 12 | * Who invoked this CLI process, and under which parent run. |
| 13 | * |
| 14 | * Both values arrive as the `COMPOSIO_CLI_INVOCATION_ORIGIN` / `COMPOSIO_CLI_PARENT_RUN_ID` |
| 15 | * handshake `composio run` and `install.sh` set on the processes they spawn, so `effect/Config` |
| 16 | * already is their injection point: a test overrides them with a config provider. |
| 17 | */ |
| 18 | export const cliInvocationContext: Effect.Effect<CliInvocationContext> = Effect.all({ |
| 19 | invocationOrigin: APP_CONFIG.CLI_INVOCATION_ORIGIN, |
| 20 | parentRunId: APP_CONFIG.CLI_PARENT_RUN_ID, |
| 21 | }).pipe( |
| 22 | Effect.orDie, |
| 23 | Effect.map(({ invocationOrigin, parentRunId }) => ({ |
| 24 | invocationOrigin: invocationOrigin ?? DEFAULT_CLI_INVOCATION_ORIGIN, |
| 25 | parentRunId, |
| 26 | })) |
| 27 | ); |