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
This commit is contained in:
kaitranntt committed 2026-02-01 02:47:15 -05:00
1 parent 53c9a3da9e
commit 7aaf568c3f
1 file changed
+12 -2
+12 -2
View File
@@ -24,6 +24,7 @@ import {
getRemoteEnvVars, getRemoteEnvVars,
getProviderConfig, getProviderConfig,
ensureProviderSettings, ensureProviderSettings,
getProviderSettingsPath,
CLIPROXY_DEFAULT_PORT, CLIPROXY_DEFAULT_PORT,
getCliproxyWritablePath, getCliproxyWritablePath,
validatePort, validatePort,
@@ -973,6 +974,7 @@ export async function execClaudeWithCLIProxy(
'--incognito', '--incognito',
'--no-incognito', '--no-incognito',
'--import', '--import',
'--settings', // Block user --settings to prevent duplicate flags
// Proxy flags are handled by resolveProxyConfig, but list for documentation // Proxy flags are handled by resolveProxyConfig, but list for documentation
...PROXY_CLI_FLAGS, ...PROXY_CLI_FLAGS,
]; ];
@@ -994,9 +996,17 @@ export async function execClaudeWithCLIProxy(
const isWindows = process.platform === 'win32'; const isWindows = process.platform === 'win32';
const needsShell = isWindows && /\.(cmd|bat|ps1)$/i.test(claudeCli); 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; let claude: ChildProcess;
if (needsShell) { if (needsShell) {
const cmdString = [claudeCli, ...claudeArgs].map(escapeShellArg).join(' '); const cmdString = [claudeCli, '--settings', settingsPath, ...claudeArgs]
.map(escapeShellArg)
.join(' ');
claude = spawn(cmdString, { claude = spawn(cmdString, {
stdio: 'inherit', stdio: 'inherit',
windowsHide: true, windowsHide: true,
@@ -1004,7 +1014,7 @@ export async function execClaudeWithCLIProxy(
env, env,
}); });
} else { } else {
claude = spawn(claudeCli, claudeArgs, { claude = spawn(claudeCli, ['--settings', settingsPath, ...claudeArgs], {
stdio: 'inherit', stdio: 'inherit',
windowsHide: true, windowsHide: true,
env, env,