Skip to content

ccproxy.config.claude

ccproxy.config.claude

Claude-specific configuration settings.

ClaudeSettings

Bases: BaseModel

Claude-specific configuration settings.

validate_claude_cli_path classmethod

validate_claude_cli_path(v)

Validate Claude CLI path if provided.

Source code in ccproxy/config/claude.py
@field_validator("cli_path")
@classmethod
def validate_claude_cli_path(cls, v: str | None) -> str | None:
    """Validate Claude CLI path if provided."""
    if v is not None:
        path = Path(v)
        if not path.exists():
            raise ValueError(f"Claude CLI path does not exist: {v}")
        if not path.is_file():
            raise ValueError(f"Claude CLI path is not a file: {v}")
        if not os.access(path, os.X_OK):
            raise ValueError(f"Claude CLI path is not executable: {v}")
    return v

validate_claude_code_options classmethod

validate_claude_code_options(v)

Validate and convert Claude Code options.

Source code in ccproxy/config/claude.py
@field_validator("code_options", mode="before")
@classmethod
def validate_claude_code_options(cls, v: Any) -> Any:
    """Validate and convert Claude Code options."""
    if v is None:
        return ClaudeCodeOptions()

    # If it's already a ClaudeCodeOptions instance, return as-is
    if isinstance(v, ClaudeCodeOptions):
        return v

    # Try to convert to dict if possible
    if hasattr(v, "model_dump"):
        return v.model_dump()
    elif hasattr(v, "__dict__"):
        return v.__dict__

    return v

find_claude_cli

find_claude_cli()

Find Claude CLI executable in PATH or specified location.

Returns:

Name Type Description
tuple tuple[str | None, bool]

(path_to_claude, found_in_path)

Source code in ccproxy/config/claude.py
def find_claude_cli(self) -> tuple[str | None, bool]:
    """Find Claude CLI executable in PATH or specified location.

    Returns:
        tuple: (path_to_claude, found_in_path)
    """
    if self.cli_path:
        return self.cli_path, False

    # Try to find claude in PATH
    claude_path = shutil.which("claude")
    if claude_path:
        return claude_path, True

    # Common installation paths (in order of preference)
    common_paths = [
        # User-specific Claude installation
        Path.home() / ".claude" / "local" / "claude",
        # User's global node_modules (npm install -g)
        Path.home() / "node_modules" / ".bin" / "claude",
        # Package installation directory node_modules
        get_package_dir() / "node_modules" / ".bin" / "claude",
        # Current working directory node_modules
        Path.cwd() / "node_modules" / ".bin" / "claude",
        # System-wide installations
        Path("/usr/local/bin/claude"),
        Path("/opt/homebrew/bin/claude"),
    ]

    for path in common_paths:
        if path.exists() and path.is_file() and os.access(path, os.X_OK):
            return str(path), False

    return None, False

get_searched_paths

get_searched_paths()

Get list of paths that would be searched for Claude CLI auto-detection.

Source code in ccproxy/config/claude.py
def get_searched_paths(self) -> list[str]:
    """Get list of paths that would be searched for Claude CLI auto-detection."""
    paths = []

    # PATH search
    paths.append("PATH environment variable")

    # Common installation paths (in order of preference)
    common_paths = [
        # User-specific Claude installation
        Path.home() / ".claude" / "local" / "claude",
        # User's global node_modules (npm install -g)
        Path.home() / "node_modules" / ".bin" / "claude",
        # Package installation directory node_modules
        get_package_dir() / "node_modules" / ".bin" / "claude",
        # Current working directory node_modules
        Path.cwd() / "node_modules" / ".bin" / "claude",
        # System-wide installations
        Path("/usr/local/bin/claude"),
        Path("/opt/homebrew/bin/claude"),
    ]

    for path in common_paths:
        paths.append(str(path))

    return paths