feat: backend selector setting

This commit is contained in:
DeskClaw Bot
2026-04-21 17:44:01 +00:00
Unverified
parent c231c54778
commit 5e6d7f9709
4 changed files with 38 additions and 1 deletions

View File

@@ -474,8 +474,9 @@ async function initialize(): Promise<void> {
}); });
// Start Gateway automatically (this seeds missing bootstrap files with full templates) // Start Gateway automatically (this seeds missing bootstrap files with full templates)
const gatewayBackend = await getSetting('gatewayBackend');
const gatewayAutoStart = await getSetting('gatewayAutoStart'); const gatewayAutoStart = await getSetting('gatewayAutoStart');
if (!isE2EMode && gatewayAutoStart) { if (!isE2EMode && gatewayBackend === 'openclaw' && gatewayAutoStart) {
try { try {
await syncAllProviderAuthToRuntime(); await syncAllProviderAuthToRuntime();
logger.debug('Auto-starting Gateway...'); logger.debug('Auto-starting Gateway...');
@@ -487,6 +488,8 @@ async function initialize(): Promise<void> {
} }
} else if (isE2EMode) { } else if (isE2EMode) {
logger.info('Gateway auto-start skipped in E2E mode'); logger.info('Gateway auto-start skipped in E2E mode');
} else if (gatewayBackend !== 'openclaw') {
logger.info(`Gateway auto-start skipped (backend=${gatewayBackend})`);
} else { } else {
logger.info('Gateway auto-start disabled in settings'); logger.info('Gateway auto-start disabled in settings');
} }

View File

@@ -35,6 +35,7 @@ export interface AppSettings {
gatewayAutoStart: boolean; gatewayAutoStart: boolean;
gatewayPort: number; gatewayPort: number;
gatewayToken: string; gatewayToken: string;
gatewayBackend: 'openclaw' | 'hermes';
proxyEnabled: boolean; proxyEnabled: boolean;
proxyServer: string; proxyServer: string;
proxyHttpServer: string; proxyHttpServer: string;
@@ -86,6 +87,7 @@ function createDefaultSettings(): AppSettings {
gatewayAutoStart: true, gatewayAutoStart: true,
gatewayPort: 18789, gatewayPort: 18789,
gatewayToken: generateToken(), gatewayToken: generateToken(),
gatewayBackend: 'openclaw',
proxyEnabled: false, proxyEnabled: false,
proxyServer: '', proxyServer: '',
proxyHttpServer: '', proxyHttpServer: '',

View File

@@ -18,6 +18,7 @@ import { Switch } from '@/components/ui/switch';
import { Separator } from '@/components/ui/separator'; import { Separator } from '@/components/ui/separator';
import { Badge } from '@/components/ui/badge'; import { Badge } from '@/components/ui/badge';
import { Input } from '@/components/ui/input'; import { Input } from '@/components/ui/input';
import { Select } from '@/components/ui/select';
import { toast } from 'sonner'; import { toast } from 'sonner';
import { useSettingsStore } from '@/stores/settings'; import { useSettingsStore } from '@/stores/settings';
import { useGatewayStore } from '@/stores/gateway'; import { useGatewayStore } from '@/stores/gateway';
@@ -57,6 +58,8 @@ export function Settings() {
setLaunchAtStartup, setLaunchAtStartup,
gatewayAutoStart, gatewayAutoStart,
setGatewayAutoStart, setGatewayAutoStart,
gatewayBackend,
setGatewayBackend,
proxyEnabled, proxyEnabled,
proxyServer, proxyServer,
proxyHttpServer, proxyHttpServer,
@@ -627,6 +630,24 @@ export function Settings() {
/> />
</div> </div>
<div className="flex flex-col sm:flex-row sm:items-center justify-between gap-3">
<div>
<Label className="text-[15px] font-medium text-foreground">Backend</Label>
<p className="text-[13px] text-muted-foreground mt-1">
OpenClaw is the built-in gateway. Hermes requires WSL2 on Windows.
</p>
</div>
<div className="w-full sm:w-56">
<Select
value={gatewayBackend}
onChange={(event) => setGatewayBackend(event.target.value as 'openclaw' | 'hermes')}
>
<option value="openclaw">OpenClaw</option>
<option value="hermes">Hermes</option>
</Select>
</div>
</div>
<div className="flex items-center justify-between"> <div className="flex items-center justify-between">
<div> <div>

View File

@@ -10,6 +10,7 @@ import { resolveSupportedLanguage } from '../../shared/language';
type Theme = 'light' | 'dark' | 'system'; type Theme = 'light' | 'dark' | 'system';
type UpdateChannel = 'stable' | 'beta' | 'dev'; type UpdateChannel = 'stable' | 'beta' | 'dev';
type GatewayBackend = 'openclaw' | 'hermes';
interface SettingsState { interface SettingsState {
// General // General
@@ -22,6 +23,7 @@ interface SettingsState {
// Gateway // Gateway
gatewayAutoStart: boolean; gatewayAutoStart: boolean;
gatewayPort: number; gatewayPort: number;
gatewayBackend: GatewayBackend;
proxyEnabled: boolean; proxyEnabled: boolean;
proxyServer: string; proxyServer: string;
proxyHttpServer: string; proxyHttpServer: string;
@@ -50,6 +52,7 @@ interface SettingsState {
setTelemetryEnabled: (value: boolean) => void; setTelemetryEnabled: (value: boolean) => void;
setGatewayAutoStart: (value: boolean) => void; setGatewayAutoStart: (value: boolean) => void;
setGatewayPort: (port: number) => void; setGatewayPort: (port: number) => void;
setGatewayBackend: (value: GatewayBackend) => void;
setProxyEnabled: (value: boolean) => void; setProxyEnabled: (value: boolean) => void;
setProxyServer: (value: string) => void; setProxyServer: (value: string) => void;
setProxyHttpServer: (value: string) => void; setProxyHttpServer: (value: string) => void;
@@ -73,6 +76,7 @@ const defaultSettings = {
telemetryEnabled: true, telemetryEnabled: true,
gatewayAutoStart: true, gatewayAutoStart: true,
gatewayPort: 18789, gatewayPort: 18789,
gatewayBackend: 'openclaw' as GatewayBackend,
proxyEnabled: false, proxyEnabled: false,
proxyServer: '', proxyServer: '',
proxyHttpServer: '', proxyHttpServer: '',
@@ -157,6 +161,13 @@ export const useSettingsStore = create<SettingsState>()(
body: JSON.stringify({ value: gatewayPort }), body: JSON.stringify({ value: gatewayPort }),
}).catch(() => { }); }).catch(() => { });
}, },
setGatewayBackend: (gatewayBackend) => {
set({ gatewayBackend });
void hostApiFetch('/api/settings/gatewayBackend', {
method: 'PUT',
body: JSON.stringify({ value: gatewayBackend }),
}).catch(() => { });
},
setProxyEnabled: (proxyEnabled) => set({ proxyEnabled }), setProxyEnabled: (proxyEnabled) => set({ proxyEnabled }),
setProxyServer: (proxyServer) => set({ proxyServer }), setProxyServer: (proxyServer) => set({ proxyServer }),
setProxyHttpServer: (proxyHttpServer) => set({ proxyHttpServer }), setProxyHttpServer: (proxyHttpServer) => set({ proxyHttpServer }),