daytona 0.184.0.alpha.1 → 0.184.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: 51f6c85ff29165b3645e8752fede62f4f0e006b6bece9cd4541ad90be2960f93
4
- data.tar.gz: 9178ec77c86d9c28f65baa3e0faf76f861f282930259dc2c44f0fbbfd2643a39
3
+ metadata.gz: a915942565b3350f301af5bc17108ed23fd4c17ab2fabf794c55d061f7001b05
4
+ data.tar.gz: b7c4ae7fb09fd196a84b5b63fb06e66300ca16ef30d18f5b87c8026e0aa0366c
5
5
  SHA512:
6
- metadata.gz: d7eb785153c1bbfe977cf0d00823cbcc0937baa52637c20001cab8237035dcb8c2a18fb2458f8fda6a1bc292a5fb1bec73d9af6853944205176713cb2438dfb8
7
- data.tar.gz: 5883ceea8ae8d4ab9e593f4a55b31df562afce803d0119ed71f4958bc53d82b1ca73a3e64152b5c200c165597b64cd1933bbc9169d33cf25cf5b6dd3cc643850
6
+ metadata.gz: a849bfb163dbd2ec05b7fbc152877d702195526bf28c1c74e3da19b79d454d338deed08f4bc503998594ba65549f1b7960af64383bc6da67402751faebd09d45
7
+ data.tar.gz: 7769c3074cda40aad265165e41755e6e6de16144a36b1bbc1e739f8b3e5b9c20d0d57c4eec20dccaa97322b412068c663f3d86f2ecf1514c3cb18aceb39337c7
@@ -232,8 +232,8 @@ module Daytona
232
232
  def create_context(cwd: nil)
233
233
  request = DaytonaToolboxApiClient::CreateContextRequest.new(cwd:)
234
234
  @toolbox_api.create_interpreter_context(request)
235
- rescue *Sdk::API_ERROR_CLASSES => e
236
- raise Sdk.wrap_error(e, 'Failed to create interpreter context')
235
+ rescue StandardError => e
236
+ raise Sdk::Error, "Failed to create interpreter context: #{e.message}"
237
237
  end
238
238
 
239
239
  # List all user-created interpreter contexts.
@@ -252,8 +252,8 @@ module Daytona
252
252
  def list_contexts
253
253
  response = @toolbox_api.list_interpreter_contexts
254
254
  response.contexts || []
255
- rescue *Sdk::API_ERROR_CLASSES => e
256
- raise Sdk.wrap_error(e, 'Failed to list interpreter contexts')
255
+ rescue StandardError => e
256
+ raise Sdk::Error, "Failed to list interpreter contexts: #{e.message}"
257
257
  end
258
258
 
259
259
  # Delete an interpreter context and shut down all associated processes.
@@ -272,8 +272,8 @@ module Daytona
272
272
  def delete_context(context)
273
273
  @toolbox_api.delete_interpreter_context(context.id)
274
274
  nil
275
- rescue *Sdk::API_ERROR_CLASSES => e
276
- raise Sdk.wrap_error(e, 'Failed to delete interpreter context')
275
+ rescue StandardError => e
276
+ raise Sdk::Error, "Failed to delete interpreter context: #{e.message}"
277
277
  end
278
278
 
279
279
  instrument :run_code, :create_context, :list_contexts, :delete_context,
@@ -46,6 +46,12 @@ module Daytona
46
46
  # @return [Boolean, nil] Whether the Sandbox should be ephemeral
47
47
  attr_accessor :ephemeral
48
48
 
49
+ # @return [String, nil] ID or name of an existing Sandbox to link the new Sandbox to. The new
50
+ # Sandbox will be scheduled on the same runner as the linked Sandbox so a local network can be
51
+ # established between them. Linked Sandboxes must be
52
+ # ephemeral (auto_delete_interval=0) and cannot themselves be linked to another Sandbox.
53
+ attr_accessor :linked_sandbox
54
+
49
55
  # Initialize CreateSandboxBaseParams
50
56
  #
51
57
  # @param language [Symbol, nil] Programming language for the Sandbox
@@ -61,6 +67,7 @@ module Daytona
61
67
  # @param network_block_all [Boolean, nil] Whether to block all network access for the Sandbox
62
68
  # @param network_allow_list [String, nil] Comma-separated list of allowed CIDR network addresses for the Sandbox
63
69
  # @param ephemeral [Boolean, nil] Whether the Sandbox should be ephemeral
70
+ # @param linked_sandbox [String, nil] ID or name of an existing Sandbox to link the new Sandbox to
64
71
  def initialize( # rubocop:disable Metrics/MethodLength, Metrics/ParameterLists
65
72
  language: nil,
66
73
  os_user: nil,
@@ -74,7 +81,8 @@ module Daytona
74
81
  volumes: nil,
75
82
  network_block_all: nil,
76
83
  network_allow_list: nil,
77
- ephemeral: nil
84
+ ephemeral: nil,
85
+ linked_sandbox: nil
78
86
  )
79
87
  @language = language
80
88
  @os_user = os_user
@@ -89,6 +97,7 @@ module Daytona
89
97
  @network_block_all = network_block_all
90
98
  @network_allow_list = network_allow_list
91
99
  @ephemeral = ephemeral
100
+ @linked_sandbox = linked_sandbox
92
101
 
93
102
  # Handle ephemeral and auto_delete_interval conflict
94
103
  handle_ephemeral_auto_delete_conflict
@@ -111,7 +120,8 @@ module Daytona
111
120
  volumes:,
112
121
  network_block_all:,
113
122
  network_allow_list:,
114
- ephemeral:
123
+ ephemeral:,
124
+ linked_sandbox:
115
125
  }.compact
116
126
  end
117
127
 
@@ -17,18 +17,23 @@ module Daytona
17
17
  # @return [Integer, nil] Number of GPUs to allocate
18
18
  attr_reader :gpu
19
19
 
20
+ # @return [String, Array<String>, nil] Preferred GPU type for the Sandbox
21
+ attr_reader :gpu_type
22
+
20
23
  # @param cpu [Integer, nil] Number of CPU cores to allocate
21
24
  # @param memory [Integer, nil] Amount of memory in GiB to allocate
22
25
  # @param disk [Integer, nil] Amount of disk space in GiB to allocate
23
26
  # @param gpu [Integer, nil] Number of GPUs to allocate
24
- def initialize(cpu: nil, memory: nil, disk: nil, gpu: nil)
27
+ # @param gpu_type [String, Array<String>, nil] Preferred GPU type for the Sandbox
28
+ def initialize(cpu: nil, memory: nil, disk: nil, gpu: nil, gpu_type: nil)
25
29
  @cpu = cpu
26
30
  @memory = memory
27
31
  @disk = disk
28
32
  @gpu = gpu
33
+ @gpu_type = gpu_type
29
34
  end
30
35
 
31
36
  # @return [Hash] Hash representation of the resources
32
- def to_h = { cpu:, memory:, disk:, gpu: }.compact
37
+ def to_h = { cpu:, memory:, disk:, gpu:, gpu_type: }.compact
33
38
  end
34
39
  end
@@ -9,6 +9,7 @@ module Daytona
9
9
  SandboxState = DaytonaApiClient::SandboxState
10
10
  SandboxListSortField = DaytonaApiClient::SandboxListSortField
11
11
  SandboxListSortDirection = DaytonaApiClient::SandboxListSortDirection
12
+ GpuType = DaytonaApiClient::GpuType
12
13
 
13
14
  class PaginatedResource
14
15
  # @return [Array<Object>]
@@ -33,8 +33,8 @@ module Daytona
33
33
  # puts "Mouse is at: #{position.x}, #{position.y}"
34
34
  def position
35
35
  toolbox_api.get_mouse_position
36
- rescue *Sdk::API_ERROR_CLASSES => e
37
- raise Sdk.wrap_error(e, 'Failed to get mouse position')
36
+ rescue StandardError => e
37
+ raise Sdk::Error, "Failed to get mouse position: #{e.message}"
38
38
  end
39
39
 
40
40
  # Moves the mouse cursor to the specified coordinates.
@@ -50,8 +50,8 @@ module Daytona
50
50
  def move(x:, y:)
51
51
  request = DaytonaToolboxApiClient::MouseMoveRequest.new(x:, y:)
52
52
  toolbox_api.move_mouse(request)
53
- rescue *Sdk::API_ERROR_CLASSES => e
54
- raise Sdk.wrap_error(e, 'Failed to move mouse')
53
+ rescue StandardError => e
54
+ raise Sdk::Error, "Failed to move mouse: #{e.message}"
55
55
  end
56
56
 
57
57
  # Clicks the mouse at the specified coordinates.
@@ -75,8 +75,8 @@ module Daytona
75
75
  def click(x:, y:, button: 'left', double: false)
76
76
  request = DaytonaToolboxApiClient::MouseClickRequest.new(x:, y:, button:, double:)
77
77
  toolbox_api.click(request)
78
- rescue *Sdk::API_ERROR_CLASSES => e
79
- raise Sdk.wrap_error(e, 'Failed to click mouse')
78
+ rescue StandardError => e
79
+ raise Sdk::Error, "Failed to click mouse: #{e.message}"
80
80
  end
81
81
 
82
82
  # Drags the mouse from start coordinates to end coordinates.
@@ -95,8 +95,8 @@ module Daytona
95
95
  def drag(start_x:, start_y:, end_x:, end_y:, button: 'left')
96
96
  request = DaytonaToolboxApiClient::MouseDragRequest.new(start_x:, start_y:, end_x:, end_y:, button:)
97
97
  toolbox_api.drag(request)
98
- rescue *Sdk::API_ERROR_CLASSES => e
99
- raise Sdk.wrap_error(e, 'Failed to drag mouse')
98
+ rescue StandardError => e
99
+ raise Sdk::Error, "Failed to drag mouse: #{e.message}"
100
100
  end
101
101
 
102
102
  # Scrolls the mouse wheel at the specified coordinates.
@@ -118,8 +118,8 @@ module Daytona
118
118
  request = DaytonaToolboxApiClient::MouseScrollRequest.new(x:, y:, direction:, amount:)
119
119
  toolbox_api.scroll(request)
120
120
  true
121
- rescue *Sdk::API_ERROR_CLASSES => e
122
- raise Sdk.wrap_error(e, 'Failed to scroll mouse')
121
+ rescue StandardError => e
122
+ raise Sdk::Error, "Failed to scroll mouse: #{e.message}"
123
123
  end
124
124
 
125
125
  instrument :position, :move, :click, :drag, :scroll, component: 'Mouse'
@@ -164,8 +164,8 @@ module Daytona
164
164
  def type(text:, delay: nil)
165
165
  request = DaytonaToolboxApiClient::KeyboardTypeRequest.new(text:, delay:)
166
166
  toolbox_api.type_text(request)
167
- rescue *Sdk::API_ERROR_CLASSES => e
168
- raise Sdk.wrap_error(e, 'Failed to type text')
167
+ rescue StandardError => e
168
+ raise Sdk::Error, "Failed to type text: #{e.message}"
169
169
  end
170
170
 
171
171
  # Presses a key with optional modifiers.
@@ -187,8 +187,8 @@ module Daytona
187
187
  def press(key:, modifiers: nil)
188
188
  request = DaytonaToolboxApiClient::KeyboardPressRequest.new(key:, modifiers: modifiers || [])
189
189
  toolbox_api.press_key(request)
190
- rescue *Sdk::API_ERROR_CLASSES => e
191
- raise Sdk.wrap_error(e, 'Failed to press key')
190
+ rescue StandardError => e
191
+ raise Sdk::Error, "Failed to press key: #{e.message}"
192
192
  end
193
193
 
194
194
  # Presses a hotkey combination.
@@ -209,8 +209,8 @@ module Daytona
209
209
  def hotkey(keys:)
210
210
  request = DaytonaToolboxApiClient::KeyboardHotkeyRequest.new(keys:)
211
211
  toolbox_api.press_hotkey(request)
212
- rescue *Sdk::API_ERROR_CLASSES => e
213
- raise Sdk.wrap_error(e, 'Failed to press hotkey')
212
+ rescue StandardError => e
213
+ raise Sdk::Error, "Failed to press hotkey: #{e.message}"
214
214
  end
215
215
 
216
216
  instrument :type, :press, :hotkey, component: 'Keyboard'
@@ -254,8 +254,8 @@ module Daytona
254
254
  # with_cursor = sandbox.computer_use.screenshot.take_full_screen(show_cursor: true)
255
255
  def take_full_screen(show_cursor: false)
256
256
  toolbox_api.take_screenshot(show_cursor:)
257
- rescue *Sdk::API_ERROR_CLASSES => e
258
- raise Sdk.wrap_error(e, 'Failed to take screenshot')
257
+ rescue StandardError => e
258
+ raise Sdk::Error, "Failed to take screenshot: #{e.message}"
259
259
  end
260
260
 
261
261
  # Takes a screenshot of a specific region.
@@ -271,8 +271,8 @@ module Daytona
271
271
  # puts "Captured region: #{screenshot.region.width}x#{screenshot.region.height}"
272
272
  def take_region(region:, show_cursor: false)
273
273
  toolbox_api.take_region_screenshot(region.height, region.width, region.y, region.x, show_cursor:)
274
- rescue *Sdk::API_ERROR_CLASSES => e
275
- raise Sdk.wrap_error(e, 'Failed to take region screenshot')
274
+ rescue StandardError => e
275
+ raise Sdk::Error, "Failed to take region screenshot: #{e.message}"
276
276
  end
277
277
 
278
278
  # Takes a compressed screenshot of the entire screen.
@@ -303,8 +303,8 @@ module Daytona
303
303
  format: options.fmt,
304
304
  show_cursor: options.show_cursor
305
305
  )
306
- rescue *Sdk::API_ERROR_CLASSES => e
307
- raise Sdk.wrap_error(e, 'Failed to take compressed screenshot')
306
+ rescue StandardError => e
307
+ raise Sdk::Error, "Failed to take compressed screenshot: #{e.message}"
308
308
  end
309
309
 
310
310
  # Takes a compressed screenshot of a specific region.
@@ -334,8 +334,8 @@ module Daytona
334
334
  format: options.fmt,
335
335
  show_cursor: options.show_cursor
336
336
  )
337
- rescue *Sdk::API_ERROR_CLASSES => e
338
- raise Sdk.wrap_error(e, 'Failed to take compressed region screenshot')
337
+ rescue StandardError => e
338
+ raise Sdk::Error, "Failed to take compressed region screenshot: #{e.message}"
339
339
  end
340
340
 
341
341
  instrument :take_full_screen, :take_region, :take_compressed, :take_compressed_region,
@@ -380,8 +380,8 @@ module Daytona
380
380
  # end
381
381
  def info
382
382
  toolbox_api.get_display_info
383
- rescue *Sdk::API_ERROR_CLASSES => e
384
- raise Sdk.wrap_error(e, 'Failed to get display info')
383
+ rescue StandardError => e
384
+ raise Sdk::Error, "Failed to get display info: #{e.message}"
385
385
  end
386
386
 
387
387
  # Gets the list of open windows.
@@ -397,8 +397,8 @@ module Daytona
397
397
  # end
398
398
  def windows
399
399
  toolbox_api.get_windows
400
- rescue *Sdk::API_ERROR_CLASSES => e
401
- raise Sdk.wrap_error(e, 'Failed to get windows')
400
+ rescue StandardError => e
401
+ raise Sdk::Error, "Failed to get windows: #{e.message}"
402
402
  end
403
403
 
404
404
  instrument :info, :windows, component: 'Display'
@@ -446,8 +446,8 @@ module Daytona
446
446
  opts[:max_depth] = max_depth unless max_depth.nil?
447
447
 
448
448
  toolbox_api.get_accessibility_tree(opts)
449
- rescue *Sdk::API_ERROR_CLASSES => e
450
- raise Sdk.wrap_error(e, 'Failed to get accessibility tree')
449
+ rescue StandardError => e
450
+ raise Sdk::Error, "Failed to get accessibility tree: #{e.message}"
451
451
  end
452
452
 
453
453
  # Finds AT-SPI accessibility nodes matching the provided filters.
@@ -482,8 +482,8 @@ module Daytona
482
482
 
483
483
  request = DaytonaToolboxApiClient::FindAccessibilityNodesRequest.new(attrs)
484
484
  toolbox_api.find_accessibility_nodes(request)
485
- rescue *Sdk::API_ERROR_CLASSES => e
486
- raise Sdk.wrap_error(e, 'Failed to find accessibility nodes')
485
+ rescue StandardError => e
486
+ raise Sdk::Error, "Failed to find accessibility nodes: #{e.message}"
487
487
  end
488
488
 
489
489
  # Focuses an AT-SPI accessibility node.
@@ -496,8 +496,8 @@ module Daytona
496
496
  def focus_node(id:)
497
497
  request = DaytonaToolboxApiClient::AccessibilityNodeRequest.new(id:)
498
498
  toolbox_api.focus_accessibility_node(request)
499
- rescue *Sdk::API_ERROR_CLASSES => e
500
- raise Sdk.wrap_error(e, 'Failed to focus accessibility node')
499
+ rescue StandardError => e
500
+ raise Sdk::Error, "Failed to focus accessibility node: #{e.message}"
501
501
  end
502
502
 
503
503
  # Invokes an AT-SPI accessibility node action.
@@ -514,8 +514,8 @@ module Daytona
514
514
 
515
515
  request = DaytonaToolboxApiClient::AccessibilityInvokeRequest.new(attrs)
516
516
  toolbox_api.invoke_accessibility_node(request)
517
- rescue *Sdk::API_ERROR_CLASSES => e
518
- raise Sdk.wrap_error(e, 'Failed to invoke accessibility node')
517
+ rescue StandardError => e
518
+ raise Sdk::Error, "Failed to invoke accessibility node: #{e.message}"
519
519
  end
520
520
 
521
521
  # Sets an AT-SPI accessibility node value.
@@ -529,8 +529,8 @@ module Daytona
529
529
  def set_node_value(id:, value:)
530
530
  request = DaytonaToolboxApiClient::AccessibilitySetValueRequest.new(id:, value:)
531
531
  toolbox_api.set_accessibility_node_value(request)
532
- rescue *Sdk::API_ERROR_CLASSES => e
533
- raise Sdk.wrap_error(e, 'Failed to set accessibility node value')
532
+ rescue StandardError => e
533
+ raise Sdk::Error, "Failed to set accessibility node value: #{e.message}"
534
534
  end
535
535
 
536
536
  instrument :get_tree, :find_nodes, :focus_node, :invoke_node, :set_node_value,
@@ -627,8 +627,8 @@ module Daytona
627
627
  def start(label: nil)
628
628
  request = DaytonaToolboxApiClient::StartRecordingRequest.new(label:)
629
629
  toolbox_api.start_recording(request: request)
630
- rescue *Sdk::API_ERROR_CLASSES => e
631
- raise Sdk.wrap_error(e, 'Failed to start recording')
630
+ rescue StandardError => e
631
+ raise Sdk::Error, "Failed to start recording: #{e.message}"
632
632
  end
633
633
 
634
634
  # Stops an active screen recording session.
@@ -644,8 +644,8 @@ module Daytona
644
644
  def stop(id:)
645
645
  request = DaytonaToolboxApiClient::StopRecordingRequest.new(id: id)
646
646
  toolbox_api.stop_recording(request)
647
- rescue *Sdk::API_ERROR_CLASSES => e
648
- raise Sdk.wrap_error(e, 'Failed to stop recording')
647
+ rescue StandardError => e
648
+ raise Sdk::Error, "Failed to stop recording: #{e.message}"
649
649
  end
650
650
 
651
651
  # Lists all recordings (active and completed).
@@ -661,8 +661,8 @@ module Daytona
661
661
  # end
662
662
  def list
663
663
  toolbox_api.list_recordings
664
- rescue *Sdk::API_ERROR_CLASSES => e
665
- raise Sdk.wrap_error(e, 'Failed to list recordings')
664
+ rescue StandardError => e
665
+ raise Sdk::Error, "Failed to list recordings: #{e.message}"
666
666
  end
667
667
 
668
668
  # Gets details of a specific recording by ID.
@@ -678,8 +678,8 @@ module Daytona
678
678
  # puts "Duration: #{recording.duration_seconds} seconds"
679
679
  def get(id:)
680
680
  toolbox_api.get_recording(id)
681
- rescue *Sdk::API_ERROR_CLASSES => e
682
- raise Sdk.wrap_error(e, 'Failed to get recording')
681
+ rescue StandardError => e
682
+ raise Sdk::Error, "Failed to get recording: #{e.message}"
683
683
  end
684
684
 
685
685
  # Deletes a recording by ID.
@@ -693,8 +693,8 @@ module Daytona
693
693
  # puts "Recording deleted"
694
694
  def delete(id:)
695
695
  toolbox_api.delete_recording(id)
696
- rescue *Sdk::API_ERROR_CLASSES => e
697
- raise Sdk.wrap_error(e, 'Failed to delete recording')
696
+ rescue StandardError => e
697
+ raise Sdk::Error, "Failed to delete recording: #{e.message}"
698
698
  end
699
699
 
700
700
  # Downloads a recording file and saves it to a local path.
@@ -815,8 +815,8 @@ module Daytona
815
815
  # puts "Computer use processes started: #{result.message}"
816
816
  def start
817
817
  toolbox_api.start_computer_use
818
- rescue *Sdk::API_ERROR_CLASSES => e
819
- raise Sdk.wrap_error(e, 'Failed to start computer use')
818
+ rescue StandardError => e
819
+ raise Sdk::Error, "Failed to start computer use: #{e.message}"
820
820
  end
821
821
 
822
822
  # Stops all computer use processes.
@@ -829,8 +829,8 @@ module Daytona
829
829
  # puts "Computer use processes stopped: #{result.message}"
830
830
  def stop
831
831
  toolbox_api.stop_computer_use
832
- rescue *Sdk::API_ERROR_CLASSES => e
833
- raise Sdk.wrap_error(e, 'Failed to stop computer use')
832
+ rescue StandardError => e
833
+ raise Sdk::Error, "Failed to stop computer use: #{e.message}"
834
834
  end
835
835
 
836
836
  # Gets the status of all computer use processes.
@@ -843,8 +843,8 @@ module Daytona
843
843
  # puts "Computer use status: #{response.status}"
844
844
  def status
845
845
  toolbox_api.get_computer_use_status
846
- rescue *Sdk::API_ERROR_CLASSES => e
847
- raise Sdk.wrap_error(e, 'Failed to get computer use status')
846
+ rescue StandardError => e
847
+ raise Sdk::Error, "Failed to get computer use status: #{e.message}"
848
848
  end
849
849
 
850
850
  # Gets the status of a specific VNC process.
@@ -858,8 +858,8 @@ module Daytona
858
858
  # no_vnc_status = sandbox.computer_use.get_process_status("novnc")
859
859
  def get_process_status(process_name:)
860
860
  toolbox_api.get_process_status(process_name, sandbox_id)
861
- rescue *Sdk::API_ERROR_CLASSES => e
862
- raise Sdk.wrap_error(e, 'Failed to get process status')
861
+ rescue StandardError => e
862
+ raise Sdk::Error, "Failed to get process status: #{e.message}"
863
863
  end
864
864
 
865
865
  # Restarts a specific VNC process.
@@ -873,8 +873,8 @@ module Daytona
873
873
  # puts "XFCE4 process restarted: #{result.message}"
874
874
  def restart_process(process_name:)
875
875
  toolbox_api.restart_process(process_name, sandbox_id)
876
- rescue *Sdk::API_ERROR_CLASSES => e
877
- raise Sdk.wrap_error(e, 'Failed to restart process')
876
+ rescue StandardError => e
877
+ raise Sdk::Error, "Failed to restart process: #{e.message}"
878
878
  end
879
879
 
880
880
  # Gets logs for a specific VNC process.
@@ -888,8 +888,8 @@ module Daytona
888
888
  # puts "NoVNC logs: #{logs}"
889
889
  def get_process_logs(process_name:)
890
890
  toolbox_api.get_process_logs(process_name, sandbox_id)
891
- rescue *Sdk::API_ERROR_CLASSES => e
892
- raise Sdk.wrap_error(e, 'Failed to get process logs')
891
+ rescue StandardError => e
892
+ raise Sdk::Error, "Failed to get process logs: #{e.message}"
893
893
  end
894
894
 
895
895
  # Gets error logs for a specific VNC process.
@@ -903,8 +903,8 @@ module Daytona
903
903
  # puts "X11VNC errors: #{errors}"
904
904
  def get_process_errors(process_name:)
905
905
  toolbox_api.get_process_errors(process_name, sandbox_id)
906
- rescue *Sdk::API_ERROR_CLASSES => e
907
- raise Sdk.wrap_error(e, 'Failed to get process errors')
906
+ rescue StandardError => e
907
+ raise Sdk::Error, "Failed to get process errors: #{e.message}"
908
908
  end
909
909
 
910
910
  instrument :start, :stop, :status, :get_process_status, :restart_process,
@@ -90,12 +90,9 @@ module Daytona
90
90
  #
91
91
  # @param id [String]
92
92
  # @return [Daytona::Sandbox]
93
- # @raise [Daytona::Sdk::Error]
94
93
  def get(id)
95
94
  sandbox_dto = sandbox_api.get_sandbox(id)
96
95
  to_sandbox(sandbox_dto:)
97
- rescue *Sdk::API_ERROR_CLASSES => e
98
- raise Sdk.wrap_error(e, "Failed to get sandbox #{id}")
99
96
  end
100
97
 
101
98
  # Iterates over Sandboxes matching the given query.
@@ -181,8 +178,6 @@ module Daytona
181
178
  }.compact
182
179
 
183
180
  sandbox_api.list_sandboxes(opts)
184
- rescue *Sdk::API_ERROR_CLASSES => e
185
- raise Sdk.wrap_error(e, 'Failed to list sandboxes')
186
181
  end
187
182
 
188
183
  instrument :fetch_sandbox_page, component: 'Daytona.list'
@@ -219,7 +214,8 @@ module Daytona
219
214
  auto_delete_interval: params.auto_delete_interval,
220
215
  volumes: params.volumes,
221
216
  network_block_all: params.network_block_all,
222
- network_allow_list: params.network_allow_list
217
+ network_allow_list: params.network_allow_list,
218
+ linked_sandbox: params.linked_sandbox
223
219
  )
224
220
 
225
221
  create_sandbox.snapshot = params.snapshot if params.respond_to?(:snapshot)
@@ -240,6 +236,10 @@ module Daytona
240
236
  create_sandbox.memory = params.resources&.memory
241
237
  create_sandbox.disk = params.resources&.disk
242
238
  create_sandbox.gpu = params.resources&.gpu
239
+ if params.resources&.gpu_type
240
+ create_sandbox.gpu_type =
241
+ params.resources.gpu_type.is_a?(Array) ? params.resources.gpu_type : [params.resources.gpu_type]
242
+ end
243
243
  end
244
244
 
245
245
  response = sandbox_api.create_sandbox(create_sandbox)
@@ -267,8 +267,6 @@ module Daytona
267
267
  end
268
268
 
269
269
  sandbox
270
- rescue *Sdk::API_ERROR_CLASSES => e
271
- raise Sdk.wrap_error(e, 'Failed to create sandbox')
272
270
  end
273
271
 
274
272
  # @return [void]
@@ -46,8 +46,8 @@ module Daytona
46
46
  def create_folder(path, mode)
47
47
  Sdk.logger.debug("Creating folder #{path} with mode #{mode}")
48
48
  toolbox_api.create_folder(path, mode)
49
- rescue *Sdk::API_ERROR_CLASSES => e
50
- raise Sdk.wrap_error(e, 'Failed to create folder')
49
+ rescue StandardError => e
50
+ raise Sdk::Error, "Failed to create folder: #{e.message}"
51
51
  end
52
52
 
53
53
  # Deletes a file from the Sandbox.
@@ -65,8 +65,8 @@ module Daytona
65
65
  # sandbox.fs.delete_file("workspace/old_dir", recursive: true)
66
66
  def delete_file(path, recursive: false)
67
67
  toolbox_api.delete_file(path, { recursive: })
68
- rescue *Sdk::API_ERROR_CLASSES => e
69
- raise Sdk.wrap_error(e, 'Failed to delete file')
68
+ rescue StandardError => e
69
+ raise Sdk::Error, "Failed to delete file: #{e.message}"
70
70
  end
71
71
 
72
72
  # Gets detailed information about a file or directory, including its
@@ -89,8 +89,8 @@ module Daytona
89
89
  # puts "Path is a directory" if info.is_dir
90
90
  def get_file_info(path)
91
91
  toolbox_api.get_file_info(path)
92
- rescue *Sdk::API_ERROR_CLASSES => e
93
- raise Sdk.wrap_error(e, 'Failed to get file info')
92
+ rescue StandardError => e
93
+ raise Sdk::Error, "Failed to get file info: #{e.message}"
94
94
  end
95
95
 
96
96
  # Lists files and directories in a given path and returns their information, similar to the ls -l command.
@@ -114,8 +114,8 @@ module Daytona
114
114
  # puts "Subdirectories: #{dirs.map(&:name).join(', ')}"
115
115
  def list_files(path)
116
116
  toolbox_api.list_files({ path: })
117
- rescue *Sdk::API_ERROR_CLASSES => e
118
- raise Sdk.wrap_error(e, 'Failed to list files')
117
+ rescue StandardError => e
118
+ raise Sdk::Error, "Failed to list files: #{e.message}"
119
119
  end
120
120
 
121
121
  # Downloads a file from the Sandbox. Returns the file contents as a string.
@@ -150,8 +150,8 @@ module Daytona
150
150
  else
151
151
  file
152
152
  end
153
- rescue *Sdk::API_ERROR_CLASSES => e
154
- raise Sdk.wrap_error(e, 'Failed to download file')
153
+ rescue StandardError => e
154
+ raise Sdk::Error, "Failed to download file: #{e.message}"
155
155
  end
156
156
 
157
157
  # Downloads a single file from the Sandbox as a stream without buffering the entire
@@ -189,8 +189,8 @@ module Daytona
189
189
  timeout: timeout, on_progress: on_progress,
190
190
  cancel_event: cancel_event, &)
191
191
  nil
192
- rescue *Sdk::API_ERROR_CLASSES, Sdk::Error => e
193
- raise Sdk.wrap_error(e, 'Failed to download file')
192
+ rescue StandardError => e
193
+ raise Sdk::Error, "Failed to download file: #{e.message}"
194
194
  end
195
195
 
196
196
  # Uploads a file to the specified path in the Sandbox. If a file already exists at
@@ -229,8 +229,8 @@ module Daytona
229
229
  toolbox_api.upload_file(remote_path, file)
230
230
  end
231
231
  end
232
- rescue *Sdk::API_ERROR_CLASSES => e
233
- raise Sdk.wrap_error(e, 'Failed to upload file')
232
+ rescue StandardError => e
233
+ raise Sdk::Error, "Failed to upload file: #{e.message}"
234
234
  end
235
235
 
236
236
  # Streams +source+ to the Sandbox without buffering its contents in memory, with
@@ -259,8 +259,8 @@ module Daytona
259
259
  FileTransfer.stream_upload(api_client: toolbox_api.api_client, remote_path: remote_path,
260
260
  source: source, timeout: timeout, on_progress: on_progress,
261
261
  cancel_event: cancel_event)
262
- rescue *Sdk::API_ERROR_CLASSES, Sdk::Error => e
263
- raise Sdk.wrap_error(e, 'Failed to upload file')
262
+ rescue StandardError => e
263
+ raise Sdk::Error, "Failed to upload file: #{e.message}"
264
264
  end
265
265
 
266
266
  # Uploads multiple files to the Sandbox. If files already exist at the destination paths,
@@ -280,8 +280,8 @@ module Daytona
280
280
  # sandbox.fs.upload_files(files)
281
281
  def upload_files(files)
282
282
  files.each { |file_upload| upload_file(file_upload.source, file_upload.destination) }
283
- rescue *Sdk::API_ERROR_CLASSES => e
284
- raise Sdk.wrap_error(e, 'Failed to upload files')
283
+ rescue StandardError => e
284
+ raise Sdk::Error, "Failed to upload files: #{e.message}"
285
285
  end
286
286
 
287
287
  # Searches for files containing a pattern, similar to the grep command.
@@ -301,8 +301,8 @@ module Daytona
301
301
  # end
302
302
  def find_files(path, pattern)
303
303
  toolbox_api.find_in_files(path, pattern)
304
- rescue *Sdk::API_ERROR_CLASSES => e
305
- raise Sdk.wrap_error(e, 'Failed to find files')
304
+ rescue StandardError => e
305
+ raise Sdk::Error, "Failed to find files: #{e.message}"
306
306
  end
307
307
 
308
308
  # Searches for files and directories whose names match the specified pattern.
@@ -325,8 +325,8 @@ module Daytona
325
325
  # puts "Found #{result.files.length} test files"
326
326
  def search_files(path, pattern)
327
327
  toolbox_api.search_files(path, pattern)
328
- rescue *Sdk::API_ERROR_CLASSES => e
329
- raise Sdk.wrap_error(e, 'Failed to search files')
328
+ rescue StandardError => e
329
+ raise Sdk::Error, "Failed to search files: #{e.message}"
330
330
  end
331
331
 
332
332
  # Moves or renames a file or directory. The parent directory of the destination must exist.
@@ -358,8 +358,8 @@ module Daytona
358
358
  # )
359
359
  def move_files(source, destination)
360
360
  toolbox_api.move_file(source, destination)
361
- rescue *Sdk::API_ERROR_CLASSES => e
362
- raise Sdk.wrap_error(e, 'Failed to move files')
361
+ rescue StandardError => e
362
+ raise Sdk::Error, "Failed to move files: #{e.message}"
363
363
  end
364
364
 
365
365
  # Performs search and replace operations across multiple files.
@@ -394,8 +394,8 @@ module Daytona
394
394
  new_value: new_value
395
395
  )
396
396
  toolbox_api.replace_in_files(replace_request)
397
- rescue *Sdk::API_ERROR_CLASSES => e
398
- raise Sdk.wrap_error(e, 'Failed to replace in files')
397
+ rescue StandardError => e
398
+ raise Sdk::Error, "Failed to replace in files: #{e.message}"
399
399
  end
400
400
 
401
401
  # Sets permissions and ownership for a file or directory. Any of the parameters can be nil
@@ -429,8 +429,8 @@ module Daytona
429
429
  opts[:group] = group if group
430
430
 
431
431
  toolbox_api.set_file_permissions(path, opts)
432
- rescue *Sdk::API_ERROR_CLASSES => e
433
- raise Sdk.wrap_error(e, 'Failed to set file permissions')
432
+ rescue StandardError => e
433
+ raise Sdk::Error, "Failed to set file permissions: #{e.message}"
434
434
  end
435
435
 
436
436
  instrument :create_folder, :delete_file, :get_file_info, :list_files, :download_file,