refactor: remove command output rendering
This commit is contained in:
@@ -40,9 +40,6 @@ Optional flags:
|
|||||||
- `--progress-silent/--no-progress-silent` (default silent)
|
- `--progress-silent/--no-progress-silent` (default silent)
|
||||||
- `--final-notify/--no-final-notify` (default notify via new message)
|
- `--final-notify/--no-final-notify` (default notify via new message)
|
||||||
- `--ignore-backlog/--process-backlog` (default ignore pending updates)
|
- `--ignore-backlog/--process-backlog` (default ignore pending updates)
|
||||||
- `--codex-io-mode [threads|selectors|asyncio]` (default `threads`)
|
|
||||||
- `--codex-command-timeout FLOAT` (default: disabled, debug defaults to 60s)
|
|
||||||
- `--codex-no-child-timeout FLOAT` (default `15.0`, set `0` to disable)
|
|
||||||
- `--workdir PATH` (override `codex_workspace`)
|
- `--workdir PATH` (override `codex_workspace`)
|
||||||
- `--model NAME` (pass through to `codex exec`)
|
- `--model NAME` (pass through to `codex exec`)
|
||||||
|
|
||||||
|
|||||||
@@ -178,7 +178,6 @@ 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)
|
||||||
@@ -235,7 +234,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, show_output=show_output):
|
for out in render_event_cli(evt, cli_state):
|
||||||
log(f"[codex] {out}")
|
log(f"[codex] {out}")
|
||||||
if on_event is not None:
|
if on_event is not None:
|
||||||
try:
|
try:
|
||||||
@@ -272,16 +271,15 @@ 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, show_output=show_output)
|
return self.run(prompt, session_id=None, on_event=on_event)
|
||||||
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, show_output=show_output)
|
return self.run(prompt, session_id=session_id, on_event=on_event)
|
||||||
|
|
||||||
|
|
||||||
# -------------------- Telegram loop --------------------
|
# -------------------- Telegram loop --------------------
|
||||||
@@ -309,11 +307,6 @@ 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.",
|
|
||||||
),
|
|
||||||
log_file: Optional[str] = typer.Option(
|
log_file: Optional[str] = typer.Option(
|
||||||
"exec_bridge.log",
|
"exec_bridge.log",
|
||||||
"--log-file",
|
"--log-file",
|
||||||
@@ -478,7 +471,6 @@ 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()
|
||||||
|
|||||||
@@ -112,15 +112,6 @@ def _with_id(item_id: Optional[int], line: str) -> str:
|
|||||||
return f"[?] {line}"
|
return f"[?] {line}"
|
||||||
|
|
||||||
|
|
||||||
def _truncate_output(text: str, max_lines: int = 20, max_chars: int = 4000) -> str:
|
|
||||||
if len(text) > max_chars:
|
|
||||||
text = text[-max_chars:]
|
|
||||||
lines = text.splitlines()
|
|
||||||
if len(lines) > max_lines:
|
|
||||||
lines = ["..."] + lines[-max_lines:]
|
|
||||||
return "\n".join(lines)
|
|
||||||
|
|
||||||
|
|
||||||
def _format_item_action_line(etype: str, item_id: Optional[int], item: dict[str, Any]) -> str | None:
|
def _format_item_action_line(etype: str, item_id: Optional[int], item: dict[str, Any]) -> str | None:
|
||||||
itype = item["type"]
|
itype = item["type"]
|
||||||
if itype == "command_execution":
|
if itype == "command_execution":
|
||||||
@@ -207,8 +198,6 @@ def _complete_action(state: ExecRenderState, item_id: Optional[int], line: str)
|
|||||||
def render_event_cli(
|
def render_event_cli(
|
||||||
event: dict[str, Any],
|
event: dict[str, Any],
|
||||||
state: ExecRenderState,
|
state: ExecRenderState,
|
||||||
*,
|
|
||||||
show_output: bool = False,
|
|
||||||
) -> list[str]:
|
) -> list[str]:
|
||||||
etype = event["type"]
|
etype = event["type"]
|
||||||
lines: list[str] = []
|
lines: list[str] = []
|
||||||
@@ -244,10 +233,6 @@ def render_event_cli(
|
|||||||
action_line = _format_item_action_line(etype, item_num, item)
|
action_line = _format_item_action_line(etype, item_num, item)
|
||||||
if action_line is not None:
|
if action_line is not None:
|
||||||
lines.append(action_line)
|
lines.append(action_line)
|
||||||
if show_output and itype == "command_execution" and etype == "item.completed":
|
|
||||||
output = _truncate_output(item["aggregated_output"])
|
|
||||||
if output:
|
|
||||||
lines.extend(indent(output, " ").splitlines())
|
|
||||||
elif etype == "item.completed":
|
elif etype == "item.completed":
|
||||||
completed_line = _format_item_completed_line(item_num, item)
|
completed_line = _format_item_completed_line(item_num, item)
|
||||||
if completed_line is not None:
|
if completed_line is not None:
|
||||||
|
|||||||
Reference in New Issue
Block a user