Run Telegram turns with full access by default

This commit is contained in:
2026-06-10 11:20:07 +09:00
parent 060a6950a4
commit f92fc8a718
4 changed files with 35 additions and 20 deletions

View File

@@ -254,7 +254,11 @@ class TelegramCodexBot:
if not prompt:
await self._reply(update, "사용법: /ask <요청 내용>")
return
await self._run_codex_from_update(update, prompt)
await self._run_codex_from_update(
update,
prompt,
sandbox=self.config.write_sandbox,
)
async def work(self, update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
if not await self._guard(update):
@@ -969,7 +973,7 @@ class TelegramCodexBot:
)
return
selected_sandbox = sandbox or self.config.readonly_sandbox
selected_sandbox = sandbox or self.config.write_sandbox
auto_repo_path = self._auto_select_repo_for_prompt(chat_id, prompt)
if auto_repo_path is not None:
await self._close_client_for_chat(chat_id)
@@ -988,7 +992,7 @@ class TelegramCodexBot:
prompt_preview=preview,
sandbox=selected_sandbox,
)
mode = "쓰기 작업" if selected_sandbox != self.config.readonly_sandbox else "조회 작업"
mode = _sandbox_mode_label(selected_sandbox, self.config)
repo_note = f"\n자동 작업폴더: {auto_repo_path}" if auto_repo_path else ""
await self._reply(
update,
@@ -1205,7 +1209,7 @@ class TelegramCodexBot:
result, fallback_note = await self._run_codex_for_chat(
chat_id=chat_id,
prompt=prompt,
sandbox=self.config.readonly_sandbox,
sandbox=self.config.write_sandbox,
update_chat_state=False,
session_id_override=schedule.get("thread_id") or None,
)
@@ -1293,7 +1297,7 @@ class TelegramCodexBot:
return "현재작업=없음"
elapsed = int(time.monotonic() - job.started_monotonic)
minutes, seconds = divmod(elapsed, 60)
mode = "write" if job.sandbox != self.config.readonly_sandbox else "read-only"
mode = _sandbox_mode_label(job.sandbox, self.config)
return (
"현재작업=진행 중\n"
f"작업모드={mode}\n"
@@ -1335,9 +1339,9 @@ class TelegramCodexBot:
"use the gitea_* MCP tools. Never reveal GITEA_TOKEN or print commands that embed it. "
"For HTTPS git clone/fetch/push, the container may provide GIT_ASKPASS from the "
"configured Gitea environment.\n"
"Only edit files, commit, or push when this turn is running with a write-capable "
"sandbox, typically from the Telegram /work command. In read-only turns, inspect and "
"explain instead of attempting file edits.\n"
"This bridge is configured for full-access turns by default. You may edit files "
"when the user asks for work that requires changes. Commit or push only when the "
"user explicitly asks for commit/push or when the request clearly includes publishing.\n"
"If the user asks to schedule, remind, monitor, or notify later, use the "
"telegram_create_schedule MCP tool. Use the default chat_id above and do not ask "
"for a destination unless the user explicitly wants a different chat. The schedule "
@@ -1376,7 +1380,7 @@ class TelegramCodexBot:
def _should_use_app_server(self, sandbox: str) -> bool:
if self.config.codex_backend == "exec":
return False
return sandbox == self.config.readonly_sandbox
return True
def _auto_select_repo_for_prompt(self, chat_id: int, prompt: str) -> Path | None:
chat_state = self.state.get_chat(chat_id)
@@ -1441,6 +1445,16 @@ def _display_speed(speed_mode: str) -> str:
return "fast(고속)" if speed_mode == "fast" else "standard(보통)"
def _sandbox_mode_label(sandbox: str, config: Config) -> str:
if sandbox == "danger-full-access" or sandbox == config.write_sandbox:
return "full-access"
if sandbox == "workspace-write":
return "workspace-write"
if sandbox == "read-only" or sandbox == config.readonly_sandbox:
return "read-only"
return sandbox
def _args_text(context: ContextTypes.DEFAULT_TYPE) -> str:
return " ".join(context.args).strip()