Merged
Show file tree
Hide file tree
Changes from all 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
18 changes: 15 additions & 3 deletions contabo/lib/common.sh
Original file line numberDiff line numberDiff line change
Expand Up@@ -35,20 +35,32 @@ get_contabo_access_token() {
-d "grant_type=password" \
"${CONTABO_AUTH_URL}" 2>&1) || {
log_error "Failed to obtain Contabo OAuth token"
log_error "Response: $response"
log_error ""
log_error "How to fix:"
log_error " 1. Verify your credentials at: https://my.contabo.com/api/details"
log_error " 2. Check that CONTABO_CLIENT_ID, CONTABO_CLIENT_SECRET, CONTABO_API_USER,"
log_error " and CONTABO_API_PASSWORD are all set correctly"
log_error " 3. The API password is separate from your Contabo login password"
return 1
}

if echo "$response" | grep -q '"error"'; then
log_error "OAuth authentication failed: $response"
log_error "Contabo OAuth authentication failed"
log_error ""
log_error "How to fix:"
log_error " 1. Verify credentials at: https://my.contabo.com/api/details"
log_error " 2. Ensure your API user has not been deactivated"
log_error " 3. Re-run to enter new credentials"
return 1
fi

local token
token=$(echo "$response" | python3 -c "import json,sys; print(json.loads(sys.stdin.read()).get('access_token',''))" 2>/dev/null)

if [[ -z "$token" ]]; then
log_error "Failed to extract access token from response"
log_error "Failed to extract access token from Contabo OAuth response"
log_error "The API returned an unexpected response format."
log_error "Try again, or check Contabo's API status page."
return 1
fi

Expand Down
10 changes: 9 additions & 1 deletion exoscale/lib/common.sh
Original file line numberDiff line numberDiff line change
Expand Up@@ -60,7 +60,9 @@ ensure_exo_cli() {
local temp_dir
temp_dir=$(mktemp -d)
if ! curl -fsSL "$exo_url" -o "${temp_dir}/exo.tar.gz"; then
log_error "Failed to download exo CLI"
log_error "Failed to download exo CLI from: $exo_url"
log_error "Check your internet connection and try again."
log_error "You can also install manually: https://community.exoscale.com/documentation/tools/exoscale-command-line-interface/"
rm -rf "$temp_dir"
return 1
fi
Expand All@@ -77,6 +79,7 @@ ensure_exo_cli() {
test_exoscale_creds() {
if ! exo config list &>/dev/null; then
log_error "Exoscale credentials not configured or invalid"
log_error "Get your API credentials at: https://portal.exoscale.com/iam/api-keys"
return 1
fi

Expand DownExpand Up@@ -128,6 +131,11 @@ ensure_exoscale_creds() {
return 0
else
log_error "Failed to configure Exoscale credentials"
log_error ""
log_error "How to fix:"
log_error " 1. Verify your API Key and Secret at: https://portal.exoscale.com/iam/api-keys"
log_error " 2. Ensure the API key has the required permissions (compute, SSH keys)"
log_error " 3. Re-run the command to enter new credentials"
return 1
fi
}
Expand Down
1 change: 1 addition & 0 deletions netcup/lib/common.sh
Original file line numberDiff line numberDiff line change
Expand Up@@ -72,6 +72,7 @@ netcup_get_session() {
-H "Content-Type: application/json" \
-d "$body" 2>&1) || {
log_error "Failed to connect to Netcup API"
log_error "Check your internet connection and try again."
return 1
}

Expand Down
6 changes: 5 additions & 1 deletion scaleway/lib/common.sh
Original file line numberDiff line numberDiff line change
Expand Up@@ -88,7 +88,11 @@ get_scaleway_project_id() {

if [[ -z "$project_id" ]]; then
log_error "Failed to get Scaleway project ID"
log_warn "Set SCW_DEFAULT_PROJECT_ID environment variable or check API permissions"
log_error ""
log_error "How to fix:"
log_error " 1. Set SCW_DEFAULT_PROJECT_ID in your environment"
log_error " 2. Find your Project ID at: https://console.scaleway.com/project/settings"
log_error " 3. Ensure your API key has permission to list projects"
return 1
fi

Expand Down
83 changes: 68 additions & 15 deletions shared/common.sh
Original file line numberDiff line numberDiff line change
Expand Up@@ -122,24 +122,33 @@ ensure_jq() {

if [[ "$OSTYPE" == "darwin"* ]]; then
if command -v brew &>/dev/null; then
brew install jq || { log_error "Failed to install jq via Homebrew"; return 1; }
brew install jq || { log_error "Failed to install jq via Homebrew. Run 'brew install jq' manually."; return 1; }
else
log_error "Install jq: brew install jq (or https://jqlang.github.io/jq/download/)"
log_error "jq is required but not installed"
log_error "Install it with: brew install jq"
log_error "If Homebrew is not available: https://jqlang.github.io/jq/download/"
return 1
fi
elif command -v apt-get &>/dev/null; then
sudo apt-get update -qq && sudo apt-get install -y jq || { log_error "Failed to install jq via apt"; return 1; }
sudo apt-get update -qq && sudo apt-get install -y jq || { log_error "Failed to install jq via apt. Run 'sudo apt-get install -y jq' manually."; return 1; }
elif command -v dnf &>/dev/null; then
sudo dnf install -y jq || { log_error "Failed to install jq via dnf"; return 1; }
sudo dnf install -y jq || { log_error "Failed to install jq via dnf. Run 'sudo dnf install -y jq' manually."; return 1; }
elif command -v apk &>/dev/null; then
sudo apk add jq || { log_error "Failed to install jq via apk"; return 1; }
sudo apk add jq || { log_error "Failed to install jq via apk. Run 'sudo apk add jq' manually."; return 1; }
else
log_error "jq is required but not installed. Install from https://jqlang.github.io/jq/download/"
log_error "jq is required but not installed"
log_error ""
log_error "Install jq for your system:"
log_error " Ubuntu/Debian: sudo apt-get install -y jq"
log_error " Fedora/RHEL: sudo dnf install -y jq"
log_error " macOS: brew install jq"
log_error " Other: https://jqlang.github.io/jq/download/"
return 1
fi

if ! command -v jq &>/dev/null; then
log_error "jq not found in PATH after installation"
log_error "jq was installed but is not found in PATH"
log_error "Try opening a new terminal or run: hash -r"
return 1
fi

Expand DownExpand Up@@ -444,7 +453,12 @@ get_openrouter_api_key_manual() {
while [[ -z "${api_key}" ]]; do
attempts=$((attempts + 1))
if [[ ${attempts} -gt ${max_attempts} ]]; then
log_error "Too many failed attempts. Set OPENROUTER_API_KEY environment variable and try again."
log_error "Too many failed attempts."
log_error ""
log_error "How to fix:"
log_error " 1. Get your key from: https://openrouter.ai/settings/keys"
log_error " 2. Set it before running spawn: export OPENROUTER_API_KEY=sk-or-v1-..."
log_error " 3. Then re-run: spawn <agent> <cloud>"
return 1
fi
api_key=$(safe_read "Enter your OpenRouter API key: ") || return 1
Expand DownExpand Up@@ -1033,17 +1047,43 @@ generate_ssh_key_if_missing() {
if [[ -f "${key_path}" ]]; then
return 0
fi
log_step "Generating SSH key..."
mkdir -p "$(dirname "${key_path}")"
ssh-keygen -t ed25519 -f "${key_path}" -N "" -q
log_step "Generating SSH key at ${key_path}..."
mkdir -p "$(dirname "${key_path}")" || {
log_error "Failed to create SSH key directory: $(dirname "${key_path}")"
log_error "Check that you have write permissions to this directory."
return 1
}
ssh-keygen -t ed25519 -f "${key_path}" -N "" -q || {
log_error "Failed to generate SSH key at ${key_path}"
log_error ""
log_error "How to fix:"
log_error " 1. Check disk space: df -h $(dirname "${key_path}")"
log_error " 2. Check permissions: ls -la $(dirname "${key_path}")"
log_error " 3. Generate manually: ssh-keygen -t ed25519 -f ${key_path}"
return 1
}
log_info "SSH key generated at ${key_path}"
}

# Get MD5 fingerprint of SSH public key
# Usage: get_ssh_fingerprint PUB_KEY_PATH
get_ssh_fingerprint() {
local pub_path="${1}"
ssh-keygen -lf "${pub_path}" -E md5 2>/dev/null | awk '{print $2}' | sed 's/MD5://'
if [[ ! -f "${pub_path}" ]]; then
log_error "SSH public key not found: ${pub_path}"
log_error "Expected a public key file alongside your private key."
log_error "Regenerate with: ssh-keygen -t ed25519 -f ${pub_path%.pub}"
return 1
fi
local fingerprint
fingerprint=$(ssh-keygen -lf "${pub_path}" -E md5 2>/dev/null | awk '{print $2}' | sed 's/MD5://')
if [[ -z "${fingerprint}" ]]; then
log_error "Failed to read SSH public key fingerprint from ${pub_path}"
log_error "The key file may be corrupted or in an unsupported format."
log_error "Regenerate with: ssh-keygen -t ed25519 -f ${pub_path%.pub}"
return 1
fi
echo "${fingerprint}"
}

# JSON-escape a string (for embedding in JSON bodies)
Expand DownExpand Up@@ -1255,7 +1295,13 @@ _report_api_failure() {
local max_retries="${2}"
log_error "${retry_reason} after ${max_retries} attempts"
if [[ "${retry_reason}" == "Cloud API network error" ]]; then
log_warn "Check your internet connection and verify the provider's API is reachable."
log_warn "Could not reach the cloud provider's API."
log_warn ""
log_warn "How to fix:"
log_warn " 1. Check your internet connection: curl -s https://httpbin.org/ip"
log_warn " 2. Check DNS resolution: nslookup the provider's API hostname"
log_warn " 3. If behind a proxy or firewall, ensure HTTPS traffic is allowed"
log_warn " 4. Try again in a few moments (the API may be temporarily down)"
else
log_warn "This is usually caused by rate limiting or temporary provider issues."
log_warn "Wait a minute and try again, or check the provider's status page."
Expand DownExpand Up@@ -1468,8 +1514,15 @@ generic_ssh_wait() {
attempt=$((attempt + 1))
done

log_error "${description} timed out after ${elapsed_time}s"
log_warn "The server at ${ip} may still be booting. You can try again or check its status in your cloud provider dashboard."
log_error "${description} timed out after ${elapsed_time}s (server: ${ip})"
log_warn ""
log_warn "The server may still be booting or the connection may be blocked."
log_warn ""
log_warn "How to fix:"
log_warn " 1. Re-run the command to try again (the server may need more time)"
log_warn " 2. Check your cloud provider dashboard to verify the server is running"
log_warn " 3. Test SSH manually: ssh ${username}@${ip}"
log_warn " 4. Check that port 22 is open in the server's firewall/security group"
return 1
}

Expand Down
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Add copy buttons to all
 blocks\n(function() {\n function addCopyButtons() {\n document.querySelectorAll('pre code').forEach(function(codeBlock) {\n if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;\n codeBlock.parentElement.setAttribute('data-copy-added', 'true');\n \n var btn = document.createElement('button');\n btn.textContent = 'Copy';\n btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';\n btn.onmouseover = function() { this.style.opacity = '1'; };\n btn.onmouseout = function() { this.style.opacity = '0.7'; };\n btn.onclick = function() {\n navigator.clipboard.writeText(codeBlock.textContent).then(function() {\n btn.textContent = 'Copied!';\n setTimeout(function() { btn.textContent = 'Copy'; }, 1500);\n });\n };\n codeBlock.parentElement.style.position = 'relative';\n codeBlock.parentElement.appendChild(btn);\n });\n }\n \n addCopyButtons();\n \n // Re-run on dynamic content\n var observer = new MutationObserver(addCopyButtons);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Add Copy Buttons to Code Blocks");
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
18 changes: 15 additions & 3 deletions contabo/lib/common.sh
Original file line numberDiff line numberDiff line change
Expand Up@@ -35,20 +35,32 @@ get_contabo_access_token() {
-d "grant_type=password" \
"${CONTABO_AUTH_URL}" 2>&1) || {
log_error "Failed to obtain Contabo OAuth token"
log_error "Response: $response"
log_error ""
log_error "How to fix:"
log_error " 1. Verify your credentials at: https://my.contabo.com/api/details"
log_error " 2. Check that CONTABO_CLIENT_ID, CONTABO_CLIENT_SECRET, CONTABO_API_USER,"
log_error " and CONTABO_API_PASSWORD are all set correctly"
log_error " 3. The API password is separate from your Contabo login password"
return 1
}

if echo "$response" | grep -q '"error"'; then
log_error "OAuth authentication failed: $response"
log_error "Contabo OAuth authentication failed"
log_error ""
log_error "How to fix:"
log_error " 1. Verify credentials at: https://my.contabo.com/api/details"
log_error " 2. Ensure your API user has not been deactivated"
log_error " 3. Re-run to enter new credentials"
return 1
fi

local token
token=$(echo "$response" | python3 -c "import json,sys; print(json.loads(sys.stdin.read()).get('access_token',''))" 2>/dev/null)

if [[ -z "$token" ]]; then
log_error "Failed to extract access token from response"
log_error "Failed to extract access token from Contabo OAuth response"
log_error "The API returned an unexpected response format."
log_error "Try again, or check Contabo's API status page."
return 1
fi

Expand Down
10 changes: 9 additions & 1 deletion exoscale/lib/common.sh
Original file line numberDiff line numberDiff line change
Expand Up@@ -60,7 +60,9 @@ ensure_exo_cli() {
local temp_dir
temp_dir=$(mktemp -d)
if ! curl -fsSL "$exo_url" -o "${temp_dir}/exo.tar.gz"; then
log_error "Failed to download exo CLI"
log_error "Failed to download exo CLI from: $exo_url"
log_error "Check your internet connection and try again."
log_error "You can also install manually: https://community.exoscale.com/documentation/tools/exoscale-command-line-interface/"
rm -rf "$temp_dir"
return 1
fi
Expand All@@ -77,6 +79,7 @@ ensure_exo_cli() {
test_exoscale_creds() {
if ! exo config list &>/dev/null; then
log_error "Exoscale credentials not configured or invalid"
log_error "Get your API credentials at: https://portal.exoscale.com/iam/api-keys"
return 1
fi

Expand DownExpand Up@@ -128,6 +131,11 @@ ensure_exoscale_creds() {
return 0
else
log_error "Failed to configure Exoscale credentials"
log_error ""
log_error "How to fix:"
log_error " 1. Verify your API Key and Secret at: https://portal.exoscale.com/iam/api-keys"
log_error " 2. Ensure the API key has the required permissions (compute, SSH keys)"
log_error " 3. Re-run the command to enter new credentials"
return 1
fi
}
Expand Down
1 change: 1 addition & 0 deletions netcup/lib/common.sh
Original file line numberDiff line numberDiff line change
Expand Up@@ -72,6 +72,7 @@ netcup_get_session() {
-H "Content-Type: application/json" \
-d "$body" 2>&1) || {
log_error "Failed to connect to Netcup API"
log_error "Check your internet connection and try again."
return 1
}

Expand Down
6 changes: 5 additions & 1 deletion scaleway/lib/common.sh
Original file line numberDiff line numberDiff line change
Expand Up@@ -88,7 +88,11 @@ get_scaleway_project_id() {

if [[ -z "$project_id" ]]; then
log_error "Failed to get Scaleway project ID"
log_warn "Set SCW_DEFAULT_PROJECT_ID environment variable or check API permissions"
log_error ""
log_error "How to fix:"
log_error " 1. Set SCW_DEFAULT_PROJECT_ID in your environment"
log_error " 2. Find your Project ID at: https://console.scaleway.com/project/settings"
log_error " 3. Ensure your API key has permission to list projects"
return 1
fi

Expand Down
83 changes: 68 additions & 15 deletions shared/common.sh
Original file line numberDiff line numberDiff line change
Expand Up@@ -122,24 +122,33 @@ ensure_jq() {

if [[ "$OSTYPE" == "darwin"* ]]; then
if command -v brew &>/dev/null; then
brew install jq || { log_error "Failed to install jq via Homebrew"; return 1; }
brew install jq || { log_error "Failed to install jq via Homebrew. Run 'brew install jq' manually."; return 1; }
else
log_error "Install jq: brew install jq (or https://jqlang.github.io/jq/download/)"
log_error "jq is required but not installed"
log_error "Install it with: brew install jq"
log_error "If Homebrew is not available: https://jqlang.github.io/jq/download/"
return 1
fi
elif command -v apt-get &>/dev/null; then
sudo apt-get update -qq && sudo apt-get install -y jq || { log_error "Failed to install jq via apt"; return 1; }
sudo apt-get update -qq && sudo apt-get install -y jq || { log_error "Failed to install jq via apt. Run 'sudo apt-get install -y jq' manually."; return 1; }
elif command -v dnf &>/dev/null; then
sudo dnf install -y jq || { log_error "Failed to install jq via dnf"; return 1; }
sudo dnf install -y jq || { log_error "Failed to install jq via dnf. Run 'sudo dnf install -y jq' manually."; return 1; }
elif command -v apk &>/dev/null; then
sudo apk add jq || { log_error "Failed to install jq via apk"; return 1; }
sudo apk add jq || { log_error "Failed to install jq via apk. Run 'sudo apk add jq' manually."; return 1; }
else
log_error "jq is required but not installed. Install from https://jqlang.github.io/jq/download/"
log_error "jq is required but not installed"
log_error ""
log_error "Install jq for your system:"
log_error " Ubuntu/Debian: sudo apt-get install -y jq"
log_error " Fedora/RHEL: sudo dnf install -y jq"
log_error " macOS: brew install jq"
log_error " Other: https://jqlang.github.io/jq/download/"
return 1
fi

if ! command -v jq &>/dev/null; then
log_error "jq not found in PATH after installation"
log_error "jq was installed but is not found in PATH"
log_error "Try opening a new terminal or run: hash -r"
return 1
fi

Expand DownExpand Up@@ -444,7 +453,12 @@ get_openrouter_api_key_manual() {
while [[ -z "${api_key}" ]]; do
attempts=$((attempts + 1))
if [[ ${attempts} -gt ${max_attempts} ]]; then
log_error "Too many failed attempts. Set OPENROUTER_API_KEY environment variable and try again."
log_error "Too many failed attempts."
log_error ""
log_error "How to fix:"
log_error " 1. Get your key from: https://openrouter.ai/settings/keys"
log_error " 2. Set it before running spawn: export OPENROUTER_API_KEY=sk-or-v1-..."
log_error " 3. Then re-run: spawn <agent> <cloud>"
return 1
fi
api_key=$(safe_read "Enter your OpenRouter API key: ") || return 1
Expand DownExpand Up@@ -1033,17 +1047,43 @@ generate_ssh_key_if_missing() {
if [[ -f "${key_path}" ]]; then
return 0
fi
log_step "Generating SSH key..."
mkdir -p "$(dirname "${key_path}")"
ssh-keygen -t ed25519 -f "${key_path}" -N "" -q
log_step "Generating SSH key at ${key_path}..."
mkdir -p "$(dirname "${key_path}")" || {
log_error "Failed to create SSH key directory: $(dirname "${key_path}")"
log_error "Check that you have write permissions to this directory."
return 1
}
ssh-keygen -t ed25519 -f "${key_path}" -N "" -q || {
log_error "Failed to generate SSH key at ${key_path}"
log_error ""
log_error "How to fix:"
log_error " 1. Check disk space: df -h $(dirname "${key_path}")"
log_error " 2. Check permissions: ls -la $(dirname "${key_path}")"
log_error " 3. Generate manually: ssh-keygen -t ed25519 -f ${key_path}"
return 1
}
log_info "SSH key generated at ${key_path}"
}

# Get MD5 fingerprint of SSH public key
# Usage: get_ssh_fingerprint PUB_KEY_PATH
get_ssh_fingerprint() {
local pub_path="${1}"
ssh-keygen -lf "${pub_path}" -E md5 2>/dev/null | awk '{print $2}' | sed 's/MD5://'
if [[ ! -f "${pub_path}" ]]; then
log_error "SSH public key not found: ${pub_path}"
log_error "Expected a public key file alongside your private key."
log_error "Regenerate with: ssh-keygen -t ed25519 -f ${pub_path%.pub}"
return 1
fi
local fingerprint
fingerprint=$(ssh-keygen -lf "${pub_path}" -E md5 2>/dev/null | awk '{print $2}' | sed 's/MD5://')
if [[ -z "${fingerprint}" ]]; then
log_error "Failed to read SSH public key fingerprint from ${pub_path}"
log_error "The key file may be corrupted or in an unsupported format."
log_error "Regenerate with: ssh-keygen -t ed25519 -f ${pub_path%.pub}"
return 1
fi
echo "${fingerprint}"
}

# JSON-escape a string (for embedding in JSON bodies)
Expand DownExpand Up@@ -1255,7 +1295,13 @@ _report_api_failure() {
local max_retries="${2}"
log_error "${retry_reason} after ${max_retries} attempts"
if [[ "${retry_reason}" == "Cloud API network error" ]]; then
log_warn "Check your internet connection and verify the provider's API is reachable."
log_warn "Could not reach the cloud provider's API."
log_warn ""
log_warn "How to fix:"
log_warn " 1. Check your internet connection: curl -s https://httpbin.org/ip"
log_warn " 2. Check DNS resolution: nslookup the provider's API hostname"
log_warn " 3. If behind a proxy or firewall, ensure HTTPS traffic is allowed"
log_warn " 4. Try again in a few moments (the API may be temporarily down)"
else
log_warn "This is usually caused by rate limiting or temporary provider issues."
log_warn "Wait a minute and try again, or check the provider's status page."
Expand DownExpand Up@@ -1468,8 +1514,15 @@ generic_ssh_wait() {
attempt=$((attempt + 1))
done

log_error "${description} timed out after ${elapsed_time}s"
log_warn "The server at ${ip} may still be booting. You can try again or check its status in your cloud provider dashboard."
log_error "${description} timed out after ${elapsed_time}s (server: ${ip})"
log_warn ""
log_warn "The server may still be booting or the connection may be blocked."
log_warn ""
log_warn "How to fix:"
log_warn " 1. Re-run the command to try again (the server may need more time)"
log_warn " 2. Check your cloud provider dashboard to verify the server is running"
log_warn " 3. Test SSH manually: ssh ${username}@${ip}"
log_warn " 4. Check that port 22 is open in the server's firewall/security group"
return 1
}

Expand Down
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Force GitHub README to respect dark mode\n(function() {\n var style = document.createElement('style');\n style.textContent = '\n .markdown-body {\n color-scheme: dark light;\n }\n .markdown-body pre { background: #161b22 !important; }\n .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; }\n .markdown-body table th, .markdown-body table td { border-color: #30363d !important; }\n .markdown-body img { background: #0d1117; }\n .markdown-body blockquote { border-left-color: #8b949e; }\n .markdown-body hr { border-color: #30363d; }\n ';\n document.head.appendChild(style);\n})();", "GitHub Dark Mode README Fix"); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
18 changes: 15 additions & 3 deletions contabo/lib/common.sh
Original file line numberDiff line numberDiff line change
Expand Up@@ -35,20 +35,32 @@ get_contabo_access_token() {
-d "grant_type=password" \
"${CONTABO_AUTH_URL}" 2>&1) || {
log_error "Failed to obtain Contabo OAuth token"
log_error "Response: $response"
log_error ""
log_error "How to fix:"
log_error " 1. Verify your credentials at: https://my.contabo.com/api/details"
log_error " 2. Check that CONTABO_CLIENT_ID, CONTABO_CLIENT_SECRET, CONTABO_API_USER,"
log_error " and CONTABO_API_PASSWORD are all set correctly"
log_error " 3. The API password is separate from your Contabo login password"
return 1
}

if echo "$response" | grep -q '"error"'; then
log_error "OAuth authentication failed: $response"
log_error "Contabo OAuth authentication failed"
log_error ""
log_error "How to fix:"
log_error " 1. Verify credentials at: https://my.contabo.com/api/details"
log_error " 2. Ensure your API user has not been deactivated"
log_error " 3. Re-run to enter new credentials"
return 1
fi

local token
token=$(echo "$response" | python3 -c "import json,sys; print(json.loads(sys.stdin.read()).get('access_token',''))" 2>/dev/null)

if [[ -z "$token" ]]; then
log_error "Failed to extract access token from response"
log_error "Failed to extract access token from Contabo OAuth response"
log_error "The API returned an unexpected response format."
log_error "Try again, or check Contabo's API status page."
return 1
fi

Expand Down
10 changes: 9 additions & 1 deletion exoscale/lib/common.sh
Original file line numberDiff line numberDiff line change
Expand Up@@ -60,7 +60,9 @@ ensure_exo_cli() {
local temp_dir
temp_dir=$(mktemp -d)
if ! curl -fsSL "$exo_url" -o "${temp_dir}/exo.tar.gz"; then
log_error "Failed to download exo CLI"
log_error "Failed to download exo CLI from: $exo_url"
log_error "Check your internet connection and try again."
log_error "You can also install manually: https://community.exoscale.com/documentation/tools/exoscale-command-line-interface/"
rm -rf "$temp_dir"
return 1
fi
Expand All@@ -77,6 +79,7 @@ ensure_exo_cli() {
test_exoscale_creds() {
if ! exo config list &>/dev/null; then
log_error "Exoscale credentials not configured or invalid"
log_error "Get your API credentials at: https://portal.exoscale.com/iam/api-keys"
return 1
fi

Expand DownExpand Up@@ -128,6 +131,11 @@ ensure_exoscale_creds() {
return 0
else
log_error "Failed to configure Exoscale credentials"
log_error ""
log_error "How to fix:"
log_error " 1. Verify your API Key and Secret at: https://portal.exoscale.com/iam/api-keys"
log_error " 2. Ensure the API key has the required permissions (compute, SSH keys)"
log_error " 3. Re-run the command to enter new credentials"
return 1
fi
}
Expand Down
1 change: 1 addition & 0 deletions netcup/lib/common.sh
Original file line numberDiff line numberDiff line change
Expand Up@@ -72,6 +72,7 @@ netcup_get_session() {
-H "Content-Type: application/json" \
-d "$body" 2>&1) || {
log_error "Failed to connect to Netcup API"
log_error "Check your internet connection and try again."
return 1
}

Expand Down
6 changes: 5 additions & 1 deletion scaleway/lib/common.sh
Original file line numberDiff line numberDiff line change
Expand Up@@ -88,7 +88,11 @@ get_scaleway_project_id() {

if [[ -z "$project_id" ]]; then
log_error "Failed to get Scaleway project ID"
log_warn "Set SCW_DEFAULT_PROJECT_ID environment variable or check API permissions"
log_error ""
log_error "How to fix:"
log_error " 1. Set SCW_DEFAULT_PROJECT_ID in your environment"
log_error " 2. Find your Project ID at: https://console.scaleway.com/project/settings"
log_error " 3. Ensure your API key has permission to list projects"
return 1
fi

Expand Down
83 changes: 68 additions & 15 deletions shared/common.sh
Original file line numberDiff line numberDiff line change
Expand Up@@ -122,24 +122,33 @@ ensure_jq() {

if [[ "$OSTYPE" == "darwin"* ]]; then
if command -v brew &>/dev/null; then
brew install jq || { log_error "Failed to install jq via Homebrew"; return 1; }
brew install jq || { log_error "Failed to install jq via Homebrew. Run 'brew install jq' manually."; return 1; }
else
log_error "Install jq: brew install jq (or https://jqlang.github.io/jq/download/)"
log_error "jq is required but not installed"
log_error "Install it with: brew install jq"
log_error "If Homebrew is not available: https://jqlang.github.io/jq/download/"
return 1
fi
elif command -v apt-get &>/dev/null; then
sudo apt-get update -qq && sudo apt-get install -y jq || { log_error "Failed to install jq via apt"; return 1; }
sudo apt-get update -qq && sudo apt-get install -y jq || { log_error "Failed to install jq via apt. Run 'sudo apt-get install -y jq' manually."; return 1; }
elif command -v dnf &>/dev/null; then
sudo dnf install -y jq || { log_error "Failed to install jq via dnf"; return 1; }
sudo dnf install -y jq || { log_error "Failed to install jq via dnf. Run 'sudo dnf install -y jq' manually."; return 1; }
elif command -v apk &>/dev/null; then
sudo apk add jq || { log_error "Failed to install jq via apk"; return 1; }
sudo apk add jq || { log_error "Failed to install jq via apk. Run 'sudo apk add jq' manually."; return 1; }
else
log_error "jq is required but not installed. Install from https://jqlang.github.io/jq/download/"
log_error "jq is required but not installed"
log_error ""
log_error "Install jq for your system:"
log_error " Ubuntu/Debian: sudo apt-get install -y jq"
log_error " Fedora/RHEL: sudo dnf install -y jq"
log_error " macOS: brew install jq"
log_error " Other: https://jqlang.github.io/jq/download/"
return 1
fi

if ! command -v jq &>/dev/null; then
log_error "jq not found in PATH after installation"
log_error "jq was installed but is not found in PATH"
log_error "Try opening a new terminal or run: hash -r"
return 1
fi

Expand DownExpand Up@@ -444,7 +453,12 @@ get_openrouter_api_key_manual() {
while [[ -z "${api_key}" ]]; do
attempts=$((attempts + 1))
if [[ ${attempts} -gt ${max_attempts} ]]; then
log_error "Too many failed attempts. Set OPENROUTER_API_KEY environment variable and try again."
log_error "Too many failed attempts."
log_error ""
log_error "How to fix:"
log_error " 1. Get your key from: https://openrouter.ai/settings/keys"
log_error " 2. Set it before running spawn: export OPENROUTER_API_KEY=sk-or-v1-..."
log_error " 3. Then re-run: spawn <agent> <cloud>"
return 1
fi
api_key=$(safe_read "Enter your OpenRouter API key: ") || return 1
Expand DownExpand Up@@ -1033,17 +1047,43 @@ generate_ssh_key_if_missing() {
if [[ -f "${key_path}" ]]; then
return 0
fi
log_step "Generating SSH key..."
mkdir -p "$(dirname "${key_path}")"
ssh-keygen -t ed25519 -f "${key_path}" -N "" -q
log_step "Generating SSH key at ${key_path}..."
mkdir -p "$(dirname "${key_path}")" || {
log_error "Failed to create SSH key directory: $(dirname "${key_path}")"
log_error "Check that you have write permissions to this directory."
return 1
}
ssh-keygen -t ed25519 -f "${key_path}" -N "" -q || {
log_error "Failed to generate SSH key at ${key_path}"
log_error ""
log_error "How to fix:"
log_error " 1. Check disk space: df -h $(dirname "${key_path}")"
log_error " 2. Check permissions: ls -la $(dirname "${key_path}")"
log_error " 3. Generate manually: ssh-keygen -t ed25519 -f ${key_path}"
return 1
}
log_info "SSH key generated at ${key_path}"
}

# Get MD5 fingerprint of SSH public key
# Usage: get_ssh_fingerprint PUB_KEY_PATH
get_ssh_fingerprint() {
local pub_path="${1}"
ssh-keygen -lf "${pub_path}" -E md5 2>/dev/null | awk '{print $2}' | sed 's/MD5://'
if [[ ! -f "${pub_path}" ]]; then
log_error "SSH public key not found: ${pub_path}"
log_error "Expected a public key file alongside your private key."
log_error "Regenerate with: ssh-keygen -t ed25519 -f ${pub_path%.pub}"
return 1
fi
local fingerprint
fingerprint=$(ssh-keygen -lf "${pub_path}" -E md5 2>/dev/null | awk '{print $2}' | sed 's/MD5://')
if [[ -z "${fingerprint}" ]]; then
log_error "Failed to read SSH public key fingerprint from ${pub_path}"
log_error "The key file may be corrupted or in an unsupported format."
log_error "Regenerate with: ssh-keygen -t ed25519 -f ${pub_path%.pub}"
return 1
fi
echo "${fingerprint}"
}

# JSON-escape a string (for embedding in JSON bodies)
Expand DownExpand Up@@ -1255,7 +1295,13 @@ _report_api_failure() {
local max_retries="${2}"
log_error "${retry_reason} after ${max_retries} attempts"
if [[ "${retry_reason}" == "Cloud API network error" ]]; then
log_warn "Check your internet connection and verify the provider's API is reachable."
log_warn "Could not reach the cloud provider's API."
log_warn ""
log_warn "How to fix:"
log_warn " 1. Check your internet connection: curl -s https://httpbin.org/ip"
log_warn " 2. Check DNS resolution: nslookup the provider's API hostname"
log_warn " 3. If behind a proxy or firewall, ensure HTTPS traffic is allowed"
log_warn " 4. Try again in a few moments (the API may be temporarily down)"
else
log_warn "This is usually caused by rate limiting or temporary provider issues."
log_warn "Wait a minute and try again, or check the provider's status page."
Expand DownExpand Up@@ -1468,8 +1514,15 @@ generic_ssh_wait() {
attempt=$((attempt + 1))
done

log_error "${description} timed out after ${elapsed_time}s"
log_warn "The server at ${ip} may still be booting. You can try again or check its status in your cloud provider dashboard."
log_error "${description} timed out after ${elapsed_time}s (server: ${ip})"
log_warn ""
log_warn "The server may still be booting or the connection may be blocked."
log_warn ""
log_warn "How to fix:"
log_warn " 1. Re-run the command to try again (the server may need more time)"
log_warn " 2. Check your cloud provider dashboard to verify the server is running"
log_warn " 3. Test SSH manually: ssh ${username}@${ip}"
log_warn " 4. Check that port 22 is open in the server's firewall/security group"
return 1
}

Expand Down
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Highlight search terms from Google/DuckDuckGo/Bing referrer\n(function() {\n var ref = document.referrer;\n var terms = [];\n \n if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) {\n var url = new URL(ref);\n var q = url.searchParams.get('q') || url.searchParams.get('p');\n if (q) {\n terms = q.split(/\\s+/).filter(function(t) { return t.length > 2; });\n }\n }\n \n if (terms.length === 0) return;\n \n var style = document.createElement('style');\n style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }';\n document.head.appendChild(style);\n \n function highlight(node) {\n if (node.nodeType === 3) { // text node\n var text = node.textContent;\n var found = false;\n terms.forEach(function(term) {\n var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\') + ')', 'gi');\n if (regex.test(text)) {\n found = true;\n var frag = document.createDocumentFragment();\n var parts = text.split(regex);\n parts.forEach(function(part, i) {\n if (i % 2 === 0) {\n frag.appendChild(document.createTextNode(part));\n } else {\n var span = document.createElement('span');\n span.className = 'userscript-highlight';\n span.textContent = part;\n frag.appendChild(span);\n }\n });\n node.parentNode.replaceChild(frag, node);\n }\n });\n } else if (node.nodeType === 1 && node.childNodes) { // element\n var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT'];\n if (!skipTags.includes(node.tagName)) {\n Array.from(node.childNodes).forEach(highlight);\n }\n }\n }\n \n highlight(document.body);\n \n // Re-highlight on dynamic content\n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1 || node.nodeType === 3) highlight(node);\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Highlight Search Terms"); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
18 changes: 15 additions & 3 deletions contabo/lib/common.sh
Original file line numberDiff line numberDiff line change
Expand Up@@ -35,20 +35,32 @@ get_contabo_access_token() {
-d "grant_type=password" \
"${CONTABO_AUTH_URL}" 2>&1) || {
log_error "Failed to obtain Contabo OAuth token"
log_error "Response: $response"
log_error ""
log_error "How to fix:"
log_error " 1. Verify your credentials at: https://my.contabo.com/api/details"
log_error " 2. Check that CONTABO_CLIENT_ID, CONTABO_CLIENT_SECRET, CONTABO_API_USER,"
log_error " and CONTABO_API_PASSWORD are all set correctly"
log_error " 3. The API password is separate from your Contabo login password"
return 1
}

if echo "$response" | grep -q '"error"'; then
log_error "OAuth authentication failed: $response"
log_error "Contabo OAuth authentication failed"
log_error ""
log_error "How to fix:"
log_error " 1. Verify credentials at: https://my.contabo.com/api/details"
log_error " 2. Ensure your API user has not been deactivated"
log_error " 3. Re-run to enter new credentials"
return 1
fi

local token
token=$(echo "$response" | python3 -c "import json,sys; print(json.loads(sys.stdin.read()).get('access_token',''))" 2>/dev/null)

if [[ -z "$token" ]]; then
log_error "Failed to extract access token from response"
log_error "Failed to extract access token from Contabo OAuth response"
log_error "The API returned an unexpected response format."
log_error "Try again, or check Contabo's API status page."
return 1
fi

Expand Down
10 changes: 9 additions & 1 deletion exoscale/lib/common.sh
Original file line numberDiff line numberDiff line change
Expand Up@@ -60,7 +60,9 @@ ensure_exo_cli() {
local temp_dir
temp_dir=$(mktemp -d)
if ! curl -fsSL "$exo_url" -o "${temp_dir}/exo.tar.gz"; then
log_error "Failed to download exo CLI"
log_error "Failed to download exo CLI from: $exo_url"
log_error "Check your internet connection and try again."
log_error "You can also install manually: https://community.exoscale.com/documentation/tools/exoscale-command-line-interface/"
rm -rf "$temp_dir"
return 1
fi
Expand All@@ -77,6 +79,7 @@ ensure_exo_cli() {
test_exoscale_creds() {
if ! exo config list &>/dev/null; then
log_error "Exoscale credentials not configured or invalid"
log_error "Get your API credentials at: https://portal.exoscale.com/iam/api-keys"
return 1
fi

Expand DownExpand Up@@ -128,6 +131,11 @@ ensure_exoscale_creds() {
return 0
else
log_error "Failed to configure Exoscale credentials"
log_error ""
log_error "How to fix:"
log_error " 1. Verify your API Key and Secret at: https://portal.exoscale.com/iam/api-keys"
log_error " 2. Ensure the API key has the required permissions (compute, SSH keys)"
log_error " 3. Re-run the command to enter new credentials"
return 1
fi
}
Expand Down
1 change: 1 addition & 0 deletions netcup/lib/common.sh
Original file line numberDiff line numberDiff line change
Expand Up@@ -72,6 +72,7 @@ netcup_get_session() {
-H "Content-Type: application/json" \
-d "$body" 2>&1) || {
log_error "Failed to connect to Netcup API"
log_error "Check your internet connection and try again."
return 1
}

Expand Down
6 changes: 5 additions & 1 deletion scaleway/lib/common.sh
Original file line numberDiff line numberDiff line change
Expand Up@@ -88,7 +88,11 @@ get_scaleway_project_id() {

if [[ -z "$project_id" ]]; then
log_error "Failed to get Scaleway project ID"
log_warn "Set SCW_DEFAULT_PROJECT_ID environment variable or check API permissions"
log_error ""
log_error "How to fix:"
log_error " 1. Set SCW_DEFAULT_PROJECT_ID in your environment"
log_error " 2. Find your Project ID at: https://console.scaleway.com/project/settings"
log_error " 3. Ensure your API key has permission to list projects"
return 1
fi

Expand Down
83 changes: 68 additions & 15 deletions shared/common.sh
Original file line numberDiff line numberDiff line change
Expand Up@@ -122,24 +122,33 @@ ensure_jq() {

if [[ "$OSTYPE" == "darwin"* ]]; then
if command -v brew &>/dev/null; then
brew install jq || { log_error "Failed to install jq via Homebrew"; return 1; }
brew install jq || { log_error "Failed to install jq via Homebrew. Run 'brew install jq' manually."; return 1; }
else
log_error "Install jq: brew install jq (or https://jqlang.github.io/jq/download/)"
log_error "jq is required but not installed"
log_error "Install it with: brew install jq"
log_error "If Homebrew is not available: https://jqlang.github.io/jq/download/"
return 1
fi
elif command -v apt-get &>/dev/null; then
sudo apt-get update -qq && sudo apt-get install -y jq || { log_error "Failed to install jq via apt"; return 1; }
sudo apt-get update -qq && sudo apt-get install -y jq || { log_error "Failed to install jq via apt. Run 'sudo apt-get install -y jq' manually."; return 1; }
elif command -v dnf &>/dev/null; then
sudo dnf install -y jq || { log_error "Failed to install jq via dnf"; return 1; }
sudo dnf install -y jq || { log_error "Failed to install jq via dnf. Run 'sudo dnf install -y jq' manually."; return 1; }
elif command -v apk &>/dev/null; then
sudo apk add jq || { log_error "Failed to install jq via apk"; return 1; }
sudo apk add jq || { log_error "Failed to install jq via apk. Run 'sudo apk add jq' manually."; return 1; }
else
log_error "jq is required but not installed. Install from https://jqlang.github.io/jq/download/"
log_error "jq is required but not installed"
log_error ""
log_error "Install jq for your system:"
log_error " Ubuntu/Debian: sudo apt-get install -y jq"
log_error " Fedora/RHEL: sudo dnf install -y jq"
log_error " macOS: brew install jq"
log_error " Other: https://jqlang.github.io/jq/download/"
return 1
fi

if ! command -v jq &>/dev/null; then
log_error "jq not found in PATH after installation"
log_error "jq was installed but is not found in PATH"
log_error "Try opening a new terminal or run: hash -r"
return 1
fi

Expand DownExpand Up@@ -444,7 +453,12 @@ get_openrouter_api_key_manual() {
while [[ -z "${api_key}" ]]; do
attempts=$((attempts + 1))
if [[ ${attempts} -gt ${max_attempts} ]]; then
log_error "Too many failed attempts. Set OPENROUTER_API_KEY environment variable and try again."
log_error "Too many failed attempts."
log_error ""
log_error "How to fix:"
log_error " 1. Get your key from: https://openrouter.ai/settings/keys"
log_error " 2. Set it before running spawn: export OPENROUTER_API_KEY=sk-or-v1-..."
log_error " 3. Then re-run: spawn <agent> <cloud>"
return 1
fi
api_key=$(safe_read "Enter your OpenRouter API key: ") || return 1
Expand DownExpand Up@@ -1033,17 +1047,43 @@ generate_ssh_key_if_missing() {
if [[ -f "${key_path}" ]]; then
return 0
fi
log_step "Generating SSH key..."
mkdir -p "$(dirname "${key_path}")"
ssh-keygen -t ed25519 -f "${key_path}" -N "" -q
log_step "Generating SSH key at ${key_path}..."
mkdir -p "$(dirname "${key_path}")" || {
log_error "Failed to create SSH key directory: $(dirname "${key_path}")"
log_error "Check that you have write permissions to this directory."
return 1
}
ssh-keygen -t ed25519 -f "${key_path}" -N "" -q || {
log_error "Failed to generate SSH key at ${key_path}"
log_error ""
log_error "How to fix:"
log_error " 1. Check disk space: df -h $(dirname "${key_path}")"
log_error " 2. Check permissions: ls -la $(dirname "${key_path}")"
log_error " 3. Generate manually: ssh-keygen -t ed25519 -f ${key_path}"
return 1
}
log_info "SSH key generated at ${key_path}"
}

# Get MD5 fingerprint of SSH public key
# Usage: get_ssh_fingerprint PUB_KEY_PATH
get_ssh_fingerprint() {
local pub_path="${1}"
ssh-keygen -lf "${pub_path}" -E md5 2>/dev/null | awk '{print $2}' | sed 's/MD5://'
if [[ ! -f "${pub_path}" ]]; then
log_error "SSH public key not found: ${pub_path}"
log_error "Expected a public key file alongside your private key."
log_error "Regenerate with: ssh-keygen -t ed25519 -f ${pub_path%.pub}"
return 1
fi
local fingerprint
fingerprint=$(ssh-keygen -lf "${pub_path}" -E md5 2>/dev/null | awk '{print $2}' | sed 's/MD5://')
if [[ -z "${fingerprint}" ]]; then
log_error "Failed to read SSH public key fingerprint from ${pub_path}"
log_error "The key file may be corrupted or in an unsupported format."
log_error "Regenerate with: ssh-keygen -t ed25519 -f ${pub_path%.pub}"
return 1
fi
echo "${fingerprint}"
}

# JSON-escape a string (for embedding in JSON bodies)
Expand DownExpand Up@@ -1255,7 +1295,13 @@ _report_api_failure() {
local max_retries="${2}"
log_error "${retry_reason} after ${max_retries} attempts"
if [[ "${retry_reason}" == "Cloud API network error" ]]; then
log_warn "Check your internet connection and verify the provider's API is reachable."
log_warn "Could not reach the cloud provider's API."
log_warn ""
log_warn "How to fix:"
log_warn " 1. Check your internet connection: curl -s https://httpbin.org/ip"
log_warn " 2. Check DNS resolution: nslookup the provider's API hostname"
log_warn " 3. If behind a proxy or firewall, ensure HTTPS traffic is allowed"
log_warn " 4. Try again in a few moments (the API may be temporarily down)"
else
log_warn "This is usually caused by rate limiting or temporary provider issues."
log_warn "Wait a minute and try again, or check the provider's status page."
Expand DownExpand Up@@ -1468,8 +1514,15 @@ generic_ssh_wait() {
attempt=$((attempt + 1))
done

log_error "${description} timed out after ${elapsed_time}s"
log_warn "The server at ${ip} may still be booting. You can try again or check its status in your cloud provider dashboard."
log_error "${description} timed out after ${elapsed_time}s (server: ${ip})"
log_warn ""
log_warn "The server may still be booting or the connection may be blocked."
log_warn ""
log_warn "How to fix:"
log_warn " 1. Re-run the command to try again (the server may need more time)"
log_warn " 2. Check your cloud provider dashboard to verify the server is running"
log_warn " 3. Test SSH manually: ssh ${username}@${ip}"
log_warn " 4. Check that port 22 is open in the server's firewall/security group"
return 1
}

Expand Down
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Strip utm_, fbclid, gclid, etc. from all links on page\n(function() {\n var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content',\n 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid',\n 'ref', 'ref_src', 'source', 'medium', 'campaign'];\n \n function cleanUrl(url) {\n try {\n var u = new URL(url, window.location.origin);\n var changed = false;\n trackingParams.forEach(function(p) {\n if (u.searchParams.has(p)) {\n u.searchParams.delete(p);\n changed = true;\n }\n });\n return changed ? u.toString() : url;\n } catch (e) {\n return url;\n }\n }\n \n function cleanLinks() {\n document.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n \n cleanLinks();\n \n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1) {\n if (node.tagName === 'A') cleanLinks();\n node.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Remove Tracking Parameters from Links"); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + '
Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
18 changes: 15 additions & 3 deletions contabo/lib/common.sh
Original file line numberDiff line numberDiff line change
Expand Up@@ -35,20 +35,32 @@ get_contabo_access_token() {
-d "grant_type=password" \
"${CONTABO_AUTH_URL}" 2>&1) || {
log_error "Failed to obtain Contabo OAuth token"
log_error "Response: $response"
log_error ""
log_error "How to fix:"
log_error " 1. Verify your credentials at: https://my.contabo.com/api/details"
log_error " 2. Check that CONTABO_CLIENT_ID, CONTABO_CLIENT_SECRET, CONTABO_API_USER,"
log_error " and CONTABO_API_PASSWORD are all set correctly"
log_error " 3. The API password is separate from your Contabo login password"
return 1
}

if echo "$response" | grep -q '"error"'; then
log_error "OAuth authentication failed: $response"
log_error "Contabo OAuth authentication failed"
log_error ""
log_error "How to fix:"
log_error " 1. Verify credentials at: https://my.contabo.com/api/details"
log_error " 2. Ensure your API user has not been deactivated"
log_error " 3. Re-run to enter new credentials"
return 1
fi

local token
token=$(echo "$response" | python3 -c "import json,sys; print(json.loads(sys.stdin.read()).get('access_token',''))" 2>/dev/null)

if [[ -z "$token" ]]; then
log_error "Failed to extract access token from response"
log_error "Failed to extract access token from Contabo OAuth response"
log_error "The API returned an unexpected response format."
log_error "Try again, or check Contabo's API status page."
return 1
fi

Expand Down
10 changes: 9 additions & 1 deletion exoscale/lib/common.sh
Original file line numberDiff line numberDiff line change
Expand Up@@ -60,7 +60,9 @@ ensure_exo_cli() {
local temp_dir
temp_dir=$(mktemp -d)
if ! curl -fsSL "$exo_url" -o "${temp_dir}/exo.tar.gz"; then
log_error "Failed to download exo CLI"
log_error "Failed to download exo CLI from: $exo_url"
log_error "Check your internet connection and try again."
log_error "You can also install manually: https://community.exoscale.com/documentation/tools/exoscale-command-line-interface/"
rm -rf "$temp_dir"
return 1
fi
Expand All@@ -77,6 +79,7 @@ ensure_exo_cli() {
test_exoscale_creds() {
if ! exo config list &>/dev/null; then
log_error "Exoscale credentials not configured or invalid"
log_error "Get your API credentials at: https://portal.exoscale.com/iam/api-keys"
return 1
fi

Expand DownExpand Up@@ -128,6 +131,11 @@ ensure_exoscale_creds() {
return 0
else
log_error "Failed to configure Exoscale credentials"
log_error ""
log_error "How to fix:"
log_error " 1. Verify your API Key and Secret at: https://portal.exoscale.com/iam/api-keys"
log_error " 2. Ensure the API key has the required permissions (compute, SSH keys)"
log_error " 3. Re-run the command to enter new credentials"
return 1
fi
}
Expand Down
1 change: 1 addition & 0 deletions netcup/lib/common.sh
Original file line numberDiff line numberDiff line change
Expand Up@@ -72,6 +72,7 @@ netcup_get_session() {
-H "Content-Type: application/json" \
-d "$body" 2>&1) || {
log_error "Failed to connect to Netcup API"
log_error "Check your internet connection and try again."
return 1
}

Expand Down
6 changes: 5 additions & 1 deletion scaleway/lib/common.sh
Original file line numberDiff line numberDiff line change
Expand Up@@ -88,7 +88,11 @@ get_scaleway_project_id() {

if [[ -z "$project_id" ]]; then
log_error "Failed to get Scaleway project ID"
log_warn "Set SCW_DEFAULT_PROJECT_ID environment variable or check API permissions"
log_error ""
log_error "How to fix:"
log_error " 1. Set SCW_DEFAULT_PROJECT_ID in your environment"
log_error " 2. Find your Project ID at: https://console.scaleway.com/project/settings"
log_error " 3. Ensure your API key has permission to list projects"
return 1
fi

Expand Down
83 changes: 68 additions & 15 deletions shared/common.sh
Original file line numberDiff line numberDiff line change
Expand Up@@ -122,24 +122,33 @@ ensure_jq() {

if [[ "$OSTYPE" == "darwin"* ]]; then
if command -v brew &>/dev/null; then
brew install jq || { log_error "Failed to install jq via Homebrew"; return 1; }
brew install jq || { log_error "Failed to install jq via Homebrew. Run 'brew install jq' manually."; return 1; }
else
log_error "Install jq: brew install jq (or https://jqlang.github.io/jq/download/)"
log_error "jq is required but not installed"
log_error "Install it with: brew install jq"
log_error "If Homebrew is not available: https://jqlang.github.io/jq/download/"
return 1
fi
elif command -v apt-get &>/dev/null; then
sudo apt-get update -qq && sudo apt-get install -y jq || { log_error "Failed to install jq via apt"; return 1; }
sudo apt-get update -qq && sudo apt-get install -y jq || { log_error "Failed to install jq via apt. Run 'sudo apt-get install -y jq' manually."; return 1; }
elif command -v dnf &>/dev/null; then
sudo dnf install -y jq || { log_error "Failed to install jq via dnf"; return 1; }
sudo dnf install -y jq || { log_error "Failed to install jq via dnf. Run 'sudo dnf install -y jq' manually."; return 1; }
elif command -v apk &>/dev/null; then
sudo apk add jq || { log_error "Failed to install jq via apk"; return 1; }
sudo apk add jq || { log_error "Failed to install jq via apk. Run 'sudo apk add jq' manually."; return 1; }
else
log_error "jq is required but not installed. Install from https://jqlang.github.io/jq/download/"
log_error "jq is required but not installed"
log_error ""
log_error "Install jq for your system:"
log_error " Ubuntu/Debian: sudo apt-get install -y jq"
log_error " Fedora/RHEL: sudo dnf install -y jq"
log_error " macOS: brew install jq"
log_error " Other: https://jqlang.github.io/jq/download/"
return 1
fi

if ! command -v jq &>/dev/null; then
log_error "jq not found in PATH after installation"
log_error "jq was installed but is not found in PATH"
log_error "Try opening a new terminal or run: hash -r"
return 1
fi

Expand DownExpand Up@@ -444,7 +453,12 @@ get_openrouter_api_key_manual() {
while [[ -z "${api_key}" ]]; do
attempts=$((attempts + 1))
if [[ ${attempts} -gt ${max_attempts} ]]; then
log_error "Too many failed attempts. Set OPENROUTER_API_KEY environment variable and try again."
log_error "Too many failed attempts."
log_error ""
log_error "How to fix:"
log_error " 1. Get your key from: https://openrouter.ai/settings/keys"
log_error " 2. Set it before running spawn: export OPENROUTER_API_KEY=sk-or-v1-..."
log_error " 3. Then re-run: spawn <agent> <cloud>"
return 1
fi
api_key=$(safe_read "Enter your OpenRouter API key: ") || return 1
Expand DownExpand Up@@ -1033,17 +1047,43 @@ generate_ssh_key_if_missing() {
if [[ -f "${key_path}" ]]; then
return 0
fi
log_step "Generating SSH key..."
mkdir -p "$(dirname "${key_path}")"
ssh-keygen -t ed25519 -f "${key_path}" -N "" -q
log_step "Generating SSH key at ${key_path}..."
mkdir -p "$(dirname "${key_path}")" || {
log_error "Failed to create SSH key directory: $(dirname "${key_path}")"
log_error "Check that you have write permissions to this directory."
return 1
}
ssh-keygen -t ed25519 -f "${key_path}" -N "" -q || {
log_error "Failed to generate SSH key at ${key_path}"
log_error ""
log_error "How to fix:"
log_error " 1. Check disk space: df -h $(dirname "${key_path}")"
log_error " 2. Check permissions: ls -la $(dirname "${key_path}")"
log_error " 3. Generate manually: ssh-keygen -t ed25519 -f ${key_path}"
return 1
}
log_info "SSH key generated at ${key_path}"
}

# Get MD5 fingerprint of SSH public key
# Usage: get_ssh_fingerprint PUB_KEY_PATH
get_ssh_fingerprint() {
local pub_path="${1}"
ssh-keygen -lf "${pub_path}" -E md5 2>/dev/null | awk '{print $2}' | sed 's/MD5://'
if [[ ! -f "${pub_path}" ]]; then
log_error "SSH public key not found: ${pub_path}"
log_error "Expected a public key file alongside your private key."
log_error "Regenerate with: ssh-keygen -t ed25519 -f ${pub_path%.pub}"
return 1
fi
local fingerprint
fingerprint=$(ssh-keygen -lf "${pub_path}" -E md5 2>/dev/null | awk '{print $2}' | sed 's/MD5://')
if [[ -z "${fingerprint}" ]]; then
log_error "Failed to read SSH public key fingerprint from ${pub_path}"
log_error "The key file may be corrupted or in an unsupported format."
log_error "Regenerate with: ssh-keygen -t ed25519 -f ${pub_path%.pub}"
return 1
fi
echo "${fingerprint}"
}

# JSON-escape a string (for embedding in JSON bodies)
Expand DownExpand Up@@ -1255,7 +1295,13 @@ _report_api_failure() {
local max_retries="${2}"
log_error "${retry_reason} after ${max_retries} attempts"
if [[ "${retry_reason}" == "Cloud API network error" ]]; then
log_warn "Check your internet connection and verify the provider's API is reachable."
log_warn "Could not reach the cloud provider's API."
log_warn ""
log_warn "How to fix:"
log_warn " 1. Check your internet connection: curl -s https://httpbin.org/ip"
log_warn " 2. Check DNS resolution: nslookup the provider's API hostname"
log_warn " 3. If behind a proxy or firewall, ensure HTTPS traffic is allowed"
log_warn " 4. Try again in a few moments (the API may be temporarily down)"
else
log_warn "This is usually caused by rate limiting or temporary provider issues."
log_warn "Wait a minute and try again, or check the provider's status page."
Expand DownExpand Up@@ -1468,8 +1514,15 @@ generic_ssh_wait() {
attempt=$((attempt + 1))
done

log_error "${description} timed out after ${elapsed_time}s"
log_warn "The server at ${ip} may still be booting. You can try again or check its status in your cloud provider dashboard."
log_error "${description} timed out after ${elapsed_time}s (server: ${ip})"
log_warn ""
log_warn "The server may still be booting or the connection may be blocked."
log_warn ""
log_warn "How to fix:"
log_warn " 1. Re-run the command to try again (the server may need more time)"
log_warn " 2. Check your cloud provider dashboard to verify the server is running"
log_warn " 3. Test SSH manually: ssh ${username}@${ip}"
log_warn " 4. Check that port 22 is open in the server's firewall/security group"
return 1
}

Expand Down
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Auto-enable theater mode on YouTube\n(function() {\n function tryTheater() {\n var btn = document.querySelector('button[aria-label=\"Theater mode\"], ytd-player #player button[title=\"Theater mode\"]');\n if (btn && !btn.classList.contains('activated')) {\n btn.click();\n }\n }\n \n // Try immediately\n tryTheater();\n \n // Try after navigation (SPA)\n var lastUrl = location.href;\n setInterval(function() {\n if (location.href !== lastUrl) {\n lastUrl = location.href;\n setTimeout(tryTheater, 500);\n }\n }, 1000);\n \n // Also try on player load\n var observer = new MutationObserver(tryTheater);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "YouTube Theater Mode Default"); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
18 changes: 15 additions & 3 deletions contabo/lib/common.sh
Original file line numberDiff line numberDiff line change
Expand Up@@ -35,20 +35,32 @@ get_contabo_access_token() {
-d "grant_type=password" \
"${CONTABO_AUTH_URL}" 2>&1) || {
log_error "Failed to obtain Contabo OAuth token"
log_error "Response: $response"
log_error ""
log_error "How to fix:"
log_error " 1. Verify your credentials at: https://my.contabo.com/api/details"
log_error " 2. Check that CONTABO_CLIENT_ID, CONTABO_CLIENT_SECRET, CONTABO_API_USER,"
log_error " and CONTABO_API_PASSWORD are all set correctly"
log_error " 3. The API password is separate from your Contabo login password"
return 1
}

if echo "$response" | grep -q '"error"'; then
log_error "OAuth authentication failed: $response"
log_error "Contabo OAuth authentication failed"
log_error ""
log_error "How to fix:"
log_error " 1. Verify credentials at: https://my.contabo.com/api/details"
log_error " 2. Ensure your API user has not been deactivated"
log_error " 3. Re-run to enter new credentials"
return 1
fi

local token
token=$(echo "$response" | python3 -c "import json,sys; print(json.loads(sys.stdin.read()).get('access_token',''))" 2>/dev/null)

if [[ -z "$token" ]]; then
log_error "Failed to extract access token from response"
log_error "Failed to extract access token from Contabo OAuth response"
log_error "The API returned an unexpected response format."
log_error "Try again, or check Contabo's API status page."
return 1
fi

Expand Down
10 changes: 9 additions & 1 deletion exoscale/lib/common.sh
Original file line numberDiff line numberDiff line change
Expand Up@@ -60,7 +60,9 @@ ensure_exo_cli() {
local temp_dir
temp_dir=$(mktemp -d)
if ! curl -fsSL "$exo_url" -o "${temp_dir}/exo.tar.gz"; then
log_error "Failed to download exo CLI"
log_error "Failed to download exo CLI from: $exo_url"
log_error "Check your internet connection and try again."
log_error "You can also install manually: https://community.exoscale.com/documentation/tools/exoscale-command-line-interface/"
rm -rf "$temp_dir"
return 1
fi
Expand All@@ -77,6 +79,7 @@ ensure_exo_cli() {
test_exoscale_creds() {
if ! exo config list &>/dev/null; then
log_error "Exoscale credentials not configured or invalid"
log_error "Get your API credentials at: https://portal.exoscale.com/iam/api-keys"
return 1
fi

Expand DownExpand Up@@ -128,6 +131,11 @@ ensure_exoscale_creds() {
return 0
else
log_error "Failed to configure Exoscale credentials"
log_error ""
log_error "How to fix:"
log_error " 1. Verify your API Key and Secret at: https://portal.exoscale.com/iam/api-keys"
log_error " 2. Ensure the API key has the required permissions (compute, SSH keys)"
log_error " 3. Re-run the command to enter new credentials"
return 1
fi
}
Expand Down
1 change: 1 addition & 0 deletions netcup/lib/common.sh
Original file line numberDiff line numberDiff line change
Expand Up@@ -72,6 +72,7 @@ netcup_get_session() {
-H "Content-Type: application/json" \
-d "$body" 2>&1) || {
log_error "Failed to connect to Netcup API"
log_error "Check your internet connection and try again."
return 1
}

Expand Down
6 changes: 5 additions & 1 deletion scaleway/lib/common.sh
Original file line numberDiff line numberDiff line change
Expand Up@@ -88,7 +88,11 @@ get_scaleway_project_id() {

if [[ -z "$project_id" ]]; then
log_error "Failed to get Scaleway project ID"
log_warn "Set SCW_DEFAULT_PROJECT_ID environment variable or check API permissions"
log_error ""
log_error "How to fix:"
log_error " 1. Set SCW_DEFAULT_PROJECT_ID in your environment"
log_error " 2. Find your Project ID at: https://console.scaleway.com/project/settings"
log_error " 3. Ensure your API key has permission to list projects"
return 1
fi

Expand Down
83 changes: 68 additions & 15 deletions shared/common.sh
Original file line numberDiff line numberDiff line change
Expand Up@@ -122,24 +122,33 @@ ensure_jq() {

if [[ "$OSTYPE" == "darwin"* ]]; then
if command -v brew &>/dev/null; then
brew install jq || { log_error "Failed to install jq via Homebrew"; return 1; }
brew install jq || { log_error "Failed to install jq via Homebrew. Run 'brew install jq' manually."; return 1; }
else
log_error "Install jq: brew install jq (or https://jqlang.github.io/jq/download/)"
log_error "jq is required but not installed"
log_error "Install it with: brew install jq"
log_error "If Homebrew is not available: https://jqlang.github.io/jq/download/"
return 1
fi
elif command -v apt-get &>/dev/null; then
sudo apt-get update -qq && sudo apt-get install -y jq || { log_error "Failed to install jq via apt"; return 1; }
sudo apt-get update -qq && sudo apt-get install -y jq || { log_error "Failed to install jq via apt. Run 'sudo apt-get install -y jq' manually."; return 1; }
elif command -v dnf &>/dev/null; then
sudo dnf install -y jq || { log_error "Failed to install jq via dnf"; return 1; }
sudo dnf install -y jq || { log_error "Failed to install jq via dnf. Run 'sudo dnf install -y jq' manually."; return 1; }
elif command -v apk &>/dev/null; then
sudo apk add jq || { log_error "Failed to install jq via apk"; return 1; }
sudo apk add jq || { log_error "Failed to install jq via apk. Run 'sudo apk add jq' manually."; return 1; }
else
log_error "jq is required but not installed. Install from https://jqlang.github.io/jq/download/"
log_error "jq is required but not installed"
log_error ""
log_error "Install jq for your system:"
log_error " Ubuntu/Debian: sudo apt-get install -y jq"
log_error " Fedora/RHEL: sudo dnf install -y jq"
log_error " macOS: brew install jq"
log_error " Other: https://jqlang.github.io/jq/download/"
return 1
fi

if ! command -v jq &>/dev/null; then
log_error "jq not found in PATH after installation"
log_error "jq was installed but is not found in PATH"
log_error "Try opening a new terminal or run: hash -r"
return 1
fi

Expand DownExpand Up@@ -444,7 +453,12 @@ get_openrouter_api_key_manual() {
while [[ -z "${api_key}" ]]; do
attempts=$((attempts + 1))
if [[ ${attempts} -gt ${max_attempts} ]]; then
log_error "Too many failed attempts. Set OPENROUTER_API_KEY environment variable and try again."
log_error "Too many failed attempts."
log_error ""
log_error "How to fix:"
log_error " 1. Get your key from: https://openrouter.ai/settings/keys"
log_error " 2. Set it before running spawn: export OPENROUTER_API_KEY=sk-or-v1-..."
log_error " 3. Then re-run: spawn <agent> <cloud>"
return 1
fi
api_key=$(safe_read "Enter your OpenRouter API key: ") || return 1
Expand DownExpand Up@@ -1033,17 +1047,43 @@ generate_ssh_key_if_missing() {
if [[ -f "${key_path}" ]]; then
return 0
fi
log_step "Generating SSH key..."
mkdir -p "$(dirname "${key_path}")"
ssh-keygen -t ed25519 -f "${key_path}" -N "" -q
log_step "Generating SSH key at ${key_path}..."
mkdir -p "$(dirname "${key_path}")" || {
log_error "Failed to create SSH key directory: $(dirname "${key_path}")"
log_error "Check that you have write permissions to this directory."
return 1
}
ssh-keygen -t ed25519 -f "${key_path}" -N "" -q || {
log_error "Failed to generate SSH key at ${key_path}"
log_error ""
log_error "How to fix:"
log_error " 1. Check disk space: df -h $(dirname "${key_path}")"
log_error " 2. Check permissions: ls -la $(dirname "${key_path}")"
log_error " 3. Generate manually: ssh-keygen -t ed25519 -f ${key_path}"
return 1
}
log_info "SSH key generated at ${key_path}"
}

# Get MD5 fingerprint of SSH public key
# Usage: get_ssh_fingerprint PUB_KEY_PATH
get_ssh_fingerprint() {
local pub_path="${1}"
ssh-keygen -lf "${pub_path}" -E md5 2>/dev/null | awk '{print $2}' | sed 's/MD5://'
if [[ ! -f "${pub_path}" ]]; then
log_error "SSH public key not found: ${pub_path}"
log_error "Expected a public key file alongside your private key."
log_error "Regenerate with: ssh-keygen -t ed25519 -f ${pub_path%.pub}"
return 1
fi
local fingerprint
fingerprint=$(ssh-keygen -lf "${pub_path}" -E md5 2>/dev/null | awk '{print $2}' | sed 's/MD5://')
if [[ -z "${fingerprint}" ]]; then
log_error "Failed to read SSH public key fingerprint from ${pub_path}"
log_error "The key file may be corrupted or in an unsupported format."
log_error "Regenerate with: ssh-keygen -t ed25519 -f ${pub_path%.pub}"
return 1
fi
echo "${fingerprint}"
}

# JSON-escape a string (for embedding in JSON bodies)
Expand DownExpand Up@@ -1255,7 +1295,13 @@ _report_api_failure() {
local max_retries="${2}"
log_error "${retry_reason} after ${max_retries} attempts"
if [[ "${retry_reason}" == "Cloud API network error" ]]; then
log_warn "Check your internet connection and verify the provider's API is reachable."
log_warn "Could not reach the cloud provider's API."
log_warn ""
log_warn "How to fix:"
log_warn " 1. Check your internet connection: curl -s https://httpbin.org/ip"
log_warn " 2. Check DNS resolution: nslookup the provider's API hostname"
log_warn " 3. If behind a proxy or firewall, ensure HTTPS traffic is allowed"
log_warn " 4. Try again in a few moments (the API may be temporarily down)"
else
log_warn "This is usually caused by rate limiting or temporary provider issues."
log_warn "Wait a minute and try again, or check the provider's status page."
Expand DownExpand Up@@ -1468,8 +1514,15 @@ generic_ssh_wait() {
attempt=$((attempt + 1))
done

log_error "${description} timed out after ${elapsed_time}s"
log_warn "The server at ${ip} may still be booting. You can try again or check its status in your cloud provider dashboard."
log_error "${description} timed out after ${elapsed_time}s (server: ${ip})"
log_warn ""
log_warn "The server may still be booting or the connection may be blocked."
log_warn ""
log_warn "How to fix:"
log_warn " 1. Re-run the command to try again (the server may need more time)"
log_warn " 2. Check your cloud provider dashboard to verify the server is running"
log_warn " 3. Test SSH manually: ssh ${username}@${ip}"
log_warn " 4. Check that port 22 is open in the server's firewall/security group"
return 1
}

Expand Down
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Remove or un-stick sticky/fixed headers that block content\n(function() {\n function unstick() {\n document.querySelectorAll('header, nav, [role=\"banner\"], .header, .navbar, .sticky, .fixed-top, [style*=\"position: fixed\"], [style*=\"position:sticky\"]').forEach(function(el) {\n if (el.style.position === 'fixed' || el.style.position === 'sticky' || \n getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') {\n el.style.position = 'static';\n el.style.top = 'auto';\n el.style.zIndex = 'auto';\n }\n });\n }\n \n unstick();\n \n var observer = new MutationObserver(unstick);\n observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] });\n})();", "Kill Sticky Headers"); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
18 changes: 15 additions & 3 deletions contabo/lib/common.sh
Original file line numberDiff line numberDiff line change
Expand Up@@ -35,20 +35,32 @@ get_contabo_access_token() {
-d "grant_type=password" \
"${CONTABO_AUTH_URL}" 2>&1) || {
log_error "Failed to obtain Contabo OAuth token"
log_error "Response: $response"
log_error ""
log_error "How to fix:"
log_error " 1. Verify your credentials at: https://my.contabo.com/api/details"
log_error " 2. Check that CONTABO_CLIENT_ID, CONTABO_CLIENT_SECRET, CONTABO_API_USER,"
log_error " and CONTABO_API_PASSWORD are all set correctly"
log_error " 3. The API password is separate from your Contabo login password"
return 1
}

if echo "$response" | grep -q '"error"'; then
log_error "OAuth authentication failed: $response"
log_error "Contabo OAuth authentication failed"
log_error ""
log_error "How to fix:"
log_error " 1. Verify credentials at: https://my.contabo.com/api/details"
log_error " 2. Ensure your API user has not been deactivated"
log_error " 3. Re-run to enter new credentials"
return 1
fi

local token
token=$(echo "$response" | python3 -c "import json,sys; print(json.loads(sys.stdin.read()).get('access_token',''))" 2>/dev/null)

if [[ -z "$token" ]]; then
log_error "Failed to extract access token from response"
log_error "Failed to extract access token from Contabo OAuth response"
log_error "The API returned an unexpected response format."
log_error "Try again, or check Contabo's API status page."
return 1
fi

Expand Down
10 changes: 9 additions & 1 deletion exoscale/lib/common.sh
Original file line numberDiff line numberDiff line change
Expand Up@@ -60,7 +60,9 @@ ensure_exo_cli() {
local temp_dir
temp_dir=$(mktemp -d)
if ! curl -fsSL "$exo_url" -o "${temp_dir}/exo.tar.gz"; then
log_error "Failed to download exo CLI"
log_error "Failed to download exo CLI from: $exo_url"
log_error "Check your internet connection and try again."
log_error "You can also install manually: https://community.exoscale.com/documentation/tools/exoscale-command-line-interface/"
rm -rf "$temp_dir"
return 1
fi
Expand All@@ -77,6 +79,7 @@ ensure_exo_cli() {
test_exoscale_creds() {
if ! exo config list &>/dev/null; then
log_error "Exoscale credentials not configured or invalid"
log_error "Get your API credentials at: https://portal.exoscale.com/iam/api-keys"
return 1
fi

Expand DownExpand Up@@ -128,6 +131,11 @@ ensure_exoscale_creds() {
return 0
else
log_error "Failed to configure Exoscale credentials"
log_error ""
log_error "How to fix:"
log_error " 1. Verify your API Key and Secret at: https://portal.exoscale.com/iam/api-keys"
log_error " 2. Ensure the API key has the required permissions (compute, SSH keys)"
log_error " 3. Re-run the command to enter new credentials"
return 1
fi
}
Expand Down
1 change: 1 addition & 0 deletions netcup/lib/common.sh
Original file line numberDiff line numberDiff line change
Expand Up@@ -72,6 +72,7 @@ netcup_get_session() {
-H "Content-Type: application/json" \
-d "$body" 2>&1) || {
log_error "Failed to connect to Netcup API"
log_error "Check your internet connection and try again."
return 1
}

Expand Down
6 changes: 5 additions & 1 deletion scaleway/lib/common.sh
Original file line numberDiff line numberDiff line change
Expand Up@@ -88,7 +88,11 @@ get_scaleway_project_id() {

if [[ -z "$project_id" ]]; then
log_error "Failed to get Scaleway project ID"
log_warn "Set SCW_DEFAULT_PROJECT_ID environment variable or check API permissions"
log_error ""
log_error "How to fix:"
log_error " 1. Set SCW_DEFAULT_PROJECT_ID in your environment"
log_error " 2. Find your Project ID at: https://console.scaleway.com/project/settings"
log_error " 3. Ensure your API key has permission to list projects"
return 1
fi

Expand Down
83 changes: 68 additions & 15 deletions shared/common.sh
Original file line numberDiff line numberDiff line change
Expand Up@@ -122,24 +122,33 @@ ensure_jq() {

if [[ "$OSTYPE" == "darwin"* ]]; then
if command -v brew &>/dev/null; then
brew install jq || { log_error "Failed to install jq via Homebrew"; return 1; }
brew install jq || { log_error "Failed to install jq via Homebrew. Run 'brew install jq' manually."; return 1; }
else
log_error "Install jq: brew install jq (or https://jqlang.github.io/jq/download/)"
log_error "jq is required but not installed"
log_error "Install it with: brew install jq"
log_error "If Homebrew is not available: https://jqlang.github.io/jq/download/"
return 1
fi
elif command -v apt-get &>/dev/null; then
sudo apt-get update -qq && sudo apt-get install -y jq || { log_error "Failed to install jq via apt"; return 1; }
sudo apt-get update -qq && sudo apt-get install -y jq || { log_error "Failed to install jq via apt. Run 'sudo apt-get install -y jq' manually."; return 1; }
elif command -v dnf &>/dev/null; then
sudo dnf install -y jq || { log_error "Failed to install jq via dnf"; return 1; }
sudo dnf install -y jq || { log_error "Failed to install jq via dnf. Run 'sudo dnf install -y jq' manually."; return 1; }
elif command -v apk &>/dev/null; then
sudo apk add jq || { log_error "Failed to install jq via apk"; return 1; }
sudo apk add jq || { log_error "Failed to install jq via apk. Run 'sudo apk add jq' manually."; return 1; }
else
log_error "jq is required but not installed. Install from https://jqlang.github.io/jq/download/"
log_error "jq is required but not installed"
log_error ""
log_error "Install jq for your system:"
log_error " Ubuntu/Debian: sudo apt-get install -y jq"
log_error " Fedora/RHEL: sudo dnf install -y jq"
log_error " macOS: brew install jq"
log_error " Other: https://jqlang.github.io/jq/download/"
return 1
fi

if ! command -v jq &>/dev/null; then
log_error "jq not found in PATH after installation"
log_error "jq was installed but is not found in PATH"
log_error "Try opening a new terminal or run: hash -r"
return 1
fi

Expand DownExpand Up@@ -444,7 +453,12 @@ get_openrouter_api_key_manual() {
while [[ -z "${api_key}" ]]; do
attempts=$((attempts + 1))
if [[ ${attempts} -gt ${max_attempts} ]]; then
log_error "Too many failed attempts. Set OPENROUTER_API_KEY environment variable and try again."
log_error "Too many failed attempts."
log_error ""
log_error "How to fix:"
log_error " 1. Get your key from: https://openrouter.ai/settings/keys"
log_error " 2. Set it before running spawn: export OPENROUTER_API_KEY=sk-or-v1-..."
log_error " 3. Then re-run: spawn <agent> <cloud>"
return 1
fi
api_key=$(safe_read "Enter your OpenRouter API key: ") || return 1
Expand DownExpand Up@@ -1033,17 +1047,43 @@ generate_ssh_key_if_missing() {
if [[ -f "${key_path}" ]]; then
return 0
fi
log_step "Generating SSH key..."
mkdir -p "$(dirname "${key_path}")"
ssh-keygen -t ed25519 -f "${key_path}" -N "" -q
log_step "Generating SSH key at ${key_path}..."
mkdir -p "$(dirname "${key_path}")" || {
log_error "Failed to create SSH key directory: $(dirname "${key_path}")"
log_error "Check that you have write permissions to this directory."
return 1
}
ssh-keygen -t ed25519 -f "${key_path}" -N "" -q || {
log_error "Failed to generate SSH key at ${key_path}"
log_error ""
log_error "How to fix:"
log_error " 1. Check disk space: df -h $(dirname "${key_path}")"
log_error " 2. Check permissions: ls -la $(dirname "${key_path}")"
log_error " 3. Generate manually: ssh-keygen -t ed25519 -f ${key_path}"
return 1
}
log_info "SSH key generated at ${key_path}"
}

# Get MD5 fingerprint of SSH public key
# Usage: get_ssh_fingerprint PUB_KEY_PATH
get_ssh_fingerprint() {
local pub_path="${1}"
ssh-keygen -lf "${pub_path}" -E md5 2>/dev/null | awk '{print $2}' | sed 's/MD5://'
if [[ ! -f "${pub_path}" ]]; then
log_error "SSH public key not found: ${pub_path}"
log_error "Expected a public key file alongside your private key."
log_error "Regenerate with: ssh-keygen -t ed25519 -f ${pub_path%.pub}"
return 1
fi
local fingerprint
fingerprint=$(ssh-keygen -lf "${pub_path}" -E md5 2>/dev/null | awk '{print $2}' | sed 's/MD5://')
if [[ -z "${fingerprint}" ]]; then
log_error "Failed to read SSH public key fingerprint from ${pub_path}"
log_error "The key file may be corrupted or in an unsupported format."
log_error "Regenerate with: ssh-keygen -t ed25519 -f ${pub_path%.pub}"
return 1
fi
echo "${fingerprint}"
}

# JSON-escape a string (for embedding in JSON bodies)
Expand DownExpand Up@@ -1255,7 +1295,13 @@ _report_api_failure() {
local max_retries="${2}"
log_error "${retry_reason} after ${max_retries} attempts"
if [[ "${retry_reason}" == "Cloud API network error" ]]; then
log_warn "Check your internet connection and verify the provider's API is reachable."
log_warn "Could not reach the cloud provider's API."
log_warn ""
log_warn "How to fix:"
log_warn " 1. Check your internet connection: curl -s https://httpbin.org/ip"
log_warn " 2. Check DNS resolution: nslookup the provider's API hostname"
log_warn " 3. If behind a proxy or firewall, ensure HTTPS traffic is allowed"
log_warn " 4. Try again in a few moments (the API may be temporarily down)"
else
log_warn "This is usually caused by rate limiting or temporary provider issues."
log_warn "Wait a minute and try again, or check the provider's status page."
Expand DownExpand Up@@ -1468,8 +1514,15 @@ generic_ssh_wait() {
attempt=$((attempt + 1))
done

log_error "${description} timed out after ${elapsed_time}s"
log_warn "The server at ${ip} may still be booting. You can try again or check its status in your cloud provider dashboard."
log_error "${description} timed out after ${elapsed_time}s (server: ${ip})"
log_warn ""
log_warn "The server may still be booting or the connection may be blocked."
log_warn ""
log_warn "How to fix:"
log_warn " 1. Re-run the command to try again (the server may need more time)"
log_warn " 2. Check your cloud provider dashboard to verify the server is running"
log_warn " 3. Test SSH manually: ssh ${username}@${ip}"
log_warn " 4. Check that port 22 is open in the server's firewall/security group"
return 1
}

Expand Down
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Universal Dark Mode - works on any site\n(function() {\n var enabled = true;\n \n function applyDarkMode() {\n if (!enabled) return;\n \n // Create style element if it doesn't exist\n var style = document.getElementById('universal-dark-mode-style');\n if (!style) {\n style = document.createElement('style');\n style.id = 'universal-dark-mode-style';\n document.head.appendChild(style);\n }\n \n // Dark mode CSS - inverts colors but preserves images/video\n style.textContent = '\n /* Invert everything except media */\n html {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #1a1a2e !important;\n }\n \n /* Restore images, videos, iframes, canvas */\n img, video, iframe, canvas, svg, picture, [style*=\"background-image\"] {\n filter: invert(1) hue-rotate(180deg) !important;\n }\n \n /* Preserve specific elements that should not be inverted */\n .no-dark-mode, .no-dark-mode *,\n [data-theme=\"light\"], [data-theme=\"light\"],\n .ace_editor, .ace_editor *,\n .CodeMirror, .CodeMirror *,\n .monaco-editor, .monaco-editor *,\n .markdown-body pre, .markdown-body pre *,\n .highlight, .highlight *,\n pre code, pre code * {\n filter: none !important;\n }\n \n /* Fix common UI elements */\n .modal, .popup, .dropdown-menu, .tooltip, .popover {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #2d2d44 !important;\n border-color: #444 !important;\n }\n \n /* Scrollbars */\n ::-webkit-scrollbar { background: #1a1a2e !important; }\n ::-webkit-scrollbar-thumb { background: #444 !important; }\n ::-webkit-scrollbar-thumb:hover { background: #555 !important; }\n \n /* Selection */\n ::selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ::-moz-selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ';\n }\n \n function removeDarkMode() {\n var style = document.getElementById('universal-dark-mode-style');\n if (style) style.remove();\n }\n \n // Toggle with Alt+Shift+D\n document.addEventListener('keydown', function(e) {\n if (e.altKey && e.shiftKey && e.key === 'D') {\n e.preventDefault();\n enabled = !enabled;\n if (enabled) {\n applyDarkMode();\n console.log('[Universal Dark Mode] Enabled');\n } else {\n removeDarkMode();\n console.log('[Universal Dark Mode] Disabled');\n }\n }\n });\n \n // Apply on load\n applyDarkMode();\n \n // Re-apply on dynamic content\n var observer = new MutationObserver(function(mutations) {\n if (enabled && !document.getElementById('universal-dark-mode-style')) {\n applyDarkMode();\n }\n });\n observer.observe(document.head, { childList: true });\n \n console.log('[Universal Dark Mode] Loaded - Press Alt+Shift+D to toggle');\n})();", "Universal Dark Mode"); } } catch(__e) { console.warn('[Userscript:Universal Dark Mode]', __e); } })(); })();
Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
18 changes: 15 additions & 3 deletions contabo/lib/common.sh
Original file line numberDiff line numberDiff line change
Expand Up@@ -35,20 +35,32 @@ get_contabo_access_token() {
-d "grant_type=password" \
"${CONTABO_AUTH_URL}" 2>&1) || {
log_error "Failed to obtain Contabo OAuth token"
log_error "Response: $response"
log_error ""
log_error "How to fix:"
log_error " 1. Verify your credentials at: https://my.contabo.com/api/details"
log_error " 2. Check that CONTABO_CLIENT_ID, CONTABO_CLIENT_SECRET, CONTABO_API_USER,"
log_error " and CONTABO_API_PASSWORD are all set correctly"
log_error " 3. The API password is separate from your Contabo login password"
return 1
}

if echo "$response" | grep -q '"error"'; then
log_error "OAuth authentication failed: $response"
log_error "Contabo OAuth authentication failed"
log_error ""
log_error "How to fix:"
log_error " 1. Verify credentials at: https://my.contabo.com/api/details"
log_error " 2. Ensure your API user has not been deactivated"
log_error " 3. Re-run to enter new credentials"
return 1
fi

local token
token=$(echo "$response" | python3 -c "import json,sys; print(json.loads(sys.stdin.read()).get('access_token',''))" 2>/dev/null)

if [[ -z "$token" ]]; then
log_error "Failed to extract access token from response"
log_error "Failed to extract access token from Contabo OAuth response"
log_error "The API returned an unexpected response format."
log_error "Try again, or check Contabo's API status page."
return 1
fi

Expand Down
10 changes: 9 additions & 1 deletion exoscale/lib/common.sh
Original file line numberDiff line numberDiff line change
Expand Up@@ -60,7 +60,9 @@ ensure_exo_cli() {
local temp_dir
temp_dir=$(mktemp -d)
if ! curl -fsSL "$exo_url" -o "${temp_dir}/exo.tar.gz"; then
log_error "Failed to download exo CLI"
log_error "Failed to download exo CLI from: $exo_url"
log_error "Check your internet connection and try again."
log_error "You can also install manually: https://community.exoscale.com/documentation/tools/exoscale-command-line-interface/"
rm -rf "$temp_dir"
return 1
fi
Expand All@@ -77,6 +79,7 @@ ensure_exo_cli() {
test_exoscale_creds() {
if ! exo config list &>/dev/null; then
log_error "Exoscale credentials not configured or invalid"
log_error "Get your API credentials at: https://portal.exoscale.com/iam/api-keys"
return 1
fi

Expand DownExpand Up@@ -128,6 +131,11 @@ ensure_exoscale_creds() {
return 0
else
log_error "Failed to configure Exoscale credentials"
log_error ""
log_error "How to fix:"
log_error " 1. Verify your API Key and Secret at: https://portal.exoscale.com/iam/api-keys"
log_error " 2. Ensure the API key has the required permissions (compute, SSH keys)"
log_error " 3. Re-run the command to enter new credentials"
return 1
fi
}
Expand Down
1 change: 1 addition & 0 deletions netcup/lib/common.sh
Original file line numberDiff line numberDiff line change
Expand Up@@ -72,6 +72,7 @@ netcup_get_session() {
-H "Content-Type: application/json" \
-d "$body" 2>&1) || {
log_error "Failed to connect to Netcup API"
log_error "Check your internet connection and try again."
return 1
}

Expand Down
6 changes: 5 additions & 1 deletion scaleway/lib/common.sh
Original file line numberDiff line numberDiff line change
Expand Up@@ -88,7 +88,11 @@ get_scaleway_project_id() {

if [[ -z "$project_id" ]]; then
log_error "Failed to get Scaleway project ID"
log_warn "Set SCW_DEFAULT_PROJECT_ID environment variable or check API permissions"
log_error ""
log_error "How to fix:"
log_error " 1. Set SCW_DEFAULT_PROJECT_ID in your environment"
log_error " 2. Find your Project ID at: https://console.scaleway.com/project/settings"
log_error " 3. Ensure your API key has permission to list projects"
return 1
fi

Expand Down
83 changes: 68 additions & 15 deletions shared/common.sh
Original file line numberDiff line numberDiff line change
Expand Up@@ -122,24 +122,33 @@ ensure_jq() {

if [[ "$OSTYPE" == "darwin"* ]]; then
if command -v brew &>/dev/null; then
brew install jq || { log_error "Failed to install jq via Homebrew"; return 1; }
brew install jq || { log_error "Failed to install jq via Homebrew. Run 'brew install jq' manually."; return 1; }
else
log_error "Install jq: brew install jq (or https://jqlang.github.io/jq/download/)"
log_error "jq is required but not installed"
log_error "Install it with: brew install jq"
log_error "If Homebrew is not available: https://jqlang.github.io/jq/download/"
return 1
fi
elif command -v apt-get &>/dev/null; then
sudo apt-get update -qq && sudo apt-get install -y jq || { log_error "Failed to install jq via apt"; return 1; }
sudo apt-get update -qq && sudo apt-get install -y jq || { log_error "Failed to install jq via apt. Run 'sudo apt-get install -y jq' manually."; return 1; }
elif command -v dnf &>/dev/null; then
sudo dnf install -y jq || { log_error "Failed to install jq via dnf"; return 1; }
sudo dnf install -y jq || { log_error "Failed to install jq via dnf. Run 'sudo dnf install -y jq' manually."; return 1; }
elif command -v apk &>/dev/null; then
sudo apk add jq || { log_error "Failed to install jq via apk"; return 1; }
sudo apk add jq || { log_error "Failed to install jq via apk. Run 'sudo apk add jq' manually."; return 1; }
else
log_error "jq is required but not installed. Install from https://jqlang.github.io/jq/download/"
log_error "jq is required but not installed"
log_error ""
log_error "Install jq for your system:"
log_error " Ubuntu/Debian: sudo apt-get install -y jq"
log_error " Fedora/RHEL: sudo dnf install -y jq"
log_error " macOS: brew install jq"
log_error " Other: https://jqlang.github.io/jq/download/"
return 1
fi

if ! command -v jq &>/dev/null; then
log_error "jq not found in PATH after installation"
log_error "jq was installed but is not found in PATH"
log_error "Try opening a new terminal or run: hash -r"
return 1
fi

Expand DownExpand Up@@ -444,7 +453,12 @@ get_openrouter_api_key_manual() {
while [[ -z "${api_key}" ]]; do
attempts=$((attempts + 1))
if [[ ${attempts} -gt ${max_attempts} ]]; then
log_error "Too many failed attempts. Set OPENROUTER_API_KEY environment variable and try again."
log_error "Too many failed attempts."
log_error ""
log_error "How to fix:"
log_error " 1. Get your key from: https://openrouter.ai/settings/keys"
log_error " 2. Set it before running spawn: export OPENROUTER_API_KEY=sk-or-v1-..."
log_error " 3. Then re-run: spawn <agent> <cloud>"
return 1
fi
api_key=$(safe_read "Enter your OpenRouter API key: ") || return 1
Expand DownExpand Up@@ -1033,17 +1047,43 @@ generate_ssh_key_if_missing() {
if [[ -f "${key_path}" ]]; then
return 0
fi
log_step "Generating SSH key..."
mkdir -p "$(dirname "${key_path}")"
ssh-keygen -t ed25519 -f "${key_path}" -N "" -q
log_step "Generating SSH key at ${key_path}..."
mkdir -p "$(dirname "${key_path}")" || {
log_error "Failed to create SSH key directory: $(dirname "${key_path}")"
log_error "Check that you have write permissions to this directory."
return 1
}
ssh-keygen -t ed25519 -f "${key_path}" -N "" -q || {
log_error "Failed to generate SSH key at ${key_path}"
log_error ""
log_error "How to fix:"
log_error " 1. Check disk space: df -h $(dirname "${key_path}")"
log_error " 2. Check permissions: ls -la $(dirname "${key_path}")"
log_error " 3. Generate manually: ssh-keygen -t ed25519 -f ${key_path}"
return 1
}
log_info "SSH key generated at ${key_path}"
}

# Get MD5 fingerprint of SSH public key
# Usage: get_ssh_fingerprint PUB_KEY_PATH
get_ssh_fingerprint() {
local pub_path="${1}"
ssh-keygen -lf "${pub_path}" -E md5 2>/dev/null | awk '{print $2}' | sed 's/MD5://'
if [[ ! -f "${pub_path}" ]]; then
log_error "SSH public key not found: ${pub_path}"
log_error "Expected a public key file alongside your private key."
log_error "Regenerate with: ssh-keygen -t ed25519 -f ${pub_path%.pub}"
return 1
fi
local fingerprint
fingerprint=$(ssh-keygen -lf "${pub_path}" -E md5 2>/dev/null | awk '{print $2}' | sed 's/MD5://')
if [[ -z "${fingerprint}" ]]; then
log_error "Failed to read SSH public key fingerprint from ${pub_path}"
log_error "The key file may be corrupted or in an unsupported format."
log_error "Regenerate with: ssh-keygen -t ed25519 -f ${pub_path%.pub}"
return 1
fi
echo "${fingerprint}"
}

# JSON-escape a string (for embedding in JSON bodies)
Expand DownExpand Up@@ -1255,7 +1295,13 @@ _report_api_failure() {
local max_retries="${2}"
log_error "${retry_reason} after ${max_retries} attempts"
if [[ "${retry_reason}" == "Cloud API network error" ]]; then
log_warn "Check your internet connection and verify the provider's API is reachable."
log_warn "Could not reach the cloud provider's API."
log_warn ""
log_warn "How to fix:"
log_warn " 1. Check your internet connection: curl -s https://httpbin.org/ip"
log_warn " 2. Check DNS resolution: nslookup the provider's API hostname"
log_warn " 3. If behind a proxy or firewall, ensure HTTPS traffic is allowed"
log_warn " 4. Try again in a few moments (the API may be temporarily down)"
else
log_warn "This is usually caused by rate limiting or temporary provider issues."
log_warn "Wait a minute and try again, or check the provider's status page."
Expand DownExpand Up@@ -1468,8 +1514,15 @@ generic_ssh_wait() {
attempt=$((attempt + 1))
done

log_error "${description} timed out after ${elapsed_time}s"
log_warn "The server at ${ip} may still be booting. You can try again or check its status in your cloud provider dashboard."
log_error "${description} timed out after ${elapsed_time}s (server: ${ip})"
log_warn ""
log_warn "The server may still be booting or the connection may be blocked."
log_warn ""
log_warn "How to fix:"
log_warn " 1. Re-run the command to try again (the server may need more time)"
log_warn " 2. Check your cloud provider dashboard to verify the server is running"
log_warn " 3. Test SSH manually: ssh ${username}@${ip}"
log_warn " 4. Check that port 22 is open in the server's firewall/security group"
return 1
}

Expand Down