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 47 lines 1.59 KB
Raw
1 import { VERSION as clientLibraryVersion, type ClientIdentity } from '@composio/client/effect';
2 import { APP_VERSION } from 'src/constants';
3
4 const runtime = () =>
5 typeof Bun !== 'undefined'
6 ? { name: 'BUN', version: Bun.version }
7 : { name: 'NODEJS', version: process.versions.node };
8
9 /**
10 * The CLI as the API client reports it. The client sends the product headers
11 * from it, adds its own library headers, and detects the runtime version.
12 */
13 export const cliClientIdentity = (): ClientIdentity => ({
14 product: '@composio/cli',
15 version: APP_VERSION,
16 source: 'CLI',
17 framework: 'cli',
18 runtime: runtime().name,
19 });
20
21 /**
22 * Product attribution for first-party HTTP requests that do not go through an
23 * API client (analytics dispatch, the agents service, the companion runtime).
24 * API clients get the same attribution from {@link cliClientIdentity}.
25 */
26 export const cliRequestHeaders = (): Record<string, string> => ({
27 'x-framework': 'cli',
28 'x-source': 'CLI',
29 'x-runtime': runtime().name,
30 'x-client-runtime': runtime().name.toLowerCase(),
31 'x-runtime-version': runtime().version,
32 'x-sdk-version': APP_VERSION,
33 'x-client-provenance': '@composio/cli',
34 'x-client-version': APP_VERSION,
35 'x-client-language': 'typescript',
36 });
37
38 export const cliAnalyticsProvenance = (version = APP_VERSION) => ({
39 client_name: '@composio/cli',
40 client_version: version,
41 client_language: 'typescript',
42 client_runtime: runtime().name.toLowerCase(),
43 client_runtime_version: runtime().version,
44 client_library: '@composio/client',
45 client_library_version: clientLibraryVersion,
46 client_framework: 'cli',
47 });