From daa1c15cde2e37b2bd4f0ca9127821f44f4f9407 Mon Sep 17 00:00:00 2001 From: fahd04 Date: Thu, 19 Feb 2026 12:38:13 +0000 Subject: [PATCH] feat: shell_screenshot returns png_url and svg_url Add png_url and svg_url to shell_screenshot response alongside download_url for backward compatibility. Users can now choose SVG for scalability or PNG for compatibility. Also fix TypeScript error in buffer-to-svg.ts (showCursor not in IModes type) that prevented local build. Closes #45 --- src/index.ts | 2 +- src/lib/buffer-to-svg.ts | 2 +- src/tools/shell-screenshot.ts | 12 ++++++++++-- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/index.ts b/src/index.ts index 57f0b59..2516fee 100644 --- a/src/index.ts +++ b/src/index.ts @@ -202,7 +202,7 @@ Tips: server.tool( "shell_screenshot", - "Capture terminal screenshot as PNG. Returns a download_url - use curl to save the file locally (e.g., curl -o screenshot.png )", + "Capture terminal screenshot as PNG and SVG. Returns png_url and svg_url - use curl to save (e.g., curl -o screenshot.png )", shellScreenshotSchema, async (params) => shellScreenshot(params, toolContext) ); diff --git a/src/lib/buffer-to-svg.ts b/src/lib/buffer-to-svg.ts index 1891dcb..4d72c4a 100644 --- a/src/lib/buffer-to-svg.ts +++ b/src/lib/buffer-to-svg.ts @@ -159,7 +159,7 @@ export function bufferToSvg( } // Render cursor if visible - if (terminal.modes.showCursor) { + if ((terminal.modes as { showCursor?: boolean }).showCursor) { const cursorX = buffer.cursorX; const cursorY = buffer.cursorY; diff --git a/src/tools/shell-screenshot.ts b/src/tools/shell-screenshot.ts index 7c658fa..ca924ef 100644 --- a/src/tools/shell-screenshot.ts +++ b/src/tools/shell-screenshot.ts @@ -53,8 +53,16 @@ export async function shellScreenshot( context.log(`[shellwright] Screenshot saved: ${screenshotDir}/${baseName}.{png,svg,ansi,txt}`); - const downloadUrl = context.getDownloadUrl(context.getMcpSessionId(), session_id, "screenshots", filename); - const output = { filename, download_url: downloadUrl, hint: "Use curl -o to save the file" }; + const mcpSessionId = context.getMcpSessionId(); + const pngUrl = context.getDownloadUrl(mcpSessionId, session_id, "screenshots", `${baseName}.png`); + const svgUrl = context.getDownloadUrl(mcpSessionId, session_id, "screenshots", `${baseName}.svg`); + const output = { + filename, + download_url: pngUrl, + png_url: pngUrl, + svg_url: svgUrl, + hint: "Use curl -o to save the file", + }; context.logToolCall("shell_screenshot", { session_id, name }, output); return {