Class: Daytona::ComputerUse::Screenshot
- Inherits:
-
Object
- Object
- Daytona::ComputerUse::Screenshot
- Includes:
- Instrumentation
- Defined in:
- lib/daytona/computer_use.rb
Overview
Screenshot operations for computer use functionality.
Instance Attribute Summary collapse
-
#sandbox_id ⇒ String
readonly
The ID of the sandbox.
-
#toolbox_api ⇒ DaytonaToolboxApiClient::ComputerUseApi
readonly
API client for sandbox operations.
Instance Method Summary collapse
-
#initialize(sandbox_id:, toolbox_api:, otel_state: nil) ⇒ Screenshot
constructor
A new instance of Screenshot.
-
#take_compressed(options: nil) ⇒ DaytonaApiClient::CompressedScreenshotResponse
Takes a compressed screenshot of the entire screen.
-
#take_compressed_region(region:, options: nil) ⇒ DaytonaApiClient::CompressedScreenshotResponse
Takes a compressed screenshot of a specific region.
-
#take_full_screen(show_cursor: false) ⇒ DaytonaApiClient::ScreenshotResponse
Takes a screenshot of the entire screen.
-
#take_region(region:, show_cursor: false) ⇒ DaytonaApiClient::RegionScreenshotResponse
Takes a screenshot of a specific region.
Methods included from Instrumentation
Constructor Details
#initialize(sandbox_id:, toolbox_api:, otel_state: nil) ⇒ Screenshot
Returns a new instance of Screenshot.
234 235 236 237 238 |
# File 'lib/daytona/computer_use.rb', line 234 def initialize(sandbox_id:, toolbox_api:, otel_state: nil) @sandbox_id = sandbox_id @toolbox_api = toolbox_api @otel_state = otel_state end |
Instance Attribute Details
#sandbox_id ⇒ String (readonly)
Returns The ID of the sandbox.
226 227 228 |
# File 'lib/daytona/computer_use.rb', line 226 def sandbox_id @sandbox_id end |
#toolbox_api ⇒ DaytonaToolboxApiClient::ComputerUseApi (readonly)
Returns API client for sandbox operations.
229 230 231 |
# File 'lib/daytona/computer_use.rb', line 229 def toolbox_api @toolbox_api end |
Instance Method Details
#take_compressed(options: nil) ⇒ DaytonaApiClient::CompressedScreenshotResponse
Takes a compressed screenshot of the entire screen.
294 295 296 297 298 299 300 301 302 303 304 305 |
# File 'lib/daytona/computer_use.rb', line 294 def take_compressed(options: nil) ||= ScreenshotOptions.new toolbox_api.take_compressed_screenshot( sandbox_id, scale: .scale, quality: .quality, format: .fmt, show_cursor: .show_cursor ) rescue StandardError => e raise Sdk::Error, "Failed to take compressed screenshot: #{e.}" end |
#take_compressed_region(region:, options: nil) ⇒ DaytonaApiClient::CompressedScreenshotResponse
Takes a compressed screenshot of a specific region.
321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 |
# File 'lib/daytona/computer_use.rb', line 321 def take_compressed_region(region:, options: nil) ||= ScreenshotOptions.new toolbox_api.take_compressed_region_screenshot( sandbox_id, region.height, region.width, region.y, region.x, scale: .scale, quality: .quality, format: .fmt, show_cursor: .show_cursor ) rescue StandardError => e raise Sdk::Error, "Failed to take compressed region screenshot: #{e.}" end |
#take_full_screen(show_cursor: false) ⇒ DaytonaApiClient::ScreenshotResponse
Takes a screenshot of the entire screen.
252 253 254 255 256 |
# File 'lib/daytona/computer_use.rb', line 252 def take_full_screen(show_cursor: false) toolbox_api.take_screenshot(show_cursor:) rescue StandardError => e raise Sdk::Error, "Failed to take screenshot: #{e.}" end |
#take_region(region:, show_cursor: false) ⇒ DaytonaApiClient::RegionScreenshotResponse
Takes a screenshot of a specific region.
269 270 271 272 273 |
# File 'lib/daytona/computer_use.rb', line 269 def take_region(region:, show_cursor: false) toolbox_api.take_region_screenshot(region.height, region.width, region.y, region.x, show_cursor:) rescue StandardError => e raise Sdk::Error, "Failed to take region screenshot: #{e.}" end |