Compare commits

...

9 Commits

Author SHA1 Message Date
chrome-storm-c442
d49fa9ce90 v1.9.40: Grafana basic auth support (user/password + api_token)
- Add user/password fields to Grafana in server dialog FIELD_MAP
- GrafanaClient: support basic auth when no api_token is set
- ssh.py: _grafana_request supports basic auth fallback

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-06 10:04:09 -05:00
IPGO Developer
df40af5632 v1.9.39: add Linux release to releases/linux/
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-06 14:44:30 +00:00
IPGO Developer
fb319afbd5 v1.9.39: Linux build with merged remote changes
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-06 14:43:01 +00:00
cosmic-frost-8b10
feff23fba9 fix: add PIL._tkinter_finder hidden import for Linux PyInstaller build
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-06 14:34:22 +00:00
chrome-storm-c442
c3124aeb7d v1.9.38: fix header controls overlay width hiding Setup tab
Remove relwidth=0.4 from header controls place() so buttons use
natural width and don't overlap rightmost tab buttons.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-06 09:06:52 -05:00
chrome-storm-c442
a7b4850c47 v1.9.37: align tab buttons with header controls on same Y-level
Removed separate header_bar, overlay header controls (language, update,
about) directly on tabview's tab row using place(). Tabs and controls
now sit in the same horizontal line — no vertical gap.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-06 09:01:16 -05:00
chrome-storm-c442
f5c91adac8 v1.9.36: document Claude Code image read crash bug & workarounds
- CLAUDE.md: add rule to never read images directly, only via Agent
- CLAUDE.md: add rule to never use chrome-devtools take_screenshot directly
- BUG_REPORT_CLAUDE_CODE_PNG_CRASH.md: full root cause analysis
- tools/patch_claude_code.js: v2 patcher with mapper media_type fix

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-06 08:31:27 -05:00
chrome-storm-c442
33e15827ce v1.9.35: eliminate CTkTabview internal top spacing to raise tabs
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-06 05:53:55 -05:00
chrome-storm-c442
73bcac8a55 v1.9.34: reduce header bar height and padding to raise tabview
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-06 05:52:23 -05:00
15 changed files with 433 additions and 30 deletions

View File

@@ -0,0 +1,142 @@
# Bug Report: Claude Code CLI crashes when reading large image files
## Summary
The `Read` tool in Claude Code CLI fails when reading images larger than ~25K base64 tokens (~150KB file size). Small images work fine. The root cause is in the `DP1` image compression pipeline — when a large image goes through compression, the resulting API content block ends up with `source: {type: "base64"}` but **missing both `data` and `media_type` fields**. This causes an unrecoverable API 400 error.
## Environment
- **Claude Code CLI:** `@anthropic-ai/claude-code@2.1.70`
- **OS:** Windows 10 Pro for Workstations 10.0.19045
- **Node.js:** v24.13.1
- **sharp:** 0.34.5 (manually installed, works correctly)
## Root Cause Analysis
### The Size Threshold
Images are read by `Nv8()` which calls `q01()` to create the result. After `q01()`, a size check runs:
```javascript
if (Math.ceil($.file.base64.length * 0.125) > q) // q = Tv8() = 25000 tokens
```
- **Small images** (< ~150KB file / < 25K tokens base64): Skip `DP1`, return directly from `q01()`**WORKS**
- **Large images** (> ~150KB file / > 25K tokens base64): Enter `DP1` compression path → **CRASHES**
### What happens in the DP1 path
When the image exceeds the token limit, `DP1()` is called to compress it. `DP1` uses sharp to resize/recompress and returns `{base64, mediaType, originalSize}`. The code then returns:
```javascript
return {type: "image", file: {base64: H.base64, type: H.mediaType, originalSize: z}}
```
In isolation, this looks correct. `H.mediaType` is `"image/jpeg"` (from `vp6()` inside `DP1`).
### Where it actually breaks
The tool result mapper converts this to an API content block:
```javascript
case "image": return {
tool_use_id: q,
type: "tool_result",
content: [{
type: "image",
source: {type: "base64", data: A.file.base64, media_type: A.file.type}
}]
};
```
**However**, between the mapper output and the actual API request, the image content block gets **stripped**. The API receives:
```json
{"type": "image", "source": {"type": "base64"}}
```
Both `data` and `media_type` are absent. `JSON.stringify` silently drops `undefined` properties, so if both become `undefined` at any point, the serialized JSON omits them entirely.
### Evidence from transcript analysis
The session transcript (`.jsonl` output) captured the exact message content sent to the API:
```json
{
"type": "user",
"content": [{
"tool_use_id": "toolu_01NmuSjPErhBfbtoV8RBrJip",
"type": "tool_result",
"content": [{"type": "image", "source": {"type": "base64"}}]
}]
}
```
This confirms `data` and `media_type` are both missing at the API call level.
### The actual root cause (suspected)
The image data stripping likely occurs in the **message normalization/storage layer** between the tool result mapper and the API call. When conversation messages are stored in memory (the internal `D` array or conversation state), large base64 image data may be:
1. Stripped for memory efficiency
2. Moved to a separate image attachment store (referenced by `imagePasteIds`)
3. Lost during `structuredClone` or message serialization
The reconstruction step that should restore the image data before the API call **fails for tool_result image blocks**, possibly because it only handles top-level image blocks (from user pastes) but not images nested inside `tool_result.content[]`.
## Test Results
| File | Size | Base64 tokens | DP1 path | Result |
|------|------|---------------|----------|--------|
| photo.jpg | 25KB | ~4,250 | No | **Works** |
| test_tiny.png | 98B | ~16 | No | **Works** |
| test_medium.png | 751KB | ~125,000 | Yes | **Crashes** |
| screenshot_gui.png | 387KB | ~64,500 | Yes | **Crashes** |
## Severity: Critical
- **Session-killing:** corrupted message poisons the entire conversation context
- **No recovery:** every subsequent API call fails with 400
- **Affects subagents too:** Agent tool crashes, but main session survives
- **Size-dependent:** only images > ~150KB trigger the bug
## Patches Applied
### Patch 1: Nv8 try/catch wrapper (`PATCHED_NV8_SAFE_IMAGE_READ`)
Wraps the entire `Nv8` function in try/catch. On failure, returns a text error message instead of corrupted binary. Also adds `||"image/png"` fallback on `H.mediaType` in the DP1 path.
### Patch 2: Image mapper media_type fallback (`PATCHED_IMAGE_MEDIA_TYPE`)
Adds `||"image/png"` fallback to `media_type` in the tool result mapper. Prevents `undefined` from being serialized as absent field.
### Effectiveness
- Patches only work after restarting Claude Code (cli.js is loaded once at startup)
- Patches fix the `media_type` issue but may NOT fix the missing `data` issue
- The underlying cause (image data being stripped from stored messages) needs to be fixed upstream
## Patcher Tool
```bash
node tools/patch_claude_code.js # Apply all patches
node tools/patch_claude_code.js --check # Check status
node tools/patch_claude_code.js --revert # Revert to backup
```
After updating Claude Code (`npm update -g @anthropic-ai/claude-code`), re-run the patcher.
## Workarounds
1. **Use subagent for ALL image reading** — crashes in isolation, main session survives
2. **Resize large images before reading** — keep under ~150KB
3. **Read images only via Bash tool**`file screenshot.png` for metadata, avoid actual content
## Files Referenced
- **Patcher:** `tools/patch_claude_code.js`
- **CLI entry:** `node_modules/@anthropic-ai/claude-code/cli.js` (minified, ~13K lines)
- **Key functions:** `Nv8` (image reader), `DP1` (compressor), `q01` (result builder), `ig` (sharp wrapper), `mapToolResultToToolResultBlockParam` (API mapper)
## Report Info
- **Date:** 2026-03-06
- **Version:** Claude Code 2.1.70
- **Reproducible:** 100% on Windows with any image > ~150KB

View File

@@ -4,6 +4,20 @@
ServerManager — **кроссплатформенное** Desktop GUI (CustomTkinter) для управления удалёнными серверами **любых типов**. Работает на **Windows и Linux**. Claude Code управляет серверами через скилл `/ssh`, зная только алиасы.
## КРИТИЧНО: Чтение изображений — ТОЛЬКО через Agent
**Claude Code CLI v2.1.70 баг:** Read tool крашит сессию на изображениях >150KB.
Большие изображения проходят через DP1-сжатие, где `data` и `media_type` теряются → API 400 → сессия мертва навсегда.
**ПРАВИЛА:**
- **НИКОГДА** не вызывать `Read` на .png/.jpg/.jpeg/.gif/.webp напрямую
- **НИКОГДА** не делать скриншоты через `mcp__chrome-devtools__take_screenshot` — результат тоже изображение, крашит так же
- **ВСЕГДА** читать изображения через `Agent` tool (субагент) — он упадёт изолированно, основная сессия выживет
- Маленькие (<150KB) работают, но **не рисковать** — всё через агента
- НЕ тестировать фиксы изображений в основном контексте даже после "исправления"
Подробности: `BUG_REPORT_CLAUDE_CODE_PNG_CRASH.md`
## КРОССПЛАТФОРМЕННОСТЬ — ОБЯЗАТЕЛЬНО
Приложение собирается и работает на **Windows** и **Linux**. При любых правках кода:

View File

@@ -133,6 +133,7 @@ def build():
cmd_parts.extend([
"--hidden-import", "customtkinter",
"--hidden-import", "PIL",
"--hidden-import", "PIL._tkinter_finder",
"--hidden-import", "pyotp",
"--hidden-import", "pyte",
"--hidden-import", "psutil",

View File

@@ -20,19 +20,25 @@ class GrafanaClient:
Initialize the Grafana client.
Args:
server: dict with keys: ip, port, api_token, use_ssl
server: dict with keys: ip, port, api_token (or user+password), use_ssl
"""
self.ip: str = server["ip"]
self.port: int = int(server["port"])
self.api_token: str = server["api_token"]
self.api_token: str = server.get("api_token", "")
self.user: str = server.get("user", "")
self.password: str = server.get("password", "")
self.use_ssl: bool = bool(server.get("use_ssl", False))
scheme = "https" if self.use_ssl else "http"
self.base_url: str = f"{scheme}://{self.ip}:{self.port}"
self.headers: dict[str, str] = {
"Authorization": f"Bearer {self.api_token}",
"Content-Type": "application/json",
}
self.headers: dict[str, str] = {"Content-Type": "application/json"}
self.auth: tuple[str, str] | None = None
if self.api_token:
self.headers["Authorization"] = f"Bearer {self.api_token}"
elif self.user and self.password:
self.auth = (self.user, self.password)
self.timeout: int = 10
def _get(self, path: str, params: dict | None = None) -> Any:
@@ -42,7 +48,7 @@ class GrafanaClient:
url = f"{self.base_url}{path}"
log.debug("Grafana GET %s", url)
resp = requests.get(
url, headers=self.headers, params=params, timeout=self.timeout
url, headers=self.headers, params=params, auth=self.auth, timeout=self.timeout
)
resp.raise_for_status()
return resp.json()
@@ -54,7 +60,7 @@ class GrafanaClient:
url = f"{self.base_url}{path}"
log.debug("Grafana POST %s", url)
resp = requests.post(
url, headers=self.headers, json=json_data, timeout=self.timeout
url, headers=self.headers, json=json_data, auth=self.auth, timeout=self.timeout
)
resp.raise_for_status()
return resp.json()

View File

@@ -169,15 +169,13 @@ class App(ctk.CTk):
self._main_frame = ctk.CTkFrame(self._paned, fg_color="transparent")
self._paned.add(self._main_frame, minsize=500)
# Header bar (language + about)
header_bar = ctk.CTkFrame(self._main_frame, fg_color="transparent", height=40)
header_bar.pack(fill="x", padx=10, pady=(8, 0))
header_bar.pack_propagate(False)
# Header controls — overlay frame placed on top of tabview's tab row
self._header_controls = ctk.CTkFrame(self._main_frame, fg_color="transparent", height=30)
# Language selector
_lang_img = ctk_icon("globe", 18)
self._lang_icon = ctk.CTkLabel(
header_bar, text="" if _lang_img else "\U0001f310",
self._header_controls, text="" if _lang_img else "\U0001f310",
image=_lang_img, font=ctk.CTkFont(size=14), width=20,
)
self._lang_icon.pack(side="right", padx=(5, 0))
@@ -185,17 +183,17 @@ class App(ctk.CTk):
current_display = LANGUAGES.get(i18n.get_language(), "English")
self._lang_var = ctk.StringVar(value=current_display)
self.lang_menu = ctk.CTkOptionMenu(
header_bar, values=lang_values, variable=self._lang_var,
width=110, height=30, command=self._change_language
self._header_controls, values=lang_values, variable=self._lang_var,
width=110, height=26, command=self._change_language
)
self.lang_menu.pack(side="right", padx=(5, 0))
# Check Updates button
_sync_img = ctk_icon("refresh", 18)
self._update_check_btn = ctk.CTkButton(
header_bar, text="" if _sync_img else "\u21bb",
image=_sync_img, width=30, height=30,
corner_radius=15, fg_color="#6b7280", hover_color="#4b5563",
self._header_controls, text="" if _sync_img else "\u21bb",
image=_sync_img, width=26, height=26,
corner_radius=13, fg_color="#6b7280", hover_color="#4b5563",
command=self._check_updates_manual,
)
self._update_check_btn.pack(side="right", padx=(5, 0))
@@ -203,12 +201,12 @@ class App(ctk.CTk):
# About button
_info_img = ctk_icon("info", 18)
self.about_btn = ctk.CTkButton(
header_bar, text="" if _info_img else "",
image=_info_img, width=30, height=30,
corner_radius=15, fg_color="#6b7280", hover_color="#4b5563",
self._header_controls, text="" if _info_img else "",
image=_info_img, width=26, height=26,
corner_radius=13, fg_color="#6b7280", hover_color="#4b5563",
command=self._show_about
)
self.about_btn.pack(side="right", padx=(5, 5))
self.about_btn.pack(side="right", padx=(5, 0))
# Update banner (hidden by default)
self._update_banner = None
@@ -250,7 +248,14 @@ class App(ctk.CTk):
# Create new tabview
self.tabview = ctk.CTkTabview(self._main_frame, command=self._on_tab_changed)
self.tabview.pack(fill="both", expand=True, padx=10, pady=(0, 10))
self.tabview._outer_spacing = 0
self.tabview._outer_button_overhang = 0
self.tabview._configure_grid()
self.tabview.pack(fill="both", expand=True, padx=10, pady=(4, 10))
# Overlay header controls on top-right of tabview (same row as tab buttons)
self._header_controls.lift()
self._header_controls.place(in_=self.tabview, relx=1.0, y=0, anchor="ne")
for key in self._tab_keys:
self.tabview.add(_tab_label(key))

View File

@@ -20,7 +20,7 @@ FIELD_MAP = {
"mssql": ["user", "password", "database"],
"postgresql": ["user", "password", "database"],
"redis": ["password", "db_index", "use_ssl"],
"grafana": ["api_token", "use_ssl"],
"grafana": ["user", "password", "api_token", "use_ssl"],
"prometheus": ["use_ssl"],
"rdp": ["user", "password", "rdp_resolution", "rdp_quality", "rdp_clipboard", "rdp_drives", "rdp_printers"],
"vnc": ["password"],

Binary file not shown.

Binary file not shown.

232
tools/patch_claude_code.js Normal file
View File

@@ -0,0 +1,232 @@
#!/usr/bin/env node
/**
* Patcher for Claude Code CLI — fixes image reading crash on Windows.
*
* Root cause: In some code paths, `media_type` field is undefined when
* constructing image content blocks for the API. JSON.stringify omits
* undefined values, so the field is absent from the request body.
* The API returns 400 "media_type: Field required" which permanently
* poisons the conversation context and kills the session.
*
* This patcher:
* 1. Installs `sharp` into claude-code's node_modules (if missing)
* 2. Patches the Nv8 (image reader) function to gracefully handle errors
* 3. Patches the image mapper to guarantee media_type is always present
*
* Usage:
* node tools/patch_claude_code.js # apply patch
* node tools/patch_claude_code.js --check # check status only
* node tools/patch_claude_code.js --revert # revert patch
*
* Safe to run multiple times — idempotent.
*/
const fs = require("fs");
const path = require("path");
const { execSync } = require("child_process");
// Find claude-code installation
function findClaudeCodeDir() {
const npmGlobal = execSync("npm root -g", { encoding: "utf8" }).trim();
const claudeDir = path.join(npmGlobal, "@anthropic-ai", "claude-code");
if (fs.existsSync(path.join(claudeDir, "cli.js"))) return claudeDir;
// Fallback: try common paths
const fallbacks = [
path.join(process.env.APPDATA || "", "npm", "node_modules", "@anthropic-ai", "claude-code"),
path.join(process.env.HOME || "", ".npm-global", "lib", "node_modules", "@anthropic-ai", "claude-code"),
"/usr/local/lib/node_modules/@anthropic-ai/claude-code",
];
for (const dir of fallbacks) {
if (fs.existsSync(path.join(dir, "cli.js"))) return dir;
}
return null;
}
// Check if sharp is installed
function isSharpInstalled(claudeDir) {
try {
const sharpDir = path.join(claudeDir, "node_modules", "sharp");
return fs.existsSync(sharpDir);
} catch {
return false;
}
}
// Install sharp
function installSharp(claudeDir) {
console.log("[*] Installing sharp...");
try {
execSync("npm install sharp", { cwd: claudeDir, encoding: "utf8", stdio: "pipe" });
console.log("[+] sharp installed successfully");
return true;
} catch (e) {
console.error("[-] Failed to install sharp:", e.message);
return false;
}
}
const PATCH_MARKER = "/* PATCHED_NV8_SAFE_IMAGE_READ */";
const MAPPER_PATCH_MARKER = "/* PATCHED_IMAGE_MEDIA_TYPE */";
function readCliJs(claudeDir) {
return fs.readFileSync(path.join(claudeDir, "cli.js"), "utf8");
}
function writeCliJs(claudeDir, code) {
// Backup first
const backupPath = path.join(claudeDir, "cli.js.bak");
if (!fs.existsSync(backupPath)) {
fs.copyFileSync(path.join(claudeDir, "cli.js"), backupPath);
console.log("[+] Backup created: cli.js.bak");
}
fs.writeFileSync(path.join(claudeDir, "cli.js"), code, "utf8");
}
function isPatched(code) {
return code.includes(PATCH_MARKER);
}
function isMapperPatched(code) {
return code.includes(MAPPER_PATCH_MARKER);
}
// Patch 1: Nv8 safety wrapper (try/catch around image reader)
function applyNv8Patch(code) {
if (code.includes(PATCH_MARKER)) {
console.log("[=] Nv8 safety patch already applied");
return code;
}
const ORIGINAL_NV8_SIGNATURE = "async function Nv8(A,q=Tv8(),K){let Y=await X1().readFileBytes(A,K)";
const idx = code.indexOf(ORIGINAL_NV8_SIGNATURE);
if (idx === -1) {
console.error("[-] Could not find Nv8 function signature in cli.js");
console.error(" Claude Code may have been updated.");
return code;
}
const endMarker = "}var Ns9";
const endIdx = code.indexOf(endMarker, idx);
if (endIdx === -1) {
console.error("[-] Could not find end of Nv8 function");
return code;
}
const patchedNv8 = `${PATCH_MARKER}async function Nv8(A,q=Tv8(),K){try{let Y=await X1().readFileBytes(A,K),z=Y.length;if(z===0)throw Error("Image file is empty: "+A);let w=kp6(Y),_=w.split("/")[1]||"png",$;try{let H=await ig(Y,z,_);$=q01(H.buffer,H.mediaType,z,H.dimensions)}catch(H){$6(H);$=q01(Y,_,z)}if(Math.ceil($.file.base64.length*0.125)>q)try{let H=await DP1(Y,q,w);return{type:"image",file:{base64:H.base64,type:H.mediaType||"image/png",originalSize:z}}}catch(H){$6(H);try{let j=await Promise.resolve().then(()=>q6(yN8(),1)),M=await(j.default||j)(Y).resize(400,400,{fit:"inside",withoutEnlargement:!0}).jpeg({quality:20}).toBuffer();return q01(M,"jpeg",z)}catch(j){return $6(j),q01(Y,_,z)}}return $}catch(_err){return{type:"text",file:{content:"[Error reading image: "+_err.message+"] File: "+A,totalLines:1}}}}`;
code = code.slice(0, idx) + patchedNv8 + code.slice(endIdx + 1);
console.log("[+] Nv8 safety patch applied");
return code;
}
// Patch 2: Image mapper — guarantee media_type is always a valid string
// This is the ROOT CAUSE fix: A.file.type can be undefined in some code paths,
// and JSON.stringify silently drops undefined fields, causing API 400 error.
function applyMapperPatch(code) {
if (code.includes(MAPPER_PATCH_MARKER)) {
console.log("[=] Image mapper patch already applied");
return code;
}
const ORIGINAL_MAPPER = 'case"image":return{tool_use_id:q,type:"tool_result",content:[{type:"image",source:{type:"base64",data:A.file.base64,media_type:A.file.type}}]}';
const idx = code.indexOf(ORIGINAL_MAPPER);
if (idx === -1) {
console.error("[-] Could not find image mapper in cli.js");
console.error(" Claude Code may have been updated.");
return code;
}
// Patched version: fallback media_type to "image/png" if undefined
const PATCHED_MAPPER = `${MAPPER_PATCH_MARKER}case"image":return{tool_use_id:q,type:"tool_result",content:[{type:"image",source:{type:"base64",data:A.file.base64,media_type:A.file.type||"image/png"}}]}`;
code = code.slice(0, idx) + PATCHED_MAPPER + code.slice(idx + ORIGINAL_MAPPER.length);
console.log("[+] Image mapper patched — media_type guaranteed non-empty");
return code;
}
function revertPatch(claudeDir) {
const backupPath = path.join(claudeDir, "cli.js.bak");
if (!fs.existsSync(backupPath)) {
console.error("[-] No backup found at cli.js.bak");
return false;
}
fs.copyFileSync(backupPath, path.join(claudeDir, "cli.js"));
console.log("[+] Reverted to original cli.js from backup");
return true;
}
// Main
function main() {
const args = process.argv.slice(2);
const checkOnly = args.includes("--check");
const revert = args.includes("--revert");
console.log("=== Claude Code Image Read Patcher v2 ===\n");
const claudeDir = findClaudeCodeDir();
if (!claudeDir) {
console.error("[-] Claude Code installation not found!");
console.error(" Install it with: npm install -g @anthropic-ai/claude-code");
process.exit(1);
}
console.log("[*] Found Claude Code at:", claudeDir);
// Read package version
try {
const pkg = JSON.parse(fs.readFileSync(path.join(claudeDir, "package.json"), "utf8"));
console.log("[*] Version:", pkg.version);
} catch {}
// Check sharp
const hasSharp = isSharpInstalled(claudeDir);
console.log("[*] sharp module:", hasSharp ? "installed" : "MISSING");
// Check patch status
const code = readCliJs(claudeDir);
const nv8Patched = isPatched(code);
const mapperPatched = isMapperPatched(code);
console.log("[*] Nv8 safety patch:", nv8Patched ? "applied" : "not applied");
console.log("[*] Image mapper patch:", mapperPatched ? "applied" : "not applied");
if (checkOnly) {
const fullyProtected = hasSharp && nv8Patched && mapperPatched;
const status = fullyProtected ? "FULLY PROTECTED" :
(mapperPatched ? "PROTECTED (mapper fix applied)" : "VULNERABLE");
console.log("\nStatus:", status);
process.exit(fullyProtected ? 0 : 1);
}
if (revert) {
revertPatch(claudeDir);
process.exit(0);
}
console.log("");
// Step 1: Install sharp
if (!hasSharp) {
if (!installSharp(claudeDir)) {
console.error("\n[-] Could not install sharp. Applying safety patches anyway...");
}
} else {
console.log("[=] sharp already installed, skipping");
}
// Step 2: Apply Nv8 safety patch
let patchedCode = applyNv8Patch(readCliJs(claudeDir));
// Step 3: Apply image mapper patch (ROOT CAUSE FIX)
patchedCode = applyMapperPatch(patchedCode);
writeCliJs(claudeDir, patchedCode);
console.log("\n=== Done! Claude Code is now protected against image read crashes ===");
console.log("Patches applied:");
console.log(" 1. Nv8 try/catch — prevents binary leak on image read failure");
console.log(" 2. Image mapper — guarantees media_type is always present (ROOT FIX)");
console.log("\nNote: After updating Claude Code (npm update -g @anthropic-ai/claude-code),");
console.log(" re-run this patcher to reapply the fixes.");
}
main();

View File

@@ -1511,16 +1511,19 @@ def _grafana_request(server: dict, endpoint: str) -> dict:
import requests
host = server["ip"]
port = server.get("port", 3000)
protocol = "https" if server.get("ssl", False) else "http"
protocol = "https" if server.get("use_ssl", server.get("ssl", False)) else "http"
base_url = server.get("base_url", f"{protocol}://{host}:{port}")
api_key = server.get("api_key", server.get("password", ""))
api_token = server.get("api_token", server.get("api_key", ""))
headers = {}
if api_key:
headers["Authorization"] = f"Bearer {api_key}"
auth = None
if api_token:
headers["Authorization"] = f"Bearer {api_token}"
elif server.get("user") and server.get("password"):
auth = (server["user"], server["password"])
url = f"{base_url.rstrip('/')}/api/{endpoint.lstrip('/')}"
resp = requests.get(url, headers=headers, timeout=15, verify=server.get("ssl_verify", True))
resp = requests.get(url, headers=headers, auth=auth, timeout=15, verify=server.get("ssl_verify", True))
resp.raise_for_status()
return resp.json()

View File

@@ -1,6 +1,6 @@
"""Version info for ServerManager."""
__version__ = "1.9.33"
__version__ = "1.9.40"
__app_name__ = "ServerManager"
__author__ = "aibot777"
__description__ = "Desktop GUI for managing remote servers"