rubik 0.9.1 → 0.10.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/ATTRIBUTION.md +1 -1
- data/CHANGELOG.md +143 -1
- data/lib/rubik/adapter/base.rb +2 -1
- data/lib/rubik/adapter/process.rb +28 -67
- data/lib/rubik/benchmark/vakanuvis_adoption.rb +10 -3
- data/lib/rubik/buffer/apply_contract.rb +3 -3
- data/lib/rubik/buffer/apply_transaction.rb +165 -0
- data/lib/rubik/buffer/manager.rb +26 -120
- data/lib/rubik/config/deep_ops.rb +4 -1
- data/lib/rubik/config/defaults.rb +6 -3
- data/lib/rubik/config/schema.rb +8 -0
- data/lib/rubik/config/secret_policy.rb +197 -0
- data/lib/rubik/config.rb +11 -0
- data/lib/rubik/diagnostics/collector.rb +0 -9
- data/lib/rubik/errors.rb +15 -0
- data/lib/rubik/event_bus.rb +2 -1
- data/lib/rubik/kernel/dispatcher.rb +12 -7
- data/lib/rubik/kernel/unit.rb +4 -1
- data/lib/rubik/llm/registry.rb +12 -9
- data/lib/rubik/llm/router.rb +2 -5
- data/lib/rubik/log.rb +21 -0
- data/lib/rubik/lsp/client.rb +77 -273
- data/lib/rubik/lsp/manager.rb +14 -10
- data/lib/rubik/lsp/transport.rb +365 -0
- data/lib/rubik/mcp/boot_lifecycle.rb +6 -2
- data/lib/rubik/mcp/boot_run.rb +190 -0
- data/lib/rubik/mcp/manager.rb +40 -163
- data/lib/rubik/mcp/transport/stdio.rb +4 -1
- data/lib/rubik/orchestrator/auto_apply.rb +4 -3
- data/lib/rubik/orchestrator/continuation_manager.rb +3 -22
- data/lib/rubik/orchestrator/goal_session.rb +53 -39
- data/lib/rubik/orchestrator/loop.rb +28 -47
- data/lib/rubik/orchestrator/maestro_gate.rb +5 -7
- data/lib/rubik/orchestrator/provider_recovery.rb +4 -2
- data/lib/rubik/orchestrator/provider_resolver.rb +4 -2
- data/lib/rubik/orchestrator/resume_window.rb +96 -0
- data/lib/rubik/orchestrator/shell_deps.rb +16 -0
- data/lib/rubik/orchestrator/stream_manager.rb +2 -1
- data/lib/rubik/orchestrator/subagent/deferred_spec.rb +4 -1
- data/lib/rubik/orchestrator/subagent/instance.rb +7 -12
- data/lib/rubik/orchestrator/subagent/lifecycle.rb +3 -1
- data/lib/rubik/orchestrator/subagent/questioner.rb +3 -1
- data/lib/rubik/orchestrator/subagent/reaper.rb +3 -5
- data/lib/rubik/orchestrator/subagent/resilience.rb +4 -2
- data/lib/rubik/orchestrator/subagent/result_archive.rb +0 -4
- data/lib/rubik/orchestrator/subagent/run_cycle.rb +2 -7
- data/lib/rubik/orchestrator/subagent/spawn_transaction.rb +11 -2
- data/lib/rubik/orchestrator/subagent/step_runner.rb +10 -2
- data/lib/rubik/orchestrator/subagent/type_definition.rb +0 -4
- data/lib/rubik/orchestrator/tool_timeout.rb +121 -1
- data/lib/rubik/platform/io_drain.rb +2 -1
- data/lib/rubik/platform/process.rb +144 -54
- data/lib/rubik/platform.rb +2 -1
- data/lib/rubik/plugin/manager.rb +2 -1
- data/lib/rubik/repl/commands/agent_context.rb +8 -7
- data/lib/rubik/repl/commands/agent_execution.rb +13 -32
- data/lib/rubik/repl/commands/agent_models.rb +4 -3
- data/lib/rubik/repl/commands/agent_providers.rb +43 -2
- data/lib/rubik/repl/commands/base.rb +47 -2
- data/lib/rubik/repl/commands/buffer.rb +5 -4
- data/lib/rubik/repl/commands/lsp.rb +2 -1
- data/lib/rubik/repl/commands/pruner.rb +2 -1
- data/lib/rubik/repl/commands/secrets.rb +151 -0
- data/lib/rubik/repl/commands/workspace.rb +60 -150
- data/lib/rubik/repl/commands/workspace_approval.rb +209 -0
- data/lib/rubik/repl/config_wiring.rb +3 -3
- data/lib/rubik/repl/hooks.rb +2 -1
- data/lib/rubik/repl/input_execution.rb +158 -76
- data/lib/rubik/repl/input_loop.rb +2 -1
- data/lib/rubik/repl/lifecycle.rb +59 -209
- data/lib/rubik/repl/notice_router.rb +319 -0
- data/lib/rubik/repl/paste_support.rb +3 -1
- data/lib/rubik/repl/presentation.rb +5 -3
- data/lib/rubik/repl/pruner/gate.rb +3 -1
- data/lib/rubik/repl/pruner/harness.rb +2 -1
- data/lib/rubik/repl/shell.rb +4 -3
- data/lib/rubik/repl/turn_recorder.rb +6 -5
- data/lib/rubik/runtime/discovery.rb +3 -2
- data/lib/rubik/runtime/loop_service.rb +4 -3
- data/lib/rubik/runtime/manifest_store.rb +9 -1
- data/lib/rubik/runtime/overlay_guard.rb +127 -0
- data/lib/rubik/runtime/overlay_storage.rb +92 -146
- data/lib/rubik/runtime/task_manager.rb +64 -25
- data/lib/rubik/sandbox/driver/docker.rb +5 -1
- data/lib/rubik/sandbox/runner.rb +16 -15
- data/lib/rubik/security/command_gate.rb +117 -93
- data/lib/rubik/security/guard.rb +6 -2
- data/lib/rubik/security/secret_store.rb +463 -0
- data/lib/rubik/security/synthesis_gate.rb +8 -11
- data/lib/rubik/session/manager.rb +7 -1
- data/lib/rubik/skills/manager.rb +2 -3
- data/lib/rubik/storage/search.rb +49 -0
- data/lib/rubik/storage/store.rb +13 -20
- data/lib/rubik/storage/vakanuvis/harness.rb +2 -3
- data/lib/rubik/tools/base.rb +22 -0
- data/lib/rubik/tools/builtins/files.rb +3 -15
- data/lib/rubik/tools/builtins/grep.rb +1 -6
- data/lib/rubik/tools/builtins/lifecycle.rb +6 -5
- data/lib/rubik/tools/lifecycle_rollbacks.rb +14 -1
- data/lib/rubik/tools/truncator.rb +48 -36
- data/lib/rubik/ui/banner.rb +4 -3
- data/lib/rubik/ui/spinner.rb +3 -1
- data/lib/rubik/ui/statusline.rb +6 -5
- data/lib/rubik/version.rb +1 -1
- data/lib/rubik.rb +1 -2
- metadata +13 -1
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
require "stringio"
|
|
4
4
|
require_relative "tee_io"
|
|
5
|
+
require_relative "../storage/layout"
|
|
5
6
|
|
|
6
7
|
module Rubik
|
|
7
8
|
module REPL
|
|
@@ -82,7 +83,7 @@ module Rubik
|
|
|
82
83
|
clean_raw = Rubik::Security::Redactor.redact(parsed.raw)
|
|
83
84
|
@recorder&.record_repl_command(clean_raw, output_text)
|
|
84
85
|
# Plan 61 D-8: bound what a bang command leaves in LLM memory; the recorder keeps the full text.
|
|
85
|
-
max_chars = @config
|
|
86
|
+
max_chars = Rubik::Storage::Layout.config_get(@config, "tools.max_output_chars", Rubik::Tools::Truncator::DEFAULT_MAX_CHARS)
|
|
86
87
|
# Deliberately context-scoped (issue #349 F8): truncation_strategy is a
|
|
87
88
|
# tool-output contract (the two orchestrator planes); bang-command echo
|
|
88
89
|
# is REPL history capture and stays head_tail, outside the knob's promise.
|
|
@@ -144,6 +145,14 @@ module Rubik
|
|
|
144
145
|
true
|
|
145
146
|
end
|
|
146
147
|
|
|
148
|
+
# Named phases of the free-text turn (issue #445): execute_free_text is
|
|
149
|
+
# the orchestrator — arming → routing → display/loop assembly → run →
|
|
150
|
+
# settle, with the rescue ladder and ensure teardown delegated to their
|
|
151
|
+
# own helpers below. All helpers run on the Shell (self stays the shell,
|
|
152
|
+
# so @output/@recorder reads are unchanged); every piece of state that
|
|
153
|
+
# was a local of the old monolith (task, renderer, md_stream, theme,
|
|
154
|
+
# md_enabled, orchestrator, interrupted) reaches its consumer explicitly
|
|
155
|
+
# as a parameter — nothing is passed through self or ambient state.
|
|
147
156
|
def execute_free_text(text)
|
|
148
157
|
# Wakeloop fix 2026-10-09: ^C settles the wake debt instead of
|
|
149
158
|
# letting the interrupted turn's own ensure re-arm the cycle. Bound
|
|
@@ -152,10 +161,45 @@ module Rubik
|
|
|
152
161
|
# an unbound read would mask the in-flight exception with a
|
|
153
162
|
# NameError, breaking the "cleanup must never mask" contract.
|
|
154
163
|
interrupted = false
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
164
|
+
task = start_free_text_turn!(text)
|
|
165
|
+
renderer = md_stream = orchestrator = nil
|
|
166
|
+
routed = route_free_text!(text)
|
|
167
|
+
return if routed.nil?
|
|
168
|
+
|
|
169
|
+
@runtime_manager.provide(:llm_client, routed[:provider])
|
|
170
|
+
|
|
171
|
+
# Pruner apply seam (context-pruner 2026-10-09): budayıcı bir plan
|
|
172
|
+
# aşamaladıysa pencereyi turn tohumlanmadan ÖNCE takas et (knob
|
|
173
|
+
# kapalıysa no-op; !plan'ın execute_free_text devri ve otonom notice
|
|
174
|
+
# turn'leri buradan geçer).
|
|
175
|
+
apply_staged_prune_plan!
|
|
176
|
+
|
|
177
|
+
max_steps = Rubik::Storage::Layout.config_get(@config, "agent.max_steps", 40).to_i
|
|
178
|
+
warn_ratio = Rubik::Storage::Layout.config_get(@config, "agent.warn_at_ratio", 0.75).to_f
|
|
179
|
+
theme = self.theme
|
|
180
|
+
renderer, md_stream, md_enabled = build_turn_display(theme, max_steps)
|
|
181
|
+
orchestrator = build_turn_orchestrator(routed, max_steps, warn_ratio, renderer, md_stream)
|
|
182
|
+
|
|
183
|
+
res = run_free_text_loop(orchestrator, text)
|
|
184
|
+
settle_free_text_result!(text, res, orchestrator: orchestrator, theme: theme, md_enabled: md_enabled)
|
|
185
|
+
rescue Interrupt
|
|
186
|
+
interrupted = true
|
|
187
|
+
handle_interrupted_free_text!(text, task, orchestrator)
|
|
188
|
+
rescue Rubik::LLM::ClientError => e
|
|
189
|
+
handle_llm_client_error!(text, e, orchestrator)
|
|
190
|
+
rescue StandardError => e
|
|
191
|
+
handle_unexpected_error!(text, e, orchestrator)
|
|
192
|
+
ensure
|
|
193
|
+
teardown_free_text_turn!(interrupted, orchestrator, renderer, md_stream)
|
|
194
|
+
end
|
|
195
|
+
|
|
196
|
+
# Arming phase: publishes the turn's task-cancellation token (issue #125
|
|
197
|
+
# — the turn owns the subagents it spawns; ^C cancels it and the
|
|
198
|
+
# supervisor stops exactly the owned descendants; detached work and
|
|
199
|
+
# older turns' executions carry different tokens and survive), settles
|
|
200
|
+
# the wake debt and records the turn's entry events. Returns the token
|
|
201
|
+
# for the rescue ladder.
|
|
202
|
+
def start_free_text_turn!(text)
|
|
159
203
|
task = Rubik::Orchestrator::TaskCancellation.new
|
|
160
204
|
@active_task = task
|
|
161
205
|
@runtime_manager&.provide(Rubik::Coeffects::TASK_CANCELLATION, task)
|
|
@@ -165,73 +209,90 @@ module Rubik
|
|
|
165
209
|
clear_pending_wake_notices! if respond_to?(:clear_pending_wake_notices!)
|
|
166
210
|
@recorder&.record_user_turn(text)
|
|
167
211
|
@event_bus.emit(:prompt_received, prompt: text)
|
|
212
|
+
task
|
|
213
|
+
end
|
|
168
214
|
|
|
169
|
-
|
|
215
|
+
# Routing phase: resolves the turn route; when no LLM provider is
|
|
216
|
+
# available, reports the failure (message + failed-turn record) and
|
|
217
|
+
# returns nil so the caller aborts the turn — ensure still unwinds.
|
|
218
|
+
def route_free_text!(text)
|
|
170
219
|
routed = resolve_turn_route(text)
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
if provider.nil?
|
|
174
|
-
spec_str = routed[:spec].is_a?(Hash) ? "#{routed[:spec]['provider']}/#{routed[:spec]['name']}" : routed[:spec].to_s
|
|
175
|
-
@output.puts "Hata: Model sağlayıcısı başlatılamadı (#{spec_str})."
|
|
176
|
-
record_failed_turn!(text, "failed", "no LLM provider available (#{spec_str})", nil)
|
|
177
|
-
return
|
|
178
|
-
end
|
|
220
|
+
return routed if routed[:provider]
|
|
179
221
|
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
# turn'leri buradan geçer).
|
|
186
|
-
apply_staged_prune_plan!
|
|
222
|
+
spec_str = routed[:spec].is_a?(Hash) ? "#{routed[:spec]['provider']}/#{routed[:spec]['name']}" : routed[:spec].to_s
|
|
223
|
+
@output.puts "Hata: Model sağlayıcısı başlatılamadı (#{spec_str})."
|
|
224
|
+
record_failed_turn!(text, "failed", "no LLM provider available (#{spec_str})", nil)
|
|
225
|
+
nil
|
|
226
|
+
end
|
|
187
227
|
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
228
|
+
# Display phase: builds the step renderer and the live markdown stream.
|
|
229
|
+
# Returns [renderer, md_stream, md_enabled]; md_enabled flows to the
|
|
230
|
+
# batch-render path in settle_free_text_result!.
|
|
231
|
+
def build_turn_display(theme, max_steps)
|
|
191
232
|
renderer = @ui_renderer || Rubik::UI::Renderer.new(config: @config, max_steps: max_steps, output: @output, theme: theme)
|
|
192
|
-
md_enabled = @config
|
|
233
|
+
md_enabled = Rubik::Storage::Layout.config_get(@config, "ui.markdown", "live") != "off"
|
|
193
234
|
md_stream = Rubik::UI::MarkdownStream.new(theme, enabled: md_enabled)
|
|
235
|
+
[renderer, md_stream, md_enabled]
|
|
236
|
+
end
|
|
194
237
|
|
|
195
|
-
|
|
196
|
-
|
|
238
|
+
# Loop-assembly phase: builds the orchestrator loop with the turn's
|
|
239
|
+
# step handler wired to the turn's renderer and markdown stream.
|
|
240
|
+
def build_turn_orchestrator(routed, max_steps, warn_ratio, renderer, md_stream)
|
|
241
|
+
orchestrator_loop(
|
|
242
|
+
provider: routed[:provider],
|
|
197
243
|
model: routed[:model],
|
|
198
244
|
max_steps: max_steps,
|
|
199
245
|
warn_at_ratio: warn_ratio,
|
|
200
246
|
context_limit: routed[:context_limit],
|
|
201
247
|
max_output_tokens: routed[:max_output_tokens],
|
|
202
|
-
on_step:
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
248
|
+
on_step: turn_step_handler(renderer, md_stream)
|
|
249
|
+
)
|
|
250
|
+
end
|
|
251
|
+
|
|
252
|
+
# The per-step streaming policy for free-text turns. The lambda closes
|
|
253
|
+
# over renderer/md_stream (passed explicitly) and the Shell's live
|
|
254
|
+
# @output/@recorder — self at invocation time is still the Shell, the
|
|
255
|
+
# same closure the inline version had.
|
|
256
|
+
def turn_step_handler(renderer, md_stream)
|
|
257
|
+
lambda { |step_info|
|
|
258
|
+
case step_info[:type]&.to_sym
|
|
259
|
+
when :chunk
|
|
260
|
+
renderer.render(step_info) # stops spinner before raw output
|
|
261
|
+
md_stream.push(step_info[:delta]) { |seg| @output.print seg }
|
|
262
|
+
@output.flush if @output.respond_to?(:flush)
|
|
263
|
+
when :chunk_end
|
|
264
|
+
renderer.render(step_info)
|
|
265
|
+
md_stream.finish { |seg| @output.print seg }
|
|
266
|
+
@output.flush if @output.respond_to?(:flush)
|
|
267
|
+
when :tool_call
|
|
268
|
+
@recorder&.record_tool_call(step_info[:tool], step_info[:args], call_id: step_info[:call_id])
|
|
269
|
+
formatted = renderer.render(step_info)
|
|
270
|
+
@output.puts formatted if formatted && !formatted.empty?
|
|
271
|
+
@output.flush if @output.respond_to?(:flush)
|
|
272
|
+
when :tool_result
|
|
273
|
+
@recorder&.record_tool_result(step_info[:tool], step_info[:output], status: step_info[:status] || :ok, call_id: step_info[:call_id])
|
|
274
|
+
formatted = renderer.render(step_info)
|
|
275
|
+
@output.puts formatted if formatted && !formatted.empty?
|
|
276
|
+
@output.flush if @output.respond_to?(:flush)
|
|
277
|
+
else
|
|
278
|
+
formatted = renderer.render(step_info)
|
|
279
|
+
if formatted && !formatted.empty?
|
|
280
|
+
@output.puts formatted
|
|
221
281
|
@output.flush if @output.respond_to?(:flush)
|
|
222
|
-
else
|
|
223
|
-
formatted = renderer.render(step_info)
|
|
224
|
-
if formatted && !formatted.empty?
|
|
225
|
-
@output.puts formatted
|
|
226
|
-
@output.flush if @output.respond_to?(:flush)
|
|
227
|
-
end
|
|
228
282
|
end
|
|
229
|
-
|
|
230
|
-
|
|
283
|
+
end
|
|
284
|
+
}
|
|
285
|
+
end
|
|
286
|
+
|
|
287
|
+
# Run phase: publishes @active_loop before the loop starts (the
|
|
288
|
+
# reentrancy guard relied on by execute_subagent_notice_turn! and
|
|
289
|
+
# route_subagent_notice's idle branch) and drives the
|
|
290
|
+
# budget-exhausted continue prompt. Returns the final loop result.
|
|
291
|
+
def run_free_text_loop(orchestrator, text)
|
|
231
292
|
@active_loop = orchestrator
|
|
232
293
|
res = orchestrator.run(text, conversation_history: @conversation_history)
|
|
233
294
|
|
|
234
|
-
while !res[:ok] && res[:reason] == :budget_exhausted && @config
|
|
295
|
+
while !res[:ok] && res[:reason] == :budget_exhausted && Rubik::Storage::Layout.config_get(@config, "agent.ask_continue_on_limit", true)
|
|
235
296
|
@output.puts "\n⚠️ [Rubik::Agent] #{res[:error]}"
|
|
236
297
|
ans = ask_yes_no(" [Rubik::Agent] +20 adım ile devam edilsin mi?", default: "n")
|
|
237
298
|
break unless ["y", "yes", "evet"].include?(ans)
|
|
@@ -240,14 +301,20 @@ module Rubik
|
|
|
240
301
|
res = orchestrator.continue_loop(20)
|
|
241
302
|
|
|
242
303
|
end
|
|
304
|
+
res
|
|
305
|
+
end
|
|
243
306
|
|
|
307
|
+
# Settle phase: merges the turn's tool history, then records and
|
|
308
|
+
# reports the outcome (success render / incomplete report). theme and
|
|
309
|
+
# md_enabled arrive from the display phase for the batch render.
|
|
310
|
+
def settle_free_text_result!(text, res, orchestrator:, theme:, md_enabled:)
|
|
244
311
|
# Plan 85 D-7 (kök neden): turn içi @history'deki tool ara adımlarını
|
|
245
312
|
# conversation_history'ye kopyala — böylece continue'da model turn sırasındaki
|
|
246
313
|
# bağlamı görür ve "sıfırdan keşfe" başlamaz. res[:loop_instance].history,
|
|
247
314
|
# turn_result'ın döndürdüğü Loop örneğinin @history'sidir.
|
|
248
315
|
merge_turn_tool_history!(
|
|
249
316
|
res[:loop_instance]&.history,
|
|
250
|
-
max_entries: @config
|
|
317
|
+
max_entries: Rubik::Storage::Layout.config_get(@config, "context.merge_turn_tool_max_entries", 20).to_i
|
|
251
318
|
)
|
|
252
319
|
|
|
253
320
|
if res[:ok]
|
|
@@ -275,11 +342,14 @@ module Rubik
|
|
|
275
342
|
@output.puts "Görev tamamlanamadı: #{res[:error]}"
|
|
276
343
|
record_failed_turn!(text, "incomplete", res[:error], orchestrator)
|
|
277
344
|
end
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
345
|
+
end
|
|
346
|
+
|
|
347
|
+
# Interrupt rescue body: the user cancelled — queued wake debts settle
|
|
348
|
+
# here. Each queued notice already lives in @conversation_history (idle
|
|
349
|
+
# path injects at route time), so draining loses nothing the model
|
|
350
|
+
# needed. `interrupted = true` stays in the orchestrator so the ensure
|
|
351
|
+
# reads the flag before this runs.
|
|
352
|
+
def handle_interrupted_free_text!(text, task, orchestrator)
|
|
283
353
|
clear_pending_wake_notices! if respond_to?(:clear_pending_wake_notices!)
|
|
284
354
|
Rubik::REPL::InterruptHandler.restore_console_after_interrupt
|
|
285
355
|
# Propagate the cancellation to owned work (issue #125) and report the
|
|
@@ -294,25 +364,37 @@ module Rubik
|
|
|
294
364
|
"reason" => "Interrupted by user (^C)")
|
|
295
365
|
@output.puts "\n⚠️ [Rubik::Agent] Görev kullanıcı tarafından iptal edildi (^C)."
|
|
296
366
|
record_failed_turn!(text, "cancelled", "Interrupted by user (^C)", orchestrator)
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
367
|
+
end
|
|
368
|
+
|
|
369
|
+
# LLM::ClientError rescue body. e.message may carry binary bytes (raw
|
|
370
|
+
# HTTP error bodies). Printing or recording those would raise INSIDE the
|
|
371
|
+
# rescue clause, bypassing every sibling handler and surfacing as a bare
|
|
372
|
+
# Encoding::CompatibilityError at the REPL prompt instead of the real
|
|
373
|
+
# LLM error. Sanitize before use.
|
|
374
|
+
def handle_llm_client_error!(text, error, orchestrator)
|
|
375
|
+
message = Rubik::Platform.safe_utf8(error.message)
|
|
304
376
|
@output.puts "[Rubik::LLM Hatası] #{message}"
|
|
305
377
|
record_failed_turn!(text, "failed", message, orchestrator)
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
378
|
+
end
|
|
379
|
+
|
|
380
|
+
# StandardError rescue body: same binary-byte sanitization as the LLM
|
|
381
|
+
# error path above.
|
|
382
|
+
def handle_unexpected_error!(text, error, orchestrator)
|
|
383
|
+
message = Rubik::Platform.safe_utf8(error.message)
|
|
384
|
+
@output.puts "[Hata] #{error.class}: #{message}"
|
|
385
|
+
record_failed_turn!(text, "failed", "#{error.class}: #{message}", orchestrator)
|
|
386
|
+
end
|
|
387
|
+
|
|
388
|
+
# Ensure-phase teardown. Cleanup must never mask the in-flight exception
|
|
389
|
+
# (Interrupt, LLM error): each step reports its own failure to stderr
|
|
390
|
+
# instead of raising. `interrupted` is the orchestrator's local, passed
|
|
391
|
+
# explicitly (Wakeloop fix 2026-10-09: an interrupted turn must not
|
|
392
|
+
# re-arm the wake cycle).
|
|
393
|
+
def teardown_free_text_turn!(interrupted, orchestrator, renderer, md_stream)
|
|
311
394
|
@active_loop = nil
|
|
312
395
|
@active_task = nil
|
|
313
396
|
# Flush a half-streamed markdown tail so an interrupt never eats the last
|
|
314
|
-
# line.
|
|
315
|
-
# error): each step reports its own failure to stderr instead of raising.
|
|
397
|
+
# line.
|
|
316
398
|
begin
|
|
317
399
|
md_stream&.finish { |seg| @output.print seg }
|
|
318
400
|
rescue StandardError => e
|
|
@@ -343,7 +425,7 @@ module Rubik
|
|
|
343
425
|
supervisor = Rubik::Coeffects.get(@runtime_manager&.context, Rubik::Coeffects::SUBAGENT_SUPERVISOR)
|
|
344
426
|
return nil unless task && supervisor.respond_to?(:cancel_owned)
|
|
345
427
|
|
|
346
|
-
supervisor.cancel_owned(task, timeout: @config
|
|
428
|
+
supervisor.cancel_owned(task, timeout: Rubik::Storage::Layout.config_get(@config, "subagents.cancel_timeout", 2.0))
|
|
347
429
|
rescue StandardError => e
|
|
348
430
|
warn "[rubik] task cancellation failed: #{e.class}: #{e.message}"
|
|
349
431
|
nil
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require_relative "prompt_grace"
|
|
4
|
+
require_relative "../storage/layout"
|
|
4
5
|
|
|
5
6
|
module Rubik
|
|
6
7
|
module REPL
|
|
@@ -224,7 +225,7 @@ module Rubik
|
|
|
224
225
|
return execute_input(text) unless prompt_grace_interactive?
|
|
225
226
|
|
|
226
227
|
if CommandParser.parse(text).type == :prompt
|
|
227
|
-
milliseconds = @config
|
|
228
|
+
milliseconds = Rubik::Storage::Layout.config_get(@config, "ui.prompt_grace_window_ms", 1000)
|
|
228
229
|
outcome = PromptGrace.new(input: @input, output: @output,
|
|
229
230
|
context: @runtime_manager&.context).wait(milliseconds)
|
|
230
231
|
if outcome == :edit
|