Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/agents/plugins/claude/claude.plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,12 @@ import {
* Supported Claude Code version
* Latest version tested and verified with CodeMie backend
*
* Latest available versions can be found here:
Comment thread
DmitriyStoyanov marked this conversation as resolved.
Outdated
* https://github.com/anthropics/claude-code/releases
*
* **UPDATE THIS WHEN BUMPING CLAUDE VERSION**
*/
const CLAUDE_SUPPORTED_VERSION = '2.1.31';
const CLAUDE_SUPPORTED_VERSION = '2.1.42';
Comment thread
DmitriyStoyanov marked this conversation as resolved.
Outdated

/**
* Claude Code installer URLs
Expand Down
43 changes: 43 additions & 0 deletions src/utils/native-installer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,37 @@ async function verifyInstallation(
return null;
}

/**
* Detect if installer output contains HTML instead of expected script output
* This occurs when the installer URL returns an HTML page (e.g., region block,
* maintenance page) instead of the actual installer script. Bash then fails
* trying to execute HTML as shell commands.
*
* @param output - Combined stdout/stderr from the installer process
* @returns true if the output contains HTML markers
*/
function isHtmlInstallerResponse(output: string): boolean {
return /<!DOCTYPE\s+html/i.test(output) || /<html[\s>]/i.test(output);
}

/**
* Extract a user-friendly error message from HTML installer response
* Checks for known error patterns (region block, service unavailability)
* and returns an appropriate message.
*
* @param output - Combined stdout/stderr containing HTML content
* @returns User-friendly error message
*/
function detectHtmlErrorMessage(output: string): string {
// Check for region-specific unavailability
if (/unavailable.*region|not.*available.*here|app.unavailable/i.test(output)) {
return 'Claude Code is not available in your current region. Visit https://claude.ai for information about supported regions.';
}

// Generic HTML response (maintenance page, unexpected redirect, etc.)
return 'Installer URL returned an HTML page instead of an installation script. The service may be temporarily unavailable or not accessible from your location. Visit https://claude.ai for more information.';
}

/**
* Install agent using native platform installer
* Detects platform and executes appropriate installation script
Expand Down Expand Up @@ -246,6 +277,18 @@ export async function installNativeAgent(

// Check if installation succeeded
if (result.code !== 0) {
const combinedOutput = `${result.stderr || ''} ${result.stdout || ''}`;

// Detect HTML response instead of installer script
// This happens when the service returns an error page (e.g., region block)
// instead of the actual installer script, and bash fails trying to parse HTML
if (isHtmlInstallerResponse(combinedOutput)) {
throw new AgentInstallationError(
agentName,
detectHtmlErrorMessage(combinedOutput)
);
}

// SECURITY: Sanitize output before including in error message
// Installer scripts might echo sensitive environment variables
const sanitizedOutput = sanitizeValue(result.stderr || result.stdout);
Expand Down