Skip to content

Open-source AI teammates in Slack, Teams, Discord, Telegram and Mattermost. Self-host it, with any agent harness and any model.

feat(switchdash): per-agent bypass-permissions setting (default off, on for remote) (#57)

Louis Amaudruz5ddb68697326
diff --git a/dash/apps/switchdash-desktop/drizzle/0039_new_ben_parker.sql b/dash/apps/switchdash-desktop/drizzle/0039_new_ben_parker.sql
new file mode 100644
index 000000000..826b84aef
--- /dev/null
+++ b/dash/apps/switchdash-desktop/drizzle/0039_new_ben_parker.sql
@@ -0,0 +1 @@
+ALTER TABLE `agents` ADD `auto_approve` integer DEFAULT false NOT NULL;
\ No newline at end of file
diff --git a/dash/apps/switchdash-desktop/drizzle/meta/0039_snapshot.json b/dash/apps/switchdash-desktop/drizzle/meta/0039_snapshot.json
new file mode 100644
index 000000000..7b44d967d
--- /dev/null
+++ b/dash/apps/switchdash-desktop/drizzle/meta/0039_snapshot.json
@@ -0,0 +1,711 @@
+{
+ "version": "6",
+ "dialect": "sqlite",
+ "id": "25b952e3-7377-460c-a144-8ea04170b171",
+ "prevId": "acf382fa-be55-4705-8814-fed45fe863f0",
+ "tables": {
+ "agents": {
+ "name": "agents",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "location_id": {
+ "name": "location_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "provider_id": {
+ "name": "provider_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "switch_agent_id": {
+ "name": "switch_agent_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "api_endpoint": {
+ "name": "api_endpoint",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "server_id": {
+ "name": "server_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "auto_approve": {
+ "name": "auto_approve",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "CURRENT_TIMESTAMP"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "CURRENT_TIMESTAMP"
+ }
+ },
+ "indexes": {
+ "idx_agents_location_id": {
+ "name": "idx_agents_location_id",
+ "columns": ["location_id"],
+ "isUnique": false
+ },
+ "idx_agents_server_id": {
+ "name": "idx_agents_server_id",
+ "columns": ["server_id"],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {
+ "agents_location_id_locations_id_fk": {
+ "name": "agents_location_id_locations_id_fk",
+ "tableFrom": "agents",
+ "tableTo": "locations",
+ "columnsFrom": ["location_id"],
+ "columnsTo": ["id"],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "agents_server_id_switch_servers_id_fk": {
+ "name": "agents_server_id_switch_servers_id_fk",
+ "tableFrom": "agents",
+ "tableTo": "switch_servers",
+ "columnsFrom": ["server_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "app_secrets": {
+ "name": "app_secrets",
+ "columns": {
+ "key": {
+ "name": "key",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "secret": {
+ "name": "secret",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ }
+ },
+ "indexes": {
+ "idx_app_secrets_key": {
+ "name": "idx_app_secrets_key",
+ "columns": ["key"],
+ "isUnique": true
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "app_settings": {
+ "name": "app_settings",
+ "columns": {
+ "key": {
+ "name": "key",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "value": {
+ "name": "value",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "CURRENT_TIMESTAMP"
+ }
+ },
+ "indexes": {
+ "idx_app_settings_key": {
+ "name": "idx_app_settings_key",
+ "columns": ["key"],
+ "isUnique": true
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "kv": {
+ "name": "kv",
+ "columns": {
+ "key": {
+ "name": "key",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "value": {
+ "name": "value",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "CURRENT_TIMESTAMP"
+ }
+ },
+ "indexes": {
+ "idx_kv_key": {
+ "name": "idx_kv_key",
+ "columns": ["key"],
+ "isUnique": true
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "location_settings": {
+ "name": "location_settings",
+ "columns": {
+ "location_id": {
+ "name": "location_id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "base_settings_json": {
+ "name": "base_settings_json",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "'{}'"
+ },
+ "shareable_settings_json": {
+ "name": "shareable_settings_json",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "'{}'"
+ },
+ "legacy_config_migrated_at": {
+ "name": "legacy_config_migrated_at",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "CURRENT_TIMESTAMP"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "CURRENT_TIMESTAMP"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "location_settings_location_id_locations_id_fk": {
+ "name": "location_settings_location_id_locations_id_fk",
+ "tableFrom": "location_settings",
+ "tableTo": "locations",
+ "columnsFrom": ["location_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "locations": {
+ "name": "locations",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "ssh_host": {
+ "name": "ssh_host",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "''"
+ },
+ "dir": {
+ "name": "dir",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "CURRENT_TIMESTAMP"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "CURRENT_TIMESTAMP"
+ }
+ },
+ "indexes": {
+ "idx_locations_host_dir": {
+ "name": "idx_locations_host_dir",
+ "columns": ["ssh_host", "dir"],
+ "isUnique": true
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "messages": {
+ "name": "messages",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "session_id": {
+ "name": "session_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "content": {
+ "name": "content",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "sender": {
+ "name": "sender",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "timestamp": {
+ "name": "timestamp",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "CURRENT_TIMESTAMP"
+ },
+ "metadata": {
+ "name": "metadata",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ }
+ },
+ "indexes": {
+ "idx_messages_session_id": {
+ "name": "idx_messages_session_id",
+ "columns": ["session_id"],
+ "isUnique": false
+ },
+ "idx_messages_timestamp": {
+ "name": "idx_messages_timestamp",
+ "columns": ["timestamp"],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {
+ "messages_session_id_sessions_id_fk": {
+ "name": "messages_session_id_sessions_id_fk",
+ "tableFrom": "messages",
+ "tableTo": "sessions",
+ "columnsFrom": ["session_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "remote_hosts": {
+ "name": "remote_hosts",
+ "columns": {
+ "ssh_host": {
+ "name": "ssh_host",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "CURRENT_TIMESTAMP"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "CURRENT_TIMESTAMP"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "sessions": {
+ "name": "sessions",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "agent_id": {
+ "name": "agent_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "config": {
+ "name": "config",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "shell_id": {
+ "name": "shell_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "'system'"
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "agent_session_id": {
+ "name": "agent_session_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "agent_status": {
+ "name": "agent_status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "agent_status_seen": {
+ "name": "agent_status_seen",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": 1
+ },
+ "is_initial_session": {
+ "name": "is_initial_session",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "is_pinned": {
+ "name": "is_pinned",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": 0
+ },
+ "archived_at": {
+ "name": "archived_at",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "last_interacted_at": {
+ "name": "last_interacted_at",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "status_changed_at": {
+ "name": "status_changed_at",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "CURRENT_TIMESTAMP"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "CURRENT_TIMESTAMP"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "CURRENT_TIMESTAMP"
+ }
+ },
+ "indexes": {
+ "idx_sessions_agent_id": {
+ "name": "idx_sessions_agent_id",
+ "columns": ["agent_id"],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {
+ "sessions_agent_id_agents_id_fk": {
+ "name": "sessions_agent_id_agents_id_fk",
+ "tableFrom": "sessions",
+ "tableTo": "agents",
+ "columnsFrom": ["agent_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "switch_servers": {
+ "name": "switch_servers",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "gateway_url": {
+ "name": "gateway_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "api_url": {
+ "name": "api_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "managed": {
+ "name": "managed",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": false
+ },
+ "management_kind": {
+ "name": "management_kind",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "ssh_host": {
+ "name": "ssh_host",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "CURRENT_TIMESTAMP"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "CURRENT_TIMESTAMP"
+ }
+ },
+ "indexes": {
+ "idx_switch_servers_gateway_url": {
+ "name": "idx_switch_servers_gateway_url",
+ "columns": ["gateway_url"],
+ "isUnique": true
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ }
+ },
+ "views": {},
+ "enums": {},
+ "_meta": {
+ "schemas": {},
+ "tables": {},
+ "columns": {}
+ },
+ "internal": {
+ "indexes": {}
+ }
+}
diff --git a/dash/apps/switchdash-desktop/drizzle/meta/_journal.json b/dash/apps/switchdash-desktop/drizzle/meta/_journal.json
index 4d3af7920..5955655af 100644
--- a/dash/apps/switchdash-desktop/drizzle/meta/_journal.json
+++ b/dash/apps/switchdash-desktop/drizzle/meta/_journal.json
@@ -274,6 +274,13 @@
"when": 1784635106895,
"tag": "0038_remote_managed_servers",
"breakpoints": true
+ },
+ {
+ "idx": 39,
+ "version": "6",
+ "when": 1784829154686,
+ "tag": "0039_new_ben_parker",
+ "breakpoints": true
}
]
}
diff --git a/dash/apps/switchdash-desktop/src/main/core/agents/createAgent.ts b/dash/apps/switchdash-desktop/src/main/core/agents/createAgent.ts
index 12653b8f1..d80e27a6b 100644
--- a/dash/apps/switchdash-desktop/src/main/core/agents/createAgent.ts
+++ b/dash/apps/switchdash-desktop/src/main/core/agents/createAgent.ts
@@ -15,6 +15,7 @@ export async function createAgent(params: CreateAgentParams): Promise<Agent> {
switchAgentId: params.switchAgentId,
apiEndpoint: params.apiEndpoint,
serverId: params.serverId,
+ autoApprove: params.autoApprove,
updatedAt: sql`CURRENT_TIMESTAMP`,
})
.returning();
diff --git a/dash/apps/switchdash-desktop/src/main/core/agents/onboard-agent.ts b/dash/apps/switchdash-desktop/src/main/core/agents/onboard-agent.ts
index b93bafdaa..9643d3f19 100644
--- a/dash/apps/switchdash-desktop/src/main/core/agents/onboard-agent.ts
+++ b/dash/apps/switchdash-desktop/src/main/core/agents/onboard-agent.ts
@@ -132,6 +132,10 @@ export async function onboardAgent(params: OnboardAgentParams): Promise<OnboardA
switchAgentId: switchAgent.agentId,
apiEndpoint: switchAgent.apiEndpoint,
serverId: params.serverId,
+ // Honor an explicit choice from the add-agent modal; otherwise default by
+ // run location — remote agents run unattended on their VM with no operator
+ // to answer permission prompts, so default them to bypass, local off.
+ autoApprove: params.autoApprove ?? sshHost !== null,
});
// Seed the local auto_session mirror + start the watcher from the gateway
diff --git a/dash/apps/switchdash-desktop/src/main/core/agents/remote-session-reconciler.test.ts b/dash/apps/switchdash-desktop/src/main/core/agents/remote-session-reconciler.test.ts
index 4d9cb8678..dcdf3c82a 100644
--- a/dash/apps/switchdash-desktop/src/main/core/agents/remote-session-reconciler.test.ts
+++ b/dash/apps/switchdash-desktop/src/main/core/agents/remote-session-reconciler.test.ts
@@ -7,6 +7,7 @@ const REMOTE_AGENT = {
providerId: 'claude',
locationId: 'proj-1',
switchAgentId: 'switch-1',
+ autoApprove: true,
};
const getAgentById = vi.fn(async () => REMOTE_AGENT as unknown);
diff --git a/dash/apps/switchdash-desktop/src/main/core/agents/remote-session-reconciler.ts b/dash/apps/switchdash-desktop/src/main/core/agents/remote-session-reconciler.ts
index 8cd1d2344..71fb8ac46 100644
--- a/dash/apps/switchdash-desktop/src/main/core/agents/remote-session-reconciler.ts
+++ b/dash/apps/switchdash-desktop/src/main/core/agents/remote-session-reconciler.ts
@@ -413,7 +413,7 @@ class RemoteSessionReconciler {
id: sessionId,
agentId: agent.id,
title: roomId ? `Switch room ${roomId}` : 'Remote session',
- autoApprove: true,
+ autoApprove: agent.autoApprove,
});
if (!result.success) {
if (result.error.type === 'already-exists') {
diff --git a/dash/apps/switchdash-desktop/src/main/core/agents/updateAgent.ts b/dash/apps/switchdash-desktop/src/main/core/agents/updateAgent.ts
index 86179119e..a7d4bc59d 100644
--- a/dash/apps/switchdash-desktop/src/main/core/agents/updateAgent.ts
+++ b/dash/apps/switchdash-desktop/src/main/core/agents/updateAgent.ts
@@ -10,6 +10,7 @@ export type UpdateAgentParams = {
switchAgentId?: string | null;
apiEndpoint?: string | null;
serverId?: string;
+ autoApprove?: boolean;
};
type AgentUpdateSet = Parameters<ReturnType<typeof db.update<typeof agents>>['set']>[0];
@@ -20,6 +21,7 @@ export async function updateAgent(params: UpdateAgentParams): Promise<Agent | un
if (params.switchAgentId !== undefined) set.switchAgentId = params.switchAgentId;
if (params.apiEndpoint !== undefined) set.apiEndpoint = params.apiEndpoint;
if (params.serverId !== undefined) set.serverId = params.serverId;
+ if (params.autoApprove !== undefined) set.autoApprove = params.autoApprove;
const [row] = await db.update(agents).set(set).where(eq(agents.id, params.agentId)).returning();
if (!row) return undefined;
diff --git a/dash/apps/switchdash-desktop/src/main/core/agents/utils.ts b/dash/apps/switchdash-desktop/src/main/core/agents/utils.ts
index ee1fafd3d..8608a249b 100644
--- a/dash/apps/switchdash-desktop/src/main/core/agents/utils.ts
+++ b/dash/apps/switchdash-desktop/src/main/core/agents/utils.ts
@@ -11,6 +11,7 @@ export function mapAgentRowToAgent(row: AgentRow): Agent {
apiEndpoint: row.apiEndpoint ?? null,
serverId: row.serverId ?? null,
status: row.status ?? null,
+ autoApprove: row.autoApprove,
createdAt: row.createdAt,
updatedAt: row.updatedAt,
};
diff --git a/dash/apps/switchdash-desktop/src/main/core/settings/schema.ts b/dash/apps/switchdash-desktop/src/main/core/settings/schema.ts
index e4c819213..e078a9632 100644
--- a/dash/apps/switchdash-desktop/src/main/core/settings/schema.ts
+++ b/dash/apps/switchdash-desktop/src/main/core/settings/schema.ts
@@ -36,10 +36,6 @@ export const sessionSettingsSchema = z.object({
includeIssueContextByDefault: z.boolean(),
});
-export const agentAutoApproveDefaultsSchema = z
- .partialRecord(z.enum(AGENT_PROVIDER_IDS), z.boolean())
- .default({});
-
export const terminalSettingsSchema = z.object({
fontFamily: z.string().optional(),
fontSize: z.number().min(TERMINAL_FONT_SIZE_MIN).max(TERMINAL_FONT_SIZE_MAX).optional(),
@@ -136,7 +132,6 @@ export const APP_SETTINGS_SCHEMA_MAP = {
localLocation: localLocationSettingsSchema,
location: locationSettingsSchema,
sessions: sessionSettingsSchema,
- agentAutoApproveDefaults: agentAutoApproveDefaultsSchema,
defaultAgent: defaultAgentSchema,
keyboard: keyboardSettingsSchema,
notifications: notificationSettingsSchema,
@@ -154,7 +149,6 @@ export const appSettingsSchema = z.object({
localLocation: localLocationSettingsSchema,
location: locationSettingsSchema,
sessions: sessionSettingsSchema,
- agentAutoApproveDefaults: agentAutoApproveDefaultsSchema,
defaultAgent: defaultAgentSchema,
keyboard: keyboardSettingsSchema,
notifications: notificationSettingsSchema,
diff --git a/dash/apps/switchdash-desktop/src/main/core/settings/settings-registry.ts b/dash/apps/switchdash-desktop/src/main/core/settings/settings-registry.ts
index 401d33228..f1b7cdff1 100644
--- a/dash/apps/switchdash-desktop/src/main/core/settings/settings-registry.ts
+++ b/dash/apps/switchdash-desktop/src/main/core/settings/settings-registry.ts
@@ -28,7 +28,6 @@ export const SETTINGS_DEFAULTS = {
preserveNameCapitalization: false,
includeIssueContextByDefault: true,
},
- agentAutoApproveDefaults: {},
notifications: {
enabled: true,
sound: true,
diff --git a/dash/apps/switchdash-desktop/src/main/core/subagents/resolve-subagent-fs.test.ts b/dash/apps/switchdash-desktop/src/main/core/subagents/resolve-subagent-fs.test.ts
index f8b370ade..9431f5b85 100644
--- a/dash/apps/switchdash-desktop/src/main/core/subagents/resolve-subagent-fs.test.ts
+++ b/dash/apps/switchdash-desktop/src/main/core/subagents/resolve-subagent-fs.test.ts
@@ -36,6 +36,7 @@ function agent(overrides: Partial<Agent>): Agent {
apiEndpoint: 'https://switch.example.com',
serverId: 'srv-1',
status: null,
+ autoApprove: false,
createdAt: '',
updatedAt: '',
...overrides,
diff --git a/dash/apps/switchdash-desktop/src/main/core/switch-rooms/auto-session-watcher.test.ts b/dash/apps/switchdash-desktop/src/main/core/switch-rooms/auto-session-watcher.test.ts
index 0c26e4bbd..263d32152 100644
--- a/dash/apps/switchdash-desktop/src/main/core/switch-rooms/auto-session-watcher.test.ts
+++ b/dash/apps/switchdash-desktop/src/main/core/switch-rooms/auto-session-watcher.test.ts
@@ -2,6 +2,7 @@ import { beforeEach, describe, expect, it, vi } from 'vitest';
const createSession = vi.fn();
const getConnections = vi.fn();
+const getAgentById = vi.fn();
vi.mock('@main/lib/logger', () => ({
log: { info: vi.fn(), warn: vi.fn(), error: vi.fn() },
@@ -15,9 +16,12 @@ vi.mock('./switch-room-service', () => ({
switchRoomService: { getConnections: () => getConnections() },
}));
-// These are only touched by startForAgent / the loops, not by the decision
-// logic under test — stub them so the module imports cleanly.
-vi.mock('@main/core/agents/getAgentById', () => ({ getAgentById: vi.fn() }));
+// spawnForRoom reads the agent to decide autoApprove; startForAgent / the loops
+// also touch this. Route it through a controllable mock so tests can set the
+// per-agent flag.
+vi.mock('@main/core/agents/getAgentById', () => ({
+ getAgentById: (...args: unknown[]) => getAgentById(...args),
+}));
vi.mock('@main/db/client', () => ({ db: {} }));
vi.mock('./auto-session-store', () => ({
listAutoSessionAgentIds: vi.fn(async () => []),
@@ -50,6 +54,8 @@ describe('AutoSessionWatcher.handleNotification', () => {
beforeEach(() => {
createSession.mockReset();
getConnections.mockReset();
+ getAgentById.mockReset();
+ getAgentById.mockResolvedValue({ id: 'local-1', autoApprove: false });
createSession.mockResolvedValue({ success: true, data: { session: { id: 'new' } } });
});
@@ -65,6 +71,30 @@ describe('AutoSessionWatcher.handleNotification', () => {
expect(params.initialPrompt).toContain('room-x');
});
+ it('spawns with permissions enforced when the agent has autoApprove off', async () => {
+ getConnections.mockReturnValue([]);
+ getAgentById.mockResolvedValue({ id: 'local-1', autoApprove: false });
+ const watcher = fakeWatcher();
+
+ handle(watcher, 'room-x');
+ await vi.waitFor(() => expect(createSession).toHaveBeenCalledTimes(1));
+
+ const params = createSession.mock.calls[0][0] as { autoApprove: boolean };
+ expect(params.autoApprove).toBe(false);
+ });
+
+ it('spawns with permissions bypassed when the agent has autoApprove on', async () => {
+ getConnections.mockReturnValue([]);
+ getAgentById.mockResolvedValue({ id: 'local-1', autoApprove: true });
+ const watcher = fakeWatcher();
+
+ handle(watcher, 'room-x');
+ await vi.waitFor(() => expect(createSession).toHaveBeenCalledTimes(1));
+
+ const params = createSession.mock.calls[0][0] as { autoApprove: boolean };
+ expect(params.autoApprove).toBe(true);
+ });
+
it('does not spawn when a live session already attends the room', async () => {
getConnections.mockReturnValue([
{ sessionId: 'c1', roomId: 'room-x', agentId: 'switch-agent-1' },
diff --git a/dash/apps/switchdash-desktop/src/main/core/switch-rooms/auto-session-watcher.ts b/dash/apps/switchdash-desktop/src/main/core/switch-rooms/auto-session-watcher.ts
index 910b4b85f..184db82f5 100644
--- a/dash/apps/switchdash-desktop/src/main/core/switch-rooms/auto-session-watcher.ts
+++ b/dash/apps/switchdash-desktop/src/main/core/switch-rooms/auto-session-watcher.ts
@@ -384,6 +384,11 @@ class AutoSessionWatcher {
}
private async spawnForRoom(watcher: AgentWatcher, roomId: string): Promise<void> {
+ // Bypass permissions only if this agent is configured to. Auto-started
+ // local sessions run with no operator watching, but the default is off —
+ // the per-agent setting (location settings) is the source of truth.
+ const agent = await getAgentById(watcher.localAgentId);
+ const autoApprove = agent?.autoApprove ?? false;
let lastError: string | null = null;
for (let attempt = 1; attempt <= SPAWN_MAX_ATTEMPTS; attempt += 1) {
if (watcher.abort.signal.aborted) return;
@@ -397,7 +402,7 @@ class AutoSessionWatcher {
// connect_to_room, the connect hook starts the per-room poller, which
// injects the message waiting in the room's event queue.
initialPrompt: `connect to switch room ${roomId}`,
- autoApprove: true,
+ autoApprove,
});
if (result.success) {
log.info('AutoSessionWatcher: spawned session for room', {
diff --git a/dash/apps/switchdash-desktop/src/main/db/schema.ts b/dash/apps/switchdash-desktop/src/main/db/schema.ts
index b0f653197..9c274200e 100644
--- a/dash/apps/switchdash-desktop/src/main/db/schema.ts
+++ b/dash/apps/switchdash-desktop/src/main/db/schema.ts
@@ -151,6 +151,11 @@ export const agents = sqliteTable(
apiEndpoint: text('api_endpoint'),
serverId: text('server_id').references(() => switchServers.id, { onDelete: 'set null' }),
status: text('status'),
+ // When set, switchdash launches this agent's CLI with its auto-approve /
+ // "bypass permissions" flag (e.g. `--dangerously-skip-permissions`).
+ // Defaults false for local agents; onboarding seeds it true for remote
+ // agents (see onboard-agent). Editable per agent in location settings.
+ autoApprove: integer('auto_approve', { mode: 'boolean' }).notNull().default(false),
createdAt: text('created_at')
.notNull()
.default(sql`CURRENT_TIMESTAMP`),
diff --git a/dash/apps/switchdash-desktop/src/renderer/features/locations/components/add-agent-modal/add-agent-modal.tsx b/dash/apps/switchdash-desktop/src/renderer/features/locations/components/add-agent-modal/add-agent-modal.tsx
index b3d9a479d..e6921dd8a 100644
--- a/dash/apps/switchdash-desktop/src/renderer/features/locations/components/add-agent-modal/add-agent-modal.tsx
+++ b/dash/apps/switchdash-desktop/src/renderer/features/locations/components/add-agent-modal/add-agent-modal.tsx
@@ -62,7 +62,7 @@ export const AddAgentModal = observer(function AddAgentModal({ onClose }: AddLoc
const showAddServerModal = useShowModal('addServerModal');
const pickState = usePickMode();
- const configureForm = useConfigureAgentForm(pickState.path);
+ const configureForm = useConfigureAgentForm(pickState.path, false);
// Run location: 'local' (default) or an onboarded remote host's SSH alias. A
// remote agent runs its sessions on the host and needs a remote working dir.
@@ -70,7 +70,7 @@ export const AddAgentModal = observer(function AddAgentModal({ onClose }: AddLoc
const [remoteRepoDir, setRemoteRepoDir] = useState('');
// Configure form for onboarding a brand-new agent in the remote dir. Defaults
// (name/description) are derived from the remote dir just like a local agent.
- const remoteConfigureForm = useConfigureAgentForm(remoteRepoDir.trim());
+ const remoteConfigureForm = useConfigureAgentForm(remoteRepoDir.trim(), true);
const { data: remoteHosts } = useQuery({
queryKey: ['remote-hosts'],
queryFn: () => rpc.remoteHosts.listHosts(),
@@ -262,6 +262,7 @@ export const AddAgentModal = observer(function AddAgentModal({ onClose }: AddLoc
serverId: pickState.serverId,
providerId: pickState.providerId,
remote: { sshHost: runHost, dir: trimmedRemoteDir },
+ autoApprove: remoteConfigureForm.autoApprove,
}
: {
mode: 'pick',
@@ -270,6 +271,7 @@ export const AddAgentModal = observer(function AddAgentModal({ onClose }: AddLoc
serverId: pickState.serverId,
providerId: pickState.providerId,
remote: undefined,
+ autoApprove: configureForm.autoApprove,
};
// The new location mounts (leaving the always-shown "unregistered" state)
// before agentsStore re-fetches its agent, which would drop it out of the
diff --git a/dash/apps/switchdash-desktop/src/renderer/features/locations/components/add-agent-modal/configure-agent-panel.tsx b/dash/apps/switchdash-desktop/src/renderer/features/locations/components/add-agent-modal/configure-agent-panel.tsx
index 7f3444c5c..1995a20a0 100644
--- a/dash/apps/switchdash-desktop/src/renderer/features/locations/components/add-agent-modal/configure-agent-panel.tsx
+++ b/dash/apps/switchdash-desktop/src/renderer/features/locations/components/add-agent-modal/configure-agent-panel.tsx
@@ -169,6 +169,23 @@ export const ConfigureAgentPanel = observer(function ConfigureAgentPanel({
/>
</label>
</Field>
+
+ <Field>
+ <label className="flex cursor-pointer items-start justify-between gap-3 rounded-md border border-border px-2 py-1.5">
+ <span className="flex flex-col gap-0.5">
+ <span className="text-sm">Bypass permissions</span>
+ <span className="text-xs text-foreground-muted">
+ Start this agent&apos;s sessions with permission prompts bypassed (the provider&apos;s
+ auto-approve flag). Turn on only for agents you trust to run unattended.
+ </span>
+ </span>
+ <Switch
+ className="mt-0.5"
+ checked={form.autoApprove}
+ onCheckedChange={(checked) => form.setAutoApprove(checked)}
+ />
+ </label>
+ </Field>
</FieldGroup>
);
});
diff --git a/dash/apps/switchdash-desktop/src/renderer/features/locations/components/add-agent-modal/modes.ts b/dash/apps/switchdash-desktop/src/renderer/features/locations/components/add-agent-modal/modes.ts
index 5605adfad..65d5cd1d4 100644
--- a/dash/apps/switchdash-desktop/src/renderer/features/locations/components/add-agent-modal/modes.ts
+++ b/dash/apps/switchdash-desktop/src/renderer/features/locations/components/add-agent-modal/modes.ts
@@ -53,7 +53,7 @@ export type PickModeState = ReturnType<typeof usePickMode>;
* optional notify handle — seeding name/description from a server-derived
* default until the user edits them.
*/
-export function useConfigureAgentForm(dir: string) {
+export function useConfigureAgentForm(dir: string, defaultAutoApprove: boolean) {
const [agentName, setAgentNameRaw] = useState('');
const [agentNameTouched, setAgentNameTouched] = useState(false);
const [description, setDescriptionRaw] = useState('');
@@ -61,6 +61,7 @@ export function useConfigureAgentForm(dir: string) {
const [providerKind, setProviderKind] = useState<AgentProviderKind | null>(null);
const [notifyUser, setNotifyUser] = useState('');
const [autoSession, setAutoSession] = useState(true);
+ const [autoApprove, setAutoApprove] = useState(defaultAutoApprove);
const trimmedDir = dir.trim();
// suggestAgentDefaults derives name/description from the directory basename and
@@ -103,6 +104,8 @@ export function useConfigureAgentForm(dir: string) {
setNotifyUser,
autoSession,
setAutoSession,
+ autoApprove,
+ setAutoApprove,
isValid,
};
}
diff --git a/dash/apps/switchdash-desktop/src/renderer/features/locations/components/settings-view/sections/auto-approve-settings-section.tsx b/dash/apps/switchdash-desktop/src/renderer/features/locations/components/settings-view/sections/auto-approve-settings-section.tsx
new file mode 100644
index 000000000..981fe4ee9
--- /dev/null
+++ b/dash/apps/switchdash-desktop/src/renderer/features/locations/components/settings-view/sections/auto-approve-settings-section.tsx
@@ -0,0 +1,81 @@
+import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
+import { rpc } from '@renderer/lib/ipc';
+import { Field, FieldDescription, FieldTitle } from '@renderer/lib/ui/field';
+import { Switch } from '@renderer/lib/ui/switch';
+import { log } from '@renderer/utils/logger';
+
+/**
+ * Per-agent "bypass permissions" toggle. When on, switchdash launches this
+ * agent's CLI with its auto-approve flag (e.g. `--dangerously-skip-permissions`)
+ * — for every session, including automation-started ones (auto-session,
+ * remote reconcile). Defaults off for local agents and on for remote agents
+ * (seeded at onboarding); this row is the source of truth thereafter. The
+ * value lives on the agent row, so the toggle writes through `updateAgent`.
+ */
+export function AutoApproveSettingsSection({ locationId }: { locationId: string }) {
+ const { data: agents } = useQuery({
+ queryKey: ['location-agents', locationId],
+ queryFn: () => rpc.agents.getAgents(locationId),
+ });
+
+ if ((agents ?? []).length === 0) return null;
+
+ return (
+ <Field>
+ <FieldTitle>Bypass permissions</FieldTitle>
+ <FieldDescription className="text-foreground-muted">
+ When on, switchdash starts this agent&apos;s sessions with permission prompts bypassed (the
+ provider&apos;s auto-approve flag). Off by default; turn it on only for agents you trust to
+ run unattended.
+ </FieldDescription>
+ <div className="flex flex-col gap-2">
+ {(agents ?? []).map((agent) => (
+ <AutoApproveRow
+ key={agent.id}
+ agentId={agent.id}
+ agentName={agent.name}
+ enabled={agent.autoApprove}
+ locationId={locationId}
+ />
+ ))}
+ </div>
+ </Field>
+ );
+}
+
+function AutoApproveRow({
+ agentId,
+ agentName,
+ enabled,
+ locationId,
+}: {
+ agentId: string;
+ agentName: string;
+ enabled: boolean;
+ locationId: string;
+}) {
+ const queryClient = useQueryClient();
+ const queryKey = ['location-agents', locationId];
+
+ const mutation = useMutation({
+ mutationFn: (next: boolean) => rpc.agents.updateAgent({ agentId, autoApprove: next }),
+ onError: (error) => {
+ log.error('Failed to update autoApprove for agent', { agentId, error });
+ void queryClient.invalidateQueries({ queryKey });
+ },
+ onSettled: () => {
+ void queryClient.invalidateQueries({ queryKey });
+ },
+ });
+
+ return (
+ <div className="flex items-center justify-between gap-3 rounded-md border border-border px-2 py-1.5">
+ <span className="truncate text-sm">{agentName}</span>
+ <Switch
+ checked={enabled}
+ disabled={mutation.isPending}
+ onCheckedChange={(checked) => mutation.mutate(checked)}
+ />
+ </div>
+ );
+}
diff --git a/dash/apps/switchdash-desktop/src/renderer/features/locations/components/settings-view/settings-panel.tsx b/dash/apps/switchdash-desktop/src/renderer/features/locations/components/settings-view/settings-panel.tsx
index d799d86f6..74e2efa7a 100644
--- a/dash/apps/switchdash-desktop/src/renderer/features/locations/components/settings-view/settings-panel.tsx
+++ b/dash/apps/switchdash-desktop/src/renderer/features/locations/components/settings-view/settings-panel.tsx
@@ -1,4 +1,5 @@
import { observer } from 'mobx-react-lite';
+import { AutoApproveSettingsSection } from '@renderer/features/locations/components/settings-view/sections/auto-approve-settings-section';
import { AutoSessionSettingsSection } from '@renderer/features/locations/components/settings-view/sections/auto-session-settings-section';
import { SubagentAutoSessionSettingsSection } from '@renderer/features/locations/components/settings-view/sections/subagent-auto-session-settings-section';
import {
@@ -29,6 +30,7 @@ export const SettingsPanel = observer(function SettingsPanel() {
) : (
<>
<AutoSessionSettingsSection locationId={locationId} />
+ <AutoApproveSettingsSection locationId={locationId} />
</>
)}
</div>
diff --git a/dash/apps/switchdash-desktop/src/renderer/features/locations/stores/agent-onboarding-types.ts b/dash/apps/switchdash-desktop/src/renderer/features/locations/stores/agent-onboarding-types.ts
index c6bd5167a..5dfef0fff 100644
--- a/dash/apps/switchdash-desktop/src/renderer/features/locations/stores/agent-onboarding-types.ts
+++ b/dash/apps/switchdash-desktop/src/renderer/features/locations/stores/agent-onboarding-types.ts
@@ -16,6 +16,9 @@ export interface PickModeData extends BaseModeData {
providerId: AgentProviderId;
/** When set, the agent runs at a remote location on this SSH host + dir. */
remote?: { sshHost: string; dir: string };
+ /** Seed for the per-agent bypass-permissions flag. Omit to take the default
+ * (false for local, true for remote). */
+ autoApprove?: boolean;
}
export type ModeData = PickModeData;
diff --git a/dash/apps/switchdash-desktop/src/renderer/features/locations/stores/location-manager.test.ts b/dash/apps/switchdash-desktop/src/renderer/features/locations/stores/location-manager.test.ts
index d18e93643..ff4118b81 100644
--- a/dash/apps/switchdash-desktop/src/renderer/features/locations/stores/location-manager.test.ts
+++ b/dash/apps/switchdash-desktop/src/renderer/features/locations/stores/location-manager.test.ts
@@ -67,6 +67,7 @@ function agent(overrides: Partial<Agent> = {}): Agent {
apiEndpoint: 'https://switch.example.com',
serverId: 'server-1',
status: null,
+ autoApprove: false,
createdAt: '2026-05-28T00:00:00.000Z',
updatedAt: '2026-05-28T00:00:00.000Z',
...overrides,
diff --git a/dash/apps/switchdash-desktop/src/renderer/features/locations/stores/location-manager.ts b/dash/apps/switchdash-desktop/src/renderer/features/locations/stores/location-manager.ts
index 11754cf5b..f4feeebda 100644
--- a/dash/apps/switchdash-desktop/src/renderer/features/locations/stores/location-manager.ts
+++ b/dash/apps/switchdash-desktop/src/renderer/features/locations/stores/location-manager.ts
@@ -117,6 +117,7 @@ export class LocationManagerStore {
providerId: data.providerId,
dir,
sshHost: data.remote?.sshHost,
+ autoApprove: data.autoApprove,
});
if (!onboarded.success) {
result = err(onboarded.error);
diff --git a/dash/apps/switchdash-desktop/src/renderer/features/sessions/create-session-modal/create-session-modal.tsx b/dash/apps/switchdash-desktop/src/renderer/features/sessions/create-session-modal/create-session-modal.tsx
index 466394c59..aa6c4ab64 100644
--- a/dash/apps/switchdash-desktop/src/renderer/features/sessions/create-session-modal/create-session-modal.tsx
+++ b/dash/apps/switchdash-desktop/src/renderer/features/sessions/create-session-modal/create-session-modal.tsx
@@ -3,7 +3,6 @@ import { ChevronDown } from 'lucide-react';
import { observer } from 'mobx-react-lite';
import { useEffect, useMemo, useState } from 'react';
import { getLocationManagerStore } from '@renderer/features/locations/stores/location-selectors';
-import { useAgentAutoApproveDefaults } from '@renderer/features/sessions/hooks/useAgentAutoApproveDefaults';
import { getSessionManagerStore } from '@renderer/features/sessions/stores/session-selectors';
import { switchRoomsStore } from '@renderer/features/switch-servers/switch-rooms-store';
import { rpc } from '@renderer/lib/ipc';
@@ -46,7 +45,6 @@ import { buildConnectPrompt } from './build-connect-prompt';
// and there is no git worktree — sessions run in the agent's location root. So the
// spawn dialog only asks for an optional name, an optional initial prompt, and an
// optional Switch room (and role in it) to connect to on start.
-const SESSION_PROVIDER = 'claude' as const;
const NO_ROLE = '__none__';
@@ -83,7 +81,6 @@ export const CreateSessionModal = observer(function CreateSessionModal({
initialPR?: unknown;
}) {
const selectedLocationId = useDefaultLocationId(locationId);
- const autoApproveDefaults = useAgentAutoApproveDefaults();
const { navigate } = useNavigate();
const [name, setName] = useState('');
@@ -169,7 +166,7 @@ export const CreateSessionModal = observer(function CreateSessionModal({
id,
agentId: resolvedAgent.id,
title: trimmedName || 'Session',
- autoApprove: autoApproveDefaults.getDefault(SESSION_PROVIDER),
+ autoApprove: resolvedAgent.autoApprove,
initialPrompt,
subagentName: subagentName || undefined,
});
diff --git a/dash/apps/switchdash-desktop/src/renderer/features/sessions/hooks/useAgentAutoApproveDefaults.ts b/dash/apps/switchdash-desktop/src/renderer/features/sessions/hooks/useAgentAutoApproveDefaults.ts
deleted file mode 100644
index beab68bd4..000000000
--- a/dash/apps/switchdash-desktop/src/renderer/features/sessions/hooks/useAgentAutoApproveDefaults.ts
+++ /dev/null
@@ -1,17 +0,0 @@
-import { useAppSettingsKey } from '@renderer/features/settings/use-app-settings-key';
-import { getAgentAutoApproveDefault } from '@shared/core/providers/agent-auto-approve-defaults';
-import type { AgentProviderId } from '@shared/core/providers/agent-provider-registry';
-
-export function useAgentAutoApproveDefaults() {
- const { value, isLoading, isSaving, update } = useAppSettingsKey('agentAutoApproveDefaults');
- const defaults = value ?? {};
-
- return {
- defaults,
- loading: isLoading,
- saving: isSaving,
- getDefault: (providerId: AgentProviderId) => getAgentAutoApproveDefault(defaults, providerId),
- setDefault: (providerId: AgentProviderId, enabled: boolean) =>
- update({ [providerId]: enabled }),
- };
-}
diff --git a/dash/apps/switchdash-desktop/src/shared/core/agents/agents.ts b/dash/apps/switchdash-desktop/src/shared/core/agents/agents.ts
index 21143c7e9..7c8a90d36 100644
--- a/dash/apps/switchdash-desktop/src/shared/core/agents/agents.ts
+++ b/dash/apps/switchdash-desktop/src/shared/core/agents/agents.ts
@@ -18,6 +18,10 @@ export type Agent = {
apiEndpoint: string | null;
serverId: string | null;
status: string | null;
+ /** When true, switchdash launches this agent's CLI with its auto-approve /
+ * "bypass permissions" flag. Defaults false for local agents and true for
+ * remote agents (seeded at onboarding); editable per agent. */
+ autoApprove: boolean;
createdAt: string;
updatedAt: string;
};
@@ -33,6 +37,9 @@ export type CreateAgentParams = {
* chosen and verified at onboarding (legacy rows may still be null until the
* user assigns one). */
serverId: string;
+ /** Seed for the per-agent bypass-permissions flag: false for local agents,
+ * true for remote agents. */
+ autoApprove: boolean;
};
export type RenameAgentParams = {
diff --git a/dash/apps/switchdash-desktop/src/shared/core/agents/onboarding.ts b/dash/apps/switchdash-desktop/src/shared/core/agents/onboarding.ts
index a7abfb5e3..948073cfc 100644
--- a/dash/apps/switchdash-desktop/src/shared/core/agents/onboarding.ts
+++ b/dash/apps/switchdash-desktop/src/shared/core/agents/onboarding.ts
@@ -21,6 +21,9 @@ export type OnboardAgentParams = {
* plus the absolute working directory on that host. */
sshHost?: string;
dir: string;
+ /** Seed for the per-agent bypass-permissions flag. Omit to take the
+ * default (false for local, true for remote). */
+ autoApprove?: boolean;
};
export type OnboardAgentError =
diff --git a/dash/apps/switchdash-desktop/src/shared/core/app-settings.ts b/dash/apps/switchdash-desktop/src/shared/core/app-settings.ts
index 27c270d07..89011df36 100644
--- a/dash/apps/switchdash-desktop/src/shared/core/app-settings.ts
+++ b/dash/apps/switchdash-desktop/src/shared/core/app-settings.ts
@@ -1,7 +1,6 @@
import type z from 'zod';
import {
appSettingsSchema,
- type agentAutoApproveDefaultsSchema,
type browserSettingsSchema,
type changesViewModeSchema,
type interfaceSettingsSchema,
@@ -18,7 +17,6 @@ export type LocalLocationSettings = z.infer<typeof localLocationSettingsSchema>;
export type LocationSettings = z.infer<typeof locationSettingsSchema>;
export type NotificationSettings = z.infer<typeof notificationSettingsSchema>;
export type SessionSettings = z.infer<typeof sessionSettingsSchema>;
-export type AgentAutoApproveDefaults = z.infer<typeof agentAutoApproveDefaultsSchema>;
export type TerminalSettings = z.infer<typeof terminalSettingsSchema>;
export type Theme = z.infer<typeof themeSchema>;
diff --git a/dash/apps/switchdash-desktop/src/shared/core/providers/agent-auto-approve-defaults.ts b/dash/apps/switchdash-desktop/src/shared/core/providers/agent-auto-approve-defaults.ts
deleted file mode 100644
index 1fe8a54fa..000000000
--- a/dash/apps/switchdash-desktop/src/shared/core/providers/agent-auto-approve-defaults.ts
+++ /dev/null
@@ -1,31 +0,0 @@
-import { getProvider, isValidProviderId, type AgentProviderId } from './agent-provider-registry';
-
-export type AgentAutoApproveDefaults = Partial<Record<AgentProviderId, boolean>>;
-
-export function providerSupportsAutoApprove(providerId: AgentProviderId): boolean {
- const provider = getProvider(providerId);
- return Boolean(provider?.autoApproveFlag || provider?.autoApproveViaEnv);
-}
-
-export function getAgentAutoApproveDefault(
- defaults: AgentAutoApproveDefaults | undefined,
- providerId: AgentProviderId
-): boolean {
- return defaults?.[providerId] ?? false;
-}
-
-export function resolveAgentAutoApprove(
- explicitAutoApprove: boolean | undefined,
- defaults: AgentAutoApproveDefaults | undefined,
- providerId: AgentProviderId
-): boolean {
- return explicitAutoApprove ?? getAgentAutoApproveDefault(defaults, providerId);
-}
-
-export function resolveAutomationAgentAutoApprove(
- provider: string,
- configured: boolean | undefined
-): boolean | undefined {
- if (!isValidProviderId(provider)) return configured;
- return providerSupportsAutoApprove(provider) ? true : configured;
-}
diff --git a/dash/apps/switchdash-desktop/tooling/fixtures/baseline.db b/dash/apps/switchdash-desktop/tooling/fixtures/baseline.db
index 82fa7cb14..23f9fa3ff 100644
Binary files a/dash/apps/switchdash-desktop/tooling/fixtures/baseline.db and b/dash/apps/switchdash-desktop/tooling/fixtures/baseline.db differ
diff --git a/dash/apps/switchdash-desktop/tooling/fixtures/empty.db b/dash/apps/switchdash-desktop/tooling/fixtures/empty.db
index ca15db7e6..c8fa0866d 100644
Binary files a/dash/apps/switchdash-desktop/tooling/fixtures/empty.db and b/dash/apps/switchdash-desktop/tooling/fixtures/empty.db differ