daytona 0.222.0 → 0.223.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1571cb9675a6cbd58c204ff3d703743d0acf676960cd2cc1179a60c76733b645
4
- data.tar.gz: 1d1e628fc6216525520dd42b03ebb93a478bb91591122a2da29e54178c1e9452
3
+ metadata.gz: ce7bf391267dee8c74a05e8ed953fc1b11d350e551f7cfe2481823b757369ca3
4
+ data.tar.gz: 476cc862b0e6395dc99b9a9df53c427cfb5fcdc30b984cf40a7b78d53c6dc57b
5
5
  SHA512:
6
- metadata.gz: 19cd6e9eaad5b31424cb9c2d4fc5298f9a8293ff11df5b4e202fcb1632a94db2d1398e2ae7717ab590ef2b333dd6e41f6d916da8b8e06560ce565f456bfd6d88
7
- data.tar.gz: 7e2eebf97b143b321ba3cf3547e5a72e3d99367367eddc04c6456e023d88e3c1daa0f18f3a2ce513d5ff2c74d2a49a8d2bf251dae6f61ebf3e24db77979ed67e
6
+ metadata.gz: 1484338fb95baf777228e193ff8092b732d92986d06dfdf9cabeb0a01e0602afbd554e6a97dd972cfcd99094f7a3259c3282336fec2c1dc8528c2b7d468bc501
7
+ data.tar.gz: e9d594ace654c716d6e7635c23a3a080d9dbb5fed967ee2a7a191159b23956f302a76672cbccca3178aa1a297a8ff9750bd8edbad40c4e8777284e0a5f67cde6
@@ -60,6 +60,8 @@ module Daytona
60
60
  # @param y [Integer] The y coordinate to click at
61
61
  # @param button [String] The mouse button to click ('left', 'right', 'middle'). Defaults to 'left'
62
62
  # @param double [Boolean] Whether to perform a double-click. Defaults to false
63
+ # @param clicks [Integer, nil] Number of clicks to perform (1-10). Omitted when nil, which is distinct from an explicit 0
64
+ # @param modifiers [Array<String>, nil] Modifier keys to hold during the click. Canonical names are 'ctrl', 'alt', 'shift', and 'cmd'
63
65
  # @return [DaytonaToolboxApiClient::MouseClickResponse] Click operation result
64
66
  # @raise [Daytona::Sdk::Error] If the operation fails
65
67
  #
@@ -72,13 +74,74 @@ module Daytona
72
74
  #
73
75
  # # Right click
74
76
  # right_click = sandbox.computer_use.mouse.click(x: 100, y: 200, button: 'right')
75
- def click(x:, y:, button: 'left', double: false)
76
- request = DaytonaToolboxApiClient::MouseClickRequest.new(x:, y:, button:, double:)
77
+ #
78
+ # # Triple click
79
+ # triple_click = sandbox.computer_use.mouse.click(x: 100, y: 200, clicks: 3)
80
+ #
81
+ # # Ctrl+click
82
+ # ctrl_click = sandbox.computer_use.mouse.click(x: 100, y: 200, modifiers: ['ctrl'])
83
+ def click(x:, y:, button: 'left', double: false, clicks: nil, modifiers: nil)
84
+ attrs = { x:, y:, button:, double: }
85
+ attrs[:clicks] = clicks unless clicks.nil?
86
+ attrs[:modifiers] = modifiers unless modifiers.nil?
87
+
88
+ request = DaytonaToolboxApiClient::MouseClickRequest.new(attrs)
77
89
  toolbox_api.click(request)
78
90
  rescue *Sdk::API_ERROR_CLASSES => e
79
91
  raise Sdk.wrap_error(e, 'Failed to click mouse')
80
92
  end
81
93
 
94
+ # Presses and holds a mouse button, optionally moving to the coordinates first.
95
+ #
96
+ # The button stays held until a matching {#up} call.
97
+ #
98
+ # @param x [Integer, nil] The x coordinate to move to before pressing. Omitted when nil
99
+ # @param y [Integer, nil] The y coordinate to move to before pressing. Omitted when nil
100
+ # @param button [String] The mouse button to press ('left', 'right', 'middle'). Defaults to 'left'
101
+ # @return [DaytonaToolboxApiClient::MousePositionResponse] Cursor position after the press
102
+ # @raise [Daytona::Sdk::Error] If the operation fails
103
+ #
104
+ # @example
105
+ # # Press at the current cursor position
106
+ # sandbox.computer_use.mouse.down
107
+ #
108
+ # # Move to coordinates and press
109
+ # sandbox.computer_use.mouse.down(x: 100, y: 200, button: 'left')
110
+ def down(x: nil, y: nil, button: 'left')
111
+ attrs = { button: }
112
+ attrs[:x] = x unless x.nil?
113
+ attrs[:y] = y unless y.nil?
114
+
115
+ request = DaytonaToolboxApiClient::MouseDownRequest.new(attrs)
116
+ toolbox_api.mouse_down(request)
117
+ rescue *Sdk::API_ERROR_CLASSES => e
118
+ raise Sdk.wrap_error(e, 'Failed to press mouse button')
119
+ end
120
+
121
+ # Releases a held mouse button, optionally moving to the coordinates first.
122
+ #
123
+ # @param x [Integer, nil] The x coordinate to move to before releasing. Omitted when nil
124
+ # @param y [Integer, nil] The y coordinate to move to before releasing. Omitted when nil
125
+ # @param button [String] The mouse button to release ('left', 'right', 'middle'). Defaults to 'left'
126
+ # @return [DaytonaToolboxApiClient::MousePositionResponse] Cursor position after the release
127
+ # @raise [Daytona::Sdk::Error] If the operation fails
128
+ #
129
+ # @example
130
+ # # Drag by holding, moving, then releasing
131
+ # sandbox.computer_use.mouse.down(x: 10, y: 10)
132
+ # sandbox.computer_use.mouse.move(x: 200, y: 200)
133
+ # sandbox.computer_use.mouse.up(x: 200, y: 200)
134
+ def up(x: nil, y: nil, button: 'left')
135
+ attrs = { button: }
136
+ attrs[:x] = x unless x.nil?
137
+ attrs[:y] = y unless y.nil?
138
+
139
+ request = DaytonaToolboxApiClient::MouseUpRequest.new(attrs)
140
+ toolbox_api.mouse_up(request)
141
+ rescue *Sdk::API_ERROR_CLASSES => e
142
+ raise Sdk.wrap_error(e, 'Failed to release mouse button')
143
+ end
144
+
82
145
  # Drags the mouse from start coordinates to end coordinates.
83
146
  #
84
147
  # @param start_x [Integer] The starting x coordinate
@@ -86,14 +149,21 @@ module Daytona
86
149
  # @param end_x [Integer] The ending x coordinate
87
150
  # @param end_y [Integer] The ending y coordinate
88
151
  # @param button [String] The mouse button to use for dragging. Defaults to 'left'
152
+ # @param modifiers [Array<String>, nil] Modifier keys to hold during the drag. Canonical names are 'ctrl', 'alt', 'shift', and 'cmd'
89
153
  # @return [DaytonaToolboxApiClient::MouseDragResponse] Drag operation result
90
154
  # @raise [Daytona::Sdk::Error] If the operation fails
91
155
  #
92
156
  # @example
93
157
  # result = sandbox.computer_use.mouse.drag(start_x: 50, start_y: 50, end_x: 150, end_y: 150)
94
158
  # puts "Drag ended at #{result.x}, #{result.y}"
95
- def drag(start_x:, start_y:, end_x:, end_y:, button: 'left')
96
- request = DaytonaToolboxApiClient::MouseDragRequest.new(start_x:, start_y:, end_x:, end_y:, button:)
159
+ #
160
+ # # Drag while holding Shift
161
+ # sandbox.computer_use.mouse.drag(start_x: 50, start_y: 50, end_x: 150, end_y: 150, modifiers: ['shift'])
162
+ def drag(start_x:, start_y:, end_x:, end_y:, button: 'left', modifiers: nil)
163
+ attrs = { start_x:, start_y:, end_x:, end_y:, button: }
164
+ attrs[:modifiers] = modifiers unless modifiers.nil?
165
+
166
+ request = DaytonaToolboxApiClient::MouseDragRequest.new(attrs)
97
167
  toolbox_api.drag(request)
98
168
  rescue *Sdk::API_ERROR_CLASSES => e
99
169
  raise Sdk.wrap_error(e, 'Failed to drag mouse')
@@ -103,8 +173,9 @@ module Daytona
103
173
  #
104
174
  # @param x [Integer] The x coordinate to scroll at
105
175
  # @param y [Integer] The y coordinate to scroll at
106
- # @param direction [String] The direction to scroll ('up' or 'down')
176
+ # @param direction [String] The direction to scroll ('up', 'down', 'left', or 'right')
107
177
  # @param amount [Integer] The amount to scroll. Defaults to 1
178
+ # @param modifiers [Array<String>, nil] Modifier keys to hold during the scroll. Canonical names are 'ctrl', 'alt', 'shift', and 'cmd'
108
179
  # @return [Boolean] Whether the scroll operation was successful
109
180
  # @raise [Daytona::Sdk::Error] If the operation fails
110
181
  #
@@ -114,15 +185,24 @@ module Daytona
114
185
  #
115
186
  # # Scroll down
116
187
  # scroll_down = sandbox.computer_use.mouse.scroll(x: 100, y: 200, direction: 'down', amount: 5)
117
- def scroll(x:, y:, direction:, amount: 1)
118
- request = DaytonaToolboxApiClient::MouseScrollRequest.new(x:, y:, direction:, amount:)
188
+ #
189
+ # # Scroll horizontally
190
+ # scroll_left = sandbox.computer_use.mouse.scroll(x: 100, y: 200, direction: 'left', amount: 2)
191
+ #
192
+ # # Ctrl+scroll to zoom
193
+ # zoom_in = sandbox.computer_use.mouse.scroll(x: 100, y: 200, direction: 'up', modifiers: ['ctrl'])
194
+ def scroll(x:, y:, direction:, amount: 1, modifiers: nil)
195
+ attrs = { x:, y:, direction:, amount: }
196
+ attrs[:modifiers] = modifiers unless modifiers.nil?
197
+
198
+ request = DaytonaToolboxApiClient::MouseScrollRequest.new(attrs)
119
199
  toolbox_api.scroll(request)
120
200
  true
121
201
  rescue *Sdk::API_ERROR_CLASSES => e
122
202
  raise Sdk.wrap_error(e, 'Failed to scroll mouse')
123
203
  end
124
204
 
125
- instrument :position, :move, :click, :drag, :scroll, component: 'Mouse'
205
+ instrument :position, :move, :click, :down, :up, :drag, :scroll, component: 'Mouse'
126
206
 
127
207
  private
128
208
 
@@ -191,6 +271,43 @@ module Daytona
191
271
  raise Sdk.wrap_error(e, 'Failed to press key')
192
272
  end
193
273
 
274
+ # Presses and holds a key or modifier until a matching {#up} call.
275
+ #
276
+ # @param key [String] The key or modifier to hold. Uses the same normalized key contract as #press, so 'ctrl', 'shift', and 'a' are all valid
277
+ # @return [void]
278
+ # @raise [Daytona::Sdk::Error] If the operation fails
279
+ #
280
+ # @example
281
+ # # Hold Shift while typing. Release in `ensure` so a failed press cannot
282
+ # # leave Shift stuck down.
283
+ # sandbox.computer_use.keyboard.down(key: 'shift')
284
+ # begin
285
+ # sandbox.computer_use.keyboard.press(key: 'a')
286
+ # ensure
287
+ # sandbox.computer_use.keyboard.up(key: 'shift')
288
+ # end
289
+ def down(key:)
290
+ request = DaytonaToolboxApiClient::KeyboardKeyDownRequest.new(key:)
291
+ toolbox_api.key_down(request)
292
+ rescue *Sdk::API_ERROR_CLASSES => e
293
+ raise Sdk.wrap_error(e, 'Failed to press key down')
294
+ end
295
+
296
+ # Releases a key or modifier that is currently held down.
297
+ #
298
+ # @param key [String] The key or modifier to release. Uses the same normalized key contract as #press
299
+ # @return [void]
300
+ # @raise [Daytona::Sdk::Error] If the operation fails
301
+ #
302
+ # @example
303
+ # sandbox.computer_use.keyboard.up(key: 'ctrl')
304
+ def up(key:)
305
+ request = DaytonaToolboxApiClient::KeyboardKeyUpRequest.new(key:)
306
+ toolbox_api.key_up(request)
307
+ rescue *Sdk::API_ERROR_CLASSES => e
308
+ raise Sdk.wrap_error(e, 'Failed to release key')
309
+ end
310
+
194
311
  # Presses a hotkey combination.
195
312
  #
196
313
  # @param keys [String] A single atomic hotkey chord (e.g., 'ctrl+c', 'alt+tab', 'cmd+shift+t', 'ctrl + c', 'shift'). Uses the same normalized key contract as #press.
@@ -213,7 +330,7 @@ module Daytona
213
330
  raise Sdk.wrap_error(e, 'Failed to press hotkey')
214
331
  end
215
332
 
216
- instrument :type, :press, :hotkey, component: 'Keyboard'
333
+ instrument :type, :press, :down, :up, :hotkey, component: 'Keyboard'
217
334
 
218
335
  private
219
336
 
@@ -5,6 +5,6 @@
5
5
 
6
6
  module Daytona
7
7
  module Sdk
8
- VERSION = '0.222.0'
8
+ VERSION = '0.223.0'
9
9
  end
10
10
  end
data/project.json CHANGED
@@ -84,8 +84,7 @@
84
84
  "options": {
85
85
  "cwd": "{projectRoot}",
86
86
  "commands": [
87
- "mkdir -p ~/.gem && echo \":rubygems: $RUBYGEMS_API_KEY\" > ~/.gem/credentials && chmod 0600 ~/.gem/credentials",
88
- "gem push daytona-*.gem --key rubygems --host https://rubygems.org"
87
+ "gem push daytona-*.gem --host https://rubygems.org"
89
88
  ],
90
89
  "parallel": false
91
90
  },
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: daytona
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.222.0
4
+ version: 0.223.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daytona Platforms Inc.
@@ -91,42 +91,42 @@ dependencies:
91
91
  requirements:
92
92
  - - '='
93
93
  - !ruby/object:Gem::Version
94
- version: 0.222.0
94
+ version: 0.223.0
95
95
  type: :runtime
96
96
  prerelease: false
97
97
  version_requirements: !ruby/object:Gem::Requirement
98
98
  requirements:
99
99
  - - '='
100
100
  - !ruby/object:Gem::Version
101
- version: 0.222.0
101
+ version: 0.223.0
102
102
  - !ruby/object:Gem::Dependency
103
103
  name: daytona_api_client
104
104
  requirement: !ruby/object:Gem::Requirement
105
105
  requirements:
106
106
  - - '='
107
107
  - !ruby/object:Gem::Version
108
- version: 0.222.0
108
+ version: 0.223.0
109
109
  type: :runtime
110
110
  prerelease: false
111
111
  version_requirements: !ruby/object:Gem::Requirement
112
112
  requirements:
113
113
  - - '='
114
114
  - !ruby/object:Gem::Version
115
- version: 0.222.0
115
+ version: 0.223.0
116
116
  - !ruby/object:Gem::Dependency
117
117
  name: daytona_toolbox_api_client
118
118
  requirement: !ruby/object:Gem::Requirement
119
119
  requirements:
120
120
  - - '='
121
121
  - !ruby/object:Gem::Version
122
- version: 0.222.0
122
+ version: 0.223.0
123
123
  type: :runtime
124
124
  prerelease: false
125
125
  version_requirements: !ruby/object:Gem::Requirement
126
126
  requirements:
127
127
  - - '='
128
128
  - !ruby/object:Gem::Version
129
- version: 0.222.0
129
+ version: 0.223.0
130
130
  - !ruby/object:Gem::Dependency
131
131
  name: dotenv
132
132
  requirement: !ruby/object:Gem::Requirement