mirror of
https://github.com/musistudio/claude-code-router.git
synced 2026-02-02 06:40:50 +08:00
This commit adds a new `ccr activate` command that outputs environment variables in shell-friendly format, making it easy to integrate claude-code-router with Agent SDK applications. Usage: eval $(ccr activate) This sets the following environment variables: - ANTHROPIC_AUTH_TOKEN - ANTHROPIC_API_KEY - ANTHROPIC_BASE_URL - NO_PROXY - DISABLE_TELEMETRY - DISABLE_COST_WARNINGS - API_TIMEOUT_MS - CLAUDE_CODE_USE_BEDROCK The implementation refactors the environment variable creation logic from `ccr code` into a shared `createEnvVariables()` function in `src/utils/createEnvVariables.ts`, ensuring consistency between both commands. Related: #855
23 lines
732 B
TypeScript
23 lines
732 B
TypeScript
import { readConfigFile } from ".";
|
|
|
|
/**
|
|
* Get environment variables for Agent SDK/Claude Code integration
|
|
* This function is shared between `ccr env` and `ccr code` commands
|
|
*/
|
|
export const createEnvVariables = async () => {
|
|
const config = await readConfigFile();
|
|
const port = config.PORT || 3456;
|
|
const apiKey = config.APIKEY || "test";
|
|
|
|
return {
|
|
ANTHROPIC_AUTH_TOKEN: apiKey,
|
|
ANTHROPIC_API_KEY: "",
|
|
ANTHROPIC_BASE_URL: `http://127.0.0.1:${port}`,
|
|
NO_PROXY: "127.0.0.1",
|
|
DISABLE_TELEMETRY: "true",
|
|
DISABLE_COST_WARNINGS: "true",
|
|
API_TIMEOUT_MS: String(config.API_TIMEOUT_MS ?? 600000),
|
|
// Reset CLAUDE_CODE_USE_BEDROCK when running with ccr
|
|
CLAUDE_CODE_USE_BEDROCK: undefined,
|
|
};
|
|
} |