daytona-sdk 0.125.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.
@@ -0,0 +1,549 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Daytona
4
+ class ComputerUse
5
+ class Mouse
6
+ # @return [String] The ID of the sandbox
7
+ attr_reader :sandbox_id
8
+
9
+ # @return [DaytonaApiClient::ToolboxApi] API client for sandbox operations
10
+ attr_reader :toolbox_api
11
+
12
+ # @param sandbox_id [String] The ID of the sandbox
13
+ # @param toolbox_api [DaytonaApiClient::ToolboxApi] API client for sandbox operations
14
+ def initialize(sandbox_id:, toolbox_api:)
15
+ @sandbox_id = sandbox_id
16
+ @toolbox_api = toolbox_api
17
+ end
18
+
19
+ # Gets the current mouse cursor position.
20
+ #
21
+ # @return [DaytonaApiClient::MousePosition] Current mouse position with x and y coordinates
22
+ # @raise [Daytona::Sdk::Error] If the operation fails
23
+ #
24
+ # @example
25
+ # position = sandbox.computer_use.mouse.get_position
26
+ # puts "Mouse is at: #{position.x}, #{position.y}"
27
+ def position
28
+ toolbox_api.get_mouse_position(sandbox_id)
29
+ rescue StandardError => e
30
+ raise Sdk::Error, "Failed to get mouse position: #{e.message}"
31
+ end
32
+
33
+ # Moves the mouse cursor to the specified coordinates.
34
+ #
35
+ # @param x [Integer] The x coordinate to move to
36
+ # @param y [Integer] The y coordinate to move to
37
+ # @return [DaytonaApiClient::MouseMoveResponse] Move operation result
38
+ # @raise [Daytona::Sdk::Error] If the operation fails
39
+ #
40
+ # @example
41
+ # result = sandbox.computer_use.mouse.move(x: 100, y: 200)
42
+ # puts "Mouse moved to: #{result.x}, #{result.y}"
43
+ def move(x:, y:) # rubocop:disable Naming/MethodParameterName
44
+ request = DaytonaApiClient::MouseMoveRequest.new(x:, y:)
45
+ toolbox_api.move_mouse(sandbox_id, request)
46
+ rescue StandardError => e
47
+ raise Sdk::Error, "Failed to move mouse: #{e.message}"
48
+ end
49
+
50
+ # Clicks the mouse at the specified coordinates.
51
+ #
52
+ # @param x [Integer] The x coordinate to click at
53
+ # @param y [Integer] The y coordinate to click at
54
+ # @param button [String] The mouse button to click ('left', 'right', 'middle'). Defaults to 'left'
55
+ # @param double [Boolean] Whether to perform a double-click. Defaults to false
56
+ # @return [DaytonaApiClient::MouseClickResponse] Click operation result
57
+ # @raise [Daytona::Sdk::Error] If the operation fails
58
+ #
59
+ # @example
60
+ # # Single left click
61
+ # result = sandbox.computer_use.mouse.click(x: 100, y: 200)
62
+ #
63
+ # # Double click
64
+ # double_click = sandbox.computer_use.mouse.click(x: 100, y: 200, button: 'left', double: true)
65
+ #
66
+ # # Right click
67
+ # right_click = sandbox.computer_use.mouse.click(x: 100, y: 200, button: 'right')
68
+ def click(x:, y:, button: 'left', double: false) # rubocop:disable Naming/MethodParameterName
69
+ request = DaytonaApiClient::MouseClickRequest.new(x:, y:, button:, double:)
70
+ toolbox_api.click_mouse(sandbox_id, request)
71
+ rescue StandardError => e
72
+ raise Sdk::Error, "Failed to click mouse: #{e.message}"
73
+ end
74
+
75
+ # Drags the mouse from start coordinates to end coordinates.
76
+ #
77
+ # @param start_x [Integer] The starting x coordinate
78
+ # @param start_y [Integer] The starting y coordinate
79
+ # @param end_x [Integer] The ending x coordinate
80
+ # @param end_y [Integer] The ending y coordinate
81
+ # @param button [String] The mouse button to use for dragging. Defaults to 'left'
82
+ # @return [DaytonaApiClient::MouseDragResponse] Drag operation result
83
+ # @raise [Daytona::Sdk::Error] If the operation fails
84
+ #
85
+ # @example
86
+ # result = sandbox.computer_use.mouse.drag(start_x: 50, start_y: 50, end_x: 150, end_y: 150)
87
+ # puts "Dragged from #{result.from_x},#{result.from_y} to #{result.to_x},#{result.to_y}"
88
+ def drag(start_x:, start_y:, end_x:, end_y:, button: 'left')
89
+ request = DaytonaApiClient::MouseDragRequest.new(start_x:, start_y:, end_x:, end_y:, button:)
90
+ toolbox_api.drag_mouse(sandbox_id, request)
91
+ rescue StandardError => e
92
+ raise Sdk::Error, "Failed to drag mouse: #{e.message}"
93
+ end
94
+
95
+ # Scrolls the mouse wheel at the specified coordinates.
96
+ #
97
+ # @param x [Integer] The x coordinate to scroll at
98
+ # @param y [Integer] The y coordinate to scroll at
99
+ # @param direction [String] The direction to scroll ('up' or 'down')
100
+ # @param amount [Integer] The amount to scroll. Defaults to 1
101
+ # @return [Boolean] Whether the scroll operation was successful
102
+ # @raise [Daytona::Sdk::Error] If the operation fails
103
+ #
104
+ # @example
105
+ # # Scroll up
106
+ # scroll_up = sandbox.computer_use.mouse.scroll(x: 100, y: 200, direction: 'up', amount: 3)
107
+ #
108
+ # # Scroll down
109
+ # scroll_down = sandbox.computer_use.mouse.scroll(x: 100, y: 200, direction: 'down', amount: 5)
110
+ def scroll(x:, y:, direction:, amount: 1) # rubocop:disable Naming/MethodParameterName
111
+ request = DaytonaApiClient::MouseScrollRequest.new(x:, y:, direction:, amount:)
112
+ toolbox_api.scroll_mouse(sandbox_id, request)
113
+ true
114
+ rescue StandardError => e
115
+ raise Sdk::Error, "Failed to scroll mouse: #{e.message}"
116
+ end
117
+ end
118
+
119
+ # Keyboard operations for computer use functionality.
120
+ class Keyboard
121
+ # @return [String] The ID of the sandbox
122
+ attr_reader :sandbox_id
123
+
124
+ # @return [DaytonaApiClient::ToolboxApi] API client for sandbox operations
125
+ attr_reader :toolbox_api
126
+
127
+ # @param sandbox_id [String] The ID of the sandbox
128
+ # @param toolbox_api [DaytonaApiClient::ToolboxApi] API client for sandbox operations
129
+ def initialize(sandbox_id:, toolbox_api:)
130
+ @sandbox_id = sandbox_id
131
+ @toolbox_api = toolbox_api
132
+ end
133
+
134
+ # Types the specified text.
135
+ #
136
+ # @param text [String] The text to type
137
+ # @param delay [Integer, nil] Delay between characters in milliseconds
138
+ # @return [void]
139
+ # @raise [Daytona::Sdk::Error] If the operation fails
140
+ #
141
+ # @example
142
+ # sandbox.computer_use.keyboard.type("Hello, World!")
143
+ #
144
+ # # With delay between characters
145
+ # sandbox.computer_use.keyboard.type("Slow typing", delay: 100)
146
+ def type(text:, delay: nil)
147
+ request = DaytonaApiClient::KeyboardTypeRequest.new(text:, delay:)
148
+ toolbox_api.type_text(sandbox_id, request)
149
+ rescue StandardError => e
150
+ raise Sdk::Error, "Failed to type text: #{e.message}"
151
+ end
152
+
153
+ # Presses a key with optional modifiers.
154
+ #
155
+ # @param key [String] The key to press (e.g., 'Enter', 'Escape', 'Tab', 'a', 'A')
156
+ # @param modifiers [Array<String>, nil] Modifier keys ('ctrl', 'alt', 'meta', 'shift')
157
+ # @return [void]
158
+ # @raise [Daytona::Sdk::Error] If the operation fails
159
+ #
160
+ # @example
161
+ # # Press Enter
162
+ # sandbox.computer_use.keyboard.press("Return")
163
+ #
164
+ # # Press Ctrl+C
165
+ # sandbox.computer_use.keyboard.press("c", modifiers: ["ctrl"])
166
+ #
167
+ # # Press Ctrl+Shift+T
168
+ # sandbox.computer_use.keyboard.press("t", modifiers: ["ctrl", "shift"])
169
+ def press(key:, modifiers: nil)
170
+ request = DaytonaApiClient::KeyboardPressRequest.new(key:, modifiers: modifiers || [])
171
+ toolbox_api.press_key(sandbox_id, request)
172
+ rescue StandardError => e
173
+ raise Sdk::Error, "Failed to press key: #{e.message}"
174
+ end
175
+
176
+ # Presses a hotkey combination.
177
+ #
178
+ # @param keys [String] The hotkey combination (e.g., 'ctrl+c', 'alt+tab', 'cmd+shift+t')
179
+ # @return [void]
180
+ # @raise [Daytona::Sdk::Error] If the operation fails
181
+ #
182
+ # @example
183
+ # # Copy
184
+ # sandbox.computer_use.keyboard.hotkey("ctrl+c")
185
+ #
186
+ # # Paste
187
+ # sandbox.computer_use.keyboard.hotkey("ctrl+v")
188
+ #
189
+ # # Alt+Tab
190
+ # sandbox.computer_use.keyboard.hotkey("alt+tab")
191
+ def hotkey(keys:)
192
+ request = DaytonaApiClient::KeyboardHotkeyRequest.new(keys:)
193
+ toolbox_api.press_hotkey(sandbox_id, request)
194
+ rescue StandardError => e
195
+ raise Sdk::Error, "Failed to press hotkey: #{e.message}"
196
+ end
197
+ end
198
+
199
+ # Screenshot operations for computer use functionality.
200
+ class Screenshot
201
+ # @return [String] The ID of the sandbox
202
+ attr_reader :sandbox_id
203
+
204
+ # @return [DaytonaApiClient::ToolboxApi] API client for sandbox operations
205
+ attr_reader :toolbox_api
206
+
207
+ # @param sandbox_id [String] The ID of the sandbox
208
+ # @param toolbox_api [DaytonaApiClient::ToolboxApi] API client for sandbox operations
209
+ def initialize(sandbox_id:, toolbox_api:)
210
+ @sandbox_id = sandbox_id
211
+ @toolbox_api = toolbox_api
212
+ end
213
+
214
+ # Takes a screenshot of the entire screen.
215
+ #
216
+ # @param show_cursor [Boolean] Whether to show the cursor in the screenshot. Defaults to false
217
+ # @return [DaytonaApiClient::ScreenshotResponse] Screenshot data with base64 encoded image
218
+ # @raise [Daytona::Sdk::Error] If the operation fails
219
+ #
220
+ # @example
221
+ # screenshot = sandbox.computer_use.screenshot.take_full_screen
222
+ # puts "Screenshot size: #{screenshot.width}x#{screenshot.height}"
223
+ #
224
+ # # With cursor visible
225
+ # with_cursor = sandbox.computer_use.screenshot.take_full_screen(show_cursor: true)
226
+ def take_full_screen(show_cursor: false)
227
+ toolbox_api.take_screenshot(sandbox_id, show_cursor:)
228
+ rescue StandardError => e
229
+ raise Sdk::Error, "Failed to take screenshot: #{e.message}"
230
+ end
231
+
232
+ # Takes a screenshot of a specific region.
233
+ #
234
+ # @param region [ScreenshotRegion] The region to capture
235
+ # @param show_cursor [Boolean] Whether to show the cursor in the screenshot. Defaults to false
236
+ # @return [DaytonaApiClient::RegionScreenshotResponse] Screenshot data with base64 encoded image
237
+ # @raise [Daytona::Sdk::Error] If the operation fails
238
+ #
239
+ # @example
240
+ # region = ScreenshotRegion.new(x: 100, y: 100, width: 300, height: 200)
241
+ # screenshot = sandbox.computer_use.screenshot.take_region(region)
242
+ # puts "Captured region: #{screenshot.region.width}x#{screenshot.region.height}"
243
+ def take_region(region:, show_cursor: false)
244
+ toolbox_api.take_region_screenshot(sandbox_id, region.height, region.width, region.y, region.x, show_cursor:)
245
+ rescue StandardError => e
246
+ raise Sdk::Error, "Failed to take region screenshot: #{e.message}"
247
+ end
248
+
249
+ # Takes a compressed screenshot of the entire screen.
250
+ #
251
+ # @param options [ScreenshotOptions, nil] Compression and display options
252
+ # @return [DaytonaApiClient::CompressedScreenshotResponse] Compressed screenshot data
253
+ # @raise [Daytona::Sdk::Error] If the operation fails
254
+ #
255
+ # @example
256
+ # # Default compression
257
+ # screenshot = sandbox.computer_use.screenshot.take_compressed
258
+ #
259
+ # # High quality JPEG
260
+ # jpeg = sandbox.computer_use.screenshot.take_compressed(
261
+ # options: ScreenshotOptions.new(format: "jpeg", quality: 95, show_cursor: true)
262
+ # )
263
+ #
264
+ # # Scaled down PNG
265
+ # scaled = sandbox.computer_use.screenshot.take_compressed(
266
+ # options: ScreenshotOptions.new(format: "png", scale: 0.5)
267
+ # )
268
+ def take_compressed(options: nil)
269
+ options ||= ScreenshotOptions.new
270
+ toolbox_api.take_compressed_screenshot(
271
+ sandbox_id,
272
+ scale: options.scale,
273
+ quality: options.quality,
274
+ format: options.fmt,
275
+ show_cursor: options.show_cursor
276
+ )
277
+ rescue StandardError => e
278
+ raise Sdk::Error, "Failed to take compressed screenshot: #{e.message}"
279
+ end
280
+
281
+ # Takes a compressed screenshot of a specific region.
282
+ #
283
+ # @param region [ScreenshotRegion] The region to capture
284
+ # @param options [ScreenshotOptions, nil] Compression and display options
285
+ # @return [DaytonaApiClient::CompressedScreenshotResponse] Compressed screenshot data
286
+ # @raise [Daytona::Sdk::Error] If the operation fails
287
+ #
288
+ # @example
289
+ # region = ScreenshotRegion.new(x: 0, y: 0, width: 800, height: 600)
290
+ # screenshot = sandbox.computer_use.screenshot.take_compressed_region(
291
+ # region,
292
+ # options: ScreenshotOptions.new(format: "webp", quality: 80, show_cursor: true)
293
+ # )
294
+ # puts "Compressed size: #{screenshot.size_bytes} bytes"
295
+ def take_compressed_region(region:, options: nil) # rubocop:disable Metrics/MethodLength
296
+ options ||= ScreenshotOptions.new
297
+ toolbox_api.take_compressed_region_screenshot(
298
+ sandbox_id,
299
+ region.height,
300
+ region.width,
301
+ region.y,
302
+ region.x,
303
+ scale: options.scale,
304
+ quality: options.quality,
305
+ format: options.fmt,
306
+ show_cursor: options.show_cursor
307
+ )
308
+ rescue StandardError => e
309
+ raise Sdk::Error, "Failed to take compressed region screenshot: #{e.message}"
310
+ end
311
+ end
312
+
313
+ # Display operations for computer use functionality.
314
+ class Display
315
+ # @return [String] The ID of the sandbox
316
+ attr_reader :sandbox_id
317
+
318
+ # @return [DaytonaApiClient::ToolboxApi] API client for sandbox operations
319
+ attr_reader :toolbox_api
320
+
321
+ # @param sandbox_id [String] The ID of the sandbox
322
+ # @param toolbox_api [DaytonaApiClient::ToolboxApi] API client for sandbox operations
323
+ def initialize(sandbox_id:, toolbox_api:)
324
+ @sandbox_id = sandbox_id
325
+ @toolbox_api = toolbox_api
326
+ end
327
+
328
+ # Gets information about the displays.
329
+ #
330
+ # @return [DaytonaApiClient::DisplayInfoResponse] Display information including primary display and all available displays
331
+ # @raise [Daytona::Sdk::Error] If the operation fails
332
+ #
333
+ # @example
334
+ # info = sandbox.computer_use.display.get_info
335
+ # puts "Primary display: #{info.primary_display.width}x#{info.primary_display.height}"
336
+ # puts "Total displays: #{info.total_displays}"
337
+ # info.displays.each_with_index do |display, i|
338
+ # puts "Display #{i}: #{display.width}x#{display.height} at #{display.x},#{display.y}"
339
+ # end
340
+ def info
341
+ toolbox_api.get_display_info(sandbox_id)
342
+ rescue StandardError => e
343
+ raise Sdk::Error, "Failed to get display info: #{e.message}"
344
+ end
345
+
346
+ # Gets the list of open windows.
347
+ #
348
+ # @return [DaytonaApiClient::WindowsResponse] List of open windows with their IDs and titles
349
+ # @raise [Daytona::Sdk::Error] If the operation fails
350
+ #
351
+ # @example
352
+ # windows = sandbox.computer_use.display.get_windows
353
+ # puts "Found #{windows.count} open windows:"
354
+ # windows.windows.each do |window|
355
+ # puts "- #{window.title} (ID: #{window.id})"
356
+ # end
357
+ def windows
358
+ toolbox_api.get_windows(sandbox_id)
359
+ rescue StandardError => e
360
+ raise Sdk::Error, "Failed to get windows: #{e.message}"
361
+ end
362
+ end
363
+
364
+ # Region coordinates for screenshot operations.
365
+ class ScreenshotRegion
366
+ # @return [Integer] X coordinate of the region
367
+ attr_accessor :x
368
+
369
+ # @return [Integer] Y coordinate of the region
370
+ attr_accessor :y
371
+
372
+ # @return [Integer] Width of the region
373
+ attr_accessor :width
374
+
375
+ # @return [Integer] Height of the region
376
+ attr_accessor :height
377
+
378
+ # @param x [Integer] X coordinate of the region
379
+ # @param y [Integer] Y coordinate of the region
380
+ # @param width [Integer] Width of the region
381
+ # @param height [Integer] Height of the region
382
+ def initialize(x:, y:, width:, height:) # rubocop:disable Naming/MethodParameterName
383
+ @x = x
384
+ @y = y
385
+ @width = width
386
+ @height = height
387
+ end
388
+ end
389
+
390
+ # Options for screenshot compression and display.
391
+ class ScreenshotOptions
392
+ # @return [Boolean, nil] Whether to show the cursor in the screenshot
393
+ attr_accessor :show_cursor
394
+
395
+ # @return [String, nil] Image format (e.g., 'png', 'jpeg', 'webp')
396
+ attr_accessor :fmt
397
+
398
+ # @return [Integer, nil] Compression quality (0-100)
399
+ attr_accessor :quality
400
+
401
+ # @return [Float, nil] Scale factor for the screenshot
402
+ attr_accessor :scale
403
+
404
+ # @param show_cursor [Boolean, nil] Whether to show the cursor in the screenshot
405
+ # @param format [String, nil] Image format (e.g., 'png', 'jpeg', 'webp')
406
+ # @param quality [Integer, nil] Compression quality (0-100)
407
+ # @param scale [Float, nil] Scale factor for the screenshot
408
+ def initialize(show_cursor: nil, format: nil, quality: nil, scale: nil)
409
+ @show_cursor = show_cursor
410
+ @fmt = format
411
+ @quality = quality
412
+ @scale = scale
413
+ end
414
+ end
415
+
416
+ # @return [String] The ID of the sandbox
417
+ attr_reader :sandbox_id
418
+
419
+ # @return [DaytonaApiClient::ToolboxApi] API client for sandbox operations
420
+ attr_reader :toolbox_api
421
+
422
+ # @return [Mouse] Mouse operations interface
423
+ attr_reader :mouse
424
+
425
+ # @return [Keyboard] Keyboard operations interface
426
+ attr_reader :keyboard
427
+
428
+ # @return [Screenshot] Screenshot operations interface
429
+ attr_reader :screenshot
430
+
431
+ # @return [Display] Display operations interface
432
+ attr_reader :display
433
+
434
+ # Initialize a new ComputerUse instance.
435
+ #
436
+ # @param sandbox_id [String] The ID of the sandbox
437
+ # @param toolbox_api [DaytonaApiClient::ToolboxApi] API client for sandbox operations
438
+ def initialize(sandbox_id:, toolbox_api:)
439
+ @sandbox_id = sandbox_id
440
+ @toolbox_api = toolbox_api
441
+ @mouse = Mouse.new(sandbox_id:, toolbox_api:)
442
+ @keyboard = Keyboard.new(sandbox_id:, toolbox_api:)
443
+ @screenshot = Screenshot.new(sandbox_id:, toolbox_api:)
444
+ @display = Display.new(sandbox_id:, toolbox_api:)
445
+ end
446
+
447
+ # Starts all computer use processes (Xvfb, xfce4, x11vnc, novnc).
448
+ #
449
+ # @return [DaytonaApiClient::ComputerUseStartResponse] Computer use start response
450
+ # @raise [Daytona::Sdk::Error] If the operation fails
451
+ #
452
+ # @example
453
+ # result = sandbox.computer_use.start
454
+ # puts "Computer use processes started: #{result.message}"
455
+ def start
456
+ toolbox_api.start_computer_use(sandbox_id)
457
+ rescue StandardError => e
458
+ raise Sdk::Error, "Failed to start computer use: #{e.message}"
459
+ end
460
+
461
+ # Stops all computer use processes.
462
+ #
463
+ # @return [DaytonaApiClient::ComputerUseStopResponse] Computer use stop response
464
+ # @raise [Daytona::Sdk::Error] If the operation fails
465
+ #
466
+ # @example
467
+ # result = sandbox.computer_use.stop
468
+ # puts "Computer use processes stopped: #{result.message}"
469
+ def stop
470
+ toolbox_api.stop_computer_use(sandbox_id)
471
+ rescue StandardError => e
472
+ raise Sdk::Error, "Failed to stop computer use: #{e.message}"
473
+ end
474
+
475
+ # Gets the status of all computer use processes.
476
+ #
477
+ # @return [DaytonaApiClient::ComputerUseStatusResponse] Status information about all VNC desktop processes
478
+ # @raise [Daytona::Sdk::Error] If the operation fails
479
+ #
480
+ # @example
481
+ # response = sandbox.computer_use.get_status
482
+ # puts "Computer use status: #{response.status}"
483
+ def status
484
+ toolbox_api.get_computer_use_status(sandbox_id)
485
+ rescue StandardError => e
486
+ raise Sdk::Error, "Failed to get computer use status: #{e.message}"
487
+ end
488
+
489
+ # Gets the status of a specific VNC process.
490
+ #
491
+ # @param process_name [String] Name of the process to check
492
+ # @return [DaytonaApiClient::ProcessStatusResponse] Status information about the specific process
493
+ # @raise [Daytona::Sdk::Error] If the operation fails
494
+ #
495
+ # @example
496
+ # xvfb_status = sandbox.computer_use.get_process_status("xvfb")
497
+ # no_vnc_status = sandbox.computer_use.get_process_status("novnc")
498
+ def get_process_status(process_name:)
499
+ toolbox_api.get_process_status(process_name, sandbox_id)
500
+ rescue StandardError => e
501
+ raise Sdk::Error, "Failed to get process status: #{e.message}"
502
+ end
503
+
504
+ # Restarts a specific VNC process.
505
+ #
506
+ # @param process_name [String] Name of the process to restart
507
+ # @return [DaytonaApiClient::ProcessRestartResponse] Process restart response
508
+ # @raise [Daytona::Sdk::Error] If the operation fails
509
+ #
510
+ # @example
511
+ # result = sandbox.computer_use.restart_process("xfce4")
512
+ # puts "XFCE4 process restarted: #{result.message}"
513
+ def restart_process(process_name:)
514
+ toolbox_api.restart_process(process_name, sandbox_id)
515
+ rescue StandardError => e
516
+ raise Sdk::Error, "Failed to restart process: #{e.message}"
517
+ end
518
+
519
+ # Gets logs for a specific VNC process.
520
+ #
521
+ # @param process_name [String] Name of the process to get logs for
522
+ # @return [DaytonaApiClient::ProcessLogsResponse] Process logs
523
+ # @raise [Daytona::Sdk::Error] If the operation fails
524
+ #
525
+ # @example
526
+ # logs = sandbox.computer_use.get_process_logs("novnc")
527
+ # puts "NoVNC logs: #{logs}"
528
+ def get_process_logs(process_name:)
529
+ toolbox_api.get_process_logs(process_name, sandbox_id)
530
+ rescue StandardError => e
531
+ raise Sdk::Error, "Failed to get process logs: #{e.message}"
532
+ end
533
+
534
+ # Gets error logs for a specific VNC process.
535
+ #
536
+ # @param process_name [String] Name of the process to get error logs for
537
+ # @return [DaytonaApiClient::ProcessErrorsResponse] Process error logs
538
+ # @raise [Daytona::Sdk::Error] If the operation fails
539
+ #
540
+ # @example
541
+ # errors = sandbox.computer_use.get_process_errors("x11vnc")
542
+ # puts "X11VNC errors: #{errors}"
543
+ def get_process_errors(process_name:)
544
+ toolbox_api.get_process_errors(process_name, sandbox_id)
545
+ rescue StandardError => e
546
+ raise Sdk::Error, "Failed to get process errors: #{e.message}"
547
+ end
548
+ end
549
+ end
@@ -0,0 +1,53 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Daytona
4
+ class Config
5
+ API_URL = 'https://app.daytona.io/api'
6
+
7
+ # API key for authentication with the Daytona API
8
+ #
9
+ # @return [String, nil] Daytona API key
10
+ attr_accessor :api_key
11
+
12
+ # JWT token for authentication with the Daytona API
13
+ #
14
+ # @return [String, nil] Daytona JWT token
15
+ attr_accessor :jwt_token
16
+
17
+ # URL of the Daytona API
18
+ #
19
+ # @return [String, nil] Daytona API URL
20
+ attr_accessor :api_url
21
+
22
+ # Organization ID for authentication with the Daytona API
23
+ #
24
+ # @return [String, nil] Daytona API URL
25
+ attr_accessor :organization_id
26
+
27
+ # Target environment for sandboxes
28
+ #
29
+ # @return [String, nil] Daytona target
30
+ attr_accessor :target
31
+
32
+ # Initializes a new Daytona::Config object.
33
+ #
34
+ # @param api_key [String, nil] Daytona API key. Defaults to ENV['DAYTONA_API_KEY'].
35
+ # @param jwt_token [String, nil] Daytona JWT token. Defaults to ENV['DAYTONA_JWT_TOKEN'].
36
+ # @param api_url [String, nil] Daytona API URL. Defaults to ENV['DAYTONA_API_URL'] or Daytona::Config::API_URL.
37
+ # @param organization_id [String, nil] Daytona organization ID. Defaults to ENV['DAYTONA_ORGANIZATION_ID'].
38
+ # @param target [String, nil] Daytona target. Defaults to ENV['DAYTONA_TARGET'].
39
+ def initialize(
40
+ api_key: ENV.fetch('DAYTONA_API_KEY', nil),
41
+ jwt_token: ENV.fetch('DAYTONA_JWT_TOKEN', nil),
42
+ api_url: ENV.fetch('DAYTONA_API_URL', API_URL),
43
+ organization_id: ENV.fetch('DAYTONA_ORGANIZATION_ID', nil),
44
+ target: ENV.fetch('DAYTONA_TARGET', nil)
45
+ )
46
+ @api_key = api_key
47
+ @jwt_token = jwt_token
48
+ @api_url = api_url
49
+ @target = target
50
+ @organization_id = organization_id
51
+ end
52
+ end
53
+ end