feat(cli): add explicit proxy option in cli (#2526)

Co-authored-by: Dcatfly <dcatfly@gmail.com>
This commit is contained in:
warjiang 2025-07-18 02:57:37 +08:00 committed by GitHub
parent 4ca471bac6
commit 606a7702de
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 126 additions and 12 deletions

View file

@ -17,6 +17,7 @@ import { Config, ApprovalMode } from '../config/config.js';
import { getResponseText } from '../utils/generateContentResponseUtilities.js';
import { fetchWithTimeout, isPrivateIp } from '../utils/fetch.js';
import { convert } from 'html-to-text';
import { ProxyAgent, setGlobalDispatcher } from 'undici';
const URL_FETCH_TIMEOUT_MS = 10000;
const MAX_CONTENT_LENGTH = 100000;
@ -81,6 +82,10 @@ export class WebFetchTool extends BaseTool<WebFetchToolParams, ToolResult> {
type: Type.OBJECT,
},
);
const proxy = config.getProxy();
if (proxy) {
setGlobalDispatcher(new ProxyAgent(proxy as string));
}
}
private async executeFallback(