дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-11-09 11:15:40 +02:00
feat(agents): new tasks default to the bypass permission mode (#444)
New agent tasks start in the agent's mode that approves everything without asking (bypassPermissions, yolo, full-access…) or with approvals bypassed, unless the New Task page sets something else.
Цей коміт міститься в:
1 джерело
195356c4b1
коміт
bc70ec7028
5 files changed
+33
-7
No files matched your search
@@ -149,6 +149,17 @@ export function modeIcon(mode: string): string {
|
||||
return "lock";
|
||||
}
|
||||
|
||||
/** The settings that approve everything without asking (a bypass mode, or approvals), by option id. */
|
||||
export function bypassDefaults(config: readonly AgentConfigOption[]): Record<string, string> {
|
||||
const out: Record<string, string> = {};
|
||||
const mode = modeOption(config);
|
||||
const unlock = mode?.values.find((v) => modeIcon(v.value) === "unlock");
|
||||
if (mode && unlock) out[mode.id] = unlock.value;
|
||||
const approval = config.find((o) => o.category === "approval");
|
||||
if (approval?.values.some((v) => v.value === "bypass")) out[approval.id] = "bypass";
|
||||
return out;
|
||||
}
|
||||
|
||||
/** Shift+Tab: the mode after the current one. */
|
||||
export function nextValue(option: AgentConfigOption, current = option.current): string | null {
|
||||
if (!option.values.length) return null;
|
||||
|
||||
@@ -13,7 +13,7 @@ import type {
|
||||
} from "@/bindings";
|
||||
import { call, commands, isTauri } from "@/platform/ipc";
|
||||
import { editorService, notifications } from "@/workbench/contributions";
|
||||
import { canSend, emptyDraft, toPrompt, type ComposerDraft, type FileRef } from "./composerModel";
|
||||
import { bypassDefaults, canSend, emptyDraft, toPrompt, type ComposerDraft, type FileRef } from "./composerModel";
|
||||
import { withQuote } from "./conversation";
|
||||
import {
|
||||
HOME_KEY,
|
||||
@@ -348,14 +348,15 @@ export function openHome(prompt?: string) {
|
||||
|
||||
/** `isolation` overrides the draft's (a project without git can only use the local checkout). */
|
||||
export async function startTask(isolation: Isolation = useAgents.getState().draft.isolation): Promise<void> {
|
||||
const { draft } = useAgents.getState();
|
||||
const { draft, providers } = useAgents.getState();
|
||||
const composer = composerDraft(HOME);
|
||||
if (!canSend(composer)) return;
|
||||
const config = { ...bypassDefaults(providers.find((p) => p.id === draft.provider)?.config ?? []), ...draft.config };
|
||||
const task = await call(
|
||||
commands.agentCreate({
|
||||
prompt: toPrompt(composer),
|
||||
provider: draft.provider,
|
||||
config: Object.entries(draft.config).map(([id, value]) => ({ id, value })),
|
||||
config: Object.entries(config).map(([id, value]) => ({ id, value })),
|
||||
isolation,
|
||||
base: isolation === "worktree" ? draft.base : null,
|
||||
}),
|
||||
|
||||
Reference in new issue
Заблокувати користувача