daytona 0.187.0 → 0.190.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 +4 -4
- data/README.md +1 -5
- data/lib/daytona/common/daytona.rb +9 -0
- data/lib/daytona/daytona.rb +1 -0
- data/lib/daytona/sandbox.rb +49 -5
- data/lib/daytona/sdk/version.rb +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c5a09af353abfbdd5b5c009623bef2f7a64425bd395eced9c5a627c0651344db
|
|
4
|
+
data.tar.gz: 50f26532c3cacc562908d48ad153149de86c8e72891baa275cb20e648df2119c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e1869e71f8fa6660bb6ed44e60febf46d066d2035433c54b08f32519fffae820e96f828ed056db8999acca657bdb8fb434786e676cb2418b211880e4cb0ba47d
|
|
7
|
+
data.tar.gz: 8638d509c60de3ebf6943b0563f96209f9fd77284816aaece42506af4e9bd6d35e5815bbba5d8945618d379e946dd3727d2289be5fe7c1b715d5dc3eb383451e
|
data/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Daytona Ruby SDK
|
|
2
2
|
|
|
3
|
-
The official Ruby SDK for [Daytona](https://daytona.io),
|
|
3
|
+
The official Ruby SDK for [Daytona](https://daytona.io), a secure and elastic infrastructure for running AI-generated code. Daytona provides full composable computers — [sandboxes](https://www.daytona.io/docs/en/sandboxes/) — that you can manage programmatically using the Daytona SDK.
|
|
4
4
|
|
|
5
5
|
The SDK provides an interface for sandbox management, file system operations, Git operations, language server protocol support, process and code execution, and computer use. For more information, see the [documentation](https://www.daytona.io/docs/en/ruby-sdk/).
|
|
6
6
|
|
|
@@ -182,7 +182,3 @@ completions = lsp_server.completions(
|
|
|
182
182
|
position: Daytona::LspServer::Position.new(line: 10, character: 15)
|
|
183
183
|
)
|
|
184
184
|
```
|
|
185
|
-
|
|
186
|
-
## Contributing
|
|
187
|
-
|
|
188
|
-
Daytona is Open Source under the [Apache License 2.0](https://github.com/daytonaio/daytona/blob/main/libs/sdk-ruby/LICENSE), and is the [copyright of its contributors](https://github.com/daytonaio/daytona/blob/main/NOTICE). If you would like to contribute to the software, read the Developer Certificate of Origin Version 1.1 (https://developercertificate.org/). Afterwards, navigate to the [contributing guide](../../CONTRIBUTING.md) to get started.
|
|
@@ -43,6 +43,9 @@ module Daytona
|
|
|
43
43
|
# @return [String, nil] Comma-separated list of allowed CIDR network addresses for the Sandbox
|
|
44
44
|
attr_accessor :network_allow_list
|
|
45
45
|
|
|
46
|
+
# @return [String, nil] Comma-separated list of allowed domains for the Sandbox
|
|
47
|
+
attr_accessor :domain_allow_list
|
|
48
|
+
|
|
46
49
|
# @return [Boolean, nil] Whether the Sandbox should be ephemeral
|
|
47
50
|
attr_accessor :ephemeral
|
|
48
51
|
|
|
@@ -66,6 +69,7 @@ module Daytona
|
|
|
66
69
|
# @param volumes [Array<DaytonaApiClient::SandboxVolume>, nil] List of volumes mounts to attach to the Sandbox
|
|
67
70
|
# @param network_block_all [Boolean, nil] Whether to block all network access for the Sandbox
|
|
68
71
|
# @param network_allow_list [String, nil] Comma-separated list of allowed CIDR network addresses for the Sandbox
|
|
72
|
+
# @param domain_allow_list [String, nil] Comma-separated list of allowed domains for the Sandbox
|
|
69
73
|
# @param ephemeral [Boolean, nil] Whether the Sandbox should be ephemeral
|
|
70
74
|
# @param linked_sandbox [String, nil] ID or name of an existing Sandbox to link the new Sandbox to
|
|
71
75
|
def initialize( # rubocop:disable Metrics/MethodLength, Metrics/ParameterLists
|
|
@@ -81,6 +85,7 @@ module Daytona
|
|
|
81
85
|
volumes: nil,
|
|
82
86
|
network_block_all: nil,
|
|
83
87
|
network_allow_list: nil,
|
|
88
|
+
domain_allow_list: nil,
|
|
84
89
|
ephemeral: nil,
|
|
85
90
|
linked_sandbox: nil
|
|
86
91
|
)
|
|
@@ -96,6 +101,7 @@ module Daytona
|
|
|
96
101
|
@volumes = volumes
|
|
97
102
|
@network_block_all = network_block_all
|
|
98
103
|
@network_allow_list = network_allow_list
|
|
104
|
+
@domain_allow_list = domain_allow_list
|
|
99
105
|
@ephemeral = ephemeral
|
|
100
106
|
@linked_sandbox = linked_sandbox
|
|
101
107
|
|
|
@@ -120,6 +126,7 @@ module Daytona
|
|
|
120
126
|
volumes:,
|
|
121
127
|
network_block_all:,
|
|
122
128
|
network_allow_list:,
|
|
129
|
+
domain_allow_list:,
|
|
123
130
|
ephemeral:,
|
|
124
131
|
linked_sandbox:
|
|
125
132
|
}.compact
|
|
@@ -166,6 +173,7 @@ module Daytona
|
|
|
166
173
|
# @param volumes [Array<DaytonaApiClient::SandboxVolume>, nil] List of volumes mounts to attach to the Sandbox
|
|
167
174
|
# @param network_block_all [Boolean, nil] Whether to block all network access for the Sandbox
|
|
168
175
|
# @param network_allow_list [String, nil] Comma-separated list of allowed CIDR network addresses for the Sandbox
|
|
176
|
+
# @param domain_allow_list [String, nil] Comma-separated list of allowed domains for the Sandbox
|
|
169
177
|
# @param ephemeral [Boolean, nil] Whether the Sandbox should be ephemeral
|
|
170
178
|
def initialize(image:, resources: nil, **args)
|
|
171
179
|
@image = image
|
|
@@ -204,6 +212,7 @@ module Daytona
|
|
|
204
212
|
# @param volumes [Array<DaytonaApiClient::SandboxVolume>, nil] List of volumes mounts to attach to the Sandbox
|
|
205
213
|
# @param network_block_all [Boolean, nil] Whether to block all network access for the Sandbox
|
|
206
214
|
# @param network_allow_list [String, nil] Comma-separated list of allowed CIDR network addresses for the Sandbox
|
|
215
|
+
# @param domain_allow_list [String, nil] Comma-separated list of allowed domains for the Sandbox
|
|
207
216
|
# @param ephemeral [Boolean, nil] Whether the Sandbox should be ephemeral
|
|
208
217
|
def initialize(snapshot: nil, **args)
|
|
209
218
|
@snapshot = snapshot
|
data/lib/daytona/daytona.rb
CHANGED
data/lib/daytona/sandbox.rb
CHANGED
|
@@ -41,6 +41,10 @@ module Daytona
|
|
|
41
41
|
# Not returned by list results; call #refresh on each item to populate.
|
|
42
42
|
attr_reader :network_allow_list
|
|
43
43
|
|
|
44
|
+
# @return [String, nil] Comma-separated list of allowed domains for the sandbox.
|
|
45
|
+
# Not returned by list results; call #refresh on each item to populate.
|
|
46
|
+
attr_reader :domain_allow_list
|
|
47
|
+
|
|
44
48
|
# @return [String] The target environment for the sandbox
|
|
45
49
|
attr_reader :target
|
|
46
50
|
|
|
@@ -216,21 +220,24 @@ module Daytona
|
|
|
216
220
|
#
|
|
217
221
|
# @param network_block_all [Boolean, nil]
|
|
218
222
|
# @param network_allow_list [String, nil]
|
|
223
|
+
# @param domain_allow_list [String, nil]
|
|
219
224
|
# @return [void]
|
|
220
225
|
# @raise [Daytona::Sdk::Error]
|
|
221
|
-
def update_network_settings(network_block_all: nil, network_allow_list: nil)
|
|
222
|
-
if network_block_all.nil? && network_allow_list.nil?
|
|
226
|
+
def update_network_settings(network_block_all: nil, network_allow_list: nil, domain_allow_list: nil)
|
|
227
|
+
if network_block_all.nil? && network_allow_list.nil? && domain_allow_list.nil?
|
|
223
228
|
raise Sdk::Error,
|
|
224
|
-
'At least one of network_block_all or
|
|
229
|
+
'At least one of network_block_all, network_allow_list or domain_allow_list must be provided'
|
|
225
230
|
end
|
|
226
231
|
|
|
227
232
|
body = DaytonaApiClient::UpdateSandboxNetworkSettings.new(
|
|
228
233
|
network_block_all:,
|
|
229
|
-
network_allow_list
|
|
234
|
+
network_allow_list:,
|
|
235
|
+
domain_allow_list:
|
|
230
236
|
)
|
|
231
237
|
data = sandbox_api.update_network_settings(id, body)
|
|
232
238
|
@network_block_all = data.network_block_all
|
|
233
239
|
@network_allow_list = data.network_allow_list
|
|
240
|
+
@domain_allow_list = data.domain_allow_list
|
|
234
241
|
end
|
|
235
242
|
|
|
236
243
|
# Sets the auto-stop interval for the Sandbox.
|
|
@@ -546,6 +553,22 @@ module Daytona
|
|
|
546
553
|
) { wait_for_snapshot_complete }
|
|
547
554
|
end
|
|
548
555
|
|
|
556
|
+
# Pauses the Sandbox, freezing all running processes.
|
|
557
|
+
# The Sandbox will enter a 'pausing' state and transition to 'paused' when complete.
|
|
558
|
+
#
|
|
559
|
+
# @param timeout [Numeric] Maximum wait time in seconds (defaults to 60 s)
|
|
560
|
+
# @return [void]
|
|
561
|
+
def pause(timeout: DEFAULT_TIMEOUT)
|
|
562
|
+
with_timeout(
|
|
563
|
+
timeout:,
|
|
564
|
+
message: "Sandbox #{id} failed to pause within the #{timeout} seconds timeout period",
|
|
565
|
+
setup: proc {
|
|
566
|
+
sandbox_api.pause_sandbox(id)
|
|
567
|
+
refresh
|
|
568
|
+
}
|
|
569
|
+
) { wait_for_pause_complete }
|
|
570
|
+
end
|
|
571
|
+
|
|
549
572
|
instrument :archive, :auto_archive_interval=, :auto_delete_interval=, :auto_stop_interval=,
|
|
550
573
|
:update_network_settings,
|
|
551
574
|
:create_ssh_access, :delete, :get_user_home_dir, :get_work_dir, :labels=,
|
|
@@ -553,7 +576,7 @@ module Daytona
|
|
|
553
576
|
:refresh, :refresh_activity, :revoke_ssh_access, :start, :recover, :stop,
|
|
554
577
|
:create_lsp_server, :validate_ssh_access, :wait_for_sandbox_start,
|
|
555
578
|
:wait_for_sandbox_stop, :resize, :wait_for_resize_complete,
|
|
556
|
-
:experimental_fork, :experimental_create_snapshot,
|
|
579
|
+
:experimental_fork, :experimental_create_snapshot, :pause,
|
|
557
580
|
component: 'Sandbox'
|
|
558
581
|
|
|
559
582
|
private
|
|
@@ -613,6 +636,7 @@ module Daytona
|
|
|
613
636
|
@env = sandbox_dto.env
|
|
614
637
|
@network_block_all = sandbox_dto.network_block_all
|
|
615
638
|
@network_allow_list = sandbox_dto.network_allow_list
|
|
639
|
+
@domain_allow_list = sandbox_dto.domain_allow_list
|
|
616
640
|
@volumes = sandbox_dto.volumes
|
|
617
641
|
@build_info = sandbox_dto.build_info
|
|
618
642
|
@backup_created_at = sandbox_dto.backup_created_at
|
|
@@ -703,5 +727,25 @@ module Daytona
|
|
|
703
727
|
end
|
|
704
728
|
end
|
|
705
729
|
end
|
|
730
|
+
|
|
731
|
+
def wait_for_pause_complete
|
|
732
|
+
interval = INITIAL_POLL_INTERVAL
|
|
733
|
+
start_time = ::Process.clock_gettime(::Process::CLOCK_MONOTONIC)
|
|
734
|
+
while state == DaytonaApiClient::SandboxState::PAUSING
|
|
735
|
+
refresh
|
|
736
|
+
|
|
737
|
+
if [DaytonaApiClient::SandboxState::ERROR, DaytonaApiClient::SandboxState::BUILD_FAILED].include?(state)
|
|
738
|
+
raise Sdk::Error,
|
|
739
|
+
"Sandbox #{id} pause failed with state: #{state}, error reason: #{error_reason}"
|
|
740
|
+
end
|
|
741
|
+
|
|
742
|
+
break if state != DaytonaApiClient::SandboxState::PAUSING
|
|
743
|
+
|
|
744
|
+
sleep(interval)
|
|
745
|
+
if ::Process.clock_gettime(::Process::CLOCK_MONOTONIC) - start_time > 5
|
|
746
|
+
interval = [interval * BACKOFF_MULTIPLIER, MAX_POLL_INTERVAL].min
|
|
747
|
+
end
|
|
748
|
+
end
|
|
749
|
+
end
|
|
706
750
|
end
|
|
707
751
|
end
|
data/lib/daytona/sdk/version.rb
CHANGED
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.
|
|
4
|
+
version: 0.190.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Daytona Platforms Inc.
|
|
@@ -85,28 +85,28 @@ dependencies:
|
|
|
85
85
|
requirements:
|
|
86
86
|
- - '='
|
|
87
87
|
- !ruby/object:Gem::Version
|
|
88
|
-
version: 0.
|
|
88
|
+
version: 0.190.0
|
|
89
89
|
type: :runtime
|
|
90
90
|
prerelease: false
|
|
91
91
|
version_requirements: !ruby/object:Gem::Requirement
|
|
92
92
|
requirements:
|
|
93
93
|
- - '='
|
|
94
94
|
- !ruby/object:Gem::Version
|
|
95
|
-
version: 0.
|
|
95
|
+
version: 0.190.0
|
|
96
96
|
- !ruby/object:Gem::Dependency
|
|
97
97
|
name: daytona_toolbox_api_client
|
|
98
98
|
requirement: !ruby/object:Gem::Requirement
|
|
99
99
|
requirements:
|
|
100
100
|
- - '='
|
|
101
101
|
- !ruby/object:Gem::Version
|
|
102
|
-
version: 0.
|
|
102
|
+
version: 0.190.0
|
|
103
103
|
type: :runtime
|
|
104
104
|
prerelease: false
|
|
105
105
|
version_requirements: !ruby/object:Gem::Requirement
|
|
106
106
|
requirements:
|
|
107
107
|
- - '='
|
|
108
108
|
- !ruby/object:Gem::Version
|
|
109
|
-
version: 0.
|
|
109
|
+
version: 0.190.0
|
|
110
110
|
- !ruby/object:Gem::Dependency
|
|
111
111
|
name: dotenv
|
|
112
112
|
requirement: !ruby/object:Gem::Requirement
|