consolle 0.3.3 → 0.3.5
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/.version +1 -1
- data/Gemfile.lock +1 -1
- data/lib/consolle/adapters/rails_console.rb +1 -1
- data/lib/consolle/cli.rb +20 -5
- data/lib/consolle/server/console_supervisor.rb +18 -2
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 570ace84f57a8120067ddae2ce8782e530f7140984558dc1b3550614a5526225
|
|
4
|
+
data.tar.gz: 0c35ba1f9afad687526c4e213adc81b1960374af656756cb6ac052c876a0c320
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a058e7974ec391a07b055b291d1d933dfb48d03850b29bdbbda926ea304146d6d7174764b9099acc24d48be144ac6ffa08b55d157cb714c9f42159dea7dd3a49
|
|
7
|
+
data.tar.gz: defc74e3bc92a8bb766fcfc3b2aad0195a76b7ac4c7748507cb323a519836976e8bb8add037785ac25c35f83fb05ace9995b4e18aa0ce3ca5324a9b0f8bcccb6
|
data/.version
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.3.
|
|
1
|
+
0.3.5
|
data/Gemfile.lock
CHANGED
data/lib/consolle/cli.rb
CHANGED
|
@@ -484,7 +484,7 @@ module Consolle
|
|
|
484
484
|
#{' '}
|
|
485
485
|
The console must be started first with 'cone start'.
|
|
486
486
|
LONGDESC
|
|
487
|
-
method_option :timeout, type: :numeric, desc: 'Timeout in seconds', default:
|
|
487
|
+
method_option :timeout, type: :numeric, desc: 'Timeout in seconds', default: 30
|
|
488
488
|
method_option :file, type: :string, aliases: '-f', desc: 'Read Ruby code from FILE'
|
|
489
489
|
method_option :raw, type: :boolean, desc: 'Do not apply escape fixes for Claude Code (keep \\! as is)'
|
|
490
490
|
def exec(*code_parts)
|
|
@@ -621,7 +621,7 @@ module Consolle
|
|
|
621
621
|
File.join(Dir.pwd, 'tmp', 'cone', "#{target}.log")
|
|
622
622
|
end
|
|
623
623
|
|
|
624
|
-
def send_code_to_socket(socket_path, code, timeout:
|
|
624
|
+
def send_code_to_socket(socket_path, code, timeout: 30)
|
|
625
625
|
request_id = SecureRandom.uuid
|
|
626
626
|
# Ensure code is UTF-8 encoded
|
|
627
627
|
code = code.force_encoding('UTF-8') if code.respond_to?(:force_encoding)
|
|
@@ -657,12 +657,27 @@ module Consolle
|
|
|
657
657
|
|
|
658
658
|
STDERR.puts "[DEBUG] Request sent, waiting for response..." if ENV['DEBUG']
|
|
659
659
|
|
|
660
|
-
# Read response
|
|
661
|
-
response_data =
|
|
660
|
+
# Read response - handle large responses by reading all available data
|
|
661
|
+
response_data = +''
|
|
662
|
+
begin
|
|
663
|
+
# Read until we get a newline (end of JSON response)
|
|
664
|
+
while (chunk = socket.read_nonblock(65536)) # Read in 64KB chunks
|
|
665
|
+
response_data << chunk
|
|
666
|
+
break if response_data.include?("\n")
|
|
667
|
+
end
|
|
668
|
+
rescue IO::WaitReadable
|
|
669
|
+
IO.select([socket], nil, nil, 1)
|
|
670
|
+
retry if response_data.empty? || !response_data.include?("\n")
|
|
671
|
+
rescue EOFError
|
|
672
|
+
# Server closed connection
|
|
673
|
+
end
|
|
674
|
+
|
|
662
675
|
STDERR.puts "[DEBUG] Response received: #{response_data&.bytesize} bytes" if ENV['DEBUG']
|
|
663
676
|
socket.close
|
|
664
677
|
|
|
665
|
-
|
|
678
|
+
# Extract just the first line (the JSON response)
|
|
679
|
+
json_line = response_data.split("\n").first
|
|
680
|
+
JSON.parse(json_line) if json_line
|
|
666
681
|
end
|
|
667
682
|
rescue Timeout::Error
|
|
668
683
|
STDERR.puts "[DEBUG] Timeout occurred after #{timeout} seconds" if ENV['DEBUG']
|
|
@@ -47,7 +47,10 @@ module Consolle
|
|
|
47
47
|
start_watchdog
|
|
48
48
|
end
|
|
49
49
|
|
|
50
|
-
def eval(code, timeout:
|
|
50
|
+
def eval(code, timeout: nil)
|
|
51
|
+
# Allow timeout to be configured via environment variable
|
|
52
|
+
default_timeout = ENV['CONSOLLE_TIMEOUT'] ? ENV['CONSOLLE_TIMEOUT'].to_i : 30
|
|
53
|
+
timeout ||= default_timeout
|
|
51
54
|
@mutex.synchronize do
|
|
52
55
|
raise 'Console is not running' unless running?
|
|
53
56
|
|
|
@@ -209,6 +212,16 @@ module Consolle
|
|
|
209
212
|
end
|
|
210
213
|
end
|
|
211
214
|
|
|
215
|
+
# Check if output is too large and truncate if necessary
|
|
216
|
+
max_output_size = 100_000 # 100KB limit for output
|
|
217
|
+
truncated = false
|
|
218
|
+
|
|
219
|
+
if output.bytesize > max_output_size
|
|
220
|
+
logger.warn "[ConsoleSupervisor] Output too large (#{output.bytesize} bytes), truncating to #{max_output_size} bytes"
|
|
221
|
+
output = output[0...max_output_size]
|
|
222
|
+
truncated = true
|
|
223
|
+
end
|
|
224
|
+
|
|
212
225
|
# Parse and return result
|
|
213
226
|
parsed_result = parse_output(output, eval_command)
|
|
214
227
|
|
|
@@ -223,7 +236,10 @@ module Consolle
|
|
|
223
236
|
if parsed_result.is_a?(Hash) && parsed_result[:error]
|
|
224
237
|
build_error_response(parsed_result[:exception], execution_time: execution_time)
|
|
225
238
|
else
|
|
226
|
-
{ success: true, output: parsed_result, execution_time: execution_time }
|
|
239
|
+
result = { success: true, output: parsed_result, execution_time: execution_time }
|
|
240
|
+
result[:truncated] = true if truncated
|
|
241
|
+
result[:truncated_at] = max_output_size if truncated
|
|
242
|
+
result
|
|
227
243
|
end
|
|
228
244
|
rescue StandardError => e
|
|
229
245
|
logger.error "[ConsoleSupervisor] Eval error: #{e.message}"
|