feat: update openclaw and polish desktop flows

This commit is contained in:
inman
2026-05-13 21:52:17 +08:00
parent 7c8781a6e3
commit 86795078f7
22 changed files with 1145 additions and 186 deletions

View File

@@ -0,0 +1,59 @@
import type { ProxySettings } from './proxy';
import { resolveProxySettings } from './proxy';
const WHATSAPP_WEB_HOST = 'web.whatsapp.com';
function splitBypassRules(rules: string): string[] {
return rules
.split(/[,\n;]/)
.map((rule) => rule.trim())
.filter(Boolean);
}
function matchesBypassRule(host: string, rule: string): boolean {
const normalizedHost = host.toLowerCase();
const normalizedRule = rule.toLowerCase();
if (normalizedRule === '*') return true;
if (normalizedRule === '<local>') {
return normalizedHost === 'localhost'
|| normalizedHost === '127.0.0.1'
|| normalizedHost === '::1'
|| !normalizedHost.includes('.');
}
if (normalizedRule.startsWith('*.')) {
const suffix = normalizedRule.slice(1);
return normalizedHost.endsWith(suffix);
}
if (normalizedRule.startsWith('.')) {
return normalizedHost.endsWith(normalizedRule);
}
return normalizedHost === normalizedRule;
}
export function shouldBypassWhatsAppProxy(bypassRules: string): boolean {
return splitBypassRules(bypassRules).some((rule) => matchesBypassRule(WHATSAPP_WEB_HOST, rule));
}
export function resolveWhatsAppProxyUrl(settings: ProxySettings): string {
if (!settings.proxyEnabled) return '';
const resolved = resolveProxySettings(settings);
if (shouldBypassWhatsAppProxy(resolved.bypassRules)) return '';
return resolved.allProxy || resolved.httpsProxy || resolved.httpProxy;
}
export function isSocksProxyUrl(proxyUrl: string): boolean {
return /^socks[45]h?:\/\//i.test(proxyUrl.trim());
}
export function redactProxyUrlForLog(proxyUrl: string): string {
try {
const parsed = new URL(proxyUrl);
if (parsed.username) parsed.username = 'redacted';
if (parsed.password) parsed.password = 'redacted';
return parsed.toString();
} catch {
return proxyUrl.replace(/\/\/([^/@:]+):([^/@]+)@/, '//redacted:redacted@');
}
}