feat: gate command output behind verbose
This commit is contained in:
@@ -149,6 +149,7 @@ class CodexExecRunner:
|
||||
prompt: str,
|
||||
session_id: Optional[str],
|
||||
on_event: Optional[Callable[[Dict[str, Any]], None]] = None,
|
||||
show_output: bool = False,
|
||||
) -> Tuple[str, str, bool]:
|
||||
"""
|
||||
Returns (session_id, final_agent_message_text)
|
||||
@@ -204,7 +205,7 @@ class CodexExecRunner:
|
||||
evt = json.loads(line)
|
||||
except json.JSONDecodeError:
|
||||
continue
|
||||
for out in render_event_cli(evt, cli_state):
|
||||
for out in render_event_cli(evt, cli_state, show_output=show_output):
|
||||
log(f"[codex] {out}")
|
||||
if on_event is not None:
|
||||
try:
|
||||
@@ -240,15 +241,16 @@ class CodexExecRunner:
|
||||
prompt: str,
|
||||
session_id: Optional[str],
|
||||
on_event: Optional[Callable[[Dict[str, Any]], None]] = None,
|
||||
show_output: bool = False,
|
||||
) -> Tuple[str, str, bool]:
|
||||
"""
|
||||
If resuming, serialize per-session.
|
||||
"""
|
||||
if not session_id:
|
||||
return self.run(prompt, session_id=None, on_event=on_event)
|
||||
return self.run(prompt, session_id=None, on_event=on_event, show_output=show_output)
|
||||
lock = self._lock_for(session_id)
|
||||
with lock:
|
||||
return self.run(prompt, session_id=session_id, on_event=on_event)
|
||||
return self.run(prompt, session_id=session_id, on_event=on_event, show_output=show_output)
|
||||
|
||||
|
||||
# -------------------- Telegram loop --------------------
|
||||
@@ -276,6 +278,11 @@ def run(
|
||||
"--ignore-backlog/--process-backlog",
|
||||
help="Skip pending Telegram updates that arrived before startup.",
|
||||
),
|
||||
verbose: bool = typer.Option(
|
||||
False,
|
||||
"--verbose/--quiet",
|
||||
help="Include command output in CLI logs.",
|
||||
),
|
||||
) -> None:
|
||||
config = load_telegram_config()
|
||||
token = config_get(config, "bot_token") or ""
|
||||
@@ -418,6 +425,7 @@ def run(
|
||||
text,
|
||||
resume_session,
|
||||
on_event=on_event,
|
||||
show_output=verbose,
|
||||
)
|
||||
except Exception as e:
|
||||
_stop_background()
|
||||
|
||||
@@ -183,6 +183,7 @@ def render_event_cli(
|
||||
state: ExecRenderState,
|
||||
*,
|
||||
show_reasoning: bool = False,
|
||||
show_output: bool = False,
|
||||
) -> list[str]:
|
||||
etype = event.get("type")
|
||||
lines: list[str] = []
|
||||
@@ -232,9 +233,10 @@ def render_event_cli(
|
||||
exit_code = item.get("exit_code")
|
||||
exit_part = f" (exit {exit_code})" if exit_code is not None else ""
|
||||
lines.append(f"{STATUS_DONE} ran: {command}{exit_part}")
|
||||
output = _truncate_output(item.get("aggregated_output", ""))
|
||||
if output:
|
||||
lines.extend(indent(output, " ").splitlines())
|
||||
if show_output:
|
||||
output = _truncate_output(item.get("aggregated_output", ""))
|
||||
if output:
|
||||
lines.extend(indent(output, " ").splitlines())
|
||||
|
||||
elif itype == "file_change" and etype == "item.completed":
|
||||
line = _format_file_change(item.get("changes", []))
|
||||
|
||||
Reference in New Issue
Block a user