feat: add runtime environment variable configuration support#6
Conversation
- introduce `resolveRuntimeConfig` to prioritize env vars over file config - add comprehensive environment variable mapping for baseUrl, apiKey, and model tiers - include validation for URL and API key presence - add warning system for conflicting environment variables - update README with configuration priority and environment variable documentation - add unit tests for runtime configuration resolution - add `@types/commander` as dev dependency for type support
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 876fe336c2
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| UI.log(''); // Spacing | ||
| const toolStyle = await promptForToolCallingStyle(); |
There was a problem hiding this comment.
Avoid forcing tool-style prompt for env-only startup
When runtime env vars provide a complete config but ~/.claude-adapter/config.json is absent, this branch still prompts for toolFormat because config.toolFormat is undefined. That makes the new env-driven startup path interactive-only, so headless runs (CI/scripts/non-TTY) will block or fail despite having ANTHROPIC_BASE_URL, ANTHROPIC_API_KEY, and model env vars set. Since server code already defaults missing toolFormat to 'native', this prompt should be skipped (or defaulted) when no file-backed config exists.
Useful? React with 👍 / 👎.
Description
This PR adds runtime environment variable support for adapter startup configuration.
The adapter now resolves config in this priority order:
ANTHROPIC_* environment variables > ~/.claude-adapter/config.json > interactive promptEnvironment variable overrides are runtime-only and are not persisted back to
config.json.Type of Change
Related Issues
N/A
Changes Made
resolveRuntimeConfigto centralize runtime config resolution.ANTHROPIC_BASE_URLANTHROPIC_API_KEYANTHROPIC_AUTH_TOKENANTHROPIC_DEFAULT_MODELANTHROPIC_DEFAULT_OPUS_MODELANTHROPIC_DEFAULT_SONNET_MODELANTHROPIC_DEFAULT_HAIKU_MODELANTHROPIC_API_KEYandANTHROPIC_AUTH_TOKENare set.@types/commanderdev dependency to fix TypeScript declaration issues in editor/TS server.Testing
Verified with:
npm run buildnpm test -- runtimeConfig.test.ts cli.test.ts config.test.ts server.test.ts handlers.test.tsnpm testChecklist:
Checklist
Screenshots (if applicable)
N/A (CLI/runtime/config behavior changes only).
Additional Notes
--no-claude-settingsis optional and only skips writing Claude settings files.