From 4852ded7e5d960fec51d58c433d707d6c2d1cb9f Mon Sep 17 00:00:00 2001 From: stswangzhiping <59632378+stswangzhiping@users.noreply.github.com> Date: Sat, 4 Apr 2026 21:33:35 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20clawd=20=E4=B8=8D=E5=86=8D=E5=86=99=20ag?= =?UTF-8?q?ents/main/agent/auth-profiles.json?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit clawd 以 root 身份运行,写该目录会导致 gateway(sts 用户)的 agents 目录被 root 创建。 clawd 只需修改 openclaw.json,gateway 重启后会自行读取,无需操作 gateway 内部目录。 Made-with: Cursor --- lib/openclaw-provider.js | 38 +------------------------------------- 1 file changed, 1 insertion(+), 37 deletions(-) diff --git a/lib/openclaw-provider.js b/lib/openclaw-provider.js index a507560..1eaeda2 100644 --- a/lib/openclaw-provider.js +++ b/lib/openclaw-provider.js @@ -31,10 +31,6 @@ function restartGateway() { }); } -function authProfilesPathFromConfig(configFile) { - return path.join(path.dirname(configFile), 'agents', 'main', 'agent', 'auth-profiles.json'); -} - function buildModelsUrl(baseUrl) { let u = String(baseUrl || '').trim().replace(/\/+$/, ''); if (!/\/v1$/.test(u)) u = `${u}/v1`; @@ -105,7 +101,7 @@ function writeJsonFile(filePath, obj) { } /** - * 同步:从 openclaw.json + auth-profiles.json 删除指定 provider(解绑)。 + * 同步:从 openclaw.json 删除指定 provider(解绑)。 * 若 primary 指向该 provider,先置为空串。 */ function removeProviderByName(providerId) { @@ -146,20 +142,6 @@ function removeProviderByName(providerId) { } writeJsonFile(configFile, config); - - const authPath = authProfilesPathFromConfig(configFile); - try { - if (fs.existsSync(authPath)) { - const authProfiles = readJsonFile(authPath); - if (authProfiles.profiles?.[`${providerId}:default`]) { - delete authProfiles.profiles[`${providerId}:default`]; - writeJsonFile(authPath, authProfiles); - } - } - } catch (e) { - log.warn('openclaw-provider', `auth-profiles 更新失败: ${e.message}`); - } - log.info('openclaw-provider', `provider 已移除: ${providerId}`); restartGateway(); } @@ -223,24 +205,6 @@ function addProviderSync(configFile, providerId, baseUrl, apiKey, models, defaul }; writeJsonFile(configFile, config); - - const authPath = authProfilesPathFromConfig(configFile); - try { - let authProfiles = { profiles: {} }; - if (fs.existsSync(authPath)) { - authProfiles = readJsonFile(authPath); - if (!authProfiles.profiles) authProfiles.profiles = {}; - } - authProfiles.profiles[`${providerId}:default`] = { - type: 'api_key', - provider: providerId, - key: apiKey, - }; - writeJsonFile(authPath, authProfiles); - } catch (e) { - log.warn('openclaw-provider', `auth-profiles 写入失败: ${e.message}`); - } - log.info('openclaw-provider', `provider 已写入: ${providerId}(${models.length} 个模型)`); }