feat: add workdir flag and trim final output
This commit is contained in:
@@ -26,7 +26,7 @@ chat_id = 123456789
|
||||
Optional keys (by mode):
|
||||
|
||||
- common: `bridge_db`, `allowed_chat_ids`, `startup_chat_ids`
|
||||
- exec/resume: `startup_message`, `codex_cmd`, `codex_workspace`, `codex_exec_args`, `max_workers`
|
||||
- exec/resume: `startup_message`, `codex_cmd`, `codex_workspace`, `codex_exec_args`, `max_workers`, `codex_io_mode`, `codex_command_timeout_s`, `codex_no_child_timeout_s`
|
||||
- MCP server: `codex_mcp_cmd`, `codex_workspace`, `codex_sandbox`, `codex_approval_policy`
|
||||
|
||||
## Option 1: exec/resume
|
||||
@@ -43,6 +43,10 @@ Optional flags:
|
||||
- `--progress-silent/--no-progress-silent` (default silent)
|
||||
- `--final-notify/--no-final-notify` (default notify via new message)
|
||||
- `--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`)
|
||||
|
||||
## Option 2: MCP server
|
||||
|
||||
|
||||
@@ -329,6 +329,11 @@ def run(
|
||||
"--log-file",
|
||||
help="Write detailed debug logs to this file (set to empty to disable).",
|
||||
),
|
||||
workdir: Optional[str] = typer.Option(
|
||||
None,
|
||||
"--workdir",
|
||||
help="Override codex workspace (--cd) for this exec-bridge run.",
|
||||
),
|
||||
) -> None:
|
||||
setup_file_logger(log_file if log_file else None)
|
||||
config = load_telegram_config()
|
||||
@@ -342,7 +347,7 @@ def run(
|
||||
startup_msg = f"{startup_msg}\nPWD: {startup_pwd}"
|
||||
|
||||
codex_cmd = config_get(config, "codex_cmd") or "codex"
|
||||
workspace = config_get(config, "codex_workspace")
|
||||
workspace = workdir if workdir is not None else config_get(config, "codex_workspace")
|
||||
raw_exec_args = config_get(config, "codex_exec_args") or ""
|
||||
if isinstance(raw_exec_args, list):
|
||||
extra_args = [str(v) for v in raw_exec_args]
|
||||
|
||||
@@ -93,6 +93,10 @@ def _format_tool_call(server: str, tool: str) -> str:
|
||||
name = ".".join(part for part in (server, tool) if part)
|
||||
return name or "tool"
|
||||
|
||||
def _is_command_log_line(line: str) -> bool:
|
||||
return f"{STATUS_DONE} ran:" in line
|
||||
|
||||
|
||||
def _extract_numeric_id(item_id: Optional[object], fallback: Optional[int] = None) -> Optional[int]:
|
||||
if isinstance(item_id, int):
|
||||
return item_id
|
||||
@@ -351,7 +355,10 @@ class ExecProgressRenderer:
|
||||
|
||||
def render_final(self, elapsed_s: float, answer: str, status: str = "done") -> str:
|
||||
header = _format_header(elapsed_s, self.state.last_turn, label=status)
|
||||
body = self._assemble(header, list(self.state.recent_actions))
|
||||
lines = list(self.state.recent_actions)
|
||||
if status == "done":
|
||||
lines = [line for line in lines if not _is_command_log_line(line)]
|
||||
body = self._assemble(header, lines)
|
||||
answer = (answer or "").strip()
|
||||
if answer:
|
||||
body = body + "\n\n" + answer
|
||||
|
||||
Reference in New Issue
Block a user