@devries-cameron20 / composio Mirror · read-only / commits / 1bb22d38c
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, 09:45 UTC

refactor(cli): centralize environment config in `src/config` (#4802)

This PR: - declares every environment variable the CLI reads, under its full name, in `ts/packages/cli/src/config`: `APP_CONFIG` (user-facing `COMPOSIO_*`), `DEBUG_CONFIG` (`*_DEBUG`, `DEBUG_OVERRIDE_*`, `FORCE_USE_CACHE`), `TELEMETRY_CONFIG` (opt-outs, PostHog target), `HOST_CONFIG` (shell, CI, package manager, agent host), and `GITHUB_CONFIG` / `GITHUB_REPAIR_CONFIG` - removes the `COMPOSIO_`-prefixing `ConfigProvider.mapInput` wrapper, the raw-provider bypass (`loadHostConfig` / `getBaseConfigProvider`), and `src/services/config.ts`; everything reads the ambient `ConfigProvider`, so a test configures the CLI with `ConfigProvider.fromEnvRecord({ COMPOSIO_X: '...' })` and nothing else - replaces the ad-hoc env readers in `analytics/dispatch.ts`, `install.cmd.ts`, `run-companion-modules.ts`, `update-check.ts`, `agent-host-env.ts`, and `toolkit-version-overrides.ts` with catalog reads, and unifies the two GitHub config shapes into one `GitHubConfig` (`apiBaseUrl`, `owner`, `repo`, `tag`, `accessToken`) - normalizes optional values: every optional setting is `optionalString` (trimmed, blank → `undefined`) instead of a mix of `Config.option(Config.String(...))`, `Option`, and `string | undefined`; shared readers live in `src/config/env.ts` - `TestLive` now defaults to `hostOnlyEnvConfigProvider`: the live host environment (`CI`, `VITEST`, `PATH`, agent markers) minus any `COMPOSIO_*` variable, which is what the old bypass gave tests implicitly; `test/src/config/*.test.ts` replaces `config.test.ts` with one small suite per catalog - behavior changes, all deliberate: - analytics now resolves the API base URL exactly like `ComposioUserContext` (`COMPOSIO_BASE_URL`, else the `COMPOSIO_ENVIRONMENT` default) instead of falling back to the persisted `base_url`, and no longer honors an undocumented bare `CACHE_DIR` - telemetry opt-out flags and `FORCE_USE_CACHE` use the tolerant flag parser (`yes`/`off`/blank all resolve) instead of `Config.Boolean`, which failed decoding on unexpected values - the `DEBUG_OVERRIDE_*` debug log lines on startup are gone - net `-376` lines (`-305` in `src/`); `pnpm typecheck`, `oxlint`, `validate:boundaries`, `validate:skills`, and all 1398 CLI unit tests pass ## Context Config reads were split between a prefixed provider (`APP_CONFIG` keys written without `COMPOSIO_`, mapped on lookup with exemptions for `DEBUG_OVERRIDE_*` and `FORCE_*`) and a raw provider rebuilt per read for "host" variables, plus four modules that named `COMPOSIO_*` variables inline with their own `ConfigProvider.fromEnv()` plumbing. Adding a variable meant knowing which world it belonged to, and tests had to choose between `extendConfigProvider(...)` and `vi.stubEnv`. One rule now covers everything: full names, one provider, one directory.

Alberto Schiabel committed Oct 12, 2026 at 20:16 UTC 1bb22d38c494a1bbb4501d3849a9ae4557b862b7
110 files changed +1151 -1464
.agents/skills/cli-command/references/design.md
+1 -1
@@ -23,7 +23,7 @@
23
24 ## Configuration And Exit Codes
25
26 -- Runtime config is read from environment variables via `effect/Config` (`src/services/config.ts`, `src/cli-config.ts`). Keys are upper snake case prefixed `COMPOSIO_` (the prefix is stripped on read); `DEBUG_OVERRIDE_*` and `FORCE_*` are read verbatim (`src/constants.ts`).
26 +- Runtime config is read from environment variables via `effect/Config`. Every variable the CLI reads is declared, under its full name, in one of the catalogs in `src/config` (`APP_CONFIG` for user-facing `COMPOSIO_*` settings, `DEBUG_CONFIG`, `TELEMETRY_CONFIG`, `HOST_CONFIG`, `GITHUB_CONFIG`); add new variables there, never inline. Tests inject `ConfigProvider.fromEnvRecord({...})`.
27 - Persistent user/auth state lives in `~/.composio/user-config.json`; `ComposioUserContext` merges environment variables over the stored file, so an env var overrides the stored value.
28 - Project-scoped data uses a project-local `.composio/` directory.
29 - Exit `0` on success and non-zero (`1`) on failure; interrupts are not treated as failures (`src/cli-main.ts` teardown via `BunRuntime.runMain`). There is no distinct "invalid usage" exit code — do not invent one.
.agents/skills/effect-v4/references/core-patterns.md
+2 -2
@@ -61,12 +61,12 @@ declare class ComposioToolkitsRepository extends Context.Service<
61 declare class NodeOs extends Context.Service<NodeOs, object>()('y') {
62 static readonly Default: Layer.Layer<NodeOs>;
63 }
64 -declare const ConfigLive: Layer.Layer<never>;
64 +declare const LogLevelFromConfigLive: Layer.Layer<never>;
65 type RequiredLayer = Layer.Layer<ComposioToolkitsRepository>;
66
67 export const ComposioToolkitsRepositoryLive = Layer.provide(
68 ComposioToolkitsRepository.Default,
69 - Layer.mergeAll(BunFileSystem.layer, BunPath.layer, NodeOs.Default, ConfigLive)
69 + Layer.mergeAll(BunFileSystem.layer, BunPath.layer, NodeOs.Default, LogLevelFromConfigLive)
70 ) satisfies RequiredLayer;
71 ```
72
.agents/skills/typescript-testing/references/effect-v4-cli.md
+1 -4
@@ -20,7 +20,6 @@ repo-local `effect-v4` skill.
20 ```ts no-check
21 import { describe, expect, layer } from '@effect/vitest';
22 import { ConfigProvider, Effect } from 'effect';
23 -import { extendConfigProvider } from 'src/services/config';
23 import { cli, pkg, TestLive, MockConsole } from 'test/__utils__';
24
25 describe('CLI: composio', () => {
@@ -34,9 +33,7 @@ describe('CLI: composio', () => {
33 );
34 });
35
37 - const testConfigProvider = ConfigProvider.fromEnv({
38 - env: { DEBUG_OVERRIDE_VERSION: '1.2.3-test' },
39 - }).pipe(extendConfigProvider);
36 + const testConfigProvider = ConfigProvider.fromEnvRecord({ DEBUG_OVERRIDE_VERSION: '1.2.3-test' });
37
38 layer(TestLive({ baseConfigProvider: testConfigProvider }))('with config override', it => {
39 it.effect('[Given] `DEBUG_OVERRIDE_VERSION` env var [Then] prints overridden version', () =>
ts/packages/cli/AGENTS.md
+2 -2
@@ -82,7 +82,7 @@ OS credential storage uses the sibling package `@composio/cli-keyring` (macOS Ke
82
83 ### Effects — `src/effects/`
84
85 -Reusable Effect computations: `app-config` (reads `COMPOSIO_*` env), `debug-config`, `force-config`, `setup-cache-dir`, `toolkit-version-overrides` (parses `COMPOSIO_TOOLKIT_VERSION_<NAME>=<ver>`), `validate-toolkit-versions`, `with-log-level`, `find-composio-core-generated`, `version`, `compare-semver`, `log-metrics`.
85 +Reusable Effect computations: `setup-cache-dir`, `toolkit-version-overrides` (maps `COMPOSIO_TOOLKIT_VERSION_<NAME>=<ver>` pins to toolkit slugs), `validate-toolkit-versions`, `with-log-level`, `find-composio-core-generated`, `version`, `compare-semver`, `log-metrics`.
86
87 ### Models — `src/models/`
88
@@ -104,7 +104,7 @@ Steps 3–4 (and the TypeScript compiler they need) ship as the `generation-runt
104 ### Configuration
105
106 - CLI: `cli-config.ts` enables help and version global actions. `commands/root-help.ts` derives the native `help` command tree and delegates documents to Effect. The formatter keeps version output bare and appends a short root overview. Hidden debug settings use `Flag.withHidden`; the diagnostic group uses `Command.unlisted` (the pinned framework's hidden-command API). `commands/argv-compat.ts` preserves optional `listen --stream` values and inserts the native `--` boundary for legacy undelimited `run` script arguments. Effect parses the script tail through `Argument.variadic`; never strip its flags. `setup skill` installs agent skills; `--dangerously-allow` is local to `dev triggers disable`.
107 -- Constants: `constants.ts` — env prefixes (`COMPOSIO_`, `DEBUG_OVERRIDE_`)
107 +- Environment: `src/config/` declares every variable the CLI reads under its full name, grouped into `APP_CONFIG` (user-facing `COMPOSIO_*`, see the README), `DEBUG_CONFIG`, `TELEMETRY_CONFIG`, `HOST_CONFIG` (shell, CI, agent host), and `GITHUB_CONFIG`. Values flow through the ambient `ConfigProvider` (the process environment by default; tests provide `ConfigProvider.fromEnvRecord`). Read a variable through its catalog, never with an inline `Config.String('COMPOSIO_…')`.
108 - User config: `~/.composio/user-config.json`
109 - Cache files: `toolkits.json`, `tools.json`, `tools-as-enums.json`, `trigger-types.json`
110
ts/packages/cli/README.md
+3
@@ -74,6 +74,7 @@ By default, both files are stored in `~/.composio`, but you can specify a custom
74 | COMPOSIO_DISABLE_CONNECTED_ACCOUNT_CACHE | - | Disables the connected-account cache | true |
75 | COMPOSIO_PERF_DEBUG | - | Set to `1` to write performance diagnostics | 0 |
76 | COMPOSIO_TOOL_DEBUG | - | Set to `1` to write tool diagnostics | 0 |
77 +| COMPOSIO_CLI_TELEMETRY_DISABLED | - | Set to `1` to disable CLI telemetry (`COMPOSIO_DISABLE_TELEMETRY` and `TELEMETRY_DISABLED` also work) | 0 |
78 | DEBUG_OVERRIDE_VERSION | - | The version to use when upgrading the Composio CLI (for debugging) | None |
79 | FORCE_USE_CACHE | - | Whether to force the use of previously cached HTTP responses | None |
80 | NO_COLOR | - | If set, disables color output in the CLI (https://no-color.org/) | None |
@@ -96,6 +97,8 @@ Additionally, `composio upgrade` supports the following environment variables:
97 | COMPOSIO_GITHUB_TAG | The tag to use when fetching the Composio CLI binary from Github | latest |
98 | COMPOSIO_GITHUB_ACCESS_TOKEN | The access token for the GitHub API. Useful during development to avoid getting rate-limited by Github | None |
99
100 +Every variable above is declared in `src/config/`, one catalog per purpose; that directory is the place to look up or add a setting.
101 +
102 ### Choosing the PATH entry with `COMPOSIO_BIN_DIR`
103
104 `composio install` writes a single `PATH` line into your shell config. The directory it points at is resolved in this order:
ts/packages/cli/src/analytics/dispatch.ts
+25 -91
@@ -4,8 +4,6 @@ import type { PlatformError } from 'effect/PlatformError';
4 import {
5 Cause,
6 Clock,
7 - Config,
8 - ConfigProvider,
7 DateTime,
8 Effect,
9 Encoding,
@@ -16,9 +14,8 @@ import {
14 } from 'effect';
15 import { HttpClient, HttpClientRequest } from 'effect/unstable/http';
16 import * as constants from 'src/constants';
19 -import { APP_CONFIG } from 'src/effects/app-config';
17 +import { APP_CONFIG, TELEMETRY_CONFIG } from 'src/config';
18 import { getDetachedWorkerSpawnArgs, spawnDetached } from 'src/services/detached-process';
21 -import { extendConfigProvider } from 'src/services/config';
19 import { atomicWriteFileString } from 'src/utils/atomic-write';
20 import { sha256Hex } from 'src/utils/checksums';
21 import { djb2Hash } from 'src/utils/djb2';
@@ -26,7 +23,7 @@ import { NodeOs } from 'src/services/node-os';
23 import { detectPluginHost, rawHostEnvironment } from 'src/services/agent-host-env';
24 import { TerminalUI } from 'src/services/terminal-ui';
25 import { isTelemetryDebugEnabled, TELEMETRY_DEBUG_FLAG } from 'src/services/runtime-flags';
29 -import { CliRunId } from 'src/services/runtime-cli-context';
26 +import { cliInvocationContext, CliRunId } from 'src/services/runtime-cli-context';
27 import type { AnalyticsEnvelope, TrackEvent } from './types';
28
29 const INTERNAL_ANALYTICS_WORKER_FLAG = '__analytics-worker';
@@ -75,59 +72,13 @@ type ConsumerShortTermCacheState = Record<
72 }
73 >;
74
78 -// Workers start before the CLI's prefixed ConfigProvider is assembled, so this
79 -// module names and reads the actual environment variables from a raw provider.
80 -// `ConfigProvider.fromEnv()` snapshots `process.env` at construction time
81 -// (see the vendored `effect` source), so the provider must be rebuilt on every
82 -// read rather than memoized at module scope -- otherwise env changes made
83 -// after import (including `vi.stubEnv` in tests) are never observed.
84 -const getEnvironmentProvider = (): ConfigProvider.ConfigProvider => ConfigProvider.fromEnv();
85 -const optionalString = (name: string) => Config.option(Config.String(name));
86 -const booleanWithDefault = (name: string) => Config.Boolean(name).pipe(Config.withDefault(false));
87 -const configuredString = (value: Option.Option<string>): string | undefined =>
88 - value.pipe(
89 - Option.map(value => value.trim()),
90 - Option.filter(value => value.length > 0),
91 - Option.getOrUndefined
92 - );
75 +const analyticsDisabled = Effect.orDie(TELEMETRY_CONFIG.DISABLED);
76
94 -const analyticsDisabled = Effect.suspend(() =>
95 - Config.all({
96 - cliTelemetryDisabled: booleanWithDefault('COMPOSIO_CLI_TELEMETRY_DISABLED'),
97 - telemetryDisabled: booleanWithDefault('TELEMETRY_DISABLED'),
98 - composioTelemetryDisabled: booleanWithDefault('COMPOSIO_DISABLE_TELEMETRY'),
99 - nodeEnvironment: Config.String('NODE_ENV').pipe(Config.withDefault('')),
100 - ci: booleanWithDefault('CI'),
77 +const getPostHogConfig = Effect.orDie(
78 + Effect.all({
79 + ingestUrl: TELEMETRY_CONFIG.POSTHOG_INGEST_URL,
80 + projectKey: TELEMETRY_CONFIG.POSTHOG_PROJECT_API_KEY,
81 })
102 - .pipe(
103 - Config.map(
104 - ({
105 - cliTelemetryDisabled,
106 - telemetryDisabled,
107 - composioTelemetryDisabled,
108 - nodeEnvironment,
109 - ci,
110 - }) =>
111 - cliTelemetryDisabled ||
112 - telemetryDisabled ||
113 - composioTelemetryDisabled ||
114 - nodeEnvironment === 'test' ||
115 - ci
116 - )
117 - )
118 - .parse(getEnvironmentProvider())
119 -);
120 -
121 -const getPostHogConfig = Effect.suspend(() =>
122 - Config.all({
123 - ingestUrl: optionalString('COMPOSIO_POSTHOG_INGEST_URL'),
124 - projectKey: optionalString('COMPOSIO_POSTHOG_PROJECT_API_KEY'),
125 - }).parse(getEnvironmentProvider())
126 -).pipe(
127 - Effect.map(({ ingestUrl, projectKey }) => ({
128 - ingestUrl: configuredString(ingestUrl) ?? constants.COMPOSIO_POSTHOG_INGEST_URL,
129 - projectKey: configuredString(projectKey) ?? constants.COMPOSIO_POSTHOG_PROJECT_API_KEY,
130 - }))
82 );
83
84 const postHogEnabled = Effect.gen(function* () {
@@ -171,14 +122,9 @@ const telemetryErrorDetails = (cause: Cause.Cause<unknown>): Record<string, stri
122 const getAnalyticsPaths = Effect.gen(function* () {
123 const path = yield* Path.Path;
124 const os = yield* NodeOs;
174 - const cacheDirectories = yield* Config.all({
175 - composio: optionalString('COMPOSIO_CACHE_DIR'),
176 - legacy: optionalString('CACHE_DIR'),
177 - }).parse(getEnvironmentProvider());
125 const analyticsDir = path.join(os.homedir, COMPOSIO_DIR);
126 const cacheDir =
180 - configuredString(cacheDirectories.composio) ??
181 - configuredString(cacheDirectories.legacy) ??
127 + (yield* Effect.orDie(APP_CONFIG.CACHE_DIR)) ??
128 path.join(os.homedir, constants.USER_COMPOSIO_DIR);
129
130 return {
@@ -361,9 +307,7 @@ const getOrgId = Effect.map(readUserConfig, config =>
307 );
308
309 const getUserApiKey = Effect.gen(function* () {
364 - const envApiKey = configuredString(
365 - yield* optionalString('COMPOSIO_USER_API_KEY').parse(getEnvironmentProvider())
366 - );
310 + const envApiKey = yield* Effect.orDie(APP_CONFIG.USER_API_KEY);
311 if (envApiKey) {
312 return envApiKey;
313 }
@@ -506,22 +450,15 @@ const withCliSessionId = (event: NonNullable<TrackEvent>, cliSessionId?: string)
450 },
451 });
452
509 -export const readApiBaseUrl = Effect.gen(function* () {
510 - const envBaseUrl = configuredString(
511 - yield* optionalString('COMPOSIO_BASE_URL').parse(getEnvironmentProvider())
512 - );
513 - if (envBaseUrl) {
514 - return envBaseUrl.replace(/\/+$/u, '');
515 - }
516 -
517 - const userConfig = yield* readUserConfig;
518 - return typeof userConfig?.base_url === 'string' && userConfig.base_url.trim().length > 0
519 - ? userConfig.base_url.trim().replace(/\/+$/u, '')
520 - : null;
521 -}).pipe(Effect.catchCause(() => Effect.succeed(null)));
453 +// The same URL the CLI itself talks to: `COMPOSIO_BASE_URL`, else the `COMPOSIO_ENVIRONMENT`
454 +// default. The persisted login URL is not consulted, matching `ComposioUserContext`.
455 +export const readApiBaseUrl = Effect.orDie(APP_CONFIG.BASE_URL).pipe(
456 + Effect.map(url => url.replace(/\/+$/u, ''))
457 +);
458
523 -const getCliCodactFailuresEndpoint = Effect.map(readApiBaseUrl, baseUrl =>
524 - baseUrl ? `${baseUrl}${CLI_CODACT_FAILURES_PATH}` : null
459 +const getCliCodactFailuresEndpoint = Effect.map(
460 + readApiBaseUrl,
461 + baseUrl => `${baseUrl}${CLI_CODACT_FAILURES_PATH}`
462 );
463
464 // Effect's Command processes are scoped and die with their scope; telemetry
@@ -603,15 +540,12 @@ type CliInvocationContext = {
540 // The COMPOSIO_CLI_PARENT_RUN_ID handshake only exists in processes `composio run` spawned. The
541 // root run process holds its freshly minted id in the CliRunId service instead, so failures it
542 // reports carry the same run id its children stamp from the environment.
606 -const getCliInvocationContext = Effect.gen(function* () {
607 - const environment = yield* Config.all({
608 - origin: APP_CONFIG.CLI_INVOCATION_ORIGIN,
609 - parentRunId: APP_CONFIG.CLI_PARENT_RUN_ID,
610 - }).parse(extendConfigProvider(getEnvironmentProvider()));
543 +const getCliInvocationContext: Effect.Effect<CliInvocationContext> = Effect.gen(function* () {
544 + const { invocationOrigin, parentRunId } = yield* cliInvocationContext;
545 const mintedRunId = Option.flatten(yield* Effect.serviceOption(CliRunId));
546 return {
613 - origin: environment.origin,
614 - parentRunId: environment.parentRunId ?? Option.getOrUndefined(mintedRunId),
547 + origin: invocationOrigin,
548 + parentRunId: parentRunId ?? Option.getOrUndefined(mintedRunId),
549 };
550 });
551
@@ -638,9 +572,9 @@ const captureToComposioCodactFailures = (failure: CliCodactFailure) =>
572 Effect.gen(function* () {
573 const endpoint = yield* getCliCodactFailuresEndpoint;
574 const disabled = yield* analyticsDisabled;
641 - if (!endpoint || disabled) {
575 + if (disabled) {
576 yield* telemetryDebugLog('codact_delivery_skipped', {
643 - reason: disabled ? 'disabled' : 'missing_endpoint',
577 + reason: 'disabled',
578 endpoint,
579 failureType: failure.failureType,
580 });
@@ -882,9 +816,9 @@ export const trackCliCodactFailureEffect = (failure: CliCodactFailure) =>
816 const endpoint = yield* getCliCodactFailuresEndpoint;
817 const userApiKey = yield* getUserApiKey;
818 const disabled = yield* analyticsDisabled;
885 - if (disabled || !endpoint || !userApiKey) {
819 + if (disabled || !userApiKey) {
820 yield* telemetryDebugLog('codact_skip', {
887 - reason: disabled ? 'disabled' : !endpoint ? 'missing_endpoint' : 'missing_user_api_key',
821 + reason: disabled ? 'disabled' : 'missing_user_api_key',
822 failureType: failure.failureType,
823 endpoint,
824 });
ts/packages/cli/src/cli-main.ts
+10 -7
@@ -15,7 +15,6 @@ import * as BunPath from '@effect/platform-bun/BunPath';
15 import { runWithConfig, type RootCommandBootstrap } from 'src/commands';
16 import * as constants from 'src/constants';
17 import { ComposioCliConfig } from 'src/cli-config';
18 -import { getBaseConfigProvider, ConfigLive, extendConfigProvider } from 'src/services/config';
18 import {
19 ComposioClientSingleton,
20 ComposioSessionRepository,
@@ -48,6 +47,7 @@ import {
47 } from 'src/analytics/events';
48 import { trackCliEventEffect } from 'src/analytics/dispatch';
49 import { getVersion } from 'src/effects/version';
50 +import { LogLevelFromConfigLive } from 'src/effects/with-log-level';
51 import { toolkitFromToolSlug } from 'src/effects/toolkit-from-tool-slug';
52 import { mapOnlyComposioOverrideError } from 'src/services/composio-error-overrides';
53 import { SetupSkillInstaller } from 'src/services/setup-skill-installer';
@@ -81,7 +81,7 @@ export const ComposioSessionRepositoryLive = Layer.provide(
81
82 export const ComposioToolkitsRepositoryLive = Layer.provide(
83 ComposioToolkitsRepository.Default,
84 - Layer.mergeAll(BunFileSystem.layer, BunPath.layer, NodeOs.Default, ConfigLive)
84 + Layer.mergeAll(BunFileSystem.layer, BunPath.layer, NodeOs.Default, LogLevelFromConfigLive)
85 ) satisfies RequiredLayer;
86
87 export const ComposioToolkitsRepositoryCachedLive = Layer.provide(
@@ -101,7 +101,7 @@ export const TriggersRealtimeLive = Layer.provide(
101
102 export const ComposioClientSingletonLive = Layer.provide(
103 ComposioClientSingleton.Default,
104 - Layer.mergeAll(BunFileSystem.layer, BunPath.layer, NodeOs.Default, ConfigLive)
104 + Layer.mergeAll(BunFileSystem.layer, BunPath.layer, NodeOs.Default, LogLevelFromConfigLive)
105 ) satisfies RequiredLayer;
106
107 // Fed the cached repository so that the staleness refresh behind it shares the
@@ -127,7 +127,7 @@ export const SetupSkillInstallerLive = Layer.provide(
127 ) satisfies RequiredLayer;
128
129 const layers = Layer.mergeAll(
130 - CliConfigLive.pipe(Layer.provide(ConfigLive)),
130 + CliConfigLive.pipe(Layer.provide(LogLevelFromConfigLive)),
131 NodeOs.Default,
132 NodeProcess.Default,
133 UpgradeBinaryLive,
@@ -331,9 +331,12 @@ const cliProgram = (argv: ReadonlyArray<string>) =>
331 })
332 ),
333 Effect.provide(layers),
334 - // v4 removed `Effect.withConfigProvider` (a FiberRef-scoped combinator); `ConfigProvider` is
335 - // now a `Context.Reference`, so the equivalent is providing it as a layer.
336 - Effect.provide(ConfigProvider.layer(extendConfigProvider(getBaseConfigProvider())))
334 + // Built per invocation, never at module scope: `ConfigProvider.fromEnv()` snapshots
335 + // `process.env` when constructed, and the ambient `ConfigProvider` reference caches its
336 + // default snapshot process-wide on first use. A fresh provider here means every config read
337 + // of this invocation observes the environment as it is now (`vi.stubEnv` in tests, any
338 + // in-process mutation before `runCli`).
339 + Effect.provide(ConfigProvider.layer(ConfigProvider.fromEnv()))
340 );
341
342 export const runCli = (options: CliBootstrapOptions): void => {
ts/packages/cli/src/commands/install.cmd.ts
+7 -15
@@ -2,8 +2,8 @@ import { Command, Flag } from 'effect/unstable/cli';
2 import * as FileSystem from 'effect/FileSystem';
3 import * as Path from 'effect/Path';
4 import type { PlatformError } from 'effect/PlatformError';
5 -import { Array as Arr, Config, ConfigProvider, Data, Effect, Option } from 'effect';
6 -import { APP_CONFIG } from 'src/effects/app-config';
5 +import { Array as Arr, Config, Data, Effect, Option } from 'effect';
6 +import { APP_CONFIG, HOST_CONFIG } from 'src/config';
7 import { ComposioCliUserConfig } from 'src/services/cli-user-config';
8 import { NodeOs } from 'src/services/node-os';
9 import { NodeProcess } from 'src/services/node-process';
@@ -85,14 +85,6 @@ const COMPLETIONS_MARKER = '# Composio CLI completions';
85 const UNSAFE_PATH_CHARS = /[`$"\\\n\r:]/;
86 const isUnsafePath = (p: string): boolean => UNSAFE_PATH_CHARS.test(p);
87
88 -// SHELL and PATH are POSIX-standard host variables, so the CLI's COMPOSIO_
89 -// prefix does not apply to them. The provider is built per read because
90 -// `ConfigProvider.fromEnv` snapshots the environment when constructed.
91 -const readEnvWithDefault = (name: string, fallback: string): Effect.Effect<string> =>
92 - Effect.orDie(
93 - Config.String(name).pipe(Config.withDefault(fallback)).parse(ConfigProvider.fromEnv())
94 - );
95 -
88 const detectShellFromEnv = (path: Path.Path, shellEnv: string): Shell | undefined => {
89 const base = path.basename(shellEnv);
90 if (base === 'zsh') return 'zsh';
@@ -690,11 +682,11 @@ export const installShellIntegration = (params: {
682 const invocationOrigin = yield* APP_CONFIG.CLI_INVOCATION_ORIGIN.pipe(Effect.orDie);
683 const installerOwnsFinalMessaging = invocationOrigin === 'installer';
684
693 - const shellEnv = yield* readEnvWithDefault('SHELL', '');
694 - const shell = params.shell ?? detectShellFromEnv(path, shellEnv);
695 -
696 - const pathEnv = yield* readEnvWithDefault('PATH', '');
697 - const binDirOnPath = isDirOnPath(pathEnv, binDir);
685 + const host = yield* Effect.orDie(
686 + Config.all({ shell: HOST_CONFIG.SHELL, path: HOST_CONFIG.PATH })
687 + );
688 + const shell = params.shell ?? detectShellFromEnv(path, host.shell ?? '');
689 + const binDirOnPath = isDirOnPath(host.path ?? '', binDir);
690
691 if (!shell) {
692 // With no shell there is no rc file to write, so the current process's
ts/packages/cli/src/commands/tools/commands/tools.execute.cmd.ts
+1 -1
@@ -52,7 +52,7 @@ import {
52 normalizeCliError,
53 } from 'src/services/composio-error-overrides';
54 import * as constants from 'src/constants';
55 -import { APP_CONFIG } from 'src/effects/app-config';
55 +import { APP_CONFIG } from 'src/config';
56 import { CLI_DEBUG_FLAG_NAMES } from 'src/services/runtime-flags';
57
58 export const ExecuteInvocationArgs = Context.Reference<ReadonlyArray<string>>(
ts/packages/cli/src/commands/triggers/commands/triggers.listen.cmd.ts
+1 -1
@@ -2,7 +2,7 @@ import { Command, Flag } from 'effect/unstable/cli';
2 import * as FileSystem from 'effect/FileSystem';
3 import * as Path from 'effect/Path';
4 import { Deferred, Effect, Option } from 'effect';
5 -import { APP_CONFIG } from 'src/effects/app-config';
5 +import { APP_CONFIG } from 'src/config';
6 import { requireAuth } from 'src/effects/require-auth';
7 import { TerminalUI } from 'src/services/terminal-ui';
8 import { TriggersRealtime } from 'src/services/triggers-realtime';
ts/packages/cli/src/config/app.ts new
+71
@@ -0,0 +1,71 @@
1 +import { Config, Schema } from 'effect';
2 +import * as constants from 'src/constants';
3 +import { flag, optionalLogLevel, optionalString } from './env';
4 +
5 +const ENVIRONMENT = optionalString('COMPOSIO_ENVIRONMENT');
6 +
7 +/** The explicit `name` value, else the `COMPOSIO_ENVIRONMENT`-derived default. */
8 +const url = (name: string, prodDefault: string, stagingDefault: string) =>
9 + Config.all({ explicit: optionalString(name), environment: ENVIRONMENT }).pipe(
10 + Config.map(
11 + ({ explicit, environment }) =>
12 + explicit ?? (environment === 'staging' ? stagingDefault : prodDefault)
13 + )
14 + );
15 +
16 +/**
17 + * The `COMPOSIO_*` variables users set to configure the CLI, documented in the README.
18 + *
19 + * URL precedence (highest → lowest):
20 + * COMPOSIO_BASE_URL → COMPOSIO_ENVIRONMENT-derived → DEFAULT_BASE_URL
21 + * COMPOSIO_WEB_URL → COMPOSIO_ENVIRONMENT-derived → DEFAULT_WEB_URL
22 + */
23 +export const APP_CONFIG = {
24 + // The API key for the Composio API
25 + USER_API_KEY: optionalString('COMPOSIO_USER_API_KEY'),
26 +
27 + // The deployment environment ("production" | "staging"). Controls URL defaults.
28 + ENVIRONMENT,
29 +
30 + // The base URL for the Composio API
31 + BASE_URL: url('COMPOSIO_BASE_URL', constants.DEFAULT_BASE_URL, constants.STAGING_BASE_URL),
32 +
33 + // The base URL for the Composio web app
34 + WEB_URL: url('COMPOSIO_WEB_URL', constants.DEFAULT_WEB_URL, constants.STAGING_WEB_URL),
35 +
36 + // The cache directory for the Composio CLI
37 + CACHE_DIR: optionalString('COMPOSIO_CACHE_DIR'),
38 +
39 + // Override the root directory for CLI session artifacts
40 + SESSION_DIR: optionalString('COMPOSIO_SESSION_DIR'),
41 +
42 + // Override the directory added to PATH by `composio install`
43 + BIN_DIR: optionalString('COMPOSIO_BIN_DIR'),
44 +
45 + // The log level for the Composio CLI
46 + LOG_LEVEL: optionalLogLevel('COMPOSIO_LOG_LEVEL'),
47 +
48 + // The organization and project for multi-project auth (override file-based config)
49 + ORG_ID: optionalString('COMPOSIO_ORG_ID'),
50 + PROJECT_ID: optionalString('COMPOSIO_PROJECT_ID'),
51 +
52 + // Override the Composio agents service URL
53 + AGENTS_BASE_URL: optionalString('COMPOSIO_AGENTS_BASE_URL'),
54 +
55 + // Sign forwarded trigger payloads with this secret
56 + WEBHOOK_SECRET: optionalString('COMPOSIO_WEBHOOK_SECRET'),
57 +
58 + // Internal context propagated between CLI processes
59 + CLI_INVOCATION_ORIGIN: optionalString('COMPOSIO_CLI_INVOCATION_ORIGIN'),
60 + CLI_PARENT_RUN_ID: optionalString('COMPOSIO_CLI_PARENT_RUN_ID'),
61 + RUN_OUTPUT_DIR: optionalString('COMPOSIO_RUN_OUTPUT_DIR'),
62 +
63 + // Disable connected account cache (defaults to true — cache is off by default)
64 + DISABLE_CONNECTED_ACCOUNT_CACHE: flag('COMPOSIO_DISABLE_CONNECTED_ACCOUNT_CACHE', true),
65 +
66 + // Every `COMPOSIO_TOOLKIT_VERSION_<TOOLKIT>=<version>` pin, keyed by `<TOOLKIT>` as written.
67 + // `Config.Record` reads the whole `COMPOSIO_TOOLKIT_VERSION` subtree of the environment.
68 + TOOLKIT_VERSIONS: Config.option(
69 + Config.Record(Schema.String, Schema.String, ['COMPOSIO', 'TOOLKIT', 'VERSION'])
70 + ),
71 +};
ts/packages/cli/src/config/debug.ts new
+22
@@ -0,0 +1,22 @@
1 +import { flag, optionalString } from './env';
2 +
3 +/**
4 + * Diagnostics and developer overrides. None of these are documented for end users except the
5 + * two `*_DEBUG` toggles, which the hidden `--perf-debug` / `--tool-debug` / `--telemetry-debug`
6 + * global flags override (see `src/services/runtime-flags.ts`).
7 + */
8 +export const DEBUG_CONFIG = {
9 + // Write performance / tool / telemetry diagnostics to stderr
10 + PERF_DEBUG: flag('COMPOSIO_PERF_DEBUG'),
11 + TOOL_DEBUG: flag('COMPOSIO_TOOL_DEBUG'),
12 + TELEMETRY_DEBUG: flag('COMPOSIO_CLI_TELEMETRY_DEBUG'),
13 +
14 + // Upgrade from this local binary instead of downloading a GitHub release
15 + UPGRADE_TARGET: optionalString('DEBUG_OVERRIDE_UPGRADE_TARGET'),
16 +
17 + // Report this as the running CLI version
18 + VERSION: optionalString('DEBUG_OVERRIDE_VERSION'),
19 +
20 + // Replay previously cached API responses instead of calling the backend
21 + FORCE_USE_CACHE: flag('FORCE_USE_CACHE'),
22 +};
ts/packages/cli/src/config/env.ts new
+83
@@ -0,0 +1,83 @@
1 +import { Config, LogLevel, Option, Schema } from 'effect';
2 +
3 +/**
4 + * Readers shared by the configuration catalogs in `src/config`.
5 + *
6 + * Every catalog names its environment variables in full (`COMPOSIO_USER_API_KEY`, `CI`, ...)
7 + * and reads them through the ambient `ConfigProvider`, which defaults to the process
8 + * environment. Nothing rewrites lookup paths, so a test configures the CLI by providing
9 + * `ConfigProvider.fromEnvRecord({ COMPOSIO_USER_API_KEY: '...' })` and nothing else.
10 + */
11 +
12 +/** A string setting; `undefined` when unset or blank. Surrounding whitespace is dropped. */
13 +export const optionalString = (name: string): Config.Config<string | undefined> =>
14 + Config.option(Config.String(name)).pipe(
15 + Config.map(value => {
16 + const trimmed = Option.getOrUndefined(value)?.trim();
17 + return trimmed ? trimmed : undefined;
18 + })
19 + );
20 +
21 +/** `self` with `fallback` in place of `undefined`. */
22 +export const withFallback = <A>(
23 + self: Config.Config<A | undefined>,
24 + fallback: A
25 +): Config.Config<A> => self.pipe(Config.map(value => value ?? fallback));
26 +
27 +/** A string setting that falls back to `fallback` when unset or blank. */
28 +export const stringWithDefault = (name: string, fallback: string): Config.Config<string> =>
29 + withFallback(optionalString(name), fallback);
30 +
31 +const LOG_LEVEL_SPELLINGS = new Map(LogLevel.values.map(level => [level.toLowerCase(), level]));
32 +
33 +/**
34 + * A `LogLevel` setting, matched case-insensitively; `undefined` when unset, blank, or not a
35 + * level name. A typo in a README-documented variable must not fail the CLI before it starts.
36 + */
37 +export const optionalLogLevel = (name: string): Config.Config<LogLevel.LogLevel | undefined> =>
38 + optionalString(name).pipe(
39 + Config.map(value =>
40 + value === undefined ? undefined : LOG_LEVEL_SPELLINGS.get(value.toLowerCase())
41 + )
42 + );
43 +
44 +const FLAG_OFF_SPELLINGS = new Set(['0', 'false', 'no', 'off']);
45 +
46 +/**
47 + * Tri-state read of a boolean flag. Flags arrive from the ambient environment, where a blank
48 + * (`COMPOSIO_X=`) or unexpected value is routine, so this is deliberately more tolerant than
49 + * `Config.Boolean`, which rejects both:
50 + *
51 + * unset or blank → `undefined`, the caller picks the default
52 + * `0` / `false` / `no` / `off`, any casing → `false`
53 + * anything else (`1`, `true`, a typo) → `true`
54 + */
55 +export const optionalFlag = (name: string): Config.Config<boolean | undefined> =>
56 + optionalString(name).pipe(
57 + Config.map(value =>
58 + value === undefined ? undefined : !FLAG_OFF_SPELLINGS.has(value.toLowerCase())
59 + )
60 + );
61 +
62 +/** A boolean flag with `defaultValue` for the unset and blank cases (see `optionalFlag`). */
63 +export const flag = (name: string, defaultValue = false): Config.Config<boolean> =>
64 + optionalFlag(name).pipe(Config.map(value => value ?? defaultValue));
65 +
66 +// `ConfigProvider.fromEnv` splits every variable name on `_` to build a trie, so `CODEX_HOME`,
67 +// `CODEX_0_X`, and a bare `CODEX` all surface under the root `CODEX`. This permissive schema
68 +// accepts that subtree whatever its shape.
69 +const environmentTree: Schema.Codec<unknown> = Schema.Union([
70 + Schema.String,
71 + Schema.Record(
72 + Schema.String,
73 + Schema.suspend(() => environmentTree)
74 + ),
75 + Schema.Array(Schema.suspend(() => environmentTree)),
76 +]);
77 +
78 +/**
79 + * Whether any variable named `<root>` or `<root>_*` is set. Names are matched as written, so
80 + * `codex_home` does not count for the root `CODEX`.
81 + */
82 +export const hasEnvironmentRoot = (root: string): Config.Config<boolean> =>
83 + Config.schema(environmentTree, root).pipe(Config.option, Config.map(Option.isSome));
ts/packages/cli/src/config/github.ts new
+41
@@ -0,0 +1,41 @@
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);
ts/packages/cli/src/config/host.ts new
+65
@@ -0,0 +1,65 @@
1 +import { Config } from 'effect';
2 +import { hasEnvironmentRoot, optionalFlag, optionalString } from './env';
3 +
4 +const agentPrefixSignals = Config.all({
5 + codex: hasEnvironmentRoot('CODEX'),
6 + claude: hasEnvironmentRoot('CLAUDE'),
7 + openclaw: hasEnvironmentRoot('OPENCLAW'),
8 +});
9 +
10 +/**
11 + * Facts about the process that launched the CLI: the shell, CI, the package manager, and the
12 + * agent host (Claude Code, Codex, ...). Most of these variables are owned by other programs;
13 + * the string-to-domain normalization lives here so consumers never inspect raw values.
14 + */
15 +export const HOST_CONFIG = {
16 + // POSIX shell variables `composio install` edits rc files for
17 + SHELL: optionalString('SHELL'),
18 + PATH: optionalString('PATH'),
19 +
20 + // The package manager that invoked the CLI, as reported by npm-compatible clients
21 + NPM_CONFIG_USER_AGENT: optionalString('npm_config_user_agent'),
22 +
23 + // https://no-color.org/
24 + NO_COLOR: optionalString('NO_COLOR').pipe(Config.map(value => value !== undefined)),
25 +
26 + // Output redaction is for recorded CI sessions and keys off the exact `CI=true` convention.
27 + // `INTERACTIVE_PERMISSION_UI_DISABLED` below reads the same variable tolerantly because
28 + // failing closed there is the safe reading of any non-falsy `CI` value.
29 + CI_REDACTION_ENABLED: optionalString('CI').pipe(
30 + Config.map(value => value?.toLowerCase() === 'true')
31 + ),
32 +
33 + // The browser approval page must never open from automated environments. The explicit
34 + // COMPOSIO_DISABLE_PERMISSION_UI knob wins in both directions; without it, CI and Vitest
35 + // runs disable the UI.
36 + INTERACTIVE_PERMISSION_UI_DISABLED: Config.all({
37 + explicit: optionalFlag('COMPOSIO_DISABLE_PERMISSION_UI'),
38 + ci: optionalFlag('CI'),
39 + vitest: optionalFlag('VITEST'),
40 + }).pipe(Config.map(({ explicit, ci, vitest }) => explicit ?? (ci === true || vitest === true))),
41 +
42 + // Markers and directories the agent hosts export to the processes they spawn
43 + AGENT_HOST: Config.all({
44 + claudeCode: optionalString('CLAUDECODE'),
45 + codexThreadId: optionalString('CODEX_THREAD_ID'),
46 + codexSandbox: optionalString('CODEX_SANDBOX'),
47 + claudeConfigDir: optionalString('CLAUDE_CONFIG_DIR'),
48 + codexHome: optionalString('CODEX_HOME'),
49 + }),
50 +
51 + // Which agent, if any, drives this process: any `CODEX*` / `CLAUDE*` variable counts
52 + MASTER_SIGNALS: agentPrefixSignals.pipe(Config.map(({ codex, claude }) => ({ codex, claude }))),
53 +
54 + // The agent asking for a tool permission: an explicit name beats the prefix signals
55 + CALLER_AGENT_SIGNALS: Config.all({
56 + explicit: Config.all({
57 + callerAgent: optionalString('COMPOSIO_CALLER_AGENT'),
58 + legacyAgent: optionalString('COMPOSIO_AGENT'),
59 + }).pipe(Config.map(({ callerAgent, legacyAgent }) => callerAgent ?? legacyAgent)),
60 + prefixes: agentPrefixSignals,
61 + }).pipe(Config.map(({ explicit, prefixes }) => ({ explicit, ...prefixes }))),
62 +};
63 +
64 +export type AgentHostEnvironment = Config.Success<typeof HOST_CONFIG.AGENT_HOST>;
65 +export type CallerAgentSignals = Config.Success<typeof HOST_CONFIG.CALLER_AGENT_SIGNALS>;
ts/packages/cli/src/config/index.ts new
+18
@@ -0,0 +1,18 @@
1 +/**
2 + * Every environment variable the CLI reads, grouped by purpose:
3 + *
4 + * - `APP_CONFIG` — `COMPOSIO_*` settings users configure (README "Configuration")
5 + * - `DEBUG_CONFIG` — diagnostics toggles and `DEBUG_OVERRIDE_*` developer overrides
6 + * - `TELEMETRY_CONFIG` — telemetry opt-outs and the PostHog target
7 + * - `HOST_CONFIG` — facts about the launching shell, CI, package manager, and agent host
8 + * - `GITHUB_CONFIG` — where releases and skills are fetched from
9 + *
10 + * Variables are named in full and read through the ambient `effect/ConfigProvider`, which
11 + * defaults to the process environment. Tests provide `ConfigProvider.fromEnvRecord({...})`.
12 + * Add a new variable to the catalog it belongs to rather than reading it where it is used.
13 + */
14 +export { APP_CONFIG } from './app';
15 +export { DEBUG_CONFIG } from './debug';
16 +export { TELEMETRY_CONFIG } from './telemetry';
17 +export { HOST_CONFIG, type AgentHostEnvironment, type CallerAgentSignals } from './host';
18 +export { GITHUB_CONFIG, GITHUB_REPAIR_CONFIG, type GitHubConfig } from './github';
ts/packages/cli/src/config/telemetry.ts new
+30
@@ -0,0 +1,30 @@
1 +import { Config } from 'effect';
2 +import * as constants from 'src/constants';
3 +import { flag, optionalString, stringWithDefault } from './env';
4 +
5 +/** Opt-out switches and the PostHog target for CLI telemetry. */
6 +export const TELEMETRY_CONFIG = {
7 + // Any opt-out spelling, a test run, or CI silences telemetry entirely
8 + DISABLED: Config.all({
9 + cli: flag('COMPOSIO_CLI_TELEMETRY_DISABLED'),
10 + composio: flag('COMPOSIO_DISABLE_TELEMETRY'),
11 + generic: flag('TELEMETRY_DISABLED'),
12 + ci: flag('CI'),
13 + nodeEnv: optionalString('NODE_ENV'),
14 + }).pipe(
15 + Config.map(
16 + ({ cli, composio, generic, ci, nodeEnv }) =>
17 + cli || composio || generic || ci || nodeEnv === 'test'
18 + )
19 + ),
20 +
21 + // PostHog capture endpoint and public project key (the key is baked at build time)
22 + POSTHOG_INGEST_URL: stringWithDefault(
23 + 'COMPOSIO_POSTHOG_INGEST_URL',
24 + constants.COMPOSIO_POSTHOG_INGEST_URL
25 + ),
26 + POSTHOG_PROJECT_API_KEY: stringWithDefault(
27 + 'COMPOSIO_POSTHOG_PROJECT_API_KEY',
28 + constants.COMPOSIO_POSTHOG_PROJECT_API_KEY
29 + ),
30 +};
ts/packages/cli/src/constants.ts
-10
@@ -27,16 +27,6 @@ export const STAGING_BASE_URL = 'https://staging-backend.composio.dev';
27 */
28 export const STAGING_WEB_URL = 'https://staging-dashboard.composio.dev/';
29
30 -/**
31 - * Prefix for user environment variable keys used by the Composio CLI.
32 - */
33 -export const APP_ENV_CONFIG_KEY_PREFIX = 'COMPOSIO_';
34 -
35 -/**
36 - * Prefix for environment variable keys used by the Composio CLI for debug overrides.
37 - */
38 -export const DEBUG_OVERRIDE_ENV_CONFIG_KEY_PREFIX = 'DEBUG_OVERRIDE_';
39 -
30 /**
31 * Name of the user config file used by the Composio CLI.
32 */
ts/packages/cli/src/effects/app-config.ts deleted
-221
@@ -1,221 +0,0 @@
1 -import { Config, LogLevel, Option, Schema } from 'effect';
2 -import * as constants from 'src/constants';
3 -
4 -type APP_CONFIG = Config.Wrap<{
5 - USER_API_KEY: Option.Option<string>;
6 - ENVIRONMENT: Option.Option<string>;
7 - BASE_URL: string;
8 - WEB_URL: string;
9 - CACHE_DIR: string | undefined;
10 - SESSION_DIR: string | undefined;
11 - BIN_DIR: string | undefined;
12 - LOG_LEVEL: Option.Option<LogLevel.LogLevel>;
13 - ORG_ID: Option.Option<string>;
14 - PROJECT_ID: Option.Option<string>;
15 - AGENTS_BASE_URL: string | undefined;
16 - WEBHOOK_SECRET: string | undefined;
17 - CLI_INVOCATION_ORIGIN: string | undefined;
18 - CLI_PARENT_RUN_ID: string | undefined;
19 - RUN_OUTPUT_DIR: string | undefined;
20 - PERF_DEBUG: boolean;
21 - TOOL_DEBUG: boolean;
22 - DISABLE_CONNECTED_ACCOUNT_CACHE: boolean;
23 -}>;
24 -
25 -type UNPREFIXED_CONFIG = Config.Wrap<{
26 - NPM_CONFIG_USER_AGENT: string | undefined;
27 - CI_REDACTION_ENABLED: boolean;
28 - INTERACTIVE_PERMISSION_UI_DISABLED: boolean;
29 - NO_COLOR: boolean;
30 - TELEMETRY_DEBUG: boolean;
31 - MASTER_SIGNALS: {
32 - readonly codex: boolean;
33 - readonly claude: boolean;
34 - };
35 - CALLER_AGENT_SIGNALS: {
36 - readonly explicit: string | undefined;
37 - readonly openclaw: boolean;
38 - readonly claude: boolean;
39 - readonly codex: boolean;
40 - };
41 -}>;
42 -
43 -const optionalString = (name: string): Config.Config<string | undefined> =>
44 - Config.option(Config.String(name)).pipe(Config.map(Option.getOrUndefined));
45 -
46 -const optionalTrimmedString = (name: string): Config.Config<string | undefined> =>
47 - optionalString(name).pipe(
48 - Config.map(value => {
49 - if (value === undefined) return undefined;
50 - const trimmed = value.trim();
51 - return trimmed.length > 0 ? trimmed : undefined;
52 - })
53 - );
54 -
55 -const ENV_FLAG_OFF_SPELLINGS = new Set(['0', 'false', 'no', 'off']);
56 -
57 -// A flag that is set counts as enabled unless it spells out one of the usual
58 -// "off" values, compared case-insensitively (`OFF` disables like `off`).
59 -const isEnvFlagEnabled = (value: string): boolean =>
60 - !ENV_FLAG_OFF_SPELLINGS.has(value.toLowerCase());
61 -
62 -/**
63 - * Tri-state read of a boolean environment flag:
64 - *
65 - * unset, or set to blank (`COMPOSIO_X=`) → `undefined` — absent, caller picks the default
66 - * `0` / `false` / `no` / `off`, any casing → `false`
67 - * anything else (`1`, `true`, even a typo) → `true`
68 - */
69 -const optionalEnvironmentFlag = (name: string): Config.Config<boolean | undefined> =>
70 - optionalTrimmedString(name).pipe(
71 - Config.map(value => (value === undefined ? undefined : isEnvFlagEnabled(value)))
72 - );
73 -
74 -// Deliberately tolerant rather than `Config.Boolean`: these flags arrive from the ambient
75 -// environment, where a blank (`COMPOSIO_PERF_DEBUG=`) or unexpected value is routine.
76 -// `Config.Boolean` rejects both with `InvalidData`, and `Config.withDefault` only recovers
77 -// `MissingData`, so a stray value would surface as an unrecoverable defect instead of `false`.
78 -const booleanFlag = (name: string, defaultValue = false): Config.Config<boolean> =>
79 - optionalEnvironmentFlag(name).pipe(Config.map(value => value ?? defaultValue));
80 -
81 -// Effect v4 exposes no root-key enumeration, so each agent prefix is probed as
82 -// its own subtree. `ConfigProvider.fromEnv` splits every variable name on `_`
83 -// to build a trie, so `CODEX_HOME`, `CODEX_0_X`, and a bare `CODEX` all surface
84 -// under the root `CODEX`, which the permissive tree schema below accepts
85 -// whatever its shape. Names are matched as written: the provider no longer
86 -// uppercases keys, so `codex_home` does not count.
87 -const environmentTree: Schema.Codec<unknown> = Schema.Union([
88 - Schema.String,
89 - Schema.Record(
90 - Schema.String,
91 - Schema.suspend(() => environmentTree)
92 - ),
93 - Schema.Array(Schema.suspend(() => environmentTree)),
94 -]);
95 -
96 -const hasEnvironmentRoot = (root: string): Config.Config<boolean> =>
97 - Config.schema(environmentTree, root).pipe(Config.option, Config.map(Option.isSome));
98 -
99 -const agentPrefixSignals = Config.all({
100 - codex: hasEnvironmentRoot('CODEX'),
101 - claude: hasEnvironmentRoot('CLAUDE'),
102 - openclaw: hasEnvironmentRoot('OPENCLAW'),
103 -});
104 -
105 -/**
106 - * Derives a URL default based on the `COMPOSIO_ENVIRONMENT` config key.
107 - * Returns `stagingDefault` when ENVIRONMENT is `"staging"`, otherwise `prodDefault`.
108 - */
109 -const environmentBasedDefault = (
110 - prodDefault: string,
111 - stagingDefault: string
112 -): Config.Config<string> =>
113 - Config.String('ENVIRONMENT').pipe(
114 - Config.map(env => (env === 'staging' ? stagingDefault : prodDefault)),
115 - Config.withDefault(prodDefault)
116 - );
117 -
118 -/**
119 - * Describe every configuration key used at runtime.
120 - * Keys are read from environment variables (with the `${APP_ENV_CONFIG_KEY_PREFIX}<key>` format).
121 - *
122 - * URL precedence (highest → lowest):
123 - * COMPOSIO_BASE_URL → COMPOSIO_ENVIRONMENT-derived → DEFAULT_BASE_URL
124 - * COMPOSIO_WEB_URL → COMPOSIO_ENVIRONMENT-derived → DEFAULT_WEB_URL
125 - */
126 -export const APP_CONFIG = {
127 - // The API key for the Composio API
128 - USER_API_KEY: Config.option(Config.String('USER_API_KEY')),
129 -
130 - // The deployment environment ("production" | "staging"). Controls URL defaults.
131 - ENVIRONMENT: Config.option(Config.String('ENVIRONMENT')),
132 -
133 - // The base URL for the Composio API
134 - BASE_URL: Config.String('BASE_URL').pipe(
135 - Config.orElse(() =>
136 - environmentBasedDefault(constants.DEFAULT_BASE_URL, constants.STAGING_BASE_URL)
137 - )
138 - ),
139 -
140 - // The base URL for the Composio web app
141 - WEB_URL: Config.String('WEB_URL').pipe(
142 - Config.orElse(() =>
143 - environmentBasedDefault(constants.DEFAULT_WEB_URL, constants.STAGING_WEB_URL)
144 - )
145 - ),
146 -
147 - // The cache directory for the Composio CLI
148 - CACHE_DIR: optionalTrimmedString('CACHE_DIR'),
149 -
150 - // Override the root directory for CLI session artifacts
151 - SESSION_DIR: optionalTrimmedString('SESSION_DIR'),
152 -
153 - // Override the directory added to PATH by `composio install`
154 - BIN_DIR: optionalTrimmedString('BIN_DIR'),
155 -
156 - // The log level for the Composio CLI
157 - LOG_LEVEL: Config.option(Config.LogLevel('LOG_LEVEL')),
158 -
159 - // The organization ID for multi-project auth (overrides file-based config)
160 - ORG_ID: Config.option(Config.String('ORG_ID')),
161 -
162 - // The project ID for multi-project auth (overrides file-based config)
163 - PROJECT_ID: Config.option(Config.String('PROJECT_ID')),
164 -
165 - // Override the Composio agents service URL
166 - AGENTS_BASE_URL: optionalString('AGENTS_BASE_URL'),
167 -
168 - // Sign forwarded trigger payloads with this secret
169 - WEBHOOK_SECRET: optionalString('WEBHOOK_SECRET'),
170 -
171 - // Internal context propagated between CLI processes
172 - CLI_INVOCATION_ORIGIN: optionalTrimmedString('CLI_INVOCATION_ORIGIN'),
173 - CLI_PARENT_RUN_ID: optionalTrimmedString('CLI_PARENT_RUN_ID'),
174 - RUN_OUTPUT_DIR: optionalTrimmedString('RUN_OUTPUT_DIR'),
175 -
176 - // Runtime debug flags
177 - PERF_DEBUG: booleanFlag('PERF_DEBUG'),
178 - TOOL_DEBUG: booleanFlag('TOOL_DEBUG'),
179 -
180 - // Disable connected account cache (defaults to true — cache is off by default)
181 - DISABLE_CONNECTED_ACCOUNT_CACHE: booleanFlag('DISABLE_CONNECTED_ACCOUNT_CACHE', true),
182 -} satisfies APP_CONFIG;
183 -
184 -/**
185 - * Configuration whose keys are spelled out in full and are therefore loaded
186 - * through the raw `ConfigProvider.fromEnv()` provider (`loadHostConfig` in
187 - * `src/services/config.ts`) rather than the `COMPOSIO_`-prefixing provider that
188 - * serves `APP_CONFIG`. Several keys do carry the `COMPOSIO_` prefix; what unites
189 - * them is that the prefix is written here instead of being applied by the
190 - * provider. Keep their string-to-domain normalization here so consumers never
191 - * inspect raw environment strings.
192 - */
193 -export const UNPREFIXED_CONFIG = {
194 - // The package manager that invoked the CLI, as reported by npm-compatible clients
195 - NPM_CONFIG_USER_AGENT: optionalString('npm_config_user_agent'),
196 -
197 - // Stricter than the `booleanFlag` family on purpose: output redaction is for
198 - // recorded CI sessions and keys off the exact `CI=true` convention. A looser
199 - // parse would also start redacting under `CI=1`-style environments, changing
200 - // long-standing behavior. `INTERACTIVE_PERMISSION_UI_DISABLED` below reads
201 - // the same variable tolerantly because failing closed there is the safe
202 - // reading of any non-falsy `CI` value.
203 - CI_REDACTION_ENABLED: optionalTrimmedString('CI').pipe(
204 - Config.map(value => value?.toLowerCase() === 'true')
205 - ),
206 - INTERACTIVE_PERMISSION_UI_DISABLED: Config.all({
207 - explicit: optionalEnvironmentFlag('COMPOSIO_DISABLE_PERMISSION_UI'),
208 - ci: optionalEnvironmentFlag('CI'),
209 - vitest: optionalEnvironmentFlag('VITEST'),
210 - }).pipe(Config.map(({ explicit, ci, vitest }) => explicit ?? (ci === true || vitest === true))),
211 - NO_COLOR: optionalString('NO_COLOR').pipe(Config.map(Boolean)),
212 - TELEMETRY_DEBUG: booleanFlag('COMPOSIO_CLI_TELEMETRY_DEBUG'),
213 - MASTER_SIGNALS: agentPrefixSignals.pipe(Config.map(({ codex, claude }) => ({ codex, claude }))),
214 - CALLER_AGENT_SIGNALS: Config.all({
215 - explicit: Config.all({
216 - callerAgent: optionalTrimmedString('COMPOSIO_CALLER_AGENT'),
217 - legacyAgent: optionalTrimmedString('COMPOSIO_AGENT'),
218 - }).pipe(Config.map(({ callerAgent, legacyAgent }) => callerAgent ?? legacyAgent)),
219 - prefixes: agentPrefixSignals,
220 - }).pipe(Config.map(({ explicit, prefixes }) => ({ explicit, ...prefixes }))),
221 -} satisfies UNPREFIXED_CONFIG;
ts/packages/cli/src/effects/debug-config.ts deleted
-19
@@ -1,19 +0,0 @@
1 -import { Config, Option } from 'effect';
2 -
3 -type DEBUG_CONFIG = Config.Wrap<{
4 - UPGRADE_TARGET: Option.Option<string>;
5 - VERSION: Option.Option<string>;
6 -}>;
7 -
8 -/**
9 - * Describe debug configuration keys used at runtime.
10 - * Keys are read from environment variables (with the `DEBUG_OVERRIDE_<key>` format).
11 - */
12 -export const DEBUG_OVERRIDE_CONFIG = {
13 - // The local binary used when upgrading the Composio CLI (for debugging).
14 - // When set, the upgrade command will use this local file instead of downloading from GitHub.
15 - UPGRADE_TARGET: Config.option(Config.String('DEBUG_OVERRIDE_UPGRADE_TARGET')),
16 -
17 - // The version to use when upgrading the Composio CLI (for debugging).
18 - VERSION: Config.option(Config.String('DEBUG_OVERRIDE_VERSION')),
19 -} satisfies DEBUG_CONFIG;
ts/packages/cli/src/effects/force-config.ts deleted
-13
@@ -1,13 +0,0 @@
1 -import { Config } from 'effect';
2 -
3 -type FORCE_CONFIG = Config.Wrap<{
4 - USE_CACHE: boolean;
5 -}>;
6 -
7 -/**
8 - * Describe force configuration keys used at runtime.
9 - * Keys are read from environment variables (with the `FORCE_<key>` format).
10 - */
11 -export const FORCE_CONFIG = {
12 - USE_CACHE: Config.Boolean('FORCE_USE_CACHE').pipe(Config.withDefault(false)),
13 -} satisfies FORCE_CONFIG;
ts/packages/cli/src/effects/github-config.ts deleted
-31
@@ -1,31 +0,0 @@
1 -import { Config, Option } from 'effect';
2 -
3 -type GITHUB_CONFIG = Config.Wrap<{
4 - API_BASE_URL: string;
5 - OWNER: string;
6 - REPO: string;
7 - TAG: Option.Option<string>;
8 - ACCESS_TOKEN: Option.Option<string>;
9 -}>;
10 -
11 -/**
12 - * Describe every Github configuration key used at runtime.
13 - */
14 -export const GITHUB_CONFIG = {
15 - // The base URL for the GitHub API
16 - API_BASE_URL: Config.String('GITHUB_API_BASE_URL').pipe(
17 - Config.withDefault('https://api.github.com')
18 - ),
19 -
20 - // The owner of the Composio repository on GitHub
21 - OWNER: Config.String('GITHUB_OWNER').pipe(Config.withDefault('ComposioHQ')),
22 -
23 - // The repository name for the Composio CLI
24 - REPO: Config.String('GITHUB_REPO').pipe(Config.withDefault('composio')),
25 -
26 - // The tag to use as the latest release
27 - TAG: Config.option(Config.String('GITHUB_TAG')),
28 -
29 - // The access token for the GitHub API. Only useful during development to avoid getting rate-limited by Github
30 - ACCESS_TOKEN: Config.option(Config.String('GITHUB_ACCESS_TOKEN')),
31 -} satisfies GITHUB_CONFIG;
ts/packages/cli/src/effects/install-skill.ts
+4 -10
@@ -1,15 +1,14 @@
1 -import { Config, Data, Effect, FileSystem, Option, Path } from 'effect';
1 +import { Data, Effect, FileSystem, Path } from 'effect';
2 import { HttpClient } from 'effect/unstable/http';
3 import { NodeOs } from 'src/services/node-os';
4 import { TerminalUI } from 'src/services/terminal-ui';
5 -import { GITHUB_CONFIG } from 'src/effects/github-config';
5 +import { GITHUB_CONFIG, type GitHubConfig } from 'src/config';
6 import { APP_VERSION, type CliReleaseChannel } from 'src/constants';
7 import { resolveRunningCliReleaseTag } from 'src/services/run-companion-modules';
8 import {
9 fetchLatestCliRelease,
10 fetchCliReleaseByTag,
11 type GitHubRelease,
12 - type GitHubRepoConfig,
12 } from 'src/effects/resolve-cli-release';
13 import { extractZipSafely } from 'src/utils/extract-zip-safely';
14
@@ -33,11 +32,6 @@ const SKILL_TARGET_DIRECTORIES: Record<SkillInstallTarget, ReadonlyArray<string>
32 openclaw: ['.openclaw', 'skills'],
33 };
34
36 -type GitHubConfig = GitHubRepoConfig & {
37 - TAG: Option.Option<string>;
38 - ACCESS_TOKEN: Option.Option<string>;
39 -};
40 -
35 export class SkillInstallError extends Data.TaggedError('effects/SkillInstallError')<{
36 readonly cause?: unknown;
37 readonly message: string;
@@ -96,7 +90,7 @@ export const resolveSkillReleaseTag = ({
90 return releaseTag;
91 }
92
99 - const configTag = Option.getOrUndefined(githubConfig.TAG);
93 + const configTag = githubConfig.tag;
94 if (configTag) {
95 return configTag;
96 }
@@ -138,7 +132,7 @@ export const installSkill = (options?: {
132 const fs = yield* FileSystem.FileSystem;
133 const path = yield* Path.Path;
134 const httpClient = yield* HttpClient.HttpClient;
141 - const githubConfig = yield* Config.all(GITHUB_CONFIG);
135 + const githubConfig = yield* GITHUB_CONFIG;
136 const home = os.homedir;
137 const target = options?.target ?? 'claude';
138 const skillName = resolveInstalledSkillName(options?.skillName);
ts/packages/cli/src/effects/resolve-cli-release.ts
+4 -7
@@ -2,6 +2,7 @@ import { Data, Effect, Option, Schema } from 'effect';
2 import { HttpClient, HttpClientResponse } from 'effect/unstable/http';
3 import { semverComparator } from 'src/effects/compare-semver';
4 import type { CliReleaseChannel } from 'src/constants';
5 +import type { GitHubConfig } from 'src/config';
6
7 export const GitHubReleaseAsset = Schema.Struct({
8 name: Schema.NonEmptyString,
@@ -36,11 +37,7 @@ export class CliReleaseResolutionError extends Data.TaggedError(
37 readonly status?: number;
38 }> {}
39
39 -export type GitHubRepoConfig = {
40 - API_BASE_URL: string;
41 - OWNER: string;
42 - REPO: string;
43 -};
40 +export type GitHubRepoConfig = Pick<GitHubConfig, 'apiBaseUrl' | 'owner' | 'repo'>;
41
42 export const CLI_RELEASE_TAG_PATTERN = /^@composio\/cli@\d+\.\d+\.\d+.*$/;
43
@@ -56,7 +53,7 @@ export const fetchCliReleaseByTag = ({
53 tag: string;
54 }) =>
55 Effect.gen(function* () {
59 - const releaseUrl = `${githubConfig.API_BASE_URL}/repos/${githubConfig.OWNER}/${githubConfig.REPO}/releases/tags/${encodeURIComponent(tag)}`;
56 + const releaseUrl = `${githubConfig.apiBaseUrl}/repos/${githubConfig.owner}/${githubConfig.repo}/releases/tags/${encodeURIComponent(tag)}`;
57 const releaseResponse = yield* httpClient.get(releaseUrl).pipe(
58 Effect.mapError(
59 cause =>
@@ -102,7 +99,7 @@ export const fetchLatestCliRelease = ({
99 httpClient: HttpClient.HttpClient;
100 }) =>
101 Effect.gen(function* () {
105 - const releaseUrl = `${githubConfig.API_BASE_URL}/repos/${githubConfig.OWNER}/${githubConfig.REPO}/releases?per_page=100`;
102 + const releaseUrl = `${githubConfig.apiBaseUrl}/repos/${githubConfig.owner}/${githubConfig.repo}/releases?per_page=100`;
103 const releaseResponse = yield* httpClient.get(releaseUrl).pipe(
104 Effect.mapError(
105 cause =>
ts/packages/cli/src/effects/setup-cache-dir.ts
+1 -1
@@ -1,6 +1,6 @@
1 import { Effect, FileSystem, Path } from 'effect';
2 import * as constants from 'src/constants';
3 -import { APP_CONFIG } from 'src/effects/app-config';
3 +import { APP_CONFIG } from 'src/config';
4 import { NodeOs } from 'src/services/node-os';
5
6 // Helper to create cache directory
ts/packages/cli/src/effects/toolkit-version-overrides.ts
+15 -57
@@ -1,5 +1,5 @@
1 -import { Config, ConfigProvider, Effect, Option, Schema, String } from 'effect';
2 -import { getBaseConfigProvider } from 'src/services/config';
1 +import { Config, Effect, Option, String } from 'effect';
2 +import { APP_CONFIG } from 'src/config';
3
4 /**
5 * Represents a toolkit with its version specification.
@@ -10,22 +10,6 @@ export interface ToolkitVersionSpec {
10 readonly toolkitVersion: string;
11 }
12
13 -/**
14 - * Config that reads COMPOSIO_TOOLKIT_VERSION_<TOOLKIT>=<version> env vars.
15 - * Uses `Config.Record` scoped to the `COMPOSIO.TOOLKIT.VERSION` path to read
16 - * all env vars matching `COMPOSIO_TOOLKIT_VERSION_${TOOLKIT}` as record keys.
17 - *
18 - * @example
19 - * // Given: COMPOSIO_TOOLKIT_VERSION_GMAIL=20250901_00
20 - * // Returns: { "GMAIL": "20250901_00" }
21 - */
22 -export const TOOLKIT_VERSION_OVERRIDES_CONFIG: Config.Config<
23 - Option.Option<Readonly<Record<string, string>>>
24 -> = Config.option(
25 - // Optional, so missing env vars don't fail the config
26 - Config.Record(Schema.String, Schema.String, ['COMPOSIO', 'TOOLKIT', 'VERSION'])
27 -);
28 -
13 /**
14 * Map type with lowercase toolkit slugs as keys.
15 */
@@ -58,16 +42,8 @@ export const sanitizeVersionString = (version: string): string | null => {
42 };
43
44 /**
61 - * Reads toolkit version overrides from environment variables.
62 - *
63 - * Uses Effect's Config system to read env vars matching the pattern
64 - * COMPOSIO_TOOLKIT_VERSION_<TOOLKIT>=<version>.
65 - *
66 - * This function uses `getBaseConfigProvider()` directly (bypassing `extendConfigProvider`)
67 - * to correctly parse the nested path structure of the environment variable names.
68 - *
69 - * @returns Effect that yields a Map<Lowercase<string>, string> where keys are lowercase toolkit slugs
70 - * and values are version strings
45 + * Reads `COMPOSIO_TOOLKIT_VERSION_<TOOLKIT>=<version>` pins into a map keyed by lowercase
46 + * toolkit slug. `latest` and blank values are skipped; versions are sanitized.
47 *
48 * @example
49 * // Given: COMPOSIO_TOOLKIT_VERSION_GMAIL=20250901_00
@@ -76,35 +52,17 @@ export const sanitizeVersionString = (version: string): string | null => {
52 export const getToolkitVersionOverrides: Effect.Effect<
53 ToolkitVersionOverrides,
54 Config.ConfigError
79 -> = Effect.gen(function* () {
80 - const maybeOverrides = yield* TOOLKIT_VERSION_OVERRIDES_CONFIG;
81 -
82 - return Option.match(maybeOverrides, {
83 - onNone: () => new Map<Lowercase<string>, string>(),
84 - onSome: record => {
85 - const result = new Map<Lowercase<string>, string>();
86 - for (const [key, value] of Object.entries(record)) {
87 - // Normalize toolkit name to lowercase and skip 'latest' values
88 - if (value && value !== 'latest') {
89 - // Sanitize version string to only allow valid characters
90 - const sanitizedVersion = sanitizeVersionString(value);
91 - if (sanitizedVersion) {
92 - result.set(String.toLowerCase(key), sanitizedVersion);
93 - }
94 - }
95 - }
96 - return result;
97 - },
98 - });
99 -}).pipe(
100 - Effect.provideServiceEffect(
101 - ConfigProvider.ConfigProvider,
102 - // Deferred via `Effect.sync` so the provider (and the `process.env` snapshot
103 - // it captures) is constructed when this Effect actually runs, not when this
104 - // module-level Effect value is built at import time.
105 - Effect.sync(() => getBaseConfigProvider())
106 - )
107 -);
55 +> = Effect.map(APP_CONFIG.TOOLKIT_VERSIONS, maybeOverrides => {
56 + const result = new Map<Lowercase<string>, string>();
57 + for (const [key, value] of Object.entries(Option.getOrElse(maybeOverrides, () => ({})))) {
58 + if (!value || value === 'latest') continue;
59 + const sanitizedVersion = sanitizeVersionString(value);
60 + if (sanitizedVersion) {
61 + result.set(String.toLowerCase(key), sanitizedVersion);
62 + }
63 + }
64 + return result;
65 +});
66
67 /**
68 * Builds an array of ToolkitVersionSpec from toolkit slugs and version overrides.
ts/packages/cli/src/effects/version.ts
+6 -8
@@ -1,12 +1,10 @@
1 -import { Effect, Option } from 'effect';
2 -import { DEBUG_OVERRIDE_CONFIG } from 'src/effects/debug-config';
1 +import { Effect } from 'effect';
2 +import { DEBUG_CONFIG } from 'src/config';
3 import * as constants from 'src/constants';
4 import { resolveRunningCliVersion } from 'src/services/run-companion-modules';
5
6 -export const getVersion = Effect.flatMap(
7 - DEBUG_OVERRIDE_CONFIG.VERSION,
8 - Option.match({
9 - onNone: () => resolveRunningCliVersion(process.execPath, constants.APP_VERSION),
10 - onSome: version => Effect.succeed(version),
11 - })
6 +export const getVersion = Effect.flatMap(DEBUG_CONFIG.VERSION, version =>
7 + version === undefined
8 + ? resolveRunningCliVersion(process.execPath, constants.APP_VERSION)
9 + : Effect.succeed(version)
10 );
ts/packages/cli/src/effects/with-log-level.ts
+9 -6
@@ -1,5 +1,5 @@
1 import { Effect, Option, LogLevel, Layer, References } from 'effect';
2 -import { APP_CONFIG } from 'src/effects/app-config';
2 +import { APP_CONFIG } from 'src/config';
3
4 /**
5 * Sets the minimum log level for subsequent logging operations: the `--log-level` CLI flag
@@ -7,11 +7,14 @@ import { APP_CONFIG } from 'src/effects/app-config';
7 * otherwise `Info`.
8 */
9 export const setMinimumLogLevel = (logLevelFromCLI: Option.Option<LogLevel.LogLevel>) =>
10 - APP_CONFIG['LOG_LEVEL'].pipe(
11 - Effect.map(logLevelFromEnv => {
12 - return Option.orElse(logLevelFromCLI, () => logLevelFromEnv);
13 - }),
14 - Effect.map(Option.getOrElse((): LogLevel.LogLevel => 'Info')),
10 + APP_CONFIG.LOG_LEVEL.pipe(
11 + Effect.map(
12 + (logLevelFromEnv): LogLevel.LogLevel =>
13 + Option.getOrUndefined(logLevelFromCLI) ?? logLevelFromEnv ?? 'Info'
14 + ),
15 Effect.map(logLevel => Layer.succeed(References.MinimumLogLevel, logLevel)),
16 Layer.unwrap
17 );
18 +
19 +/** The `COMPOSIO_LOG_LEVEL` level alone, for layers built before the root command parses flags. */
20 +export const LogLevelFromConfigLive = setMinimumLogLevel(Option.none());
ts/packages/cli/src/services/agent-host-env.ts
+9 -40
@@ -1,53 +1,22 @@
1 import * as FileSystem from 'effect/FileSystem';
2 import * as Path from 'effect/Path';
3 -import { Config, Effect, Option } from 'effect';
3 +import { Effect, Option } from 'effect';
4 +import { HOST_CONFIG, type AgentHostEnvironment } from 'src/config';
5 import type { AgentHost } from './agent-host';
5 -import { loadHostConfig } from './config';
6 import { NodeOs } from './node-os';
7
8 -export interface HostEnvMarkers {
9 - readonly claudeCode: string | undefined;
10 - readonly codexThreadId: string | undefined;
11 - readonly codexSandbox: string | undefined;
12 -}
13 -
14 -export interface RawHostEnvironment extends HostEnvMarkers {
15 - readonly claudeConfigDir: string | undefined;
16 - readonly codexHome: string | undefined;
17 -}
18 -
19 -const isPresent = (value: string | undefined): boolean =>
20 - value !== undefined && value.trim().length > 0;
21 -
22 -const nonBlankOrUndefined = (value: string | undefined): string | undefined => {
23 - if (!isPresent(value)) return undefined;
24 - return value;
25 -};
8 +type HostEnvMarkers = Pick<AgentHostEnvironment, 'claudeCode' | 'codexThreadId' | 'codexSandbox'>;
9
10 +// Blank markers already read as `undefined` (see `HOST_CONFIG`).
11 export function detectPluginHost(markers: HostEnvMarkers): AgentHost | undefined {
28 - if (isPresent(markers.claudeCode)) return 'claude';
29 - if (isPresent(markers.codexThreadId) || isPresent(markers.codexSandbox)) return 'codex';
12 + if (markers.claudeCode !== undefined) return 'claude';
13 + if (markers.codexThreadId !== undefined || markers.codexSandbox !== undefined) return 'codex';
14 return undefined;
15 }
16
33 -const optionalRawEnv = (name: string) =>
34 - Config.option(Config.String(name)).pipe(Config.map(Option.getOrUndefined));
35 -
36 -// Host-owned variables must bypass the CLI ConfigProvider, which prefixes
37 -// application keys with COMPOSIO_. loadHostConfig builds a fresh
38 -// ConfigProvider.fromEnv() per execution (v4's fromEnv snapshots the
39 -// environment at build time), so live env changes and test stubs are
40 -// always observed.
41 -const HostEnvironmentConfig = Config.all({
42 - claudeCode: optionalRawEnv('CLAUDECODE'),
43 - codexThreadId: optionalRawEnv('CODEX_THREAD_ID'),
44 - codexSandbox: optionalRawEnv('CODEX_SANDBOX'),
45 - claudeConfigDir: optionalRawEnv('CLAUDE_CONFIG_DIR').pipe(Config.map(nonBlankOrUndefined)),
46 - codexHome: optionalRawEnv('CODEX_HOME').pipe(Config.map(nonBlankOrUndefined)),
47 -});
48 -
49 -export const rawHostEnvironment: Effect.Effect<RawHostEnvironment> =
50 - loadHostConfig(HostEnvironmentConfig);
17 +export const rawHostEnvironment: Effect.Effect<AgentHostEnvironment> = Effect.orDie(
18 + HOST_CONFIG.AGENT_HOST
19 +);
20
21 export const hostConfigDirectory = (host: AgentHost) =>
22 Effect.gen(function* () {
ts/packages/cli/src/services/agents.ts
+1 -1
@@ -2,7 +2,7 @@ import { cliRequestHeaders } from './client-provenance';
2 import * as FileSystem from 'effect/FileSystem';
3 import * as Path from 'effect/Path';
4 import { Data, Effect, Option, Predicate, Result, Schema } from 'effect';
5 -import { APP_CONFIG } from 'src/effects/app-config';
5 +import { APP_CONFIG } from 'src/config';
6 import { JsonRecordSchema } from 'src/effects/json';
7 import { setupCacheDir } from 'src/effects/setup-cache-dir';
8 import { atomicWritePrivateFileString, ensurePrivateFileMode } from 'src/utils/atomic-write';
ts/packages/cli/src/services/cli-session-artifacts.ts
+1 -1
@@ -1,7 +1,7 @@
1 import * as FileSystem from 'effect/FileSystem';
2 import * as Path from 'effect/Path';
3 import { Effect, Option } from 'effect';
4 -import { APP_CONFIG } from 'src/effects/app-config';
4 +import { APP_CONFIG } from 'src/config';
5 import { getOrCreateProbablyMyCliSessionIdForCurrentCwd } from 'src/services/consumer-short-term-cache';
6 import { ComposioCliUserConfig } from 'src/services/cli-user-config';
7 import { NodeOs } from 'src/services/node-os';
ts/packages/cli/src/services/composio-clients-cached.ts
+4 -4
@@ -3,7 +3,7 @@ import * as FileSystem from 'effect/FileSystem';
3 import * as Path from 'effect/Path';
4 import * as BunFileSystem from '@effect/platform-bun/BunFileSystem';
5 import { setupCacheDir } from 'src/effects/setup-cache-dir';
6 -import { FORCE_CONFIG } from 'src/effects/force-config';
6 +import { DEBUG_CONFIG } from 'src/config';
7 import { writeFileAtomic } from 'src/effects/write-file-atomic';
8 import {
9 ComposioToolkitsRepository,
@@ -26,7 +26,7 @@ import {
26 TriggerTypesToJSON,
27 type TriggerTypes,
28 } from 'src/models/trigger-types';
29 -import { ConfigLive } from './config';
29 +import { LogLevelFromConfigLive } from 'src/effects/with-log-level';
30
31 /**
32 * Cache file names for different data types
@@ -68,7 +68,7 @@ function createCachedEffect<T, E, R>(
68 */
69 const readFromCache = (fs: FileSystem.FileSystem, cacheFilePath: string) =>
70 Effect.gen(function* () {
71 - const consumeFromCache = yield* FORCE_CONFIG['USE_CACHE'];
71 + const consumeFromCache = yield* DEBUG_CONFIG.FORCE_USE_CACHE;
72 if (!consumeFromCache) {
73 return Option.none<T>();
74 }
@@ -303,5 +303,5 @@ export const ComposioToolkitsRepositoryCached = Layer.effect(
303 })
304 ).pipe(
305 // Provide the required dependencies for the layer
306 - Layer.provide(Layer.mergeAll(BunFileSystem.layer, NodeOs.Default, ConfigLive))
306 + Layer.provide(Layer.mergeAll(BunFileSystem.layer, NodeOs.Default, LogLevelFromConfigLive))
307 );
ts/packages/cli/src/services/config.ts deleted
-92
@@ -1,92 +0,0 @@
1 -import { Config, Option, Effect, ConfigProvider, Layer, References } from 'effect';
2 -import * as constants from 'src/constants';
3 -import { DEBUG_OVERRIDE_CONFIG } from 'src/effects/debug-config';
4 -import { APP_CONFIG } from 'src/effects/app-config';
5 -
6 -/**
7 - * Define where `effect/Config` reads config values from.
8 - * Lookup priority:
9 - * 1. Environment variables
10 - *
11 - * Environment variables' keys are in upper snake case.
12 - * They are prefixed with `COMPOSIO_`, with the only exception of `DEBUG_OVERRIDE_*` and `FORCE_*` variables.
13 - * The prefix is stripped when reading the environment variables from `effect/Config`.
14 - *
15 - * @example
16 - * ```sh
17 - * # Environment variable
18 - * COMPOSIO_USER_API_KEY=your_user_api_key
19 - * ```
20 - *
21 - * Read via `yield* Config.String('USER_API_KEY')`.
22 - */
23 -
24 -/**
25 - * Builds a fresh `ConfigProvider` backed by the current process environment.
26 - *
27 - * This MUST be constructed lazily (a function, not a memoized module-level
28 - * constant): `ConfigProvider.fromEnv()` snapshots `process.env` into an
29 - * internal trie at construction time, so a module-level constant would freeze
30 - * the environment as of first import and never observe later env var changes
31 - * (e.g. `vi.stubEnv` in tests, or any other in-process env mutation).
32 - */
33 -export function getBaseConfigProvider(): ConfigProvider.ConfigProvider {
34 - return ConfigProvider.fromEnv();
35 -}
36 -
37 -/**
38 - * Load a config whose keys are spelled out in full, through the raw provider
39 - * that applies no `COMPOSIO_` prefix mapping. Pair it with `UNPREFIXED_CONFIG`.
40 - */
41 -export const loadHostConfig = <A>(config: Config.Config<A>): Effect.Effect<A> =>
42 - Effect.suspend(() => config.parse(getBaseConfigProvider())).pipe(Effect.orDie);
43 -
44 -export function extendConfigProvider(baseConfigProvider: ConfigProvider.ConfigProvider) {
45 - return baseConfigProvider.pipe(
46 - ConfigProvider.mapInput(path =>
47 - path.map(segment => {
48 - if (typeof segment !== 'string') {
49 - return segment;
50 - }
51 - if (segment.startsWith('DEBUG_OVERRIDE_') || segment.startsWith('FORCE_')) {
52 - return segment;
53 - }
54 - return `${constants.APP_ENV_CONFIG_KEY_PREFIX}${segment}`;
55 - })
56 - )
57 - );
58 -}
59 -
60 -/**
61 - * Tentatively set the minimum log level if found in the config.
62 - */
63 -const LoggerFromConfigLive = Effect.map(
64 - APP_CONFIG['LOG_LEVEL'],
65 - Option.match({
66 - onNone: () => Layer.empty,
67 - onSome: logLevel => Layer.succeed(References.MinimumLogLevel, logLevel),
68 - })
69 -).pipe(Layer.unwrap);
70 -
71 -/**
72 - * Print a debug message for each debug environment variable that overrides dynamic configuration values.
73 - */
74 -const logDebugOverride = Effect.gen(function* () {
75 - const debugOverrideEntries = Object.keys(DEBUG_OVERRIDE_CONFIG) as [
76 - keyof typeof DEBUG_OVERRIDE_CONFIG,
77 - ];
78 -
79 - for (const key of debugOverrideEntries) {
80 - const configEntry = yield* DEBUG_OVERRIDE_CONFIG[key];
81 - if (Option.isSome(configEntry)) {
82 - yield* Effect.logDebug(
83 - `Using \`${constants.DEBUG_OVERRIDE_ENV_CONFIG_KEY_PREFIX}${key}\` debug override`
84 - );
85 - }
86 - }
87 -});
88 -
89 -export const ConfigLive = LoggerFromConfigLive.pipe(
90 - Layer.tap(() => logDebugOverride),
91 - Layer.tap(() => Effect.logDebug('ConfigLive layer initialized'))
92 -);
ts/packages/cli/src/services/consumer-short-term-cache.ts
+1 -1
@@ -1,7 +1,7 @@
1 import * as FileSystem from 'effect/FileSystem';
2 import * as Path from 'effect/Path';
3 import { Effect, Option, Record as EffectRecord, Schema } from 'effect';
4 -import { APP_CONFIG } from 'src/effects/app-config';
4 +import { APP_CONFIG } from 'src/config';
5 import { JsonRecordSchema } from 'src/effects/json';
6 import { setupCacheDir } from 'src/effects/setup-cache-dir';
7 import { NodeProcess } from 'src/services/node-process';
ts/packages/cli/src/services/master-detector.ts
+5 -5
@@ -1,6 +1,5 @@
1 import { Effect } from 'effect';
2 -import { UNPREFIXED_CONFIG } from 'src/effects/app-config';
3 -import { loadHostConfig } from 'src/services/config';
2 +import { HOST_CONFIG } from 'src/config';
3
4 export type MasterKind = 'claude' | 'codex' | 'user';
5
@@ -19,6 +18,7 @@ export const detectMaster = (signals: MasterSignals): MasterKind => {
18 return 'user';
19 };
20
22 -export const detectMasterFromHost: Effect.Effect<MasterKind> = loadHostConfig(
23 - UNPREFIXED_CONFIG.MASTER_SIGNALS
24 -).pipe(Effect.map(detectMaster));
21 +export const detectMasterFromHost: Effect.Effect<MasterKind> = HOST_CONFIG.MASTER_SIGNALS.pipe(
22 + Effect.orDie,
23 + Effect.map(detectMaster)
24 +);
ts/packages/cli/src/services/permission-ui.ts
+7 -21
@@ -1,21 +1,12 @@
1 import * as BunServices from '@effect/platform-bun/BunServices';
2 -import { Config, Effect, Stream } from 'effect';
2 +import { Effect, Stream } from 'effect';
3 import { ChildProcess, ChildProcessSpawner } from 'effect/unstable/process';
4 -import { UNPREFIXED_CONFIG } from 'src/effects/app-config';
5 -import { loadHostConfig } from 'src/services/config';
4 +import { HOST_CONFIG, type CallerAgentSignals } from 'src/config';
5
6 export type PermissionCallerAgent = 'claude' | 'codex' | 'openclaw' | 'composio';
7
9 -/**
10 - * The browser approval page must never open from automated environments. The
11 - * explicit COMPOSIO_DISABLE_PERMISSION_UI knob wins in both directions; without
12 - * it, CI and Vitest runs disable the UI.
13 - */
14 -export const interactivePermissionUiDisabledConfig =
15 - UNPREFIXED_CONFIG.INTERACTIVE_PERMISSION_UI_DISABLED;
16 -
17 -export const isInteractivePermissionUiDisabled: Effect.Effect<boolean> = loadHostConfig(
18 - interactivePermissionUiDisabledConfig
8 +export const isInteractivePermissionUiDisabled: Effect.Effect<boolean> = Effect.orDie(
9 + HOST_CONFIG.INTERACTIVE_PERMISSION_UI_DISABLED
10 );
11
12 // Enhanced controls are not offered on Intel Macs (#3421).
@@ -77,12 +68,8 @@ const detectCallerAgentFromProcessTree: Effect.Effect<
68 return undefined;
69 });
70
80 -export type PermissionCallerAgentSignals = Config.Success<
81 - typeof UNPREFIXED_CONFIG.CALLER_AGENT_SIGNALS
82 ->;
83 -
71 const detectCallerAgentFromSignals = (
85 - signals: PermissionCallerAgentSignals
72 + signals: CallerAgentSignals
73 ): PermissionCallerAgent | undefined => {
74 const explicit = normalizeCallerAgent(signals.explicit);
75 if (explicit) return explicit;
@@ -95,11 +82,10 @@ const detectCallerAgentFromSignals = (
82 };
83
84 export const detectPermissionCallerAgentEffect = (
98 - providedSignals?: PermissionCallerAgentSignals
85 + providedSignals?: CallerAgentSignals
86 ): Effect.Effect<PermissionCallerAgent, never, ChildProcessSpawner.ChildProcessSpawner> =>
87 Effect.gen(function* () {
101 - const signals =
102 - providedSignals ?? (yield* loadHostConfig(UNPREFIXED_CONFIG.CALLER_AGENT_SIGNALS));
88 + const signals = providedSignals ?? (yield* Effect.orDie(HOST_CONFIG.CALLER_AGENT_SIGNALS));
89 const fromEnv = detectCallerAgentFromSignals(signals);
90 if (fromEnv !== undefined) return fromEnv;
91
ts/packages/cli/src/services/plugin-hint.ts
+1 -1
@@ -4,7 +4,7 @@ import * as BunFileSystem from '@effect/platform-bun/BunFileSystem';
4 import { Effect, Exit, Layer, Option, Schema } from 'effect';
5 import { trackCliEventEffect } from 'src/analytics/dispatch';
6 import { getPluginHintShownEvent } from 'src/analytics/events';
7 -import { APP_CONFIG } from 'src/effects/app-config';
7 +import { APP_CONFIG } from 'src/config';
8 import { setupCacheDir } from 'src/effects/setup-cache-dir';
9 import { APP_VERSION } from 'src/constants';
10 import { AGENT_HOST_LABELS, COMPOSIO_AGENT_PLUGIN_ID, type AgentHost } from './agent-host';
ts/packages/cli/src/services/project-context.ts
+4 -4
@@ -3,7 +3,7 @@ import * as FileSystem from 'effect/FileSystem';
3 import * as Path from 'effect/Path';
4 import { NodeOs } from 'src/services/node-os';
5 import { NodeProcess } from 'src/services/node-process';
6 -import { APP_CONFIG } from 'src/effects/app-config';
6 +import { APP_CONFIG } from 'src/config';
7 import { getAncestors } from 'src/utils/get-ancestors';
8 import * as constants from 'src/constants';
9 import { type ProjectKeys, projectKeysFromJSON } from 'src/models/project-keys';
@@ -66,11 +66,11 @@ const makeProjectContext = Effect.gen(function* () {
66 // 1. Check env vars (highest priority)
67 const envOrgId = yield* APP_CONFIG.ORG_ID;
68 const envProjectId = yield* APP_CONFIG.PROJECT_ID;
69 - if (Option.isSome(envOrgId) && Option.isSome(envProjectId)) {
69 + if (envOrgId !== undefined && envProjectId !== undefined) {
70 yield* Effect.logDebug('ProjectContext: resolved from env vars');
71 return Option.some<ProjectKeys>({
72 - orgId: envOrgId.value,
73 - projectId: envProjectId.value,
72 + orgId: envOrgId,
73 + projectId: envProjectId,
74 projectName: Option.none(),
75 orgName: Option.none(),
76 email: Option.none(),
ts/packages/cli/src/services/project-environment-detector.ts
+2 -5
@@ -3,8 +3,7 @@ import * as FileSystem from 'effect/FileSystem';
3 import * as Path from 'effect/Path';
4 import { Data, Effect, Match, Context, Layer } from 'effect';
5 import { getAncestors } from 'src/utils/get-ancestors';
6 -import { UNPREFIXED_CONFIG } from 'src/effects/app-config';
7 -import { loadHostConfig } from 'src/services/config';
6 +import { HOST_CONFIG } from 'src/config';
7
8 const toError = (e: unknown): Error => (e instanceof Error ? e : new Error(String(e)));
9
@@ -500,9 +499,7 @@ const detectJsPackageManager = (fs: FileSystem.FileSystem, cwd: string) =>
499 if (fileSet.has('pnpm-workspace.yaml')) return 'pnpm' as const;
500 }
501
503 - const userAgent = parseUserAgent(
504 - yield* loadHostConfig(UNPREFIXED_CONFIG.NPM_CONFIG_USER_AGENT)
505 - );
502 + const userAgent = parseUserAgent(yield* Effect.orDie(HOST_CONFIG.NPM_CONFIG_USER_AGENT));
503 if (userAgent) return userAgent;
504
505 return 'npm' as const;
ts/packages/cli/src/services/run-companion-modules.ts
+14 -64
@@ -4,11 +4,11 @@
4 // outside the CLI runtime (companion runtimes, scripts) provide their own platform layers.
5 import * as FileSystem from 'effect/FileSystem';
6 import * as Path from 'effect/Path';
7 -import { Config, ConfigProvider, Data, Effect, Option, PlatformError, Schema } from 'effect';
7 +import { Data, Effect, Option, PlatformError, Schema } from 'effect';
8 import { extractZipSafely } from 'src/utils/extract-zip-safely';
9 import { APP_VERSION, IS_RELEASE_BUILD } from 'src/constants';
10 import { GitHubRelease } from 'src/effects/resolve-cli-release';
11 -import { getBaseConfigProvider, extendConfigProvider } from 'src/services/config';
11 +import { GITHUB_REPAIR_CONFIG } from 'src/config';
12 import { atomicReplaceFile } from 'src/utils/atomic-replace';
13 import { parseChecksumsText, sha256Hex } from 'src/utils/checksums';
14 import { CLI_RELEASE_TAG_PREFIX } from 'src/utils/cli-release-version';
@@ -157,12 +157,6 @@ export const collectExpectedRunCompanionAssetRelativePaths = (
157 return [...collected].sort();
158 });
159
160 -const DEFAULT_GITHUB_CONFIG = {
161 - apiBaseUrl: 'https://api.github.com',
162 - owner: 'ComposioHQ',
163 - repo: 'composio',
164 -};
165 -
160 const resolveBinaryAssetName = ({
161 platform = process.platform,
162 arch = process.arch,
@@ -391,67 +385,19 @@ const toRepairError = (error: unknown) =>
385 cause: error,
386 });
387
394 -// Self-repair honors the unprefixed GITHUB_* contract (set by CI and the binary
395 -// build workflow) first, then falls back to the
396 -// CLI-wide COMPOSIO_-prefixed spelling installed by cli-main's config provider.
397 -//
398 -// Built lazily (a function, not a memoized module-level constant): each
399 -// `getBaseConfigProvider()` call snapshots `process.env` at call time, so a
400 -// frozen constant would never observe env var changes made after this module
401 -// is first imported (e.g. `vi.stubEnv` in tests).
402 -const getRepairConfigProvider = (): ConfigProvider.ConfigProvider =>
403 - getBaseConfigProvider().pipe(
404 - ConfigProvider.orElse(extendConfigProvider(getBaseConfigProvider()))
405 - );
406 -
388 +// GITHUB_TAG pins the release used for self-repair (set by the binary build workflow).
389 const resolveRepairReleaseTag = ({
390 + pinnedTag,
391 execPath,
392 appVersion,
393 }: {
394 + pinnedTag: string | undefined;
395 execPath: string;
396 appVersion: string;
397 }) =>
414 - Effect.gen(function* () {
415 - // GITHUB_TAG pins the release used for self-repair (set by the binary build workflow).
416 - const pinnedTag = yield* Effect.orDie(
417 - Config.option(Config.String('GITHUB_TAG')).pipe(
418 - Config.map(tag => Option.getOrUndefined(Option.map(tag, value => value.trim())))
419 - )
420 - ).pipe(
421 - Effect.provideServiceEffect(
422 - ConfigProvider.ConfigProvider,
423 - Effect.sync(() => getRepairConfigProvider())
424 - )
425 - );
426 - if (pinnedTag) {
427 - return pinnedTag;
428 - }
429 -
430 - return yield* resolveRunningCliReleaseTag(execPath, appVersion);
431 - });
432 -
433 -const nonEmptyConfigWithFallback = (name: string, fallback: string) =>
434 - Config.String(name).pipe(
435 - Config.map(value => value || fallback),
436 - Config.withDefault(fallback)
437 - );
438 -
439 -// The GITHUB_* overrides let CI and forks redirect the self-repair download.
440 -const githubRepairConfig = Effect.orDie(
441 - Effect.all({
442 - apiBaseUrl: nonEmptyConfigWithFallback('GITHUB_API_BASE_URL', DEFAULT_GITHUB_CONFIG.apiBaseUrl),
443 - owner: nonEmptyConfigWithFallback('GITHUB_OWNER', DEFAULT_GITHUB_CONFIG.owner),
444 - repo: nonEmptyConfigWithFallback('GITHUB_REPO', DEFAULT_GITHUB_CONFIG.repo),
445 - accessToken: Config.option(Config.String('GITHUB_ACCESS_TOKEN')).pipe(
446 - Config.map(Option.getOrUndefined)
447 - ),
448 - })
449 -).pipe(
450 - Effect.provideServiceEffect(
451 - ConfigProvider.ConfigProvider,
452 - Effect.sync(() => getRepairConfigProvider())
453 - )
454 -);
398 + pinnedTag === undefined
399 + ? resolveRunningCliReleaseTag(execPath, appVersion)
400 + : Effect.succeed(pinnedTag);
401
402 /**
403 * Restores a packaged install whose companion wrappers went missing, from the
@@ -494,8 +440,12 @@ export const repairMissingInstalledRunCompanionModules = ({
440 return { repaired: false as const };
441 }
442
497 - const releaseTag = yield* resolveRepairReleaseTag({ execPath, appVersion });
498 - const githubConfig = yield* githubRepairConfig;
443 + const githubConfig = yield* Effect.orDie(GITHUB_REPAIR_CONFIG);
444 + const releaseTag = yield* resolveRepairReleaseTag({
445 + pinnedTag: githubConfig.tag,
446 + execPath,
447 + appVersion,
448 + });
449
450 const encodedTag = encodeURIComponent(releaseTag);
451 const release = yield* Effect.tryPromise({
ts/packages/cli/src/services/runtime-cli-context.ts
+1 -1
@@ -1,5 +1,5 @@
1 import { Context, Effect, Layer, Option } from 'effect';
2 -import { APP_CONFIG } from 'src/effects/app-config';
2 +import { APP_CONFIG } from 'src/config';
3
4 export const DEFAULT_CLI_INVOCATION_ORIGIN = 'cli';
5
ts/packages/cli/src/services/runtime-flags.ts
+4 -5
@@ -1,7 +1,6 @@
1 import { Context, Effect, Layer, Option } from 'effect';
2 import { Flag, GlobalFlag } from 'effect/unstable/cli';
3 -import { APP_CONFIG, UNPREFIXED_CONFIG } from 'src/effects/app-config';
4 -import { loadHostConfig } from 'src/services/config';
3 +import { DEBUG_CONFIG } from 'src/config';
4
5 export const TELEMETRY_DEBUG_FLAG = '--telemetry-debug';
6
@@ -75,13 +74,13 @@ const debugFlagOr = <const Name extends string>(
74 export const isPerfDebugEnabled = debugFlagOr(
75 debugSettings['perf-debug'],
76 overrides => overrides.perfDebug,
78 - Effect.orDie(APP_CONFIG.PERF_DEBUG)
77 + Effect.orDie(DEBUG_CONFIG.PERF_DEBUG)
78 );
79
80 export const isToolDebugEnabled = debugFlagOr(
81 debugSettings['tool-debug'],
82 overrides => overrides.toolDebug,
84 - Effect.orDie(APP_CONFIG.TOOL_DEBUG)
83 + Effect.orDie(DEBUG_CONFIG.TOOL_DEBUG)
84 );
85
86 /**
@@ -118,5 +117,5 @@ export const isTelemetryDebugEnabled: Effect.Effect<boolean> = Effect.gen(functi
117 const bootstrap = yield* Effect.serviceOption(TelemetryDebugMode);
118 return Option.isSome(bootstrap)
119 ? bootstrap.value
121 - : yield* loadHostConfig(UNPREFIXED_CONFIG.TELEMETRY_DEBUG);
120 + : yield* Effect.orDie(DEBUG_CONFIG.TELEMETRY_DEBUG);
121 });
ts/packages/cli/src/services/setup-skill-installer.ts
+3 -3
@@ -1,7 +1,7 @@
1 import * as FileSystem from 'effect/FileSystem';
2 import * as Path from 'effect/Path';
3 import { HttpClient } from 'effect/unstable/http';
4 -import { Config, Effect, Context, Layer } from 'effect';
4 +import { Effect, Context, Layer } from 'effect';
5 import {
6 inferSkillReleaseChannel,
7 installSkill,
@@ -10,7 +10,7 @@ import {
10 resolveTargetSkillPath,
11 SKILL_RELEASE_TAG_FILENAME,
12 } from 'src/effects/install-skill';
13 -import { GITHUB_CONFIG } from 'src/effects/github-config';
13 +import { GITHUB_CONFIG } from 'src/config';
14 import { APP_VERSION } from 'src/constants';
15 import { resolveRunningCliReleaseTag } from 'src/services/run-companion-modules';
16 import { NodeOs } from './node-os';
@@ -21,7 +21,7 @@ export const resolveSetupSkillReleaseTag = (
21 ) =>
22 Effect.gen(function* () {
23 const httpClient = yield* HttpClient.HttpClient;
24 - const githubConfig = yield* Config.all(GITHUB_CONFIG);
24 + const githubConfig = yield* GITHUB_CONFIG;
25 const installedReleaseTag = yield* resolveRunningCliReleaseTag(execPath, fallbackVersion);
26
27 return yield* resolveSkillReleaseTag({
ts/packages/cli/src/services/update-check.ts
+6 -9
@@ -1,10 +1,11 @@
1 import * as FileSystem from 'effect/FileSystem';
2 import * as Path from 'effect/Path';
3 import * as BunFileSystem from '@effect/platform-bun/BunFileSystem';
4 -import { Config, Data, Effect, Layer, Option, Predicate, Schema } from 'effect';
4 +import { Data, Effect, Layer, Option, Predicate, Schema } from 'effect';
5 import semver from 'semver';
6 import { bold, cyanBright, dim } from 'src/ui/colors';
7 -import { APP_VERSION, GITHUB_REPO } from '../constants';
7 +import { GITHUB_CONFIG } from 'src/config';
8 +import { APP_VERSION } from '../constants';
9 import { NodeOs, type NodeOsShape } from './node-os';
10 import { resolveRunningCliVersion } from './run-companion-modules';
11 import { TerminalUI } from './terminal-ui';
@@ -100,18 +101,14 @@ const defaultConfig = (stateFile: string) =>
101 Effect.gen(function* () {
102 const os = yield* NodeOs;
103 const currentVersion = yield* resolveRunningCliVersion(process.execPath, APP_VERSION);
103 - const accessToken = yield* Effect.orDie(
104 - Config.option(Config.String('COMPOSIO_GITHUB_ACCESS_TOKEN')).pipe(
105 - Config.map(Option.getOrUndefined)
106 - )
107 - );
104 + const github = yield* Effect.orDie(GITHUB_CONFIG);
105 return {
106 stateFile,
107 currentVersion,
108 checkIntervalMs: CHECK_INTERVAL_MS,
112 - releasesUrl: `${GITHUB_REPO.API_BASE_URL}/repos/${GITHUB_REPO.OWNER}/${GITHUB_REPO.REPO}/releases?per_page=100`,
109 + releasesUrl: `${github.apiBaseUrl}/repos/${github.owner}/${github.repo}/releases?per_page=100`,
110 binaryAssetName: getCurrentBinaryAssetName(os),
114 - accessToken,
111 + accessToken: github.accessToken,
112 fetchFn: fetch,
113 } satisfies UpdateCheckConfig;
114 });
ts/packages/cli/src/services/upgrade-binary.ts
+8 -12
@@ -1,7 +1,6 @@
1 import {
2 Data,
3 Effect,
4 - Config,
4 Match,
5 Option,
6 Predicate,
@@ -15,8 +14,7 @@ import { HttpClient, HttpClientResponse } from 'effect/unstable/http';
14 import * as FileSystem from 'effect/FileSystem';
15 import * as Path from 'effect/Path';
16 import { APP_VERSION } from '../constants';
18 -import { DEBUG_OVERRIDE_CONFIG } from 'src/effects/debug-config';
19 -import { GITHUB_CONFIG } from 'src/effects/github-config';
17 +import { DEBUG_CONFIG, GITHUB_CONFIG, type GitHubConfig } from 'src/config';
18 import { detectPlatform, type PlatformArch } from 'src/effects/detect-platform';
19 import { CompareSemverError, semverComparator } from 'src/effects/compare-semver';
20 import { fetchLatestCliRelease, GitHubRelease } from 'src/effects/resolve-cli-release';
@@ -53,15 +51,13 @@ const getBinaryAssetName = (platformArch: PlatformArch) =>
51 const hasPlatformBinaryAsset = (release: GitHubRelease, platformArch: PlatformArch) =>
52 release.assets.some(asset => asset.name === getBinaryAssetName(platformArch));
53
56 -const GITHUB_CONFIG_ALL = Config.all(GITHUB_CONFIG);
57 -
54 // Dependencies resolved once at service construction time and threaded
55 // through the module-level helpers below.
56 interface UpgradeBinaryContext {
57 readonly httpClient: HttpClient.HttpClient;
58 readonly fs: FileSystem.FileSystem;
59 readonly path: Path.Path;
64 - readonly githubConfig: Config.Success<typeof GITHUB_CONFIG_ALL>;
60 + readonly githubConfig: GitHubConfig;
61 }
62
63 /**
@@ -73,7 +69,7 @@ const fetchGitHubRelease = (
69 ): Effect.Effect<GitHubRelease, UpgradeBinaryError, never> =>
70 Effect.gen(function* () {
71 const encodedTag = encodeURIComponent(tag);
76 - const url = `${githubConfig.API_BASE_URL}/repos/${githubConfig.OWNER}/${githubConfig.REPO}/releases/tags/${encodedTag}`;
72 + const url = `${githubConfig.apiBaseUrl}/repos/${githubConfig.owner}/${githubConfig.repo}/releases/tags/${encodedTag}`;
73 const fetchErrorMessage = `Failed to fetch tags/${tag} release from GitHub`;
74 yield* Effect.logDebug(`GET ${url}`);
75
@@ -126,7 +122,7 @@ const fetchLatestRelease = (
122 Effect.gen(function* () {
123 const { githubConfig, httpClient } = ctx;
124 const prerelease = options.prerelease ?? false;
129 - const explicitTag = options.tag ? Option.some(options.tag) : githubConfig.TAG;
125 + const explicitTag = Option.fromNullishOr(options.tag ?? githubConfig.tag);
126 const release = yield* explicitTag.pipe(
127 Option.match({
128 onNone: Effect.fn(function* () {
@@ -628,7 +624,7 @@ const upgrade = (
624 ) =>
625 Effect.gen(function* () {
626 const ui = yield* TerminalUI;
631 - const upgradeTargetOpt = yield* DEBUG_OVERRIDE_CONFIG['UPGRADE_TARGET'];
627 + const upgradeTarget = yield* DEBUG_CONFIG.UPGRADE_TARGET;
628 const currentPath = yield* getCurrentExecutablePath();
629 const prerelease = options.prerelease ?? false;
630 const explicitTag = options.tag;
@@ -639,9 +635,9 @@ const upgrade = (
635 yield* ui.intro('composio upgrade');
636
637 // If local binary path is provided (for testing), use it directly
642 - if (Option.isSome(upgradeTargetOpt)) {
638 + if (upgradeTarget !== undefined) {
639 yield* ui.log.info(`New local version available (current: ${currentReleaseIdentifier})`);
644 - yield* replaceBinary(ctx, upgradeTargetOpt.value, currentPath, {
640 + yield* replaceBinary(ctx, upgradeTarget, currentPath, {
641 releaseTag: explicitTag,
642 });
643 yield* ui.outro('Upgrade completed');
@@ -725,7 +721,7 @@ const makeUpgradeBinary = Effect.gen(function* () {
721 httpClient: yield* HttpClient.HttpClient,
722 fs: yield* FileSystem.FileSystem,
723 path: yield* Path.Path,
728 - githubConfig: yield* GITHUB_CONFIG_ALL,
724 + githubConfig: yield* GITHUB_CONFIG,
725 };
726
727 return {
ts/packages/cli/src/services/user-context.ts
+4 -4
@@ -10,7 +10,7 @@ import {
10 import { JsonRecordSchema } from 'src/effects/json';
11 import { setupCacheDir } from 'src/effects/setup-cache-dir';
12 import * as constants from 'src/constants';
13 -import { APP_CONFIG } from 'src/effects/app-config';
13 +import { APP_CONFIG } from 'src/config';
14 import { KeyringService, KeyringLiveWithBackend } from '@composio/cli-keyring/effect';
15 import type { KeyringServiceShape } from '@composio/cli-keyring/effect';
16 import { KeyringError, type MacOSBackend } from '@composio/cli-keyring';
@@ -167,9 +167,9 @@ export const rawComposioUserContextLive = Layer.effect(
167 Effect.gen(function* () {
168 const fs = yield* FileSystem.FileSystem;
169 const path = yield* Path.Path;
170 - const apiKey = yield* APP_CONFIG['USER_API_KEY'];
171 - const baseURL = yield* APP_CONFIG['BASE_URL'];
172 - const webURL = yield* APP_CONFIG['WEB_URL'];
170 + const apiKey = Option.fromNullishOr(yield* APP_CONFIG.USER_API_KEY);
171 + const baseURL = yield* APP_CONFIG.BASE_URL;
172 + const webURL = yield* APP_CONFIG.WEB_URL;
173 const cliConfig = yield* ComposioCliUserConfig;
174 const keyring = yield* KeyringService;
175
ts/packages/cli/src/ui/colors.ts
+2 -3
@@ -1,9 +1,8 @@
1 import color from 'picocolors';
2 import { Effect } from 'effect';
3 -import { UNPREFIXED_CONFIG } from 'src/effects/app-config';
4 -import { loadHostConfig } from 'src/services/config';
3 +import { HOST_CONFIG } from 'src/config';
4
6 -const colorsEnabled = !Effect.runSync(loadHostConfig(UNPREFIXED_CONFIG.NO_COLOR));
5 +const colorsEnabled = !Effect.runSync(HOST_CONFIG.NO_COLOR);
6
7 export const {
8 bold,
ts/packages/cli/src/ui/redact.ts
+2 -3
@@ -1,11 +1,10 @@
1 import { Effect } from 'effect';
2 -import { UNPREFIXED_CONFIG } from 'src/effects/app-config';
3 -import { loadHostConfig } from 'src/services/config';
2 +import { HOST_CONFIG } from 'src/config';
3
4 // Read once at import time, like `ui/colors.ts`: `redact` runs per formatted
5 // value, and spinning up a fiber per call to read a single environment
6 // variable is pure overhead.
8 -const ciRedactionEnabled = Effect.runSync(loadHostConfig(UNPREFIXED_CONFIG.CI_REDACTION_ENABLED));
7 +const ciRedactionEnabled = Effect.runSync(HOST_CONFIG.CI_REDACTION_ENABLED);
8
9 /**
10 * Redact a value when running in CI (e.g., CLI recordings).
ts/packages/cli/test/__utils__/index.ts
+1
@@ -6,3 +6,4 @@ export { TestLayer as TestLive } from './services/test-layer';
6 export { cli } from './cli';
7 export { pkg };
8 export { withHttpServer } from './http-server';
9 +export { hostOnlyEnvConfigProvider, liveEnvConfigProvider } from './live-env-config-provider';
ts/packages/cli/test/__utils__/live-env-config-provider.ts
+20 -1
@@ -1,4 +1,4 @@
1 -import { ConfigProvider } from 'effect';
1 +import { ConfigProvider, Effect } from 'effect';
2
3 /**
4 * `ConfigProvider.fromEnv` snapshots the environment when it is built, so a
@@ -8,3 +8,22 @@ import { ConfigProvider } from 'effect';
8 export const liveEnvConfigProvider: ConfigProvider.ConfigProvider = ConfigProvider.make(
9 configPath => ConfigProvider.fromEnv().load(configPath)
10 );
11 +
12 +// Variables a developer shell may export that would change what a test observes: every
13 +// Composio setting (`APP_CONFIG`, `TELEMETRY_CONFIG`, `GITHUB_CONFIG`, the `COMPOSIO_*_DEBUG`
14 +// toggles) and the developer overrides in `DEBUG_CONFIG`.
15 +const MASKED_PREFIXES = ['COMPOSIO_', 'DEBUG_OVERRIDE_', 'FORCE_'];
16 +
17 +/**
18 + * The default provider of `TestLive`: the real host environment (`CI`, `VITEST`, `PATH`, the
19 + * agent-host markers, ...) read live, but never the developer shell's Composio settings or
20 + * `DEBUG_OVERRIDE_*` / `FORCE_*` overrides, so a test only sees the values it provides itself.
21 + */
22 +export const hostOnlyEnvConfigProvider: ConfigProvider.ConfigProvider = ConfigProvider.make(
23 + configPath => {
24 + const name = configPath.map(String).join('_');
25 + return MASKED_PREFIXES.some(prefix => name.startsWith(prefix))
26 + ? Effect.succeed(undefined)
27 + : liveEnvConfigProvider.load(configPath);
28 + }
29 +);
ts/packages/cli/test/__utils__/services/test-layer.ts
+10 -3
@@ -33,6 +33,7 @@ import {
33 import { CliConfig, type Command as CliCommand } from 'effect/unstable/cli';
34 import { ChildProcess, ChildProcessSpawner } from 'effect/unstable/process';
35 import { ComposioCliConfig } from 'src/cli-config';
36 +import { hostOnlyEnvConfigProvider } from 'test/__utils__/live-env-config-provider';
37 import * as MockConsole from './mock-console';
38 import * as MockTerminal from './mock-terminal';
39 import { TerminalUITest } from './terminal-ui-test';
@@ -128,8 +129,10 @@ export interface MockAccountRequest {
129
130 export interface TestLiveInput {
131 /**
131 - * Base config provider to use in test.
132 - * If not provided, the default `ConfigProvider.fromEnv({ env: {} })` is used.
132 + * Config provider to use in test. Its values win; anything it leaves unset falls through to
133 + * `hostOnlyEnvConfigProvider`, the live host environment without any `COMPOSIO_*`,
134 + * `DEBUG_OVERRIDE_*`, or `FORCE_*` variable, so `HOST_CONFIG` (`CI`, `VITEST`, `PATH`, the
135 + * agent-host markers) keeps reading the real process the way the old raw-provider bypass did.
136 */
137 baseConfigProvider?: ConfigProvider.ConfigProvider;
138
@@ -1612,7 +1615,11 @@ export const TestLayer = (input?: TestLiveInput) =>
1615 // `ConfigProvider` reference instead of the test's `baseConfigProvider`. `Layer.provideMerge`
1616 // keeps `ConfigProvider` in the output so it stays visible to everything `TestLayer` provides.
1617 Layer.provideMerge(
1615 - ConfigProvider.layer(input?.baseConfigProvider ?? ConfigProvider.fromEnv({ env: {} }))
1618 + ConfigProvider.layer(
1619 + input?.baseConfigProvider === undefined
1620 + ? hostOnlyEnvConfigProvider
1621 + : ConfigProvider.orElse(input.baseConfigProvider, hostOnlyEnvConfigProvider)
1622 + )
1623 )
1624 );
1625
ts/packages/cli/test/src/analytics.dispatch.test.ts
+7 -6
@@ -2,7 +2,7 @@ import { describe, expect, it } from '@effect/vitest';
2 import { afterEach, beforeEach, vi } from 'vitest';
3 import * as BunFileSystem from '@effect/platform-bun/BunFileSystem';
4 import * as BunPath from '@effect/platform-bun/BunPath';
5 -import { Effect, FileSystem, Layer, Path } from 'effect';
5 +import { ConfigProvider, Effect, FileSystem, Layer, Path } from 'effect';
6 import { mkdirSync, rmSync, writeFileSync } from 'node:fs';
7 import path from 'node:path';
8 import { FetchHttpClient } from 'effect/unstable/http';
@@ -22,6 +22,7 @@ import { cliRunIdLayer } from 'src/services/runtime-cli-context';
22 import { APP_VERSION, USER_CONFIG_FILE_NAME } from 'src/constants';
23 import { defaultNodeOs, NodeOs } from 'src/services/node-os';
24 import { TerminalUITest } from 'test/__utils__/services/terminal-ui-test';
25 +import { liveEnvConfigProvider } from 'test/__utils__/live-env-config-provider';
26
27 const childProcessMocks = vi.hoisted(() => ({
28 once: vi.fn(),
@@ -56,11 +57,14 @@ const cwdHash = (cwd: string): string => {
57 // which `makePlatformLayerWithFetch` below wires up. Tests that never
58 // exercise a fetch-reaching code path use the plain `makePlatformLayer` and
59 // don't touch `globalThis.fetch` at all.
60 +// `vi.stubEnv` drives every scenario, so config reads go through a provider that re-reads
61 +// the environment per lookup instead of the process-wide snapshot `ConfigProvider` defaults to.
62 const makePlatformLayer = (home: string) =>
63 Layer.mergeAll(
64 BunFileSystem.layer,
65 BunPath.layer,
66 FetchHttpClient.layer,
67 + ConfigProvider.layer(liveEnvConfigProvider),
68 TerminalUITest,
69 Layer.succeed(NodeOs, defaultNodeOs({ homedir: home }))
70 );
@@ -70,6 +74,7 @@ const makePlatformLayerWithFetch = (home: string, fetchImpl: typeof fetch) =>
74 BunFileSystem.layer,
75 BunPath.layer,
76 FetchHttpClient.layer,
77 + ConfigProvider.layer(liveEnvConfigProvider),
78 Layer.succeed(FetchHttpClient.Fetch, fetchImpl),
79 TerminalUITest,
80 Layer.succeed(NodeOs, defaultNodeOs({ homedir: home }))
@@ -130,15 +135,11 @@ describe('CLI analytics dispatch', () => {
135 const cacheDir = tempy.temporaryDirectory();
136 const cwd = '/workspace/project';
137 vi.stubEnv('COMPOSIO_CACHE_DIR', cacheDir);
133 - vi.stubEnv('COMPOSIO_BASE_URL', '');
138 + vi.stubEnv('COMPOSIO_BASE_URL', 'https://backend.example.test///');
139
140 return Effect.gen(function* () {
141 const fs = yield* FileSystem.FileSystem;
142 const path = yield* Path.Path;
138 - yield* fs.writeFileString(
139 - path.join(cacheDir, USER_CONFIG_FILE_NAME),
140 - JSON.stringify({ base_url: 'https://backend.example.test///' })
141 - );
143 yield* fs.writeFileString(
144 path.join(cacheDir, 'consumer-short-term-cache.json'),
145 JSON.stringify({
ts/packages/cli/test/src/commands/auth-configs/auth-configs.create.cmd.test.ts
+1 -2
@@ -1,13 +1,12 @@
1 import { describe, expect, layer } from '@effect/vitest';
2 import type { AuthConfigCreateParams } from '@composio/client/resources/auth-configs';
3 import { ConfigProvider, Effect } from 'effect';
4 -import { extendConfigProvider } from 'src/services/config';
4 import { cli, TestLive, MockConsole } from 'test/__utils__';
5 import type { TestLiveInput } from 'test/__utils__/services/test-layer';
6
7 const testConfigProvider = ConfigProvider.fromEnv({
8 env: { COMPOSIO_USER_API_KEY: 'test_api_key' },
10 -}).pipe(extendConfigProvider);
9 +});
10
11 const dangerousDevConfig = {
12 cliUserConfig: {
ts/packages/cli/test/src/commands/auth-configs/auth-configs.info.cmd.test.ts
+1 -2
@@ -1,6 +1,5 @@
1 import { describe, expect, layer } from '@effect/vitest';
2 import { ConfigProvider, Effect } from 'effect';
3 -import { extendConfigProvider } from 'src/services/config';
3 import { cli, TestLive, MockConsole } from 'test/__utils__';
4 import type { TestLiveInput } from 'test/__utils__/services/test-layer';
5 import type { AuthConfigItem } from 'src/models/auth-configs';
@@ -27,7 +26,7 @@ const authConfigsData = {
26
27 const testConfigProvider = ConfigProvider.fromEnv({
28 env: { COMPOSIO_USER_API_KEY: 'test_api_key' },
30 -}).pipe(extendConfigProvider);
29 +});
30
31 describe('CLI: composio dev auth-configs info', () => {
32 layer(TestLive({ baseConfigProvider: testConfigProvider, authConfigsData }))(
ts/packages/cli/test/src/commands/auth-configs/auth-configs.list.cmd.test.ts
+1 -2
@@ -1,6 +1,5 @@
1 import { describe, expect, layer } from '@effect/vitest';
2 import { ConfigProvider, Effect } from 'effect';
3 -import { extendConfigProvider } from 'src/services/config';
3 import { cli, TestLive, MockConsole } from 'test/__utils__';
4 import type { TestLiveInput } from 'test/__utils__/services/test-layer';
5 import type { AuthConfigItem } from 'src/models/auth-configs';
@@ -53,7 +52,7 @@ const authConfigsData = {
52
53 const testConfigProvider = ConfigProvider.fromEnv({
54 env: { COMPOSIO_USER_API_KEY: 'test_api_key' },
56 -}).pipe(extendConfigProvider);
55 +});
56
57 describe('CLI: composio dev auth-configs list', () => {
58 layer(TestLive({ baseConfigProvider: testConfigProvider, authConfigsData }))(
ts/packages/cli/test/src/commands/connected-accounts/connected-accounts.info.cmd.test.ts
+1 -2
@@ -1,6 +1,5 @@
1 import { describe, expect, layer } from '@effect/vitest';
2 import { ConfigProvider, Effect } from 'effect';
3 -import { extendConfigProvider } from 'src/services/config';
3 import { cli, TestLive, MockConsole } from 'test/__utils__';
4 import type { TestLiveInput } from 'test/__utils__/services/test-layer';
5 import type { ConnectedAccountItem } from 'src/models/connected-accounts';
@@ -31,7 +30,7 @@ const connectedAccountsData = {
30
31 const testConfigProvider = ConfigProvider.fromEnv({
32 env: { COMPOSIO_USER_API_KEY: 'test_api_key' },
34 -}).pipe(extendConfigProvider);
33 +});
34
35 describe('CLI: composio dev connected-accounts info', () => {
36 layer(TestLive({ baseConfigProvider: testConfigProvider, connectedAccountsData }))(
ts/packages/cli/test/src/commands/connected-accounts/connected-accounts.link.cmd.test.ts
+1 -2
@@ -1,7 +1,6 @@
1 import { APIError } from '@composio/client';
2 import { describe, expect, layer } from '@effect/vitest';
3 import { ConfigProvider, Console, Effect } from 'effect';
4 -import { extendConfigProvider } from 'src/services/config';
4 import { cli, TestLive, MockConsole } from 'test/__utils__';
5 import { makeSessionInfo } from 'test/__utils__/models/account';
6 import type { MockRequestScope } from 'test/__utils__/services/test-layer';
@@ -57,7 +56,7 @@ const connectedAccountWithCredentialFields = {
56
57 const testConfigProvider = ConfigProvider.fromEnv({
58 env: { COMPOSIO_USER_API_KEY: 'test_api_key' },
60 -}).pipe(extendConfigProvider);
59 +});
60
61 const RecordingTerminalUI = TerminalUI.of({
62 capabilities: Effect.succeed(
ts/packages/cli/test/src/commands/connected-accounts/connected-accounts.list.cmd.test.ts
+1 -2
@@ -1,6 +1,5 @@
1 import { describe, expect, layer } from '@effect/vitest';
2 import { ConfigProvider, Effect } from 'effect';
3 -import { extendConfigProvider } from 'src/services/config';
3 import { ComposioUserContext } from 'src/services/user-context';
4 import { cli, TestLive, MockConsole } from 'test/__utils__';
5 import type { TestLiveInput } from 'test/__utils__/services/test-layer';
@@ -70,7 +69,7 @@ const testDevConfigProvider = ConfigProvider.fromEnv({
69 COMPOSIO_ORG_ID: 'dev_org_test',
70 COMPOSIO_PROJECT_ID: 'dev_project_test',
71 },
73 -}).pipe(extendConfigProvider);
72 +});
73
74 describe('CLI: composio dev connected-accounts list', () => {
75 layer(TestLive({ baseConfigProvider: testDevConfigProvider, connectedAccountsData }))(
ts/packages/cli/test/src/commands/connected-accounts/connected-accounts.whoami.cmd.test.ts
+1 -2
@@ -1,6 +1,5 @@
1 import { describe, expect, layer } from '@effect/vitest';
2 import { ConfigProvider, Effect } from 'effect';
3 -import { extendConfigProvider } from 'src/services/config';
3 import { cli, TestLive, MockConsole } from 'test/__utils__';
4 import type { TestLiveInput } from 'test/__utils__/services/test-layer';
5 import type { ConnectedAccountItem } from 'src/models/connected-accounts';
@@ -48,7 +47,7 @@ const connectedAccountsData = {
47
48 const testConfigProvider = ConfigProvider.fromEnv({
49 env: { COMPOSIO_USER_API_KEY: 'test_api_key' },
51 -}).pipe(extendConfigProvider);
50 +});
51
52 describe('CLI: composio dev connected-accounts whoami', () => {
53 layer(TestLive({ baseConfigProvider: testConfigProvider, connectedAccountsData }))(
ts/packages/cli/test/src/commands/connections/connections.list.cmd.test.ts
+1 -2
@@ -1,7 +1,6 @@
1 import { describe, expect, layer } from '@effect/vitest';
2 import { ConfigProvider, Console, Effect } from 'effect';
3 import type { ConnectedAccountItem } from 'src/models/connected-accounts';
4 -import { extendConfigProvider } from 'src/services/config';
4 import { getTerminalCapabilities, TerminalUI } from 'src/services/terminal-ui';
5 import { ComposioUserContext } from 'src/services/user-context';
6 import { cli, TestLive, MockConsole } from 'test/__utils__';
@@ -86,7 +85,7 @@ const connectedAccountsData = {
85
86 const testConfigProvider = ConfigProvider.fromEnv({
87 env: { COMPOSIO_USER_API_KEY: 'test_api_key' },
89 -}).pipe(extendConfigProvider);
88 +});
89
90 const terminalUIWithConfirm = (confirmed: boolean) =>
91 TerminalUI.of({
ts/packages/cli/test/src/commands/dev.cmd.test.ts
+1 -2
@@ -1,11 +1,10 @@
1 import { describe, expect, layer } from '@effect/vitest';
2 import { ConfigProvider, Effect } from 'effect';
3 -import { extendConfigProvider } from 'src/services/config';
3 import { cli, MockConsole, TestLive } from 'test/__utils__';
4
5 const testConfigProvider = ConfigProvider.fromEnv({
6 env: { COMPOSIO_USER_API_KEY: 'test_api_key' },
8 -}).pipe(extendConfigProvider);
7 +});
8
9 describe('CLI: composio dev', () => {
10 layer(TestLive({ baseConfigProvider: testConfigProvider }))(it => {
ts/packages/cli/test/src/commands/install.cmd.test.ts
+1 -2
@@ -11,7 +11,6 @@ import {
11 type Shell,
12 } from 'src/commands/install.cmd';
13 import { makeTerminalUI } from 'src/services/terminal-ui';
14 -import { extendConfigProvider } from 'src/services/config';
14 import { cli, TestLive, MockConsole } from 'test/__utils__';
15 import { liveEnvConfigProvider } from 'test/__utils__/live-env-config-provider';
16
@@ -43,7 +42,7 @@ const TEST_EXEC_PATH = '/usr/local/bin/composio';
42 const expectedRuntimeBinDir = (): string => path.dirname(TEST_EXEC_PATH);
43 const InstallTestLive = (input: Parameters<typeof TestLive>[0] = {}) =>
44 TestLive({
46 - baseConfigProvider: liveEnvConfigProvider.pipe(extendConfigProvider),
45 + baseConfigProvider: liveEnvConfigProvider,
46 execPath: TEST_EXEC_PATH,
47 ...input,
48 });
ts/packages/cli/test/src/commands/listen.cmd.test.ts
+1 -2
@@ -1,13 +1,12 @@
1 import { describe, expect, layer } from '@effect/vitest';
2 import { Cause, ConfigProvider, Effect, Exit } from 'effect';
3 import { ListenCommandError } from 'src/commands/listen.cmd';
4 -import { extendConfigProvider } from 'src/services/config';
4 import { ComposioCliUserConfig } from 'src/services/cli-user-config';
5 import { cli, MockConsole, TestLive } from 'test/__utils__';
6
7 const testConfigProvider = ConfigProvider.fromEnv({
8 env: { COMPOSIO_USER_API_KEY: 'test_api_key' },
10 -}).pipe(extendConfigProvider);
9 +});
10
11 const enableListen = Effect.gen(function* () {
12 const config = yield* ComposioCliUserConfig;
ts/packages/cli/test/src/commands/logout.cmd.test.ts
+1 -2
@@ -6,7 +6,6 @@ import * as constants from 'src/constants';
6 import { setupCacheDir } from 'src/effects/setup-cache-dir';
7 import { UserDataWithDefaults } from 'src/models/user-data';
8 import { writeStoredAgentIdentity } from 'src/services/agents';
9 -import { extendConfigProvider } from 'src/services/config';
9 import { getTerminalCapabilities, TerminalUI } from 'src/services/terminal-ui';
10 import { ComposioUserContext } from 'src/services/user-context';
11 import { cli, TestLive, MockConsole } from 'test/__utils__';
@@ -107,7 +106,7 @@ describe('CLI: composio logout', () => {
106 describe('[When] logged in', () => {
107 const testConfigProvider = ConfigProvider.fromEnv({
108 env: { COMPOSIO_USER_API_KEY: 'api_key_already_logged_in' },
110 - }).pipe(extendConfigProvider);
109 + });
110
111 layer(TestLive({ baseConfigProvider: testConfigProvider }))(it => {
112 it.effect('[Then] it persists user data', () =>
ts/packages/cli/test/src/commands/orgs.switch.cmd.test.ts
+1 -2
@@ -1,7 +1,6 @@
1 import { describe, expect, layer } from '@effect/vitest';
2 import { ConfigProvider, Effect } from 'effect';
3 import { afterEach, vi } from 'vitest';
4 -import { extendConfigProvider } from 'src/services/config';
4 import { cli, TestLive } from 'test/__utils__';
5 import { makeSessionInfo } from 'test/__utils__/models/account';
6 import type { MockRequestScope } from 'test/__utils__/services/test-layer';
@@ -31,7 +30,7 @@ describe('CLI: composio orgs switch', () => {
30
31 const testConfigProvider = ConfigProvider.fromEnvRecord({
32 COMPOSIO_USER_API_KEY: 'uak_switch_test',
34 - }).pipe(extendConfigProvider);
33 + });
34
35 const sessionInfoScopes: MockRequestScope[] = [];
36 layer(
ts/packages/cli/test/src/commands/proxy.cmd.test.ts
+1 -2
@@ -6,7 +6,6 @@ import type {
6 SessionCreateParams,
7 SessionProxyExecuteParams,
8 } from '@composio/client/resources/tool-router';
9 -import { extendConfigProvider } from 'src/services/config';
9 import {
10 normalizeProxyMethod,
11 parseProxyBody,
@@ -18,7 +17,7 @@ import { cli, MockConsole, TestLive } from 'test/__utils__';
17
18 const testConfigProvider = ConfigProvider.fromEnv({
19 env: { COMPOSIO_USER_API_KEY: 'test_api_key' },
21 -}).pipe(extendConfigProvider);
20 +});
21
22 describe('CLI: composio proxy', () => {
23 afterEach(() => {
ts/packages/cli/test/src/commands/py/py.generate.cmd.test.ts
+3 -1
@@ -3,7 +3,7 @@ import path from 'node:path';
3 import { describe, expect, layer } from '@effect/vitest';
4 import { Effect, Predicate } from 'effect';
5 import * as FileSystem from 'effect/FileSystem';
6 -import { cli, TestLive } from 'test/__utils__';
6 +import { cli, liveEnvConfigProvider, TestLive } from 'test/__utils__';
7 import { makeTestToolkits } from 'test/__utils__/models/toolkits';
8 import { NodeProcess } from 'src/services/node-process';
9 import { TRIGGER_TYPES_GMAIL } from 'test/__mocks__/trigger-types-gmail';
@@ -32,6 +32,8 @@ describe('CLI: composio generate py', () => {
32 TestLive({
33 fixture: 'python-project-with-composio-core',
34 toolkitsData: appClientData,
35 + // The COMPOSIO_TOOLKIT_VERSION_* scenarios below stub the environment.
36 + baseConfigProvider: liveEnvConfigProvider,
37 })
38 )(it => {
39 describe('[Given] valid fetched app data', () => {
ts/packages/cli/test/src/commands/run.cmd.test.ts
+1 -2
@@ -25,7 +25,6 @@ import {
25 resolveRunCompanionModulePath,
26 writeInstalledReleaseTag,
27 } from 'src/services/run-companion-modules';
28 -import { extendConfigProvider } from 'src/services/config';
28 import { telemetryDebugModeLayer } from 'src/services/runtime-flags';
29 import { DEFAULT_CLI_INVOCATION_ORIGIN } from 'src/services/runtime-cli-context';
30 import { cli, MockConsole, TestLive } from 'test/__utils__';
@@ -35,7 +34,7 @@ const enabledRuntimeFlagsConfigProvider = ConfigProvider.fromEnvRecord({
34 COMPOSIO_RUN_ACP_ONLY: '1',
35 COMPOSIO_PERF_DEBUG: '1',
36 COMPOSIO_TOOL_DEBUG: '1',
38 -}).pipe(extendConfigProvider);
37 +});
38
39 const readRunPreloadSource = (command: ReadonlyArray<string>): string => {
40 const preloadPath = command[2];
ts/packages/cli/test/src/commands/toolkits/toolkits.info.cmd.test.ts
+1 -2
@@ -1,6 +1,5 @@
1 import { describe, expect, layer } from '@effect/vitest';
2 import { ConfigProvider, DateTime, Effect } from 'effect';
3 -import { extendConfigProvider } from 'src/services/config';
3 import { cli, TestLive, MockConsole } from 'test/__utils__';
4 import type { TestLiveInput } from 'test/__utils__/services/test-layer';
5 import type { Toolkits, ToolkitDetailed } from 'src/models/toolkits';
@@ -127,7 +126,7 @@ const toolkitsData = {
126
127 const testConfigProvider = ConfigProvider.fromEnv({
128 env: { COMPOSIO_USER_API_KEY: 'test_api_key' },
130 -}).pipe(extendConfigProvider);
129 +});
130
131 describe('CLI: composio dev toolkits info', () => {
132 layer(TestLive({ baseConfigProvider: testConfigProvider, toolkitsData }))(
ts/packages/cli/test/src/commands/toolkits/toolkits.list.cmd.test.ts
+1 -2
@@ -1,6 +1,5 @@
1 import { describe, expect, layer } from '@effect/vitest';
2 import { ConfigProvider, DateTime, Effect } from 'effect';
3 -import { extendConfigProvider } from 'src/services/config';
3 import { cli, TestLive, MockConsole } from 'test/__utils__';
4 import type { TestLiveInput } from 'test/__utils__/services/test-layer';
5 import type { Toolkits } from 'src/models/toolkits';
@@ -65,7 +64,7 @@ const toolkitsData = {
64
65 const testConfigProvider = ConfigProvider.fromEnv({
66 env: { COMPOSIO_USER_API_KEY: 'test_api_key' },
68 -}).pipe(extendConfigProvider);
67 +});
68
69 describe('CLI: composio dev toolkits list', () => {
70 layer(TestLive({ baseConfigProvider: testConfigProvider, toolkitsData }))(
ts/packages/cli/test/src/commands/toolkits/toolkits.search.cmd.test.ts
+1 -2
@@ -1,6 +1,5 @@
1 import { describe, expect, layer } from '@effect/vitest';
2 import { ConfigProvider, DateTime, Effect } from 'effect';
3 -import { extendConfigProvider } from 'src/services/config';
3 import { cli, TestLive, MockConsole } from 'test/__utils__';
4 import type { TestLiveInput } from 'test/__utils__/services/test-layer';
5 import type { Toolkits } from 'src/models/toolkits';
@@ -65,7 +64,7 @@ const toolkitsData = {
64
65 const testConfigProvider = ConfigProvider.fromEnv({
66 env: { COMPOSIO_USER_API_KEY: 'test_api_key' },
68 -}).pipe(extendConfigProvider);
67 +});
68
69 describe('CLI: composio dev toolkits search', () => {
70 layer(TestLive({ baseConfigProvider: testConfigProvider, toolkitsData }))(
ts/packages/cli/test/src/commands/toolkits/toolkits.version.cmd.test.ts
+1 -2
@@ -1,6 +1,5 @@
1 import { describe, expect, layer } from '@effect/vitest';
2 import { ConfigProvider, DateTime, Effect } from 'effect';
3 -import { extendConfigProvider } from 'src/services/config';
3 import { cli, TestLive, MockConsole } from 'test/__utils__';
4 import type { TestLiveInput } from 'test/__utils__/services/test-layer';
5 import type { Toolkits, ToolkitDetailed } from 'src/models/toolkits';
@@ -57,7 +56,7 @@ const toolkitsData = {
56
57 const testConfigProvider = ConfigProvider.fromEnv({
58 env: { COMPOSIO_USER_API_KEY: 'test_api_key' },
60 -}).pipe(extendConfigProvider);
59 +});
60
61 const parseLastJson = (lines: ReadonlyArray<string>) => {
62 for (let i = lines.length - 1; i >= 0; i -= 1) {
ts/packages/cli/test/src/commands/tools/tools.execute.cmd.test.ts
+8 -10
@@ -4,7 +4,6 @@ import * as path from 'node:path';
4 import { describe, expect, it, layer } from '@effect/vitest';
5 import { vi, beforeEach, afterEach } from 'vitest';
6 import { Config, ConfigProvider, DateTime, Effect, Exit, Option, Predicate } from 'effect';
7 -import { extendConfigProvider } from 'src/services/config';
7 import { APIError } from '@composio/client';
8 import { ComposioNoActiveConnectionError } from 'src/services/composio-error-overrides';
9 import { setupCacheDir } from 'src/effects/setup-cache-dir';
@@ -38,7 +37,7 @@ vi.hoisted(() => {
37
38 const testConfigProvider = ConfigProvider.fromEnv({
39 env: { COMPOSIO_USER_API_KEY: 'test_api_key' },
41 -}).pipe(extendConfigProvider);
40 +});
41
42 // `testConfigProvider` pins its env, so it bypasses the per-test
43 // `COMPOSIO_CACHE_DIR` stub, and the learned toolkit slugs resolve against the
@@ -57,23 +56,22 @@ const isolatedCacheConfigProvider = (fixture: string) => {
56 );
57 return ConfigProvider.fromEnv({
58 env: { COMPOSIO_USER_API_KEY: 'test_api_key', COMPOSIO_CACHE_DIR: cacheDir },
60 - }).pipe(extendConfigProvider);
59 + });
60 };
61
62 const runInvocationConfigProvider = ConfigProvider.fromEnvRecord({
63 COMPOSIO_USER_API_KEY: 'test_api_key',
64 COMPOSIO_CLI_INVOCATION_ORIGIN: 'run',
66 -}).pipe(extendConfigProvider);
65 +});
66
67 // Reuse the suite-managed cache directory for artifacts without exposing the
69 -// empty test cache as the CLI's authenticated config directory. Path
70 -// transformations apply innermost first, so this rename sees the bare key and
71 -// `extendConfigProvider` adds the `COMPOSIO_` prefix afterwards.
68 +// empty test cache as the CLI's authenticated config directory: only
69 +// `COMPOSIO_SESSION_DIR` resolves, to the stubbed `COMPOSIO_CACHE_DIR`.
70 const testArtifactConfigProvider = liveEnvConfigProvider.pipe(
71 ConfigProvider.mapInput(configPath =>
72 configPath.map(segment =>
75 - segment === 'SESSION_DIR'
76 - ? 'CACHE_DIR'
73 + segment === 'COMPOSIO_SESSION_DIR'
74 + ? 'COMPOSIO_CACHE_DIR'
75 : typeof segment === 'string'
76 ? `UNSET_${segment}`
77 : segment
@@ -83,7 +81,7 @@ const testArtifactConfigProvider = liveEnvConfigProvider.pipe(
81
82 const largeOutputConfigProvider = ConfigProvider.fromEnvRecord({
83 COMPOSIO_USER_API_KEY: 'test_api_key',
86 -}).pipe(ConfigProvider.orElse(testArtifactConfigProvider), extendConfigProvider);
84 +}).pipe(ConfigProvider.orElse(testArtifactConfigProvider));
85
86 const expectInvalidValueMessage = (failure: unknown, message: string) => {
87 expect(Predicate.isTagged(failure, 'commands/ParallelExecuteArgumentError')).toBe(true);
ts/packages/cli/test/src/commands/tools/tools.info.cmd.test.ts
+1 -2
@@ -1,6 +1,5 @@
1 import { afterEach, describe, expect, layer } from '@effect/vitest';
2 import { ConfigProvider, Effect } from 'effect';
3 -import { extendConfigProvider } from 'src/services/config';
3 import { cli, TestLive, MockConsole } from 'test/__utils__';
4 import type { TestLiveInput } from 'test/__utils__/services/test-layer';
5 import type { Tools } from 'src/models/tools';
@@ -86,7 +85,7 @@ const toolkitsData = {
85
86 const testConfigProvider = ConfigProvider.fromEnv({
87 env: { COMPOSIO_USER_API_KEY: 'test_api_key' },
89 -}).pipe(extendConfigProvider);
88 +});
89
90 describe('CLI: composio tools info', () => {
91 afterEach(() => {
ts/packages/cli/test/src/commands/tools/tools.list.cmd.test.ts
+1 -2
@@ -1,6 +1,5 @@
1 import { describe, expect, layer } from '@effect/vitest';
2 import { ConfigProvider, Effect } from 'effect';
3 -import { extendConfigProvider } from 'src/services/config';
3 import { cli, TestLive, MockConsole } from 'test/__utils__';
4 import type { TestLiveInput } from 'test/__utils__/services/test-layer';
5 import type { Tools } from 'src/models/tools';
@@ -53,7 +52,7 @@ const toolkitsData = {
52
53 const testConfigProvider = ConfigProvider.fromEnv({
54 env: { COMPOSIO_USER_API_KEY: 'test_api_key' },
56 -}).pipe(extendConfigProvider);
55 +});
56
57 describe('CLI: composio tools list', () => {
58 layer(TestLive({ baseConfigProvider: testConfigProvider, toolkitsData }))(
ts/packages/cli/test/src/commands/tools/tools.search.cmd.test.ts
+1 -2
@@ -4,7 +4,6 @@ import type {
4 SessionCreateParams,
5 SessionSearchParams,
6 } from '@composio/client/resources/tool-router';
7 -import { extendConfigProvider } from 'src/services/config';
7 import { cli, TestLive, MockConsole } from 'test/__utils__';
8 import type { TestLiveInput } from 'test/__utils__/services/test-layer';
9 import type { Tools } from 'src/models/tools';
@@ -46,7 +45,7 @@ const toolkitsData = {
45
46 const testConfigProvider = ConfigProvider.fromEnv({
47 env: { COMPOSIO_USER_API_KEY: 'test_api_key' },
49 -}).pipe(extendConfigProvider);
48 +});
49
50 const testLiveOptions = {
51 baseConfigProvider: testConfigProvider,
ts/packages/cli/test/src/commands/triggers/triggers.info.cmd.test.ts
+1 -2
@@ -1,6 +1,5 @@
1 import { afterEach, describe, expect, layer } from '@effect/vitest';
2 import { ConfigProvider, Effect } from 'effect';
3 -import { extendConfigProvider } from 'src/services/config';
3 import { cli, MockConsole, TestLive } from 'test/__utils__';
4 import type { TriggerTypes } from 'src/models/trigger-types';
5 import type { TestLiveInput } from 'test/__utils__/services/test-layer';
@@ -52,7 +51,7 @@ const toolkitsData = {
51
52 const testConfigProvider = ConfigProvider.fromEnv({
53 env: { COMPOSIO_USER_API_KEY: 'test_api_key' },
55 -}).pipe(extendConfigProvider);
54 +});
55
56 describe('CLI: composio dev triggers info', () => {
57 afterEach(() => {
ts/packages/cli/test/src/commands/triggers/triggers.list.cmd.test.ts
+1 -2
@@ -1,6 +1,5 @@
1 import { describe, expect, layer } from '@effect/vitest';
2 import { Cause, ConfigProvider, Effect, Exit } from 'effect';
3 -import { extendConfigProvider } from 'src/services/config';
3 import { cli, MockConsole, TestLive } from 'test/__utils__';
4 import type { TriggerTypes } from 'src/models/trigger-types';
5 import type { TestLiveInput } from 'test/__utils__/services/test-layer';
@@ -51,7 +50,7 @@ const toolkitsData = {
50
51 const testConfigProvider = ConfigProvider.fromEnv({
52 env: { COMPOSIO_USER_API_KEY: 'test_api_key' },
54 -}).pipe(extendConfigProvider);
53 +});
54
55 describe('CLI: composio dev triggers list', () => {
56 layer(TestLive({ baseConfigProvider: testConfigProvider, toolkitsData }))(
ts/packages/cli/test/src/commands/triggers/triggers.mutations.cmd.test.ts
+1 -2
@@ -1,11 +1,10 @@
1 import { describe, expect, layer } from '@effect/vitest';
2 import { ConfigProvider, Effect } from 'effect';
3 -import { extendConfigProvider } from 'src/services/config';
3 import { cli, MockConsole, TestLive } from 'test/__utils__';
4
5 const testConfigProvider = ConfigProvider.fromEnv({
6 env: { COMPOSIO_USER_API_KEY: 'test_api_key' },
8 -}).pipe(extendConfigProvider);
7 +});
8
9 const dangerousDevConfig = {
10 baseConfigProvider: testConfigProvider,
ts/packages/cli/test/src/commands/triggers/triggers.status.cmd.test.ts
+1 -2
@@ -1,6 +1,5 @@
1 import { describe, expect, layer } from '@effect/vitest';
2 import { ConfigProvider, Effect } from 'effect';
3 -import { extendConfigProvider } from 'src/services/config';
3 import { cli, MockConsole, TestLive } from 'test/__utils__';
4 import type { TestLiveInput } from 'test/__utils__/services/test-layer';
5 import type { TriggerInstanceItem } from 'src/models/triggers';
@@ -53,7 +52,7 @@ const triggersData = {
52
53 const testConfigProvider = ConfigProvider.fromEnv({
54 env: { COMPOSIO_USER_API_KEY: 'test_api_key' },
56 -}).pipe(extendConfigProvider);
55 +});
56
57 describe('CLI: composio dev triggers status', () => {
58 layer(TestLive({ baseConfigProvider: testConfigProvider, triggersData }))(
ts/packages/cli/test/src/commands/ts/ts.generate.cmd.test.ts
+2 -1
@@ -3,7 +3,7 @@ import path from 'node:path';
3 import { describe, expect, layer } from '@effect/vitest';
4 import { Effect } from 'effect';
5 import * as FileSystem from 'effect/FileSystem';
6 -import { cli, TestLive } from 'test/__utils__';
6 +import { cli, liveEnvConfigProvider, TestLive } from 'test/__utils__';
7 import { makeTestToolkits } from 'test/__utils__/models/toolkits';
8 import { NodeProcess } from 'src/services/node-process';
9 import {
@@ -1031,6 +1031,7 @@ describe('CLI: composio generate ts', () => {
1031 TestLive({
1032 fixture: 'typescript-project-with-composio-core',
1033 toolkitsData: appClientData,
1034 + baseConfigProvider: liveEnvConfigProvider,
1035 })
1036 )(it => {
1037 it.effect(
ts/packages/cli/test/src/commands/version.test.ts
+1 -2
@@ -1,12 +1,11 @@
1 import { describe, expect, layer } from '@effect/vitest';
2 import { ConfigProvider, Effect } from 'effect';
3 -import { extendConfigProvider } from 'src/services/config';
3 import { cli, pkg, TestLive, MockConsole } from 'test/__utils__';
4
5 describe('CLI: composio', () => {
6 const testConfigProvider = ConfigProvider.fromEnv({
7 env: { DEBUG_OVERRIDE_VERSION: '1.2.3-test' },
9 - }).pipe(extendConfigProvider);
8 + });
9
10 layer(TestLive())(it => {
11 it.effect("[Given] no arguments [Then] prints composio's version from package.json", () =>
ts/packages/cli/test/src/commands/whoami.cmd.test.ts
+1 -2
@@ -1,13 +1,12 @@
1 import { describe, expect, layer } from '@effect/vitest';
2 import { ConfigProvider, Effect } from 'effect';
3 -import { extendConfigProvider } from 'src/services/config';
3 import { cli, TestLive, MockConsole } from 'test/__utils__';
4 import { makeSessionInfo } from 'test/__utils__/models/account';
5
6 describe('CLI: composio whoami', () => {
7 const testConfigProvider = ConfigProvider.fromEnv({
8 env: { COMPOSIO_USER_API_KEY: 'api_key_from_test_config_provider' },
10 - }).pipe(extendConfigProvider);
9 + });
10
11 layer(TestLive({ baseConfigProvider: testConfigProvider }))('with config override', it => {
12 it.effect('[Given] `COMPOSIO_USER_API_KEY` [Then] prints global user context JSON', () =>
ts/packages/cli/test/src/config/app.test.ts new
+124
@@ -0,0 +1,124 @@
1 +import { describe, it } from '@effect/vitest';
2 +import { deepStrictEqual } from '@effect/vitest/utils';
3 +import { Config, ConfigProvider, Effect, Option } from 'effect';
4 +import { APP_CONFIG } from 'src/config';
5 +import * as constants from 'src/constants';
6 +
7 +const read = <A>(config: Config.Config<A>, env: Record<string, string>) =>
8 + config.parse(ConfigProvider.fromEnvRecord(env));
9 +
10 +const urls = Config.all({ base: APP_CONFIG.BASE_URL, web: APP_CONFIG.WEB_URL });
11 +
12 +describe('APP_CONFIG', () => {
13 + it.effect('[Given] an empty environment [Then] every setting takes its default', () =>
14 + Effect.gen(function* () {
15 + deepStrictEqual(yield* read(Config.all(APP_CONFIG), {}), {
16 + USER_API_KEY: undefined,
17 + ENVIRONMENT: undefined,
18 + BASE_URL: constants.DEFAULT_BASE_URL,
19 + WEB_URL: constants.DEFAULT_WEB_URL,
20 + CACHE_DIR: undefined,
21 + SESSION_DIR: undefined,
22 + BIN_DIR: undefined,
23 + LOG_LEVEL: undefined,
24 + ORG_ID: undefined,
25 + PROJECT_ID: undefined,
26 + AGENTS_BASE_URL: undefined,
27 + WEBHOOK_SECRET: undefined,
28 + CLI_INVOCATION_ORIGIN: undefined,
29 + CLI_PARENT_RUN_ID: undefined,
30 + RUN_OUTPUT_DIR: undefined,
31 + DISABLE_CONNECTED_ACCOUNT_CACHE: true,
32 + TOOLKIT_VERSIONS: Option.none(),
33 + });
34 + })
35 + );
36 +
37 + it.effect('[Given] unprefixed names [Then] they are ignored', () =>
38 + Effect.gen(function* () {
39 + const actual = yield* read(
40 + Config.all({ apiKey: APP_CONFIG.USER_API_KEY, logLevel: APP_CONFIG.LOG_LEVEL }),
41 + { USER_API_KEY: 'api_key', LOG_LEVEL: 'Debug' }
42 + );
43 + deepStrictEqual(actual, { apiKey: undefined, logLevel: undefined });
44 + })
45 + );
46 +
47 + it.effect('[Given] every COMPOSIO_* variable [Then] values are trimmed and typed', () =>
48 + Effect.gen(function* () {
49 + const actual = yield* read(Config.all(APP_CONFIG), {
50 + COMPOSIO_USER_API_KEY: 'api_key',
51 + COMPOSIO_BASE_URL: 'https://test.localhost',
52 + COMPOSIO_WEB_URL: 'https://web.localhost',
53 + COMPOSIO_CACHE_DIR: ' /tmp/composio-cache ',
54 + COMPOSIO_SESSION_DIR: ' ',
55 + COMPOSIO_BIN_DIR: '/usr/local/bin',
56 + COMPOSIO_LOG_LEVEL: 'Info',
57 + COMPOSIO_ORG_ID: 'org_1',
58 + COMPOSIO_PROJECT_ID: 'proj_1',
59 + COMPOSIO_AGENTS_BASE_URL: 'https://agents.localhost',
60 + COMPOSIO_WEBHOOK_SECRET: 'secret',
61 + COMPOSIO_CLI_INVOCATION_ORIGIN: 'run',
62 + COMPOSIO_CLI_PARENT_RUN_ID: 'run_parent',
63 + COMPOSIO_RUN_OUTPUT_DIR: '\t/tmp/composio-output\n',
64 + COMPOSIO_DISABLE_CONNECTED_ACCOUNT_CACHE: 'OFF',
65 + COMPOSIO_TOOLKIT_VERSION_GMAIL: '20250901_00',
66 + });
67 + deepStrictEqual(actual, {
68 + USER_API_KEY: 'api_key',
69 + ENVIRONMENT: undefined,
70 + BASE_URL: 'https://test.localhost',
71 + WEB_URL: 'https://web.localhost',
72 + CACHE_DIR: '/tmp/composio-cache',
73 + SESSION_DIR: undefined,
74 + BIN_DIR: '/usr/local/bin',
75 + LOG_LEVEL: 'Info',
76 + ORG_ID: 'org_1',
77 + PROJECT_ID: 'proj_1',
78 + AGENTS_BASE_URL: 'https://agents.localhost',
79 + WEBHOOK_SECRET: 'secret',
80 + CLI_INVOCATION_ORIGIN: 'run',
81 + CLI_PARENT_RUN_ID: 'run_parent',
82 + RUN_OUTPUT_DIR: '/tmp/composio-output',
83 + DISABLE_CONNECTED_ACCOUNT_CACHE: false,
84 + TOOLKIT_VERSIONS: Option.some({ GMAIL: '20250901_00' }),
85 + });
86 + })
87 + );
88 +
89 + it.effect('[Given] COMPOSIO_ENVIRONMENT [Then] it picks the URL defaults', () =>
90 + Effect.gen(function* () {
91 + deepStrictEqual(yield* read(urls, { COMPOSIO_ENVIRONMENT: 'staging' }), {
92 + base: constants.STAGING_BASE_URL,
93 + web: constants.STAGING_WEB_URL,
94 + });
95 + deepStrictEqual(yield* read(urls, { COMPOSIO_ENVIRONMENT: 'production' }), {
96 + base: constants.DEFAULT_BASE_URL,
97 + web: constants.DEFAULT_WEB_URL,
98 + });
99 + deepStrictEqual(yield* read(urls, { COMPOSIO_ENVIRONMENT: 'unknown' }), {
100 + base: constants.DEFAULT_BASE_URL,
101 + web: constants.DEFAULT_WEB_URL,
102 + });
103 + })
104 + );
105 +
106 + it.effect('[Given] an explicit URL [Then] it beats the COMPOSIO_ENVIRONMENT default', () =>
107 + Effect.gen(function* () {
108 + deepStrictEqual(
109 + yield* read(urls, {
110 + COMPOSIO_ENVIRONMENT: 'staging',
111 + COMPOSIO_BASE_URL: 'https://custom-backend.localhost',
112 + }),
113 + { base: 'https://custom-backend.localhost', web: constants.STAGING_WEB_URL }
114 + );
115 + deepStrictEqual(
116 + yield* read(urls, {
117 + COMPOSIO_ENVIRONMENT: 'staging',
118 + COMPOSIO_WEB_URL: 'https://custom-web.localhost',
119 + }),
120 + { base: constants.STAGING_BASE_URL, web: 'https://custom-web.localhost' }
121 + );
122 + })
123 + );
124 +});
ts/packages/cli/test/src/config/debug.test.ts new
+57
@@ -0,0 +1,57 @@
1 +import { describe, it } from '@effect/vitest';
2 +import { deepStrictEqual } from '@effect/vitest/utils';
3 +import { Config, ConfigProvider, Effect } from 'effect';
4 +import { DEBUG_CONFIG } from 'src/config';
5 +
6 +const read = (env: Record<string, string>) =>
7 + Config.all(DEBUG_CONFIG).parse(ConfigProvider.fromEnvRecord(env));
8 +
9 +describe('DEBUG_CONFIG', () => {
10 + it.effect('[Given] an empty environment [Then] every toggle is off', () =>
11 + Effect.gen(function* () {
12 + deepStrictEqual(yield* read({}), {
13 + PERF_DEBUG: false,
14 + TOOL_DEBUG: false,
15 + TELEMETRY_DEBUG: false,
16 + UPGRADE_TARGET: undefined,
17 + VERSION: undefined,
18 + FORCE_USE_CACHE: false,
19 + });
20 + })
21 + );
22 +
23 + it.effect('[Given] misspelled override names [Then] they are ignored', () =>
24 + Effect.gen(function* () {
25 + const actual = yield* read({
26 + COMPOSIO_UPGRADE_TARGET: 'x',
27 + COMPOSIO_DEBUG_OVERRIDE_VERSION: 'x',
28 + UPGRADE_TARGET: 'x',
29 + });
30 + deepStrictEqual(actual.UPGRADE_TARGET, undefined);
31 + deepStrictEqual(actual.VERSION, undefined);
32 + })
33 + );
34 +
35 + it.effect('[Given] every variable [Then] values are read as written', () =>
36 + Effect.gen(function* () {
37 + deepStrictEqual(
38 + yield* read({
39 + COMPOSIO_PERF_DEBUG: '1',
40 + COMPOSIO_TOOL_DEBUG: 'true',
41 + COMPOSIO_CLI_TELEMETRY_DEBUG: 'yes',
42 + DEBUG_OVERRIDE_UPGRADE_TARGET: './composio',
43 + DEBUG_OVERRIDE_VERSION: '9.9.9',
44 + FORCE_USE_CACHE: 'true',
45 + }),
46 + {
47 + PERF_DEBUG: true,
48 + TOOL_DEBUG: true,
49 + TELEMETRY_DEBUG: true,
50 + UPGRADE_TARGET: './composio',
51 + VERSION: '9.9.9',
52 + FORCE_USE_CACHE: true,
53 + }
54 + );
55 + })
56 + );
57 +});
ts/packages/cli/test/src/config/env.test.ts new
+76
@@ -0,0 +1,76 @@
1 +import { describe, it } from '@effect/vitest';
2 +import { deepStrictEqual } from '@effect/vitest/utils';
3 +import { Config, ConfigProvider, Effect } from 'effect';
4 +import {
5 + flag,
6 + hasEnvironmentRoot,
7 + optionalFlag,
8 + optionalLogLevel,
9 + optionalString,
10 + withFallback,
11 +} from 'src/config/env';
12 +
13 +const read = <A>(config: Config.Config<A>, env: Record<string, string>) =>
14 + config.parse(ConfigProvider.fromEnvRecord(env));
15 +
16 +describe('config readers', () => {
17 + it.effect('optionalString trims and treats blank as unset', () =>
18 + Effect.gen(function* () {
19 + deepStrictEqual(yield* read(optionalString('X'), {}), undefined);
20 + deepStrictEqual(yield* read(optionalString('X'), { X: ' ' }), undefined);
21 + deepStrictEqual(yield* read(optionalString('X'), { X: ' value ' }), 'value');
22 + })
23 + );
24 +
25 + it.effect('flags are tolerant: blank falls back, off-words disable, anything else enables', () =>
26 + Effect.gen(function* () {
27 + const flags = Config.all({
28 + blank: flag('BLANK', true),
29 + off: flag('OFF', true),
30 + typo: flag('TYPO'),
31 + unset: optionalFlag('UNSET'),
32 + });
33 + deepStrictEqual(yield* read(flags, { BLANK: '', OFF: 'No', TYPO: 'maybe' }), {
34 + blank: true,
35 + off: false,
36 + typo: true,
37 + unset: undefined,
38 + });
39 + })
40 + );
41 +
42 + it.effect(
43 + 'optionalLogLevel matches level names case-insensitively and ignores other values',
44 + () =>
45 + Effect.gen(function* () {
46 + const level = optionalLogLevel('LEVEL');
47 + deepStrictEqual(yield* read(level, {}), undefined);
48 + deepStrictEqual(yield* read(level, { LEVEL: 'debug' }), 'Debug');
49 + deepStrictEqual(yield* read(level, { LEVEL: ' Error ' }), 'Error');
50 + deepStrictEqual(yield* read(level, { LEVEL: 'verbose' }), undefined);
51 + })
52 + );
53 +
54 + it.effect('withFallback replaces only undefined', () =>
55 + Effect.gen(function* () {
56 + const value = withFallback(optionalString('X'), 'fallback');
57 + deepStrictEqual(yield* read(value, {}), 'fallback');
58 + deepStrictEqual(yield* read(value, { X: ' ' }), 'fallback');
59 + deepStrictEqual(yield* read(value, { X: 'set' }), 'set');
60 + })
61 + );
62 +
63 + it.effect('hasEnvironmentRoot matches a bare root and any underscore-prefixed child', () =>
64 + Effect.gen(function* () {
65 + const roots = Config.all({
66 + codex: hasEnvironmentRoot('CODEX'),
67 + claude: hasEnvironmentRoot('CLAUDE'),
68 + });
69 + deepStrictEqual(yield* read(roots, { CODEX_HOME: '/x', claude_home: '/y' }), {
70 + codex: true,
71 + claude: false,
72 + });
73 + deepStrictEqual(yield* read(roots, { CLAUDE: '1' }), { codex: false, claude: true });
74 + })
75 + );
76 +});
ts/packages/cli/test/src/config/github.test.ts new
+61
@@ -0,0 +1,61 @@
1 +import { describe, it } from '@effect/vitest';
2 +import { deepStrictEqual } from '@effect/vitest/utils';
3 +import { ConfigProvider, Effect } from 'effect';
4 +import { GITHUB_CONFIG, GITHUB_REPAIR_CONFIG } from 'src/config';
5 +import * as constants from 'src/constants';
6 +
7 +const provider = (env: Record<string, string>) => ConfigProvider.fromEnvRecord(env);
8 +
9 +const DEFAULTS = {
10 + apiBaseUrl: constants.GITHUB_REPO.API_BASE_URL,
11 + owner: constants.GITHUB_REPO.OWNER,
12 + repo: constants.GITHUB_REPO.REPO,
13 + tag: undefined,
14 + accessToken: undefined,
15 +};
16 +
17 +describe('GITHUB_CONFIG', () => {
18 + it.effect('[Given] no overrides [Then] both configs point at the Composio repository', () =>
19 + Effect.gen(function* () {
20 + deepStrictEqual(yield* GITHUB_CONFIG.parse(provider({})), DEFAULTS);
21 + deepStrictEqual(yield* GITHUB_REPAIR_CONFIG.parse(provider({})), DEFAULTS);
22 + })
23 + );
24 +
25 + it.effect('[Given] COMPOSIO_GITHUB_* [Then] releases are fetched from the override', () =>
26 + Effect.gen(function* () {
27 + const env = {
28 + COMPOSIO_GITHUB_API_BASE_URL: 'https://proxy.test',
29 + COMPOSIO_GITHUB_OWNER: 'fork-owner',
30 + COMPOSIO_GITHUB_REPO: '',
31 + COMPOSIO_GITHUB_TAG: '@composio/cli@1.2.3',
32 + COMPOSIO_GITHUB_ACCESS_TOKEN: 'ghp_test',
33 + };
34 + const expected = {
35 + apiBaseUrl: 'https://proxy.test',
36 + owner: 'fork-owner',
37 + repo: constants.GITHUB_REPO.REPO,
38 + tag: '@composio/cli@1.2.3',
39 + accessToken: 'ghp_test',
40 + };
41 + deepStrictEqual(yield* GITHUB_CONFIG.parse(provider(env)), expected);
42 + deepStrictEqual(yield* GITHUB_REPAIR_CONFIG.parse(provider(env)), expected);
43 + })
44 + );
45 +
46 + it.effect('[Given] unprefixed GITHUB_* [Then] only self-repair honors it, and first', () =>
47 + Effect.gen(function* () {
48 + const env = {
49 + GITHUB_TAG: '@composio/cli@9.9.9',
50 + GITHUB_OWNER: 'ci-owner',
51 + COMPOSIO_GITHUB_OWNER: 'fork-owner',
52 + };
53 + const upgrade = yield* GITHUB_CONFIG.parse(provider(env));
54 + deepStrictEqual(upgrade.tag, undefined);
55 + deepStrictEqual(upgrade.owner, 'fork-owner');
56 + const repair = yield* GITHUB_REPAIR_CONFIG.parse(provider(env));
57 + deepStrictEqual(repair.tag, '@composio/cli@9.9.9');
58 + deepStrictEqual(repair.owner, 'ci-owner');
59 + })
60 + );
61 +});
ts/packages/cli/test/src/config/host.test.ts new
+68
@@ -0,0 +1,68 @@
1 +import { describe, it } from '@effect/vitest';
2 +import { deepStrictEqual } from '@effect/vitest/utils';
3 +import { Config, ConfigProvider, Effect } from 'effect';
4 +import { HOST_CONFIG } from 'src/config';
5 +
6 +const read = <A>(config: Config.Config<A>, env: Record<string, string>) =>
7 + config.parse(ConfigProvider.fromEnvRecord(env));
8 +
9 +describe('HOST_CONFIG', () => {
10 + it.effect('[Then] it normalizes host values into runtime facts', () =>
11 + Effect.gen(function* () {
12 + const actual = yield* read(Config.all(HOST_CONFIG), {
13 + SHELL: '/bin/zsh',
14 + PATH: '/usr/bin:/bin',
15 + npm_config_user_agent: 'pnpm/9.0.0 npm/? node/v22.0.0 darwin arm64',
16 + CI: ' TRUE ',
17 + NO_COLOR: '1',
18 + CLAUDECODE: '1',
19 + CODEX_THREAD_ID: 'thread_test',
20 + CLAUDE_CONFIG_DIR: ' ',
21 + COMPOSIO_CALLER_AGENT: 'Open-Claw',
22 + VITEST: 'off',
23 + });
24 + deepStrictEqual(actual, {
25 + SHELL: '/bin/zsh',
26 + PATH: '/usr/bin:/bin',
27 + NPM_CONFIG_USER_AGENT: 'pnpm/9.0.0 npm/? node/v22.0.0 darwin arm64',
28 + NO_COLOR: true,
29 + CI_REDACTION_ENABLED: true,
30 + INTERACTIVE_PERMISSION_UI_DISABLED: true,
31 + AGENT_HOST: {
32 + claudeCode: '1',
33 + codexThreadId: 'thread_test',
34 + codexSandbox: undefined,
35 + claudeConfigDir: undefined,
36 + codexHome: undefined,
37 + },
38 + MASTER_SIGNALS: { codex: true, claude: true },
39 + CALLER_AGENT_SIGNALS: { explicit: 'Open-Claw', codex: true, claude: true, openclaw: false },
40 + });
41 + })
42 + );
43 +
44 + it.effect('[Then] CI redaction keys off the exact `CI=true` convention only', () =>
45 + Effect.gen(function* () {
46 + deepStrictEqual(yield* read(HOST_CONFIG.CI_REDACTION_ENABLED, { CI: '1' }), false);
47 + deepStrictEqual(yield* read(HOST_CONFIG.CI_REDACTION_ENABLED, { CI: 'true' }), true);
48 + })
49 + );
50 +
51 + it.effect('[Then] an explicit permission UI value overrides CI and Vitest detection', () =>
52 + Effect.gen(function* () {
53 + const disabled = HOST_CONFIG.INTERACTIVE_PERMISSION_UI_DISABLED;
54 + deepStrictEqual(yield* read(disabled, {}), false);
55 + deepStrictEqual(yield* read(disabled, { CI: '1' }), true);
56 + deepStrictEqual(yield* read(disabled, { VITEST: 'true' }), true);
57 + deepStrictEqual(
58 + yield* read(disabled, {
59 + COMPOSIO_DISABLE_PERMISSION_UI: 'false',
60 + CI: 'true',
61 + VITEST: 'true',
62 + }),
63 + false
64 + );
65 + deepStrictEqual(yield* read(disabled, { COMPOSIO_DISABLE_PERMISSION_UI: '1' }), true);
66 + })
67 + );
68 +});
ts/packages/cli/test/src/config/telemetry.test.ts new
+47
@@ -0,0 +1,47 @@
1 +import { describe, it } from '@effect/vitest';
2 +import { deepStrictEqual } from '@effect/vitest/utils';
3 +import { Config, ConfigProvider, Effect } from 'effect';
4 +import { TELEMETRY_CONFIG } from 'src/config';
5 +import * as constants from 'src/constants';
6 +
7 +const read = (env: Record<string, string>) =>
8 + Config.all(TELEMETRY_CONFIG).parse(ConfigProvider.fromEnvRecord(env));
9 +
10 +describe('TELEMETRY_CONFIG', () => {
11 + it.effect('[Given] an empty environment [Then] telemetry is on and targets PostHog', () =>
12 + Effect.gen(function* () {
13 + deepStrictEqual(yield* read({}), {
14 + DISABLED: false,
15 + POSTHOG_INGEST_URL: constants.COMPOSIO_POSTHOG_INGEST_URL,
16 + POSTHOG_PROJECT_API_KEY: constants.COMPOSIO_POSTHOG_PROJECT_API_KEY,
17 + });
18 + })
19 + );
20 +
21 + it.effect('[Given] any opt-out, CI, or a test run [Then] telemetry is disabled', () =>
22 + Effect.gen(function* () {
23 + const optOuts: ReadonlyArray<Record<string, string>> = [
24 + { COMPOSIO_CLI_TELEMETRY_DISABLED: 'yes' },
25 + { COMPOSIO_DISABLE_TELEMETRY: 'true' },
26 + { TELEMETRY_DISABLED: '1' },
27 + { CI: 'true' },
28 + { NODE_ENV: 'test' },
29 + ];
30 + for (const env of optOuts) {
31 + deepStrictEqual((yield* read(env)).DISABLED, true, JSON.stringify(env));
32 + }
33 + deepStrictEqual((yield* read({ CI: 'false', NODE_ENV: 'development' })).DISABLED, false);
34 + })
35 + );
36 +
37 + it.effect('[Given] a PostHog override [Then] it replaces the baked target', () =>
38 + Effect.gen(function* () {
39 + const actual = yield* read({
40 + COMPOSIO_POSTHOG_INGEST_URL: 'https://posthog.example.test/i/v0/e/',
41 + COMPOSIO_POSTHOG_PROJECT_API_KEY: ' phc_test ',
42 + });
43 + deepStrictEqual(actual.POSTHOG_INGEST_URL, 'https://posthog.example.test/i/v0/e/');
44 + deepStrictEqual(actual.POSTHOG_PROJECT_API_KEY, 'phc_test');
45 + })
46 + );
47 +});
ts/packages/cli/test/src/effects/install-skill.test.ts
+23 -20
@@ -25,7 +25,7 @@ import {
25 SkillInstallError,
26 type SkillReleaseChannel,
27 } from 'src/effects/install-skill';
28 -import { GITHUB_CONFIG } from 'src/effects/github-config';
28 +import { GITHUB_CONFIG } from 'src/config';
29 import { CliReleaseResolutionError } from 'src/effects/resolve-cli-release';
30 import { defaultNodeOs, NodeOs } from 'src/services/node-os';
31
@@ -54,9 +54,9 @@ const makeInstallEffect = (
54 ConfigProvider.layer(
55 ConfigProvider.fromEnv({
56 env: {
57 - GITHUB_API_BASE_URL: apiBaseUrl,
58 - GITHUB_OWNER: 'test-owner',
59 - GITHUB_REPO: 'test-repo',
57 + COMPOSIO_GITHUB_API_BASE_URL: apiBaseUrl,
58 + COMPOSIO_GITHUB_OWNER: 'test-owner',
59 + COMPOSIO_GITHUB_REPO: 'test-repo',
60 },
61 })
62 )
@@ -143,7 +143,7 @@ const makeResolveEffect = (
143 ) =>
144 Effect.gen(function* () {
145 const httpClient = yield* HttpClient.HttpClient;
146 - const githubConfig = yield* Config.all(GITHUB_CONFIG);
146 + const githubConfig = yield* GITHUB_CONFIG;
147
148 return yield* resolveSkillReleaseTag({
149 channel: options.channel,
@@ -229,9 +229,12 @@ describe('install-skill', () => {
229
230 it.effect('prefers the configured release tag over packaged metadata', () =>
231 Effect.gen(function* () {
232 - const tag = yield* makeResolveEffect([['GITHUB_TAG', '@composio/cli@0.2.34-beta.1']], {
233 - installedReleaseTag: '@composio/cli@0.2.33',
234 - });
232 + const tag = yield* makeResolveEffect(
233 + [['COMPOSIO_GITHUB_TAG', '@composio/cli@0.2.34-beta.1']],
234 + {
235 + installedReleaseTag: '@composio/cli@0.2.33',
236 + }
237 + );
238
239 expect(tag).toBe('@composio/cli@0.2.34-beta.1');
240 })
@@ -331,9 +334,9 @@ describe('install-skill', () => {
334 });
335
336 const tag = yield* makeResolveEffect([
334 - ['GITHUB_API_BASE_URL', apiBaseUrl],
335 - ['GITHUB_OWNER', 'test-owner'],
336 - ['GITHUB_REPO', 'test-repo'],
337 + ['COMPOSIO_GITHUB_API_BASE_URL', apiBaseUrl],
338 + ['COMPOSIO_GITHUB_OWNER', 'test-owner'],
339 + ['COMPOSIO_GITHUB_REPO', 'test-repo'],
340 ]);
341
342 expect(tag).toBe('@composio/cli@0.2.33');
@@ -350,9 +353,9 @@ describe('install-skill', () => {
353 const error = yield* Effect.flip(
354 makeResolveEffect(
355 [
353 - ['GITHUB_API_BASE_URL', apiBaseUrl],
354 - ['GITHUB_OWNER', 'test-owner'],
355 - ['GITHUB_REPO', 'test-repo'],
356 + ['COMPOSIO_GITHUB_API_BASE_URL', apiBaseUrl],
357 + ['COMPOSIO_GITHUB_OWNER', 'test-owner'],
358 + ['COMPOSIO_GITHUB_REPO', 'test-repo'],
359 ],
360 { channel: 'stable' }
361 )
@@ -466,9 +469,9 @@ describe('install-skill', () => {
469
470 const tag = yield* makeResolveEffect(
471 [
469 - ['GITHUB_API_BASE_URL', apiBaseUrl],
470 - ['GITHUB_OWNER', 'test-owner'],
471 - ['GITHUB_REPO', 'test-repo'],
472 + ['COMPOSIO_GITHUB_API_BASE_URL', apiBaseUrl],
473 + ['COMPOSIO_GITHUB_OWNER', 'test-owner'],
474 + ['COMPOSIO_GITHUB_REPO', 'test-repo'],
475 ],
476 { channel: 'stable' }
477 );
@@ -523,9 +526,9 @@ describe('install-skill', () => {
526
527 const tag = yield* makeResolveEffect(
528 [
526 - ['GITHUB_API_BASE_URL', apiBaseUrl],
527 - ['GITHUB_OWNER', 'test-owner'],
528 - ['GITHUB_REPO', 'test-repo'],
529 + ['COMPOSIO_GITHUB_API_BASE_URL', apiBaseUrl],
530 + ['COMPOSIO_GITHUB_OWNER', 'test-owner'],
531 + ['COMPOSIO_GITHUB_REPO', 'test-repo'],
532 ],
533 { channel: 'beta' }
534 );
ts/packages/cli/test/src/effects/resolve-cli-release.test.ts
+3 -3
@@ -4,9 +4,9 @@ import { HttpClient, HttpClientResponse } from 'effect/unstable/http';
4 import { fetchLatestCliRelease, type GitHubRelease } from 'src/effects/resolve-cli-release';
5
6 const githubConfig = {
7 - API_BASE_URL: 'https://api.github.test',
8 - OWNER: 'ComposioHQ',
9 - REPO: 'composio',
7 + apiBaseUrl: 'https://api.github.test',
8 + owner: 'ComposioHQ',
9 + repo: 'composio',
10 };
11
12 const stubHttpClient = (body: unknown) =>
ts/packages/cli/test/src/effects/toolkit-from-tool-slug.test.ts
+3 -1
@@ -130,7 +130,9 @@ const runInCacheDir = <A>(
130 );
131 }).pipe(
132 Effect.provide(BunFileSystem.layer),
133 - Effect.provide(ConfigProvider.layer(ConfigProvider.fromEnvRecord({ CACHE_DIR: cacheDir })))
133 + Effect.provide(
134 + ConfigProvider.layer(ConfigProvider.fromEnvRecord({ COMPOSIO_CACHE_DIR: cacheDir }))
135 + )
136 );
137
138 describe('toolkitFromToolSlug', () => {
ts/packages/cli/test/src/effects/toolkit-version-overrides.test.ts
+32 -11
@@ -1,5 +1,6 @@
1 import { describe, it, expect, vi, afterEach } from '@effect/vitest';
2 -import { Effect } from 'effect';
2 +import { ConfigProvider, Effect } from 'effect';
3 +import { liveEnvConfigProvider } from 'test/__utils__';
4 import {
5 getToolkitVersionOverrides,
6 buildToolkitVersionSpecs,
@@ -19,7 +20,9 @@ describe('toolkit-version-overrides', () => {
20 describe('getToolkitVersionOverrides', () => {
21 it.effect('should return empty map when no env vars set', () =>
22 Effect.gen(function* () {
22 - const result = yield* getToolkitVersionOverrides;
23 + const result = yield* getToolkitVersionOverrides.pipe(
24 + Effect.provide(ConfigProvider.layer(liveEnvConfigProvider))
25 + );
26 expect(result.size).toBe(0);
27 })
28 );
@@ -27,7 +30,9 @@ describe('toolkit-version-overrides', () => {
30 it.effect('should parse single env var with COMPOSIO_ prefix', () =>
31 Effect.gen(function* () {
32 vi.stubEnv('COMPOSIO_TOOLKIT_VERSION_GMAIL', '20250901_00');
30 - const result = yield* getToolkitVersionOverrides;
33 + const result = yield* getToolkitVersionOverrides.pipe(
34 + Effect.provide(ConfigProvider.layer(liveEnvConfigProvider))
35 + );
36 expect(result.get('gmail')).toBe('20250901_00');
37 expect(result.size).toBe(1);
38 })
@@ -37,7 +42,9 @@ describe('toolkit-version-overrides', () => {
42 Effect.gen(function* () {
43 vi.stubEnv('COMPOSIO_TOOLKIT_VERSION_GMAIL', '20250901_00');
44 vi.stubEnv('COMPOSIO_TOOLKIT_VERSION_SLACK', '20250815_00');
40 - const result = yield* getToolkitVersionOverrides;
45 + const result = yield* getToolkitVersionOverrides.pipe(
46 + Effect.provide(ConfigProvider.layer(liveEnvConfigProvider))
47 + );
48 expect(result.get('gmail')).toBe('20250901_00');
49 expect(result.get('slack')).toBe('20250815_00');
50 expect(result.size).toBe(2);
@@ -47,7 +54,9 @@ describe('toolkit-version-overrides', () => {
54 it.effect('should lowercase toolkit name from env var', () =>
55 Effect.gen(function* () {
56 vi.stubEnv('COMPOSIO_TOOLKIT_VERSION_GMAIL', '20250901_00');
50 - const result = yield* getToolkitVersionOverrides;
57 + const result = yield* getToolkitVersionOverrides.pipe(
58 + Effect.provide(ConfigProvider.layer(liveEnvConfigProvider))
59 + );
60 expect(result.has('gmail')).toBe(true);
61 // Cast to bypass type check - we're testing runtime behavior that uppercase keys are not stored
62 expect(result.has('GMAIL' as Lowercase<string>)).toBe(false);
@@ -57,7 +66,9 @@ describe('toolkit-version-overrides', () => {
66 it.effect('should ignore "latest" as explicit value', () =>
67 Effect.gen(function* () {
68 vi.stubEnv('COMPOSIO_TOOLKIT_VERSION_GMAIL', 'latest');
60 - const result = yield* getToolkitVersionOverrides;
69 + const result = yield* getToolkitVersionOverrides.pipe(
70 + Effect.provide(ConfigProvider.layer(liveEnvConfigProvider))
71 + );
72 expect(result.size).toBe(0);
73 })
74 );
@@ -65,7 +76,9 @@ describe('toolkit-version-overrides', () => {
76 it.effect('should ignore empty string values', () =>
77 Effect.gen(function* () {
78 vi.stubEnv('COMPOSIO_TOOLKIT_VERSION_GMAIL', '');
68 - const result = yield* getToolkitVersionOverrides;
79 + const result = yield* getToolkitVersionOverrides.pipe(
80 + Effect.provide(ConfigProvider.layer(liveEnvConfigProvider))
81 + );
82 expect(result.size).toBe(0);
83 })
84 );
@@ -73,7 +86,9 @@ describe('toolkit-version-overrides', () => {
86 it.effect('should not read env vars without COMPOSIO_ prefix', () =>
87 Effect.gen(function* () {
88 vi.stubEnv('TOOLKIT_VERSION_GMAIL', '20250901_00');
76 - const result = yield* getToolkitVersionOverrides;
89 + const result = yield* getToolkitVersionOverrides.pipe(
90 + Effect.provide(ConfigProvider.layer(liveEnvConfigProvider))
91 + );
92 expect(result.size).toBe(0);
93 })
94 );
@@ -84,7 +99,9 @@ describe('toolkit-version-overrides', () => {
99 vi.stubEnv('COMPOSIO_TOOLKIT_VERSION_SLACK', 'latest'); // Should be ignored
100 vi.stubEnv('COMPOSIO_TOOLKIT_VERSION_GITHUB', ''); // Should be ignored
101 vi.stubEnv('COMPOSIO_TOOLKIT_VERSION_NOTION', '20250815_00');
87 - const result = yield* getToolkitVersionOverrides;
102 + const result = yield* getToolkitVersionOverrides.pipe(
103 + Effect.provide(ConfigProvider.layer(liveEnvConfigProvider))
104 + );
105 expect(result.size).toBe(2);
106 expect(result.get('gmail')).toBe('20250901_00');
107 expect(result.get('notion')).toBe('20250815_00');
@@ -286,7 +303,9 @@ describe('toolkit-version-overrides', () => {
303 it.effect('should sanitize version strings with invalid characters', () =>
304 Effect.gen(function* () {
305 vi.stubEnv('COMPOSIO_TOOLKIT_VERSION_GMAIL', '20250901_00!@#');
289 - const result = yield* getToolkitVersionOverrides;
306 + const result = yield* getToolkitVersionOverrides.pipe(
307 + Effect.provide(ConfigProvider.layer(liveEnvConfigProvider))
308 + );
309 expect(result.get('gmail')).toBe('20250901_00');
310 expect(result.size).toBe(1);
311 })
@@ -295,7 +314,9 @@ describe('toolkit-version-overrides', () => {
314 it.effect('should ignore version strings that become empty after sanitization', () =>
315 Effect.gen(function* () {
316 vi.stubEnv('COMPOSIO_TOOLKIT_VERSION_GMAIL', '$$$');
298 - const result = yield* getToolkitVersionOverrides;
317 + const result = yield* getToolkitVersionOverrides.pipe(
318 + Effect.provide(ConfigProvider.layer(liveEnvConfigProvider))
319 + );
320 expect(result.size).toBe(0);
321 })
322 );
ts/packages/cli/test/src/effects/with-log-level.test.ts
+1 -6
@@ -2,14 +2,9 @@ import { describe, it } from '@effect/vitest';
2 import { assertEquals } from '@effect/vitest/utils';
3 import { ConfigProvider, Effect, type LogLevel, Option, References } from 'effect';
4 import { setMinimumLogLevel } from 'src/effects/with-log-level';
5 -import { extendConfigProvider } from 'src/services/config';
5
6 const withEnv = (entries: ReadonlyArray<readonly [string, string]>) =>
8 - Effect.provide(
9 - ConfigProvider.layer(
10 - extendConfigProvider(ConfigProvider.fromEnvRecord(Object.fromEntries(entries)))
11 - )
12 - );
7 + Effect.provide(ConfigProvider.layer(ConfigProvider.fromEnvRecord(Object.fromEntries(entries))));
8
9 const resolveMinimumLogLevel = (logLevelFromCLI: Option.Option<LogLevel.LogLevel>) =>
10 Effect.service(References.MinimumLogLevel).pipe(
ts/packages/cli/test/src/services/cli-session-artifacts.test.ts
+2 -5
@@ -11,19 +11,16 @@ import {
11 storeCliSessionArtifact,
12 } from 'src/services/cli-session-artifacts';
13 import { ComposioCliUserConfig } from 'src/services/cli-user-config';
14 -import { extendConfigProvider } from 'src/services/config';
14 import { defaultNodeOs, NodeOs } from 'src/services/node-os';
15 import { TestLive } from 'test/__utils__';
16
17 // Backed by the live `process.env` record so `vi.stubEnv` calls made inside a test are
18 // observed by later config reads; `ConfigProvider.fromEnv()` would snapshot the environment.
20 -const environmentTestConfigProvider = ConfigProvider.fromEnvRecord(process.env).pipe(
21 - extendConfigProvider
22 -);
19 +const environmentTestConfigProvider = ConfigProvider.fromEnvRecord(process.env);
20
21 const cacheEnabledTestConfigProvider = ConfigProvider.fromEnvRecord({
22 COMPOSIO_DISABLE_CONNECTED_ACCOUNT_CACHE: 'false',
26 -}).pipe(ConfigProvider.orElse(ConfigProvider.fromEnvRecord(process.env)), extendConfigProvider);
23 +}).pipe(ConfigProvider.orElse(ConfigProvider.fromEnvRecord(process.env)));
24
25 describe('CLI session artifacts', () => {
26 beforeEach(() => {
ts/packages/cli/test/src/services/cli-user-config.test.ts
+1 -2
@@ -7,7 +7,6 @@ import * as FileSystem from 'effect/FileSystem';
7 import * as BunFileSystem from '@effect/platform-bun/BunFileSystem';
8 import * as BunPath from '@effect/platform-bun/BunPath';
9 import { ConfigProvider, Effect, Layer } from 'effect';
10 -import { extendConfigProvider } from 'src/services/config';
10 import { defaultNodeOs, NodeOs } from 'src/services/node-os';
11 import { ComposioCliUserConfig, ComposioCliUserConfigLive } from 'src/services/cli-user-config';
12
@@ -15,7 +14,7 @@ describe('ComposioCliUserConfig', () => {
14 const withMapConfigProvider = (map: Map<string, string>) =>
15 Layer.succeed(
16 ConfigProvider.ConfigProvider,
18 - extendConfigProvider(ConfigProvider.fromEnv({ env: Object.fromEntries(map) }))
17 + ConfigProvider.fromEnv({ env: Object.fromEntries(map) })
18 );
19
20 it.effect('defaults experimental features off in stable releases', () => {
ts/packages/cli/test/src/services/composio-client-singleton.test.ts
+1 -2
@@ -9,7 +9,6 @@ import * as tempy from 'tempy';
9 import { ComposioClientSingleton } from 'src/services/composio-clients';
10 import { APP_VERSION } from 'src/constants';
11 import { defaultNodeOs, NodeOs } from 'src/services/node-os';
12 -import { extendConfigProvider } from 'src/services/config';
12
13 // Exercise real user-context/config resolution without opening the OS credential store.
14 vi.mock('@composio/cli-keyring/effect', async importOriginal => {
@@ -37,7 +36,7 @@ const withConfigLayer = (map: Map<string, string>, homedir: string) =>
36 Layer.succeed(NodeOs, defaultNodeOs({ homedir })),
37 Layer.succeed(
38 ConfigProvider.ConfigProvider,
40 - extendConfigProvider(ConfigProvider.fromEnv({ env: Object.fromEntries(map) }))
39 + ConfigProvider.fromEnv({ env: Object.fromEntries(map) })
40 )
41 );
42
ts/packages/cli/test/src/services/composio-clients.test.ts
+11 -14
@@ -18,7 +18,6 @@ import {
18 listOrgProjects,
19 } from 'src/services/composio-clients';
20 import { handleHttpServerError } from 'src/effects/handle-http-error';
21 -import { extendConfigProvider } from 'src/services/config';
21 import { defaultNodeOs, NodeOs } from 'src/services/node-os';
22 import { TerminalUI } from 'src/services/terminal-ui';
23 import { makeOrgProject, makeSessionInfo } from 'test/__utils__/models/account';
@@ -53,11 +52,10 @@ const platformLayer = () =>
52 Layer.succeed(NodeOs, defaultNodeOs({ homedir: tempy.temporaryDirectory() })),
53 Layer.succeed(
54 ConfigProvider.ConfigProvider,
56 - extendConfigProvider(
57 - ConfigProvider.fromEnv({
58 - env: { COMPOSIO_USER_API_KEY: 'uak_config', COMPOSIO_BASE_URL: BASE_URL },
59 - })
60 - )
55 +
56 + ConfigProvider.fromEnv({
57 + env: { COMPOSIO_USER_API_KEY: 'uak_config', COMPOSIO_BASE_URL: BASE_URL },
58 + })
59 )
60 );
61
@@ -583,14 +581,13 @@ describe('ComposioToolkitsRepository toolkit lists', () => {
581 Layer.succeed(NodeOs, defaultNodeOs({ homedir: tempy.temporaryDirectory() })),
582 Layer.succeed(
583 ConfigProvider.ConfigProvider,
586 - extendConfigProvider(
587 - ConfigProvider.fromEnv({
588 - env: {
589 - COMPOSIO_USER_API_KEY: 'uak_test',
590 - COMPOSIO_BASE_URL: 'https://backend.composio.dev',
591 - },
592 - })
593 - )
584 +
585 + ConfigProvider.fromEnv({
586 + env: {
587 + COMPOSIO_USER_API_KEY: 'uak_test',
588 + COMPOSIO_BASE_URL: 'https://backend.composio.dev',
589 + },
590 + })
591 )
592 )
593 );
ts/packages/cli/test/src/services/config.test.ts deleted
-456
@@ -1,456 +0,0 @@
1 -import { describe, expect, it } from '@effect/vitest';
2 -import { deepStrictEqual } from '@effect/vitest/utils';
3 -
4 -import { Config, ConfigProvider, Effect, Option } from 'effect';
5 -import { APP_CONFIG, UNPREFIXED_CONFIG } from 'src/effects/app-config';
6 -import { extendConfigProvider } from 'src/services/config';
7 -import { DEBUG_OVERRIDE_CONFIG } from 'src/effects/debug-config';
8 -import * as constants from 'src/constants';
9 -
10 -const NORMALIZED_APP_CONFIG_DEFAULTS = {
11 - CACHE_DIR: undefined,
12 - SESSION_DIR: undefined,
13 - BIN_DIR: undefined,
14 - AGENTS_BASE_URL: undefined,
15 - WEBHOOK_SECRET: undefined,
16 - CLI_INVOCATION_ORIGIN: undefined,
17 - CLI_PARENT_RUN_ID: undefined,
18 - RUN_OUTPUT_DIR: undefined,
19 - PERF_DEBUG: false,
20 - TOOL_DEBUG: false,
21 -};
22 -
23 -describe('Config', () => {
24 - describe('[When] using `ConfigProvider.fromMap`', () => {
25 - const withMapConfigProvider = (map: Map<string, string>) =>
26 - Effect.provideService(
27 - ConfigProvider.ConfigProvider,
28 - extendConfigProvider(ConfigProvider.fromEnvRecord(Object.fromEntries(map)))
29 - );
30 -
31 - describe('APP_CONFIG', () => {
32 - it.effect('[When] no map entry is set', () =>
33 - Effect.gen(function* () {
34 - const map = new Map([]) satisfies Map<string, string>;
35 -
36 - const actual = yield* withMapConfigProvider(map)(Config.all(APP_CONFIG));
37 -
38 - deepStrictEqual(actual, {
39 - USER_API_KEY: Option.none(),
40 - ...NORMALIZED_APP_CONFIG_DEFAULTS,
41 - ENVIRONMENT: Option.none(),
42 - BASE_URL: 'https://backend.composio.dev',
43 - LOG_LEVEL: Option.none(),
44 - ORG_ID: Option.none(),
45 - PROJECT_ID: Option.none(),
46 - DISABLE_CONNECTED_ACCOUNT_CACHE: true,
47 - WEB_URL: 'https://dashboard.composio.dev/',
48 - });
49 - })
50 - );
51 -
52 - it.effect('[When] map entries are set without `COMPOSIO_` prefix', () =>
53 - Effect.gen(function* () {
54 - const map = new Map([
55 - ['USER_API_KEY', 'api_key'],
56 - ['BASE_URL', 'https://test.localhost'],
57 - ['CACHE_DIR', '~/.composio'],
58 - ['LOG_LEVEL', 'info'],
59 - ]) satisfies Map<string, string>;
60 -
61 - const actual = yield* withMapConfigProvider(map)(Config.all(APP_CONFIG));
62 -
63 - deepStrictEqual(actual, {
64 - USER_API_KEY: Option.none(),
65 - ...NORMALIZED_APP_CONFIG_DEFAULTS,
66 - ENVIRONMENT: Option.none(),
67 - BASE_URL: 'https://backend.composio.dev',
68 - LOG_LEVEL: Option.none(),
69 - ORG_ID: Option.none(),
70 - PROJECT_ID: Option.none(),
71 - DISABLE_CONNECTED_ACCOUNT_CACHE: true,
72 - WEB_URL: 'https://dashboard.composio.dev/',
73 - });
74 - })
75 - );
76 -
77 - it.effect('[When] env variables are set with `COMPOSIO_` prefix', () =>
78 - Effect.gen(function* () {
79 - const map = new Map([
80 - ['COMPOSIO_USER_API_KEY', 'api_key'],
81 - ['COMPOSIO_BASE_URL', 'https://test.localhost'],
82 - ['COMPOSIO_WEB_URL', 'https://test.localhost'],
83 - ['COMPOSIO_CACHE_DIR', '~/.composio'],
84 - ['COMPOSIO_SESSION_DIR', '/tmp/composio-sessions'],
85 - ['COMPOSIO_BIN_DIR', '/usr/local/bin'],
86 - ['COMPOSIO_LOG_LEVEL', 'Info'],
87 - ['COMPOSIO_AGENTS_BASE_URL', 'https://agents.test.localhost'],
88 - ['COMPOSIO_WEBHOOK_SECRET', 'secret'],
89 - ['COMPOSIO_CLI_INVOCATION_ORIGIN', 'run'],
90 - ['COMPOSIO_CLI_PARENT_RUN_ID', 'run_parent'],
91 - ['COMPOSIO_RUN_ACP_ONLY', '1'],
92 - ['COMPOSIO_RUN_OUTPUT_DIR', '/tmp/composio-output'],
93 - ['COMPOSIO_PERF_DEBUG', '1'],
94 - ['COMPOSIO_TOOL_DEBUG', '1'],
95 - ]) satisfies Map<string, string>;
96 -
97 - const actual = yield* withMapConfigProvider(map)(Config.all(APP_CONFIG));
98 -
99 - deepStrictEqual(actual, {
100 - USER_API_KEY: Option.some('api_key'),
101 - ENVIRONMENT: Option.none(),
102 - BASE_URL: 'https://test.localhost',
103 - WEB_URL: 'https://test.localhost',
104 - CACHE_DIR: '~/.composio',
105 - SESSION_DIR: '/tmp/composio-sessions',
106 - BIN_DIR: '/usr/local/bin',
107 - LOG_LEVEL: Option.some('Info' as const),
108 - ORG_ID: Option.none(),
109 - PROJECT_ID: Option.none(),
110 - AGENTS_BASE_URL: 'https://agents.test.localhost',
111 - WEBHOOK_SECRET: 'secret',
112 - CLI_INVOCATION_ORIGIN: 'run',
113 - CLI_PARENT_RUN_ID: 'run_parent',
114 - RUN_OUTPUT_DIR: '/tmp/composio-output',
115 - PERF_DEBUG: true,
116 - TOOL_DEBUG: true,
117 - DISABLE_CONNECTED_ACCOUNT_CACHE: true,
118 - });
119 - })
120 - );
121 -
122 - it.effect('[When] optional directory values contain whitespace', () =>
123 - Effect.gen(function* () {
124 - const map = new Map([
125 - ['COMPOSIO_CACHE_DIR', ' /tmp/composio-cache '],
126 - ['COMPOSIO_SESSION_DIR', ' '],
127 - ['COMPOSIO_BIN_DIR', ' /usr/local/bin '],
128 - ['COMPOSIO_RUN_OUTPUT_DIR', '\t/tmp/composio-output\n'],
129 - ]) satisfies Map<string, string>;
130 -
131 - const actual = yield* withMapConfigProvider(map)(
132 - Config.all({
133 - cacheDirectory: APP_CONFIG.CACHE_DIR,
134 - sessionDirectory: APP_CONFIG.SESSION_DIR,
135 - binDirectory: APP_CONFIG.BIN_DIR,
136 - runOutputDirectory: APP_CONFIG.RUN_OUTPUT_DIR,
137 - })
138 - );
139 -
140 - deepStrictEqual(actual, {
141 - cacheDirectory: '/tmp/composio-cache',
142 - sessionDirectory: undefined,
143 - binDirectory: '/usr/local/bin',
144 - runOutputDirectory: '/tmp/composio-output',
145 - });
146 - })
147 - );
148 -
149 - it.effect('[When] boolean flags carry blank or unrecognized values', () =>
150 - Effect.gen(function* () {
151 - // These arrive from the ambient environment, where `COMPOSIO_PERF_DEBUG=` and
152 - // stray values are routine. They must resolve to a boolean rather than failing
153 - // config decoding, which would surface as an unrecoverable defect at the call site.
154 - const map = new Map([
155 - ['COMPOSIO_PERF_DEBUG', ''],
156 - ['COMPOSIO_TOOL_DEBUG', 'maybe'],
157 - ['COMPOSIO_DISABLE_CONNECTED_ACCOUNT_CACHE', ' '],
158 - ]) satisfies Map<string, string>;
159 -
160 - const actual = yield* withMapConfigProvider(map)(
161 - Config.all({
162 - perfDebug: APP_CONFIG.PERF_DEBUG,
163 - toolDebug: APP_CONFIG.TOOL_DEBUG,
164 - disableConnectedAccountCache: APP_CONFIG.DISABLE_CONNECTED_ACCOUNT_CACHE,
165 - })
166 - );
167 -
168 - deepStrictEqual(actual, {
169 - // Blank falls back to the flag's own default, ...
170 - perfDebug: false,
171 - // ... which must hold for a default-true flag too, ...
172 - disableConnectedAccountCache: true,
173 - // ... while any other non-falsy value counts as set.
174 - toolDebug: true,
175 - });
176 - })
177 - );
178 -
179 - it.effect('[When] boolean flags carry explicit falsy words', () =>
180 - Effect.gen(function* () {
181 - const map = new Map([
182 - ['COMPOSIO_PERF_DEBUG', '0'],
183 - ['COMPOSIO_TOOL_DEBUG', 'false'],
184 - ['COMPOSIO_DISABLE_CONNECTED_ACCOUNT_CACHE', 'OFF'],
185 - ]) satisfies Map<string, string>;
186 -
187 - const actual = yield* withMapConfigProvider(map)(
188 - Config.all({
189 - perfDebug: APP_CONFIG.PERF_DEBUG,
190 - toolDebug: APP_CONFIG.TOOL_DEBUG,
191 - disableConnectedAccountCache: APP_CONFIG.DISABLE_CONNECTED_ACCOUNT_CACHE,
192 - })
193 - );
194 -
195 - deepStrictEqual(actual, {
196 - perfDebug: false,
197 - toolDebug: false,
198 - disableConnectedAccountCache: false,
199 - });
200 - })
201 - );
202 -
203 - it.effect('[When] COMPOSIO_DISABLE_CONNECTED_ACCOUNT_CACHE is "false"', () =>
204 - Effect.gen(function* () {
205 - const map = new Map([
206 - ['COMPOSIO_DISABLE_CONNECTED_ACCOUNT_CACHE', 'false'],
207 - ]) satisfies Map<string, string>;
208 -
209 - const actual = yield* withMapConfigProvider(map)(Config.all(APP_CONFIG));
210 -
211 - deepStrictEqual(actual, {
212 - USER_API_KEY: Option.none(),
213 - ...NORMALIZED_APP_CONFIG_DEFAULTS,
214 - ENVIRONMENT: Option.none(),
215 - BASE_URL: 'https://backend.composio.dev',
216 - WEB_URL: 'https://dashboard.composio.dev/',
217 - LOG_LEVEL: Option.none(),
218 - ORG_ID: Option.none(),
219 - PROJECT_ID: Option.none(),
220 - DISABLE_CONNECTED_ACCOUNT_CACHE: false,
221 - });
222 - })
223 - );
224 -
225 - it.effect('[When] COMPOSIO_ENVIRONMENT is "production"', () =>
226 - Effect.gen(function* () {
227 - const map = new Map([['COMPOSIO_ENVIRONMENT', 'production']]) satisfies Map<
228 - string,
229 - string
230 - >;
231 -
232 - const actual = yield* withMapConfigProvider(map)(Config.all(APP_CONFIG));
233 -
234 - deepStrictEqual(actual, {
235 - USER_API_KEY: Option.none(),
236 - ...NORMALIZED_APP_CONFIG_DEFAULTS,
237 - ENVIRONMENT: Option.some('production'),
238 - BASE_URL: constants.DEFAULT_BASE_URL,
239 - WEB_URL: constants.DEFAULT_WEB_URL,
240 - LOG_LEVEL: Option.none(),
241 - ORG_ID: Option.none(),
242 - PROJECT_ID: Option.none(),
243 - DISABLE_CONNECTED_ACCOUNT_CACHE: true,
244 - });
245 - })
246 - );
247 -
248 - it.effect('[When] COMPOSIO_ENVIRONMENT is "staging"', () =>
249 - Effect.gen(function* () {
250 - const map = new Map([['COMPOSIO_ENVIRONMENT', 'staging']]) satisfies Map<string, string>;
251 -
252 - const actual = yield* withMapConfigProvider(map)(Config.all(APP_CONFIG));
253 -
254 - deepStrictEqual(actual, {
255 - USER_API_KEY: Option.none(),
256 - ...NORMALIZED_APP_CONFIG_DEFAULTS,
257 - ENVIRONMENT: Option.some('staging'),
258 - BASE_URL: constants.STAGING_BASE_URL,
259 - WEB_URL: 'https://staging-dashboard.composio.dev/',
260 - LOG_LEVEL: Option.none(),
261 - ORG_ID: Option.none(),
262 - PROJECT_ID: Option.none(),
263 - DISABLE_CONNECTED_ACCOUNT_CACHE: true,
264 - });
265 - })
266 - );
267 -
268 - it.effect(
269 - '[When] COMPOSIO_ENVIRONMENT is "staging" but explicit COMPOSIO_BASE_URL is set',
270 - () =>
271 - Effect.gen(function* () {
272 - const map = new Map([
273 - ['COMPOSIO_ENVIRONMENT', 'staging'],
274 - ['COMPOSIO_BASE_URL', 'https://custom-backend.localhost'],
275 - ]) satisfies Map<string, string>;
276 -
277 - const actual = yield* withMapConfigProvider(map)(Config.all(APP_CONFIG));
278 -
279 - deepStrictEqual(actual, {
280 - USER_API_KEY: Option.none(),
281 - ...NORMALIZED_APP_CONFIG_DEFAULTS,
282 - ENVIRONMENT: Option.some('staging'),
283 - BASE_URL: 'https://custom-backend.localhost',
284 - WEB_URL: constants.STAGING_WEB_URL,
285 - LOG_LEVEL: Option.none(),
286 - ORG_ID: Option.none(),
287 - PROJECT_ID: Option.none(),
288 - DISABLE_CONNECTED_ACCOUNT_CACHE: true,
289 - });
290 - })
291 - );
292 -
293 - it.effect(
294 - '[When] COMPOSIO_ENVIRONMENT is "staging" but explicit COMPOSIO_WEB_URL is set',
295 - () =>
296 - Effect.gen(function* () {
297 - const map = new Map([
298 - ['COMPOSIO_ENVIRONMENT', 'staging'],
299 - ['COMPOSIO_WEB_URL', 'https://custom-web.localhost'],
300 - ]) satisfies Map<string, string>;
301 -
302 - const actual = yield* withMapConfigProvider(map)(Config.all(APP_CONFIG));
303 -
304 - deepStrictEqual(actual, {
305 - USER_API_KEY: Option.none(),
306 - ...NORMALIZED_APP_CONFIG_DEFAULTS,
307 - ENVIRONMENT: Option.some('staging'),
308 - BASE_URL: constants.STAGING_BASE_URL,
309 - WEB_URL: 'https://custom-web.localhost',
310 - LOG_LEVEL: Option.none(),
311 - ORG_ID: Option.none(),
312 - PROJECT_ID: Option.none(),
313 - DISABLE_CONNECTED_ACCOUNT_CACHE: true,
314 - });
315 - })
316 - );
317 -
318 - it.effect('[When] COMPOSIO_ENVIRONMENT is an unknown value', () =>
319 - Effect.gen(function* () {
320 - const map = new Map([['COMPOSIO_ENVIRONMENT', 'unknown']]) satisfies Map<string, string>;
321 -
322 - const actual = yield* withMapConfigProvider(map)(Config.all(APP_CONFIG));
323 -
324 - deepStrictEqual(actual, {
325 - USER_API_KEY: Option.none(),
326 - ...NORMALIZED_APP_CONFIG_DEFAULTS,
327 - ENVIRONMENT: Option.some('unknown'),
328 - BASE_URL: constants.DEFAULT_BASE_URL,
329 - WEB_URL: constants.DEFAULT_WEB_URL,
330 - LOG_LEVEL: Option.none(),
331 - ORG_ID: Option.none(),
332 - PROJECT_ID: Option.none(),
333 - DISABLE_CONNECTED_ACCOUNT_CACHE: true,
334 - });
335 - })
336 - );
337 - });
338 -
339 - describe('DEBUG_OVERRIDE_CONFIG', () => {
340 - it.effect('[When] no map entries variable is set', () =>
341 - Effect.gen(function* () {
342 - const map = new Map([]) satisfies Map<string, string>;
343 -
344 - const actual = yield* withMapConfigProvider(map)(Config.all(DEBUG_OVERRIDE_CONFIG));
345 -
346 - deepStrictEqual(actual, {
347 - UPGRADE_TARGET: Option.none(),
348 - VERSION: Option.none(),
349 - });
350 - })
351 - );
352 -
353 - it.effect('[When] map entries are set without `DEBUG_OVERRIDE_` prefix', () =>
354 - Effect.gen(function* () {
355 - const map = new Map([
356 - ['UPGRADE_TARGET', 'upgrade_target'],
357 - ['VERSION', 'x.x.x'],
358 - ]) satisfies Map<string, string>;
359 -
360 - const actual = yield* withMapConfigProvider(map)(Config.all(DEBUG_OVERRIDE_CONFIG));
361 -
362 - deepStrictEqual(actual, {
363 - UPGRADE_TARGET: Option.none(),
364 - VERSION: Option.none(),
365 - });
366 - })
367 - );
368 -
369 - it.effect(
370 - '[When] map entries are set without `DEBUG_OVERRIDE_` but with `COMPOSIO_` prefix',
371 - () =>
372 - Effect.gen(function* () {
373 - const map = new Map([
374 - ['COMPOSIO_UPGRADE_TARGET', 'upgrade_target'],
375 - ['COMPOSIO_VERSION', 'x.x.x'],
376 - ]) satisfies Map<string, string>;
377 -
378 - const actual = yield* withMapConfigProvider(map)(Config.all(DEBUG_OVERRIDE_CONFIG));
379 -
380 - deepStrictEqual(actual, {
381 - UPGRADE_TARGET: Option.none(),
382 - VERSION: Option.none(),
383 - });
384 - })
385 - );
386 - it.effect('[When] map entries are set with `DEBUG_OVERRIDE_` prefix', () =>
387 - Effect.gen(function* () {
388 - const map = new Map([
389 - ['DEBUG_OVERRIDE_UPGRADE_TARGET', 'upgrade_target'],
390 - ['DEBUG_OVERRIDE_VERSION', 'x.x.x'],
391 - ]) satisfies Map<string, string>;
392 -
393 - const actual = yield* withMapConfigProvider(map)(Config.all(DEBUG_OVERRIDE_CONFIG));
394 -
395 - deepStrictEqual(actual, {
396 - UPGRADE_TARGET: Option.some('upgrade_target'),
397 - VERSION: Option.some('x.x.x'),
398 - });
399 - })
400 - );
401 - });
402 -
403 - describe('UNPREFIXED_CONFIG', () => {
404 - it.effect('[Then] it normalizes unprefixed host values into runtime facts', () =>
405 - Effect.gen(function* () {
406 - const provider = ConfigProvider.fromEnvRecord(
407 - Object.fromEntries([
408 - ['npm_config_user_agent', 'pnpm/9.0.0 npm/? node/v22.0.0 darwin arm64'],
409 - ['CI', ' TRUE '],
410 - ['NO_COLOR', '1'],
411 - ['COMPOSIO_CLI_TELEMETRY_DEBUG', 'true'],
412 - ['CODEX_FUTURE_MARKER', 'thread_test'],
413 - ['CLAUDE_FUTURE_MARKER', 'cli'],
414 - ['COMPOSIO_CALLER_AGENT', 'Open-Claw'],
415 - ['VITEST', 'off'],
416 - ])
417 - );
418 -
419 - const actual = yield* Config.all(UNPREFIXED_CONFIG).parse(provider);
420 -
421 - expect(actual).toEqual({
422 - NPM_CONFIG_USER_AGENT: 'pnpm/9.0.0 npm/? node/v22.0.0 darwin arm64',
423 - CI_REDACTION_ENABLED: true,
424 - INTERACTIVE_PERMISSION_UI_DISABLED: true,
425 - NO_COLOR: true,
426 - TELEMETRY_DEBUG: true,
427 - MASTER_SIGNALS: { codex: true, claude: true },
428 - CALLER_AGENT_SIGNALS: {
429 - explicit: 'Open-Claw',
430 - openclaw: false,
431 - claude: true,
432 - codex: true,
433 - },
434 - });
435 - })
436 - );
437 -
438 - it.effect('[Then] an explicit permission UI value overrides CI detection', () =>
439 - Effect.gen(function* () {
440 - const provider = ConfigProvider.fromEnvRecord(
441 - Object.fromEntries([
442 - ['COMPOSIO_DISABLE_PERMISSION_UI', 'false'],
443 - ['CI', 'true'],
444 - ['VITEST', 'true'],
445 - ])
446 - );
447 -
448 - deepStrictEqual(
449 - yield* UNPREFIXED_CONFIG.INTERACTIVE_PERMISSION_UI_DISABLED.parse(provider),
450 - false
451 - );
452 - })
453 - );
454 - });
455 - });
456 -});
ts/packages/cli/test/src/services/consumer-short-term-cache.test.ts
+1 -2
@@ -4,7 +4,6 @@ import * as FileSystem from 'effect/FileSystem';
4 import { ConfigProvider, DateTime, Effect, Option } from 'effect';
5 import path from 'node:path';
6 import { setupCacheDir } from 'src/effects/setup-cache-dir';
7 -import { extendConfigProvider } from 'src/services/config';
7 import * as composioClients from 'src/services/composio-clients';
8 import {
9 getFreshConsumerConnectedToolkitsFromCache,
@@ -22,7 +21,7 @@ const makeTestConfigProvider = (entries: Array<[string, string]>) =>
21 ['COMPOSIO_BASE_URL', 'https://backend.composio.dev'],
22 ...entries,
23 ]),
25 - }).pipe(extendConfigProvider);
24 + });
25
26 const defaultTestConfigProvider = makeTestConfigProvider([]);
27 const cacheEnabledTestConfigProvider = makeTestConfigProvider([
ts/packages/cli/test/src/services/permission-ui.test.ts
+4 -7
@@ -1,14 +1,11 @@
1 import { describe, expect, it } from '@effect/vitest';
2 import { ChildProcessSpawner } from 'effect/unstable/process';
3 import { ConfigProvider, Effect, Layer, PlatformError } from 'effect';
4 -import {
5 - detectPermissionCallerAgentEffect,
6 - interactivePermissionUiDisabledConfig,
7 -} from 'src/services/permission-ui';
8 -import { UNPREFIXED_CONFIG } from 'src/effects/app-config';
4 +import { detectPermissionCallerAgentEffect } from 'src/services/permission-ui';
5 +import { HOST_CONFIG } from 'src/config';
6
7 const loadFlag = (entries: Record<string, string>) =>
11 - interactivePermissionUiDisabledConfig.pipe(
8 + HOST_CONFIG.INTERACTIVE_PERMISSION_UI_DISABLED.pipe(
9 Effect.provideService(ConfigProvider.ConfigProvider, ConfigProvider.fromEnv({ env: entries }))
10 );
11
@@ -30,7 +27,7 @@ const detectAgent = (
27 layer: Layer.Layer<ChildProcessSpawner.ChildProcessSpawner>
28 ) =>
29 Effect.gen(function* () {
33 - const signals = yield* UNPREFIXED_CONFIG.CALLER_AGENT_SIGNALS.pipe(
30 + const signals = yield* HOST_CONFIG.CALLER_AGENT_SIGNALS.pipe(
31 Effect.provideService(ConfigProvider.ConfigProvider, ConfigProvider.fromEnv({ env }))
32 );
33 return yield* detectPermissionCallerAgentEffect(signals);
ts/packages/cli/test/src/services/plugin-hint.test.ts
+13 -22
@@ -6,8 +6,8 @@ import { existsSync, mkdirSync, mkdtempSync, rmSync, utimesSync, writeFileSync }
6 import { tmpdir } from 'node:os';
7 import { dirname, join } from 'node:path';
8 import { Writable } from 'node:stream';
9 +import { HOST_CONFIG } from 'src/config';
10 import { APP_VERSION } from 'src/constants';
10 -import { extendConfigProvider } from 'src/services/config';
11 import { defaultNodeOs, NodeOs } from 'src/services/node-os';
12 import { NodeProcess } from 'src/services/node-process';
13 import { detectPluginHost } from 'src/services/agent-host-env';
@@ -99,11 +99,14 @@ describe('detectPluginHost', () => {
99 ).toBe('claude');
100 });
101
102 - it('ignores empty and whitespace-only markers', () => {
103 - expect(
104 - detectPluginHost({ claudeCode: '', codexThreadId: ' ', codexSandbox: '\t' })
105 - ).toBeUndefined();
106 - });
102 + it.effect('ignores empty and whitespace-only markers', () =>
103 + Effect.gen(function* () {
104 + const markers = yield* HOST_CONFIG.AGENT_HOST.parse(
105 + ConfigProvider.fromEnvRecord({ CLAUDECODE: '', CODEX_THREAD_ID: ' ', CODEX_SANDBOX: '\t' })
106 + );
107 + expect(detectPluginHost(markers)).toBeUndefined();
108 + })
109 + );
110 });
111
112 describe('resolvePluginHintConfig', () => {
@@ -119,10 +122,7 @@ describe('resolvePluginHintConfig', () => {
122 expect(config.host).toBe('claude');
123 expect(config.commandName).toBe('version');
124 }).pipe(
122 - Effect.provideService(
123 - ConfigProvider.ConfigProvider,
124 - extendConfigProvider(ConfigProvider.fromEnv())
125 - ),
125 + Effect.provideService(ConfigProvider.ConfigProvider, ConfigProvider.fromEnv()),
126 Effect.provide(hintLayers())
127 );
128 });
@@ -139,10 +139,7 @@ describe('resolvePluginHintConfig', () => {
139 );
140 expect(config.codexConfigFile).toBe(join(tempDir, '.codex', 'config.toml'));
141 }).pipe(
142 - Effect.provideService(
143 - ConfigProvider.ConfigProvider,
144 - extendConfigProvider(ConfigProvider.fromEnv())
145 - ),
142 + Effect.provideService(ConfigProvider.ConfigProvider, ConfigProvider.fromEnv()),
143 Effect.provide(hintLayers())
144 );
145 });
@@ -161,10 +158,7 @@ describe('resolvePluginHintConfig', () => {
158 );
159 expect(config.codexConfigFile).toBe(join(codexHome, 'config.toml'));
160 }).pipe(
164 - Effect.provideService(
165 - ConfigProvider.ConfigProvider,
166 - extendConfigProvider(ConfigProvider.fromEnv())
167 - ),
161 + Effect.provideService(ConfigProvider.ConfigProvider, ConfigProvider.fromEnv()),
162 Effect.provide(hintLayers())
163 );
164 });
@@ -181,10 +175,7 @@ describe('resolvePluginHintConfig', () => {
175 );
176 expect(config.codexConfigFile).toBe(join(tempDir, 'codex-relative', 'config.toml'));
177 }).pipe(
184 - Effect.provideService(
185 - ConfigProvider.ConfigProvider,
186 - extendConfigProvider(ConfigProvider.fromEnv())
187 - ),
178 + Effect.provideService(ConfigProvider.ConfigProvider, ConfigProvider.fromEnv()),
179 Effect.provide(hintLayers())
180 );
181 });
ts/packages/cli/test/src/services/project-environment-detector.test.ts
+7 -2
@@ -2,7 +2,8 @@ import path from 'node:path';
2 import * as tempy from 'tempy';
3 import { describe, expect, layer, assert } from '@effect/vitest';
4 import { beforeAll, afterAll } from 'vitest';
5 -import { Effect, Layer, Result } from 'effect';
5 +import { ConfigProvider, Effect, Layer, Result } from 'effect';
6 +import { liveEnvConfigProvider } from 'test/__utils__';
7 import * as FileSystem from 'effect/FileSystem';
8 import * as BunFileSystem from '@effect/platform-bun/BunFileSystem';
9 import {
@@ -10,7 +11,11 @@ import {
11 ProjectEnvironmentDetectorError,
12 } from 'src/services/project-environment-detector';
13
13 -const testLayer = Layer.provideMerge(ProjectEnvironmentDetector.Default, BunFileSystem.layer);
14 +// The package-manager cases below set `npm_config_user_agent` on the live process environment.
15 +const testLayer = Layer.provideMerge(
16 + ProjectEnvironmentDetector.Default,
17 + Layer.mergeAll(BunFileSystem.layer, ConfigProvider.layer(liveEnvConfigProvider))
18 +);
19
20 const writeFile = (fs: FileSystem.FileSystem, filePath: string, content: string) =>
21 Effect.gen(function* () {
ts/packages/cli/test/src/services/run-companion-modules.test.ts
+2 -9
@@ -14,7 +14,6 @@ import {
14 RUN_COMPANION_MODULE_FILENAMES,
15 RUN_COMPANION_RELEASE_TAG_FILENAME,
16 } from 'src/services/run-companion-modules';
17 -import { getBaseConfigProvider, extendConfigProvider } from 'src/services/config';
17
18 const extractZipMock = vi.hoisted(() => vi.fn());
19 vi.mock('extract-zip', () => ({ default: extractZipMock }));
@@ -415,10 +414,7 @@ describe('run-companion-modules', () => {
414 }).pipe(
415 // Simulate the cli-main runtime, whose provider rewrites config keys
416 // to their COMPOSIO_-prefixed spelling.
418 - Effect.provideService(
419 - ConfigProvider.ConfigProvider,
420 - extendConfigProvider(getBaseConfigProvider())
421 - ),
417 + Effect.provideService(ConfigProvider.ConfigProvider, ConfigProvider.fromEnv()),
418 Effect.ensuring(
419 Effect.sync(() => fs.rmSync(installDirectory, { recursive: true, force: true }))
420 )
@@ -459,10 +455,7 @@ describe('run-companion-modules', () => {
455 'https://prefixed-proxy.test/repos/ComposioHQ/composio/releases/tags/%40composio%2Fcli%408.8.8-test'
456 );
457 }).pipe(
462 - Effect.provideService(
463 - ConfigProvider.ConfigProvider,
464 - extendConfigProvider(getBaseConfigProvider())
465 - ),
458 + Effect.provideService(ConfigProvider.ConfigProvider, ConfigProvider.fromEnv()),
459 Effect.ensuring(
460 Effect.sync(() => fs.rmSync(installDirectory, { recursive: true, force: true }))
461 )
ts/packages/cli/test/src/services/runtime-debug-logger.test.ts
+1 -2
@@ -6,13 +6,12 @@ import {
6 NO_CLI_DEBUG_FLAG_OVERRIDES,
7 type CliDebugFlagOverrides,
8 } from 'src/services/runtime-flags';
9 -import { extendConfigProvider } from 'src/services/config';
9 import { MockConsole, TestLive } from 'test/__utils__';
10
11 const configuredDebugFlags = ConfigProvider.fromEnvRecord({
12 COMPOSIO_PERF_DEBUG: '1',
13 COMPOSIO_TOOL_DEBUG: '1',
15 -}).pipe(extendConfigProvider);
14 +});
15
16 const withDebugFlags = (overrides: Partial<CliDebugFlagOverrides>) =>
17 Effect.provide(cliDebugFlagsLayer({ ...NO_CLI_DEBUG_FLAG_OVERRIDES, ...overrides }));
ts/packages/cli/test/src/services/runtime-flags.test.ts
+3 -4
@@ -12,8 +12,7 @@ import {
12 telemetryDebugModeLayer,
13 TELEMETRY_DEBUG_FLAG,
14 } from 'src/services/runtime-flags';
15 -import { extendConfigProvider } from 'src/services/config';
16 -import { TestLive } from 'test/__utils__';
15 +import { liveEnvConfigProvider, TestLive } from 'test/__utils__';
16
17 describe('debugFlagsToChildEnv', () => {
18 it('[Given] resolved debug flags [Then] every flag serializes into the child environment', () => {
@@ -56,7 +55,7 @@ const enabledDebugConfig = ConfigProvider.fromEnvRecord({
55 COMPOSIO_PERF_DEBUG: '1',
56 COMPOSIO_TOOL_DEBUG: '1',
57 COMPOSIO_RUN_ACP_ONLY: '1',
59 -}).pipe(extendConfigProvider);
58 +});
59
60 const readAllDebugFlags = Effect.all({
61 perfDebug: isPerfDebugEnabled,
@@ -111,6 +110,6 @@ describe('telemetry debug mode', () => {
110
111 vi.stubEnv('COMPOSIO_CLI_TELEMETRY_DEBUG', '');
112 expect(yield* isTelemetryDebugEnabled).toBe(false);
114 - })
113 + }).pipe(Effect.provide(ConfigProvider.layer(liveEnvConfigProvider)))
114 );
115 });
ts/packages/cli/test/src/services/tool-input-validation.test.ts
+1 -1
@@ -138,7 +138,7 @@ describe('tool input validation', () => {
138 ),
139 Effect.provideService(
140 ConfigProvider.ConfigProvider,
141 - ConfigProvider.fromEnv({ env: { CACHE_DIR: cacheDir } })
141 + ConfigProvider.fromEnv({ env: { COMPOSIO_CACHE_DIR: cacheDir } })
142 )
143 );
144 });
ts/packages/cli/test/src/services/tool-permissions.test.ts
+1 -2
@@ -22,7 +22,6 @@ import {
22 ToolPermissionDeniedError,
23 type ConsumerPermissionSnapshot,
24 } from 'src/services/tool-permissions';
25 -import { extendConfigProvider } from 'src/services/config';
25 import { NodeOs } from 'src/services/node-os';
26 import {
27 ComposioClientConfigurationError,
@@ -42,7 +41,7 @@ const ToolPermissionsTest = Layer.mergeAll(
41 NodeOs.Default,
42 // fromEnv() snapshots the environment when built; build it per provide so the
43 // per-test COMPOSIO_CACHE_DIR stub is observed.
45 - ConfigProvider.layer(Effect.sync(() => extendConfigProvider(ConfigProvider.fromEnv())))
44 + ConfigProvider.layer(Effect.sync(() => ConfigProvider.fromEnv()))
45 );
46
47 const snapshotFixture = (
ts/packages/cli/test/src/services/upgrade-binary.test.ts
+27 -27
@@ -179,9 +179,9 @@ describe('UpgradeBinary', () => {
179 });
180
181 const error = yield* runUpgrade([
182 - ['GITHUB_API_BASE_URL', apiBaseUrl],
183 - ['GITHUB_OWNER', 'test-owner'],
184 - ['GITHUB_REPO', 'test-repo'],
182 + ['COMPOSIO_GITHUB_API_BASE_URL', apiBaseUrl],
183 + ['COMPOSIO_GITHUB_OWNER', 'test-owner'],
184 + ['COMPOSIO_GITHUB_REPO', 'test-repo'],
185 ]);
186
187 expect(error).toBeInstanceOf(UpgradeBinaryError);
@@ -203,10 +203,10 @@ describe('UpgradeBinary', () => {
203 });
204
205 const error = yield* runUpgrade([
206 - ['GITHUB_API_BASE_URL', apiBaseUrl],
207 - ['GITHUB_OWNER', 'test-owner'],
208 - ['GITHUB_REPO', 'test-repo'],
209 - ['GITHUB_TAG', 'v9.9.9'],
206 + ['COMPOSIO_GITHUB_API_BASE_URL', apiBaseUrl],
207 + ['COMPOSIO_GITHUB_OWNER', 'test-owner'],
208 + ['COMPOSIO_GITHUB_REPO', 'test-repo'],
209 + ['COMPOSIO_GITHUB_TAG', 'v9.9.9'],
210 ]);
211
212 expect(error).toBeInstanceOf(UpgradeBinaryError);
@@ -227,10 +227,10 @@ describe('UpgradeBinary', () => {
227 });
228
229 const error = yield* runUpgrade([
230 - ['GITHUB_API_BASE_URL', apiBaseUrl],
231 - ['GITHUB_OWNER', 'test-owner'],
232 - ['GITHUB_REPO', 'test-repo'],
233 - ['GITHUB_TAG', 'v9.9.9'],
230 + ['COMPOSIO_GITHUB_API_BASE_URL', apiBaseUrl],
231 + ['COMPOSIO_GITHUB_OWNER', 'test-owner'],
232 + ['COMPOSIO_GITHUB_REPO', 'test-repo'],
233 + ['COMPOSIO_GITHUB_TAG', 'v9.9.9'],
234 ]);
235
236 expect(error).toBeInstanceOf(UpgradeBinaryError);
@@ -254,10 +254,10 @@ describe('UpgradeBinary', () => {
254
255 const tag = '@composio/cli@0.1.24';
256 const error = yield* runUpgrade([
257 - ['GITHUB_API_BASE_URL', apiBaseUrl],
258 - ['GITHUB_OWNER', 'test-owner'],
259 - ['GITHUB_REPO', 'test-repo'],
260 - ['GITHUB_TAG', tag],
257 + ['COMPOSIO_GITHUB_API_BASE_URL', apiBaseUrl],
258 + ['COMPOSIO_GITHUB_OWNER', 'test-owner'],
259 + ['COMPOSIO_GITHUB_REPO', 'test-repo'],
260 + ['COMPOSIO_GITHUB_TAG', tag],
261 ]);
262
263 expect(error).toBeInstanceOf(UpgradeBinaryError);
@@ -314,9 +314,9 @@ describe('UpgradeBinary', () => {
314 });
315
316 const result = yield* runUpgradeSuccess([
317 - ['GITHUB_API_BASE_URL', apiBaseUrl],
318 - ['GITHUB_OWNER', 'test-owner'],
319 - ['GITHUB_REPO', 'test-repo'],
317 + ['COMPOSIO_GITHUB_API_BASE_URL', apiBaseUrl],
318 + ['COMPOSIO_GITHUB_OWNER', 'test-owner'],
319 + ['COMPOSIO_GITHUB_REPO', 'test-repo'],
320 ]);
321
322 expect(result).toBeUndefined();
@@ -367,9 +367,9 @@ describe('UpgradeBinary', () => {
367 });
368
369 const result = yield* runUpgradeSuccess([
370 - ['GITHUB_API_BASE_URL', apiBaseUrl],
371 - ['GITHUB_OWNER', 'test-owner'],
372 - ['GITHUB_REPO', 'test-repo'],
370 + ['COMPOSIO_GITHUB_API_BASE_URL', apiBaseUrl],
371 + ['COMPOSIO_GITHUB_OWNER', 'test-owner'],
372 + ['COMPOSIO_GITHUB_REPO', 'test-repo'],
373 ]);
374
375 expect(result).toBeUndefined();
@@ -435,9 +435,9 @@ describe('UpgradeBinary', () => {
435
436 const error = yield* runUpgrade(
437 [
438 - ['GITHUB_API_BASE_URL', apiBaseUrl],
439 - ['GITHUB_OWNER', 'test-owner'],
440 - ['GITHUB_REPO', 'test-repo'],
438 + ['COMPOSIO_GITHUB_API_BASE_URL', apiBaseUrl],
439 + ['COMPOSIO_GITHUB_OWNER', 'test-owner'],
440 + ['COMPOSIO_GITHUB_REPO', 'test-repo'],
441 ],
442 { prerelease: true }
443 );
@@ -690,9 +690,9 @@ describe('UpgradeBinary', () => {
690
691 const error = yield* runUpgrade(
692 [
693 - ['GITHUB_API_BASE_URL', apiBaseUrl],
694 - ['GITHUB_OWNER', 'test-owner'],
695 - ['GITHUB_REPO', 'test-repo'],
693 + ['COMPOSIO_GITHUB_API_BASE_URL', apiBaseUrl],
694 + ['COMPOSIO_GITHUB_OWNER', 'test-owner'],
695 + ['COMPOSIO_GITHUB_REPO', 'test-repo'],
696 ],
697 { prerelease: true }
698 );
ts/packages/cli/test/src/services/user-context.test.ts
+1 -2
@@ -8,7 +8,6 @@ import * as tempy from 'tempy';
8 import { ComposioUserContext, rawComposioUserContextLive } from 'src/services/user-context';
9 import { defaultNodeOs, NodeOs } from 'src/services/node-os';
10 import { UserData, UserDataWithDefaults, userDataToJSON } from 'src/models/user-data';
11 -import { extendConfigProvider } from 'src/services/config';
11 import { CliUserConfig } from 'src/models/cli-user-config';
12 import { ComposioCliUserConfig } from 'src/services/cli-user-config';
13 import { makeKeyringService, KeyringService } from '@composio/cli-keyring/effect';
@@ -77,7 +76,7 @@ describe('ComposioUserContext', () => {
76 const withMapConfigProvider = (map: Map<string, string>) =>
77 Layer.succeed(
78 ConfigProvider.ConfigProvider,
80 - extendConfigProvider(ConfigProvider.fromEnv({ env: Object.fromEntries(map) }))
79 + ConfigProvider.fromEnv({ env: Object.fromEntries(map) })
80 );
81
82 describe('[When] no `~/.composio/user_data.json` config file exists', () => {