Module: ClaudeAgentSDK::CLIInstaller::Release
- Defined in:
- lib/claude_agent_sdk/cli_installer.rb
Overview
Talks to the release service: dist-tag resolution, manifest lookup and URL construction. Pure remote reads — no filesystem, no state.
Class Method Summary collapse
- .binary_url(version, platform) ⇒ Object
-
.platform_entry(version, platform) ⇒ Object
The manifest's release info for
platform: the SHA-256 (required, validated as 64 hex chars) and the declared download size (optional — nil when absent or not a positive Integer, in which case the checksum alone vouches for the download). -
.resolve_version(validated) ⇒ Object
Turns a validated request into a concrete version: dist-tags go to the network, concrete versions are already the answer.
-
.validate_version(version) ⇒ Object
Local, network-free check of what the caller asked for.
Class Method Details
.binary_url(version, platform) ⇒ Object
238 239 240 |
# File 'lib/claude_agent_sdk/cli_installer.rb', line 238 def binary_url(version, platform) "#{BASE_URL}/#{version}/#{platform}/#{BINARY_NAME}" end |
.platform_entry(version, platform) ⇒ Object
The manifest's release info for platform: the SHA-256 (required,
validated as 64 hex chars) and the declared download size (optional
— nil when absent or not a positive Integer, in which case the
checksum alone vouches for the download).
222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 |
# File 'lib/claude_agent_sdk/cli_installer.rb', line 222 def platform_entry(version, platform) url = "#{BASE_URL}/#{version}/manifest.json" platforms = parse_manifest(Http.fetch_text(url, limit: MANIFEST_RESPONSE_LIMIT), url)['platforms'] entry = platforms.is_a?(Hash) ? platforms[platform] : nil unless entry.is_a?(Hash) available = platforms.is_a?(Hash) ? platforms.keys.sort.join(', ') : 'none' raise CLIInstallError, "#{url} has no entry for platform #{platform} (available: #{available})" end checksum = entry['checksum'].to_s.downcase raise CLIInstallError, "#{url} has no valid sha256 checksum for #{platform}" unless checksum.match?(CHECKSUM_PATTERN) size = entry['size'] { checksum: checksum, size: size.is_a?(Integer) && size.positive? ? size : nil } end |
.resolve_version(validated) ⇒ Object
Turns a validated request into a concrete version: dist-tags go to the network, concrete versions are already the answer.
214 215 216 |
# File 'lib/claude_agent_sdk/cli_installer.rb', line 214 def resolve_version(validated) DIST_TAGS.include?(validated) ? resolve_dist_tag(validated) : validated end |
.validate_version(version) ⇒ Object
Local, network-free check of what the caller asked for. Returns the normalized request — a dist-tag name or a concrete version — so bad input fails before the installer touches the filesystem.
203 204 205 206 207 208 209 210 |
# File 'lib/claude_agent_sdk/cli_installer.rb', line 203 def validate_version(version) version = version.to_s.strip return version if DIST_TAGS.include?(version) || version.match?(VERSION_PATTERN) raise CLIInstallError, "Invalid Claude Code CLI version #{version.inspect}: " \ "expected #{DIST_TAGS.join('/')} or a version like '2.1.220'" end |