Class: Daytona::ComputerUse::Recording
- Inherits:
-
Object
- Object
- Daytona::ComputerUse::Recording
- Includes:
- Instrumentation
- Defined in:
- lib/daytona/computer_use.rb
Overview
Recording 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
-
#delete(id:) ⇒ void
Deletes a recording by ID.
-
#download(id:, local_path:) ⇒ void
Downloads a recording file and saves it to a local path.
-
#get(id:) ⇒ DaytonaToolboxApiClient::Recording
Gets details of a specific recording by ID.
-
#initialize(sandbox_id:, toolbox_api:, otel_state: nil) ⇒ Recording
constructor
A new instance of Recording.
-
#list ⇒ DaytonaToolboxApiClient::ListRecordingsResponse
Lists all recordings (active and completed).
-
#start(label: nil) ⇒ DaytonaToolboxApiClient::Recording
Starts a new screen recording session.
-
#stop(id:) ⇒ DaytonaToolboxApiClient::Recording
Stops an active screen recording session.
Methods included from Instrumentation
Constructor Details
#initialize(sandbox_id:, toolbox_api:, otel_state: nil) ⇒ Recording
Returns a new instance of Recording.
474 475 476 477 478 |
# File 'lib/daytona/computer_use.rb', line 474 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.
466 467 468 |
# File 'lib/daytona/computer_use.rb', line 466 def sandbox_id @sandbox_id end |
#toolbox_api ⇒ DaytonaToolboxApiClient::ComputerUseApi (readonly)
Returns API client for sandbox operations.
469 470 471 |
# File 'lib/daytona/computer_use.rb', line 469 def toolbox_api @toolbox_api end |
Instance Method Details
#delete(id:) ⇒ void
This method returns an undefined value.
Deletes a recording by ID.
558 559 560 561 562 |
# File 'lib/daytona/computer_use.rb', line 558 def delete(id:) toolbox_api.delete_recording(id) rescue StandardError => e raise Sdk::Error, "Failed to delete recording: #{e.}" end |
#download(id:, local_path:) ⇒ void
This method returns an undefined value.
Downloads a recording file and saves it to a local path.
The file is streamed directly to disk without loading the entire content into memory.
576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 |
# File 'lib/daytona/computer_use.rb', line 576 def download(id:, local_path:) require 'fileutils' require 'typhoeus' # Get the API configuration and build the download URL api_client = toolbox_api.api_client config = api_client.config base_url = config.base_url download_url = "#{base_url}/computeruse/recordings/#{id}/download" # Create parent directory if it doesn't exist parent_dir = File.dirname(local_path) FileUtils.mkdir_p(parent_dir) unless parent_dir.empty? # Stream the download directly to file file = File.open(local_path, 'wb') request = Typhoeus::Request.new( download_url, method: :get, headers: api_client.default_headers, timeout: config.timeout, ssl_verifypeer: config.verify_ssl, ssl_verifyhost: config.verify_ssl_host ? 2 : 0 ) # Stream chunks directly to file request.on_body do |chunk| file.write(chunk) end request.on_complete do |response| file.close unless response.success? File.delete(local_path) if File.exist?(local_path) raise Sdk::Error, "Failed to download recording: HTTP #{response.code}" end end request.run rescue StandardError => e file&.close File.delete(local_path) if File.exist?(local_path) raise Sdk::Error, "Failed to download recording: #{e.}" end |
#get(id:) ⇒ DaytonaToolboxApiClient::Recording
Gets details of a specific recording by ID.
543 544 545 546 547 |
# File 'lib/daytona/computer_use.rb', line 543 def get(id:) toolbox_api.get_recording(id) rescue StandardError => e raise Sdk::Error, "Failed to get recording: #{e.}" end |
#list ⇒ DaytonaToolboxApiClient::ListRecordingsResponse
Lists all recordings (active and completed).
526 527 528 529 530 |
# File 'lib/daytona/computer_use.rb', line 526 def list toolbox_api.list_recordings rescue StandardError => e raise Sdk::Error, "Failed to list recordings: #{e.}" end |
#start(label: nil) ⇒ DaytonaToolboxApiClient::Recording
Starts a new screen recording session.
491 492 493 494 495 496 |
# File 'lib/daytona/computer_use.rb', line 491 def start(label: nil) request = DaytonaToolboxApiClient::StartRecordingRequest.new(label:) toolbox_api.start_recording(request: request) rescue StandardError => e raise Sdk::Error, "Failed to start recording: #{e.}" end |
#stop(id:) ⇒ DaytonaToolboxApiClient::Recording
Stops an active screen recording session.
508 509 510 511 512 513 |
# File 'lib/daytona/computer_use.rb', line 508 def stop(id:) request = DaytonaToolboxApiClient::StopRecordingRequest.new(id: id) toolbox_api.stop_recording(request) rescue StandardError => e raise Sdk::Error, "Failed to stop recording: #{e.}" end |