mirror of
https://github.com/claude-code-best/claude-code.git
synced 2026-06-17 13:55:50 +00:00
fix: 修复截图 MIME 类型硬编码导致 API 拒绝的问题
macOS screencapture 输出 PNG,但代码硬编码 mimeType 为 image/jpeg, 导致 API 报错 "specified using image/jpeg but appears to be image/png"。 改为通过 magic bytes 检测实际图片格式。 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -30,6 +30,7 @@ import { getSessionId } from '../../bootstrap/state.js'
|
||||
import { ComputerUseApproval } from '../../components/permissions/ComputerUseApproval/ComputerUseApproval.js'
|
||||
import type { Tool, ToolUseContext } from '../../Tool.js'
|
||||
import { logForDebugging } from '../debug.js'
|
||||
import { detectImageFormatFromBase64 } from '../imageResizer.js'
|
||||
import {
|
||||
checkComputerUseLock,
|
||||
tryAcquireComputerUseLock,
|
||||
@@ -330,7 +331,7 @@ export function getComputerUseMCPToolOverrides(
|
||||
type: 'image' as const,
|
||||
source: {
|
||||
type: 'base64' as const,
|
||||
media_type: item.mimeType ?? 'image/jpeg',
|
||||
media_type: item.mimeType ?? detectImageFormatFromBase64(item.data),
|
||||
data: item.data,
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user