@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 41 lines 1.59 KB
Raw
1 import { Config } from 'effect';
2 import * as constants from 'src/constants';
3 import { optionalString, withFallback } from './env';
4
5 export interface GitHubConfig {
6 readonly apiBaseUrl: string;
7 readonly owner: string;
8 readonly repo: string;
9 /** Pins the release to fetch instead of resolving the latest one. */
10 readonly tag: string | undefined;
11 /** Avoids GitHub API rate limits during development. */
12 readonly accessToken: string | undefined;
13 }
14
15 const githubConfig = (
16 read: (name: string) => Config.Config<string | undefined>
17 ): Config.Config<GitHubConfig> =>
18 Config.all({
19 apiBaseUrl: withFallback(read('API_BASE_URL'), constants.GITHUB_REPO.API_BASE_URL),
20 owner: withFallback(read('OWNER'), constants.GITHUB_REPO.OWNER),
21 repo: withFallback(read('REPO'), constants.GITHUB_REPO.REPO),
22 tag: read('TAG'),
23 accessToken: read('ACCESS_TOKEN'),
24 });
25
26 const prefixed = (name: string) => optionalString(`COMPOSIO_GITHUB_${name}`);
27
28 // The binary build workflow and CI speak the unprefixed `GITHUB_*` contract, which wins.
29 const unprefixedFirst = (name: string) =>
30 Config.all({ ci: optionalString(`GITHUB_${name}`), prefixed: prefixed(name) }).pipe(
31 Config.map(({ ci, prefixed }) => ci ?? prefixed)
32 );
33
34 /**
35 * Where `composio upgrade`, `composio setup skill`, and the update check fetch releases from.
36 * The `COMPOSIO_GITHUB_*` overrides are documented in the README.
37 */
38 export const GITHUB_CONFIG = githubConfig(prefixed);
39
40 /** The same settings for self-repair of a packaged install, honoring the workflow's `GITHUB_*`. */
41 export const GITHUB_REPAIR_CONFIG = githubConfig(unprefixedFirst);