agent-console 1.3.1: 全部自动同意 (Auto-approve all), split out of #727 (#747)

Auto-approve all (全部自动同意) ships in agent-console 1.3.1, split out of #727 (qingnian108).

The mode is off by default. In it, Codex runs with its sandbox off and Claude Code skips its checks. Cursor, OpenCode and dsh requests are answered allow-once by the console, never allow_always or acceptForSession. Each auto answer is saved with `auto: true` before the Agent goes on, and a banner shows while the mode is on. Plan confirmations and questions still ask. A 1.2 默认 of 全部放行 is not silently upgraded to real auto-approve. Pi keeps the `default` mode id ("Pi never asks"), so switching Agents before the first message never carries auto-approve into an Agent the user didn't pick.

Reviewed at 7e55c87ca merged onto main 20b89389:
- Linux (WSL2 Ubuntu 24.04): root `bun test packages/agent-console` 6/6; `bun scripts/check.mjs` OK; `npm run check` OK; vitest 461 passed / 17 skipped; `verify:build` 5/5 identical.
- Windows 11 (Edge): `e2e:v1` 29/29.
- Linux e2e stops at scenario 5 (steer timeout). It does the same on main 1.3.0, so it was filed as #753.
- Broken by hand:
  - Pi's modeMap back to bypassPermissions: 2 tests red.
  - The keeps line shown for every Agent: 1 test red.
  - Pi's label branch removed: 1 test red.
- An earlier round at 049449612 on macOS checked the daemon behaviour with probes. This version is published from the dist branch; the package isn't on npm.
This commit is contained in:
qingnian108
2026-11-05 14:02:29 +08:00
committed by GitHub
parent 20b893893f
commit 2c4e76dbba
38 changed files with 1378 additions and 136 deletions
@@ -23,6 +23,7 @@ import { clearBinCache } from "../util/bin.js";
import { cachedDetect, cachedModels, clearProviderCache } from "../providers/infoCache.js";
import { launchFromSettings } from "../providers/launch.js";
import { clampMode } from "../providers/modes.js";
import { endLegacyDefault, guardLegacyMode, upgradeNotice } from "../migrate/autoApprove13.js";
import { setAppLocale, tr, intlLocale } from "../util/i18n.js";
import { MAX_MENTIONS } from "../util/mentions.js";
import { openExternal } from "../util/openExternal.js";
@@ -153,6 +154,8 @@ export function registerMethods(gw: Gateway, svc: Services): void {
if (!checked.ok) throw new ApiError("bad_params", `Invalid setting: ${checked.error}`);
const before = await svc.settings.get();
const next = await svc.settings.set(checked.patch as Partial<Settings>);
// 1.3: a default permission mode picked after the upgrade is the user's 1.3 choice (ends the 1.2 全部放行 guard)
if ("defaultMode" in checked.patch) await endLegacyDefault(svc.settings);
// 1.3: Settings → Bash path (Windows) re-runs Git Bash detection for the next agent start
if ("bashPath" in checked.patch && (before.bashPath ?? "") !== (next.bashPath ?? "")) {
await refreshAgentShell(typeof next.bashPath === "string" ? next.bashPath : "");
@@ -329,8 +332,11 @@ export function registerMethods(gw: Gateway, svc: Services): void {
}
// B8: the default permission mode is mapped onto this Agent's own modes (same rule as thread.setProvider)
const provider = getProvider(p.provider);
const mode = clampMode(provider?.capabilities.modes ?? [], p.mode);
// 1.3 (#727 review 3): a pre-1.3 default of 全部放行 stays 每次询问 for Agents it did nothing for in 1.2 (told once)
const guard = await guardLegacyMode(svc.settings, p.provider, clampMode(provider?.capabilities.modes ?? [], p.mode));
const mode = guard.mode;
const meta = await svc.threads.create({ ...p, mode });
if (guard.notice) await svc.threads.appendEvent(meta.id, upgradeNotice());
gw.publish("sidebar", { type: "thread.upsert", thread: meta });
return meta;
}