diff --git a/packages/cli/src/index.ts b/packages/cli/src/index.ts index 24fbec79..19693b9d 100644 --- a/packages/cli/src/index.ts +++ b/packages/cli/src/index.ts @@ -643,8 +643,6 @@ async function main(): Promise { const ob = await outboxStats(db); console.log(`outbox: ${ob.pending} ожидают, ${ob.failed} не доставлены`); console.log(`раннеры: ${(await listSessions(db, { active: true })).length} активных · вопросы: ${(await pendingQuestions(db)).length} открытых`); - const foreign = await tmux.foreignServerEnv().catch(() => []); - if (foreign.length) console.log(`⚠ в окружении tmux-сервера чужие переменные: ${foreign.join(", ")} — агенты их унаследуют; очистятся при следующем запуске раннера или: ${foreign.map((n) => `tmux set-environment -g -u ${n}`).join("; ")}`); const paired = new Set((await adminRecipients(db)).map((u) => u.login)); const admins = (await platformAdmins(db)).map((l) => `${l}${paired.has(l) ? " (Telegram)" : " (без Telegram)"}`); console.log(`админы: ${admins.join(", ") || "нет"}`); diff --git a/packages/runner/src/tmux.ts b/packages/runner/src/tmux.ts index a63468e7..71ad3c8c 100644 --- a/packages/runner/src/tmux.ts +++ b/packages/runner/src/tmux.ts @@ -41,35 +41,6 @@ export interface NewTmuxSession { width?: number; } -/** - * PEP-69: names that must never come from a tmux server's global environment. Every session - * inherits it, and a server started by some test run or tool shell carries that process's - * GITEA_*, PEPPA_*, DATABASE_URL, MOCK_* — agents and their MCP then talk to the wrong place. - * What an agent needs is passed per session (`new-session -e`) or read from `.env`. - */ -const FOREIGN_ENV = /^(GITEA_|PEPPA_|MOCK_|DATABASE_URL$)/; - -/** Foreign variables in the global environment of the tmux server (default server only). */ -export async function foreignServerEnv(p: Pane = { name: "" }): Promise { - // A dedicated socket (-L, tests) is its owner's own server: nothing foreign in it. - if (process.env.PEPPA_TMUX_SOCKET) return []; - let out: string; - try { - out = await tmuxOn(p, ["show-environment", "-g"]); - } catch (e) { - if (e instanceof HostUnreachable) throw e; - return []; // no server running - } - return out.split("\n").map((l) => l.split("=")[0]!.trim()).filter((k) => FOREIGN_ENV.test(k)); -} - -/** Removes them from the server's global environment; returns the names removed. */ -export async function scrubServerEnv(p: Pane = { name: "" }): Promise { - const names = await foreignServerEnv(p); - for (const n of names) await tmuxOn(p, ["set-environment", "-g", "-u", n]); - return names; -} - export async function newSession(s: NewTmuxSession): Promise { if (isRunnerClient()) return viaService("newSession", [s]); const envArgs = Object.entries(s.env).flatMap(([k, v]) => ["-e", `${k}=${v}`]); @@ -77,7 +48,6 @@ export async function newSession(s: NewTmuxSession): Promise { // Keep the server up when its last session ends: otherwise a session created while the // previous last one is being killed can land on a server that is shutting down. await tmuxOn(p, ["start-server", ";", "set-option", "-s", "exit-empty", "off"]); - await scrubServerEnv(p).catch(() => {}); // PEP-69 await tmuxOn(p, ["new-session", "-d", "-s", s.name, "-c", s.cwd, "-x", String(s.width ?? 220), "-y", "50", ...envArgs, s.command]); // Keep the pane after claude exits so the watchdog can read the exit status. await tmuxOn(p, ["set-option", "-t", s.name, "remain-on-exit", "on"]);