feat: generate images through chatgpt.com with Playwright behind an MCP server

Port of ZenvairoProspect's imagegen (legacy/whatsapp-mockup) to the
ZenvairoMediaGenerator-MCP submit+poll contract: persistent logged-in
Chromium profile, selector fallback lists, serial queue with pacing and a
circuit breaker for usage limits and lost sessions, signed public URLs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
dasemuandClaude Opus 5.5 committed 2026-10-07 17:09:51 +02:00
1 parent 15c2a90f08
commit b46db0cf6a
17 files changed
+1717

No files matched your search

+20
View File
@@ -0,0 +1,20 @@
export const ASPECT_RATIOS = ["auto", "1:1", "2:3", "3:2", "3:4", "4:3", "4:5", "5:4", "9:16", "16:9", "21:9"] as const;
const ORIENTATION: Record<string, string> = {
"1:1": "square", "2:3": "portrait", "3:4": "portrait", "4:5": "portrait", "9:16": "vertical",
"3:2": "landscape", "4:3": "landscape", "5:4": "landscape", "16:9": "widescreen landscape", "21:9": "ultra-wide landscape",
};
/** Wraps the caller's prompt so ChatGPT generates directly instead of chatting about it. */
export function buildImageRequest(prompt: string, aspectRatio: string, referenceCount: number): string {
const instructions = [
"Generate an image with the prompt below. Do not comment on it, do not rewrite it and do not ask me any questions: create exactly one image right away, at the highest quality available.",
];
if (aspectRatio !== "auto") instructions.push(`The image must use a ${aspectRatio} aspect ratio (${ORIENTATION[aspectRatio] ?? "custom"} format).`);
if (referenceCount > 0) {
instructions.push(referenceCount === 1
? "Use the attached image as the reference described in the prompt."
: `Use the ${referenceCount} attached images as the references described in the prompt.`);
}
return `${instructions.join(" ")}\n\n${prompt.trim()}`;
}