@devries-cameron20 / composio-1 / commits / 8dc3c7496
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.

refactor(cli): read host env through the shared loadHostConfig pathway

rawHostEnvironment re-implemented by hand what src/services/config.ts already provides: a fresh unprefixed ConfigProvider.fromEnv() per execution with orDie error handling. Build the five host keys as one Config.all and load them via loadHostConfig, deleting the bespoke readOptionalEnv helper and the per-call provideServiceEffect override. The fromEnv snapshot rationale now lives only in config.ts's documented getBaseConfigProvider. Behavior is unchanged: same live-env semantics (vi.stubEnv stays observable), same blank-marker handling, same orDie on config failures.

jkomyno committed Sep 16, 2026 at 18:40 UTC 8dc3c7496abaf8fafa31ad5da4c39aa47e5f8dd6
1 file changed +18 -18
ts/packages/cli/src/services/agent-host-env.ts
+18 -18
@@ -1,7 +1,8 @@
1 import * as FileSystem from 'effect/FileSystem';
2 import * as Path from 'effect/Path';
3 -import { Config, ConfigProvider, Effect, Option } from 'effect';
3 +import { Config, Effect, Option } from 'effect';
4 import type { AgentHost } from './agent-host';
5 +import { loadHostConfig } from './config';
6 import { NodeOs } from './node-os';
7
8 export interface HostEnvMarkers {
@@ -29,25 +30,24 @@ export function detectPluginHost(markers: HostEnvMarkers): AgentHost | undefined
30 return undefined;
31 }
32
32 -const readOptionalEnv = (name: string) =>
33 - Effect.orDie(Config.option(Config.string(name)).pipe(Config.map(Option.getOrUndefined)));
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
36 -// application keys with COMPOSIO_. v4's fromEnv() snapshots the environment
37 -// when the provider is built, so it is built per read.
38 -export const rawHostEnvironment: Effect.Effect<RawHostEnvironment> = Effect.gen(function* () {
39 - const claudeCode = yield* readOptionalEnv('CLAUDECODE');
40 - const codexThreadId = yield* readOptionalEnv('CODEX_THREAD_ID');
41 - const codexSandbox = yield* readOptionalEnv('CODEX_SANDBOX');
42 - const claudeConfigDir = nonBlankOrUndefined(yield* readOptionalEnv('CLAUDE_CONFIG_DIR'));
43 - const codexHome = nonBlankOrUndefined(yield* readOptionalEnv('CODEX_HOME'));
44 - return { claudeCode, codexThreadId, codexSandbox, claudeConfigDir, codexHome };
45 -}).pipe(
46 - Effect.provideServiceEffect(
47 - ConfigProvider.ConfigProvider,
48 - Effect.sync(() => ConfigProvider.fromEnv())
49 - )
50 -);
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);
51
52 export const hostConfigDirectory = (host: AgentHost) =>
53 Effect.gen(function* () {