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
@@ -45,7 +45,9 @@ export const acpCapabilities: Capabilities = {
export const cursorAcpCapabilities: Capabilities = {
...acpCapabilities,
questions: true,
modes: ["default", "plan", "ask"],
// 1.3: bypassPermissions = 全部自动同意: Cursor's agent mode, every approval answered "allow once" by the daemon
// (Cursor's own --force only exists at spawn, and Auto-review is not applied over ACP)
modes: ["default", "bypassPermissions", "plan", "ask"],
};
function runVersion(r: ResolveResult & { ok: true }, args: string[], timeoutMs = 8000): Promise<string> {
@@ -79,7 +81,7 @@ async function resolveProviderBin(cfg: AcpProviderConfig) {
export function createAcpProvider(cfg: AcpProviderConfig): Provider {
const base = cfg.capabilities ?? acpCapabilities;
// With a mode table, expose only the modes the Agent really has (in our fixed order)
const ORDER: Mode[] = ["plan", "default", "acceptEdits", "bypassPermissions"];
const ORDER: Mode[] = ["plan", "default", "acceptEdits", "bypassPermissions", "ask"];
const caps: Capabilities = cfg.modeMap
? { ...base, modes: ORDER.filter((m) => cfg.modeMap![m] !== undefined), modeLabels: cfg.modeLabels }
: base;
@@ -268,7 +268,7 @@ export class AcpSession implements ProviderSession {
return hit?.id ?? want;
}
if (this.o.flavor === "cursor") {
const map: Partial<Record<Mode, string>> = { default: "agent", plan: "plan", ask: "ask" };
const map: Partial<Record<Mode, string>> = { default: "agent", bypassPermissions: "agent", plan: "plan", ask: "ask" };
const want = map[mode] ?? "agent";
const avail = this.active?.modes?.availableModes ?? [];
const hit = avail.find((m) => m.id === want || m.name.toLowerCase() === want);
@@ -49,8 +49,9 @@ export function acpConfigForEntry(entry: ProviderCatalogEntry, appVersion: strin
...base,
acpArgs: ["acp"],
fetchModels: acpProbeModels(["acp"], entry.id),
modeMap: { plan: "plan", default: "build" },
modeLabels: { plan: "Plan", default: "Build" },
// 1.3: 全部自动同意 = build + the daemon answers each approval "allow once" (OPENCODE_PERMISSION only applies at spawn)
modeMap: { plan: "plan", default: "build", bypassPermissions: "build" },
modeLabels: { plan: "Plan", default: "Build", bypassPermissions: "Build" },
};
case "copilot":
// As Paseo: Agent / Plan / Allow All. Allow All = agent mode + allow_all config on (autopilot is not used)
@@ -62,7 +63,9 @@ export function acpConfigForEntry(entry: ProviderCatalogEntry, appVersion: strin
modeLabels: { plan: "Plan", default: "Agent", bypassPermissions: "Allow All" },
};
case "pi":
// pi-acp has no mode options; thinking level thought_level (low…max)
// pi-acp has no mode options; thinking level thought_level (low…max). Pi never asks before its tools, so its one
// mode uses the neutral default id (shown read-only; nothing is sent), so switching Agents never carries
// bypassPermissions into an Agent the user did not choose. Pi extensions' own dialogs still reach the user.
return { ...base, acpArgs: [], fetchModels: acpProbeModels([], entry.id), modeMap: { default: "" } };
case "dsh":
// Started on the conversation's route (--patch), so its initialize advertises image input for that model (see dsh.ts)
@@ -0,0 +1,60 @@
// 1.3 "全部自动同意" (full auto-approve): the permission chip's bypassPermissions mode, for every Agent.
//
// Where the Agent has its own switch we use it (see FULL_AUTO); the daemon also answers every tool approval the Agent
// still asks for while the mode is on, so Agents that only ask over their protocol (Cursor / OpenCode / dsh over ACP)
// stop asking too, and a card already on screen is approved the moment the user turns the mode on.
//
// The answer is always the option that covers this one request ("Allow once" / accept), never "Allow always":
// an allow-always answer can make the Agent write a permanent rule into the user's own config (Cursor's allowlist,
// OpenCode's permission file), which would outlive the mode. Questions and plan approvals are never auto-answered.
import type { Mode } from "./types.js";
export const FULL_AUTO: Mode = "bypassPermissions";
export type ApprovalOption = { id: string; label?: string; kind?: string };
export type ApprovalRequest = { kind?: string; options: ApprovalOption[] };
/** How full-auto works for each Agent (also the source of the plan's table) */
export const FULL_AUTO_NATIVE: Record<string, { native: string; live: "live" | "nextTurn" | "none"; daemonAnswers: boolean }> = {
claude: { native: "--permission-mode bypassPermissions (+ --allow-dangerously-skip-permissions)", live: "nextTurn", daemonAnswers: true },
codex: { native: "approvalPolicy never + sandbox danger-full-access (turn/start)", live: "nextTurn", daemonAnswers: true },
cursor: { native: "none over ACP (--force is spawn-only); ACP mode agent", live: "live", daemonAnswers: true },
copilot: { native: "ACP config allow_all = on (agent mode)", live: "live", daemonAnswers: true },
opencode: { native: "none over ACP (OPENCODE_PERMISSION is spawn-only); ACP mode build", live: "live", daemonAnswers: true },
devin: { native: "ACP mode bypass", live: "live", daemonAnswers: true },
dsh: { native: "none known; ACP default mode", live: "live", daemonAnswers: true },
// pi never asks before its own tools; requestPermission only carries Pi extensions' own dialogs, which stay with the user
pi: { native: "always (Pi has no tool approvals)", live: "live", daemonAnswers: false },
mock: { native: "mock", live: "live", daemonAnswers: true },
};
const REJECT = /reject|deny|decline|cancel|never|拒绝/i;
const ALLOW = /allow|accept|approve|yes|允许|同意/i;
/**
* The option that allows just this request: kind allow_once, else an allow-looking id/label that is not "always" /
* "session". Never allow_always (that writes a lasting rule into the Agent's own config): when a request offers
* nothing narrower, null, and the card is left for the user.
*/
export function pickAllowOnce(options: ApprovalOption[]): ApprovalOption | null {
const once = options.find((o) => o.kind === "allow_once");
if (once) return once;
const plain = options.find((o) => {
const s = `${o.id} ${o.label ?? ""}`;
return !o.kind?.startsWith("reject") && !REJECT.test(s) && ALLOW.test(s) && !/always|session|总是|始终/i.test(s);
});
return plain ?? null;
}
/** The daemon answers this request itself: the mode is full-auto, the Agent lets us, it is a tool approval and something allows it */
export function autoApproveOption(
mode: Mode | null | undefined,
providerId: string,
req: ApprovalRequest,
): ApprovalOption | null {
if (mode !== FULL_AUTO) return null;
if (FULL_AUTO_NATIVE[providerId]?.daemonAnswers === false) return null;
// A plan ("implement this plan?") is a decision, not a tool permission
if (req.kind === "plan" || req.kind === "switch_mode") return null;
return pickAllowOnce(req.options);
}