Class: Daytona::ComputerUse::Keyboard
- Inherits:
-
Object
- Object
- Daytona::ComputerUse::Keyboard
- Includes:
- Instrumentation
- Defined in:
- lib/daytona/computer_use.rb
Overview
Keyboard 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
-
#hotkey(keys:) ⇒ void
Presses a hotkey combination.
-
#initialize(sandbox_id:, toolbox_api:, otel_state: nil) ⇒ Keyboard
constructor
A new instance of Keyboard.
-
#press(key:, modifiers: nil) ⇒ void
Presses a key with optional modifiers.
-
#type(text:, delay: nil) ⇒ void
Types the specified text.
Methods included from Instrumentation
Constructor Details
#initialize(sandbox_id:, toolbox_api:, otel_state: nil) ⇒ Keyboard
Returns a new instance of Keyboard.
143 144 145 146 147 |
# File 'lib/daytona/computer_use.rb', line 143 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.
135 136 137 |
# File 'lib/daytona/computer_use.rb', line 135 def sandbox_id @sandbox_id end |
#toolbox_api ⇒ DaytonaToolboxApiClient::ComputerUseApi (readonly)
Returns API client for sandbox operations.
138 139 140 |
# File 'lib/daytona/computer_use.rb', line 138 def toolbox_api @toolbox_api end |
Instance Method Details
#hotkey(keys:) ⇒ void
This method returns an undefined value.
Presses a hotkey combination.
206 207 208 209 210 211 |
# File 'lib/daytona/computer_use.rb', line 206 def hotkey(keys:) request = DaytonaToolboxApiClient::KeyboardHotkeyRequest.new(keys:) toolbox_api.press_hotkey(request) rescue StandardError => e raise Sdk::Error, "Failed to press hotkey: #{e.}" end |
#press(key:, modifiers: nil) ⇒ void
This method returns an undefined value.
Presses a key with optional modifiers.
184 185 186 187 188 189 |
# File 'lib/daytona/computer_use.rb', line 184 def press(key:, modifiers: nil) request = DaytonaToolboxApiClient::KeyboardPressRequest.new(key:, modifiers: modifiers || []) toolbox_api.press_key(request) rescue StandardError => e raise Sdk::Error, "Failed to press key: #{e.}" end |
#type(text:, delay: nil) ⇒ void
This method returns an undefined value.
Types the specified text.
161 162 163 164 165 166 |
# File 'lib/daytona/computer_use.rb', line 161 def type(text:, delay: nil) request = DaytonaToolboxApiClient::KeyboardTypeRequest.new(text:, delay:) toolbox_api.type_text(request) rescue StandardError => e raise Sdk::Error, "Failed to type text: #{e.}" end |