refactor(agent): 将 Summary Model 改造为内置 Sub Agent
- 扩展 AgentMode 类型添加 'internal' 模式 - 新增 summary agent preset (claude-3-5-haiku) - AgentRegistry 添加 getInternal/listInternalAgents 方法 - CompressionManager 添加 setSummaryModelFromAgentConfig - Agent 构造函数改用 Registry 配置初始化 Summary 模型 - 清理旧的 SummaryConfig 配置系统 - UI AgentsPanel 分离显示 System/Preset/Custom agents - UI AgentEditor 为 internal agent 显示简化编辑界面
This commit is contained in:
@@ -19,11 +19,6 @@ interface StoredConfig {
|
||||
visionModel?: string;
|
||||
/** Vision 专用的 Base URL(用于 OpenAI 兼容的 Vision 服务) */
|
||||
visionBaseUrl?: string;
|
||||
// Summary 配置(用于对话压缩摘要生成)
|
||||
summaryProvider?: ProviderType;
|
||||
summaryModel?: string;
|
||||
/** Summary 专用的 Base URL(用于 OpenAI 兼容的 Summary 服务) */
|
||||
summaryBaseUrl?: string;
|
||||
}
|
||||
|
||||
// Vision 配置接口
|
||||
@@ -35,15 +30,6 @@ export interface VisionConfig {
|
||||
baseUrl?: string;
|
||||
}
|
||||
|
||||
// Summary 配置接口(用于对话压缩摘要生成)
|
||||
export interface SummaryConfig {
|
||||
provider: ProviderType;
|
||||
apiKey: string;
|
||||
model: string;
|
||||
/** 自定义 Base URL(用于 OpenAI 兼容的 Summary 服务) */
|
||||
baseUrl?: string;
|
||||
}
|
||||
|
||||
// 默认模型配置
|
||||
const DEFAULT_MODELS: Record<ProviderType, string> = {
|
||||
anthropic: 'claude-sonnet-4-20250514',
|
||||
@@ -58,13 +44,6 @@ const DEFAULT_VISION_MODELS: Record<ProviderType, string> = {
|
||||
openai: 'gpt-4o',
|
||||
};
|
||||
|
||||
// 默认 Summary 模型(推荐使用成本较低的模型)
|
||||
const DEFAULT_SUMMARY_MODELS: Record<ProviderType, string> = {
|
||||
anthropic: 'claude-3-5-haiku-20241022',
|
||||
deepseek: 'deepseek-chat',
|
||||
openai: 'gpt-4o-mini',
|
||||
};
|
||||
|
||||
// 默认系统提示词
|
||||
const DEFAULT_SYSTEM_PROMPT = `你是一个运行在终端中的 AI 编程助手。你可以帮助用户:
|
||||
- 读取和写入文件
|
||||
@@ -167,49 +146,6 @@ export function loadVisionConfig(): VisionConfig | null {
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* 加载 Summary 配置
|
||||
* Summary 用于对话压缩时生成摘要,推荐使用成本较低的小模型
|
||||
* 通过 ProviderRegistry 获取 API Key
|
||||
*/
|
||||
export function loadSummaryConfig(): SummaryConfig | null {
|
||||
// 从配置文件读取
|
||||
const storedConfig = getConfig();
|
||||
|
||||
// 如果没有任何 summary 相关配置,返回 null(使用主模型)
|
||||
const hasSummaryConfig = storedConfig.summaryProvider || storedConfig.summaryModel;
|
||||
|
||||
if (!hasSummaryConfig) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// 确定 summary provider(默认使用主配置的 provider)
|
||||
const mainProvider = storedConfig.provider || 'anthropic';
|
||||
const finalProvider = storedConfig.summaryProvider || mainProvider;
|
||||
|
||||
// 通过 ProviderRegistry 获取 API Key
|
||||
const providerConfig = providerRegistry.getConfig(finalProvider);
|
||||
const finalApiKey = resolveApiKey(providerConfig);
|
||||
|
||||
// 如果没有 API Key,返回 null
|
||||
if (!finalApiKey) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// 确定模型
|
||||
const finalModel = storedConfig.summaryModel || DEFAULT_SUMMARY_MODELS[finalProvider];
|
||||
|
||||
// 确定 baseUrl
|
||||
const finalBaseUrl = storedConfig.summaryBaseUrl || providerConfig?.baseUrl;
|
||||
|
||||
return {
|
||||
provider: finalProvider,
|
||||
apiKey: finalApiKey,
|
||||
model: finalModel,
|
||||
baseUrl: finalBaseUrl,
|
||||
};
|
||||
}
|
||||
|
||||
// 保存配置
|
||||
export function saveConfig(config: Partial<StoredConfig>): void {
|
||||
// 确保目录存在
|
||||
|
||||
Reference in New Issue
Block a user