Merge branch 'main' into feature/stream-json-migration

This commit is contained in:
mingholy.lmh
2025-11-06 10:15:47 +08:00
43 changed files with 2279 additions and 501 deletions

View File

@@ -57,7 +57,7 @@ import { TaskTool } from '../tools/task.js';
import { TodoWriteTool } from '../tools/todoWrite.js';
import { ToolRegistry } from '../tools/tool-registry.js';
import { WebFetchTool } from '../tools/web-fetch.js';
import { WebSearchTool } from '../tools/web-search.js';
import { WebSearchTool } from '../tools/web-search/index.js';
import { WriteFileTool } from '../tools/write-file.js';
// Other modules
@@ -263,7 +263,14 @@ export interface ConfigParameters {
cliVersion?: string;
loadMemoryFromIncludeDirectories?: boolean;
// Web search providers
tavilyApiKey?: string;
webSearch?: {
provider: Array<{
type: 'tavily' | 'google' | 'dashscope';
apiKey?: string;
searchEngineId?: string;
}>;
default: string;
};
chatCompression?: ChatCompressionSettings;
interactive?: boolean;
trustedFolder?: boolean;
@@ -376,7 +383,14 @@ export class Config {
private readonly cliVersion?: string;
private readonly experimentalZedIntegration: boolean = false;
private readonly loadMemoryFromIncludeDirectories: boolean = false;
private readonly tavilyApiKey?: string;
private readonly webSearch?: {
provider: Array<{
type: 'tavily' | 'google' | 'dashscope';
apiKey?: string;
searchEngineId?: string;
}>;
default: string;
};
private readonly chatCompression: ChatCompressionSettings | undefined;
private readonly interactive: boolean;
private readonly trustedFolder: boolean | undefined;
@@ -487,7 +501,7 @@ export class Config {
this.skipLoopDetection = params.skipLoopDetection ?? false;
// Web search
this.tavilyApiKey = params.tavilyApiKey;
this.webSearch = params.webSearch;
this.useRipgrep = params.useRipgrep ?? true;
this.useBuiltinRipgrep = params.useBuiltinRipgrep ?? true;
this.shouldUseNodePtyShell = params.shouldUseNodePtyShell ?? false;
@@ -947,8 +961,8 @@ export class Config {
}
// Web search provider configuration
getTavilyApiKey(): string | undefined {
return this.tavilyApiKey;
getWebSearchConfig() {
return this.webSearch;
}
getIdeMode(): boolean {
@@ -1185,8 +1199,10 @@ export class Config {
registerCoreTool(TodoWriteTool, this);
registerCoreTool(ExitPlanModeTool, this);
registerCoreTool(WebFetchTool, this);
// Conditionally register web search tool only if Tavily API key is set
if (this.getTavilyApiKey()) {
// Conditionally register web search tool if web search provider is configured
// buildWebSearchConfig ensures qwen-oauth users get dashscope provider, so
// if tool is registered, config must exist
if (this.getWebSearchConfig()) {
registerCoreTool(WebSearchTool, this);
}