From 7aaf568c3f15ae0a5c9dcab14f3e61d811515c9a Mon Sep 17 00:00:00 2001 From: kaitranntt Date: Sun, 1 Feb 2026 02:41:04 -0500 Subject: [PATCH] fix(cliproxy): load WebSearch hooks via --settings flag - Add --settings flag to Claude CLI spawn for CLIProxy profiles - Use getProviderSettingsPath() for hardcoded profiles (agy, gemini, codex, qwen) - Use cfg.customSettingsPath for CLIProxy variants (user-defined providers) - Block user --settings flag to prevent duplicate flags - Enables WebSearch hooks to load for all CLIProxy profiles Closes #412 --- src/cliproxy/cliproxy-executor.ts | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/cliproxy/cliproxy-executor.ts b/src/cliproxy/cliproxy-executor.ts index 18e4faa4..c3876358 100644 --- a/src/cliproxy/cliproxy-executor.ts +++ b/src/cliproxy/cliproxy-executor.ts @@ -24,6 +24,7 @@ import { getRemoteEnvVars, getProviderConfig, ensureProviderSettings, + getProviderSettingsPath, CLIPROXY_DEFAULT_PORT, getCliproxyWritablePath, validatePort, @@ -973,6 +974,7 @@ export async function execClaudeWithCLIProxy( '--incognito', '--no-incognito', '--import', + '--settings', // Block user --settings to prevent duplicate flags // Proxy flags are handled by resolveProxyConfig, but list for documentation ...PROXY_CLI_FLAGS, ]; @@ -994,9 +996,17 @@ export async function execClaudeWithCLIProxy( const isWindows = process.platform === 'win32'; const needsShell = isWindows && /\.(cmd|bat|ps1)$/i.test(claudeCli); + // Get profile settings path for hooks (WebSearch, etc.) + // Use custom settings path for CLIProxy variants, otherwise use default provider path + const settingsPath = cfg.customSettingsPath + ? cfg.customSettingsPath.replace(/^~/, process.env.HOME || '') + : getProviderSettingsPath(provider); + let claude: ChildProcess; if (needsShell) { - const cmdString = [claudeCli, ...claudeArgs].map(escapeShellArg).join(' '); + const cmdString = [claudeCli, '--settings', settingsPath, ...claudeArgs] + .map(escapeShellArg) + .join(' '); claude = spawn(cmdString, { stdio: 'inherit', windowsHide: true, @@ -1004,7 +1014,7 @@ export async function execClaudeWithCLIProxy( env, }); } else { - claude = spawn(claudeCli, claudeArgs, { + claude = spawn(claudeCli, ['--settings', settingsPath, ...claudeArgs], { stdio: 'inherit', windowsHide: true, env,