adelie-ai 0.1.2 → 0.1.4
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.
- package/adelie/interactive.py +16 -9
- package/package.json +1 -1
package/adelie/interactive.py
CHANGED
|
@@ -170,6 +170,8 @@ class AdelieApp:
|
|
|
170
170
|
self._ui_logger: Optional[UILogger] = None
|
|
171
171
|
self._running = True
|
|
172
172
|
self._orch_thread: Optional[threading.Thread] = None
|
|
173
|
+
# Capture the original Rich Console BEFORE any patching
|
|
174
|
+
self._real_console: Console = console
|
|
173
175
|
|
|
174
176
|
def run(self):
|
|
175
177
|
"""Start the orchestrator and enter the command loop."""
|
|
@@ -198,8 +200,8 @@ class AdelieApp:
|
|
|
198
200
|
# Wire orchestrator callbacks
|
|
199
201
|
self._wire_orchestrator()
|
|
200
202
|
|
|
201
|
-
|
|
202
|
-
|
|
203
|
+
self._real_console.print("[dim]Type '/help' for a list of commands.[/dim]")
|
|
204
|
+
self._real_console.print()
|
|
203
205
|
|
|
204
206
|
# Start orchestrator in background
|
|
205
207
|
self._orch_thread = threading.Thread(
|
|
@@ -209,9 +211,10 @@ class AdelieApp:
|
|
|
209
211
|
|
|
210
212
|
# Handle Ctrl+C gracefully
|
|
211
213
|
original_sigint = signal.getsignal(signal.SIGINT)
|
|
214
|
+
real_con = self._real_console
|
|
212
215
|
|
|
213
216
|
def _sigint_handler(signum, frame):
|
|
214
|
-
|
|
217
|
+
real_con.print("\n[yellow]Shutting down…[/yellow]")
|
|
215
218
|
self._shutdown()
|
|
216
219
|
|
|
217
220
|
signal.signal(signal.SIGINT, _sigint_handler)
|
|
@@ -240,10 +243,12 @@ class AdelieApp:
|
|
|
240
243
|
|
|
241
244
|
def _setup_logger(self):
|
|
242
245
|
"""Create UILogger and wire callbacks."""
|
|
246
|
+
# Use the saved real console so callbacks never recurse through UILogger
|
|
247
|
+
real_con = self._real_console
|
|
243
248
|
self._ui_logger = UILogger()
|
|
244
249
|
|
|
245
250
|
self._ui_logger.on_agent_update = lambda name, info: print_agent_event(name, info)
|
|
246
|
-
self._ui_logger.on_log = lambda category, obj:
|
|
251
|
+
self._ui_logger.on_log = lambda category, obj: real_con.print(obj)
|
|
247
252
|
self._ui_logger.on_cycle_start = lambda it, ph, st: print_cycle_header(it, ph, st)
|
|
248
253
|
self._ui_logger.on_cycle_metrics = lambda m: print_cycle_metrics(m)
|
|
249
254
|
|
|
@@ -267,7 +272,11 @@ class AdelieApp:
|
|
|
267
272
|
)
|
|
268
273
|
|
|
269
274
|
def _patch_consoles(self):
|
|
270
|
-
"""Replace console objects in all Adelie modules with UILogger.
|
|
275
|
+
"""Replace console objects in all Adelie modules with UILogger.
|
|
276
|
+
|
|
277
|
+
NOTE: Do NOT patch interactive_module itself — it is the display layer
|
|
278
|
+
and must keep the real Rich Console to avoid infinite recursion.
|
|
279
|
+
"""
|
|
271
280
|
import adelie.orchestrator as orch_module
|
|
272
281
|
import adelie.agents.writer_ai as writer_module
|
|
273
282
|
import adelie.agents.expert_ai as expert_module
|
|
@@ -276,13 +285,11 @@ class AdelieApp:
|
|
|
276
285
|
import adelie.agents.runner_ai as runner_module
|
|
277
286
|
import adelie.agents.monitor_ai as monitor_module
|
|
278
287
|
import adelie.agents.analyst_ai as analyst_module
|
|
279
|
-
import adelie.interactive as interactive_module
|
|
280
288
|
|
|
281
289
|
modules = [
|
|
282
290
|
orch_module, writer_module, expert_module,
|
|
283
291
|
coder_module, coder_manager_module,
|
|
284
292
|
runner_module, monitor_module, analyst_module,
|
|
285
|
-
interactive_module,
|
|
286
293
|
]
|
|
287
294
|
|
|
288
295
|
for mod_name in (
|
|
@@ -305,9 +312,9 @@ class AdelieApp:
|
|
|
305
312
|
try:
|
|
306
313
|
self.orchestrator.run_loop()
|
|
307
314
|
except Exception as e:
|
|
308
|
-
|
|
315
|
+
self._real_console.print(f"\n[bold red]ERROR: Orchestrator crashed: {e}[/bold red]")
|
|
309
316
|
finally:
|
|
310
|
-
|
|
317
|
+
self._real_console.print("\n[dim]Orchestrator loop finished.[/dim]")
|
|
311
318
|
self._running = False
|
|
312
319
|
# Print a newline so the input prompt doesn't hang
|
|
313
320
|
print()
|