Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
Mirrored from https://github.com/Camo67/composio.git
Synced Nov 21, 04:45 UTC
| 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 | COMPOSIO_AGENT_HOST: 'claude', |
| 24 | COMPOSIO_AGENT_SESSION_ID: 'hook_session_test', |
| 25 | CLAUDE_CODE_SESSION_ID: 'claude_session_test', |
| 26 | CODEX_SESSION_ID: 'codex_session_test', |
| 27 | }); |
| 28 | deepStrictEqual(actual, { |
| 29 | SHELL: '/bin/zsh', |
| 30 | PATH: '/usr/bin:/bin', |
| 31 | NPM_CONFIG_USER_AGENT: 'pnpm/9.0.0 npm/? node/v22.0.0 darwin arm64', |
| 32 | NO_COLOR: true, |
| 33 | CI_REDACTION_ENABLED: true, |
| 34 | INTERACTIVE_PERMISSION_UI_DISABLED: true, |
| 35 | AGENT_HOST: { |
| 36 | claudeCode: '1', |
| 37 | codexThreadId: 'thread_test', |
| 38 | codexSandbox: undefined, |
| 39 | claudeConfigDir: undefined, |
| 40 | codexHome: undefined, |
| 41 | }, |
| 42 | AGENT_SESSION: { |
| 43 | hookHost: 'claude', |
| 44 | hookSessionId: 'hook_session_test', |
| 45 | claudeCodeSessionId: 'claude_session_test', |
| 46 | codexSessionId: 'codex_session_test', |
| 47 | codexThreadId: 'thread_test', |
| 48 | }, |
| 49 | MASTER_SIGNALS: { codex: true, claude: true }, |
| 50 | CALLER_AGENT_SIGNALS: { explicit: 'Open-Claw', codex: true, claude: true, openclaw: false }, |
| 51 | }); |
| 52 | }) |
| 53 | ); |
| 54 | |
| 55 | it.effect('[Given] blank agent session variables [Then] each one reads as unset', () => |
| 56 | Effect.gen(function* () { |
| 57 | deepStrictEqual( |
| 58 | yield* read(HOST_CONFIG.AGENT_SESSION, { |
| 59 | COMPOSIO_AGENT_HOST: '', |
| 60 | COMPOSIO_AGENT_SESSION_ID: ' ', |
| 61 | CLAUDE_CODE_SESSION_ID: '', |
| 62 | CODEX_SESSION_ID: ' ', |
| 63 | CODEX_THREAD_ID: '', |
| 64 | }), |
| 65 | { |
| 66 | hookHost: undefined, |
| 67 | hookSessionId: undefined, |
| 68 | claudeCodeSessionId: undefined, |
| 69 | codexSessionId: undefined, |
| 70 | codexThreadId: undefined, |
| 71 | } |
| 72 | ); |
| 73 | }) |
| 74 | ); |
| 75 | |
| 76 | it.effect('[Then] CI redaction keys off the exact `CI=true` convention only', () => |
| 77 | Effect.gen(function* () { |
| 78 | deepStrictEqual(yield* read(HOST_CONFIG.CI_REDACTION_ENABLED, { CI: '1' }), false); |
| 79 | deepStrictEqual(yield* read(HOST_CONFIG.CI_REDACTION_ENABLED, { CI: 'true' }), true); |
| 80 | }) |
| 81 | ); |
| 82 | |
| 83 | it.effect('[Then] an explicit permission UI value overrides CI and Vitest detection', () => |
| 84 | Effect.gen(function* () { |
| 85 | const disabled = HOST_CONFIG.INTERACTIVE_PERMISSION_UI_DISABLED; |
| 86 | deepStrictEqual(yield* read(disabled, {}), false); |
| 87 | deepStrictEqual(yield* read(disabled, { CI: '1' }), true); |
| 88 | deepStrictEqual(yield* read(disabled, { VITEST: 'true' }), true); |
| 89 | deepStrictEqual( |
| 90 | yield* read(disabled, { |
| 91 | COMPOSIO_DISABLE_PERMISSION_UI: 'false', |
| 92 | CI: 'true', |
| 93 | VITEST: 'true', |
| 94 | }), |
| 95 | false |
| 96 | ); |
| 97 | deepStrictEqual(yield* read(disabled, { COMPOSIO_DISABLE_PERMISSION_UI: '1' }), true); |
| 98 | }) |
| 99 | ); |
| 100 | }); |