chore: remove unused exec-bridge flags
This commit is contained in:
@@ -35,13 +35,14 @@ uv run exec-bridge
|
|||||||
|
|
||||||
Optional flags:
|
Optional flags:
|
||||||
|
|
||||||
- `--progress-edit-every FLOAT` (default `2.0`)
|
|
||||||
- `--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)
|
- `--debug/--no-debug` (default no debug logging; use `--debug | tee debug.log` to capture)
|
||||||
- `--cd PATH` (pass through to `codex --cd`)
|
- `--cd PATH` (pass through to `codex --cd`)
|
||||||
- `--model NAME` (pass through to `codex exec`)
|
- `--model NAME` (pass through to `codex exec`)
|
||||||
|
|
||||||
Progress updates are always sent silently.
|
Progress updates are always sent silently.
|
||||||
|
Pending updates are always ignored on startup.
|
||||||
|
Progress updates are throttled to roughly every 2 seconds.
|
||||||
|
|
||||||
To resume an existing thread without a database, reply with (or include) the session id shown at the end of the bot response:
|
To resume an existing thread without a database, reply with (or include) the session id shown at the end of the bot response:
|
||||||
|
|
||||||
|
|||||||
@@ -308,8 +308,6 @@ class BridgeConfig:
|
|||||||
bot: TelegramClient
|
bot: TelegramClient
|
||||||
runner: CodexExecRunner
|
runner: CodexExecRunner
|
||||||
chat_id: int
|
chat_id: int
|
||||||
ignore_backlog: bool
|
|
||||||
progress_edit_every_s: float
|
|
||||||
final_notify: bool
|
final_notify: bool
|
||||||
startup_msg: str
|
startup_msg: str
|
||||||
max_concurrency: int
|
max_concurrency: int
|
||||||
@@ -317,9 +315,7 @@ class BridgeConfig:
|
|||||||
|
|
||||||
def _parse_bridge_config(
|
def _parse_bridge_config(
|
||||||
*,
|
*,
|
||||||
progress_edit_every_s: float,
|
|
||||||
final_notify: bool,
|
final_notify: bool,
|
||||||
ignore_backlog: bool,
|
|
||||||
cd: str | None,
|
cd: str | None,
|
||||||
model: str | None,
|
model: str | None,
|
||||||
) -> BridgeConfig:
|
) -> BridgeConfig:
|
||||||
@@ -366,8 +362,6 @@ def _parse_bridge_config(
|
|||||||
bot=bot,
|
bot=bot,
|
||||||
runner=runner,
|
runner=runner,
|
||||||
chat_id=chat_id,
|
chat_id=chat_id,
|
||||||
ignore_backlog=bool(ignore_backlog),
|
|
||||||
progress_edit_every_s=progress_edit_every_s,
|
|
||||||
final_notify=final_notify,
|
final_notify=final_notify,
|
||||||
startup_msg=startup_msg,
|
startup_msg=startup_msg,
|
||||||
max_concurrency=16,
|
max_concurrency=16,
|
||||||
@@ -386,8 +380,6 @@ async def _send_startup(cfg: BridgeConfig) -> None:
|
|||||||
|
|
||||||
|
|
||||||
async def _drain_backlog(cfg: BridgeConfig, offset: int | None) -> int | None:
|
async def _drain_backlog(cfg: BridgeConfig, offset: int | None) -> int | None:
|
||||||
if not cfg.ignore_backlog:
|
|
||||||
return offset
|
|
||||||
try:
|
try:
|
||||||
updates = await cfg.bot.get_updates(
|
updates = await cfg.bot.get_updates(
|
||||||
offset=offset, timeout_s=0, allowed_updates=["message"]
|
offset=offset, timeout_s=0, allowed_updates=["message"]
|
||||||
@@ -486,7 +478,7 @@ async def _handle_message(
|
|||||||
if not progress_renderer.note_event(evt):
|
if not progress_renderer.note_event(evt):
|
||||||
return
|
return
|
||||||
now = time.monotonic()
|
now = time.monotonic()
|
||||||
if (now - last_edit_at) < cfg.progress_edit_every_s:
|
if (now - last_edit_at) < 2.0:
|
||||||
return
|
return
|
||||||
if edit_task is not None and not edit_task.done():
|
if edit_task is not None and not edit_task.done():
|
||||||
return
|
return
|
||||||
@@ -646,32 +638,16 @@ async def _run_main_loop(cfg: BridgeConfig) -> None:
|
|||||||
|
|
||||||
|
|
||||||
def run(
|
def run(
|
||||||
progress_edit_every_s: float = typer.Option(
|
|
||||||
2.0,
|
|
||||||
"--progress-edit-every",
|
|
||||||
help="Minimum seconds between progress message edits.",
|
|
||||||
min=1.0,
|
|
||||||
),
|
|
||||||
final_notify: bool = typer.Option(
|
final_notify: bool = typer.Option(
|
||||||
True,
|
True,
|
||||||
"--final-notify/--no-final-notify",
|
"--final-notify/--no-final-notify",
|
||||||
help="Send the final response as a new message (not an edit).",
|
help="Send the final response as a new message (not an edit).",
|
||||||
),
|
),
|
||||||
ignore_backlog: bool = typer.Option(
|
|
||||||
True,
|
|
||||||
"--ignore-backlog/--process-backlog",
|
|
||||||
help="Skip pending Telegram updates that arrived before startup.",
|
|
||||||
),
|
|
||||||
debug: bool = typer.Option(
|
debug: bool = typer.Option(
|
||||||
False,
|
False,
|
||||||
"--debug/--no-debug",
|
"--debug/--no-debug",
|
||||||
help="Log codex JSONL, Telegram requests, and rendered messages.",
|
help="Log codex JSONL, Telegram requests, and rendered messages.",
|
||||||
),
|
),
|
||||||
log_file: str | None = typer.Option(
|
|
||||||
None,
|
|
||||||
"--log-file",
|
|
||||||
help="Write detailed logs to this file.",
|
|
||||||
),
|
|
||||||
cd: str | None = typer.Option(
|
cd: str | None = typer.Option(
|
||||||
None,
|
None,
|
||||||
"--cd",
|
"--cd",
|
||||||
@@ -683,11 +659,9 @@ def run(
|
|||||||
help="Codex model to pass to `codex exec`.",
|
help="Codex model to pass to `codex exec`.",
|
||||||
),
|
),
|
||||||
) -> None:
|
) -> None:
|
||||||
setup_logging(log_file if log_file else None, debug=debug)
|
setup_logging(debug=debug)
|
||||||
cfg = _parse_bridge_config(
|
cfg = _parse_bridge_config(
|
||||||
progress_edit_every_s=progress_edit_every_s,
|
|
||||||
final_notify=final_notify,
|
final_notify=final_notify,
|
||||||
ignore_backlog=ignore_backlog,
|
|
||||||
cd=cd,
|
cd=cd,
|
||||||
model=model,
|
model=model,
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ from __future__ import annotations
|
|||||||
import logging
|
import logging
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
from logging.handlers import RotatingFileHandler
|
|
||||||
|
|
||||||
TELEGRAM_TOKEN_RE = re.compile(r"bot\d+:[A-Za-z0-9_-]+")
|
TELEGRAM_TOKEN_RE = re.compile(r"bot\d+:[A-Za-z0-9_-]+")
|
||||||
TELEGRAM_BARE_TOKEN_RE = re.compile(r"\b\d+:[A-Za-z0-9_-]{10,}\b")
|
TELEGRAM_BARE_TOKEN_RE = re.compile(r"\b\d+:[A-Za-z0-9_-]{10,}\b")
|
||||||
@@ -24,7 +23,7 @@ class RedactTokenFilter(logging.Filter):
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
def setup_logging(log_file: str | None, *, debug: bool = False) -> None:
|
def setup_logging(*, debug: bool = False) -> None:
|
||||||
root_logger = logging.getLogger()
|
root_logger = logging.getLogger()
|
||||||
root_logger.setLevel(logging.DEBUG)
|
root_logger.setLevel(logging.DEBUG)
|
||||||
for handler in root_logger.handlers[:]:
|
for handler in root_logger.handlers[:]:
|
||||||
@@ -39,16 +38,3 @@ def setup_logging(log_file: str | None, *, debug: bool = False) -> None:
|
|||||||
console.setFormatter(fmt)
|
console.setFormatter(fmt)
|
||||||
console.addFilter(redactor)
|
console.addFilter(redactor)
|
||||||
root_logger.addHandler(console)
|
root_logger.addHandler(console)
|
||||||
|
|
||||||
if log_file:
|
|
||||||
file_handler = RotatingFileHandler(
|
|
||||||
log_file,
|
|
||||||
maxBytes=5 * 1024 * 1024,
|
|
||||||
backupCount=3,
|
|
||||||
encoding="utf-8",
|
|
||||||
)
|
|
||||||
file_handler.setLevel(logging.DEBUG if debug else logging.INFO)
|
|
||||||
file_handler.setFormatter(fmt)
|
|
||||||
file_handler.addFilter(redactor)
|
|
||||||
root_logger.addHandler(file_handler)
|
|
||||||
logging.getLogger(__name__).debug("[debug] file logger initialized path=%r", log_file)
|
|
||||||
|
|||||||
@@ -96,8 +96,6 @@ def test_final_notify_sends_loud_final_message() -> None:
|
|||||||
bot=bot, # type: ignore[arg-type]
|
bot=bot, # type: ignore[arg-type]
|
||||||
runner=runner, # type: ignore[arg-type]
|
runner=runner, # type: ignore[arg-type]
|
||||||
chat_id=123,
|
chat_id=123,
|
||||||
ignore_backlog=True,
|
|
||||||
progress_edit_every_s=999.0,
|
|
||||||
final_notify=True,
|
final_notify=True,
|
||||||
startup_msg="",
|
startup_msg="",
|
||||||
max_concurrency=1,
|
max_concurrency=1,
|
||||||
@@ -128,8 +126,6 @@ def test_new_final_message_forces_notification_when_too_long_to_edit() -> None:
|
|||||||
bot=bot, # type: ignore[arg-type]
|
bot=bot, # type: ignore[arg-type]
|
||||||
runner=runner, # type: ignore[arg-type]
|
runner=runner, # type: ignore[arg-type]
|
||||||
chat_id=123,
|
chat_id=123,
|
||||||
ignore_backlog=True,
|
|
||||||
progress_edit_every_s=999.0,
|
|
||||||
final_notify=False,
|
final_notify=False,
|
||||||
startup_msg="",
|
startup_msg="",
|
||||||
max_concurrency=1,
|
max_concurrency=1,
|
||||||
|
|||||||
Reference in New Issue
Block a user