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:
+159
-9
@@ -147,6 +147,8 @@ var init_i18n = __esm({
|
||||
"notice.sessionStartFailed": "\u4F1A\u8BDD\u542F\u52A8\u5931\u8D25\uFF1A{detail}",
|
||||
"notice.sendFailed": "\u53D1\u9001\u5931\u8D25\uFF1A{detail}",
|
||||
"notice.bashMissing": "\u6CA1\u6709\u627E\u5230 Git Bash\u3002\u8FD9\u4E2A Agent \u5728 Windows \u4E0A\u8981\u7528 Git Bash \u8FD0\u884C\u547D\u4EE4\uFF08C:\\Windows\\System32\\bash.exe \u662F WSL \u542F\u52A8\u5668\uFF0C\u4E0D\u80FD\u7528\uFF09\u3002\u8BF7\u5B89\u88C5 Git for Windows\uFF1Ahttps://git-scm.com/download/win \uFF0C\u6216\u5728\u300C\u8BBE\u7F6E \u2192 Bash \u8DEF\u5F84\u300D\u91CC\u624B\u52A8\u6307\u5B9A bash.exe\u3002",
|
||||
"notice.autoApproveUpgrade": "1.3 \u65B0\u589E\u300C\u5168\u90E8\u81EA\u52A8\u540C\u610F\u300D\uFF1A\u73B0\u5728\u5BF9 Cursor\u3001OpenCode\u3001dsh \u4E5F\u4F1A\u771F\u6B63\u81EA\u52A8\u540C\u610F\uFF081.2 \u7684\u300C\u5168\u90E8\u653E\u884C\u300D\u5BF9\u5B83\u4EEC\u4E0D\u751F\u6548\uFF0C\u4ECD\u4F1A\u8BE2\u95EE\uFF09\u3002\u4F60\u4E4B\u524D\u628A\u9ED8\u8BA4\u6743\u9650\u6A21\u5F0F\u8BBE\u6210\u4E86\u5B83\uFF0C\u4E3A\u5B89\u5168\u8D77\u89C1\u8FD9\u4E2A\u5BF9\u8BDD\u4ECD\u4ECE\u300C\u6BCF\u6B21\u8BE2\u95EE\u300D\u5F00\u59CB\uFF1B\u9700\u8981\u65F6\u8BF7\u5728\u4E0B\u65B9\u6743\u9650\u83DC\u5355\u91CC\u624B\u52A8\u5F00\u542F\uFF0C\u6216\u5728\u8BBE\u7F6E\u91CC\u91CD\u65B0\u9009\u62E9\u9ED8\u8BA4\u6743\u9650\u6A21\u5F0F\u3002",
|
||||
"notice.autoApproveMigrated": "\u8FD9\u4E2A\u5BF9\u8BDD\u5728 1.2 \u91CC\u8BBE\u6210\u4E86\u300C\u5168\u90E8\u653E\u884C\u300D\uFF0C\u5F53\u65F6\u8FD9\u4E2A Agent \u5B9E\u9645\u4ECD\u4F1A\u8BE2\u95EE\u30021.3 \u8D77\u300C\u5168\u90E8\u81EA\u52A8\u540C\u610F\u300D\u4F1A\u771F\u6B63\u81EA\u52A8\u540C\u610F\uFF0C\u6240\u4EE5\u5DF2\u6539\u56DE\u300C\u6BCF\u6B21\u8BE2\u95EE\u300D\uFF1B\u9700\u8981\u65F6\u8BF7\u5728\u4E0B\u65B9\u6743\u9650\u83DC\u5355\u91CC\u624B\u52A8\u5F00\u542F\u3002",
|
||||
"notice.effortNextTurn": "\u601D\u8003\u5F3A\u5EA6\u5DF2\u4FDD\u5B58\uFF0C\u5C06\u5728\u4E0B\u4E00\u8F6E\u751F\u6548",
|
||||
"notice.effortResetOnModel": "\u5F53\u524D\u6A21\u578B\u4E0D\u652F\u6301\u8BE5\u601D\u8003\u5F3A\u5EA6\uFF0C\u5DF2\u6062\u590D\u4E3A Default",
|
||||
"turn.agentExit": "Agent \u8FDB\u7A0B\u610F\u5916\u9000\u51FA",
|
||||
@@ -258,6 +260,8 @@ var init_i18n = __esm({
|
||||
"notice.sessionStartFailed": "Session start failed: {detail}",
|
||||
"notice.sendFailed": "Send failed: {detail}",
|
||||
"notice.bashMissing": "Git Bash was not found. On Windows this agent runs its commands with Git Bash (C:\\Windows\\System32\\bash.exe is the WSL launcher and won't work). Install Git for Windows: https://git-scm.com/download/win , or set bash.exe under Settings \u2192 Bash path.",
|
||||
"notice.autoApproveUpgrade": "New in 1.3: Auto-approve all now really auto-approves for Cursor, OpenCode and dsh too (1.2's bypass mode did nothing for them; they still asked). Your default permission mode was set to it, so to be safe this conversation starts in Always Ask; switch it on in the permission menu below if you want it, or pick the default permission mode again in Settings.",
|
||||
"notice.autoApproveMigrated": "This conversation was set to bypass permissions in 1.2, where this agent still asked anyway. From 1.3 Auto-approve all really auto-approves, so it was put back to Always Ask; switch it on in the permission menu below if you want it.",
|
||||
"notice.effortNextTurn": "Reasoning effort saved \u2014 takes effect on the next turn",
|
||||
"notice.effortResetOnModel": "This model does not support that effort level; reset to Default",
|
||||
"turn.agentExit": "Agent process exited unexpectedly",
|
||||
@@ -4871,7 +4875,7 @@ var init_session3 = __esm({
|
||||
return hit?.id ?? want;
|
||||
}
|
||||
if (this.o.flavor === "cursor") {
|
||||
const map = { default: "agent", plan: "plan", ask: "ask" };
|
||||
const map = { default: "agent", bypassPermissions: "agent", plan: "plan", ask: "ask" };
|
||||
const want = map[mode2] ?? "agent";
|
||||
const avail = this.active?.modes?.availableModes ?? [];
|
||||
const hit = avail.find((m) => m.id === want || m.name.toLowerCase() === want);
|
||||
@@ -5138,7 +5142,7 @@ async function resolveProviderBin(cfg2) {
|
||||
}
|
||||
function createAcpProvider(cfg2) {
|
||||
const base = cfg2.capabilities ?? acpCapabilities;
|
||||
const ORDER = ["plan", "default", "acceptEdits", "bypassPermissions"];
|
||||
const ORDER = ["plan", "default", "acceptEdits", "bypassPermissions", "ask"];
|
||||
const caps = cfg2.modeMap ? { ...base, modes: ORDER.filter((m) => cfg2.modeMap[m] !== void 0), modeLabels: cfg2.modeLabels } : base;
|
||||
return {
|
||||
id: cfg2.id,
|
||||
@@ -5219,7 +5223,9 @@ var init_provider3 = __esm({
|
||||
cursorAcpCapabilities = {
|
||||
...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"]
|
||||
};
|
||||
}
|
||||
});
|
||||
@@ -5487,8 +5493,9 @@ function acpConfigForEntry(entry, appVersion) {
|
||||
...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":
|
||||
return {
|
||||
@@ -5866,6 +5873,106 @@ var init_modes = __esm({
|
||||
}
|
||||
});
|
||||
|
||||
// daemon/src/providers/autoApprove.ts
|
||||
function pickAllowOnce(options) {
|
||||
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;
|
||||
}
|
||||
function autoApproveOption(mode2, providerId, req) {
|
||||
if (mode2 !== FULL_AUTO) return null;
|
||||
if (FULL_AUTO_NATIVE[providerId]?.daemonAnswers === false) return null;
|
||||
if (req.kind === "plan" || req.kind === "switch_mode") return null;
|
||||
return pickAllowOnce(req.options);
|
||||
}
|
||||
var FULL_AUTO, FULL_AUTO_NATIVE, REJECT, ALLOW;
|
||||
var init_autoApprove = __esm({
|
||||
"daemon/src/providers/autoApprove.ts"() {
|
||||
FULL_AUTO = "bypassPermissions";
|
||||
FULL_AUTO_NATIVE = {
|
||||
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 }
|
||||
};
|
||||
REJECT = /reject|deny|decline|cancel|never|拒绝/i;
|
||||
ALLOW = /allow|accept|approve|yes|允许|同意/i;
|
||||
}
|
||||
});
|
||||
|
||||
// daemon/src/migrate/autoApprove13.ts
|
||||
var autoApprove13_exports = {};
|
||||
__export(autoApprove13_exports, {
|
||||
LEGACY_NO_AUTO: () => LEGACY_NO_AUTO,
|
||||
MIGRATED_NOTICE_CODE: () => MIGRATED_NOTICE_CODE,
|
||||
UPGRADE_NOTICE_CODE: () => UPGRADE_NOTICE_CODE,
|
||||
endLegacyDefault: () => endLegacyDefault,
|
||||
guardLegacyMode: () => guardLegacyMode,
|
||||
migrateAutoApprove13: () => migrateAutoApprove13,
|
||||
upgradeNotice: () => upgradeNotice
|
||||
});
|
||||
function state(s) {
|
||||
const v = s[KEY];
|
||||
return v && typeof v === "object" && v.done === true ? { done: true, legacyDefault: v.legacyDefault === true, noticed: v.noticed === true } : null;
|
||||
}
|
||||
async function migrateAutoApprove13(stores) {
|
||||
const s = await stores.settings.get();
|
||||
if (state(s)) return { threads: [], legacyDefault: false, skipped: true };
|
||||
const moved = [];
|
||||
for (const t of await stores.threads.list()) {
|
||||
if (t.mode !== FULL_AUTO || !LEGACY_NO_AUTO.has(t.provider)) continue;
|
||||
try {
|
||||
await stores.threads.patch(t.id, { mode: "default" });
|
||||
await stores.threads.appendEvent(t.id, { type: "notice", level: "warn", code: MIGRATED_NOTICE_CODE, message: tr("notice.autoApproveMigrated") });
|
||||
moved.push(t.id);
|
||||
} catch (e) {
|
||||
log("warn", `\u5168\u90E8\u81EA\u52A8\u540C\u610F\u8FC1\u79FB\uFF1A\u5BF9\u8BDD ${t.id} \u5931\u8D25\uFF1A${String(e)}`);
|
||||
}
|
||||
}
|
||||
const legacyDefault = s.defaultMode === FULL_AUTO;
|
||||
await stores.settings.set({ [KEY]: { done: true, legacyDefault, noticed: false } });
|
||||
if (moved.length || legacyDefault) log("info", `\u5168\u90E8\u81EA\u52A8\u540C\u610F\u8FC1\u79FB\uFF1A${moved.length} \u4E2A\u5BF9\u8BDD\u6539\u56DE\u6BCF\u6B21\u8BE2\u95EE\uFF1B\u65E7\u7684\u9ED8\u8BA4\u5168\u90E8\u653E\u884C=${legacyDefault}`);
|
||||
return { threads: moved, legacyDefault, skipped: false };
|
||||
}
|
||||
async function guardLegacyMode(settings, providerId, mode2) {
|
||||
if (mode2 !== FULL_AUTO || !LEGACY_NO_AUTO.has(providerId)) return { mode: mode2, notice: false };
|
||||
const s = await settings.get();
|
||||
const st = state(s);
|
||||
if (!st?.legacyDefault) return { mode: mode2, notice: false };
|
||||
if (st.noticed) return { mode: "default", notice: false };
|
||||
await settings.set({ [KEY]: { ...st, noticed: true } });
|
||||
return { mode: "default", notice: true };
|
||||
}
|
||||
async function endLegacyDefault(settings) {
|
||||
const st = state(await settings.get());
|
||||
if (st?.legacyDefault) await settings.set({ [KEY]: { ...st, legacyDefault: false } });
|
||||
}
|
||||
function upgradeNotice() {
|
||||
return { type: "notice", level: "info", code: UPGRADE_NOTICE_CODE, message: tr("notice.autoApproveUpgrade") };
|
||||
}
|
||||
var LEGACY_NO_AUTO, UPGRADE_NOTICE_CODE, MIGRATED_NOTICE_CODE, KEY;
|
||||
var init_autoApprove13 = __esm({
|
||||
"daemon/src/migrate/autoApprove13.ts"() {
|
||||
init_autoApprove();
|
||||
init_i18n();
|
||||
init_log();
|
||||
LEGACY_NO_AUTO = /* @__PURE__ */ new Set(["cursor", "opencode", "dsh"]);
|
||||
UPGRADE_NOTICE_CODE = "auto_approve_upgrade";
|
||||
MIGRATED_NOTICE_CODE = "auto_approve_migrated";
|
||||
KEY = "autoApproveUpgrade";
|
||||
}
|
||||
});
|
||||
|
||||
// daemon/src/util/mentions.ts
|
||||
import { realpath, stat as stat8 } from "node:fs/promises";
|
||||
import { isAbsolute as isAbsolute2, resolve as resolve3, sep as sep2, win32 as win322, posix as posix2 } from "node:path";
|
||||
@@ -6795,6 +6902,7 @@ function registerMethods(gw, svc) {
|
||||
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);
|
||||
if ("defaultMode" in checked.patch) await endLegacyDefault(svc.settings);
|
||||
if ("bashPath" in checked.patch && (before.bashPath ?? "") !== (next.bashPath ?? "")) {
|
||||
await refreshAgentShell(typeof next.bashPath === "string" ? next.bashPath : "");
|
||||
}
|
||||
@@ -6944,8 +7052,10 @@ function registerMethods(gw, svc) {
|
||||
throw new ApiError("bad_params", tr("provider.plannedNamed", { name: cat.name }));
|
||||
}
|
||||
const provider = getProvider(p.provider);
|
||||
const mode2 = clampMode(provider?.capabilities.modes ?? [], p.mode);
|
||||
const guard = await guardLegacyMode(svc.settings, p.provider, clampMode(provider?.capabilities.modes ?? [], p.mode));
|
||||
const mode2 = guard.mode;
|
||||
const meta = await svc.threads.create({ ...p, mode: mode2 });
|
||||
if (guard.notice) await svc.threads.appendEvent(meta.id, upgradeNotice());
|
||||
gw.publish("sidebar", { type: "thread.upsert", thread: meta });
|
||||
return meta;
|
||||
}
|
||||
@@ -7286,6 +7396,7 @@ var init_methods = __esm({
|
||||
init_infoCache();
|
||||
init_launch();
|
||||
init_modes();
|
||||
init_autoApprove13();
|
||||
init_i18n();
|
||||
init_mentions();
|
||||
init_openExternal();
|
||||
@@ -8561,6 +8672,8 @@ init_registry();
|
||||
// daemon/src/agents/manager.ts
|
||||
init_launch();
|
||||
init_modes();
|
||||
init_autoApprove13();
|
||||
init_autoApprove();
|
||||
init_attachmentRefs();
|
||||
init_registry();
|
||||
init_catalog();
|
||||
@@ -8967,9 +9080,21 @@ var AgentManager = class {
|
||||
},
|
||||
event: ev
|
||||
};
|
||||
if (ev.type === "permission_request") {
|
||||
const meta = await this.threads.get(threadId);
|
||||
const auto = meta ? autoApproveOption(meta.mode, meta.provider, ev) : null;
|
||||
if (auto) {
|
||||
log("info", `thread ${threadId} \u81EA\u52A8\u540C\u610F ${ev.title.slice(0, 80)} \u2192 ${auto.id}`);
|
||||
await this.appendRaw(threadId, { ...ev, auto: true });
|
||||
await this.appendRaw(threadId, { type: "permission_resolved", requestId: ev.requestId, optionId: auto.id, auto: true });
|
||||
rt.session?.respond(ev.requestId, { optionId: auto.id });
|
||||
return;
|
||||
}
|
||||
}
|
||||
const toolName = ev.detail?.toolName;
|
||||
if (toolName && rt.allowAlways.has(toolName)) {
|
||||
rt.session?.respond(ev.requestId, { optionId: "accept" });
|
||||
const allow = options.find((o) => o.kind === "allow_once") ?? options.find((o) => o.kind === "allow_always");
|
||||
rt.session?.respond(ev.requestId, { optionId: allow?.id ?? "accept" });
|
||||
return;
|
||||
}
|
||||
rt.pending.set(ev.requestId, pending);
|
||||
@@ -9051,6 +9176,22 @@ var AgentManager = class {
|
||||
}
|
||||
rt.session?.respond(requestId, answer);
|
||||
}
|
||||
/** Answer every waiting tool approval with its allow-once option (full-auto just turned on). Returns how many. */
|
||||
async autoApprovePending(threadId, providerId, mode2) {
|
||||
const rt = this.rt(threadId);
|
||||
let n = 0;
|
||||
for (const p of [...rt.pending.values()]) {
|
||||
if (p.kind !== "permission") continue;
|
||||
const ev = p.event;
|
||||
const opt = autoApproveOption(mode2, providerId, { kind: ev.kind, options: p.options });
|
||||
if (!opt) continue;
|
||||
rt.pending.delete(p.requestId);
|
||||
await this.appendRaw(threadId, { type: "permission_resolved", requestId: p.requestId, optionId: opt.id, auto: true });
|
||||
rt.session?.respond(p.requestId, { optionId: opt.id });
|
||||
n++;
|
||||
}
|
||||
return n;
|
||||
}
|
||||
// ---- interrupt ----
|
||||
async interrupt(threadId) {
|
||||
const rt = this.rt(threadId);
|
||||
@@ -9095,8 +9236,9 @@ var AgentManager = class {
|
||||
this.gw.publish("sidebar", { type: "thread.upsert", thread: await this.threads.get(threadId) });
|
||||
}
|
||||
async setMode(threadId, mode2) {
|
||||
await this.threads.patch(threadId, { mode: mode2 });
|
||||
const meta = await this.threads.patch(threadId, { mode: mode2 });
|
||||
const rt = this.rt(threadId);
|
||||
if (mode2 === FULL_AUTO) await this.autoApprovePending(threadId, meta.provider, mode2);
|
||||
if (rt.session) await rt.session.setMode(mode2);
|
||||
this.gw.publish("sidebar", { type: "thread.upsert", thread: await this.threads.get(threadId) });
|
||||
}
|
||||
@@ -9149,14 +9291,16 @@ var AgentManager = class {
|
||||
rt.commands = [];
|
||||
}
|
||||
rt.status = "idle";
|
||||
const guard = await guardLegacyMode(this.settings, providerId, clampMode(p.capabilities.modes, meta.mode));
|
||||
await this.threads.patch(threadId, {
|
||||
provider: providerId,
|
||||
model: null,
|
||||
mode: clampMode(p.capabilities.modes, meta.mode),
|
||||
mode: guard.mode,
|
||||
effort: null,
|
||||
providerSessionId: null,
|
||||
status: "idle"
|
||||
});
|
||||
if (guard.notice) await this.appendRaw(threadId, upgradeNotice());
|
||||
this.gw.publish("sidebar", { type: "thread.upsert", thread: await this.threads.get(threadId) });
|
||||
}
|
||||
async close(threadId) {
|
||||
@@ -10044,6 +10188,12 @@ async function main() {
|
||||
} catch (e) {
|
||||
log("error", "\u65E7\u6570\u636E\u8FC1\u79FB\u5931\u8D25", { err: String(e) });
|
||||
}
|
||||
try {
|
||||
const { migrateAutoApprove13: migrateAutoApprove132 } = await Promise.resolve().then(() => (init_autoApprove13(), autoApprove13_exports));
|
||||
await migrateAutoApprove132({ settings, threads });
|
||||
} catch (e) {
|
||||
log("error", "\u5168\u90E8\u81EA\u52A8\u540C\u610F\u8FC1\u79FB\u5931\u8D25", { err: String(e) });
|
||||
}
|
||||
const manager = new AgentManager(gateway, threads, projects, settings, attachments);
|
||||
await manager.recoverOnStart();
|
||||
const terminals = new TerminalService(gateway);
|
||||
|
||||
+1
-1
File diff suppressed because one or more lines are too long
@@ -7,6 +7,8 @@ import type { AttachmentStore } from "../store/attachments.js";
|
||||
import type { Provider, ProviderSession, SendInput, RespondAnswer, Mode, SlashCommand } from "../providers/types.js";
|
||||
import { launchFromSettings } from "../providers/launch.js";
|
||||
import { clampMode } from "../providers/modes.js";
|
||||
import { guardLegacyMode, upgradeNotice } from "../migrate/autoApprove13.js";
|
||||
import { autoApproveOption, FULL_AUTO } from "../providers/autoApprove.js";
|
||||
import { resolveAttachmentRefs } from "../util/attachmentRefs.js";
|
||||
import { getProvider } from "../providers/registry.js";
|
||||
import { catalogById, providerCreatable } from "../providers/catalog.js";
|
||||
@@ -450,10 +452,25 @@ export class AgentManager {
|
||||
resolve: () => {},
|
||||
event: ev,
|
||||
};
|
||||
// allowAlways hit → approve directly
|
||||
if (ev.type === "permission_request") {
|
||||
// 1.3 全部自动同意: the daemon answers "allow once" itself; no card (the tool call still shows in the timeline)
|
||||
const meta = await this.threads.get(threadId);
|
||||
const auto = meta ? autoApproveOption(meta.mode, meta.provider, ev) : null;
|
||||
if (auto) {
|
||||
// #727 review: every auto-approval leaves a trace. The request (title, command / path / diff, options) and its
|
||||
// answer are persisted like a card the user answered, both marked auto, before the Agent is told to go on.
|
||||
log("info", `thread ${threadId} 自动同意 ${ev.title.slice(0, 80)} → ${auto.id}`);
|
||||
await this.appendRaw(threadId, { ...ev, auto: true });
|
||||
await this.appendRaw(threadId, { type: "permission_resolved", requestId: ev.requestId, optionId: auto.id, auto: true });
|
||||
rt.session?.respond(ev.requestId, { optionId: auto.id });
|
||||
return;
|
||||
}
|
||||
}
|
||||
// allowAlways hit → approve directly (with this request's own allow option, not a guessed id)
|
||||
const toolName = (ev as { detail?: { toolName?: string } }).detail?.toolName;
|
||||
if (toolName && rt.allowAlways.has(toolName)) {
|
||||
rt.session?.respond(ev.requestId, { optionId: "accept" });
|
||||
const allow = options.find((o) => o.kind === "allow_once") ?? options.find((o) => o.kind === "allow_always");
|
||||
rt.session?.respond(ev.requestId, { optionId: allow?.id ?? "accept" });
|
||||
return;
|
||||
}
|
||||
rt.pending.set(ev.requestId, pending);
|
||||
@@ -544,6 +561,23 @@ export class AgentManager {
|
||||
rt.session?.respond(requestId, answer);
|
||||
}
|
||||
|
||||
/** Answer every waiting tool approval with its allow-once option (full-auto just turned on). Returns how many. */
|
||||
private async autoApprovePending(threadId: string, providerId: string, mode: Mode): Promise<number> {
|
||||
const rt = this.rt(threadId);
|
||||
let n = 0;
|
||||
for (const p of [...rt.pending.values()]) {
|
||||
if (p.kind !== "permission") continue;
|
||||
const ev = p.event as { kind?: string };
|
||||
const opt = autoApproveOption(mode, providerId, { kind: ev.kind, options: p.options });
|
||||
if (!opt) continue;
|
||||
rt.pending.delete(p.requestId);
|
||||
await this.appendRaw(threadId, { type: "permission_resolved", requestId: p.requestId, optionId: opt.id, auto: true });
|
||||
rt.session?.respond(p.requestId, { optionId: opt.id });
|
||||
n++;
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
// ---- interrupt ----
|
||||
async interrupt(threadId: string): Promise<void> {
|
||||
const rt = this.rt(threadId);
|
||||
@@ -592,8 +626,10 @@ export class AgentManager {
|
||||
this.gw.publish("sidebar", { type: "thread.upsert", thread: await this.threads.get(threadId) });
|
||||
}
|
||||
async setMode(threadId: string, mode: Mode): Promise<void> {
|
||||
await this.threads.patch(threadId, { mode });
|
||||
const meta = await this.threads.patch(threadId, { mode });
|
||||
const rt = this.rt(threadId);
|
||||
// 1.3: turning 全部自动同意 on also approves the cards already waiting (the user was stuck exactly there)
|
||||
if (mode === FULL_AUTO) await this.autoApprovePending(threadId, meta.provider, mode);
|
||||
if (rt.session) await rt.session.setMode(mode);
|
||||
this.gw.publish("sidebar", { type: "thread.upsert", thread: await this.threads.get(threadId) });
|
||||
}
|
||||
@@ -652,14 +688,17 @@ export class AgentManager {
|
||||
rt.commands = [];
|
||||
}
|
||||
rt.status = "idle";
|
||||
// 1.3 (#727 review 3): same guard as threads.create for a pre-1.3 default of 全部放行
|
||||
const guard = await guardLegacyMode(this.settings, providerId, clampMode(p.capabilities.modes, meta.mode));
|
||||
await this.threads.patch(threadId, {
|
||||
provider: providerId,
|
||||
model: null,
|
||||
mode: clampMode(p.capabilities.modes, meta.mode),
|
||||
mode: guard.mode,
|
||||
effort: null,
|
||||
providerSessionId: null,
|
||||
status: "idle",
|
||||
});
|
||||
if (guard.notice) await this.appendRaw(threadId, upgradeNotice());
|
||||
this.gw.publish("sidebar", { type: "thread.upsert", thread: await this.threads.get(threadId) });
|
||||
}
|
||||
|
||||
|
||||
@@ -68,6 +68,13 @@ async function main(): Promise<void> {
|
||||
} catch (e) {
|
||||
log("error", "旧数据迁移失败", { err: String(e) });
|
||||
}
|
||||
// 1.3 (#727 review 3): a 1.2 "全部放行" never turns into real auto-approval silently for Cursor / OpenCode / dsh
|
||||
try {
|
||||
const { migrateAutoApprove13 } = await import("./migrate/autoApprove13.js");
|
||||
await migrateAutoApprove13({ settings, threads });
|
||||
} catch (e) {
|
||||
log("error", "全部自动同意迁移失败", { err: String(e) });
|
||||
}
|
||||
const manager = new AgentManager(gateway, threads, projects, settings, attachments);
|
||||
await manager.recoverOnStart();
|
||||
const terminals = new TerminalService(gateway);
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
// 1.3 全部自动同意 upgrade safety (#727 review 3).
|
||||
//
|
||||
// In 1.2, "bypassPermissions" (全部放行) only did something for Agents with a native switch (Claude, Codex, Copilot,
|
||||
// Devin). Cursor and OpenCode had no such mode, so a saved default of bypassPermissions was clamped to "default" for
|
||||
// them, and dsh accepted the mode but still asked for every tool. In 1.3 the daemon answers those Agents' approvals
|
||||
// itself, so the same saved setting would silently start approving everything for them.
|
||||
//
|
||||
// Choice: never escalate silently. On the first 1.3 start:
|
||||
// - conversations of those Agents stored in bypassPermissions go back to "default" (每次询问), each with a notice;
|
||||
// - a pre-1.3 default of bypassPermissions is remembered as "legacy": new conversations of those Agents start in
|
||||
// "default" and the first one says once that the new mode exists (the user can switch it on there, explicitly).
|
||||
// Choosing a default permission mode in Settings after the upgrade is a 1.3-era decision and ends the legacy state.
|
||||
// Claude / Codex / Copilot / Devin keep bypassPermissions: for them 1.2 already meant the same thing.
|
||||
import type { SettingsStore } from "../store/settings.js";
|
||||
import type { ThreadsStore } from "../store/threads.js";
|
||||
import type { Mode } from "../timeline/types.js";
|
||||
import { FULL_AUTO } from "../providers/autoApprove.js";
|
||||
import { tr } from "../util/i18n.js";
|
||||
import { log } from "../log.js";
|
||||
|
||||
/** Agents for which 1.2's bypassPermissions did not auto-approve anything */
|
||||
export const LEGACY_NO_AUTO = new Set(["cursor", "opencode", "dsh"]);
|
||||
export const UPGRADE_NOTICE_CODE = "auto_approve_upgrade";
|
||||
export const MIGRATED_NOTICE_CODE = "auto_approve_migrated";
|
||||
|
||||
/** Kept in settings.json; written only by the daemon (not in settingsPatchSchema, so the page cannot set it) */
|
||||
export type AutoApproveUpgradeState = { done: true; legacyDefault: boolean; noticed: boolean };
|
||||
const KEY = "autoApproveUpgrade";
|
||||
|
||||
function state(s: Record<string, unknown>): AutoApproveUpgradeState | null {
|
||||
const v = s[KEY] as Partial<AutoApproveUpgradeState> | undefined;
|
||||
return v && typeof v === "object" && v.done === true
|
||||
? { done: true, legacyDefault: v.legacyDefault === true, noticed: v.noticed === true }
|
||||
: null;
|
||||
}
|
||||
|
||||
/** Runs once, on the first start of a build with this code (fresh installs: nothing to do, just marks it done) */
|
||||
export async function migrateAutoApprove13(stores: { settings: SettingsStore; threads: ThreadsStore }): Promise<{ threads: string[]; legacyDefault: boolean; skipped: boolean }> {
|
||||
const s = await stores.settings.get();
|
||||
if (state(s)) return { threads: [], legacyDefault: false, skipped: true };
|
||||
const moved: string[] = [];
|
||||
for (const t of await stores.threads.list()) {
|
||||
if (t.mode !== FULL_AUTO || !LEGACY_NO_AUTO.has(t.provider)) continue;
|
||||
try {
|
||||
await stores.threads.patch(t.id, { mode: "default" });
|
||||
await stores.threads.appendEvent(t.id, { type: "notice", level: "warn", code: MIGRATED_NOTICE_CODE, message: tr("notice.autoApproveMigrated") });
|
||||
moved.push(t.id);
|
||||
} catch (e) {
|
||||
log("warn", `全部自动同意迁移:对话 ${t.id} 失败:${String(e)}`);
|
||||
}
|
||||
}
|
||||
const legacyDefault = s.defaultMode === FULL_AUTO;
|
||||
await stores.settings.set({ [KEY]: { done: true, legacyDefault, noticed: false } satisfies AutoApproveUpgradeState });
|
||||
if (moved.length || legacyDefault) log("info", `全部自动同意迁移:${moved.length} 个对话改回每次询问;旧的默认全部放行=${legacyDefault}`);
|
||||
return { threads: moved, legacyDefault, skipped: false };
|
||||
}
|
||||
|
||||
/**
|
||||
* The mode a new (or re-pointed) conversation of this Agent really starts in. A pre-1.3 default of bypassPermissions
|
||||
* does not turn into real auto-approval for Agents where it did nothing in 1.2; the first time, a notice says so.
|
||||
*/
|
||||
export async function guardLegacyMode(settings: SettingsStore, providerId: string, mode: Mode): Promise<{ mode: Mode; notice: boolean }> {
|
||||
if (mode !== FULL_AUTO || !LEGACY_NO_AUTO.has(providerId)) return { mode, notice: false };
|
||||
const s = await settings.get();
|
||||
const st = state(s);
|
||||
if (!st?.legacyDefault) return { mode, notice: false };
|
||||
if (st.noticed) return { mode: "default", notice: false };
|
||||
await settings.set({ [KEY]: { ...st, noticed: true } satisfies AutoApproveUpgradeState });
|
||||
return { mode: "default", notice: true };
|
||||
}
|
||||
|
||||
/** The user picked a default permission mode in Settings: their 1.3 choice from now on */
|
||||
export async function endLegacyDefault(settings: SettingsStore): Promise<void> {
|
||||
const st = state(await settings.get());
|
||||
if (st?.legacyDefault) await settings.set({ [KEY]: { ...st, legacyDefault: false } satisfies AutoApproveUpgradeState });
|
||||
}
|
||||
|
||||
/** The one-time notice appended to the conversation the guard kept in 每次询问 */
|
||||
export function upgradeNotice(): { type: "notice"; level: "info"; code: string; message: string } {
|
||||
return { type: "notice", level: "info", code: UPGRADE_NOTICE_CODE, message: tr("notice.autoApproveUpgrade") };
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
@@ -17,8 +17,8 @@ export type TimelineEvent =
|
||||
| { seq: number; ts: number; threadId: string; turnId?: string; type: "tool_call"; itemId: string; kind: ToolKind; title: string; status: "running" | "ok" | "failed"; input?: unknown; detail?: unknown; output?: string; exitCode?: number; durationMs?: number }
|
||||
| { seq: number; ts: number; threadId: string; turnId?: string; type: "plan"; itemId: string; markdown: string; entries?: { step: string; status: string }[] }
|
||||
| { seq: number; ts: number; threadId: string; turnId?: string; type: "todo"; items: { text: string; status: string }[] }
|
||||
| { seq: number; ts: number; threadId: string; turnId?: string; type: "permission_request"; requestId: string; title: string; kind: string; detail?: unknown; options: { id: string; label: string; kind: string }[] }
|
||||
| { seq: number; ts: number; threadId: string; turnId?: string; type: "permission_resolved"; requestId: string; optionId?: string; cancelled?: boolean }
|
||||
| { seq: number; ts: number; threadId: string; turnId?: string; type: "permission_request"; requestId: string; title: string; kind: string; detail?: unknown; options: { id: string; label: string; kind: string }[]; auto?: boolean }
|
||||
| { seq: number; ts: number; threadId: string; turnId?: string; type: "permission_resolved"; requestId: string; optionId?: string; cancelled?: boolean; auto?: boolean }
|
||||
| { seq: number; ts: number; threadId: string; turnId?: string; type: "question"; requestId: string; questions: unknown[] }
|
||||
| { seq: number; ts: number; threadId: string; turnId?: string; type: "question_answered"; requestId: string; answers: Record<string, string> }
|
||||
| { seq: number; ts: number; threadId: string; turnId?: string; type: "usage"; inputTokens: number; outputTokens: number; cacheReadTokens: number; costUsd: number; contextWindow?: number }
|
||||
@@ -37,8 +37,8 @@ export type ProviderEvent =
|
||||
| { type: "tool_call"; itemId: string; kind: string; title: string; status: "running" | "ok" | "failed"; input?: unknown; detail?: unknown; output?: string; exitCode?: number; durationMs?: number }
|
||||
| { type: "plan"; itemId: string; markdown: string; entries?: { step: string; status: string }[] }
|
||||
| { type: "todo"; items: { text: string; status: string }[] }
|
||||
| { type: "permission_request"; requestId: string; title: string; kind: string; detail?: unknown; options: { id: string; label: string; kind: string }[] }
|
||||
| { type: "permission_resolved"; requestId: string; optionId?: string; cancelled?: boolean }
|
||||
| { type: "permission_request"; requestId: string; title: string; kind: string; detail?: unknown; options: { id: string; label: string; kind: string }[]; auto?: boolean }
|
||||
| { type: "permission_resolved"; requestId: string; optionId?: string; cancelled?: boolean; auto?: boolean }
|
||||
| { type: "question"; requestId: string; questions: unknown[] }
|
||||
| { type: "question_answered"; requestId: string; answers: Record<string, string> }
|
||||
| { type: "usage"; inputTokens: number; outputTokens: number; cacheReadTokens: number; costUsd: number; contextWindow?: number }
|
||||
|
||||
@@ -29,6 +29,8 @@ const dict: Record<AppLocale, Record<string, string>> = {
|
||||
"notice.sessionStartFailed": "会话启动失败:{detail}",
|
||||
"notice.sendFailed": "发送失败:{detail}",
|
||||
"notice.bashMissing": "没有找到 Git Bash。这个 Agent 在 Windows 上要用 Git Bash 运行命令(C:\\Windows\\System32\\bash.exe 是 WSL 启动器,不能用)。请安装 Git for Windows:https://git-scm.com/download/win ,或在「设置 → Bash 路径」里手动指定 bash.exe。",
|
||||
"notice.autoApproveUpgrade": "1.3 新增「全部自动同意」:现在对 Cursor、OpenCode、dsh 也会真正自动同意(1.2 的「全部放行」对它们不生效,仍会询问)。你之前把默认权限模式设成了它,为安全起见这个对话仍从「每次询问」开始;需要时请在下方权限菜单里手动开启,或在设置里重新选择默认权限模式。",
|
||||
"notice.autoApproveMigrated": "这个对话在 1.2 里设成了「全部放行」,当时这个 Agent 实际仍会询问。1.3 起「全部自动同意」会真正自动同意,所以已改回「每次询问」;需要时请在下方权限菜单里手动开启。",
|
||||
"notice.effortNextTurn": "思考强度已保存,将在下一轮生效",
|
||||
"notice.effortResetOnModel": "当前模型不支持该思考强度,已恢复为 Default",
|
||||
"turn.agentExit": "Agent 进程意外退出",
|
||||
@@ -140,6 +142,8 @@ const dict: Record<AppLocale, Record<string, string>> = {
|
||||
"notice.sessionStartFailed": "Session start failed: {detail}",
|
||||
"notice.sendFailed": "Send failed: {detail}",
|
||||
"notice.bashMissing": "Git Bash was not found. On Windows this agent runs its commands with Git Bash (C:\\Windows\\System32\\bash.exe is the WSL launcher and won't work). Install Git for Windows: https://git-scm.com/download/win , or set bash.exe under Settings → Bash path.",
|
||||
"notice.autoApproveUpgrade": "New in 1.3: Auto-approve all now really auto-approves for Cursor, OpenCode and dsh too (1.2's bypass mode did nothing for them; they still asked). Your default permission mode was set to it, so to be safe this conversation starts in Always Ask; switch it on in the permission menu below if you want it, or pick the default permission mode again in Settings.",
|
||||
"notice.autoApproveMigrated": "This conversation was set to bypass permissions in 1.2, where this agent still asked anyway. From 1.3 Auto-approve all really auto-approves, so it was put back to Always Ask; switch it on in the permission menu below if you want it.",
|
||||
"notice.effortNextTurn": "Reasoning effort saved — takes effect on the next turn",
|
||||
"notice.effortResetOnModel": "This model does not support that effort level; reset to Default",
|
||||
"turn.agentExit": "Agent process exited unexpectedly",
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user