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 { buildRootCommand } from 'src/commands'; |
| 2 | import { identityAt } from 'src/invocation/command-identity'; |
| 3 | import { Option } from 'effect'; |
| 4 | import { createCliCommandTelemetryContext } from 'src/analytics/events'; |
| 5 | import type { TelemetryFamily } from 'src/analytics/types'; |
| 6 | import { resolveCommandMeta } from 'src/invocation/command-identity'; |
| 7 | import { |
| 8 | DEFAULT_CLI_INVOCATION_ORIGIN, |
| 9 | type CliInvocationContext, |
| 10 | } from 'src/services/runtime-cli-context'; |
| 11 | |
| 12 | /** |
| 13 | * The lifecycle telemetry context of `args` (argv after `composio`) run as the command |
| 14 | * registration `path` of `family`, with the input `effect/cli` parsed for it. `input` omitted |
| 15 | * means nothing was parsed, as for `--help`, `--version`, and parse failures. |
| 16 | */ |
| 17 | export const commandTelemetryContext = ( |
| 18 | args: ReadonlyArray<string>, |
| 19 | options: { |
| 20 | readonly path: ReadonlyArray<string>; |
| 21 | readonly family?: TelemetryFamily; |
| 22 | readonly input?: unknown; |
| 23 | readonly cliVersion?: string; |
| 24 | readonly terminal?: { readonly stdoutIsTTY: boolean; readonly stderrIsTTY: boolean }; |
| 25 | readonly invocation?: CliInvocationContext; |
| 26 | } |
| 27 | ) => |
| 28 | createCliCommandTelemetryContext({ |
| 29 | argv: ['/bin/bun', '/cli/bin.ts', ...args], |
| 30 | cliVersion: options.cliVersion ?? '1.2.3', |
| 31 | terminal: options.terminal ?? { stdoutIsTTY: false, stderrIsTTY: false }, |
| 32 | invocation: options.invocation ?? { |
| 33 | invocationOrigin: DEFAULT_CLI_INVOCATION_ORIGIN, |
| 34 | parentRunId: undefined, |
| 35 | }, |
| 36 | identity: { |
| 37 | path: options.path, |
| 38 | meta: resolveCommandMeta(undefined, { |
| 39 | telemetryFamily: options.family ?? 'command', |
| 40 | telemetryInput: identityAt( |
| 41 | buildRootCommand({ isDevModeEnabled: true, isExperimentalFeatureEnabled: () => true }), |
| 42 | ['composio', options.family ?? options.path[0] ?? ''] |
| 43 | ).meta.telemetryInput, |
| 44 | }), |
| 45 | }, |
| 46 | input: options.input === undefined ? Option.none() : Option.some(options.input), |
| 47 | startedAt: Date.now(), |
| 48 | }); |