( ctx context.Context, conn workspacesdk.AgentConn, declaredWidth, declaredHeight int, )
| 350 | } |
| 351 | |
| 352 | func (t *computerUseTool) captureScreenshot( |
| 353 | ctx context.Context, |
| 354 | conn workspacesdk.AgentConn, |
| 355 | declaredWidth, declaredHeight int, |
| 356 | ) (fantasy.ToolResponse, error) { |
| 357 | screenResp, err := executeScreenshotAction(ctx, conn, declaredWidth, declaredHeight) |
| 358 | if err != nil { |
| 359 | return fantasy.NewTextErrorResponse( |
| 360 | fmt.Sprintf("screenshot failed: %v", err), |
| 361 | ), nil |
| 362 | } |
| 363 | screenData, err := base64.StdEncoding.DecodeString(screenResp.ScreenshotData) |
| 364 | if err != nil { |
| 365 | t.logger.Error(ctx, "failed to decode screenshot base64 in captureScreenshot", |
| 366 | slog.Error(err), |
| 367 | ) |
| 368 | return fantasy.NewTextErrorResponse( |
| 369 | fmt.Sprintf("failed to decode screenshot data: %v", err), |
| 370 | ), nil |
| 371 | } |
| 372 | return fantasy.NewImageResponse(screenData, "image/png"), nil |
| 373 | } |
| 374 | |
| 375 | func (t *computerUseTool) captureSharedScreenshot( |
| 376 | ctx context.Context, |
no test coverage detected