@@ -149,45 +149,6 @@ type BrowserEvalArgs = {
149149 files ?: string [ ]
150150}
151151
152- /**
153- * Filter out base64 image data from the `screenshot` result to reduce context usage.
154- * Extract file paths from text content and attach guidance.
155- */
156- export function filterImageDataFromResult ( result : unknown ) : unknown {
157- if ( typeof result !== "object" || result === null ) {
158- return result
159- }
160-
161- const typedResult = result as { content ?: { type : string ; text ?: string ; data ?: string } [ ] }
162-
163- if ( ! Array . isArray ( typedResult . content ) ) {
164- return result
165- }
166-
167- const filteredContent = typedResult . content . filter ( ( block ) => block . type !== "image" )
168-
169- const textBlock = filteredContent . find ( ( block ) => block . type === "text" )
170- let screenshotPath : string | null = null
171-
172- if ( textBlock ?. text ) {
173- // Extract file path from text like "saved it as /path/to/screenshot.png"
174- const pathMatch = textBlock . text . match ( / (?: s a v e d (?: i t ) ? a s | s a v e d t o ) ( .+ \. p n g ) / i)
175- if ( pathMatch ) {
176- screenshotPath = pathMatch [ 1 ]
177- }
178- }
179-
180- // Add helpful message about reading the screenshot
181- if ( screenshotPath && textBlock ) {
182- filteredContent . push ( {
183- type : "text" ,
184- text : `\n\nTo view this screenshot, use the "read" tool with the file path: ${ screenshotPath } ` ,
185- } )
186- }
187-
188- return { ...typedResult , content : filteredContent }
189- }
190-
191152export async function handler ( args : BrowserEvalArgs ) : Promise < string > {
192153 try {
193154 if ( args . action === "start" ) {
@@ -327,13 +288,10 @@ export async function handler(args: BrowserEvalArgs): Promise<string> {
327288
328289 const result = await callServerTool ( connection , toolName , toolArgs )
329290
330- const formattedResult =
331- args . action === "screenshot" ? filterImageDataFromResult ( result ) : result
332-
333291 return JSON . stringify ( {
334292 success : true ,
335293 action : args . action ,
336- result : formattedResult ,
294+ result,
337295 } )
338296 } catch ( error ) {
339297 const errorMessage = error instanceof Error ? error . message : String ( error )
0 commit comments