imgx-cli 0.6.1 → 0.8.0
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/CHANGELOG.md +26 -1
- package/README.md +4 -2
- package/dist/cli.bundle.js +24 -12
- package/dist/mcp.bundle.js +48 -22
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,30 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.8.0 (2026-02-27)
|
|
4
|
+
|
|
5
|
+
### Fixed
|
|
6
|
+
|
|
7
|
+
- **MCP inline preview size guard** — images exceeding ~780KB base64 (Claude Desktop's 1MB tool result limit) are now gracefully skipped from inline preview. Full-quality images are always saved to disk. Previously, oversized images caused silent display failures in Claude Desktop.
|
|
8
|
+
|
|
9
|
+
## 0.7.1 (2026-02-27)
|
|
10
|
+
|
|
11
|
+
### Fixed
|
|
12
|
+
|
|
13
|
+
- Remove `MULTIPLE_OUTPUTS` capability from Gemini provider — `gemini-3-pro-image-preview` does not support `candidateCount`, causing errors when `count > 1`
|
|
14
|
+
|
|
15
|
+
## 0.7.0 (2026-02-27)
|
|
16
|
+
|
|
17
|
+
### Added
|
|
18
|
+
|
|
19
|
+
- **Output format selection** — `--format` flag (CLI) and `output_format` parameter (MCP) to choose between `png`, `jpeg`, or `webp` output. Currently supported by OpenAI provider (`gpt-image-1`). Gemini provider outputs PNG regardless of format setting.
|
|
20
|
+
- `OUTPUT_FORMAT` capability added to provider capability system
|
|
21
|
+
|
|
22
|
+
## 0.6.2 (2026-02-27)
|
|
23
|
+
|
|
24
|
+
### Added
|
|
25
|
+
|
|
26
|
+
- **Image preview in MCP responses** — MCP tool results now include inline image data (base64) alongside file paths. Claude Desktop and other MCP clients can display generated/edited images directly without opening files manually.
|
|
27
|
+
|
|
3
28
|
## 0.6.1 (2026-02-27)
|
|
4
29
|
|
|
5
30
|
### Fixed
|
|
@@ -111,7 +136,7 @@ Initial release.
|
|
|
111
136
|
- `edit` command: image editing with text instructions
|
|
112
137
|
- `providers` command: list available providers
|
|
113
138
|
- `capabilities` command: show provider capabilities
|
|
114
|
-
- Gemini provider with
|
|
139
|
+
- Gemini provider with 6 capabilities (generate, edit, aspect ratio, resolution, reference images, person control)
|
|
115
140
|
- Capability-based provider abstraction (model-independent core + model-dependent providers)
|
|
116
141
|
- JSON output for scripting and tool integration
|
|
117
142
|
- Single-file esbuild bundle
|
package/README.md
CHANGED
|
@@ -108,6 +108,7 @@ imgx edit --last -p "Crop to 16:9" -o final.png
|
|
|
108
108
|
| `--aspect-ratio` | `-a` | `1:1`, `16:9`, `9:16`, `4:3`, `3:4`, `2:3`, `3:2` |
|
|
109
109
|
| `--resolution` | `-r` | `1K`, `2K`, `4K` |
|
|
110
110
|
| `--count` | `-n` | Number of images to generate |
|
|
111
|
+
| `--format` | `-f` | Output format: `png`, `jpeg`, `webp` (OpenAI only) |
|
|
111
112
|
| `--model` | `-m` | Model name |
|
|
112
113
|
| `--provider` | | Provider name (default: `gemini`) |
|
|
113
114
|
| `--output-dir` | `-d` | Output directory |
|
|
@@ -315,13 +316,14 @@ Each provider declares its supported capabilities. The CLI dynamically enables o
|
|
|
315
316
|
| `MULTIPLE_OUTPUTS` | Generate multiple images per request |
|
|
316
317
|
| `REFERENCE_IMAGES` | Use reference images for guidance |
|
|
317
318
|
| `PERSON_CONTROL` | Control person generation in output |
|
|
319
|
+
| `OUTPUT_FORMAT` | Choose output format (PNG, JPEG, WebP) |
|
|
318
320
|
|
|
319
321
|
### Current providers
|
|
320
322
|
|
|
321
323
|
| Provider | Models | Capabilities |
|
|
322
324
|
|----------|--------|-------------|
|
|
323
|
-
| Gemini | `gemini-3-pro-image-preview`, `gemini-2.5-flash-image` | All 7 capabilities |
|
|
324
|
-
| OpenAI | `gpt-image-1` | Generate, edit, aspect ratio, multi-output |
|
|
325
|
+
| Gemini | `gemini-3-pro-image-preview`, `gemini-2.5-flash-image` | All 7 base capabilities |
|
|
326
|
+
| OpenAI | `gpt-image-1` | Generate, edit, aspect ratio, multi-output, output format |
|
|
325
327
|
|
|
326
328
|
## Development
|
|
327
329
|
|
package/dist/cli.bundle.js
CHANGED
|
@@ -39235,7 +39235,9 @@ function fallbackOutputDir(outputDir) {
|
|
|
39235
39235
|
}
|
|
39236
39236
|
function saveImage(image, outputPath, outputDir) {
|
|
39237
39237
|
const ext = MIME_TO_EXT[image.mimeType] || ".png";
|
|
39238
|
-
const
|
|
39238
|
+
const resolvedDir = fallbackOutputDir(outputDir);
|
|
39239
|
+
const filePath = outputPath ? resolve2(outputPath) : resolve2(resolvedDir, `imgx-${randomUUID().slice(0, 8)}${ext}`);
|
|
39240
|
+
console.error(`[imgx-debug] homedir=${homedir2()} cwd=${process.cwd()} outputPath=${outputPath} outputDir=${outputDir} resolvedDir=${resolvedDir} filePath=${filePath}`);
|
|
39239
39241
|
mkdirSync2(dirname(filePath), { recursive: true });
|
|
39240
39242
|
writeFileSync2(filePath, image.data);
|
|
39241
39243
|
return filePath;
|
|
@@ -39252,6 +39254,7 @@ var Capability;
|
|
|
39252
39254
|
Capability2["REFERENCE_IMAGES"] = "REFERENCE_IMAGES";
|
|
39253
39255
|
Capability2["PERSON_CONTROL"] = "PERSON_CONTROL";
|
|
39254
39256
|
Capability2["STYLE_CONTROL"] = "STYLE_CONTROL";
|
|
39257
|
+
Capability2["OUTPUT_FORMAT"] = "OUTPUT_FORMAT";
|
|
39255
39258
|
})(Capability || (Capability = {}));
|
|
39256
39259
|
|
|
39257
39260
|
// build/providers/gemini/capabilities.js
|
|
@@ -39264,7 +39267,6 @@ var GEMINI_PROVIDER_INFO = {
|
|
|
39264
39267
|
Capability.ASPECT_RATIO,
|
|
39265
39268
|
Capability.IMAGE_EDITING,
|
|
39266
39269
|
Capability.RESOLUTION_CONTROL,
|
|
39267
|
-
Capability.MULTIPLE_OUTPUTS,
|
|
39268
39270
|
Capability.REFERENCE_IMAGES,
|
|
39269
39271
|
Capability.PERSON_CONTROL
|
|
39270
39272
|
]),
|
|
@@ -39384,7 +39386,8 @@ var OPENAI_PROVIDER_INFO = {
|
|
|
39384
39386
|
Capability.TEXT_TO_IMAGE,
|
|
39385
39387
|
Capability.ASPECT_RATIO,
|
|
39386
39388
|
Capability.IMAGE_EDITING,
|
|
39387
|
-
Capability.MULTIPLE_OUTPUTS
|
|
39389
|
+
Capability.MULTIPLE_OUTPUTS,
|
|
39390
|
+
Capability.OUTPUT_FORMAT
|
|
39388
39391
|
]),
|
|
39389
39392
|
aspectRatios: ["1:1", "3:2", "2:3", "16:9", "9:16", "4:3", "3:4"],
|
|
39390
39393
|
resolutions: ["1K", "2K", "4K"]
|
|
@@ -39465,7 +39468,8 @@ var OpenAIProvider = class {
|
|
|
39465
39468
|
prompt: input.prompt,
|
|
39466
39469
|
n: input.count || 1,
|
|
39467
39470
|
size: mapSize(input.aspectRatio),
|
|
39468
|
-
quality: mapQuality(input.resolution)
|
|
39471
|
+
quality: mapQuality(input.resolution),
|
|
39472
|
+
...input.outputFormat ? { output_format: input.outputFormat } : {}
|
|
39469
39473
|
})
|
|
39470
39474
|
});
|
|
39471
39475
|
const json = await response.json();
|
|
@@ -39476,7 +39480,7 @@ var OpenAIProvider = class {
|
|
|
39476
39480
|
error: json.error?.message || `HTTP ${response.status}`
|
|
39477
39481
|
};
|
|
39478
39482
|
}
|
|
39479
|
-
return this.parseResponse(json);
|
|
39483
|
+
return this.parseResponse(json, input.outputFormat);
|
|
39480
39484
|
} catch (err) {
|
|
39481
39485
|
const msg = err instanceof Error ? err.message : String(err);
|
|
39482
39486
|
return { success: false, images: [], error: msg };
|
|
@@ -39493,7 +39497,8 @@ var OpenAIProvider = class {
|
|
|
39493
39497
|
prompt: input.prompt,
|
|
39494
39498
|
n: String(input.count || 1),
|
|
39495
39499
|
size: mapSize(input.aspectRatio),
|
|
39496
|
-
quality: mapQuality(input.resolution)
|
|
39500
|
+
quality: mapQuality(input.resolution),
|
|
39501
|
+
...input.outputFormat ? { output_format: input.outputFormat } : {}
|
|
39497
39502
|
};
|
|
39498
39503
|
const { body, contentType: ct } = buildMultipart(fields, [
|
|
39499
39504
|
{
|
|
@@ -39520,20 +39525,22 @@ var OpenAIProvider = class {
|
|
|
39520
39525
|
error: json.error?.message || `HTTP ${response.status}`
|
|
39521
39526
|
};
|
|
39522
39527
|
}
|
|
39523
|
-
return this.parseResponse(json);
|
|
39528
|
+
return this.parseResponse(json, input.outputFormat);
|
|
39524
39529
|
} catch (err) {
|
|
39525
39530
|
const msg = err instanceof Error ? err.message : String(err);
|
|
39526
39531
|
return { success: false, images: [], error: msg };
|
|
39527
39532
|
}
|
|
39528
39533
|
}
|
|
39529
|
-
parseResponse(json) {
|
|
39534
|
+
parseResponse(json, outputFormat) {
|
|
39535
|
+
const mimeMap = { png: "image/png", jpeg: "image/jpeg", webp: "image/webp" };
|
|
39536
|
+
const mimeType = mimeMap[outputFormat || "png"] || "image/png";
|
|
39530
39537
|
const images = [];
|
|
39531
39538
|
if (json.data) {
|
|
39532
39539
|
for (const item of json.data) {
|
|
39533
39540
|
if (item.b64_json) {
|
|
39534
39541
|
images.push({
|
|
39535
39542
|
data: Buffer.from(item.b64_json, "base64"),
|
|
39536
|
-
mimeType
|
|
39543
|
+
mimeType
|
|
39537
39544
|
});
|
|
39538
39545
|
}
|
|
39539
39546
|
}
|
|
@@ -39590,7 +39597,8 @@ async function runGenerate(provider, args) {
|
|
|
39590
39597
|
prompt: args.prompt,
|
|
39591
39598
|
aspectRatio: args.aspectRatio,
|
|
39592
39599
|
count: args.count,
|
|
39593
|
-
resolution: args.resolution
|
|
39600
|
+
resolution: args.resolution,
|
|
39601
|
+
outputFormat: args.outputFormat
|
|
39594
39602
|
}, args.model);
|
|
39595
39603
|
if (!result.success || result.images.length === 0) {
|
|
39596
39604
|
fail(result.error || "Generation failed");
|
|
@@ -39618,7 +39626,8 @@ async function runEdit(provider, args) {
|
|
|
39618
39626
|
inputImage: args.inputImage,
|
|
39619
39627
|
prompt: args.prompt,
|
|
39620
39628
|
aspectRatio: args.aspectRatio,
|
|
39621
|
-
resolution: args.resolution
|
|
39629
|
+
resolution: args.resolution,
|
|
39630
|
+
outputFormat: args.outputFormat
|
|
39622
39631
|
}, args.model);
|
|
39623
39632
|
if (!result.success || result.images.length === 0) {
|
|
39624
39633
|
fail(result.error || "Edit failed");
|
|
@@ -39769,7 +39778,7 @@ function showAll() {
|
|
|
39769
39778
|
}
|
|
39770
39779
|
|
|
39771
39780
|
// build/cli/index.js
|
|
39772
|
-
var VERSION2 = "0.
|
|
39781
|
+
var VERSION2 = "0.8.0";
|
|
39773
39782
|
var HELP = `imgx v${VERSION2} \u2014 AI image generation and editing CLI
|
|
39774
39783
|
|
|
39775
39784
|
Commands:
|
|
@@ -39794,6 +39803,7 @@ Options:
|
|
|
39794
39803
|
-a, --aspect-ratio <ratio> Aspect ratio (e.g., 16:9, 1:1)
|
|
39795
39804
|
-n, --count <number> Number of images to generate
|
|
39796
39805
|
-r, --resolution <size> Resolution: 1K, 2K, 4K
|
|
39806
|
+
-f, --format <type> Output format: png, jpeg, webp (OpenAI only)
|
|
39797
39807
|
-m, --model <model> Model name
|
|
39798
39808
|
--provider <name> Provider: gemini, openai (default: gemini)
|
|
39799
39809
|
-d, --output-dir <dir> Output directory
|
|
@@ -39861,6 +39871,7 @@ function main() {
|
|
|
39861
39871
|
"aspect-ratio": { type: "string", short: "a" },
|
|
39862
39872
|
count: { type: "string", short: "n" },
|
|
39863
39873
|
resolution: { type: "string", short: "r" },
|
|
39874
|
+
format: { type: "string", short: "f" },
|
|
39864
39875
|
model: { type: "string", short: "m" },
|
|
39865
39876
|
provider: { type: "string" },
|
|
39866
39877
|
"output-dir": { type: "string", short: "d" },
|
|
@@ -39895,6 +39906,7 @@ function main() {
|
|
|
39895
39906
|
outputDir: values["output-dir"] || resolveDefault("outputDir") || void 0,
|
|
39896
39907
|
aspectRatio: values["aspect-ratio"] || resolveDefault("aspectRatio") || void 0,
|
|
39897
39908
|
resolution: values.resolution || resolveDefault("resolution") || void 0,
|
|
39909
|
+
outputFormat: values.format || void 0,
|
|
39898
39910
|
model,
|
|
39899
39911
|
count: values.count ? parseInt(values.count, 10) : void 0
|
|
39900
39912
|
};
|
package/dist/mcp.bundle.js
CHANGED
|
@@ -69273,7 +69273,9 @@ function fallbackOutputDir(outputDir) {
|
|
|
69273
69273
|
}
|
|
69274
69274
|
function saveImage(image, outputPath, outputDir) {
|
|
69275
69275
|
const ext = MIME_TO_EXT[image.mimeType] || ".png";
|
|
69276
|
-
const
|
|
69276
|
+
const resolvedDir = fallbackOutputDir(outputDir);
|
|
69277
|
+
const filePath = outputPath ? resolve2(outputPath) : resolve2(resolvedDir, `imgx-${randomUUID().slice(0, 8)}${ext}`);
|
|
69278
|
+
console.error(`[imgx-debug] homedir=${homedir2()} cwd=${process.cwd()} outputPath=${outputPath} outputDir=${outputDir} resolvedDir=${resolvedDir} filePath=${filePath}`);
|
|
69277
69279
|
mkdirSync2(dirname(filePath), { recursive: true });
|
|
69278
69280
|
writeFileSync2(filePath, image.data);
|
|
69279
69281
|
return filePath;
|
|
@@ -69290,6 +69292,7 @@ var Capability;
|
|
|
69290
69292
|
Capability2["REFERENCE_IMAGES"] = "REFERENCE_IMAGES";
|
|
69291
69293
|
Capability2["PERSON_CONTROL"] = "PERSON_CONTROL";
|
|
69292
69294
|
Capability2["STYLE_CONTROL"] = "STYLE_CONTROL";
|
|
69295
|
+
Capability2["OUTPUT_FORMAT"] = "OUTPUT_FORMAT";
|
|
69293
69296
|
})(Capability || (Capability = {}));
|
|
69294
69297
|
|
|
69295
69298
|
// build/providers/gemini/capabilities.js
|
|
@@ -69302,7 +69305,6 @@ var GEMINI_PROVIDER_INFO = {
|
|
|
69302
69305
|
Capability.ASPECT_RATIO,
|
|
69303
69306
|
Capability.IMAGE_EDITING,
|
|
69304
69307
|
Capability.RESOLUTION_CONTROL,
|
|
69305
|
-
Capability.MULTIPLE_OUTPUTS,
|
|
69306
69308
|
Capability.REFERENCE_IMAGES,
|
|
69307
69309
|
Capability.PERSON_CONTROL
|
|
69308
69310
|
]),
|
|
@@ -69422,7 +69424,8 @@ var OPENAI_PROVIDER_INFO = {
|
|
|
69422
69424
|
Capability.TEXT_TO_IMAGE,
|
|
69423
69425
|
Capability.ASPECT_RATIO,
|
|
69424
69426
|
Capability.IMAGE_EDITING,
|
|
69425
|
-
Capability.MULTIPLE_OUTPUTS
|
|
69427
|
+
Capability.MULTIPLE_OUTPUTS,
|
|
69428
|
+
Capability.OUTPUT_FORMAT
|
|
69426
69429
|
]),
|
|
69427
69430
|
aspectRatios: ["1:1", "3:2", "2:3", "16:9", "9:16", "4:3", "3:4"],
|
|
69428
69431
|
resolutions: ["1K", "2K", "4K"]
|
|
@@ -69503,7 +69506,8 @@ var OpenAIProvider = class {
|
|
|
69503
69506
|
prompt: input.prompt,
|
|
69504
69507
|
n: input.count || 1,
|
|
69505
69508
|
size: mapSize(input.aspectRatio),
|
|
69506
|
-
quality: mapQuality(input.resolution)
|
|
69509
|
+
quality: mapQuality(input.resolution),
|
|
69510
|
+
...input.outputFormat ? { output_format: input.outputFormat } : {}
|
|
69507
69511
|
})
|
|
69508
69512
|
});
|
|
69509
69513
|
const json2 = await response.json();
|
|
@@ -69514,7 +69518,7 @@ var OpenAIProvider = class {
|
|
|
69514
69518
|
error: json2.error?.message || `HTTP ${response.status}`
|
|
69515
69519
|
};
|
|
69516
69520
|
}
|
|
69517
|
-
return this.parseResponse(json2);
|
|
69521
|
+
return this.parseResponse(json2, input.outputFormat);
|
|
69518
69522
|
} catch (err) {
|
|
69519
69523
|
const msg = err instanceof Error ? err.message : String(err);
|
|
69520
69524
|
return { success: false, images: [], error: msg };
|
|
@@ -69531,7 +69535,8 @@ var OpenAIProvider = class {
|
|
|
69531
69535
|
prompt: input.prompt,
|
|
69532
69536
|
n: String(input.count || 1),
|
|
69533
69537
|
size: mapSize(input.aspectRatio),
|
|
69534
|
-
quality: mapQuality(input.resolution)
|
|
69538
|
+
quality: mapQuality(input.resolution),
|
|
69539
|
+
...input.outputFormat ? { output_format: input.outputFormat } : {}
|
|
69535
69540
|
};
|
|
69536
69541
|
const { body, contentType: ct } = buildMultipart(fields, [
|
|
69537
69542
|
{
|
|
@@ -69558,20 +69563,22 @@ var OpenAIProvider = class {
|
|
|
69558
69563
|
error: json2.error?.message || `HTTP ${response.status}`
|
|
69559
69564
|
};
|
|
69560
69565
|
}
|
|
69561
|
-
return this.parseResponse(json2);
|
|
69566
|
+
return this.parseResponse(json2, input.outputFormat);
|
|
69562
69567
|
} catch (err) {
|
|
69563
69568
|
const msg = err instanceof Error ? err.message : String(err);
|
|
69564
69569
|
return { success: false, images: [], error: msg };
|
|
69565
69570
|
}
|
|
69566
69571
|
}
|
|
69567
|
-
parseResponse(json2) {
|
|
69572
|
+
parseResponse(json2, outputFormat) {
|
|
69573
|
+
const mimeMap = { png: "image/png", jpeg: "image/jpeg", webp: "image/webp" };
|
|
69574
|
+
const mimeType = mimeMap[outputFormat || "png"] || "image/png";
|
|
69568
69575
|
const images = [];
|
|
69569
69576
|
if (json2.data) {
|
|
69570
69577
|
for (const item of json2.data) {
|
|
69571
69578
|
if (item.b64_json) {
|
|
69572
69579
|
images.push({
|
|
69573
69580
|
data: Buffer.from(item.b64_json, "base64"),
|
|
69574
|
-
mimeType
|
|
69581
|
+
mimeType
|
|
69575
69582
|
});
|
|
69576
69583
|
}
|
|
69577
69584
|
}
|
|
@@ -69592,9 +69599,28 @@ function initOpenAI() {
|
|
|
69592
69599
|
}
|
|
69593
69600
|
|
|
69594
69601
|
// build/mcp/server.js
|
|
69602
|
+
var MAX_INLINE_BASE64 = 8e5;
|
|
69603
|
+
function buildImageContent(images, paths, extra) {
|
|
69604
|
+
const content = [];
|
|
69605
|
+
let skipped = 0;
|
|
69606
|
+
for (const img of images) {
|
|
69607
|
+
const b64 = img.data.toString("base64");
|
|
69608
|
+
if (b64.length <= MAX_INLINE_BASE64) {
|
|
69609
|
+
content.push({ type: "image", data: b64, mimeType: img.mimeType });
|
|
69610
|
+
} else {
|
|
69611
|
+
skipped++;
|
|
69612
|
+
}
|
|
69613
|
+
}
|
|
69614
|
+
const info = { success: true, filePaths: paths, ...extra };
|
|
69615
|
+
if (skipped > 0) {
|
|
69616
|
+
info.note = `${skipped} image(s) too large for inline preview. Open file(s) directly.`;
|
|
69617
|
+
}
|
|
69618
|
+
content.push({ type: "text", text: JSON.stringify(info) });
|
|
69619
|
+
return content;
|
|
69620
|
+
}
|
|
69595
69621
|
var server = new McpServer({
|
|
69596
69622
|
name: "imgx",
|
|
69597
|
-
version: "0.
|
|
69623
|
+
version: "0.8.0"
|
|
69598
69624
|
});
|
|
69599
69625
|
initGemini();
|
|
69600
69626
|
initOpenAI();
|
|
@@ -69614,6 +69640,7 @@ server.tool("generate_image", "Generate an image from a text prompt", {
|
|
|
69614
69640
|
aspect_ratio: external_exports3.enum(["1:1", "2:3", "3:2", "3:4", "4:3", "9:16", "16:9"]).optional().describe("Aspect ratio"),
|
|
69615
69641
|
resolution: external_exports3.enum(["1K", "2K", "4K"]).optional().describe("Output resolution"),
|
|
69616
69642
|
count: external_exports3.number().int().min(1).max(4).optional().describe("Number of images"),
|
|
69643
|
+
output_format: external_exports3.enum(["png", "jpeg", "webp"]).optional().describe("Output format"),
|
|
69617
69644
|
model: external_exports3.string().optional().describe("Model name"),
|
|
69618
69645
|
provider: external_exports3.string().optional().describe("Provider name")
|
|
69619
69646
|
}, async (args) => {
|
|
@@ -69623,7 +69650,8 @@ server.tool("generate_image", "Generate an image from a text prompt", {
|
|
|
69623
69650
|
prompt: args.prompt,
|
|
69624
69651
|
aspectRatio: args.aspect_ratio,
|
|
69625
69652
|
resolution: args.resolution,
|
|
69626
|
-
count: args.count
|
|
69653
|
+
count: args.count,
|
|
69654
|
+
outputFormat: args.output_format
|
|
69627
69655
|
};
|
|
69628
69656
|
const result = await prov.generate(input, args.model);
|
|
69629
69657
|
if (!result.success || result.images.length === 0) {
|
|
@@ -69636,9 +69664,7 @@ server.tool("generate_image", "Generate an image from a text prompt", {
|
|
|
69636
69664
|
paths.push(saved);
|
|
69637
69665
|
}
|
|
69638
69666
|
saveLastOutput(paths);
|
|
69639
|
-
return {
|
|
69640
|
-
content: [{ type: "text", text: JSON.stringify({ success: true, filePaths: paths }) }]
|
|
69641
|
-
};
|
|
69667
|
+
return { content: buildImageContent(result.images, paths) };
|
|
69642
69668
|
} catch (err) {
|
|
69643
69669
|
const msg = err instanceof Error ? err.message : String(err);
|
|
69644
69670
|
return { content: [{ type: "text", text: `Error: ${msg}` }] };
|
|
@@ -69651,6 +69677,7 @@ server.tool("edit_image", "Edit an existing image with text instructions", {
|
|
|
69651
69677
|
output_dir: external_exports3.string().optional().describe("Output directory"),
|
|
69652
69678
|
aspect_ratio: external_exports3.enum(["1:1", "2:3", "3:2", "3:4", "4:3", "9:16", "16:9"]).optional().describe("Aspect ratio"),
|
|
69653
69679
|
resolution: external_exports3.enum(["1K", "2K", "4K"]).optional().describe("Output resolution"),
|
|
69680
|
+
output_format: external_exports3.enum(["png", "jpeg", "webp"]).optional().describe("Output format"),
|
|
69654
69681
|
model: external_exports3.string().optional().describe("Model name"),
|
|
69655
69682
|
provider: external_exports3.string().optional().describe("Provider name")
|
|
69656
69683
|
}, async (args) => {
|
|
@@ -69665,7 +69692,8 @@ server.tool("edit_image", "Edit an existing image with text instructions", {
|
|
|
69665
69692
|
prompt: args.prompt,
|
|
69666
69693
|
inputImage: args.input,
|
|
69667
69694
|
aspectRatio: args.aspect_ratio,
|
|
69668
|
-
resolution: args.resolution
|
|
69695
|
+
resolution: args.resolution,
|
|
69696
|
+
outputFormat: args.output_format
|
|
69669
69697
|
};
|
|
69670
69698
|
const result = await prov.edit(input, args.model);
|
|
69671
69699
|
if (!result.success || result.images.length === 0) {
|
|
@@ -69673,9 +69701,7 @@ server.tool("edit_image", "Edit an existing image with text instructions", {
|
|
|
69673
69701
|
}
|
|
69674
69702
|
const saved = saveImage(result.images[0], args.output, args.output_dir);
|
|
69675
69703
|
saveLastOutput([saved]);
|
|
69676
|
-
return {
|
|
69677
|
-
content: [{ type: "text", text: JSON.stringify({ success: true, filePaths: [saved] }) }]
|
|
69678
|
-
};
|
|
69704
|
+
return { content: buildImageContent(result.images, [saved]) };
|
|
69679
69705
|
} catch (err) {
|
|
69680
69706
|
const msg = err instanceof Error ? err.message : String(err);
|
|
69681
69707
|
return { content: [{ type: "text", text: `Error: ${msg}` }] };
|
|
@@ -69687,6 +69713,7 @@ server.tool("edit_last", "Edit the last generated/edited image with new text ins
|
|
|
69687
69713
|
output_dir: external_exports3.string().optional().describe("Output directory"),
|
|
69688
69714
|
aspect_ratio: external_exports3.enum(["1:1", "2:3", "3:2", "3:4", "4:3", "9:16", "16:9"]).optional().describe("Aspect ratio"),
|
|
69689
69715
|
resolution: external_exports3.enum(["1K", "2K", "4K"]).optional().describe("Output resolution"),
|
|
69716
|
+
output_format: external_exports3.enum(["png", "jpeg", "webp"]).optional().describe("Output format"),
|
|
69690
69717
|
model: external_exports3.string().optional().describe("Model name"),
|
|
69691
69718
|
provider: external_exports3.string().optional().describe("Provider name")
|
|
69692
69719
|
}, async (args) => {
|
|
@@ -69707,7 +69734,8 @@ server.tool("edit_last", "Edit the last generated/edited image with new text ins
|
|
|
69707
69734
|
prompt: args.prompt,
|
|
69708
69735
|
inputImage: lastPaths[0],
|
|
69709
69736
|
aspectRatio: args.aspect_ratio,
|
|
69710
|
-
resolution: args.resolution
|
|
69737
|
+
resolution: args.resolution,
|
|
69738
|
+
outputFormat: args.output_format
|
|
69711
69739
|
};
|
|
69712
69740
|
const result = await prov.edit(input, args.model);
|
|
69713
69741
|
if (!result.success || result.images.length === 0) {
|
|
@@ -69715,9 +69743,7 @@ server.tool("edit_last", "Edit the last generated/edited image with new text ins
|
|
|
69715
69743
|
}
|
|
69716
69744
|
const saved = saveImage(result.images[0], args.output, args.output_dir);
|
|
69717
69745
|
saveLastOutput([saved]);
|
|
69718
|
-
return {
|
|
69719
|
-
content: [{ type: "text", text: JSON.stringify({ success: true, filePaths: [saved], inputUsed: lastPaths[0] }) }]
|
|
69720
|
-
};
|
|
69746
|
+
return { content: buildImageContent(result.images, [saved], { inputUsed: lastPaths[0] }) };
|
|
69721
69747
|
} catch (err) {
|
|
69722
69748
|
const msg = err instanceof Error ? err.message : String(err);
|
|
69723
69749
|
return { content: [{ type: "text", text: `Error: ${msg}` }] };
|