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