Description
The comet_screenshot tool is not working properly. When called, it fails to return screenshot data.
Technical Analysis
Root Cause
The issue is in src/cdp-client.ts at line 1113:
async screenshot(format: "png" | "jpeg" = "png"): Promise<ScreenshotResult> {
this.ensureConnected();
return this.client!.Page.captureScreenshot({ format }) as Promise<ScreenshotResult>;
}
Problems identified:
ensureConnected() is not being awaited, which means the connection check happens asynchronously but doesn't block execution
- The type assertion
as Promise<ScreenshotResult> may be hiding a runtime type mismatch
- No error handling if the CDP method fails or returns unexpected data
- Missing additional CDP parameters that might be required for reliable screenshots
Expected Type
From src/types.ts line 27:
export interface ScreenshotResult {
data: string; // Base64 encoded
}
Proposed Fix
Update the screenshot method in src/cdp-client.ts:
async screenshot(format: "png" | "jpeg" = "png"): Promise<ScreenshotResult> {
await this.ensureConnected(); // Add await
try {
const result = await this.client!.Page.captureScreenshot({
format,
captureBeyondViewport: false // Add CDP options
});
if (!result || !result.data) {
throw new Error("Screenshot returned no data");
}
return { data: result.data };
} catch (error) {
throw new Error(`Screenshot failed: ${error instanceof Error ? error.message : String(error)}`);
}
}
Environment
- Platform: Windows
- Version: 2.5.0 (current main branch)
Impact
Users cannot capture screenshots of the current browser state, which is essential for debugging and monitoring agentic browsing tasks.Platform:
Description
The
comet_screenshottool is not working properly. When called, it fails to return screenshot data.Technical Analysis
Root Cause
The issue is in
src/cdp-client.tsat line 1113:Problems identified:
ensureConnected()is not being awaited, which means the connection check happens asynchronously but doesn't block executionas Promise<ScreenshotResult>may be hiding a runtime type mismatchExpected Type
From
src/types.tsline 27:Proposed Fix
Update the screenshot method in
src/cdp-client.ts:Environment
Impact
Users cannot capture screenshots of the current browser state, which is essential for debugging and monitoring agentic browsing tasks.Platform: