ccproxy.utils.binary_resolver¶
ccproxy.utils.binary_resolver
¶
Binary resolution with package manager fallback support.
BinaryCommand
¶
PackageManagerConfig
¶
Bases: TypedDict
Configuration for a package manager.
CLIInfo
¶
Bases: TypedDict
Common structure for CLI information.
BinaryResolver
¶
BinaryResolver(
fallback_enabled=True,
package_manager_only=False,
preferred_package_manager=None,
package_manager_priority=None,
)
Resolves binaries with fallback to package managers.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
fallback_enabled
|
bool
|
Whether to use package manager fallback |
True
|
package_manager_only
|
bool
|
Skip direct binary lookup and use package managers exclusively |
False
|
preferred_package_manager
|
str | None
|
Preferred package manager (bunx, pnpm, npx) |
None
|
package_manager_priority
|
list[str] | None
|
Custom priority order for package managers |
None
|
Source code in ccproxy/utils/binary_resolver.py
find_binary
¶
Find a binary with optional package manager fallback.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
binary_name
|
str
|
Name of the binary to find. Can be: - Simple binary name (e.g., "claude") - Full package name (e.g., "anthropic-ai/claude-code") |
required |
package_name
|
str | None
|
NPM package name if different from binary name |
None
|
Returns:
| Type | Description |
|---|---|
BinaryCommand | None
|
BinaryCommand with resolved command or None if not found |
Source code in ccproxy/utils/binary_resolver.py
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 | |
get_available_package_managers
¶
Get list of available package managers on the system.
Returns:
| Type | Description |
|---|---|
list[str]
|
List of package manager names that are available (e.g., ['bunx', 'pnpm']) |
Source code in ccproxy/utils/binary_resolver.py
get_package_manager_info
¶
Get detailed information about package managers.
Returns:
| Type | Description |
|---|---|
dict[str, dict[str, str | bool | int]]
|
Dictionary with package manager info including availability and priority |
Source code in ccproxy/utils/binary_resolver.py
get_cli_info
¶
Get comprehensive CLI information in common format.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
binary_name
|
str
|
Name of the binary to find |
required |
package_name
|
str | None
|
NPM package name if different from binary name |
None
|
version
|
str | None
|
Optional version string (if known) |
None
|
Returns:
| Type | Description |
|---|---|
CLIInfo
|
CLIInfo dictionary with structured information |
Source code in ccproxy/utils/binary_resolver.py
clear_cache
¶
from_settings
classmethod
¶
Create a BinaryResolver from application settings.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
settings
|
Settings
|
Application settings |
required |
Returns:
| Type | Description |
|---|---|
BinaryResolver
|
Configured BinaryResolver instance |
Source code in ccproxy/utils/binary_resolver.py
find_binary_with_fallback
¶
Convenience function to find a binary with package manager fallback.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
binary_name
|
str
|
Name of the binary to find. Can be: - Simple binary name (e.g., "claude") - Full package name (e.g., "anthropic-ai/claude-code") |
required |
package_name
|
str | None
|
NPM package name if different from binary name |
None
|
fallback_enabled
|
bool
|
Whether to use package manager fallback |
True
|
Returns:
| Type | Description |
|---|---|
list[str] | None
|
Command list to execute the binary, or None if not found |
Source code in ccproxy/utils/binary_resolver.py
is_package_manager_command
¶
Check if a command uses a package manager.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
command
|
list[str]
|
Command list to check |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if command uses a package manager |