@goonnguyen/human-mcp 2.8.0 → 2.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +24 -5
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -167922,29 +167922,48 @@ async function editImage(geminiClient, options, config) {
|
|
|
167922
167922
|
const editingPrompt = buildEditingPrompt(options);
|
|
167923
167923
|
logger2.info(`Image editing operation: ${options.operation}`);
|
|
167924
167924
|
logger2.info(`Editing prompt: "${editingPrompt}"`);
|
|
167925
|
-
const model = geminiClient.
|
|
167925
|
+
const model = geminiClient.getImageGenerationModel();
|
|
167926
167926
|
const requestContent = await buildRequestContent(options, processedInputImage, editingPrompt);
|
|
167927
167927
|
const response = await model.generateContent(requestContent);
|
|
167928
167928
|
const result = response.response;
|
|
167929
167929
|
const candidates = result.candidates;
|
|
167930
|
+
logger2.debug(`Gemini API response structure: ${JSON.stringify({
|
|
167931
|
+
hasCandidates: !!candidates,
|
|
167932
|
+
candidatesLength: candidates?.length,
|
|
167933
|
+
firstCandidate: candidates?.[0] ? {
|
|
167934
|
+
hasContent: !!candidates[0].content,
|
|
167935
|
+
hasParts: !!candidates[0].content?.parts,
|
|
167936
|
+
partsLength: candidates[0].content?.parts?.length
|
|
167937
|
+
} : null
|
|
167938
|
+
})}`);
|
|
167930
167939
|
if (!candidates || candidates.length === 0) {
|
|
167931
|
-
|
|
167940
|
+
logger2.error("No candidates in Gemini response. Full response:", JSON.stringify(result, null, 2));
|
|
167941
|
+
throw new Error("No image candidates returned from Gemini API. This may indicate the API doesn't support image editing yet, or the request format is incorrect.");
|
|
167932
167942
|
}
|
|
167933
167943
|
const candidate = candidates[0];
|
|
167934
|
-
if (!candidate || !candidate.content
|
|
167935
|
-
|
|
167944
|
+
if (!candidate || !candidate.content) {
|
|
167945
|
+
logger2.error("Invalid candidate structure:", JSON.stringify(candidate, null, 2));
|
|
167946
|
+
throw new Error("Invalid response format from Gemini API: missing candidate content");
|
|
167947
|
+
}
|
|
167948
|
+
if (!candidate.content.parts || candidate.content.parts.length === 0) {
|
|
167949
|
+
logger2.error("No parts in candidate content:", JSON.stringify(candidate.content, null, 2));
|
|
167950
|
+
throw new Error("Invalid response format from Gemini API: missing content parts. Note: Gemini image editing may not be available in the current API version.");
|
|
167936
167951
|
}
|
|
167937
167952
|
let imageData = null;
|
|
167938
167953
|
let mimeType = "image/jpeg";
|
|
167954
|
+
logger2.debug(`Searching for image data in ${candidate.content.parts.length} parts`);
|
|
167939
167955
|
for (const part of candidate.content.parts) {
|
|
167956
|
+
logger2.debug(`Part type: ${JSON.stringify(Object.keys(part))}`);
|
|
167940
167957
|
if ("inlineData" in part && part.inlineData) {
|
|
167941
167958
|
imageData = part.inlineData.data;
|
|
167942
167959
|
mimeType = part.inlineData.mimeType || "image/jpeg";
|
|
167960
|
+
logger2.info(`Found image data: ${imageData.length} bytes, type: ${mimeType}`);
|
|
167943
167961
|
break;
|
|
167944
167962
|
}
|
|
167945
167963
|
}
|
|
167946
167964
|
if (!imageData) {
|
|
167947
|
-
|
|
167965
|
+
logger2.error("No image data found in response parts:", JSON.stringify(candidate.content.parts, null, 2));
|
|
167966
|
+
throw new Error("No image data found in Gemini response. The API may have returned text instead of an edited image.");
|
|
167948
167967
|
}
|
|
167949
167968
|
const processingTime = Date.now() - startTime;
|
|
167950
167969
|
let resultData;
|