@genart-dev/mcp-server 0.4.6 → 0.4.8
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.cjs +26 -26
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +26 -26
- package/dist/index.js.map +1 -1
- package/dist/lib.cjs +26 -26
- package/dist/lib.cjs.map +1 -1
- package/dist/lib.js +26 -26
- package/dist/lib.js.map +1 -1
- package/package.json +1 -1
package/dist/lib.cjs
CHANGED
|
@@ -2444,6 +2444,7 @@ function isDirectComponent(name, components) {
|
|
|
2444
2444
|
}
|
|
2445
2445
|
|
|
2446
2446
|
// src/tools/capture.ts
|
|
2447
|
+
var import_child_process = require("child_process");
|
|
2447
2448
|
var import_promises6 = require("fs/promises");
|
|
2448
2449
|
var import_path8 = require("path");
|
|
2449
2450
|
var import_core8 = require("@genart-dev/core");
|
|
@@ -2527,6 +2528,12 @@ async function captureHtmlMulti(options) {
|
|
|
2527
2528
|
|
|
2528
2529
|
// src/tools/capture.ts
|
|
2529
2530
|
var registry2 = (0, import_core8.createDefaultRegistry)();
|
|
2531
|
+
function openPreview(filePath) {
|
|
2532
|
+
const cmd = process.platform === "darwin" ? "open" : process.platform === "win32" ? "start" : "xdg-open";
|
|
2533
|
+
(0, import_child_process.exec)(`${cmd} "${filePath}"`, (err) => {
|
|
2534
|
+
if (err) console.error(`[openPreview] failed: ${err.message}`);
|
|
2535
|
+
});
|
|
2536
|
+
}
|
|
2530
2537
|
function applyOverrides(sketch, overrides) {
|
|
2531
2538
|
if (overrides.seed === void 0 && overrides.params === void 0) {
|
|
2532
2539
|
return sketch;
|
|
@@ -2592,9 +2599,7 @@ async function captureScreenshot(state, input) {
|
|
|
2592
2599
|
previewPath
|
|
2593
2600
|
});
|
|
2594
2601
|
const previewJpegBase64 = Buffer.from(multi.inlineJpeg).toString("base64");
|
|
2595
|
-
|
|
2596
|
-
metadata.previewDataUri = previewDataUri;
|
|
2597
|
-
return { metadata, previewJpegBase64, previewDataUri };
|
|
2602
|
+
return { metadata, previewJpegBase64 };
|
|
2598
2603
|
} catch (e) {
|
|
2599
2604
|
const msg = e instanceof Error ? e.message : String(e);
|
|
2600
2605
|
throw new Error(`Renderer error for '${sketchId}': ${msg}`);
|
|
@@ -2615,6 +2620,9 @@ async function buildScreenshotMetadata(state, multi, info) {
|
|
|
2615
2620
|
await (0, import_promises6.writeFile)(info.previewPath, multi.previewPng);
|
|
2616
2621
|
metadata.savedPreviewTo = info.previewPath;
|
|
2617
2622
|
metadata.previewWritten = true;
|
|
2623
|
+
if (info.autoOpen !== false) {
|
|
2624
|
+
openPreview(info.previewPath);
|
|
2625
|
+
}
|
|
2618
2626
|
}
|
|
2619
2627
|
return metadata;
|
|
2620
2628
|
}
|
|
@@ -2649,7 +2657,9 @@ async function captureBatch(state, input) {
|
|
|
2649
2657
|
target: "sketch",
|
|
2650
2658
|
sketchId: id,
|
|
2651
2659
|
seed: effectiveSeed,
|
|
2652
|
-
previewPath
|
|
2660
|
+
previewPath,
|
|
2661
|
+
autoOpen: false
|
|
2662
|
+
// Don't flood windows for batch captures
|
|
2653
2663
|
});
|
|
2654
2664
|
items.push({
|
|
2655
2665
|
metadata: itemMetadata,
|
|
@@ -5192,7 +5202,7 @@ function registerSketchTools(server, state) {
|
|
|
5192
5202
|
addToWorkspace: import_zod2.z.string().optional().describe("Path to workspace to add sketch to after creation"),
|
|
5193
5203
|
agent: import_zod2.z.string().optional().describe("Your CLI agent name (e.g. 'claude-code', 'codex-cli', 'gemini-cli', 'opencode', 'kiro')"),
|
|
5194
5204
|
model: import_zod2.z.string().optional().describe("Your AI model identifier (e.g. 'claude-opus-4-6', 'gpt-4o', 'gemini-2.5-pro')"),
|
|
5195
|
-
capture: import_zod2.z.boolean().optional().describe("When true, automatically capture a screenshot after creation
|
|
5205
|
+
capture: import_zod2.z.boolean().optional().describe("When true, automatically capture a screenshot after creation and return it inline (avoids a separate capture_screenshot call)")
|
|
5196
5206
|
},
|
|
5197
5207
|
async (args) => {
|
|
5198
5208
|
try {
|
|
@@ -5203,15 +5213,13 @@ function registerSketchTools(server, state) {
|
|
|
5203
5213
|
target: "sketch",
|
|
5204
5214
|
sketchId: args.id
|
|
5205
5215
|
});
|
|
5206
|
-
const captureMeta = captureResult.metadata;
|
|
5207
5216
|
return {
|
|
5208
5217
|
content: [
|
|
5218
|
+
{ type: "image", data: captureResult.previewJpegBase64, mimeType: "image/jpeg" },
|
|
5209
5219
|
{ type: "text", text: JSON.stringify({
|
|
5210
5220
|
...result,
|
|
5211
|
-
capture:
|
|
5212
|
-
}, null, 2) }
|
|
5213
|
-
{ type: "image", data: captureResult.previewJpegBase64, mimeType: "image/jpeg" },
|
|
5214
|
-
...captureMeta.savedPreviewTo ? [{ type: "text", text: `` }] : []
|
|
5221
|
+
capture: captureResult.metadata
|
|
5222
|
+
}, null, 2) }
|
|
5215
5223
|
]
|
|
5216
5224
|
};
|
|
5217
5225
|
} catch (captureErr) {
|
|
@@ -5777,7 +5785,7 @@ function registerSnapshotTools(server, state) {
|
|
|
5777
5785
|
function registerCaptureTools(server, state) {
|
|
5778
5786
|
server.tool(
|
|
5779
5787
|
"capture_screenshot",
|
|
5780
|
-
"Capture a screenshot of a sketch. Returns
|
|
5788
|
+
"Capture a screenshot of a sketch. Returns an inline JPEG image + metadata as text. In local mode, also writes a full-res PNG to snapshots/<sketchId>-<seed>-preview.png (path in savedPreviewTo).",
|
|
5781
5789
|
{
|
|
5782
5790
|
target: import_zod2.z.enum(["selected", "sketch"]).optional().describe("What to capture (default: selected)"),
|
|
5783
5791
|
sketchId: import_zod2.z.string().optional().describe("Required when target is 'sketch'"),
|
|
@@ -5790,13 +5798,11 @@ function registerCaptureTools(server, state) {
|
|
|
5790
5798
|
async (args) => {
|
|
5791
5799
|
try {
|
|
5792
5800
|
const result = await captureScreenshot(state, args);
|
|
5793
|
-
console.error(`[capture_screenshot] jpeg base64 length: ${result.previewJpegBase64.length}
|
|
5801
|
+
console.error(`[capture_screenshot] jpeg base64 length: ${result.previewJpegBase64.length}`);
|
|
5794
5802
|
return {
|
|
5795
5803
|
content: [
|
|
5796
|
-
{ type: "text", text: JSON.stringify(result.metadata, null, 2) },
|
|
5797
5804
|
{ type: "image", data: result.previewJpegBase64, mimeType: "image/jpeg" },
|
|
5798
|
-
|
|
5799
|
-
...result.metadata.savedPreviewTo ? [{ type: "text", text: `` }] : []
|
|
5805
|
+
{ type: "text", text: JSON.stringify(result.metadata, null, 2) }
|
|
5800
5806
|
]
|
|
5801
5807
|
};
|
|
5802
5808
|
} catch (e) {
|
|
@@ -5807,7 +5813,7 @@ function registerCaptureTools(server, state) {
|
|
|
5807
5813
|
);
|
|
5808
5814
|
server.tool(
|
|
5809
5815
|
"capture_batch",
|
|
5810
|
-
"Capture screenshots of multiple sketches in parallel. Returns
|
|
5816
|
+
"Capture screenshots of multiple sketches in parallel. Returns inline JPEG images + per-sketch metadata. In local mode, writes full-res PNGs to snapshots/.",
|
|
5811
5817
|
{
|
|
5812
5818
|
sketchIds: import_zod2.z.array(import_zod2.z.string()).optional().describe("IDs of sketches to capture (default: all)"),
|
|
5813
5819
|
width: import_zod2.z.number().optional().describe("Override width for all captures"),
|
|
@@ -5822,21 +5828,15 @@ function registerCaptureTools(server, state) {
|
|
|
5822
5828
|
{ type: "text", text: JSON.stringify(result.metadata, null, 2) }
|
|
5823
5829
|
];
|
|
5824
5830
|
for (const item of result.items) {
|
|
5825
|
-
content.push({
|
|
5826
|
-
type: "text",
|
|
5827
|
-
text: JSON.stringify(item.metadata, null, 2)
|
|
5828
|
-
});
|
|
5829
5831
|
content.push({
|
|
5830
5832
|
type: "image",
|
|
5831
5833
|
data: item.inlineJpegBase64,
|
|
5832
5834
|
mimeType: "image/jpeg"
|
|
5833
5835
|
});
|
|
5834
|
-
|
|
5835
|
-
|
|
5836
|
-
|
|
5837
|
-
|
|
5838
|
-
});
|
|
5839
|
-
}
|
|
5836
|
+
content.push({
|
|
5837
|
+
type: "text",
|
|
5838
|
+
text: JSON.stringify(item.metadata, null, 2)
|
|
5839
|
+
});
|
|
5840
5840
|
}
|
|
5841
5841
|
return { content };
|
|
5842
5842
|
} catch (e) {
|