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.
237 238 239 240 241 |
# File 'lib/daytona/computer_use.rb', line 237 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.
229 230 231 |
# File 'lib/daytona/computer_use.rb', line 229 def sandbox_id @sandbox_id end |
#toolbox_api ⇒ DaytonaToolboxApiClient::ComputerUseApi (readonly)
Returns API client for sandbox operations.
232 233 234 |
# File 'lib/daytona/computer_use.rb', line 232 def toolbox_api @toolbox_api end |
Instance Method Details
#take_compressed(options: nil) ⇒ DaytonaApiClient::CompressedScreenshotResponse
Takes a compressed screenshot of the entire screen.
297 298 299 300 301 302 303 304 305 306 307 308 |
# File 'lib/daytona/computer_use.rb', line 297 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.
324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 |
# File 'lib/daytona/computer_use.rb', line 324 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.
255 256 257 258 259 |
# File 'lib/daytona/computer_use.rb', line 255 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.
272 273 274 275 276 |
# File 'lib/daytona/computer_use.rb', line 272 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 |