daytona 0.152.1 → 0.153.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/lib/daytona/daytona.rb +1 -16
- data/lib/daytona/process.rb +75 -0
- 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: f74008ee993c712a21ad332e5660bd2715bb209582a8fbd3f79001364d9f3b60
|
|
4
|
+
data.tar.gz: 6bfcf0c617c99aae320edf5b22c43e110ab82def2128f886c37e585a9b44f68a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2ab0785429eff6beeabcd6dd833d86257365cb37795e06ca388aa94087bfa67a3821d1630f9cafd78f0698da5468b81035175f147e1a0597356f32a13a48ef16
|
|
7
|
+
data.tar.gz: 4e7131ce5f6d777efa1223e662685b9d3d65cff5d7406d168cdabf6b7d37d0d2af01235e03f8416f093065e16f9fdf1dd07ffd80ef08e098099a1cf638532130
|
data/lib/daytona/daytona.rb
CHANGED
|
@@ -84,21 +84,6 @@ module Daytona
|
|
|
84
84
|
to_sandbox(sandbox_dto:, code_toolbox: code_toolbox_from_labels(sandbox_dto.labels))
|
|
85
85
|
end
|
|
86
86
|
|
|
87
|
-
# Finds a Sandbox by its ID or labels.
|
|
88
|
-
#
|
|
89
|
-
# @param id [String, Nil]
|
|
90
|
-
# @param labels [Hash<String, String>]
|
|
91
|
-
# @return [Daytona::Sandbox]
|
|
92
|
-
# @raise [Daytona::Sdk::Error]
|
|
93
|
-
def find_one(id: nil, labels: nil)
|
|
94
|
-
return get(id) if id
|
|
95
|
-
|
|
96
|
-
response = list(labels)
|
|
97
|
-
raise Sdk::Error, "No sandbox found with labels #{labels}" if response.items.empty?
|
|
98
|
-
|
|
99
|
-
response.items.first
|
|
100
|
-
end
|
|
101
|
-
|
|
102
87
|
# Lists Sandboxes filtered by labels.
|
|
103
88
|
#
|
|
104
89
|
# @param labels [Hash<String, String>]
|
|
@@ -139,7 +124,7 @@ module Daytona
|
|
|
139
124
|
# @return [void]
|
|
140
125
|
def stop(sandbox, timeout = Sandbox::DEFAULT_TIMEOUT) = sandbox.stop(timeout)
|
|
141
126
|
|
|
142
|
-
instrument :create, :delete, :get, :
|
|
127
|
+
instrument :create, :delete, :get, :list, :start, :stop, component: 'Daytona'
|
|
143
128
|
|
|
144
129
|
private
|
|
145
130
|
|
data/lib/daytona/process.rb
CHANGED
|
@@ -128,6 +128,17 @@ module Daytona
|
|
|
128
128
|
# end
|
|
129
129
|
def get_session(session_id) = toolbox_api.get_session(session_id)
|
|
130
130
|
|
|
131
|
+
# Gets the Sandbox entrypoint session
|
|
132
|
+
#
|
|
133
|
+
# @return [DaytonaApiClient::Session] Entrypoint session information including session_id and commands
|
|
134
|
+
#
|
|
135
|
+
# @example
|
|
136
|
+
# session = sandbox.process.get_entrypoint_session()
|
|
137
|
+
# session.commands.each do |cmd|
|
|
138
|
+
# puts "Command: #{cmd.command}"
|
|
139
|
+
# end
|
|
140
|
+
def get_entrypoint_session = toolbox_api.get_entrypoint_session
|
|
141
|
+
|
|
131
142
|
# Gets information about a specific command executed in a session
|
|
132
143
|
#
|
|
133
144
|
# @param session_id [String] Unique identifier of the session
|
|
@@ -263,6 +274,70 @@ module Daytona
|
|
|
263
274
|
completion_queue.pop
|
|
264
275
|
end
|
|
265
276
|
|
|
277
|
+
# Get the sandbox entrypoint logs
|
|
278
|
+
#
|
|
279
|
+
# @return [Daytona::SessionCommandLogsResponse] Entrypoint logs including output, stdout, and stderr
|
|
280
|
+
#
|
|
281
|
+
# @example
|
|
282
|
+
# logs = sandbox.process.get_entrypoint_logs()
|
|
283
|
+
# puts "Command stdout: #{logs.stdout}"
|
|
284
|
+
# puts "Command stderr: #{logs.stderr}"
|
|
285
|
+
def get_entrypoint_logs = parse_session_command_logs(toolbox_api.get_entrypoint_logs)
|
|
286
|
+
|
|
287
|
+
# Asynchronously retrieves and processes the sandbox entrypoint logs as they become available
|
|
288
|
+
#
|
|
289
|
+
# @param on_stdout [Proc] Callback function to handle stdout log chunks as they arrive
|
|
290
|
+
# @param on_stderr [Proc] Callback function to handle stderr log chunks as they arrive
|
|
291
|
+
# @return [WebSocket::Client::Simple::Client]
|
|
292
|
+
#
|
|
293
|
+
# @example
|
|
294
|
+
# sandbox.process.get_entrypoint_logs_async(
|
|
295
|
+
# on_stdout: ->(log) { puts "[STDOUT]: #{log}" },
|
|
296
|
+
# on_stderr: ->(log) { puts "[STDERR]: #{log}" }
|
|
297
|
+
# )
|
|
298
|
+
def get_entrypoint_logs_async(on_stdout:, on_stderr:) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
|
|
299
|
+
preview_link = get_preview_link.call(WS_PORT)
|
|
300
|
+
url = URI.parse(preview_link.url)
|
|
301
|
+
url.scheme = url.scheme == 'https' ? 'wss' : 'ws'
|
|
302
|
+
url.path = '/process/session/entrypoint/logs'
|
|
303
|
+
url.query = 'follow=true'
|
|
304
|
+
|
|
305
|
+
completion_queue = Queue.new
|
|
306
|
+
|
|
307
|
+
ws = WebSocket::Client::Simple.connect(
|
|
308
|
+
url.to_s,
|
|
309
|
+
headers: toolbox_api.api_client.default_headers.dup.merge(
|
|
310
|
+
'X-Daytona-Preview-Token' => preview_link.token,
|
|
311
|
+
'Content-Type' => 'text/plain',
|
|
312
|
+
'Accept' => 'text/plain'
|
|
313
|
+
)
|
|
314
|
+
)
|
|
315
|
+
|
|
316
|
+
ws.on(:message) do |message|
|
|
317
|
+
if message.type == :close
|
|
318
|
+
ws.close
|
|
319
|
+
completion_queue.push(:close)
|
|
320
|
+
else
|
|
321
|
+
stdout, stderr = Util.demux(message.data.to_s)
|
|
322
|
+
|
|
323
|
+
on_stdout.call(stdout) unless stdout.empty?
|
|
324
|
+
on_stderr.call(stderr) unless stderr.empty?
|
|
325
|
+
end
|
|
326
|
+
end
|
|
327
|
+
|
|
328
|
+
ws.on(:close) do
|
|
329
|
+
completion_queue.push(:close)
|
|
330
|
+
end
|
|
331
|
+
|
|
332
|
+
ws.on(:error) do |e|
|
|
333
|
+
completion_queue.push(:error)
|
|
334
|
+
raise Sdk::Error, "WebSocket error: #{e.message}"
|
|
335
|
+
end
|
|
336
|
+
|
|
337
|
+
# Wait for completion
|
|
338
|
+
completion_queue.pop
|
|
339
|
+
end
|
|
340
|
+
|
|
266
341
|
# Sends input data to a command executed in a session
|
|
267
342
|
#
|
|
268
343
|
# This method allows you to send input to an interactive command running in a session,
|
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.153.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.153.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.153.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.153.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.153.0
|
|
110
110
|
- !ruby/object:Gem::Dependency
|
|
111
111
|
name: dotenv
|
|
112
112
|
requirement: !ruby/object:Gem::Requirement
|