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:
2025-12-14 22:12:36 +08:00
parent e97daaa0eb
commit c307cd3a7c
20 changed files with 339 additions and 594 deletions
+28
View File
@@ -9,6 +9,8 @@ import {
CompressionStatus,
DEFAULT_COMPRESSION_CONFIG,
} from './types.js';
import type { AgentModelConfig } from '../agent/types.js';
import { getProviderRegistry } from '../provider/index.js';
/**
* 压缩管理器
@@ -41,6 +43,32 @@ export class CompressionManager {
this.summaryModel = model;
}
/**
* 从 Agent 配置设置摘要模型
* @param config Agent 的模型配置
* @param apiKey API Key
* @param baseUrl 可选的 Base URL
*/
setSummaryModelFromAgentConfig(
config: AgentModelConfig,
apiKey: string,
baseUrl?: string
): void {
const registry = getProviderRegistry();
const provider = config.provider || 'anthropic';
const modelName = config.model || 'claude-3-5-haiku-20241022';
try {
const getModel = registry.getModelFactory(provider, {
apiKey,
baseUrl,
});
this.summaryModel = getModel(modelName);
} catch (error) {
console.warn('[CompressionManager] Failed to create summary model:', error);
}
}
/**
* 获取用于摘要生成的模型
* 优先使用专用摘要模型,无则使用主模型