From 10b90ae0bfde1a2c912ebd28b3366e9cd0983e7e Mon Sep 17 00:00:00 2001 From: TheEdgeOfClaw Date: Mon, 23 Mar 2026 21:26:18 +0000 Subject: [PATCH 1/4] Remove /start command --- src/telegram.ts | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/telegram.ts b/src/telegram.ts index f7199b8..9df96b8 100644 --- a/src/telegram.ts +++ b/src/telegram.ts @@ -106,14 +106,7 @@ export function createBot(token: string, allowedUsers: number[]): Bot { } }); - bot.command("start", async (ctx) => { - const sessionId = getSessionId(ctx.chat.id); - const autoApproveStatus = sessionId && isAutoApprove(sessionId) ? "on" : "off"; - await ctx.reply( - `Welcome to ClawCode\\! Send me a message and I'll forward it to OpenCode\\.\n\nAuto\\-approve: *${autoApproveStatus}*`, - { parse_mode: "MarkdownV2" }, - ); - }); + bot.command("new", async (ctx) => { const chatId = ctx.chat.id; From ef0cc7b1ecdf7f51d95b38193ba43654efe2e866 Mon Sep 17 00:00:00 2001 From: TheEdgeOfClaw Date: Mon, 23 Mar 2026 21:29:38 +0000 Subject: [PATCH 2/4] Remove auto-approve functionality --- src/telegram.ts | 34 ---------------------------------- 1 file changed, 34 deletions(-) diff --git a/src/telegram.ts b/src/telegram.ts index 9df96b8..5f7eb14 100644 --- a/src/telegram.ts +++ b/src/telegram.ts @@ -14,8 +14,6 @@ import { abortSession, sendPrompt, replyPermission, - setAutoApprove, - isAutoApprove, } from "./opencode.js"; import { registerSession, unregisterSession } from "./events.js"; import { saveExchange } from "./memory.js"; @@ -174,29 +172,6 @@ export function createBot(token: string, allowedUsers: number[]): Bot { } }); - bot.command("autoapprove", async (ctx) => { - log.info(`[cmd] /autoapprove chat=${ctx.chat.id}`); - const arg = ctx.match?.trim().toLowerCase(); - if (arg !== "on" && arg !== "off") { - await ctx.reply("Usage: /autoapprove on \\| off", { parse_mode: "MarkdownV2" }); - return; - } - const sessionId = getSessionId(ctx.chat.id); - if (!sessionId) { - await ctx.reply("No active session\\. Use /new to create one\\.", { - parse_mode: "MarkdownV2", - }); - return; - } - const enabled = arg === "on"; - setAutoApprove(sessionId, enabled); - log.info(`[session] autoapprove=${enabled} session=${sessionId}`); - await ctx.reply( - escapeMarkdownV2(`Auto-approve ${enabled ? "enabled" : "disabled"} for current session.`), - { parse_mode: "MarkdownV2" }, - ); - }); - bot.command("history", async (ctx) => { log.info(`[cmd] /history chat=${ctx.chat.id}`); const sessionId = getSessionId(ctx.chat.id); @@ -373,15 +348,6 @@ export function createBot(token: string, allowedUsers: number[]): Bot { // onPermission async (perm: PermissionEvent) => { log.info(`[permission] request permission=${perm.permission} session=${perm.sessionID} perm=${perm.id}`); - if (isAutoApprove(perm.sessionID)) { - log.info(`[permission] auto-approving perm=${perm.id}`); - await replyPermission(perm.sessionID, perm.id, "once"); - await ctx.api.sendMessage(chatId, - escapeMarkdownV2(`Auto-approved: ${perm.permission} ${perm.patterns.join(", ")}`), - { parse_mode: "MarkdownV2" }, - ); - return; - } const key = String(++permCounter); pendingPerms.set(key, { sessionId: perm.sessionID, permissionId: perm.id }); const keyboard = new InlineKeyboard() From a9fd9f47ead5c19602370babbaabbdb98edba42e Mon Sep 17 00:00:00 2001 From: TheEdgeOfClaw Date: Mon, 23 Mar 2026 21:33:06 +0000 Subject: [PATCH 3/4] Remove autoapprove from opencode.ts and main.ts --- src/main.ts | 2 -- src/opencode.ts | 10 ---------- 2 files changed, 12 deletions(-) diff --git a/src/main.ts b/src/main.ts index 16287a4..f19f596 100644 --- a/src/main.ts +++ b/src/main.ts @@ -25,11 +25,9 @@ export const ClawCode: Plugin = async ({ client, directory }) => { const bot = createBot(token, allowedUsers); await bot.api.setMyCommands([ - { command: "start", description: "Welcome message" }, { command: "new", description: "New session" }, { command: "sessions", description: "List and switch sessions" }, { command: "abort", description: "Abort current session" }, - { command: "autoapprove", description: "Toggle auto-approve (on|off)" }, { command: "history", description: "Recent messages from current session" }, { command: "remember", description: "Save a memory (/remember )" }, { command: "start_llama", description: "Start llama service" }, diff --git a/src/opencode.ts b/src/opencode.ts index a2a4652..abf2e5a 100644 --- a/src/opencode.ts +++ b/src/opencode.ts @@ -8,7 +8,6 @@ let client: Client; let sessionsFile: string; const chatSessions = new Map(); -const autoApprove = new Set(); export function init(c: Client, directory: string): void { client = c; @@ -32,15 +31,6 @@ function saveSessions(): void { writeFileSync(sessionsFile, JSON.stringify(obj, null, 2)); } -export function setAutoApprove(sessionId: string, enabled: boolean): void { - if (enabled) autoApprove.add(sessionId); - else autoApprove.delete(sessionId); -} - -export function isAutoApprove(sessionId: string): boolean { - return autoApprove.has(sessionId); -} - export async function getOrCreateSession( chatId: number, ): Promise<{ sessionId: string; fallback: boolean }> { From 9e454218d7be981ba6627f210ef7507f9deefad4 Mon Sep 17 00:00:00 2001 From: TheEdgeOfClaw Date: Thu, 26 Mar 2026 14:24:46 +0000 Subject: [PATCH 4/4] Remove documentation for autoapprove --- AGENTS.md | 7 ++++--- README.md | 1 - 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index 6a51e79..1fc2969 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -18,7 +18,7 @@ The server loads the plugin at startup. The plugin starts a grammY long-polling src/ main.ts -- plugin entry: env validation, bot start, event hook telegram.ts -- grammY bot: auth middleware, commands, prompt dispatch, streaming edits - opencode.ts -- SDK client wrapper: session CRUD, prompt, abort, permissions, auto-approve + opencode.ts -- SDK client wrapper: session CRUD, prompt, abort, permissions format.ts -- MarkdownV2 escaping, code block preservation, tool summaries, message chunking events.ts -- event router: message.part.updated, permission.asked, streaming dispatch memory.ts -- exchange logging: saves every Telegram exchange as markdown to exchanges/ @@ -35,7 +35,7 @@ skills/ - Session-to-chat mapping persisted to `sessions.json` (resolved relative to `directory` from plugin context) - Streaming uses edit-in-place with 2s throttle to stay under Telegram rate limits - Prompt is fired non-blocking (`.then/.catch`) so grammY can process permission callbacks while waiting -- Permission requests surface as inline keyboards (Allow/Session/Deny); auto-approve is per-session toggle +- Permission requests surface as inline keyboards (Allow/Session/Deny) - Permission callback data uses short counter keys (Telegram 64-byte limit on callback data) - Message chunking respects code block boundaries at 4096 char Telegram limit - Server sends `permission.asked` with a shape that diverges from the SDK's v1 `Permission` type. @@ -51,6 +51,7 @@ skills/ ## Config Environment variables (set in server's environment or systemd `EnvironmentFile=`): + - `TELEGRAM_BOT_TOKEN` -- required - `TELEGRAM_ALLOWED_USERS` -- required, comma-separated Telegram user IDs - `OPENCODE_WORKSPACE` -- optional, server working directory (used by Makefile at install time) @@ -78,7 +79,7 @@ Install the plugin into the OpenCode workspace's plugin directory (symlink or co | Telegram lib | grammY | Lightweight, TypeScript-native | | Runtime | bun | No build step, runs TS directly | | Bot mode | Long polling | Simpler than webhooks for single-user | -| Session mapping | File-persisted Map | Survives restarts; auto-approve is in-memory only | +| Session mapping | File-persisted Map | Survives restarts | | Deployment | systemd user service | Reliable, auto-restart, journald logging | | Streaming | Edit-in-place messages | ChatGPT-style UX with 2s throttle | | Prompt execution | Non-blocking `.then/.catch` | Avoids deadlock: grammY must process permission callbacks while prompt blocks | diff --git a/README.md b/README.md index f239888..8e1a1cd 100644 --- a/README.md +++ b/README.md @@ -49,7 +49,6 @@ make uninstall | `/new` | New session | | `/sessions` | List and switch sessions | | `/abort` | Abort current session | -| `/autoapprove on\|off` | Toggle auto-approve for permissions | | `/history` | Recent messages from current session | | `/remember ` | Save a memory to MEMORY.md via OpenCode | | `/start_llama` | Start llama systemd service |