Feat/upgrade openclaw (#729)
This commit is contained in:
committed by
GitHub
Unverified
parent
bf5b089158
commit
d34a88e629
@@ -473,7 +473,7 @@ export async function removeProviderFromOpenClaw(provider: string): Promise<void
|
||||
const config = await readOpenClawJson();
|
||||
let modified = false;
|
||||
|
||||
// Disable plugin (for OAuth like qwen-portal-auth)
|
||||
// Disable plugin (for OAuth like minimax-portal-auth)
|
||||
const plugins = config.plugins as Record<string, unknown> | undefined;
|
||||
const entries = (plugins?.entries ?? {}) as Record<string, Record<string, unknown>>;
|
||||
const pluginName = `${provider}-auth`;
|
||||
@@ -872,6 +872,10 @@ export async function setOpenClawDefaultModelWithOverride(
|
||||
* Get a set of all active provider IDs configured in openclaw.json.
|
||||
* Reads the file ONCE and extracts both models.providers and plugins.entries.
|
||||
*/
|
||||
// Provider IDs that have been deprecated and should never appear as active.
|
||||
// These may still linger in openclaw.json from older versions.
|
||||
const DEPRECATED_PROVIDER_IDS = new Set(['qwen-portal']);
|
||||
|
||||
export async function getActiveOpenClawProviders(): Promise<Set<string>> {
|
||||
const activeProviders = new Set<string>();
|
||||
|
||||
@@ -897,7 +901,7 @@ export async function getActiveOpenClawProviders(): Promise<Set<string>> {
|
||||
}
|
||||
|
||||
// 3. agents.defaults.model.primary — the default model reference encodes
|
||||
// the provider prefix (e.g. "qwen-portal/coder-model" → "qwen-portal").
|
||||
// the provider prefix (e.g. "modelstudio/qwen3.5-plus" → "modelstudio").
|
||||
// This covers providers that are active via OAuth or env-key but don't
|
||||
// have an explicit models.providers entry.
|
||||
const agents = config.agents as Record<string, unknown> | undefined;
|
||||
@@ -921,6 +925,11 @@ export async function getActiveOpenClawProviders(): Promise<Set<string>> {
|
||||
console.warn('Failed to read openclaw.json for active providers:', err);
|
||||
}
|
||||
|
||||
// Remove deprecated providers that may still linger in config/auth files.
|
||||
for (const deprecated of DEPRECATED_PROVIDER_IDS) {
|
||||
activeProviders.delete(deprecated);
|
||||
}
|
||||
|
||||
return activeProviders;
|
||||
}
|
||||
|
||||
@@ -1350,10 +1359,24 @@ export async function sanitizeOpenClawConfig(): Promise<void> {
|
||||
toolsModified = true;
|
||||
}
|
||||
|
||||
// ── tools.exec approvals (OpenClaw 3.28+) ──────────────────────
|
||||
// ClawX is a local desktop app where the user is the trusted operator.
|
||||
// Exec approval prompts add unnecessary friction in this context, so we
|
||||
// set security="full" (allow all commands) and ask="off" (never prompt).
|
||||
// If a user has manually configured a stricter ~/.openclaw/exec-approvals.json,
|
||||
// OpenClaw's minSecurity/maxAsk merge will still respect their intent.
|
||||
const execConfig = (toolsConfig.exec as Record<string, unknown> | undefined) || {};
|
||||
if (execConfig.security !== 'full' || execConfig.ask !== 'off') {
|
||||
execConfig.security = 'full';
|
||||
execConfig.ask = 'off';
|
||||
toolsConfig.exec = execConfig;
|
||||
toolsModified = true;
|
||||
console.log('[sanitize] Set tools.exec.security="full" and tools.exec.ask="off" to disable exec approvals for ClawX desktop');
|
||||
}
|
||||
|
||||
if (toolsModified) {
|
||||
config.tools = toolsConfig;
|
||||
modified = true;
|
||||
console.log('[sanitize] Enforced tools.profile="full" and tools.sessions.visibility="all" for OpenClaw 3.8+');
|
||||
}
|
||||
|
||||
// ── plugins.entries.feishu cleanup ──────────────────────────────
|
||||
@@ -1465,6 +1488,44 @@ export async function sanitizeOpenClawConfig(): Promise<void> {
|
||||
modified = true;
|
||||
}
|
||||
|
||||
// ── qwen-portal → modelstudio migration ────────────────────
|
||||
// OpenClaw 2026.3.28 deprecated qwen-portal OAuth (portal.qwen.ai)
|
||||
// in favor of Model Studio (DashScope API key). Clean up legacy
|
||||
// qwen-portal-auth plugin entries and qwen-portal provider config.
|
||||
const LEGACY_QWEN_PLUGIN_ID = 'qwen-portal-auth';
|
||||
if (Array.isArray(pluginsObj.allow)) {
|
||||
const allowArr = pluginsObj.allow as string[];
|
||||
const legacyIdx = allowArr.indexOf(LEGACY_QWEN_PLUGIN_ID);
|
||||
if (legacyIdx !== -1) {
|
||||
allowArr.splice(legacyIdx, 1);
|
||||
console.log(`[sanitize] Removed deprecated plugin from plugins.allow: ${LEGACY_QWEN_PLUGIN_ID}`);
|
||||
modified = true;
|
||||
}
|
||||
}
|
||||
if (pEntries?.[LEGACY_QWEN_PLUGIN_ID]) {
|
||||
delete pEntries[LEGACY_QWEN_PLUGIN_ID];
|
||||
console.log(`[sanitize] Removed deprecated plugin from plugins.entries: ${LEGACY_QWEN_PLUGIN_ID}`);
|
||||
modified = true;
|
||||
}
|
||||
|
||||
// Remove deprecated models.providers.qwen-portal
|
||||
const LEGACY_QWEN_PROVIDER = 'qwen-portal';
|
||||
if (providers[LEGACY_QWEN_PROVIDER]) {
|
||||
delete providers[LEGACY_QWEN_PROVIDER];
|
||||
console.log(`[sanitize] Removed deprecated provider: ${LEGACY_QWEN_PROVIDER}`);
|
||||
modified = true;
|
||||
}
|
||||
|
||||
// Clean up qwen-portal OAuth auth profile (no longer functional)
|
||||
const authConfig = config.auth as Record<string, unknown> | undefined;
|
||||
const authProfiles = authConfig?.profiles as Record<string, unknown> | undefined;
|
||||
if (authProfiles?.[LEGACY_QWEN_PROVIDER]) {
|
||||
delete authProfiles[LEGACY_QWEN_PROVIDER];
|
||||
console.log(`[sanitize] Removed deprecated auth profile: ${LEGACY_QWEN_PROVIDER}`);
|
||||
modified = true;
|
||||
}
|
||||
|
||||
|
||||
// ── Remove bare 'feishu' when canonical feishu plugin is present ──
|
||||
// The Gateway binary automatically adds bare 'feishu' to plugins.allow
|
||||
// because the official plugin registers the 'feishu' channel.
|
||||
|
||||
Reference in New Issue
Block a user